Localisation updates from https://translatewiki.net.
[shapado:shapado.git] / app / views / questions / show.html.haml
1 %meta{"data-js"=> 'show'}
2 = include_latex
3
4 - question_body = find_and_preserve(shapado_auto_link(markdown(@question.body.present? ? @question.body : @question.title)))
5
6 - content_for :head do
7   %meta{name: "keywords", content: clean_seo_keywords(@question.tags.dup, @question.title)}
8   %meta{name: "description", content: question_body.gsub(/<\/?[^>]*>/, "")[0, 255] }
9   %link{rel: "canonical", href: question_url(@question) }
10
11 -cache_for(:question, @question.id, @question.user == current_user ? "owner" : "" ) do
12   %section{class: "main-question #{@question.id}", id: "question-#{@question.id}", item_scope: '', itemtype: "http://schema.org/Article"}
13
14     %h1{itemprop: "name"}
15       = @question.title
16       - if @question.closed
17         =" [#{t("closed", scope: "activerecord.attributes.question").upcase}]"
18     .author
19       %small
20         %span
21           = t('activerecord.attributes.question.asked_by')
22         = render "users/user_mini", user: @question.user, author: true
23         %time{datetime: @question.created_at.iso8601, itemprop: "datePublished"}
24           = t("time.ago", time: time_ago_in_words(@question.created_at))
25         - if @question.updated_by
26           ,
27           = t('global.edited_by')
28           = render "users/user_mini", user: @question.updated_by
29
30           %time{datetime: @question.updated_at.iso8601, itemprop: "dateModified"}
31             = link_to t("time.ago", time: time_ago_in_words(@question.updated_at)), history_question_path(@question), title: "#{t("questions.show.history")} (#{@question.versions_count})"
32
33     .description.markdown.clearfix
34       %div{itemprop: "articleBody"}
35         = question_body
36       = render "reward_info"
37       = render "attachments", question: @question, attachments: @question.attachments, editing: false
38
39
40     %ul.tag-list.clearfix
41       - @question.tags.each do |tag|
42         %li
43           = tag_link(tag)
44       - if logged_in? && (current_user.can_modify?(@question) || current_user.can_retag_others_questions_on?(current_group))
45         %li.retag
46           = link_to t('.retag'), retag_question_path(@question), class: 'retag-link'
47
48     %meta{itemprop: "keywords", content: @question.tags.join(",")}
49     %meta{itemprop: "inLanguage", content: @question.language}
50     %meta{itemprop: "interactionCount", content: "UserComments:#{@question.answers_count}"}
51     %meta{itemprop: "interactionCount", content: "UserPageVisits:#{@question.views_count}"}
52
53     = render "toolbar"
54
55     .comments
56       =link_to "#{content_tag(:span, "NN", class: "counter")} comments".html_safe, "#", class: "toggle_comments"
57       -@question.comments.each do |comment|
58         -read = (@last_read_at && @last_read_at > comment.created_at && comment.votes_average < 2)
59         = render "comments/comment", comment: comment, source: question_path(@question), mini: true, read: read
60
61     .panel-comments
62       = form_for [@question, @comment ||= Comment.new], remote: true, html: {class: "question_comment_form", data: {commentable: @question.id, editor: current_group.wysiwyg_editor ? 'wysiwyg_editor' : 'markdown_editor', "login-required" => true}} do |f|
63         %fieldset
64           = render "comments/form", f: f, commentable: @question, source: question_url(@question)
65           .buttons
66             = f.submit t("comments.shared.comment_submit"), data: {"disable-with" => "Saving..."}
67             = t("global.or")
68             = link_to t('scaffold.cancel'), '', :class => 'cancel cancel_comment'
69
70 #answers-content-wrap
71   .error
72     - source = question_path(@question)
73     = error_messages_for 'answer'
74
75   - if @question.closed && @question.close_reason.present?
76     #close_reason
77       = t(".close_reason")
78       = t(@question.close_reason.reason, scope: "close_requests.form")
79       - if !@question.close_reason.comment.empty?
80
81         .comment
82           =find_and_preserve(shapado_auto_link(@question.close_reason.comment))
83   - if !@answers.empty? || @question.accepted
84     -cache_for(:question_answers, @question.id) do
85       %h2
86         = t("questions.question.has_answers", count: @question.answers_count)
87
88       .filters.clearfix
89         %ul.menubar{class: @active_subtab.to_s}
90           %li
91             %label=t('global.sort_by')
92           %li.newest-active
93             = link_to t("questions.index.newest"), question_path(@question, sort: "newest", anchor: "answers"), rel: "nofollow", class: "pjax", data: {layout: "question"}
94           %li.votes-active
95             = link_to t("questions.index.votes"), question_path(@question, sort: "votes", anchor: "answers"), rel: "nofollow", class: "pjax", data: {layout: "question"}
96           %li.oldest-active
97             = link_to t("questions.index.oldest"), question_path(@question, sort: "oldest", anchor: "answers"), rel: "nofollow", class: "pjax", data: {layout: "question"}
98           %li
99             = link_to t('.solution')
100
101         -if @question.follow_up
102           .followUp-content
103             %h1
104               = t("questions.show.follow_up_of")
105             = link_to @question.follow_up.original_question.title, question_path(@question.follow_up.original_question, anchor: @question.follow_up.original_answer_id), rel: 'nofollow'
106
107         -if @question.followed_up_by.limit(1).count > 0
108           %h1= t('global.followed_by')
109           %ul
110             -@question.followed_up_by.all.each do |child|
111               %li
112                 = link_to child.title, question_path(child)
113
114   - if !@answers.empty? || @question.accepted
115     .answers-list
116       - if @question.accepted
117         - solution = @question.answer
118         = render "answer", question: @question, answer: solution unless solution.nil?
119
120       - @answers.each do |answer|
121         - next if answer.id == @question.answer_id
122         = render "answer", {:question => @question, :answer => answer}
123
124       = paginate(@answers)
125
126   -if !@question.closed || !(logged_in? && current_user.can_answer_on?(current_group))
127     #to_answer
128       -if logged_in? && @question.answers.where(user_id: current_user.id).count > 0
129         %h2
130         .toolbar
131           %ul.menubar
132             %li.action
133               = link_to "Add another answer", "#", id: "add_another_answer"
134       -else
135         %h2
136           -#i18n
137           Your answer
138
139       = render "answers/form", markdown: true, question: @question