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

Skip to content

Commit 305a350

Browse files
committed
主题详情页基本完成
1 parent 7ffc362 commit 305a350

File tree

12 files changed

+165
-362
lines changed

12 files changed

+165
-362
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ func TopicsHandler(rw http.ResponseWriter, req *http.Request) {
4545
view = "last"
4646
order = "ctime DESC"
4747
}
48+
4849
topics, total := service.FindTopics(page, 0, where, order)
49-
pageHtml := service.GetPageHtml(page, total, "/topics")
50+
pageHtml := service.GetPageHtml(page, total, req.URL.Path)
5051
req.Form.Set(filter.CONTENT_TPL_KEY, "/template/topics/list.html")
5152
// 设置模板数据
5253
filter.SetData(req, map[string]interface{}{"activeTopics": "active", "topics": topics, "page": template.HTML(pageHtml), "nodes": nodes, "view": view})

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,17 @@ html, body { background: #F2F2F2; font-family: "Helvetica Neue", Helvetica, Aria
153153
.page .page-comment .comment-title:after { display: block;visibility: hidden;height: 0; content: '\0020'; clear: both; }
154154
.page .page-comment .comment-title h2 { font-size: 24px;color: #D55252;font-weight: normal;float: left; font-family: "microsoft yahei"; margin-top: 0px; }
155155
.page .page-comment .comment-title .h2-tip { font-size: 12px;margin-left: 8px;float: left;color: #505050;padding-top: 4px;font-family: "nsimsun"; margin-bottom: 10.5px;}
156+
.page .page-comment .md-toolbar ul { margin-bottom:2px;}
157+
.page .page-comment .md-toolbar ul a { -moz-border-radius: 8px;-webkit-border-radius: 8px;border-radius: 8px;padding: 0 5px;line-height: 18px;font-size: 12px;margin-right: 6px;text-shadow: 0;color: #444;border: 1px solid #fff;}
158+
.page .page-comment .md-toolbar ul a:hover { text-decoration: none;}
159+
.page .page-comment .md-toolbar ul .cur a { background: #fff;border: 1px solid #ddd;color: #666;}
160+
.page .page-comment .md-toolbar .upload-img { cursor: pointer;}
161+
.page .page-comment .submit {border-bottom: solid 1px #ECECEC;}
156162
.page .page-comment .submit textarea {resize: none;width: 100%;color: #999999;font-size: 14px;border: solid 1px #E5E5E5;padding: 15px;}
157163
.page .page-comment .submit textarea:focus{outline: solid 1px #FFB7B7;color: #000;}
164+
.page .page-comment .submit .sub ul { padding-left: 30px; font-size:13px; line-height: 13px;}
158165
.page .page-comment .submit .sub .btn {padding: 6px 22px;}
166+
.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; }
159167
.page .page-comment .words {padding-bottom: 20px;}
160168
.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;}
161169
.page .page-comment .words h3 span {color: #A2442F;padding: 0 3px;}
@@ -218,4 +226,4 @@ label.error {color:red;}
218226
/*emoji*/
219227
.emoji {width:20px;height:20px;vertical-align: middle;}
220228

221-
.img-rounded {-webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;}
229+
.img-rounded {-webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;}

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

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,45 @@
66

77
$(document).ready(function(){
88
// 文本框事件
9-
$(".page-comment #commentForm textarea").click(function(){
9+
$(".page-comment #commentForm textarea").on('click', function(){
1010
// 没有登录
1111
if($("#is_login_status").val() != 1){
1212
openPop("#login-pop");
1313
}
14-
})
14+
});
15+
16+
$('.page-comment .md-toolbar .edit').on('click', function(evt){
17+
evt.preventDefault();
18+
19+
$(this).addClass('cur');
20+
$('.page-comment .md-toolbar .preview').removeClass('cur');
21+
22+
$('.page-comment .content-preview').hide();
23+
$('.page-comment #commentForm').show();
24+
});
25+
$('.page-comment .md-toolbar .preview').on('click', function(evt){
26+
evt.preventDefault();
27+
28+
// 配置 marked 语法高亮
29+
marked.setOptions({
30+
highlight: function (code) {
31+
code = code.replace(/"/g, '"');
32+
code = code.replace(/&lt;/g, '<');
33+
code = code.replace(/&gt;/g, '>');
34+
return hljs.highlightAuto(code).value;
35+
}
36+
});
37+
38+
$(this).addClass('cur');
39+
$('.page-comment .md-toolbar .edit').removeClass('cur');
40+
41+
$('.page-comment #commentForm').hide();
42+
var content = $('.page-comment #commentForm textarea').val();
43+
$('.page-comment .content-preview').html(marked(content));
44+
$('.page-comment .content-preview').show();
45+
});
46+
47+
$('.markdown_tip').html(marked($('.markdown_tip').text()));
1548

1649
emojify.setConfig({
1750
// emojify_tag_type : 'span',

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ jQuery(document).ready(function($) {
2929

3030
$('.timeago').timeago();
3131

32+
// tooltip
33+
$('.tool-tip').tooltip();
34+
3235
// 点击回到顶部的元素
3336
$("#gotop").click(function(e) {
3437
// 以1秒的间隔返回顶部

websites/code/studygolang/static/js/projects.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,13 @@
3636
},
3737

3838
parseDesc: function(){
39-
var markdownString = $('.project .desc').html();
39+
var markdownString = $('.project .desc').text();
40+
// 配置 marked 语法高亮
4041
marked.setOptions({
4142
highlight: function (code) {
43+
code = code.replace(/&#34;/g, '"');
44+
code = code.replace(/&lt;/g, '<');
45+
code = code.replace(/&gt;/g, '>');
4246
return hljs.highlightAuto(code).value;
4347
}
4448
});
@@ -49,16 +53,20 @@
4953

5054
jQuery(document).ready(function($) {
5155
var IS_PREVIEW = false;
52-
$('.preview').on('click', function(){
56+
$('.desc .preview').on('click', function(){
5357
// console.log(hljs.listLanguages());
5458
if (IS_PREVIEW) {
5559
$('.preview-div').hide();
5660
$('#desc').show();
5761
IS_PREVIEW = false;
5862
} else {
5963
var markdownString = $('#desc').val();
64+
// 配置 marked 语法高亮
6065
marked.setOptions({
6166
highlight: function (code) {
67+
code = code.replace(/&#34;/g, '"');
68+
code = code.replace(/&lt;/g, '<');
69+
code = code.replace(/&gt;/g, '>');
6270
return hljs.highlightAuto(code).value;
6371
}
6472
});

0 commit comments

Comments
 (0)