Neue Funktion: Das Datum der letzten änderung würd jetzt unten rechts angezeigt.
Außerdem etwas Code aufgeräumt.
This commit is contained in:
parent
3be67ae665
commit
3dfcf7e237
22
main.go
22
main.go
@ -102,6 +102,7 @@ func main() {
|
|||||||
router := mux.NewRouter()
|
router := mux.NewRouter()
|
||||||
router.HandleFunc("/_api/md/{pagename:.*}", getRawPage).Methods("GET")
|
router.HandleFunc("/_api/md/{pagename:.*}", getRawPage).Methods("GET")
|
||||||
router.HandleFunc("/_api/pdf/{pagename:.*}", getPDFPage).Methods("GET")
|
router.HandleFunc("/_api/pdf/{pagename:.*}", getPDFPage).Methods("GET")
|
||||||
|
router.HandleFunc("/_api/pinfo/{pagename:.*}", getPageInfo).Methods("GET")
|
||||||
router.HandleFunc("/_api/fts/{searchterm:.*}", getFTS).Methods("GET")
|
router.HandleFunc("/_api/fts/{searchterm:.*}", getFTS).Methods("GET")
|
||||||
router.HandleFunc("/{pagename:.*}", getHTMLPage).Methods("GET")
|
router.HandleFunc("/{pagename:.*}", getHTMLPage).Methods("GET")
|
||||||
router.HandleFunc("/{pagename:.*}", postHTMLPage).Methods("POST")
|
router.HandleFunc("/{pagename:.*}", postHTMLPage).Methods("POST")
|
||||||
@ -269,6 +270,27 @@ func getFTS(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getPageInfo(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
|
params := mux.Vars(r)
|
||||||
|
pPageName := params["pagename"] + ".md"
|
||||||
|
|
||||||
|
f, err := os.Open(path.Join(config.DataPath, pPageName))
|
||||||
|
check(err)
|
||||||
|
statinfo, err := f.Stat()
|
||||||
|
check(err)
|
||||||
|
|
||||||
|
data := struct {
|
||||||
|
PageName string
|
||||||
|
ModTime time.Time
|
||||||
|
}{
|
||||||
|
pPageName,
|
||||||
|
statinfo.ModTime(),
|
||||||
|
}
|
||||||
|
|
||||||
|
json.NewEncoder(w).Encode(data)
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
// Typen
|
// Typen
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
|
@ -134,8 +134,7 @@
|
|||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="d-flex flex-row">
|
<div class="d-flex flex-row">
|
||||||
<div id="sidebar" class="p-2 sidebar">
|
<div id="sidebar" class="p-2 sidebar">
|
||||||
<!-- <div id="outputsidebar" style="display: none;">{{.SideBar}}</div> -->
|
<div id="outputsidebar" style="display: none;">{{.SideBar}}</div>
|
||||||
<div id="outputsidebar">{{.SideBar}}</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div id="main" class="p-2 main">
|
<div id="main" class="p-2 main">
|
||||||
<div id="markdowndiv" style="display: none;">{{.MDText}}</div>
|
<div id="markdowndiv" style="display: none;">{{.MDText}}</div>
|
||||||
@ -143,6 +142,7 @@
|
|||||||
<div id="editdiv" style="display: none;">
|
<div id="editdiv" style="display: none;">
|
||||||
<form><textarea id="code" name="code"></textarea>
|
<form><textarea id="code" name="code"></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="ModificationInfos" style="position:fixed;top:98%;right:1%"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -157,13 +157,13 @@
|
|||||||
|
|
||||||
var html = "EMPTY";
|
var html = "EMPTY";
|
||||||
var MD2HTMLConverter = new showdown.Converter({
|
var MD2HTMLConverter = new showdown.Converter({
|
||||||
tables: true,
|
tables: true,
|
||||||
strikethrough: true,
|
strikethrough: true,
|
||||||
simplifiedAutoLink: true,
|
simplifiedAutoLink: true,
|
||||||
excludeTrailingPunctuationFromURLs: true,
|
excludeTrailingPunctuationFromURLs: true,
|
||||||
tasklists: true,
|
tasklists: true,
|
||||||
emoji: true
|
emoji: true
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
@ -172,9 +172,8 @@
|
|||||||
$(btnPreviewpage).hide();
|
$(btnPreviewpage).hide();
|
||||||
|
|
||||||
|
|
||||||
//html = converter.makeHtml($("#outputdiv").html());
|
//-----------------------------------------------------------------------------------
|
||||||
//$("#outputdiv").html(html);
|
// Breadcrump Navigation im Header
|
||||||
|
|
||||||
var breadcrumbHTML = "";
|
var breadcrumbHTML = "";
|
||||||
var sPageURL = window.location.pathname.split('/');
|
var sPageURL = window.location.pathname.split('/');
|
||||||
|
|
||||||
@ -190,7 +189,8 @@
|
|||||||
|
|
||||||
$("#breadcrumb").html(breadcrumbHTML);
|
$("#breadcrumb").html(breadcrumbHTML);
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------------
|
||||||
|
// Codemirror Editor
|
||||||
window.myCodeMirror = CodeMirror.fromTextArea(document.getElementById("code"), {
|
window.myCodeMirror = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||||
mode: 'markdown',
|
mode: 'markdown',
|
||||||
lineNumbers: true,
|
lineNumbers: true,
|
||||||
@ -203,7 +203,8 @@
|
|||||||
window.myCodeMirror.refresh();
|
window.myCodeMirror.refresh();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------------
|
||||||
|
// Laden des Outputdiv (HTML Anzeige des MD-Textes)
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
contentType:'application/json; charset=utf-8',
|
contentType:'application/json; charset=utf-8',
|
||||||
@ -218,7 +219,8 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------------
|
||||||
|
// Laden der sidebar.md in die Sidebar
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
contentType:'application/json; charset=utf-8',
|
contentType:'application/json; charset=utf-8',
|
||||||
@ -232,6 +234,12 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
ajaxLoadModificationInfos(window.location.pathname);
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------------
|
||||||
|
// Volltext-Suche
|
||||||
$('#srch-term').keypress(function (e) {
|
$('#srch-term').keypress(function (e) {
|
||||||
if (e.which == 13) {
|
if (e.which == 13) {
|
||||||
//alert($('#srch-term').val());
|
//alert($('#srch-term').val());
|
||||||
@ -329,6 +337,8 @@
|
|||||||
$(btnEditpage).show();
|
$(btnEditpage).show();
|
||||||
$(btnSavepage).hide();
|
$(btnSavepage).hide();
|
||||||
$(btnPreviewpage).hide();
|
$(btnPreviewpage).hide();
|
||||||
|
|
||||||
|
ajaxLoadModificationInfos(window.location.pathname);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -338,6 +348,23 @@
|
|||||||
window.open('/_api/pdf'+window.location.pathname);
|
window.open('/_api/pdf'+window.location.pathname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ajaxLoadModificationInfos(page) {
|
||||||
|
// Laden des ModificationInfos-Div (Anzeige der letzten Änderung an der Seite)
|
||||||
|
$.ajax({
|
||||||
|
method: "GET",
|
||||||
|
contentType:'application/json; charset=utf-8',
|
||||||
|
url: '/_api/pinfo/'+page,
|
||||||
|
dataType: "json",
|
||||||
|
data: "",
|
||||||
|
success: function(content){
|
||||||
|
//date = new Intl.DateTimeFormat('de-DE').format(new Date(content.ModTime));
|
||||||
|
date = new Date(content.ModTime).toLocaleString('de-DE');
|
||||||
|
$("#ModificationInfos").html("<p><small>Letzte änderung: "+date+"</small></p>");
|
||||||
|
$("#ModificationInfos").show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user