54
54
`
55
55
)
56
56
57
- //DocumentController struct.
57
+ // DocumentController struct.
58
58
type DocumentController struct {
59
59
BaseController
60
60
}
@@ -93,7 +93,7 @@ func parseGitCommit(str string) (cont, commit string) {
93
93
return
94
94
}
95
95
96
- //判断用户是否可以阅读文档.
96
+ // 判断用户是否可以阅读文档.
97
97
func isReadable (identify , token string , this * DocumentController ) * models.BookResult {
98
98
book , err := models .NewBook ().FindByFieldFirst ("identify" , identify )
99
99
if err != nil {
@@ -153,7 +153,7 @@ func isReadable(identify, token string, this *DocumentController) *models.BookRe
153
153
return bookResult
154
154
}
155
155
156
- //文档首页.
156
+ // 文档首页.
157
157
func (this * DocumentController ) Index () {
158
158
identify := this .Ctx .Input .Param (":key" )
159
159
if identify == "" {
@@ -210,7 +210,7 @@ func (this *DocumentController) Index() {
210
210
this .Data ["RelateBooks" ] = models .NewRelateBook ().Lists (bookResult .BookId )
211
211
}
212
212
213
- //文档首页.
213
+ // 文档首页.
214
214
func (this * DocumentController ) indexWithPassword () {
215
215
identify := this .Ctx .Input .Param (":key" )
216
216
if identify == "" {
@@ -226,7 +226,7 @@ func (this *DocumentController) indexWithPassword() {
226
226
this .Data ["Identify" ] = identify
227
227
}
228
228
229
- //阅读文档.
229
+ // 阅读文档.
230
230
func (this * DocumentController ) Read () {
231
231
232
232
identify := this .Ctx .Input .Param (":key" )
@@ -477,6 +477,7 @@ func (this *DocumentController) Read() {
477
477
if wd := this .GetString ("wd" ); strings .TrimSpace (wd ) != "" {
478
478
this .Data ["Keywords" ] = models .NewElasticSearchClient ().SegWords (wd )
479
479
}
480
+ this .Data ["IsThemeDark" ] = this .Ctx .GetCookie ("theme-dark" ) == "true"
480
481
this .Data ["Bookmark" ] = existBookmark
481
482
this .Data ["Model" ] = bookResult
482
483
this .Data ["Book" ] = bookResult //文档下载需要用到Book变量
@@ -492,7 +493,7 @@ func (this *DocumentController) Read() {
492
493
this .Data ["Percent" ] = percent
493
494
}
494
495
495
- //编辑文档.
496
+ // 编辑文档.
496
497
func (this * DocumentController ) Edit () {
497
498
docId := 0 // 文档id
498
499
@@ -563,7 +564,7 @@ func (this *DocumentController) Edit() {
563
564
}
564
565
}
565
566
566
- //创建一个文档.
567
+ // 创建一个文档.
567
568
func (this * DocumentController ) Create () {
568
569
identify := this .GetString ("identify" ) //书籍书籍标识
569
570
docIdentify := this .GetString ("doc_identify" ) //新建的文档标识
@@ -663,7 +664,7 @@ func (this *DocumentController) Create() {
663
664
this .JsonResult (0 , "ok" , document )
664
665
}
665
666
666
- //批量创建文档
667
+ // 批量创建文档
667
668
func (this * DocumentController ) CreateMulti () {
668
669
bookId , _ := this .GetInt ("book_id" )
669
670
@@ -708,7 +709,7 @@ func (this *DocumentController) CreateMulti() {
708
709
this .JsonResult (0 , "添加成功" )
709
710
}
710
711
711
- //上传附件或图片.
712
+ // 上传附件或图片.
712
713
func (this * DocumentController ) Upload () {
713
714
identify := this .GetString ("identify" )
714
715
docId , _ := this .GetInt ("doc_id" )
@@ -866,7 +867,7 @@ func (this *DocumentController) Upload() {
866
867
this .StopRun ()
867
868
}
868
869
869
- //DownloadAttachment 下载附件.
870
+ // DownloadAttachment 下载附件.
870
871
func (this * DocumentController ) DownloadAttachment () {
871
872
identify := this .Ctx .Input .Param (":key" )
872
873
attachId , _ := strconv .Atoi (this .Ctx .Input .Param (":attach_id" ))
@@ -919,7 +920,7 @@ func (this *DocumentController) DownloadAttachment() {
919
920
this .StopRun ()
920
921
}
921
922
922
- //删除附件.
923
+ // 删除附件.
923
924
func (this * DocumentController ) RemoveAttachment () {
924
925
attachId , _ := this .GetInt ("attach_id" )
925
926
if attachId <= 0 {
@@ -958,7 +959,7 @@ func (this *DocumentController) RemoveAttachment() {
958
959
this .JsonResult (0 , "ok" , attach )
959
960
}
960
961
961
- //删除文档.
962
+ // 删除文档.
962
963
func (this * DocumentController ) Delete () {
963
964
964
965
identify := this .GetString ("identify" )
@@ -1222,7 +1223,7 @@ func (this *DocumentController) Content() {
1222
1223
1223
1224
}
1224
1225
1225
- //导出文件
1226
+ // 导出文件
1226
1227
func (this * DocumentController ) ExportOld () {
1227
1228
wecode := strings .TrimSpace (this .GetString ("wecode" ))
1228
1229
if wecode == "" && (this .Member == nil || this .Member .MemberId == 0 ) {
@@ -1286,7 +1287,7 @@ func (this *DocumentController) ExportOld() {
1286
1287
this .JsonResult (1 , "下载失败,您要下载的书籍当前并未生成可下载的电子书。" )
1287
1288
}
1288
1289
1289
- //导出文件
1290
+ // 导出文件
1290
1291
func (this * DocumentController ) Export () {
1291
1292
wecode := strings .TrimSpace (this .GetString ("wecode" ))
1292
1293
if wecode == "" && (this .Member == nil || this .Member .MemberId == 0 ) {
@@ -1389,7 +1390,7 @@ func (this *DocumentController) QrCode() {
1389
1390
}
1390
1391
}
1391
1392
1392
- //书籍内搜索.
1393
+ // 书籍内搜索.
1393
1394
func (this * DocumentController ) Search () {
1394
1395
identify := this .Ctx .Input .Param (":key" )
1395
1396
token := this .GetString ("token" )
@@ -1443,7 +1444,7 @@ func (this *DocumentController) Search() {
1443
1444
}
1444
1445
}
1445
1446
1446
- //文档历史列表.
1447
+ // 文档历史列表.
1447
1448
func (this * DocumentController ) History () {
1448
1449
1449
1450
this .TplName = "document/history.html"
@@ -1667,7 +1668,7 @@ func (this *DocumentController) Compare() {
1667
1668
this .Data ["Content" ] = ModelStore .GetFiledById (doc .DocumentId , "markdown" )
1668
1669
}
1669
1670
1670
- //递归生成文档序列数组.
1671
+ // 递归生成文档序列数组.
1671
1672
func RecursiveFun (parentId int , prefix , dpath string , this * DocumentController , book * models.BookResult , docs []* models.Document , paths * list.List ) {
1672
1673
for _ , item := range docs {
1673
1674
if item .ParentId == parentId {
0 commit comments