Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
290 lines (275 loc) · 10.4 KB
/
Copy pathindex.html
File metadata and controls
290 lines (275 loc) · 10.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
<div id='sidebar'>
<div class='panel'>
<div class='header'>
<span class='col_fade'>作者</span>
</div>
<div class='inner'>
<%- partial('user/card', { object: topic.author, as: 'user' }) %>
</div>
</div>
<div class='panel'>
<div class='header'>
<span class='col_fade'>作者其它话题</span>
</div>
<div class='inner'>
<% if (locals.author_other_topics && author_other_topics.length > 0) { %>
<ul class='unstyled'>
<%- partial('topic/small', { collection: author_other_topics, as: 'topic' }) %>
</ul>
<% } else { %>
<p>无</p>
<% } %>
</div>
</div>
<div class='panel'>
<div class='header'>
<span class='col_fade'>无人回复的话题</span>
</div>
<div class='inner'>
<% if (locals.no_reply_topics && no_reply_topics.length > 0) { %>
<ul class='unstyled'>
<%- partial('topic/small', { collection: no_reply_topics, as: 'topic' }) %>
</ul>
<% } else { %>
<p>无</p>
<% } %>
</div>
</div>
</div>
<div id='content'>
<div class='panel'>
<div class='header'>
<ul class='breadcrumb'>
<li><a href='/'>主页</a><span class='divider'>/</span></li>
<li class='active'>话题详情</li>
</ul>
</div>
<div class='inner topic'>
<h3>
<% if (topic.top) { %>
<span class='put_top'>置顶</span>
<% } %>
<%= topic.title %>
</h3>
<hr>
<div class='topic_content'>
<%- markdown(topic.content) %>
</div>
<hr>
<div class="tags">
<% if (topic.tags.length > 0) { %>
<span class='col_fade'>标签:</span>
<%- partial('tag/tag_in_topic',{ collection: topic.tags, as: 'tag' }) %>
<% } else { %>
<span class='col_fade'>标签:无</span>
<% } %>
</div>
<div class="changes">
<span class='col_fade'>
<a class='dark' href="/user/<%= topic.author.name %>"><%= topic.author.name %></a> 在 <%= topic.friendly_create_at %> 发布
</span>
<% if (topic.friendly_create_at != topic.friendly_update_at) { %>
<span class='col_fade'>
<a class='dark' href="/user/<%= topic.author.name %>"><%= topic.author.name %></a> 在 <%= topic.friendly_update_at %> 重新编辑
</span>
<% } %>
</div>
<div class="action">
<a class='dark' id='share_weibo_btn'
href="javascript:void((function(s,d,e,r,l,p,t,z,c){var%20f='http://v.t.sina.com.cn/share/share.php?appkey=<%= config.weibo_key %>',u=z||d.location,p=['&url=',e(u),'&title=',e(t||d.title),'&source=',e(r),'&sourceUrl=',e(l),'&content=',c||'gb2312','&pic=',e(p||'')].join('');function%20a(){if(!window.open([f,p].join(''),'mb',['toolbar=0,status=0,resizable=1,width=440,height=430,left=',(s.width-440)/2,',top=',(s.height-430)/2].join('')))u.href=[f,p].join('');};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();})(screen,document,encodeURIComponent,'','','','分享来自<%= config.name %>的话题:<%= topic.title %>','',''));"
>分享到 weibo</a>
<% if (locals.current_user) { %>
<% if (!topic.in_collection) { %>
<button class='btn btn-success' id='collect_btn' action='collect'>加入收藏</button>
<% } else { %>
<button class='btn' id='collect_btn' action='de_collect'>取消收藏</button>
<% } %>
<% } %>
<% if (locals.current_user) { %>
<% if (current_user.is_admin) { %>
<% if (topic.top) { %>
<a href='/topic/<%= topic._id %>/top/0'><img class='user_icon' src='<%- config.site_static_host %>/public/images/star_fav_empty_icon&16.png' title='取消置顶' /></a>
<% } else { %>
<a href='/topic/<%= topic._id %>/top/1'><img class='user_icon' src='<%- config.site_static_host %>/public/images/star_fav_icon&16.png' title='置顶' /></a>
<% } %>
<a href='/topic/<%= topic._id %>/edit'><img class='user_icon' src='<%- config.site_static_host %>/public/images/doc_edit_icon&16.png' title='编辑' /></a>
<a href='javascript:;' data-id="<%= topic._id %>" class='delete_topic_btn'><img class='user_icon' src='<%- config.site_static_host %>/public/images/trash_icon&16.png' title='删除' /></a>
<% } else { %>
<% if (current_user._id == topic.author_id) { %>
<a href='/topic/<%= topic._id %>/edit'><img class='user_icon' src='<%- config.site_static_host %>/public/images/doc_edit_icon&16.png' title='编辑' /></a>
<% } %>
<% } %>
<% } %>
</div>
</div>
</div>
<% if (topic.replies && topic.replies.length > 0) { %>
<div class='panel'>
<div class='header'>
<span class='col_fade'><%= topic.replies.length %> 回复</span>
</div>
<%- partial('reply/reply', topic.replies) %>
</div>
<% } %>
<% if (locals.current_user && locals.topic) { %>
<div class='panel'>
<div class='header'>
<span class='col_fade'>添加回复</span>
</div>
<div class='inner reply'>
<form id='reply_form' action='/<%= topic._id %>/reply' method='post'>
<div class='tabbable'>
<ul class='nav nav-pills'>
<li class='active'><a href='#markdown' data-toggle='pill'>markdown</a></li>
<!-- <li><a href='#preview' data-toggle='pill' class="preview-btn">预览</a></li> -->
</ul>
<div class='tab-content'>
<div class='tab-pane active' id='markdown'>
<div id='wmd-button-bar'></div>
<textarea class='span8 editor' id='wmd-input' name='r_content' rows='8'></textarea>
</div>
<div id='preview' class='tab-pane'>
<div id='wmd-preview' class='wmd-preview reply-wmd-preview'></div>
</div>
</div>
<input type='hidden' name='_csrf' id="_csrf" value='<%= csrf %>' />
</div>
<button id='submit_btn' class='btn'>回复</button>
<span class='col_fade'>Ctrl+Enter 快捷回复</span>
</form>
</div>
</div>
<% } %>
</div>
<% if (locals.current_user && locals.topic) { %>
<!-- ajaxupload -->
<!-- markdown editor -->
<%- Loader('/public/topic_edit.min.js')
.js('/public/libs/ajax-upload/ajaxupload.js')
.js('/public/libs/epiceditor/epiceditor.js')
.js('/public/javascripts/editor.js')
.done(assets, config.site_static_host, config.mini_assets)
%>
<script>
$(document).ready(function () {
var editorList = {};
$('.reply2_btn').click(function () {
var $btn = $(this);
var parent = $btn.parents('.reply_area');
var editorWrap = parent.find('.reply2_form');
parent.find('.reply2_area').prepend(editorWrap);
var textarea = editorWrap.find('textarea.editor');
var user = $btn.parents('.cell').find('.reply_author a').html();
editorWrap.show('fast', function () {
var editor = createEpicEditor(textarea);
editorList[textarea.attr('id')] = editor;
editor.load();
});
});
$('.reply2_at_btn').click(function () {
var $btn = $(this);
var editorWrap = $btn.parents('.reply2_area').find('.reply2_form');
$btn.parents('.reply2_item').after(editorWrap);
var textarea = editorWrap.find('textarea.editor');
var user = $btn.parents('.cell').find('.reply_author a').html();
if (textarea.val().indexOf('@' + user) < 0) {
textarea.val('@' + user + ' ');
}
editorWrap.show('fast', function () {
var editor = createEpicEditor(textarea);
editorList[textarea.attr('id')] = editor;
editor.load();
});
});
$('#collect_btn').click(function(){
var $me = $(this);
var action = $me.attr('action');
var data = {
topic_id: '<%= topic._id %>',
_csrf: '<%= csrf %>'
};
$.post('/topic/' + action, data, function(data) {
if (data.status === 'success') {
if (action == 'collect') {
$me.html('取消收藏');
$me.attr('action','de_collect');
} else {
$me.html('加入收藏');
$me.attr('action','collect');
}
$me.toggleClass('btn-success');
}
}, 'json');
});
$('.delete_reply_btn, .delete_reply2_btn').live('click', function() {
var $me = $(this);
if (confirm('确定要删除此回复吗?')) {
var reply_id = null;
if ($me.hasClass('delete_reply_btn')) {
reply_id = $me.parents('.reply_item').attr('reply_id');
}
if ($me.hasClass('delete_reply2_btn')) {
reply_id = $me.parents('.reply2_item').attr('reply_id');
}
var data = {
reply_id: reply_id,
_csrf: "<%- csrf %>"
};
$.post('/reply/' + reply_id + '/delete', data, function (data) {
if (data.status === 'success') {
if($me.hasClass('delete_reply_btn')){
$me.parents('.reply_item').remove();
}
if($me.hasClass('delete_reply2_btn')){
$me.parents('.reply2_item').remove();
}
}
}, 'json');
}
return false;
});
$('.delete_topic_btn').click(function () {
var topicId = $(this).data('id');
if (topicId && confirm('确定要删除此话题吗?')) {
$.post('/topic/' + topicId + '/delete', { _csrf: $('#_csrf').val() }, function (result) {
if (!result.success) {
alert(result.message);
} else {
location.href = '/';
}
});
}
return false;
});
var submit_btn;
$('textarea').each(function(){
$(this).focus(function(){
var parent = $(this).parent().parent().parent().parent();
var btn = parent.find('button');
if(btn.html() == '回复'){
submit_btn = btn;
}
});
});
document.onkeyup=function(event) {
if(window.ActiveXObject) {
var keydown = window.event.keyCode;
event=window.event;
}else{
var keydown = event.keyCode;
if(event.ctrlKey == true && keydown == 13){
if(submit_btn){
submit_btn.click();
}
}
}
};
});
</script>
<% } %>
<%- Loader('/public/fancebox.min.js', '/public/libs/fancybox/fancebox.min.css')
.css('/public/libs/fancybox/jquery.fancybox-1.3.4.css')
.js('/public/libs/fancybox/jquery.fancybox-1.3.4.pack.js')
.js('/public/javascripts/topic.js')
.done(assets, config.site_static_host, config.mini_assets)
%>