1、新增标签页面

2、优化显示效果
pull/219/head
Minho 2017-07-10 14:54:59 +08:00
parent 47687cc5b1
commit 3a1daba62a
11 changed files with 157 additions and 28 deletions

View File

@ -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 (

View File

@ -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 {

View File

@ -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
}

View File

@ -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")
}

View File

@ -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;

View File

@ -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 = "<ul class=\"pagination\">"
if po.EnableFirstLastLink { //当首页,尾页都设定的时候,就显示
rs += "<li" + judgeDisable(po, totalpages, 0) + " ><a href='" + po.Href + "&" + po.ParamName + "=" + con.Itoa(1) + "'>" + po.FirstPageText + "</a></li>"
if po.EnableFirstLastLink { //当首页,尾页都设定的时候,就显示
if po.CurrentPage == 1 {
rs += "<li" + judgeDisable(po, totalpages, 0) + " class=\"disabled\"><a href=\"###\">" + po.FirstPageText + "</a></li>"
}else{
rs += "<li" + judgeDisable(po, totalpages, 0) + " ><a href='" + po.Href + "&" + po.ParamName + "=" + con.Itoa(1) + "'>" + po.FirstPageText + "</a></li>"
}
}
if po.EnablePreNexLink { // disabled=\"disabled\"
var a int = po.CurrentPage - 1
@ -270,13 +276,14 @@ func getFooter(po *PageOptions, totalpages int) string {
var rs string = ""
if po.EnablePreNexLink {
var a int = po.CurrentPage + 1
if po.CurrentPage == totalpages {
a = totalpages
}
rs += "<li " + judgeDisable(po, totalpages, 1) + " ><a href='" + po.Href + "&" + po.ParamName + "=" + con.Itoa(a) + "'>" + po.NextPageText + "</a></li>"
}
if po.EnableFirstLastLink { //当首页,尾页都设定的时候,就显示
rs += "<li " + judgeDisable(po, totalpages, 1) + " ><a href='" + po.Href + "&" + po.ParamName + "=" + con.Itoa(totalpages) + "'>" + po.LastPageText + "</a></li>"
if po.CurrentPage == totalpages {
rs += "<li " + judgeDisable(po, totalpages, 1) + " class=\"disabled\"><a href=\"###\">" + po.LastPageText + "</a></li>"
}else{
rs += "<li " + judgeDisable(po, totalpages, 1) + " ><a href=\"" + po.Href + "&" + po.ParamName + "=" + con.Itoa(totalpages) + "\">" + po.LastPageText + "</a></li>"
}
}
rs += "</ul>"
return rs

View File

@ -25,7 +25,7 @@
{{template "widgets/header.tpl" .}}
<div class="container manual-body">
<div class="row">
{{if gt (.Labels|len) 0}}
{{if gt (.Labels|len) 1000000}}
<div class="hide tag-container-outer">
<span class="title">热门标签:</span>
<span class="tags">

View File

@ -52,7 +52,7 @@
<div class="clearfix"></div>
</div>
<nav>
<nav class="pagination-container">
{{.PageHtml}}
</nav>
</div>

View File

@ -0,0 +1,54 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>标签列表 - Powered by MinDoc</title>
<meta name="author" content="Minho" />
<meta name="site" content="https://www.iminho.me" />
<!-- Bootstrap -->
<link href="{{cdncss "/static/bootstrap/css/bootstrap.min.css"}}" rel="stylesheet">
<link href="{{cdncss "/static/font-awesome/css/font-awesome.min.css"}}" rel="stylesheet">
<link href="{{cdncss "/static/css/main.css"}}" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="/static/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="/static/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="manual-reader manual-container manual-search-reader">
{{template "widgets/header.tpl" .}}
<div class="container manual-body">
<div class="search-head">
<strong class="search-title">显示标签列表</strong>
</div>
<div class="row">
{{if gt (.Labels|len) 0}}
<div class="hide tag-container-outer" style="border: 0;margin-top: 0;padding: 5px 15px;min-height: 200px;">
<span class="tags">
{{range $index,$item := .Labels}}
<a href="{{urlfor "LabelController.Index" ":key" $item.LabelName}}">{{$item.LabelName}}<span class="detail">{{$item.BookNumber}}</span></a>
{{end}}
</span>
</div>
{{end}}
<nav class="pagination-container">
{{if gt .TotalPages 1}}
{{.PageHtml}}
{{end}}
<div class="clearfix"></div>
</nav>
</div>
</div>
{{template "widgets/footer.tpl" .}}
</div>
<script src="{{cdnjs "/static/jquery/1.12.4/jquery.min.js"}}" type="text/javascript"></script>
<script src="{{cdnjs "/static/bootstrap/js/bootstrap.min.js"}}" type="text/javascript"></script>
</body>
</html>

View File

@ -72,7 +72,7 @@
{{end}}
</tbody>
</table>
<nav>
<nav class="pagination-container">
{{.PageHtml}}
</nav>
</div>

View File

@ -8,14 +8,26 @@
{{.SITE_NAME}}
{{end}}
</a>
<div class="searchbar pull-left visible-lg-inline-block visible-md-inline-block">
<form class="form-inline" action="{{urlfor "SearchController.Index"}}" method="get">
<input class="form-control" name="keyword" type="search" style="width: 230px;" placeholder="请输入关键词..." value="{{.Keyword}}">
<button class="search-btn">
<i class="fa fa-search"></i>
</button>
</form>
</div>
<nav class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li>
<a href="{{urlfor "HomeController.Index" }}" title="首页">首页</a>
</li>
<li>
<a href="{{urlfor "LabelController.List" }}" title="标签">标签</a>
</li>
</ul>
<div class="searchbar pull-left visible-lg-inline-block visible-md-inline-block">
<form class="form-inline" action="{{urlfor "SearchController.Index"}}" method="get">
<input class="form-control" name="keyword" type="search" style="width: 230px;" placeholder="请输入关键词..." value="{{.Keyword}}">
<button class="search-btn">
<i class="fa fa-search"></i>
</button>
</form>
</div>
</nav>
<div class="btn-group dropdown-menu-right pull-right slidebar visible-xs-inline-block visible-sm-inline-block">
<button class="btn btn-default dropdown-toggle hidden-lg" type="button" data-toggle="dropdown"><i class="fa fa-align-justify"></i></button>