mirror of https://github.com/mindoc-org/mindoc.git
parent
cb3d1fdd10
commit
1ec965a2d1
|
@ -186,11 +186,13 @@ func (c *DocumentController) Read() {
|
||||||
Body string `json:"body"`
|
Body string `json:"body"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
DocInfo string `json:"doc_info"`
|
DocInfo string `json:"doc_info"`
|
||||||
|
Version int64 `json:"version"`
|
||||||
}
|
}
|
||||||
data.DocTitle = doc.DocumentName
|
data.DocTitle = doc.DocumentName
|
||||||
data.Body = doc.Release
|
data.Body = doc.Release
|
||||||
data.Title = doc.DocumentName + " - Powered by MinDoc"
|
data.Title = doc.DocumentName + " - Powered by MinDoc"
|
||||||
data.DocInfo = docInfo
|
data.DocInfo = docInfo
|
||||||
|
data.Version = doc.Version
|
||||||
|
|
||||||
c.JsonResult(0, "ok", data)
|
c.JsonResult(0, "ok", data)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,9 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"html/template"
|
"html/template"
|
||||||
"math"
|
"math"
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"github.com/astaxie/beego/orm"
|
"github.com/astaxie/beego/orm"
|
||||||
"github.com/lifei6671/mindoc/conf"
|
"github.com/lifei6671/mindoc/conf"
|
||||||
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DocumentTree struct {
|
type DocumentTree struct {
|
||||||
|
@ -116,11 +115,7 @@ func getDocumentTree(array []*DocumentTree, parentId int, selectedId int, select
|
||||||
if item.DocumentId == selectedParentId || (item.State != nil && item.State.Opened) {
|
if item.DocumentId == selectedParentId || (item.State != nil && item.State.Opened) {
|
||||||
selectedLi = ` class="jstree-open"`
|
selectedLi = ` class="jstree-open"`
|
||||||
}
|
}
|
||||||
buf.WriteString("<li id=\"")
|
buf.WriteString(fmt.Sprintf("<li id=\"%d\"%s><a href=\"",item.DocumentId,selectedLi))
|
||||||
buf.WriteString(strconv.Itoa(item.DocumentId))
|
|
||||||
buf.WriteString("\"")
|
|
||||||
buf.WriteString(selectedLi)
|
|
||||||
buf.WriteString("><a href=\"")
|
|
||||||
if item.Identify != "" {
|
if item.Identify != "" {
|
||||||
uri := conf.URLFor("DocumentController.Read", ":key", item.BookIdentify, ":id", item.Identify)
|
uri := conf.URLFor("DocumentController.Read", ":key", item.BookIdentify, ":id", item.Identify)
|
||||||
buf.WriteString(uri)
|
buf.WriteString(uri)
|
||||||
|
@ -128,10 +123,9 @@ func getDocumentTree(array []*DocumentTree, parentId int, selectedId int, select
|
||||||
uri := conf.URLFor("DocumentController.Read", ":key", item.BookIdentify, ":id", item.DocumentId)
|
uri := conf.URLFor("DocumentController.Read", ":key", item.BookIdentify, ":id", item.DocumentId)
|
||||||
buf.WriteString(uri)
|
buf.WriteString(uri)
|
||||||
}
|
}
|
||||||
buf.WriteString("\" title=\"")
|
buf.WriteString(fmt.Sprintf("\" title=\"%s\"",template.HTMLEscapeString(item.DocumentName)))
|
||||||
buf.WriteString(template.HTMLEscapeString(item.DocumentName) + "\"")
|
buf.WriteString(fmt.Sprintf(" data-version=\"%d\"%s>%s</a>",item.Version,selected,template.HTMLEscapeString(item.DocumentName)))
|
||||||
buf.WriteString(selected + ">")
|
|
||||||
buf.WriteString(template.HTMLEscapeString(item.DocumentName) + "</a>")
|
|
||||||
|
|
||||||
for _, sub := range array {
|
for _, sub := range array {
|
||||||
if p, ok := sub.ParentId.(int); ok && p == item.DocumentId {
|
if p, ok := sub.ParentId.(int); ok && p == item.DocumentId {
|
||||||
|
|
|
@ -498,6 +498,7 @@
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var settings = this.settings;
|
var settings = this.settings;
|
||||||
var loadPath = settings.path;
|
var loadPath = settings.path;
|
||||||
|
var isLoadedDisplay = false;
|
||||||
|
|
||||||
var loadFlowChartOrSequenceDiagram = function() {
|
var loadFlowChartOrSequenceDiagram = function() {
|
||||||
|
|
||||||
|
@ -507,6 +508,8 @@
|
||||||
|
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (settings.mermaid) {
|
if (settings.mermaid) {
|
||||||
editormd.loadCSS(loadPath + "mermaid/mermaid", function () {
|
editormd.loadCSS(loadPath + "mermaid/mermaid", function () {
|
||||||
editormd.loadScript(loadPath + "mermaid/mermaid.min", function () {
|
editormd.loadScript(loadPath + "mermaid/mermaid.min", function () {
|
||||||
|
@ -544,7 +547,11 @@
|
||||||
return d.getFullYear();
|
return d.getFullYear();
|
||||||
}]]
|
}]]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!isLoadedDisplay){
|
||||||
|
isLoadedDisplay = true;
|
||||||
_this.loadedDisplay();
|
_this.loadedDisplay();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -553,7 +560,10 @@
|
||||||
editormd.loadScript(loadPath + "raphael.min", function() {
|
editormd.loadScript(loadPath + "raphael.min", function() {
|
||||||
editormd.loadScript(loadPath + "flowchart.min", function() {
|
editormd.loadScript(loadPath + "flowchart.min", function() {
|
||||||
editormd.loadScript(loadPath + "jquery.flowchart.min", function() {
|
editormd.loadScript(loadPath + "jquery.flowchart.min", function() {
|
||||||
|
if (!isLoadedDisplay){
|
||||||
|
isLoadedDisplay = true;
|
||||||
_this.loadedDisplay();
|
_this.loadedDisplay();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -565,7 +575,10 @@
|
||||||
editormd.loadScript(loadPath + "sequence/snap.svg-min", function() {
|
editormd.loadScript(loadPath + "sequence/snap.svg-min", function() {
|
||||||
editormd.loadScript(loadPath + "sequence/underscore-min", function() {
|
editormd.loadScript(loadPath + "sequence/underscore-min", function() {
|
||||||
editormd.loadScript(loadPath + "sequence/sequence-diagram-min", function() {
|
editormd.loadScript(loadPath + "sequence/sequence-diagram-min", function() {
|
||||||
|
if (!isLoadedDisplay){
|
||||||
|
isLoadedDisplay = true;
|
||||||
_this.loadedDisplay();
|
_this.loadedDisplay();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -42,8 +42,9 @@ $(function () {
|
||||||
};
|
};
|
||||||
this.addKeyMap(keyMap);
|
this.addKeyMap(keyMap);
|
||||||
|
|
||||||
|
console.log("加载完成")
|
||||||
uploadImage("docEditor", function ($state, $res) {
|
uploadImage("docEditor", function ($state, $res) {
|
||||||
|
console.log("注册上传图片")
|
||||||
if ($state === "before") {
|
if ($state === "before") {
|
||||||
return layer.load(1, {
|
return layer.load(1, {
|
||||||
shade: [0.1, '#fff'] // 0.1 透明度的白色背景
|
shade: [0.1, '#fff'] // 0.1 透明度的白色背景
|
||||||
|
|
|
@ -73,8 +73,9 @@ function loadDocument($url, $id, $callback) {
|
||||||
if(data) {
|
if(data) {
|
||||||
if (typeof $callback === "function") {
|
if (typeof $callback === "function") {
|
||||||
data.body = $callback(data.body);
|
data.body = $callback(data.body);
|
||||||
|
}else if(data.version && data.version != $callback){
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#page-content").html(data.body);
|
$("#page-content").html(data.body);
|
||||||
$("title").text(data.title);
|
$("title").text(data.title);
|
||||||
$("#article-title").text(data.doc_title);
|
$("#article-title").text(data.doc_title);
|
||||||
|
@ -172,7 +173,7 @@ $(function () {
|
||||||
}
|
}
|
||||||
}).on('select_node.jstree', function (node, selected, event) {
|
}).on('select_node.jstree', function (node, selected, event) {
|
||||||
$(".m-manual").removeClass('manual-mobile-show-left');
|
$(".m-manual").removeClass('manual-mobile-show-left');
|
||||||
loadDocument(selected.node.a_attr.href, selected.node.id);
|
loadDocument(selected.node.a_attr.href, selected.node.id,selected.node.a_attr['data-version']);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#slidebar").on("click", function () {
|
$("#slidebar").on("click", function () {
|
||||||
|
|
Loading…
Reference in New Issue