Add method to investments helper to calculate absolute url for investments images. Use it in social share widget.
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
module InvestmentsHelper
|
module InvestmentsHelper
|
||||||
|
|
||||||
|
def investment_image_full_url(investment, version)
|
||||||
|
URI(request.url) + investment.image.url(version)
|
||||||
|
end
|
||||||
|
|
||||||
def investment_image_file_name(investment)
|
def investment_image_file_name(investment)
|
||||||
investment.image.url.split('/').last.split("?")[0] if investment.image.present?
|
investment.image.url.split('/').last.split("?")[0] if investment.image.present?
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<div id="<%= dom_id(investment) %>" class="budget-investment clear">
|
<div id="<%= dom_id(investment) %>" class="budget-investment clear">
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
<div class="small-12 medium-3 large-2 column">
|
<div class="small-12 medium-3 large-2 column">
|
||||||
<% if investment.image.exists? %>
|
<% if investment.image.exists? %>
|
||||||
<picture>
|
<picture>
|
||||||
@@ -16,12 +17,16 @@
|
|||||||
<div class="no-image"></div>
|
<div class="no-image"></div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="small-12 medium-6 large-7 column">
|
<div class="small-12 medium-6 large-7 column">
|
||||||
<div class="budget-investment-content">
|
<div class="budget-investment-content">
|
||||||
|
|
||||||
<% cache [locale_and_user_status(investment), 'index', investment, investment.author] do %>
|
<% cache [locale_and_user_status(investment), 'index', investment, investment.author] do %>
|
||||||
<h3><%= link_to investment.title, namespaced_budget_investment_path(investment) %></h3>
|
<h3><%= link_to investment.title, namespaced_budget_investment_path(investment) %></h3>
|
||||||
|
|
||||||
<p class="investment-project-info">
|
<p class="investment-project-info">
|
||||||
<%= l investment.created_at.to_date %>
|
<%= l investment.created_at.to_date %>
|
||||||
|
|
||||||
<% if investment.author.hidden? || investment.author.erased? %>
|
<% if investment.author.hidden? || investment.author.erased? %>
|
||||||
<span class="bullet"> • </span>
|
<span class="bullet"> • </span>
|
||||||
<span class="author">
|
<span class="author">
|
||||||
@@ -39,6 +44,7 @@
|
|||||||
</span>
|
</span>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<span class="bullet"> • </span>
|
<span class="bullet"> • </span>
|
||||||
<%= investment.heading.name %>
|
<%= investment.heading.name %>
|
||||||
</p>
|
</p>
|
||||||
@@ -52,6 +58,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% unless investment.unfeasible? %>
|
<% unless investment.unfeasible? %>
|
||||||
|
|
||||||
<% if investment.should_show_votes? %>
|
<% if investment.should_show_votes? %>
|
||||||
<div id="<%= dom_id(investment) %>_votes"
|
<div id="<%= dom_id(investment) %>_votes"
|
||||||
class="small-12 medium-3 column text-center">
|
class="small-12 medium-3 column text-center">
|
||||||
@@ -88,6 +95,7 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<section class="budget-investment-show" id="<%= dom_id(investment) %>">
|
<section class="budget-investment-show" id="<%= dom_id(investment) %>">
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="small-12 medium-9 column">
|
<div class="small-12 medium-9 column">
|
||||||
<%= back_link_to budget_investments_path(investment.budget, heading_id: investment.heading) %>
|
<%= back_link_to budget_investments_path(investment.budget, heading_id: investment.heading) %>
|
||||||
@@ -18,12 +19,15 @@
|
|||||||
<h1><%= investment.title %></h1>
|
<h1><%= investment.title %></h1>
|
||||||
<div class="budget-investment-info">
|
<div class="budget-investment-info">
|
||||||
<%= render '/shared/author_info', resource: investment %>
|
<%= render '/shared/author_info', resource: investment %>
|
||||||
|
|
||||||
<span class="bullet"> • </span>
|
<span class="bullet"> • </span>
|
||||||
<%= l investment.created_at.to_date %>
|
<%= l investment.created_at.to_date %>
|
||||||
<span class="bullet"> • </span>
|
<span class="bullet"> • </span>
|
||||||
<%= investment.heading.name %>
|
<%= investment.heading.name %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<% if investment.image.exists? %>
|
<% if investment.image.exists? %>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="small-12 column text-center">
|
<div class="small-12 column text-center">
|
||||||
@@ -39,19 +43,23 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<p id="investment_code">
|
<p id="investment_code">
|
||||||
<%= t("budgets.investments.show.code_html", code: investment.id) %>
|
<%= t("budgets.investments.show.code_html", code: investment.id) %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<% if investment.location.present? %>
|
<% if investment.location.present? %>
|
||||||
<p>
|
<p>
|
||||||
<%= t("budgets.investments.show.location_html", location: investment.location) %>
|
<%= t("budgets.investments.show.location_html", location: investment.location) %>
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if investment.organization_name.present? %>
|
<% if investment.organization_name.present? %>
|
||||||
<p>
|
<p>
|
||||||
<%= t("budgets.investments.show.organization_name_html", name: investment.organization_name) %>
|
<%= t("budgets.investments.show.organization_name_html", name: investment.organization_name) %>
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= render 'shared/tags', taggable: investment %>
|
<%= render 'shared/tags', taggable: investment %>
|
||||||
|
|
||||||
<%= safe_html_with_links investment.description.html_safe %>
|
<%= safe_html_with_links investment.description.html_safe %>
|
||||||
@@ -61,10 +69,12 @@
|
|||||||
<%= text_with_links investment.external_url %>
|
<%= text_with_links investment.external_url %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if investment.unfeasible? && investment.unfeasibility_explanation.present? %>
|
<% if investment.unfeasible? && investment.unfeasibility_explanation.present? %>
|
||||||
<h2><%= t('budgets.investments.show.unfeasibility_explanation') %></h2>
|
<h2><%= t('budgets.investments.show.unfeasibility_explanation') %></h2>
|
||||||
<p><%= investment.unfeasibility_explanation %></p>
|
<p><%= investment.unfeasibility_explanation %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if investment.should_show_price_info? %>
|
<% if investment.should_show_price_info? %>
|
||||||
<h2><%= t('budgets.investments.show.price_explanation') %></h2>
|
<h2><%= t('budgets.investments.show.price_explanation') %></h2>
|
||||||
<p><%= investment.price_explanation %></p>
|
<p><%= investment.price_explanation %></p>
|
||||||
@@ -129,7 +139,7 @@
|
|||||||
<%= render partial: 'shared/social_share', locals: {
|
<%= render partial: 'shared/social_share', locals: {
|
||||||
share_title: t("budgets.investments.show.share"),
|
share_title: t("budgets.investments.show.share"),
|
||||||
title: investment.title,
|
title: investment.title,
|
||||||
image_url: investment.image.exists? ? URI(request.url) + investment.image.url(:thumb) : '',
|
image_url: investment.image.exists? ? investment_image_full_url(investment, :thumb) : '',
|
||||||
url: budget_investment_url(budget_id: investment.budget_id, id: investment.id)
|
url: budget_investment_url(budget_id: investment.budget_id, id: investment.id)
|
||||||
} %>
|
} %>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user