From 24e692b0cf1e6b2c3f1f209bebb39f0f9a97eb20 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 4 Dec 2016 12:58:35 +0100 Subject: Set a specific S3 expiration time so that files can be cached --- app/views/accounts/_grid_card.html.haml | 2 +- app/views/accounts/_header.html.haml | 4 ++-- app/views/accounts/show.atom.ruby | 2 +- app/views/api/v1/accounts/show.rabl | 4 ++-- app/views/api/v1/media/create.rabl | 4 ++-- app/views/api/v1/statuses/_media.rabl | 4 ++-- app/views/stream_entries/_status.html.haml | 2 +- app/views/stream_entries/show.html.haml | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) (limited to 'app/views') diff --git a/app/views/accounts/_grid_card.html.haml b/app/views/accounts/_grid_card.html.haml index d91c18476..d0f1ae3d4 100644 --- a/app/views/accounts/_grid_card.html.haml +++ b/app/views/accounts/_grid_card.html.haml @@ -1,6 +1,6 @@ .account-grid-card .account-grid-card__header - .avatar= image_tag account.avatar.expiring_url(3600, :original) + .avatar= image_tag account.avatar.expiring_url(s3_expiry, :original) .name = link_to TagManager.instance.url_for(account) do %span.display_name= display_name(account) diff --git a/app/views/accounts/_header.html.haml b/app/views/accounts/_header.html.haml index 4c7d53678..7c483e790 100644 --- a/app/views/accounts/_header.html.haml +++ b/app/views/accounts/_header.html.haml @@ -1,4 +1,4 @@ -.card{ style: "background-image: url(#{@account.header.expiring_url(3600, :original)})" } +.card{ style: "background-image: url(#{@account.header.expiring_url(s3_expiry, :original)})" } - if user_signed_in? && current_account.id != @account.id .controls - if current_account.following?(@account) @@ -6,7 +6,7 @@ - else = link_to t('accounts.follow'), follow_account_path(@account), data: { method: :post }, class: 'button' - .avatar= image_tag @account.avatar.expiring_url(3600, :original) + .avatar= image_tag @account.avatar.expiring_url(s3_expiry, :original) %h1.name = display_name(@account) %small= "@#{@account.username}" diff --git a/app/views/accounts/show.atom.ruby b/app/views/accounts/show.atom.ruby index 68b1c157d..2fcaecdce 100644 --- a/app/views/accounts/show.atom.ruby +++ b/app/views/accounts/show.atom.ruby @@ -6,7 +6,7 @@ Nokogiri::XML::Builder.new do |xml| title xml, @account.display_name subtitle xml, @account.note updated_at xml, stream_updated_at - logo xml, full_asset_url(@account.avatar.expiring_url(3600, :original)) + logo xml, full_asset_url(@account.avatar.expiring_url(s3_expiry, :original)) author(xml) do include_author xml, @account diff --git a/app/views/api/v1/accounts/show.rabl b/app/views/api/v1/accounts/show.rabl index a58db29b6..cd267eb00 100644 --- a/app/views/api/v1/accounts/show.rabl +++ b/app/views/api/v1/accounts/show.rabl @@ -4,8 +4,8 @@ attributes :id, :username, :acct, :display_name node(:note) { |account| Formatter.instance.simplified_format(account) } node(:url) { |account| TagManager.instance.url_for(account) } -node(:avatar) { |account| full_asset_url(account.avatar.expiring_url(3600, :original)) } -node(:header) { |account| full_asset_url(account.header.expiring_url(3600, :original)) } +node(:avatar) { |account| full_asset_url(account.avatar.expiring_url(s3_expiry, :original)) } +node(:header) { |account| full_asset_url(account.header.expiring_url(s3_expiry, :original)) } node(:followers_count) { |account| defined?(@followers_counts_map) ? (@followers_counts_map[account.id] || 0) : (account.try(:followers_count) || account.followers.count) } node(:following_count) { |account| defined?(@following_counts_map) ? (@following_counts_map[account.id] || 0) : (account.try(:following_count) || account.following.count) } node(:statuses_count) { |account| defined?(@statuses_counts_map) ? (@statuses_counts_map[account.id] || 0) : (account.try(:statuses_count) || account.statuses.count) } diff --git a/app/views/api/v1/media/create.rabl b/app/views/api/v1/media/create.rabl index 2a4db7aae..ba1a0c378 100644 --- a/app/views/api/v1/media/create.rabl +++ b/app/views/api/v1/media/create.rabl @@ -1,5 +1,5 @@ object @media attribute :id, :type -node(:url) { |media| full_asset_url(media.file.expiring_url(3600, :original)) } -node(:preview_url) { |media| full_asset_url(media.file.expiring_url(3600, :small)) } +node(:url) { |media| full_asset_url(media.file.expiring_url(s3_expiry, :original)) } +node(:preview_url) { |media| full_asset_url(media.file.expiring_url(s3_expiry, :small)) } node(:text_url) { |media| medium_url(media) } diff --git a/app/views/api/v1/statuses/_media.rabl b/app/views/api/v1/statuses/_media.rabl index 76256ed2c..83b986d51 100644 --- a/app/views/api/v1/statuses/_media.rabl +++ b/app/views/api/v1/statuses/_media.rabl @@ -1,4 +1,4 @@ attributes :id, :remote_url, :type -node(:url) { |media| full_asset_url(media.file.expiring_url(3600, :original)) } -node(:preview_url) { |media| full_asset_url(media.file.expiring_url(3600, :small)) } +node(:url) { |media| full_asset_url(media.file.expiring_url(s3_expiry, :original)) } +node(:preview_url) { |media| full_asset_url(media.file.expiring_url(s3_expiry, :small)) } diff --git a/app/views/stream_entries/_status.html.haml b/app/views/stream_entries/_status.html.haml index 42994abbd..8d6507623 100644 --- a/app/views/stream_entries/_status.html.haml +++ b/app/views/stream_entries/_status.html.haml @@ -34,7 +34,7 @@ - if (status.reblog? ? status.reblog : status).media_attachments.size > 0 %ul.media-attachments - (status.reblog? ? status.reblog : status).media_attachments.each do |media| - %li.transparent-background= link_to '', media.file.expiring_url(3600, :original), style: "background-image: url(#{media.file.expiring_url(3600, :small)})", target: '_blank' + %li.transparent-background= link_to '', media.file.expiring_url(s3_expiry, :original), style: "background-image: url(#{media.file.expiring_url(s3_expiry, :small)})", target: '_blank' - if include_threads = render partial: 'status', collection: @descendants, as: :status, locals: { is_successor: true } diff --git a/app/views/stream_entries/show.html.haml b/app/views/stream_entries/show.html.haml index 76dfa6dac..9a134ab16 100644 --- a/app/views/stream_entries/show.html.haml +++ b/app/views/stream_entries/show.html.haml @@ -7,7 +7,7 @@ %meta{ name: 'og:title', content: "#{@account.username} on #{Rails.configuration.x.local_domain}" }/ %meta{ name: 'og:article:author', content: @account.username }/ %meta{ name: 'og:description', content: @stream_entry.activity.content }/ - %meta{ name: 'og:image', content: @stream_entry.activity.is_a?(Status) && @stream_entry.activity.media_attachments.size > 0 ? full_asset_url(@stream_entry.activity.media_attachments.first.file.expiring_url(3600, :small)) : full_asset_url(@account.avatar.expiring_url(3600, :original)) }/ + %meta{ name: 'og:image', content: @stream_entry.activity.is_a?(Status) && @stream_entry.activity.media_attachments.size > 0 ? full_asset_url(@stream_entry.activity.media_attachments.first.file.expiring_url(s3_expiry, :small)) : full_asset_url(@account.avatar.expiring_url(s3_expiry, :original)) }/ .activity-stream.activity-stream-headless = render partial: @type, locals: { @type.to_sym => @stream_entry.activity, include_threads: true } -- cgit