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