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