From 0f4bc567195d368de596cdeeee6bc0b6507ae95e Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 8 Sep 2016 01:24:26 +0200 Subject: Improving production logs, removing n+1 on media attachments in atom, adding attachments display to static views --- .../components/components/media_gallery.jsx | 2 +- app/assets/stylesheets/stream_entries.scss | 31 +++++++++++++++++++++- app/controllers/accounts_controller.rb | 2 +- app/views/stream_entries/_status.html.haml | 4 +++ 4 files changed, 36 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/assets/javascripts/components/components/media_gallery.jsx b/app/assets/javascripts/components/components/media_gallery.jsx index 45d2f2492..81bf7c87c 100644 --- a/app/assets/javascripts/components/components/media_gallery.jsx +++ b/app/assets/javascripts/components/components/media_gallery.jsx @@ -59,7 +59,7 @@ const MediaGallery = React.createClass({ } } - return ; + return ; }); return ( diff --git a/app/assets/stylesheets/stream_entries.scss b/app/assets/stylesheets/stream_entries.scss index 93880237c..25a536e24 100644 --- a/app/assets/stylesheets/stream_entries.scss +++ b/app/assets/stylesheets/stream_entries.scss @@ -158,7 +158,7 @@ font-size: 14px; padding: 0 10px; padding-left: 8px; - padding-bottom: 25px; + padding-bottom: 15px; color: #282c37; a { @@ -189,4 +189,33 @@ text-decoration: underline; } } + + .media-attachments { + list-style: none; + margin: 0; + padding: 0; + display: block; + overflow: hidden; + padding-left: 10px; + + li { + display: block; + float: left; + width: 120px; + height: 100px; + border-radius: 4px; + margin-right: 4px; + margin-bottom: 25px; + + a { + display: block; + width: 120px; + height: 100px; + border-radius: 4px; + background-position: center; + background-repeat: none; + background-size: cover; + } + } + } } diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 162e85dec..3c02e0bec 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -11,7 +11,7 @@ class AccountsController < ApplicationController format.atom do @entries = @account.stream_entries.order('id desc').with_includes.paginate_by_max_id(20, params[:max_id] || nil) - ActiveRecord::Associations::Preloader.new.preload(@entries.select { |a| a.activity_type == 'Status' }, activity: [:mentions, reblog: :account, thread: :account]) + ActiveRecord::Associations::Preloader.new.preload(@entries.select { |a| a.activity_type == 'Status' }, activity: [:mentions, :media_attachments, reblog: :account, thread: :account]) ActiveRecord::Associations::Preloader.new.preload(@entries.select { |a| a.activity_type == 'Favourite' }, activity: [:account, :status]) ActiveRecord::Associations::Preloader.new.preload(@entries.select { |a| a.activity_type == 'Follow' }, activity: :target_account) end diff --git a/app/views/stream_entries/_status.html.haml b/app/views/stream_entries/_status.html.haml index d210805fe..defadffc6 100644 --- a/app/views/stream_entries/_status.html.haml +++ b/app/views/stream_entries/_status.html.haml @@ -38,6 +38,10 @@ .content= content_for_status(proper_status(status)) + %ul.media-attachments + - status.media_attachments.each do |media| + %li.transparent-background= link_to '', media.file.url, style: "background-image: url(#{media.file.url(:small)})", target: '_blank' + - if include_threads - status.descendants.with_includes.with_counters.each do |status| = render partial: 'status', locals: { status: status, is_successor: true } -- cgit