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