Merge remote branch 'origin/fix-scrolling-comment'
[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         %span.fn.nickname
72           = link_to h(@question.user.login), user_path(@question.user)
73         %span.time_ago.published{:title => @question.created_at, :class => "relativetime"}
74           = t("time.ago", :time => time_ago_in_words(@question.created_at))
75           -if @question.wiki
76             .wiki_flag
77               wiki
78         %span.adr
79           -if !@question.user.hide_country
80             %span.country-name
81               = t("global.from", :site => @question.user.country_name)
82               = country_flag(@question.user.country_code, @question.user.country_name)
83       .clear
84     -if @question.updated_by.present?
85       .user_info
86         .gravatar.logo
87           = gravatar(@question.updated_by.email.to_s, :size => 32)
88         .user_data
89           %span.asked_by
90             = t('activerecord.attributes.question.updated_by')
91           %span.fn.nickname
92             = link_to h(@question.updated_by.login), user_path(@question.updated_by)
93           %span.time_ago.published{:title => @question.updated_at, :class => "relativetime"}
94             = t("time.ago", :time => time_ago_in_words(@question.updated_at))
95           %span.adr
96             -if !@question.updated_by.hide_country
97               %span.country-name
98                 = t("global.from", :site => @question.updated_by.country_name)
99                 = country_flag(@question.user.country_code, @question.updated_by.country_name)
100         .clear
101   .controls
102     .actions
103       =link_to t(".flag"), flag_question_path(@question), :class => "flag-link", :id => "question_flag_link", :rel => 'nofollow'
104       -if show_close_request_form
105         -close_link_label = current_user.mod_of?(current_group) ?  t(".close") : t(".request_closing")
106         =link_to close_link_label, new_question_close_request_path(@question), :id => "request-close-link", :rel => 'nofollow', :title => t('.request_closing_details')
107
108       -if logged_in?
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   =link_to t("comments.shared.add_comment"), "#", :id => "add_comment_link", :rel => 'nofollow'
131
132   .comments
133     -@question.comments.each do |comment|
134       = render :partial => "comments/comment", :object => comment, :locals => {:source => source, :mini => true}
135   .clear
136   .forms
137     .comment-form-question
138       -form_tag comments_path, :class => "form commentForm nestedAnswerForm", :id => "add_comment_form" do
139         -@comment = Comment.new
140         = render :partial => "comments/form", :locals => {:source => source, :commentable => @question}
141         .group.navform
142           = submit_tag t("comments.shared.comment_submit"), :class => "button"
143           = t("global.or")
144           = link_to t('scaffold.cancel'), '', :class => 'cancel_comment'
145
146 %a{:name=>"answers"}
147 #answers
148   .secondary-navigation{:class => @active_subtab.to_s}
149     .navtitle
150       = t(".answers_title", :count => @answers.total_entries + (@question.accepted ? 1 : 0))
151
152     %ul
153       %li.newest
154         = link_to t("questions.index.newest"), question_path(@question, :sort=>"newest", :anchor => "answers")
155       %li.votes
156         = link_to t("questions.index.votes"), question_path(@question, :sort=>"votes", :anchor => "answers")
157       %li.oldest
158         = link_to t("questions.index.oldest"), question_path(@question, :sort=>"oldest", :anchor => "answers")
159     .clear
160   .block
161     -if @question.accepted
162       -solution = @question.answer
163       =render :partial=> "answer", :locals=> {:question => @question, :answer => solution} unless solution.nil?
164     .hentry
165       -@answers.each do |answer|
166         =render :partial=> "answer", :locals=> {:question => @question, :answer => answer}
167     =will_paginate(@answers)
168
169 -unless @question.closed
170   %a{:name=>"to_answer"}
171   -form_for @answer, :url => question_answers_path(@question.id), :html => {:class => "form mainAnswerForm"} do |f|
172     = render :partial => "answers/form", :locals => {:f => f, :markdown => true}
173     .group.navform
174       .right
175         = f.label :wiki, "Wiki", :class => "radio"
176         = f.check_box :wiki, :class => "checkbox"
177       = submit_tag t('answers.form.submit'), :class => "button"
178     .clear
179
180 -content_for :sidebar do
181   -if logged_in? && (current_user.mod_of?(current_group) || current_user.can_view_offensive_counts_on?(current_group))
182     -unless @question.flags.count == 0
183       .block
184         %h3
185           = t(:flags, :scope => "activerecord.models")
186         .content
187           = render :partial => "flags/list", :locals => {:flaggeable => @question}
188
189     -unless @question.close_requests.size == 0
190       .block
191         %h3
192           = t(:prural_name, :scope => "close_requests.model")
193         .content
194           = render :partial => "close_requests/list", :locals => {:question => @question}
195
196   .block
197     %h3
198       = t('.tags', :default => [:"layouts.application.tags", :"activerecord.attributes.user.tags", "tags"])
199     = render :partial => "shared/tag_list", :object => @tag_cloud, :locals => { :extra_params => {:controller => "questions", :action => "index"} }
200     .clear
201
202   -if @question.badges.size > 0
203     .block
204       %h3
205         = t('badges', :scope => "activerecord.models")
206       .content
207         %ul.list
208           -@question.badges.each do |badge|
209             %li
210               = render :partial => "badges/badge", :object => badge, :locals => {:hide_user => false}
211
212   .block.stats
213     -if @question.group_id != current_group.id
214       = t(".asked_on")
215       &= @question.group.name
216
217     .entry
218       .text.asked
219         = t('activerecord.attributes.question.created_at')
220         .data
221           = t("time.ago", :time => time_ago_in_words(@question.created_at))
222     .entry
223       .text.viewed
224         = t('.viewed')
225       .data
226         = t('number.x_time', :count => number_with_delimiter(@question.views_count))
227     .entry
228       .text.last_activity
229         = t(".last_activity")
230       .data.updated{:title => @question.activity_at, :class => "relativetime"}
231         = t("time.ago", :time => time_ago_in_words(@question.activity_at))
232   -if AppConfig.enable_sharing
233     .block
234       %h3
235         = t(".share")
236       .content
237         %ul.navigation
238           %li
239             = render :partial => "twitter"
240           %li
241             = render :partial => "identica"
242           %li
243             = render :partial => "facebook"
244
245   -related_questions = Question.related_questions(@question, :language => find_languages)
246   -if !related_questions.empty?
247     .block
248       %h3
249         =t(".related_questions")
250       .content
251         %ul.list
252           -related_questions.each do |rq|
253             %li
254               =link_to h(rq.title), question_path(rq), :title => truncate(strip_tags(rq.body), :length => 200)
255
256
257 = javascript_include_tag 'jsMath/easy/load.js'