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