fix i18n strings for closing requests
[shapado:shapado.git] / app / views / questions / show.html.haml
1 = javascript_include_merged :show
2
3 - @current_class = 'question hentry entry post'
4
5 - show_close_request_form = !@question.closed && logged_in? && @question.can_be_requested_to_close_by?(current_user)
6 - show_open_request_form = @question.closed && logged_in? && @question.can_be_requested_to_open_by?(current_user)
7
8 - if logged_in?
9   - if current_user.mod_of?(current_group) && @question.closed
10     - show_close_request_form = (@question.close_reason.user_id == current_user.id)
11   - @flag = current_user.has_flagged?(@question) || Flag.new
12
13 - @flag ||= Flag.new
14
15 - if show_open_request_form
16   - @open_request = current_user.has_requested_to_open?(@question) || OpenRequest.new
17
18 - if show_close_request_form
19   - @close_request = @question.close_requests.detect{ |rq| rq.user_id == current_user.id } || CloseRequest.new(:reason => "dupe")
20
21 - question_body = find_and_preserve(shapado_auto_link(markdown(@question.body.present? ? @question.body : @question.title)))
22
23 - content_for :head do
24   %meta{:name => "keywords", :content => clean_seo_keywords(@question.tags.dup, @question.title)}
25   %meta{:name => "description", :content => question_body.gsub(/<\/?[^>]*>/, "")[0, 255] }
26   %link{:rel => "canonical", :href => question_url(@question) }
27
28 - content_for :subtabs do
29   %h1.navtitle.title.entry-title
30     &= @question.title
31     - if @question.closed
32       =" [#{t("closed", :scope => "activerecord.attributes.question").upcase}]"
33
34 - source = question_path(@question)
35 = error_messages_for 'answer'
36
37 #question-vote-col
38   - if current_user && @question.watch_for?(current_user)
39     = link_to image_tag("layer-visible-on.png", 'data-src' => "/images/layer-visible-off.png"), unwatch_question_path(@question), :class => 'question-action', "data-undo" =>  watch_question_path(@question), "data-title" => t(".watch_tooltip"), :title => t(".unwatch_tooltip"), :id => "watch-question"
40   - else
41     = link_to image_tag("layer-visible-off.png", 'data-src' => "/images/layer-visible-on.png"), watch_question_path(@question), :title => t(".watch_tooltip"), :class => 'question-action', "data-undo" =>  unwatch_question_path(@question), "data-title" => t(".unwatch_tooltip"), :id => "watch-question"
42
43   =vote_box(@question, question_path(@question), @question.closed)
44
45   - if logged_in? && favorite = current_user.favorite(@question)
46     = link_to image_tag("favorites.png", 'data-src' => "/images/unfavorites.png"), unfavorite_question_path(@question), :id => "unfavorite-link", :title => t(".unfavorite_tooltip"), :class => 'question-action', "data-undo" =>  favorite_question_path(@question), "data-title" => t(".favorite_tooltip"), 'data-counter' => '.favorites_count'
47   - else
48     = link_to image_tag("unfavorites.png", 'data-src' => "/images/favorites.png"), favorite_question_path(@question), :id => "favorite-link", :title => t(".favorite_tooltip"), :class => 'question-action', "data-undo" =>  unfavorite_question_path(@question), "data-title" => t(".unfavorite_tooltip"), 'data-counter' => '.favorites_count'
49   .favorites_count
50     &= @question.favorites_count
51
52
53 #question-body-col.commentable.markdown
54   %a{:name => @question.id}
55   #body
56     - if @question.closed && @question.close_reason
57       #close_reason
58         = t(".close_reason")
59         = t(@question.close_reason.reason, :scope=>"close_requests.form")
60         - if !@question.close_reason.comment.empty?
61           .comment
62             =find_and_preserve(shapado_auto_link(@question.close_reason.comment))
63     .post-text.entry-content
64       = question_body
65   .tag-list
66     - @question.tags.each do |tag|
67       %span.tag
68         = link_to h(tag), url_for(:controller => "questions", :action => "index", :tags => tag), :rel => "tag"
69     - if logged_in? && (current_user.can_modify?(@question) || current_user.can_retag_others_questions_on?(current_group))
70       %span.retag
71         = link_to t('.retag'), retag_question_path(@question), :id => 'retag'
72   .post-info
73     .author.user_info.vcard
74       .gravatar.logo
75         = gravatar(@question.user.email.to_s, :size => 32)
76       .user_data
77         %span.asked_by
78           = t('activerecord.attributes.question.asked_by')
79         =render :partial => "users/user_mini", :locals => {:user => @question.user}
80         %span.time_ago.published{:title => @question.created_at, :class => "relativetime"}
81           = t("time.ago", :time => time_ago_in_words(@question.created_at))
82           - if @question.wiki
83             .wiki_flag
84               wiki
85         %span.adr
86           - if !@question.user.hide_country
87             %span.country-name
88               = t("global.from", :site => @question.user.country_name)
89               = country_flag(@question.user.country_code, @question.user.country_name)
90       .clear
91     - if @question.updated_by.present?
92       .user_info
93         .gravatar.logo
94           = gravatar(@question.updated_by.email.to_s, :size => 32)
95         .user_data
96           %span.asked_by
97             = t('activerecord.attributes.question.updated_by')
98           =render :partial => "users/user_mini", :locals => {:user => @question.updated_by}
99           %span.time_ago.published{:title => @question.updated_at, :class => "relativetime"}
100             = t("time.ago", :time => time_ago_in_words(@question.updated_at))
101           %span.adr
102             - if !@question.updated_by.hide_country
103               %span.country-name
104                 = t("global.from", :site => @question.updated_by.country_name)
105                 = country_flag(@question.updated_by.country_code, @question.updated_by.country_name)
106         .clear
107   .controls
108     .actions
109       - if !@flag.new?
110         .flagged
111           = "#{t('.flagged_as')} #{t(@flag.reason, :scope=>'flags.form')}"
112           = link_to t("scaffold.edit"), edit_question_flag_path(@question,@flag), :class => "flag-link", :id => "edit_question_flag_link", :rel => 'nofollow'
113           = link_to t("scaffold.destroy"), question_flag_path(@question,@flag), :id => "destroy_question_flag_link", :rel => 'nofollow', :confirm => "are you sure?", :method => :delete
114       - elsif logged_in? && current_user != @question.user
115         = link_to t(".flag"), new_question_flag_path(@question), :class => "flag-link", :id => "question_flag_link", :rel => 'nofollow'
116
117       - if logged_in?
118         - if show_close_request_form
119           -if !@close_request.new?
120             .flagged
121               = "#{t('.requested_close_as')} #{t(@close_request.reason, :scope=>'close_requests.form')}"
122               = link_to t(".edit_closing_request"), edit_question_close_request_path(@question,@close_request), :class => "flag-link", :id => "edit_question_close_request_link", :rel => 'nofollow'
123               = link_to t(".retract_closing_request"), question_close_request_path(@question,@close_request), :id => "destroy_question_close_request_link", :rel => 'nofollow', :confirm => "are you sure?", :method => :delete
124
125           - close_link_label = current_user.mod_of?(current_group) ?  t(".close") : t(".request_closing")
126           = link_to close_link_label, @close_request.new? ? new_question_close_request_path(@question) : edit_question_close_request_path(@question, @close_request), :id => "request-close-link", :rel => 'nofollow', :title => t('.request_closing_details')
127
128         - if show_open_request_form
129           -if !@open_request.new?
130             .flagged
131               = "#{t('.request_open')} #{@open_request.comment}"
132               = link_to t("scaffold.edit"), edit_question_open_request_path(@question, @open_request), :class => "flag-link", :id => "edit_question_open_request_link", :rel => 'nofollow'
133               = link_to t("scaffold.destroy"), question_open_request_path(@question,@open_request), :id => "destroy_question_open_request_link", :rel => 'nofollow', :confirm => "are you sure?", :method => :delete
134
135           -if current_user.mod_of?(current_group)
136             = link_to t(".open"), open_question_path(@question), :rel => 'nofollow', :title => t('.request_opening_details'), :method => "put"
137           -else
138             = link_to t(".request_opening"), new_question_open_request_path(@question), :id => "request-open-link", :rel => 'nofollow', :title => t('.request_opening_details')
139
140         - if (@question.wiki && current_user.can_edit_wiki_post_on?(@question.group)) || current_user.can_edit_others_posts_on?(@question.group) || current_user.can_modify?(@question)
141           = link_to t('scaffold.edit'), edit_question_path(@question), :class => "button"
142         - if @question.versions.count > 0
143           = link_to t(".history", :default => "history"), history_question_path(@question)
144         - if (current_user.can_modify?(@question) || current_user.owner_of?(@question.group))
145           = link_to t("scaffold.destroy"), question_path(@question.id), :confirm => "are you sure?", :method => :delete
146         - if current_user.mod_of?(@question.group)
147           = link_to t(".ban"), ban_path(:question_ids => [@question.id]), :class => "button", :confirm => "are you sure?"
148     .forms
149       /= render :partial => "flags/form", :locals => {:flag => @flag, :flaggeable => @question, :source => source, :form_id => "question_flag_form" }
150
151       - if !@question.closed && show_close_request_form
152         /= render :partial => "close_requests/form", :locals => { :question => @question, :close_request => @close_request, :hide => true, :form_id => "request_close_question_form"}
153
154   - if logged_in?
155     = link_to t("comments.shared.add_comment"), new_question_comment_path(@question), :id => "add_comment_link", :rel => 'nofollow'
156
157   .comments
158     -@question.comments.each do |comment|
159       = render :partial => "comments/comment", :object => comment, :locals => {:source => source, :mini => true}
160   .clear
161   .forms
162     .comment-form-question
163       -form_tag question_comments_path(@question), :class => "form commentForm nestedAnswerForm", :id => "add_comment_form" do
164         -@comment = Comment.new
165         = render :partial => "comments/form", :locals => {:source => source, :commentable => @question}
166         .group.navform
167           = submit_tag t("comments.shared.comment_submit"), :class => "button"
168           = t("global.or")
169           = link_to t('scaffold.cancel'), '', :class => 'cancel_comment'
170
171 %a{:name=>"answers"}
172 #answers
173   .secondary-navigation{:class => @active_subtab.to_s}
174     .navtitle
175       = t(".answers_title", :count => @answers.total_entries + (@question.accepted ? 1 : 0))
176
177     %ul
178       %li.newest
179         = link_to t("questions.index.newest"), question_path(@question, :sort=>"newest", :anchor => "answers"), :rel => "nofollow"
180       %li.votes
181         = link_to t("questions.index.votes"), question_path(@question, :sort=>"votes", :anchor => "answers"), :rel => "nofollow"
182       %li.oldest
183         = link_to t("questions.index.oldest"), question_path(@question, :sort=>"oldest", :anchor => "answers"), :rel => "nofollow"
184     .clear
185   .block
186     - if @question.accepted
187       -solution = @question.answer
188       =render :partial=> "answer", :locals=> {:question => @question, :answer => solution} unless solution.nil?
189     .hentry
190       -@answers.each do |answer|
191         =render :partial=> "answer", :locals=> {:question => @question, :answer => answer}
192     =will_paginate(@answers)
193
194 -unless @question.closed
195   %a{:name=>"to_answer"}
196   -form_for @answer, :url => question_answers_path(@question.id), :html => {:class => "form mainAnswerForm"} do |f|
197     = render :partial => "answers/form", :locals => {:f => f, :markdown => true}
198     .group.navform
199       .right
200         = f.label :wiki, "Wiki", :class => "radio"
201         = f.check_box :wiki, :class => "checkbox"
202       = submit_tag t('answers.form.submit'), :class => "button"
203     .clear
204
205 -content_for :sidebar do
206   - if AppConfig.enable_sharing
207     .block
208       %h3
209         = t(".share")
210       .content
211         %ul.share
212           %li
213             = render :partial => "identica"
214           - if current_group.domain != AppConfig.domain
215             %li
216               = render :partial => "shapado"
217           %li
218             = render :partial => "twitter"
219           %li
220             = render :partial => "linkedin"
221           %li
222             = render :partial => "think"
223           %li
224             = render :partial => "facebook"
225       .clear
226
227   - if logged_in? && (current_user.mod_of?(current_group) || current_user.can_view_offensive_counts_on?(current_group))
228     -unless @question.flags.count == 0
229       .block
230         %h3
231           = t(:flags, :scope => "activerecord.models")
232         .content
233           = render :partial => "flags/list", :locals => {:flaggeable => @question}
234
235     -unless @question.close_requests.size == 0
236       .block
237         %h3
238           = t(:prural_name, :scope => "close_requests.model")
239         .content
240           = render :partial => "close_requests/list", :locals => {:question => @question}
241
242     -unless @question.open_requests.size == 0
243       .block
244         %h3
245           = t(:prural_name, :scope => "open_requests.model")
246         .content
247           = render :partial => "open_requests/list", :locals => {:question => @question}
248
249   .block
250     %h3
251       = t('.tags', :default => [:"layouts.application.tags", :"activerecord.attributes.user.tags", "tags"])
252     = render :partial => "shared/tag_list", :object => @tag_cloud, :locals => { :extra_params => {:controller => "questions", :action => "index"} }
253     .clear
254
255   - if @question.badges.size > 0
256     .block
257       %h3
258         = t('badges', :scope => "activerecord.models")
259       .content
260         %ul.list
261           -@question.badges.each do |badge|
262             %li
263               = render :partial => "badges/badge", :object => badge, :locals => {:hide_user => false}
264
265   .block.stats
266     - if @question.group_id != current_group.id
267       = t(".asked_on")
268       &= @question.group.name
269
270     .entry
271       .text.asked
272         = t('activerecord.attributes.question.created_at')
273         .data
274           = t("time.ago", :time => time_ago_in_words(@question.created_at))
275     .entry
276       .text.viewed
277         = t('.viewed')
278       .data
279         = t('number.x_time', :count => number_with_delimiter(@question.views_count))
280     .entry
281       .text.last_activity
282         = t(".last_activity")
283       .data.updated{:title => @question.activity_at, :class => "relativetime"}
284         = t("time.ago", :time => time_ago_in_words(@question.activity_at))
285
286   -related_questions = Question.related_questions(@question, :language => find_languages)
287   - if !related_questions.empty?
288     .block
289       %h3
290         =t(".related_questions")
291       .content
292         %ul.list
293           -related_questions.each do |rq|
294             %li
295               = link_to h(rq.title), question_path(rq), :title => truncate(strip_tags(rq.body), :length => 200)