This way we fix a bug we mentioned in commit 930bb753c which caused
links to documents to be broken when editing their title because the
title was used to generate the URL of the document.
Note we're still using Paperclip to render cached attachments because
this is the only case where we store files with just Paperclip and not
Active Storage.
With Active Storage, we render attachments just like any other resource,
using `polymorphic_path`. Paperclip included the `url` method in the
model; since the model doesn't have access to the request parameters
(like the host), this was inconvenient because it wasn't possible to
generate absolute URLs with Paperclip.
In order to simplify the code and make it similar to the way we used
Paperclip, we're adding a `variant` method accepting the name of a
variant and returning the variant.
124 lines
4.5 KiB
Plaintext
124 lines
4.5 KiB
Plaintext
<%= provide :title, t("social_share.polls_show.title_#{@poll.id}", default: @poll.title) %>
|
|
<%= provide :meta_description, t("social_share.polls_show.description_#{@poll.id}", default: @poll.title) %>
|
|
<%= provide :social_media_meta_tags do %>
|
|
<%= render "shared/social_media_meta_tags",
|
|
social_url: poll_url,
|
|
social_title: t("social_share.polls_show.title_#{@poll.id}", default: @poll.title),
|
|
social_description: t("social_share.polls_show.facebook_#{@poll.id}", default: @poll.title),
|
|
twitter_image_url: "social_media_polls_twitter.jpg",
|
|
og_image_url: "social_media_polls.jpg" %>
|
|
<% end %>
|
|
|
|
<div class="polls-show">
|
|
<%= render "poll_header" %>
|
|
|
|
<%= render "poll_subnav" %>
|
|
|
|
<div class="row margin">
|
|
<div class="small-12 medium-9 column">
|
|
<%= render "callout" %>
|
|
|
|
<% if @poll.voted_in_booth?(current_user) %>
|
|
<div class="callout warning">
|
|
<%= t("polls.show.already_voted_in_booth") %>
|
|
</div>
|
|
<% else %>
|
|
|
|
<% if current_user && @poll.voted_in_web?(current_user) && !@poll.expired? %>
|
|
<div class="callout warning">
|
|
<%= t("polls.show.already_voted_in_web") %>
|
|
</div>
|
|
<% end %>
|
|
<% end %>
|
|
|
|
<% @questions.each do |question| %>
|
|
<%= render "polls/questions/question", question: question, token: @token %>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="expanded poll-more-info">
|
|
<div class="row margin">
|
|
<div class="small-12 medium-9 column">
|
|
<h3><%= t("polls.show.more_info_title") %></h3>
|
|
<%= auto_link_already_sanitized_html simple_format(@poll.description) %>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="poll_more_info_answers" class="expanded poll-more-info-answers">
|
|
<div class="row padding">
|
|
<% @poll_questions_answers.each do |answer| %>
|
|
<div class="small-12 medium-6 column end answer <%= cycle("first", "") %>" id="answer_<%= answer.id %>">
|
|
<h3><%= answer.title %></h3>
|
|
|
|
<% if answer.images.any? %>
|
|
<%= render "gallery", answer: answer %>
|
|
<% end %>
|
|
|
|
<% if answer.description.present? %>
|
|
<div class="margin-top">
|
|
<div id="answer_description_<%= answer.id %>" class="answer-description short" data-toggler="short">
|
|
<%= wysiwyg(answer.description) %>
|
|
</div>
|
|
<div class="read-more">
|
|
<button type="button" id="read_more_<%= answer.id %>"
|
|
data-toggle="answer_description_<%= answer.id %> read_more_<%= answer.id %> read_less_<%= answer.id %>"
|
|
data-toggler="hide">
|
|
<%= t("polls.show.read_more", answer: answer.title) %>
|
|
</button>
|
|
<button type="button" id="read_less_<%= answer.id %>"
|
|
data-toggle="answer_description_<%= answer.id %> read_more_<%= answer.id %> read_less_<%= answer.id %>"
|
|
data-toggler="hide"
|
|
class="hide">
|
|
<%= t("polls.show.read_less", answer: answer.title) %>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
|
|
<% if answer.documents.present? %>
|
|
<div class="document-link">
|
|
<p>
|
|
<span class="icon-document"></span>
|
|
<strong><%= t("polls.show.documents") %></strong>
|
|
</p>
|
|
|
|
<% answer.documents.each do |document| %>
|
|
<%= link_to document.title,
|
|
document.storage_attachment,
|
|
target: "_blank",
|
|
rel: "nofollow" %><br>
|
|
<% end %>
|
|
</div>
|
|
<% end %>
|
|
|
|
<% if answer.videos.present? %>
|
|
<div class="video-link">
|
|
<p>
|
|
<span class="icon-video"></span>
|
|
<strong><%= t("polls.show.videos") %></strong>
|
|
</p>
|
|
|
|
<% answer.videos.each do |video| %>
|
|
<%= link_to video.title,
|
|
video.url,
|
|
target: "_blank",
|
|
rel: "nofollow" %><br>
|
|
<% end %>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="tabs-content" data-tabs-content="polls_tabs">
|
|
<%= render "filter_subnav" %>
|
|
|
|
<div class="tabs-panel is-active" id="tab-comments">
|
|
<%= render "comments" %>
|
|
</div>
|
|
</div>
|
|
</div>
|