]> git.openstreetmap.org Git - osqa.git/blob - forum/skins/default/templates/question.html
228285730fd1946d0fbfe269fd765e4b6d94d203
[osqa.git] / forum / skins / default / templates / question.html
1 {% extends "base.html" %}\r
2 <!-- question.html -->\r
3 {% load node_tags %}\r
4 {% load extra_tags %}\r
5 {% load extra_filters %}\r
6 {% load general_sidebar_tags %}\r
7 {% load smart_if %}\r
8 {% load humanize %}\r
9 {% load i18n %}\r
10 {% load cache %}\r
11 {% block metadescription %}{{ question.meta_description }}{% endblock %}\r
12 {% block metakeywords %}{{question.tagname_meta_generator}}{% endblock %}\r
13 {% block meta %}\r
14         <link rel="canonical" href="{{settings.APP_BASE_URL}}{{question.get_absolute_url}}" />\r
15         <link rel="alternate" type="application/rss+xml" title="RSS" href="{{ question.get_absolute_url }}?type=rss">\r
16 {% endblock %}\r
17 {% block title %}{% spaceless %}{{ question.headline }}{% endspaceless %}{% endblock %}\r
18 {% block forejs %}\r
19         {% if not question.nis.closed %}\r
20         <script type='text/javascript' src='{% media  "/media/js/osqa.question.js" %}'></script>\r
21         <script type='text/javascript' src='{% media  "/media/js/jquery.caret.js" %}'></script>\r
22         <script type='text/javascript' src='{% media  "/media/js/wmd/showdown.js" %}'></script>\r
23         <script type='text/javascript' src='{% media  "/media/js/wmd/wmd.js" %}'></script>\r
24         <script type='text/javascript' src='{% media  "/media/js/html_sanitizer.js" %}'></script>\r
25         <link rel="stylesheet" type="text/css" href="{% media  "/media/js/wmd/wmd.css" %}" />\r
26 \r
27         {% if embed_youtube_videos %}\r
28         <script type='text/javascript' src='{% media  "/media/js/viewbox_min.js" %}'></script>\r
29         <script type='text/javascript' src='{% media  "/media/js/youtube.js" %}'></script>\r
30         <link rel="stylesheet" type="text/css" href="{% media  "/media/js/viewbox.css" %}" />\r
31         {% endif %}\r
32         {% endif %}\r
33 \r
34         <script type="text/javascript">\r
35         $().ready(function(){\r
36             $("#nav_questions").attr('className',"on");\r
37             var answer_sort_tab = "{{ tab_id }}";\r
38 \r
39             if (answer_sort_tab) {\r
40                 $("#" + answer_sort_tab).attr('className',"on");\r
41             }\r
42 \r
43             $('#editor').TextAreaResizer();\r
44 \r
45             //toggle preview of editor\r
46             var display = true;\r
47             var txt = "[{% trans "hide preview" %}]";\r
48             $('#pre-collapse').text(txt);\r
49             $('#pre-collapse').bind('click', function(){\r
50                 txt = display ? "[{% trans "show preview" %}]" : "[{% trans "hide preview" %}]";\r
51                 display = !display;\r
52                 $('#previewer').toggle();\r
53                 $('#pre-collapse').text(txt);\r
54             });\r
55         });\r
56 \r
57         function submitClicked(e, f) {\r
58             if(!(browserTester('chrome') || browserTester('safari'))) {\r
59                 $("input.submit")[0].disabled=true;\r
60             }\r
61             window.removeEventListener('beforeunload', beforeUnload, true);\r
62             if (f) {\r
63                 f.submit();\r
64             }\r
65         }\r
66 \r
67         function beforeUnload(e) {\r
68 \r
69             if($("textarea#editor")[0].value != "") {\r
70                 return yourWorkWillBeLost(e);\r
71             }\r
72 \r
73             var commentBoxes = $("textarea.commentBox");\r
74             for(var index = 0; index < commentBoxes.length; index++) {\r
75                 if(commentBoxes[index].value != "") {\r
76                     return yourWorkWillBeLost(e);\r
77                 }\r
78             }\r
79         }\r
80         window.addEventListener('beforeunload', beforeUnload, true);\r
81         </script>\r
82         <noscript>\r
83             <style>\r
84                 .comment.not_top_scorer {\r
85                     display: block;\r
86                 }\r
87                 .comment-form-container {\r
88                     display: block;\r
89                 }\r
90                 .div.comment-tools {\r
91                     display: none;\r
92                 }\r
93             </style>\r
94         </noscript>\r
95 {% endblock %}\r
96         \r
97 {% block content %}\r
98 <div class="headNormal">\r
99     <h1><a href="{{ question.get_absolute_url }}">{{ question.headline }}</a></h1>\r
100 </div>\r
101 <div id="main-body" class="">\r
102     <div id="askform">\r
103             <table style="width:100%;" id="question-table" {% post_classes question %}>\r
104                 <tr>\r
105                     <td style="width:30px;vertical-align:top">\r
106                         <div class="vote-buttons">\r
107                             {% vote_buttons question request.user %}\r
108                             {% favorite_mark question request.user %}                            \r
109                         </div>\r
110                     </td>\r
111                     <td>\r
112                         <div id="item-right">\r
113                             <div class="question-body">\r
114                                 {{ question.html|safe }}\r
115                             </div>\r
116                             <div id="question-tags" class="tags-container tags">\r
117                                 {% for tag in question.tagname_list %}\r
118                                     <a href="{% url tag_questions tag|urlencode %}" class="post-tag tag-link-{{ tag }}"\r
119                                         title="{% blocktrans with tag as tagname %}see questions tagged '{{ tagname }}'{% endblocktrans %}" rel="tag">{{ tag }}</a>\r
120                                 {% endfor %}\r
121                             </div>\r
122                             <div id="question-controls" class="post-controls">                            \r
123                                 {% post_controls question request.user %}\r
124                                 {% wiki_symbol request.user question %}\r
125                             </div>\r
126                             <div class="post-update-info-container">\r
127                                     {% contributors_info question %}\r
128                             </div>\r
129                             {% comments question request.user %}\r
130                         </div>\r
131                         \r
132                     </td>\r
133                 </tr>\r
134             </table>\r
135             {% if question.nis.closed %}\r
136             <div class="question-status" style="margin-bottom:15px">\r
137             <h3>\r
138                 {% blocktrans with question.nstate.closed.extra as close_reason %}The question has been closed for the following reason "{{ close_reason }}" by{% endblocktrans %}\r
139                 <a href="{{ question.nstate.closed.by.get_profile_url }}">{{ question.nstate.closed.by.username }}</a>\r
140                  {% diff_date question.nstate.closed.at %}\r
141             </h3>\r
142             </div>\r
143             {% endif %}\r
144             {% if answers %}\r
145                 <hr/>\r
146                 <div class="tabBar">\r
147                     <a name="sort-top"></a>\r
148                     <div class="headQuestions">\r
149                     {% blocktrans count answers.paginator.count as counter %}One Answer:{% plural %}{{counter}} Answers:{% endblocktrans %}\r
150                     </div>\r
151                     {{ answers.paginator.sort_tabs }}\r
152                 </div>\r
153                 {{ answers.paginator.page_numbers }}\r
154   \r
155                 {% for answer in answers.paginator.page %}\r
156                     <a name="{{ answer.id }}"></a>\r
157                     <div id="answer-container-{{ answer.id }}" class="answer {% post_classes answer %}{% ifequal answer.id focused_answer_id %} focusedAnswer{% endifequal %}">\r
158                         <table style="width:100%;">\r
159                             <tr>\r
160                                 <td style="width:30px;vertical-align:top">\r
161                                     <div class="vote-buttons">\r
162                                         {% vote_buttons answer request.user %}\r
163                                         {% accept_button answer request.user %}\r
164                                     </div>\r
165                                 </td>\r
166                                 <td>\r
167                                     <div class="item-right">\r
168                                         <div class="answer-body">\r
169                                             {{ answer.html|safe }}\r
170                                         </div>\r
171                                         <div class="answer-controls post-controls">\r
172                                             {% post_controls answer request.user %}\r
173                                             {% wiki_symbol request.user answer %}\r
174                                         </div>\r
175                                         <div class="post-update-info-container">\r
176                                             {% contributors_info answer %}\r
177                                         </div>\r
178                                         {% comments answer request.user %}\r
179                                     </div>\r
180                                 </td>\r
181                             </tr>\r
182                         </table>\r
183                     </div>\r
184                 {% endfor %}\r
185                 <div class="paginator-container-left">\r
186                     {{ answers.paginator.page_numbers }}\r
187                 </div>\r
188             {% endif %}\r
189         <form id="fmanswer" action="{% url answer question.id %}" method="post">\r
190             {% csrf_token %}\r
191             <div style="clear:both">\r
192             </div>\r
193             \r
194             {% if not question.closed %}\r
195                 <div style="padding:10px 0 0 0;">\r
196                     {% spaceless %}\r
197                     <div class="headNormal">\r
198                         {% if answers %}\r
199                             {% trans "Your answer" %}\r
200                         {% else %}\r
201                             {% trans "Be the first one to answer this question!" %}\r
202                         {% endif %}\r
203                     </div>\r
204                     {% endspaceless %}\r
205                 </div>\r
206                 {% comment %}\r
207                 {% if not request.user.is_authenticated %}\r
208                     <div class="message">{% trans "You can answer anonymously and then login." %}</div>\r
209                 {% else %}\r
210                     <p class="message">\r
211                         {% ifequal request.user question.author  %}\r
212                             {% trans "Answer your own question only to give an answer." %}\r
213                         {% else %}\r
214                             {% trans "Please only give an answer, no discussions." %}\r
215                         {% endifequal %}\r
216                         {% if not request.user.email_valid_and_can_answer %}\r
217                             {% blocktrans %}Remember, your answer will not be published until you validate your email.{% endblocktrans %}\r
218                             <a href="{% url send_validation_email %}">{% trans "Send me a validation link." %}</a>\r
219                         {% endif %}\r
220                     </p>\r
221                 {% endif %}\r
222                 {% endcomment %}\r
223 \r
224                 <div id="description" class="" >\r
225                     <div id="wmd-button-bar" class="wmd-panel"></div>\r
226                     {{ answer.text }}\r
227                     <div class="preview-toggle">\r
228                         <table width="100%">\r
229                             <tr>\r
230                                 <td>\r
231                                     <span id="pre-collapse" \r
232                                         title="{% trans "Toggle the real time Markdown editor preview" %}">\r
233                                             {% trans "toggle preview" %}\r
234                                     </span>\r
235                                 </td>\r
236                                 <td style="text-align: right;" id="editor-metrics"></td>\r
237                                 {% if settings.WIKI_ON %}\r
238                                 <td style="text-align:right;">\r
239                                     {{ answer.wiki }} \r
240                                     <span style="font-weight:normal;cursor:help" \r
241                                         title="{{answer.wiki.help_text}}">\r
242                                             {{ answer.wiki.label_tag }} \r
243                                     </span>\r
244                                 </td>\r
245                                 {% endif %}\r
246                             </tr>\r
247                         \r
248                         </table>  \r
249                     </div>\r
250                     {{ answer.text.errors }}\r
251                     <div id="previewer" class="wmd-preview"></div>\r
252                 </div>\r
253 \r
254                     {% if answer.recaptcha %}\r
255                     <div class="question-captcha" style="float: left;">\r
256                         {{ answer.recaptcha.errors }}\r
257                         {{ answer.recaptcha }}\r
258                     </div>\r
259                     <div class="clear"></div>\r
260                     {% endif %}\r
261                 \r
262                 <p><span class="form-error"></span></p>\r
263                 <input type="button"\r
264                     {% if user.is_anonymous %}\r
265                         value="{% trans "Login/Signup to Post Your Answer" %}" \r
266                     {% else %}\r
267                         {% if user == question.author %}\r
268                         value="{% trans "Answer Your Own Question" %}" \r
269                         {% else %}\r
270                         value="{% trans "Answer the question" %}" \r
271                         {% endif %}\r
272                     {% endif %}\r
273                     class="submit" style="float:left" onclick="submitClicked(event, this.form)"/>\r
274             {% endif %}\r
275         </form>\r
276     </div>\r
277 </div>\r
278 {% endblock %}\r
279 \r
280 {% block sidebar %}\r
281 <div class="boxC" id="subscription_box">\r
282     {% include "subscription_status.html" %}\r
283 </div>\r
284 \r
285 {% markdown_help %}\r
286 \r
287 {% sidebar_upper %}\r
288 \r
289 {% cache 60 questions_tags settings.APP_URL question.id %}\r
290 <div class="boxC">\r
291     <p>\r
292                 {% trans "Question tags" %}:\r
293     </p>\r
294     <p class="tags" >\r
295         {% for tag in question.tags.all %}\r
296                 <a href="{% url tag_questions tag.name|urlencode %}"\r
297             class="tag-link-{{ tag.name }}"\r
298                         title="{% trans "see questions tagged"%}'{{tag.name}}'{% trans "using tags" %}"\r
299                         rel="tag">{{ tag.name }}</a> <span class="tag-number">&#215;{{ tag.used_count|intcomma }}</span><br/>\r
300         {% endfor %}\r
301     </p>\r
302     <p>\r
303         {% trans "question asked" %}: <strong title="{{ question.added_at }}">{% diff_date question.added_at %}</strong>\r
304     </p>\r
305     <p> \r
306         {% trans "question was seen" %}: <strong>{{ question.view_count|intcomma }} {% trans "times" %}</strong>\r
307     </p>\r
308     <p> \r
309         {% trans "last updated" %}: <strong title="{{ question.last_activity_at }}">{% diff_date question.last_activity_at %}</strong>\r
310     </p>\r
311 </div>\r
312 {% endcache %}\r
313 {% sidebar_lower %}\r
314 <div class="boxC">\r
315     <h3 class="subtitle">{% trans "Related questions" %}</h3>\r
316     <div class="questions-related">\r
317 \r
318         {% for question in similar_questions %}\r
319         <p>\r
320             <a href="{{ question.get_absolute_url }}">{{ question.headline }}</a>\r
321         </p>\r
322         {% endfor %}\r
323 \r
324     </div>\r
325 </div>\r
326 \r
327 {% endblock %}\r
328 \r
329 {% block endjs %}\r
330 {% endblock %}\r
331 <!-- end question.html -->\r