Browse Source

Small optimizations in Atom feeds

closed-social-v3
Eugen Rochko 8 years ago
parent
commit
7e00a21ea6
5 changed files with 6 additions and 4 deletions
  1. +1
    -1
      app/controllers/accounts_controller.rb
  2. +1
    -1
      app/helpers/atom_builder_helper.rb
  3. +1
    -1
      app/models/status.rb
  4. +2
    -0
      app/models/stream_entry.rb
  5. +1
    -1
      app/views/accounts/show.atom.ruby

+ 1
- 1
app/controllers/accounts_controller.rb View File

@ -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

+ 1
- 1
app/helpers/atom_builder_helper.rb View File

@ -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)

+ 1
- 1
app/models/status.rb View File

@ -46,7 +46,7 @@ class Status < ActiveRecord::Base
end
def title
content.truncate(80, omission: "...")
content
end
def reblogs_count

+ 2
- 0
app/models/stream_entry.rb View File

@ -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

+ 1
- 1
app/views/accounts/show.atom.ruby View File

@ -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

Loading…
Cancel
Save