post answers as anonymous
[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         -if !@question.anonymous
76           = gravatar(@question.user.email.to_s, :size => 32)
77       .user_data
78         %span.asked_by
79           = t('activerecord.attributes.question.asked_by')
80         -if @question.anonymous
81           =t("global.anonymous")
82         -else
83           =render :partial => "users/user_mini", :locals => {:user => @question.user}
84         %span.time_ago.published{:title => @question.created_at, :class => "relativetime"}
85           = t("time.ago", :time => time_ago_in_words(@question.created_at))
86           - if @question.wiki
87             .wiki_flag
88               wiki
89         %span.adr
90           - if !@question.user.hide_country
91             %span.country-name
92               = t("global.from", :site => @question.user.country_name)
93               = country_flag(@question.user.country_code, @question.user.country_name)
94       .clear
95     - if @question.updated_by.present?
96       .user_info
97         .gravatar.logo
98           = gravatar(@question.updated_by.email.to_s, :size => 32)
99         .user_data
100           %span.asked_by
101             = t('activerecord.attributes.question.updated_by')
102           =render :partial => "users/user_mini", :locals => {:user => @question.updated_by}
103           %span.time_ago.published{:title => @question.updated_at, :class => "relativetime"}
104             = t("time.ago", :time => time_ago_in_words(@question.updated_at))
105           %span.adr
106             - if !@question.updated_by.hide_country
107               %span.country-name
108                 = t("global.from", :site => @question.updated_by.country_name)
109                 = country_flag(@question.updated_by.country_code, @question.updated_by.country_name)
110         .clear
111   .controls
112     .actions
113       - if !@flag.new?
114         .flagged
115           = "#{t('.flagged_as')} #{t(@flag.reason, :scope=>'flags.form')}"
116           = link_to t("scaffold.edit"), edit_question_flag_path(@question,@flag), :class => "flag-link", :id => "edit_question_flag_link", :rel => 'nofollow'
117           = link_to t("scaffold.destroy"), question_flag_path(@question,@flag), :id => "destroy_question_flag_link", :rel => 'nofollow', :confirm => "are you sure?", :method => :delete
118       - elsif logged_in? && current_user != @question.user
119         = link_to t(".flag"), new_question_flag_path(@question), :class => "flag-link", :id => "question_flag_link", :rel => 'nofollow'
120
121       - if logged_in?
122         - if show_close_request_form
123           -if !@close_request.new?
124             .flagged
125               = "#{t('.requested_close_as')} #{t(@close_request.reason, :scope=>'close_requests.form')}"
126               = link_to t(".edit_request"), edit_question_close_request_path(@question,@close_request), :class => "flag-link", :id => "edit_question_close_request_link", :rel => 'nofollow'
127               = link_to t(".retract_request"), question_close_request_path(@question,@close_request), :id => "destroy_question_close_request_link", :rel => 'nofollow', :confirm => "are you sure?", :method => :delete
128           = link_to t(".request_closing"), @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')
129
130         - if show_open_request_form
131           -if !@open_request.new?
132             .flagged
133               = "#{t('.requested_reopening')} #{@open_request.comment}"
134               = link_to t(".edit_request"), edit_question_open_request_path(@question, @open_request), :class => "flag-link", :id => "edit_question_open_request_link", :rel => 'nofollow'
135               = link_to t(".retract_request"), question_open_request_path(@question,@open_request), :id => "destroy_question_open_request_link", :rel => 'nofollow', :confirm => "are you sure?", :method => :delete
136
137           -if current_user.mod_of?(current_group)
138             = link_to t(".open"), open_question_path(@question), :rel => 'nofollow', :title => t('.request_opening_details'), :method => "put"
139           -else
140             = link_to t(".request_opening"), new_question_open_request_path(@question), :id => "request-open-link", :rel => 'nofollow', :title => t('.request_opening_details')
141
142         - 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)
143           = link_to t('scaffold.edit'), edit_question_path(@question), :class => "button"
144         - if @question.versions.count > 0
145           = link_to t(".history", :default => "history"), history_question_path(@question)
146         - if (current_user.can_modify?(@question) || current_user.owner_of?(@question.group))
147           = link_to t("scaffold.destroy"), question_path(@question.id), :confirm => "are you sure?", :method => :delete
148         - if current_user.mod_of?(@question.group)
149           -if !@question.closed
150             = link_to t('.close'), question_close_requests_path(@question)
151           = link_to t(".ban"), ban_path(:question_ids => [@question.id]), :class => "button", :confirm => "are you sure?"
152     .forms
153       -# render :partial => "flags/form", :locals => {:flag => @flag, :flaggeable => @question, :source => source, :form_id => "question_flag_form" }
154
155       -# if !@question.closed && show_close_request_form
156         -#= render :partial => "close_requests/form", :locals => { :question => @question, :close_request => @close_request, :hide => true, :form_id => "request_close_question_form"}
157
158   - if logged_in?
159     = link_to t("comments.shared.add_comment"), new_question_comment_path(@question), :id => "add_comment_link", :rel => 'nofollow'
160
161   .comments
162     -@question.comments.each do |comment|
163       = render :partial => "comments/comment", :object => comment, :locals => {:source => source, :mini => true}
164   .clear
165   .forms
166     .comment-form-question
167       -form_tag question_comments_path(@question), :class => "form commentForm nestedAnswerForm", :id => "add_comment_form" do
168         -@comment = Comment.new
169         = render :partial => "comments/form", :locals => {:source => source, :commentable => @question}
170         .group.navform
171           = submit_tag t("comments.shared.comment_submit"), :class => "button"
172           = t("global.or")
173           = link_to t('scaffold.cancel'), '', :class => 'cancel_comment'
174
175 %a{:name=>"answers"}
176 #answers
177   .secondary-navigation{:class => @active_subtab.to_s}
178     .navtitle
179       = t(".answers_title", :count => @answers.total_entries + (@question.accepted ? 1 : 0))
180
181     %ul
182       %li.newest
183         = link_to t("questions.index.newest"), question_path(@question, :sort=>"newest", :anchor => "answers"), :rel => "nofollow"
184       %li.votes
185         = link_to t("questions.index.votes"), question_path(@question, :sort=>"votes", :anchor => "answers"), :rel => "nofollow"
186       %li.oldest
187         = link_to t("questions.index.oldest"), question_path(@question, :sort=>"oldest", :anchor => "answers"), :rel => "nofollow"
188     .clear
189   .block
190     - if @question.accepted
191       -solution = @question.answer
192       =render :partial=> "answer", :locals=> {:question => @question, :answer => solution} unless solution.nil?
193     .hentry
194       -@answers.each do |answer|
195         =render :partial=> "answer", :locals=> {:question => @question, :answer => answer}
196     =will_paginate(@answers)
197
198 -unless @question.closed
199   %a{:name=>"to_answer"}
200   -form_for @answer, :url => question_answers_path(@question.id), :html => {:class => "form mainAnswerForm"} do |f|
201     = render :partial => "answers/form", :locals => {:f => f, :markdown => true}
202     .group.navform
203       .controls.right{:style => "width: 50%"}
204         .left{:style => "width: 49.5%"}
205           = f.label :wiki, "Wiki", :class => "radio"
206           = f.check_box :wiki, :class => "checkbox"
207         .left{:style => "width: 49.5%"}
208           = f.label :anonymous, t("scaffold.post_as_anonymous"), :class => "radio"
209           = f.check_box :anonymous, :class => "checkbox"
210       = submit_tag t('answers.form.submit'), :class => "button"
211     .clear
212
213 -content_for :sidebar do
214   - if AppConfig.enable_sharing
215     .block
216       %h3
217         = t(".share")
218       .content
219         %ul.share
220           %li
221             = render :partial => "identica"
222           - if current_group.domain != AppConfig.domain
223             %li
224               = render :partial => "shapado"
225           %li
226             = render :partial => "twitter"
227           %li
228             = render :partial => "linkedin"
229           %li
230             = render :partial => "think"
231           %li
232             = render :partial => "facebook"
233       .clear
234
235   - if logged_in? && (current_user.mod_of?(current_group) || current_user.can_view_offensive_counts_on?(current_group))
236     -unless @question.flags.count == 0
237       .block
238         %h3
239           = t(:flags, :scope => "activerecord.models")
240         .content
241           = render :partial => "flags/list", :locals => {:flaggeable => @question}
242
243     -unless @question.close_requests.size == 0
244       .block
245         %h3
246           = t(:prural_name, :scope => "close_requests.model")
247         .content
248           = render :partial => "close_requests/list", :locals => {:question => @question}
249
250     -unless @question.open_requests.size == 0
251       .block
252         %h3
253           = t(:prural_name, :scope => "open_requests.model")
254         .content
255           = render :partial => "open_requests/list", :locals => {:question => @question}
256
257   .block
258     %h3
259       = t('.tags', :default => [:"layouts.application.tags", :"activerecord.attributes.user.tags", "tags"])
260     = render :partial => "shared/tag_list", :object => @tag_cloud, :locals => { :extra_params => {:controller => "questions", :action => "index"} }
261     .clear
262
263   - if @question.badges.size > 0
264     .block
265       %h3
266         = t('badges', :scope => "activerecord.models")
267       .content
268         %ul.list
269           -@question.badges.each do |badge|
270             %li
271               = render :partial => "badges/badge", :object => badge, :locals => {:hide_user => false}
272
273   .block.stats
274     - if @question.group_id != current_group.id
275       = t(".asked_on")
276       &= @question.group.name
277
278     .entry
279       .text.asked
280         = t('activerecord.attributes.question.created_at')
281         .data
282           = t("time.ago", :time => time_ago_in_words(@question.created_at))
283     .entry
284       .text.viewed
285         = t('.viewed')
286       .data
287         = t('number.x_time', :count => number_with_delimiter(@question.views_count))
288     .entry
289       .text.last_activity
290         = t(".last_activity")
291       .data.updated{:title => @question.activity_at, :class => "relativetime"}
292         = t("time.ago", :time => time_ago_in_words(@question.activity_at))
293
294   -related_questions = Question.related_questions(@question, :language => find_languages)
295   - if !related_questions.empty?
296     .block
297       %h3
298         =t(".related_questions")
299       .content
300         %ul.list
301           -related_questions.each do |rq|
302             %li
303               = link_to h(rq.title), question_path(rq), :title => truncate(strip_tags(rq.body), :length => 200)