Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3ff1244

Browse files
author
xuxinhua
committed
1. 提取评论框公共部分;评论框放在下面
2. 增加标准库中文版入口
1 parent cd90761 commit 3ff1244

File tree

25 files changed

+399
-306
lines changed

25 files changed

+399
-306
lines changed

websites/code/studygolang/src/controller/article.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func ArticleDetailHandler(rw http.ResponseWriter, req *http.Request) {
127127
article.Viewnum++
128128

129129
// 设置内容模板
130-
req.Form.Set(filter.CONTENT_TPL_KEY, "/template/articles/detail.html")
130+
req.Form.Set(filter.CONTENT_TPL_KEY, "/template/articles/detail.html,/template/common/comment.html")
131131
// 设置模板数据
132132
filter.SetData(req, map[string]interface{}{"activeArticles": "active", "article": article, "prev": prevNext[0], "next": prevNext[1], "likeflag": likeFlag, "hadcollect": hadCollect})
133133
}

websites/code/studygolang/src/controller/index.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,11 @@ func WRHandler(rw http.ResponseWriter, req *http.Request) {
111111
// 设置模板数据
112112
filter.SetData(req, map[string]interface{}{"url": tUrl})
113113
}
114+
115+
// PkgdocHandler Go 语言文档中文版
116+
func PkgdocHandler(rw http.ResponseWriter, req *http.Request) {
117+
// 设置内容模板
118+
req.Form.Set(filter.CONTENT_TPL_KEY, "/template/pkgdoc.html")
119+
// 设置模板数据
120+
filter.SetData(req, map[string]interface{}{"activeDoc": "active"})
121+
}

websites/code/studygolang/src/controller/project.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func ProjectDetailHandler(rw http.ResponseWriter, req *http.Request) {
173173
// 为了阅读数即时看到
174174
project.Viewnum++
175175

176-
req.Form.Set(filter.CONTENT_TPL_KEY, "/template/projects/detail.html")
176+
req.Form.Set(filter.CONTENT_TPL_KEY, "/template/projects/detail.html,/template/common/comment.html")
177177
filter.SetData(req, map[string]interface{}{"activeProjects": "active", "project": project, "likeflag": likeFlag, "hadcollect": hadCollect})
178178
}
179179

websites/code/studygolang/src/controller/resource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func ResourceDetailHandler(rw http.ResponseWriter, req *http.Request) {
7373

7474
service.Views.Incr(req, model.TYPE_RESOURCE, util.MustInt(vars["id"]))
7575

76-
req.Form.Set(filter.CONTENT_TPL_KEY, "/template/resources/detail.html")
76+
req.Form.Set(filter.CONTENT_TPL_KEY, "/template/resources/detail.html,/template/common/comment.html")
7777
filter.SetData(req, map[string]interface{}{"activeResources": "active", "resource": resource, "comments": comments, "likeflag": likeFlag, "hadcollect": hadCollect})
7878
}
7979

websites/code/studygolang/src/controller/topic.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func TopicDetailHandler(rw http.ResponseWriter, req *http.Request) {
9696
service.Views.Incr(req, model.TYPE_TOPIC, util.MustInt(vars["tid"]))
9797

9898
// 设置内容模板
99-
req.Form.Set(filter.CONTENT_TPL_KEY, "/template/topics/detail.html")
99+
req.Form.Set(filter.CONTENT_TPL_KEY, "/template/topics/detail.html,/template/common/comment.html")
100100
// 设置模板数据
101101
filter.SetData(req, map[string]interface{}{"activeTopics": "active", "topic": topic, "replies": replies, "likeflag": likeFlag, "hadcollect": hadCollect})
102102
}

websites/code/studygolang/src/server/studygolang/router.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func initRouter() *mux.Router {
3333

3434
router.HandleFunc("/", IndexHandler)
3535
router.HandleFunc("/wr", WRHandler)
36+
router.HandleFunc("/pkgdoc", PkgdocHandler)
3637

3738
router.HandleFunc("/topics{view:(|/popular|/no_reply|/last)}", TopicsHandler)
3839
router.HandleFunc("/topics/{tid:[0-9]+}", TopicDetailHandler)

websites/code/studygolang/static/css/main.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ html, body { background: #F2F2F2; font-family: "Helvetica Neue", Helvetica, Aria
165165
.page .page-comment .submit .sub ul { padding-left: 30px; font-size:13px; line-height: 13px;}
166166
.page .page-comment .submit .sub .btn {padding: 6px 22px;}
167167
.page .page-comment .content-preview { margin-bottom: 5px; width: 100%;height: 200px;border: 1px solid #CCCCCC;border-radius: 3px 3px 3px 3px;-moz-border-radius: 3px 3px 3px 3px;display: none;padding: 4px;overflow: scroll; display: none; }
168-
.page .page-comment .words {padding-bottom: 20px;}
168+
.page .page-comment .words {/*padding-bottom: 20px;*/}
169169
.page .page-comment .words h3 {font-size: 14px;color: #999999;height: 40px;line-height: 40px;border-bottom: solid 1px #ECECEC;position: relative;margin-top: 4px;font-weight: normal;margin-bottom: 0px;}
170170
.page .page-comment .words h3 span {color: #A2442F;padding: 0 3px;}
171171
.page .page-comment .words ul li {padding: 20px 0 8px;border-bottom: dashed 1px #ECECEC;}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/Users/lingxizaiwo/project/golang/pkgdoc/static

websites/code/studygolang/template/admin/topic/list.html

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
{{define "content"}}
22
<div class="pageheader notab">
3-
<h1 class="pagetitle">帖子管理</h1>
4-
<span class="pagedesc">管理网站所有帖子信息</span>
3+
<h1 class="pagetitle">帖子管理</h1>
4+
<span class="pagedesc">管理网站所有帖子信息</span>
55
</div><!--pageheader-->
66

77
<div id="contentwrapper" class="contentwrapper">
88
<form id="queryform" class="stdform_q" action="" method="get">
9-
<div>
10-
<p>
11-
<label>帖子标题</label>
12-
<span class="field"><input type="text" id="q_title" name="title" class="smallinput" value=""/></span>
13-
</p>
14-
</div>
15-
<div>
16-
<p>
17-
<label>创建时间</label>
18-
<span class="field">
19-
<input type="text" id="create_time_min" name="create_time_min" class="smallinput date_time" style="width:80px;" value=""/>
20-
<input type="text" id="create_time_max" name="create_time_max" class="smallinput date_time" style="width:80px;" value=""/>
21-
</span>
22-
</p>
23-
</div>
24-
<div>
25-
<p>
26-
<label>&nbsp;</label>
27-
<span class="field"><button id="queryform_sub" class="submit radius2">查询</button></span>
28-
</p>
29-
</div>
30-
</form>
31-
<div class="contenttitle2">
32-
<h3>数据列表</h3>
9+
<div>
10+
<p>
11+
<label>帖子标题</label>
12+
<span class="field"><input type="text" id="q_title" name="title" class="smallinput" value=""/></span>
13+
</p>
14+
</div>
15+
<div>
16+
<p>
17+
<label>创建时间</label>
18+
<span class="field">
19+
<input type="text" id="create_time_min" name="create_time_min" class="smallinput date_time" style="width:80px;" value=""/>
20+
<input type="text" id="create_time_max" name="create_time_max" class="smallinput date_time" style="width:80px;" value=""/>
21+
</span>
22+
</p>
3323
</div>
34-
<div id="query_result">
35-
{{template "querylist" .}}
24+
<div>
25+
<p>
26+
<label>&nbsp;</label>
27+
<span class="field"><button id="queryform_sub" class="submit radius2">查询</button></span>
28+
</p>
3629
</div>
37-
<img id="loaders" src="/static/img/loaders/loader7.gif" alt="" class="hide">
38-
30+
</form>
31+
<div class="contenttitle2">
32+
<h3>数据列表</h3>
33+
</div>
34+
<div id="query_result">
35+
{{template "querylist" .}}
36+
</div>
37+
<img id="loaders" src="/static/img/loaders/loader7.gif" alt="" class="hide">
38+
3939
</div><!--contentwrapper-->
4040

4141
<br clear="all" />
@@ -45,12 +45,12 @@ <h3>数据列表</h3>
4545
<script type="text/javascript">
4646
// 需要传入下面js的变量定义
4747
var GLOBAL_CONF = {
48-
"action_query" : "/admin/community/topic/query.html",
49-
"query_params" : {
50-
'title' : '#q_title',
51-
'create_time_min' : '#create_time_min',
52-
'create_time_max' : '#create_time_max'
53-
}
48+
"action_query" : "/admin/community/topic/query.html",
49+
"query_params" : {
50+
'title' : '#q_title',
51+
'create_time_min' : '#create_time_min',
52+
'create_time_max' : '#create_time_max'
53+
}
5454
};
5555
</script>
5656
<script type="text/javascript" src="/static/js/admin/datalist.js"></script>

websites/code/studygolang/template/articles/detail.html

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ <h1>{{.article.Title}}</h1>
9090
</div>
9191
<!-- 评论 -->
9292
<div class="page-comment" data-objid="{{.article.Id}}" data-objtype="1" {{if .me}}data-username="{{.me.username}}" data-uid="{{.me.uid}}" data-avatar="{{gravatar .me.avatar .me.email 48}}"{{end}}>
93+
<div class="words hide">
94+
<h3><span class="cmtnum">{{.article.Cmtnum}}</span>条评论</h3>
95+
<ul class="list-unstyled">
96+
</ul>
97+
</div>
9398
<div class="comment-title">
9499
<h2>文章点评:</h2>
95100
{{if .me}}
@@ -98,33 +103,7 @@ <h2>文章点评:</h2>
98103
(您需要 <a class="c-log" href="javascript:openPop('#login-pop');">登录</a> 后才能评论 <a href="/user/register" class="c-reg"> 没有账号</a> ?)</span>
99104
{{end}}
100105
</div>
101-
<div class="row clearfix md-toolbar">
102-
<ul class="col-md-10 list-inline">
103-
<li class="edit cur"><a href="#">编辑</a></li>
104-
<li class="preview"><a href="#">预览</a></li>
105-
</ul>
106-
<div class="col-md-2 text-right">
107-
<i id="upload-img" class="glyphicon glyphicon-picture upload-img tool-tip" data-toggle="tooltip" data-placement="top" title="上传图片"></i>
108-
</div>
109-
</div>
110-
<div class="submit" id="commentForm">
111-
<div class="text">
112-
<textarea name="content" placeholder="我有话要说……" class="main-textarea need-autogrow"></textarea>
113-
</div>
114-
<div class="sub row">
115-
<ul class="help-block col-md-10">
116-
<li class="markdown_tip">支持 Markdown 格式, <strong>**粗体**</strong>、~~删除线~~、<code>`单行代码`</code></li>
117-
<li>支持 @ 本站用户;支持表情(输入 : 提示),见 <a href="http://www.emoji-cheat-sheet.com/" target="_blank">Emoji cheat sheet</a></li>
118-
</ul>
119-
<div class="col-md-2 text-right"><button type="submit" title="提交" class="btn btn-danger">提交</button></div>
120-
</div>
121-
</div>
122-
<div class="content-preview"></div>
123-
<div class="words hide">
124-
<h3><span class="cmtnum">{{.article.Cmtnum}}</span>条评论</h3>
125-
<ul class="list-unstyled">
126-
</ul>
127-
</div>
106+
{{template "comment" .}}
128107
</div>
129108
<!-- 评论 -->
130109
</div>
@@ -155,9 +134,15 @@ <h3><span class="cmtnum">{{.article.Cmtnum}}</span>条评论</h3>
155134
</div>
156135
</div>
157136
</div>
158-
</div>
159137

160-
<div class="col-lg-3 col-md-4 col-sm-5">
138+
<div class="row box_white sidebar">
139+
<script type="text/javascript">
140+
var cpro_id="u1996895";
141+
(window["cproStyleApi"] = window["cproStyleApi"] || {})[cpro_id]={at:"3",rsi0:"291",rsi1:"291",pat:"6",tn:"baiduCustNativeAD",rss1:"#FFFFFF",conBW:"0",adp:"1",ptt:"0",titFF:"%E5%BE%AE%E8%BD%AF%E9%9B%85%E9%BB%91",titFS:"14",rss2:"#000000",titSU:"0",ptbg:"90",piw:"0",pih:"0",ptp:"0"}
142+
</script>
143+
<script src="http://cpro.baidustatic.com/cpro/ui/c.js" type="text/javascript"></script>
144+
</div>
145+
161146
<div class="row box_white sidebar">
162147
<div class="top">
163148
<h3 class="title"><i class="glyphicon glyphicon-fire"></i>&nbsp;<a href="/projects" target="_blank" title="点击更多">开源项目</a></h3>
@@ -170,13 +155,12 @@ <h3 class="title"><i class="glyphicon glyphicon-fire"></i>&nbsp;<a href="/projec
170155
</div>
171156
</div>
172157
</div>
173-
</div>
174158

175-
<div class="col-lg-3 col-md-4 col-sm-5">
176159
<div class="row box_white sidebar">
177160
<a href="http://www.shiyanlou.com/courses/startandgetconsole/698" target="_blank"><img src="http://studygolang.qiniudn.com/ad/shiyanlou_golang_env.jpg" alt="实验环境"></a>
178161
</div>
179162
</div>
163+
180164
</div>
181165
{{end}}
182166
{{define "css"}}

websites/code/studygolang/template/articles/list.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,16 @@ <h2><a href="/articles/{{.Id}}" target="_blank" title="{{.Title}}">{{.Title}}</a
107107
</div>
108108
</div>
109109
</div>
110+
111+
<div class="row box_white sidebar">
112+
<script type="text/javascript">
113+
var cpro_id="u1996895";
114+
(window["cproStyleApi"] = window["cproStyleApi"] || {})[cpro_id]={at:"3",rsi0:"291",rsi1:"291",pat:"6",tn:"baiduCustNativeAD",rss1:"#FFFFFF",conBW:"0",adp:"1",ptt:"0",titFF:"%E5%BE%AE%E8%BD%AF%E9%9B%85%E9%BB%91",titFS:"14",rss2:"#000000",titSU:"0",ptbg:"90",piw:"0",pih:"0",ptp:"0"}
115+
</script>
116+
<script src="http://cpro.baidustatic.com/cpro/ui/c.js" type="text/javascript"></script>
117+
</div>
110118
</div>
119+
111120
</div>
112121
{{end}}
113122
{{define "js"}}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{{define "comment"}}
2+
<div class="row clearfix md-toolbar">
3+
<ul class="col-md-10 list-inline">
4+
<li class="edit cur"><a href="#">编辑</a></li>
5+
<li class="preview"><a href="#">预览</a></li>
6+
</ul>
7+
<div class="col-md-2 text-right">
8+
<i id="upload-img" class="glyphicon glyphicon-picture upload-img tool-tip" data-toggle="tooltip" data-placement="top" title="上传图片"></i>
9+
</div>
10+
</div>
11+
<div class="submit" id="commentForm">
12+
<div class="text">
13+
<textarea name="content" placeholder="我有话要说……" class="main-textarea need-autogrow"></textarea>
14+
</div>
15+
<div class="sub row">
16+
<ul class="help-block col-md-10">
17+
<li class="markdown_tip">支持 Markdown 格式, <strong>**粗体**</strong>、~~删除线~~、<code>`单行代码`</code></li>
18+
<li>支持 @ 本站用户;支持表情(输入 : 提示),见 <a href="http://www.emoji-cheat-sheet.com/" target="_blank">Emoji cheat sheet</a></li>
19+
</ul>
20+
<div class="col-md-2 text-right"><button type="submit" title="提交" class="btn btn-danger">提交</button></div>
21+
</div>
22+
</div>
23+
<div class="content-preview"></div>
24+
{{end}}

websites/code/studygolang/template/common/layout.html

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<!--<link href="http://maxcdn.bootstrapcdn.com/bootswatch/3.2.0/cosmo/bootstrap.min.css" rel="stylesheet">-->
1313
<link href="http://studygolang.qiniudn.com/cosmo_bootstrap.min.css" rel="stylesheet">
1414
<!--<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css" rel="stylesheet">-->
15-
<link href="/static/css/main.css?v=1.0" rel="stylesheet"/>
15+
<link href="/static/css/main.css?v=1.1" rel="stylesheet"/>
1616
{{template "css"}}
1717
</head>
1818
<body>
@@ -40,7 +40,7 @@
4040
</ul>
4141
</li>
4242
<li class="{{.activeProjects}}">
43-
<a href="/projects">开源项目<i class="newfuture"></i></a>
43+
<a href="/projects">开源项目</a>
4444
</li>
4545
<li class="{{.activeResources}}">
4646
<a href="/resources">资源</a>
@@ -52,15 +52,21 @@
5252
<li><a href="/readings?rtype=1">综合晨读</a></li>
5353
</ul>
5454
</li>
55-
<li class="dropdown">
56-
<a class="dropdown-toggle" data-toggle="dropdown" href="#" id="docs">官方文档 <span class="caret"></span></a>
55+
<li class="dropdown {{.activeDoc}}">
56+
<a class="dropdown-toggle" data-toggle="dropdown" href="#" id="docs">官方文档<i class="newfuture"></i> <span class="caret"></span></a>
5757
<ul class="dropdown-menu" aria-labelledby="docs">
5858
<li><a href="http://docs.studygolang.com" target="_blank">英文文档</a></li>
5959
<li><a href="http://docscn.studygolang.com" target="_blank">中文文档</a></li>
60+
<li><a href="/pkgdoc">标准库中文版</a></li>
6061
<li role="presentation" class="divider"></li>
6162
<li><a href="http://tour.studygolang.com" target="_blank">Go指南</a></li>
6263
</ul>
6364
</li>
65+
<!--
66+
<li class="{{.activeWide}}">
67+
<a href="/wide/playground">游乐场</a>
68+
</li>
69+
-->
6470
</ul>
6571
<form class="navbar-form navbar-left" action="/search" role="search" target="_blank">
6672
<input type="text" name="q" class="form-control search-query" placeholder="搜索" value="{{if .q}}{{.q}}{{end}}">
@@ -70,9 +76,6 @@
7076
<li>
7177
<a href="/message/system" id="user_message_count"><span class="badge{{if .me.msgnum}} badge-warning{{end}}">{{.me.msgnum}}</span></a>
7278
</li>
73-
<li>
74-
<a href="/project/new">发布项目</a>
75-
</li>
7679
<li class="dropdown" id="user_menu">
7780
<a href="#user_menu" class="dropdown-toggle" data-toggle="dropdown">{{.me.username}} <b class="caret"></b></a>
7881
<ul class="dropdown-menu">

websites/code/studygolang/template/index.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,10 @@ <h3><a href="javascript:">学习资料</a></h3>
250250
<p><a href="/account/edit">个人资料设置</a></p>
251251
</div>
252252
</div>
253-
<div class="box" style="margin: 0 20px;">
253+
<div class="box" style="margin: 0 5px;">
254254
<a class="btn btn-default btn-sm" href="/topics/new">发布主题</a>&nbsp;&nbsp;
255-
<a class="btn btn-default btn-sm" href="/resources/new">分享资源</a>
255+
<a class="btn btn-default btn-sm" href="/resources/new">分享资源</a>&nbsp;&nbsp;
256+
<a class="btn btn-default btn-sm" href="/project/new">发布项目</a>
256257
</div>
257258
{{else}}
258259
<div class="top">
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{{define "title"}}Go语言标准库文档中文版{{end}}
2+
{{define "seo"}}<meta name="keywords" content="中文, 文档, 标准库, Go语言,Golang,Go社区,Go中文社区,Golang中文社区,Go语言社区,Go语言学习,学习Go语言,Go语言学习园地,Golang 中国,Golang中国,Golang China, Go语言论坛, Go语言中文网">
3+
<meta name="description" content="Go语言文档中文版,Go语言中文网,中国 Golang 社区,Go语言学习园地,致力于构建完善的 Golang 中文社区,Go语言爱好者的学习家园。分享 Go 语言知识,交流使用经验">{{end}}
4+
{{define "content"}}
5+
<div class="row">
6+
<div class="col-lg-12">
7+
<ol class="breadcrumb">
8+
<li><a href="/"><i class="glyphicon glyphicon-home"></i> 首页</a></li>
9+
<li><a href="/pkgdoc">标准库中文版</a></li>
10+
</ol>
11+
<div class="box_white">
12+
<iframe src="/static/pkgdoc/index.html" id="pkgdoc" width="100%" frameborder="0" framemargin="0" scrolling="no" name="pkgdoc" onload="autoHeight()"></iframe>
13+
</div>
14+
</div>
15+
</div>
16+
{{end}}
17+
{{define "js"}}
18+
<script type="text/javascript">
19+
function autoHeight(){
20+
var iframe = document.getElementById("pkgdoc");
21+
22+
if(iframe.Document){ // ie自有属性
23+
var addHeight = 0;
24+
var uri = iframe.Document.location.href;
25+
if (uri.indexOf('/static/pkgdoc/index.html') > 0) {
26+
addHeight = 25;
27+
}
28+
29+
iframe.style.height = iframe.Document.documentElement.scrollHeight + addHeight;
30+
} else if(iframe.contentDocument){ //ie,firefox,chrome,opera,safari
31+
var addHeight = 0;
32+
var uri = iframe.contentDocument.location.href;
33+
if (uri.indexOf('/static/pkgdoc/index.html') > 0) {
34+
addHeight = 25;
35+
}
36+
37+
iframe.height = iframe.contentDocument.body.offsetHeight + addHeight;
38+
}
39+
}
40+
</script>
41+
{{end}}

0 commit comments

Comments
 (0)