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

Skip to content

Commit bd77ed6

Browse files
committed
回复 @ 和 表情bugfix;文章顶部增加收藏按钮
1 parent bc9e7ac commit bd77ed6

File tree

4 files changed

+42
-41
lines changed

4 files changed

+42
-41
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,9 @@ html, body { background: #F2F2F2; font-family: "Helvetica Neue", Helvetica, Aria
120120
.page .meta .p-author a {color: #272727;}
121121
.page .meta .p-author a:hover {color: #DB6D4C; text-decoration: none; }
122122
.page .meta .p-comment {float: right;padding-left: 10px;border-left: solid 1px #E0E0E0;height: 18px;margin-top: 5px;line-height: 18px;}
123-
.page .meta .p-comment .view,.page .meta .p-comment .like {font-family: "NSimSun";font-size: 12px;color: #888888;}
123+
.page .meta .p-comment .view,.page .meta .p-comment .like, .page .meta .p-comment .favorite {font-family: "NSimSun";font-size: 12px;color: #888888;}
124124
.page .meta .p-comment .like i { color: red; }
125+
.page .meta .p-comment .hadlike {color: red;}
125126
.page .meta .p-comment a {font-size: 12px;color: #ed5565; text-decoration: none;}
126127
.page .tags {padding: 20px 0; margin: 0 30px;}
127128
.page .tags .list-inline li {margin-right: 5px;margin-bottom: 6px;}

websites/code/studygolang/static/js/comment.js

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@
1313
}
1414
})
1515

16+
emojify.setConfig({
17+
// emojify_tag_type : 'span',
18+
only_crawl_id : null,
19+
img_dir : 'http://www.emoji-cheat-sheet.com/graphics/emojis',
20+
ignored_tags : { //忽略以下几种标签内的emoji识别
21+
'SCRIPT' : 1,
22+
'TEXTAREA': 1,
23+
'A' : 1,
24+
'PRE' : 1,
25+
'CODE' : 1
26+
}
27+
});
28+
1629
// 异步加载 评论
1730
window.loadComments = function() {
1831
var objid = $('.page-comment').data('objid'),
@@ -50,19 +63,9 @@
5063
$('.page-comment .words').removeClass('hide');
5164
}
5265

53-
emojify.setConfig({
54-
// emojify_tag_type : 'span',
55-
only_crawl_id : null,
56-
img_dir : 'http://www.emoji-cheat-sheet.com/graphics/emojis',
57-
ignored_tags : { //忽略以下几种标签内的emoji识别
58-
'SCRIPT' : 1,
59-
'TEXTAREA': 1,
60-
'A' : 1,
61-
'PRE' : 1,
62-
'CODE' : 1
63-
}
64-
});
6566
emojify.run($('.page-comment .words ul').get(0));
67+
68+
registerAtEvent();
6669
} else {
6770
comTip("评论加载失败");
6871
}
@@ -227,20 +230,11 @@
227230

228231
$('.page-comment .words ul').append(oneCmt);
229232
$('.page-comment .words').removeClass('hide');
230-
231-
emojify.setConfig({
232-
// emojify_tag_type : 'span',
233-
only_crawl_id : null,
234-
img_dir : 'http://www.emoji-cheat-sheet.com/graphics/emojis',
235-
ignored_tags : { //忽略以下几种标签内的emoji识别
236-
'SCRIPT' : 1,
237-
'TEXTAREA': 1,
238-
'A' : 1,
239-
'PRE' : 1,
240-
'CODE' : 1
241-
}
242-
});
233+
234+
// 解析表情
243235
emojify.run($('.page-comment .words ul li:last').get(0));
236+
// 注册@
237+
registerAtEvent();
244238

245239
var $cmtNumObj = $('.page-comment .words h3 .cmtnum'),
246240
cmtNum = parseInt($cmtNumObj.text(), 10) + 1;
@@ -265,16 +259,19 @@
265259
});
266260
}
267261

268-
if ($("#is_login_status").val() == 1) {
269-
// @ 本站其他人
270-
$('.page-comment #commentForm textarea').atwho({
271-
at: "@",
272-
data: "/at/users.json"
273-
}).atwho({
274-
at: ":",
275-
data: window.emojis,
276-
tpl:"<li data-value='${key}'><img src='http://www.emoji-cheat-sheet.com/graphics/emojis/${name}.png' height='20' width='20' /> ${name}</li>"
277-
});
262+
// 注册 @ 和 表情
263+
var registerAtEvent = function() {
264+
if ($("#is_login_status").val() == 1) {
265+
// @ 本站其他人
266+
$('.page-comment textarea').atwho({
267+
at: "@",
268+
data: "/at/users.json"
269+
}).atwho({
270+
at: ":",
271+
data: window.emojis,
272+
tpl:"<li data-value='${key}'><img src='http://www.emoji-cheat-sheet.com/graphics/emojis/${name}.png' height='20' width='20' /> ${name}</li>"
273+
});
274+
}
278275
}
279276

280277
// 分析 @ 的用户

websites/code/studygolang/static/js/common.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,13 @@ jQuery(document).ready(function($) {
214214

215215
var that = this;
216216
postFavorite(that, function(hadCollect){
217-
$(that).data('collect', hadCollect);
217+
$('.page .collect').data('collect', hadCollect);
218218

219219
if (hadCollect) {
220220
comTip("感谢收藏!");
221-
$(that).addClass('hadlike').attr('title', '取消收藏');
221+
$('.page .collect').addClass('hadlike').attr('title', '取消收藏');
222222
} else {
223-
$(that).removeClass('hadlike').attr('title', '稍后再读');
223+
$('.page .collect').removeClass('hadlike').attr('title', '稍后再读');
224224
comTip("已取消收藏!");
225225
}
226226
});

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{define "title"}}{{.article.Title}} {{end}}
2-
{{define "seo"}}<meta name="keywords" content="{{.article.Title}} Go语言博客文章, Go语言博文, Go语言, Golang, Go中文社区,Golang中文社区, Go语言社区, Go语言学习园地">
2+
{{define "seo"}}<meta name="keywords" content="{{.article.Title}}, Go语言博客文章, Go语言博文, Go语言, Golang, Go中文社区,Golang中文社区, Go语言社区, Go语言学习园地">
33
<meta name="description" content="{{substring .article.Txt 200 ""}}">{{end}}
44
{{define "content"}}
55
<div class="row banner">
@@ -33,7 +33,10 @@ <h1>{{.article.Title}}</h1>
3333
<i class="glyphicon glyphicon-heart"></i>
3434
<span class="likenum">{{.article.Likenum}}</span> 人喜欢&nbsp;
3535
</span>
36-
<a href="/articles/{{.article.Id}}#commentForm" title="我要评论"><i class="glyphicon glyphicon-comment"></i> <span class="cmtnum">{{.article.Cmtnum}}</span> 条评论</a>
36+
<a href="/articles/{{.article.Id}}#commentForm" title="我要评论"><i class="glyphicon glyphicon-comment"></i> <span class="cmtnum">{{.article.Cmtnum}}</span> 条评论</a>&nbsp;
37+
<a class="favorite collect {{if .hadcollect}}hadlike{{end}}" href="#" title="{{if .hadcollect}}取消收藏{{else}}稍后再读{{end}}" data-objid="{{.article.Id}}" data-objtype="1" data-collect="{{.hadcollect}}">
38+
<i class="glyphicon glyphicon-star{{if eq .hadcollect 0}}-empty{{end}}"></i> 收藏
39+
</a>
3740
</div>
3841
<!-- p-comment END -->
3942
</div>

0 commit comments

Comments
 (0)