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