diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2016-03-21 10:31:20 +0100 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2016-03-21 10:31:20 +0100 |
commit | 7e00a21ea6f76f8167f1070fbfe231bbd65c6cad (patch) | |
tree | f9dc54efab6e4fc905934786e468f14320fe4277 | |
parent | 19a259915eedcdff8c1e82f3b99a6249010b4b30 (diff) |
Small optimizations in Atom feeds
-rw-r--r-- | app/controllers/accounts_controller.rb | 2 | ||||
-rw-r--r-- | app/helpers/atom_builder_helper.rb | 2 | ||||
-rw-r--r-- | app/models/status.rb | 2 | ||||
-rw-r--r-- | app/models/stream_entry.rb | 2 | ||||
-rw-r--r-- | app/views/accounts/show.atom.ruby | 2 |
5 files changed, 6 insertions, 4 deletions
diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 72d32baf0..cfccd0f19 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -7,7 +7,7 @@ class AccountsController < ApplicationController def show respond_to do |format| format.html { @statuses = @account.statuses.order('id desc').with_includes.with_counters.paginate(page: params[:page], per_page: 10)} - format.atom + format.atom { @entries = @account.stream_entries.order('id desc').with_includes } end end diff --git a/app/helpers/atom_builder_helper.rb b/app/helpers/atom_builder_helper.rb index da3a1a9b8..b9eb79fbd 100644 --- a/app/helpers/atom_builder_helper.rb +++ b/app/helpers/atom_builder_helper.rb @@ -40,7 +40,7 @@ module AtomBuilderHelper end def title(xml, title) - xml.title title + xml.title strip_tags(title || '').truncate(80) end def author(xml, &block) diff --git a/app/models/status.rb b/app/models/status.rb index 7c5cd2f8a..08b5ee75e 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -46,7 +46,7 @@ class Status < ActiveRecord::Base end def title - content.truncate(80, omission: "...") + content end def reblogs_count diff --git a/app/models/stream_entry.rb b/app/models/stream_entry.rb index 0cc959a1c..68a33ccf7 100644 --- a/app/models/stream_entry.rb +++ b/app/models/stream_entry.rb @@ -4,6 +4,8 @@ class StreamEntry < ActiveRecord::Base validates :account, :activity, presence: true + scope :with_includes, -> { includes(:activity) } + def object_type orphaned? ? :activity : (targeted? ? :activity : self.activity.object_type) end diff --git a/app/views/accounts/show.atom.ruby b/app/views/accounts/show.atom.ruby index eaa4c63b1..e2ae57cc4 100644 --- a/app/views/accounts/show.atom.ruby +++ b/app/views/accounts/show.atom.ruby @@ -15,7 +15,7 @@ Nokogiri::XML::Builder.new do |xml| link_hub xml, Rails.configuration.x.hub_url link_salmon xml, api_salmon_url(@account.id) - @account.stream_entries.order('id desc').each do |stream_entry| + @entries.order('id desc').each do |stream_entry| entry(xml, false) do include_entry xml, stream_entry end |