From 3a1daba62a70a30d8fa18b71982bb842ff77d0b4 Mon Sep 17 00:00:00 2001 From: Minho Date: Mon, 10 Jul 2017 14:54:59 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=96=B0=E5=A2=9E=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=202=E3=80=81=E4=BC=98=E5=8C=96=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/enumerate.go | 2 +- controllers/document.go | 3 ++ controllers/label.go | 39 +++++++++++++++++++++++-- routers/router.go | 1 + static/css/main.css | 33 ++++++++++++++++----- utils/pager.go | 19 ++++++++---- views/home/index.tpl | 2 +- views/label/index.tpl | 2 +- views/label/list.tpl | 54 +++++++++++++++++++++++++++++++++++ views/manager/attach_list.tpl | 2 +- views/widgets/header.tpl | 28 ++++++++++++------ 11 files changed, 157 insertions(+), 28 deletions(-) create mode 100644 views/label/list.tpl diff --git a/conf/enumerate.go b/conf/enumerate.go index 96c3a9c9..4b2e2049 100644 --- a/conf/enumerate.go +++ b/conf/enumerate.go @@ -19,7 +19,7 @@ const RegexpEmail = `^(\w)+(\.\w+)*@(\w)+((\.\w+)+)$` const RegexpAccount = `^[a-zA-Z][a-zA-z0-9\.]{2,50}$` // PageSize 默认分页条数. -const PageSize = 15 +const PageSize = 5 // 用户权限 const ( diff --git a/controllers/document.go b/controllers/document.go index 2760bacd..e4728bc3 100644 --- a/controllers/document.go +++ b/controllers/document.go @@ -768,6 +768,9 @@ func (c *DocumentController) Export() { } else { bookResult = isReadable(identify, token, c) } + if bookResult.PrivatelyOwned == 0 { + //TODO 私有项目禁止导出 + } docs, err := models.NewDocument().FindListByBookId(bookResult.BookId) if err != nil { diff --git a/controllers/label.go b/controllers/label.go index c2fe653f..ca36fe66 100644 --- a/controllers/label.go +++ b/controllers/label.go @@ -6,21 +6,27 @@ import ( "github.com/astaxie/beego" "github.com/lifei6671/mindoc/conf" "github.com/lifei6671/mindoc/utils" + "math" ) type LabelController struct { BaseController } -func (c *LabelController) Index() { - c.Prepare() - c.TplName = "label/index.tpl" +func (c *LabelController) Prepare() { + c.BaseController.Prepare() //如果没有开启你们访问则跳转到登录 if !c.EnableAnonymous && c.Member == nil { c.Redirect(beego.URLFor("AccountController.Login"),302) return } +} + +//查看包含标签的文档列表. +func (c *LabelController) Index() { + c.Prepare() + c.TplName = "label/index.tpl" labelName := c.Ctx.Input.Param(":key") pageIndex,_ := c.GetInt("page",1) @@ -58,3 +64,30 @@ func (c *LabelController) Index() { c.Data["LabelName"] = labelName } + +func (c *LabelController) List() { + c.Prepare() + c.TplName = "label/list.tpl" + + pageIndex,_ := c.GetInt("page",1) + pageSize := 200 + + labels ,totalCount,err := models.NewLabel().FindToPager(pageIndex,pageSize) + + if err != nil { + c.ShowErrorPage(50001,err.Error()) + } + if totalCount > 0 { + html := utils.GetPagerHtml(c.Ctx.Request.RequestURI, pageIndex, pageSize, totalCount) + + c.Data["PageHtml"] = html + }else { + c.Data["PageHtml"] = "" + } + c.Data["TotalPages"] = int(math.Ceil(float64(totalCount) / float64(pageSize))) + + c.Data["Labels"] = labels +} + + + diff --git a/routers/router.go b/routers/router.go index 880ec872..e94d4261 100644 --- a/routers/router.go +++ b/routers/router.go @@ -85,5 +85,6 @@ func init() { beego.Router("/search",&controllers.SearchController{},"get:Index") beego.Router("/tag/:key", &controllers.LabelController{},"get:Index") + beego.Router("/tags", &controllers.LabelController{},"get:List") } diff --git a/static/css/main.css b/static/css/main.css index 0d24e3ac..aa086a95 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -249,13 +249,24 @@ textarea{ height: 231px; position: relative; } +.manual-list .list-item .manual-item-standard>dt>a { + display: block; + position: relative; + width: 100%; +} +.manual-list .list-item .manual-item-standard>dt>a .image{ + position: relative; + /*display: none;*/ +} .manual-list .list-item .manual-item-standard .cover { - border: 1px solid #999999; + border: none; width: 171px; position: relative; display: inline-block; height: 229px; - background-color: #eee + background-color: #eee; + border-radius: 2px; + box-shadow: 0 1px 3px 0 #d4d4d5, 0 0 0 1px #d4d4d5; } .manual-list .list-item .manual-item-standard .b-cover:hover { border-color: #4db559; @@ -562,19 +573,27 @@ textarea{ .pagination-container { margin: 5px auto; - text-align: center !important; display: block !important; } +.pagination-container .pagination{ + box-shadow: 0 1px 2px 0 #e3e3e0; +} .pagination-container .pagination>li>a,.pagination-container .pagination>li>span{ - padding: 4px 9px !important; + padding: 8px 16px !important; } .pagination-container .pagination>li>a,.pagination-container .pagination>li>span{ - color: #333; + color: #272727; } .pagination-container .pagination>.active>a{ - color: #fff; + /*color: #fff;*/ + background-color: #f3f3f3; + border: 1px solid #e3e3e0; } - /**************网站底部样式*************************/ +.pagination-container .pagination>.active>a, .pagination>.active>a:focus, .pagination>.active>a:hover, .pagination>.active>span, .pagination>.active>span:focus, .pagination>.active>span:hover{ + color: #272727; +} + +/**************网站底部样式*************************/ .footer{ color: #777; padding: 30px 0; diff --git a/utils/pager.go b/utils/pager.go index 1dcf7349..1a9ec51e 100644 --- a/utils/pager.go +++ b/utils/pager.go @@ -25,6 +25,7 @@ type PageOptions struct { NextPageText string //下一页文字 默认"下一页" EnableFirstLastLink bool //是否启用首尾连接 默认false 建议开启 EnablePreNexLink bool //是否启用上一页,下一页连接 默认false 建议开启 + TotalPages int } /** @@ -99,6 +100,7 @@ func GetPagerHtml(requestURI string,pageIndex, pageSize,totalCount int) (html.HT PageSize: pageSize, EnableFirstLastLink : true, ParamName : "page", + TotalPages:int(math.Ceil(float64(totalCount) / float64(pageSize))), } totalPages := int(math.Ceil(float64(totalCount) / float64(pageSize))) @@ -249,9 +251,13 @@ func fun1(po *PageOptions, totalpages int) string { */ func getHeader(po *PageOptions, totalpages int) string { var rs string = "" return rs diff --git a/views/home/index.tpl b/views/home/index.tpl index e1025817..cdff6e28 100644 --- a/views/home/index.tpl +++ b/views/home/index.tpl @@ -25,7 +25,7 @@ {{template "widgets/header.tpl" .}}
- {{if gt (.Labels|len) 0}} + {{if gt (.Labels|len) 1000000}}
热门标签: diff --git a/views/label/index.tpl b/views/label/index.tpl index f7ecbdd6..b3f6ec1e 100644 --- a/views/label/index.tpl +++ b/views/label/index.tpl @@ -52,7 +52,7 @@
-
diff --git a/views/label/list.tpl b/views/label/list.tpl new file mode 100644 index 00000000..057d54c4 --- /dev/null +++ b/views/label/list.tpl @@ -0,0 +1,54 @@ + + + + + + + + 标签列表 - Powered by MinDoc + + + + + + + + + + + + +
+ {{template "widgets/header.tpl" .}} +
+
+ 显示标签列表 +
+
+ {{if gt (.Labels|len) 0}} +
+ + {{range $index,$item := .Labels}} + {{$item.LabelName}}{{$item.BookNumber}} + {{end}} + +
+ + {{end}} + +
+
+ {{template "widgets/footer.tpl" .}} +
+ + + + \ No newline at end of file diff --git a/views/manager/attach_list.tpl b/views/manager/attach_list.tpl index b585976d..000c5c89 100644 --- a/views/manager/attach_list.tpl +++ b/views/manager/attach_list.tpl @@ -72,7 +72,7 @@ {{end}} -
diff --git a/views/widgets/header.tpl b/views/widgets/header.tpl index 8082d351..1cc6be77 100644 --- a/views/widgets/header.tpl +++ b/views/widgets/header.tpl @@ -8,14 +8,26 @@ {{.SITE_NAME}} {{end}} - + + +