summaryrefslogtreecommitdiffstats
path: root/templates/question.html
blob: 5ba08b631eea1ffb82ce292fc2252ea6c73eee3f (plain)
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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
<!-- question.html -->
{% extends "base.html" %}{% load extra_tags %}{% load extra_filters %}{% load humanize %}
{% load i18n %}
{% block title %}{% spaceless %}{{ question.get_question_title }}{% endspaceless %}{% endblock %}
{% block forejs %}
        {% if not question.closed and request.user.is_authenticated %}
        <script type='text/javascript' src='/content/js/com.cnprog.editor.js'></script>
        <script type='text/javascript' src='/content/js/wmd/showdown.js'></script>
        <script type='text/javascript' src='/content/js/wmd/wmd.js'></script>
        <link rel="stylesheet" type="text/css" href="/content/js/wmd/wmd.css" />
        {% endif %}
        <script type='text/javascript' src='/content/js/com.cnprog.post.js'></script>
        <script type='text/javascript' src='/content/js/jquery.validate.pack.js'></script>
        <script type="text/javascript">
        // define reputation needs for comments
        var repNeededForComments = 50;
        $().ready(function(){
            $("#nav_questions").attr('className',"on");
            var answer_sort_tab = "{{ tab_id }}";
            $("#" + answer_sort_tab).attr('className',"on");
            
            Vote.init({{ question.id }}, '{{ question.author.id }}','{{ request.user.id }}');
            
            {% if not question.closed and request.user.is_authenticated %}initEditor();{% endif %}
            
            lanai.highlightSyntax();
            $('#btLogin').bind('click', function(){window.location.href='/account/signin/'; } )
        });
        
        function initEditor(){
            $('#editor').TextAreaResizer();
            //highlight code synctax when editor has new text
            $("#editor").typeWatch({highlight: false, wait: 3000,
                             captureLength: 5, callback: lanai.highlightSyntax});
                             
            var display = true;
            var txt = "[{% trans "hide preview" %}]";
            $('#pre-collapse').text(txt);
            $('#pre-collapse').bind('click', function(){
                txt = display ? "[{% trans "show preview" %}]" : "[{% trans "hide preview" %}]";
                display = !display;
                $('#previewer').toggle();
                $('#pre-collapse').text(txt);
            });
            
            setupFormValidation("#fmanswer", CPValidator.getQuestionFormRules(), CPValidator.getQuestionFormMessages());
        }
         
        </script>
{% endblock %}
        
{% block content %}
<div class="headNormal">
    <a href="{{ question.get_absolute_url }}">{{ question.get_question_title }}</a>
</div>
<div id="main-body" class="">
    <div id="askform">
        <form id="fmanswer" action="{% url answer question.id %}" method="post">
            <table style="width:100%;" id="question-table" {% if question.deleted %}class="deleted"{%endif%}>
                <tr>
                    <td style="width:30px;vertical-align:top">
                        <div class="vote-buttons">
                            {% if question_vote %}
                            <img id="question-img-upvote-{{ question.id }}" class="question-img-upvote" 
								src="/content/images/vote-arrow-up{% if question_vote.is_upvote %}-on{% endif %}.png" 
								title="{% trans "i like this post (click again to cancel)" %}" >
                            <div id="question-vote-number-{{ question.id }}" class="vote-number" 
								title="{% trans "current number of votes" %}">
                                {{ question.score }}
                            </div>
                            <img id="question-img-downvote-{{ question.id }}" class="question-img-downvote" 
								src="/content/images/vote-arrow-down{% if question_vote.is_downvote %}-on{% endif %}.png" 
								title="{% trans "i dont like this post (click again to cancel)" %}" >
                           
                            {% else %}
                            <img id="question-img-upvote-{{ question.id }}" class="question-img-upvote" 
								src="/content/images/vote-arrow-up.png" 
								title="{% trans "i like this post (click again to cancel)" %}" >
                            <div id="question-vote-number-{{ question.id }}" class="vote-number" 
								title="{% trans "current number of votes" %}">
                                {{ question.score }}
                            </div>
                            <img id="question-img-downvote-{{ question.id }}" class="question-img-downvote" 
								src="/content/images/vote-arrow-down.png" title="{% trans "i dont like this post (click again to cancel)" %}" >    
          
                            {% endif %}
                            <br><br>
                            {% if favorited %}
                            <img class="question-img-favorite" src="/content/images/vote-favorite-on.png" 
								title="{% trans "mark this question as favorite (click again to cancel)" %}" >
                            <div id="favorite-number" class="favorite-number my-favorite-number">
                                {{ question.favourite_count }}
                            </div>
                            {% else %}
                            <img class="question-img-favorite" src="/content/images/vote-favorite-off.png" 
								title="{% trans "remove favorite mark from this question (click again to restore mark)" %}" >   
                            <div id="favorite-number" class="favorite-number">{% ifnotequal question.favourite_count 0 %}{{ question.favourite_count }}{% endifnotequal %}
                            </div>
                        
                            {% endif %}
                            
                        </div>
                    </td>
                    <td>
                        <div id="item-right">
                            <div class="question-body">
                                {{ question.html|safe }}
                            </div>
                            <div id="question-tags" class="tags" >
                                {% for tag in question.tagname_list %}
                                    <a href="{% url forum.views.tag tag|urlencode %}" class="post-tag" 
										title="{% trans "see questions tagged" %}'{{ tag }}'{% trans "using tags" %}" rel="tag">{{ tag }}</a>
                                {% endfor %}
                            </div>
                            <div id="question-controls" style="clear:both;">
                                <table width="100%">
                                    <tr>
                                        <td width="210px" style="vertical-align:top">
                                            
                                            {% if request.user|can_edit_post:question %}
                                            <span class="action-link"><a href="{% url edit_question question.id %}">{% trans 'edit' %}</a></span>
                                            <span class="action-link-separator">|</span>
                                            {% endif %}
                                            {% if request.user|can_delete_post:question %}
                                            <span class="action-link"><a id="question-delete-link-{{question.id}}">{% trans "delete" %}</a></span>
                                            <span class="action-link-separator">|</span>
                                            {% endif %}
                                            {% if question.closed %}
                                            {% if request.user|can_reopen_question:question %}
                                            <span class="action-link"><a href="{% url reopen question.id %}">{% trans "reopen" %}</a></span>
                                            <span class="action-link-separator">|</span>
                                            {% endif %}
                                            {% else %}
                                            {% if request.user|can_close_question:question %}
                                            <span class="action-link"><a href="{% url close question.id %}">{% trans "close" %}</a></span>
                                            <span class="action-link-separator">|</span>
                                            {% endif %}
                                            {% endif %}
                                            
                                            <span id="question-offensive-flag-{{ question.id }}" class="offensive-flag" 
												title="{% trans "report as offensive (i.e containing spam, advertising, malicious text, etc.)" %}">
												<a>{% trans "flag offensive" %}</a>
												<span class="darkred">{% if request.user|can_view_offensive_flags %}
												{% if question.offensive_flag_count %}({{ question.offensive_flag_count }}){% endif %}{% endif %}</span>
                                            </span>
                                            
                                        </td>
                                        <td width="210px" style="vertical-align:top">
                                            {% if question.last_edited_by %}
                                            <div class="question-edit" >
                                                <table width="200px" >
                                                    <tr>
                                                        <td colspan="2"> 
                                                         {% trans "updated" %} <a href="{% url question_revisions question.id %}"><strong title="{{question.last_edited_at }}">{% diff_date question.last_edited_at  %}</strong></a>
                                                        </td>
                                                        
                                                    </tr>
                                                    {% if question.wiki %}
                                                    <tr>
                                                        <td style="width:40px;vertical-align:bottom">
                                                        {% gravatar question.last_edited_by 32 %}
                                                        </td>
                                                        <td style="width:160px; vertical-align:top">
                                                            <a href="/users/{{ question.last_edited_by.id }}/{{ question.last_edited_by.username }}">{{ question.last_edited_by.username }}</a>
                                                        </td>
                                                    </tr>
                                                    {% else %}
                                                    {% ifequal question.last_edited_by question.author %}
                                                    <tr>
                                                        <td> </td>
                                                        <td> </td>
                                                    </tr>
                                                    {% else %}
                                                    <tr>
                                                        <td style="width:40px;vertical-align:bottom">
                                                        {% gravatar question.last_edited_by 32 %}
                                                        </td>
                                                        <td style="width:160px; vertical-align:top">
                                                            <div><a href="/users/{{ question.last_edited_by.id }}/{{ question.last_edited_by.username }}">{{ question.last_edited_by.username }}</a></div>
                                
                                                            <div>
                                                            {% get_score_badge question.last_edited_by %}
                                                            </div>
                                                          
                                                        </td>
                                                    </tr>
                                                    {% endifequal %}
                                                    {% endif %}
                                                </table>
                                            </div>
                                            {% endif %}
                                            
                                        </td>
                                        <td style="vertical-align:top">
                                            {% if question.wiki %}
                                            <span class="wiki-category">{% trans "community wiki" %}</span>
                                            <div style="margin-bottom:10px"></div>
                                            {% else %}
                                            <div  class="question-mark">
                                                <table width="200px">
                                                    <tr>
                                                        <td colspan="2"> 
                                                        {% trans "asked" %} <strong title="{{ question.added_at }}">{% diff_date question.added_at %}</strong>
                                                        </td>
                                                        
                                                    </tr>
                                                    
                                                    <tr>
                                                        <td style="width:40px; vertical-align:bottom">
                                                        {% gravatar question.author 32 %}
                                                        </td>
                                                        <td align="left" style="width:160px;vertical-align:top">
                                                            <div><a href="/users/{{ question.author.id }}/{{ question.author }}">{{ question.author }}</a></div>
                                                            <div>
                                                            {% get_score_badge question.author %}
                                                            </div>
                                                        </td>
                                                    </tr>
                                                    
                                                </table>
                                            </div>
                                            {% endif %}
                                        
                                        </td>
                                    </tr>
                                </table>
                                
                            </div>
                            
                            <div class="post-comments" style="margin-bottom:20px">
                                <input id="can-post-comments-question-{{question.id}}" type="hidden" value="{{ request.user|can_add_comments }}"/>
                                <a id="comments-link-question-{{question.id}}" class="comments-link">
								{% if question.comment_count %}{% trans "comments" %} <strong>({{question.comment_count}})</strong>
								{% else %}{% trans "add comment" %}
								{% endif %}</a>
                                <div id="comments-question-{{question.id}}" class="comments-container">
                                <div class="comments"/></div>
                            </div>
                            
                        </div>
                        
                    </td>
                </tr>
            </table>
            {% if question.closed %}
            <div class="question-status" style="margin-bottom:15px">
            <h3>{% blocktrans %}The question has been closed for the following reason "{{ question.get_close_reason_display }}" by{% endblocktrans %} 
			<a href="{{ question.closed_by.get_profile_url }}">{{ question.closed_by.username }}</a> 
			{% blocktrans %}close date {{question.closed_at}}{% endblocktrans %}</h3>
            </div>
            {% endif %}
            
            {% ifnotequal question.answer_count 0 %}
                <div class="tabBar">
                    <a name="sort-top"></a>
                    <div class="headQuestions">{{ question.answer_count }}{% trans "Answers" %}:</div>
                    <div class="tabsA">
                         <a id="oldest" href="?sort=oldest#sort-top" title="{% trans "oldest answers will be shown first" %}">{% trans "oldest answers" %}</a>
                        <a id="latest" href="?sort=latest#sort-top" title="{% trans "newest answers will be shown first" %}">{% trans "newest answers" %}</a>
                        <a id="votes" href="?sort=votes#sort-top" title="{% trans "most voted answers will be shown first" %}">{% trans "popular answers" %}</a>   
                    </div>
                </div>
                {% cnprog_paginator context %}
  
                {% for answer in answers %}
                    <a name="{{ answer.id }}"></a>
                    <div id="answer-container-{{ answer.id }}" class="answer {% if answer.accepted %}accepted-answer{% endif %} {% ifequal answer.author_id question.author_id %} answered-by-owner{% endifequal %} {% if answer.deleted %}deleted{% endif %}">
                        <table style="width:100%;">
                            <tr>
                                <td style="width:30px;vertical-align:top">
                                    <div class="vote-buttons">
                                        <img id="answer-img-upvote-{{ answer.id }}" class="answer-img-upvote" src="/content/images/vote-arrow-up{% get_user_vote_image user_answer_votes answer.id 1 %}.png" title="{% trans "i like this answer (click again to cancel)" %}">
                                        <div id="answer-vote-number-{{ answer.id }}" class="vote-number" title="{% trans "current number of votes" %}">
                                            {{ answer.score }}
                                        </div>
                                        <img id="answer-img-downvote-{{ answer.id }}" class="answer-img-downvote" 
											src="/content/images/vote-arrow-down{% get_user_vote_image user_answer_votes answer.id -1 %}.png" 
											title="{% trans "i dont like this answer (click again to cancel)" %}" >
                                     
                                        <br><br>
                                        {% ifequal request.user question.author  %}
                                        <img id="answer-img-accept-{{ answer.id }}" class="answer-img-accept" 
											src="/content/images/vote-accepted{% if answer.accepted %}-on{% endif %}.png" 
											title="{% trans "mark this answer as favorite (click again to undo)" %}" >
                                        {% else %}
                                            {% if answer.accepted %}
                                            <img id="answer-img-accept-{{ answer.id }}" class="answer-img-accept" 
												src="/content/images/vote-accepted{% if answer.accepted %}-on{% endif %}.png" 
												title="{% trans "the author of the question has selected this answer as correct" %}" >
                                            {% endif %}
                                        {% endifequal %}
                                    </div>
                                </td>
                                <td>
                                    <div class="item-right">
                                        <div class="answer-body">
                                            {{ answer.html|safe }}
                                        </div>
                                        <div class="answer-controls" style="clear:both;">
                                            <table width="100%">
                        	                    <tr>
                                                    <td width="400px" style="vertical-align:top">
                                                        {% if request.user|can_edit_post:answer %}
                                                        <span class="action-link"><a href="{% url edit_answer answer.id %}">{% trans "edit" %}</a></span>
                                                        <span class="action-link-separator">|</span>
                                                        {% endif %}
                                                        {% if request.user|can_delete_post:answer %}
                                                        <span class="action-link">
															<a id="answer-delete-link-{{answer.id}}">
																{% if answer.deleted %}
																	{% trans "undelete" %}
																{% endif %}
																{% if not answer.deleted %}
																	{% trans "delete" %}
																{% endif %}
															</a>
														</span>
                                                        <span class="action-link-separator">|</span>
                                                        {% endif %}
                                                        <span class="linksopt">
                                                            <a href="#{{ answer.id }}" title="{% trans "answer permanent link" %}">
															{% trans "permanent link" %}
                                                            </a>
                                                        </span>
                                                        <span class="action-link-separator">|</span>
                                                        <span id="answer-offensive-flag-{{ answer.id }}" class="offensive-flag" 
															title="{% trans "report as offensive (i.e containing spam, advertising, malicious text, etc.)" %}">
															<a>{% trans "flag offensive" %}</a>
															<span class="darkred">{% if request.user|can_view_offensive_flags %}{% if answer.offensive_flag_count %}({{ answer.offensive_flag_count }}){% endif %}{% endif %}</span></span>
                                                    </td>
                        	                    	<td width="110px" style="vertical-align:top">
                                                    {% if answer.last_edited_by %}
                                                    <div class="question-edit" >
                                                        <table width="200px" >
                                                            <tr>
                                                                <td colspan="2"> 
                                                                 {% trans "updated" %}<a href="{% url answer_revisions answer.id %}"><strong title="{{answer.last_edited_at }}">{% diff_date answer.last_edited_at  %}</strong></a>
                                                                </td>
                                                            </tr>
                                                            {% if answer.wiki %}
                                                            <tr>
                                                                <td width="40px" style="vertical-align:bottom">
                                                                {% gravatar answer.last_edited_by 32 %}
                                                                </td>
                                                                <td style="width:160px; vertical-align:top">
                                                                    <div><a href="/users/{{ answer.last_edited_by.id }}/{{ answer.last_edited_by.username }}">{{ answer.last_edited_by.username }}</a></div>
                                                               
                                                                </td>
                                                            </tr>
                                                            {% else %}
                                                            {% ifequal answer.last_edited_by answer.author %}
                                                            <tr>
                                                                <td> </td>
                                                                <td> </td>
                                                            </tr>
                                                            {% else %}
                                                            <tr>
                                                                <td width="40px" style="vertical-align:bottom">
                                                                {% gravatar answer.last_edited_by 32 %}
                                                                </td>
                                                                <td style="width:160px; vertical-align:top">
                                                                    <div><a href="/users/{{ answer.last_edited_by.id }}/{{ answer.last_edited_by.username }}">{{ answer.last_edited_by.username }}</a></div>
                                                                    <div>
                                                                    {% get_score_badge answer.last_edited_by %}
                                                                    </div>
                                                                </td>
                                                            </tr>
                                                            {% endifequal %}
                                                            {% endif %}
                                                        </table>
                                                    </div>
                                                    {% endif %}
                                                    
                                                </td>
                                                 <td style="vertical-align:top">
                                                    {% if answer.wiki %}
                                                    <span class="wiki-category">{% trans "community wiki" %}</span>
                                                    <div style="margin-bottom:10px"></div>
                                                    {% else %}
                                                    <div  class="answer-mark">
                                                        <table width="200px">
                            	                            <tr>
                                	                           	<td colspan="2"> 
                                                                {% trans "asked" %} <strong title="{{answer.added_at}}">{% diff_date answer.added_at %}</strong>
                                                                </td>
                            	                            </tr>
                            	                            <tr>
                                                                <td width="40px" style="vertical-align:bottom">
                                                                {% gravatar answer.author 32 %}
                                                                </td>
                                                                <td style="width:160px; vertical-align:top">
                                                                    <div><a href="/users/{{ answer.author.id }}/{{ answer.author.username }}">{{ answer.author }}</a></div>
                                                                    <div>
                                                                    {% get_score_badge answer.author %}
                                                                    </div>
                                                                </td>
                            	                            </tr>
                                                        </table>
                                                    </div>
                                                    {% endif %}
                                                    
                                                 </td>
                        	                    </tr>
                        	                    
                                            </table>
                                            
                                        </div>
                                        <div id="comment-{{ answer.id }}" class="post-comments" >
                                            <input id="can-post-comments-answer-{{answer.id}}" type="hidden" value="{{ request.user|can_add_comments }}"/>
                                            <a id="comments-link-answer-{{answer.id}}" class="comments-link">
												{% if answer.comment_count %}{% trans "comments" %} 
												<strong>({{answer.comment_count}})</strong>{% else %}{% trans "add comment" %}{% endif %}</a>
                                            <div id="comments-answer-{{answer.id}}" class="comments-container">
                                            <div class="comments"/></div>
                                        </div>
                                        
                                    </div>
                                    
                                </td>
                            </tr>
                        </table>
                    </div>
                {% endfor %}
                <div class="paginator-container-left">
                    {% cnprog_paginator context %}
                </div>
            {% else %}
                <div class="line"></div>
            {% endifnotequal %}
            <div style="clear:both">
            </div>
            
            {% if not question.closed %}
            {% if request.user.is_authenticated %}
            <div style="padding:10px 0 0 0;">
                <div class="headNormal">{% trans "Your answer" %}:</div>
            </div>

            <div id="description" class="" >
                <div id="wmd-button-bar" class="wmd-panel"></div>
                {{ answer.text }}
                <div class="preview-toggle">
                    <table width="100%">
                        <tr>
                            <td>
                                <span id="pre-collapse" 
									title="{% trans "Toggle the real time Markdown editor preview" %}">{% trans "toggle preview" %}</span>
                            </td>
                            <td style="text-align:right;">
                                {{ answer.wiki }} <span style="font-weight:normal;cursor:help" title="{{answer.wiki.help_text}}">{{ answer.wiki.label_tag }} </span>
                            </td>
                        </tr>
                    
                    </table>  
                </div>
                <div id="previewer" class="wmd-preview"></div>
                {{ answer.text.errors }}
            </div>
            <br>
            <input type="submit" value="{% trans "Answer the question" %}" class="submit"><span class="form-error"></span>
            {% else %}
            <input id="btLogin" type="button" class="submit" style="width:200px" value="{% trans "Login to answer" %}">
            {% endif %}
            {% endif %}
            <br><br>
        </form>
    </div>
</div>
{% endblock %}

{% block sidebar %}
<div class="boxC">
    <p>
		{% trans "Question tags" %}:
    </p>
    <p class="tags" >
        {% for tag in tags %}
        	<a href="{% url forum.views.tag tag.name|urlencode %}" 
			title="{% trans "see questions tagged"%}'{{tag.name}}'{% trans "using tags" %}" 
			rel="tag">{{ tag.name }}</a> <span class="tag-number">× {{ tag.used_count|intcomma }}</span><br>
        {% endfor %}
    </p>
    <p>
        {% trans "question asked" %}: <strong title="{{ question.added_at }}">{{ question.added_at|timesince }} {% trans "ago" %}</strong>
    </p>
    <p> 
     	{% trans "question was seen" %}: <strong>{{ question.view_count|intcomma }} {% trans "times" %}</strong>
    </p>
    <p> 
        {% trans "last updated" %}: <strong title="{{ question.last_activity_at }}">{{ question.last_activity_at|timesince }} {% trans "ago" %}</strong>
    </p>
</div>

<div class="boxC">
    <h3 class="subtitle">{% trans "Related questions" %}</h3>
    <div class="questions-related">
        {% for question in similar_questions %}
        <p>
            <a href="/questions/{{question.id}}/{{ question.get_question_title }}">{{ question.get_question_title }}</a>
        </p>
        {% endfor %}
    </div>
    <br>  
</div>

{% endblock %}

{% block endjs %}
{% endblock %}
<!-- end question.html -->