Config Controller eingebaut um Such-Textbox und Logout-Button nur anzuzeigen, wenn diese in der Config eingeschaltet sind
This commit is contained in:
parent
d7e91ebdba
commit
98be2f6c6d
24
main.go
24
main.go
@ -138,6 +138,7 @@ func main() {
|
|||||||
router.HandleFunc("/_api/pdf/{pagename:.*}", basicAuth(getPDFPage)).Methods("GET")
|
router.HandleFunc("/_api/pdf/{pagename:.*}", basicAuth(getPDFPage)).Methods("GET")
|
||||||
router.HandleFunc("/_api/pinfo/{pagename:.*}", basicAuth(getPageInfo)).Methods("GET")
|
router.HandleFunc("/_api/pinfo/{pagename:.*}", basicAuth(getPageInfo)).Methods("GET")
|
||||||
router.HandleFunc("/_api/fts/{searchterm:.*}", basicAuth(getFTS)).Methods("GET")
|
router.HandleFunc("/_api/fts/{searchterm:.*}", basicAuth(getFTS)).Methods("GET")
|
||||||
|
router.HandleFunc("/_api/config", basicAuth(getWikiConfig)).Methods("GET")
|
||||||
router.HandleFunc("/{pagename:.*}", basicAuth(getHTMLPage)).Methods("GET")
|
router.HandleFunc("/{pagename:.*}", basicAuth(getHTMLPage)).Methods("GET")
|
||||||
router.HandleFunc("/{pagename:.*}", basicAuth(postHTMLPage)).Methods("POST")
|
router.HandleFunc("/{pagename:.*}", basicAuth(postHTMLPage)).Methods("POST")
|
||||||
|
|
||||||
@ -330,6 +331,29 @@ func getPageInfo(w http.ResponseWriter, r *http.Request) {
|
|||||||
json.NewEncoder(w).Encode(data)
|
json.NewEncoder(w).Encode(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getWikiConfig(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
|
FTS := false
|
||||||
|
Login := false
|
||||||
|
|
||||||
|
if config.DataPathFTS != "" {
|
||||||
|
FTS = true
|
||||||
|
}
|
||||||
|
if config.WebUser != "" && config.WebPasswd != "" {
|
||||||
|
Login = true
|
||||||
|
}
|
||||||
|
|
||||||
|
data := struct {
|
||||||
|
FTS bool
|
||||||
|
Login bool
|
||||||
|
}{
|
||||||
|
FTS,
|
||||||
|
Login,
|
||||||
|
}
|
||||||
|
|
||||||
|
json.NewEncoder(w).Encode(data)
|
||||||
|
}
|
||||||
|
|
||||||
func basicAuth(handler http.HandlerFunc) http.HandlerFunc {
|
func basicAuth(handler http.HandlerFunc) http.HandlerFunc {
|
||||||
|
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -124,7 +124,7 @@ mark {
|
|||||||
<li id="btnPreviewpage"><a href="#" onclick="PreviewPage()">Preview</a></li>
|
<li id="btnPreviewpage"><a href="#" onclick="PreviewPage()">Preview</a></li>
|
||||||
<li id="btnSavepage"><a href="#" onclick="SavePage()">Save</a></li>
|
<li id="btnSavepage"><a href="#" onclick="SavePage()">Save</a></li>
|
||||||
<li id="btnPDFgen"><a href="#" onclick="PDFGen()">PDF</a></li>
|
<li id="btnPDFgen"><a href="#" onclick="PDFGen()">PDF</a></li>
|
||||||
<li id="btnPDFgen"><a href="#" onclick="Logout()">Logout</a></li>
|
<li id="btnLogout"><a href="#" onclick="Logout()">Logout</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<form class="navbar-form nav navbar-nav navbar-right" role="search">
|
<form class="navbar-form nav navbar-nav navbar-right" role="search">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
@ -238,6 +238,25 @@ mark {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------------
|
||||||
|
// Laden der Config
|
||||||
|
$.ajax({
|
||||||
|
method: "GET",
|
||||||
|
contentType:'application/json; charset=utf-8',
|
||||||
|
url: '/_api/config',
|
||||||
|
dataType: "json",
|
||||||
|
data: "",
|
||||||
|
success: function(data){
|
||||||
|
if(!data.FTS) {
|
||||||
|
$("#srch-term").hide();
|
||||||
|
}
|
||||||
|
if(!data.Login)
|
||||||
|
{
|
||||||
|
$("#btnLogout").hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------
|
||||||
|
|
||||||
ajaxLoadModificationInfos(window.location.pathname);
|
ajaxLoadModificationInfos(window.location.pathname);
|
||||||
|
Loading…
Reference in New Issue
Block a user