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