diff options
-rw-r--r-- | app/controllers/accounts_controller.rb | 7 | ||||
-rw-r--r-- | app/controllers/api/v1/accounts_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/api/v1/timelines_controller.rb | 8 | ||||
-rw-r--r-- | app/controllers/application_controller.rb | 1 | ||||
-rw-r--r-- | app/controllers/tags_controller.rb | 3 | ||||
-rw-r--r-- | app/helpers/application_helper.rb | 4 | ||||
-rw-r--r-- | app/views/accounts/show.html.haml | 2 | ||||
-rw-r--r-- | app/views/tags/show.html.haml | 2 | ||||
-rw-r--r-- | config/locales/devise.pt.yml | 4 | ||||
-rw-r--r-- | config/locales/pt.yml | 3 |
10 files changed, 21 insertions, 15 deletions
diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 5d2f4eee0..b0e5a8320 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -9,7 +9,8 @@ class AccountsController < ApplicationController def show respond_to do |format| format.html do - @statuses = @account.statuses.order('id desc').with_includes.with_counters.paginate(page: params[:page], per_page: 10) + @statuses = @account.statuses.order('id desc').paginate_by_max_id(20, params[:max_id || nil]) + @statuses = cache_collection(@statuses, Status) end format.atom do @@ -29,11 +30,11 @@ class AccountsController < ApplicationController end def followers - @followers = @account.followers.order('follows.created_at desc').paginate(page: params[:page], per_page: 6) + @followers = @account.followers.order('follows.created_at desc').paginate(page: params[:page], per_page: 12) end def following - @following = @account.following.order('follows.created_at desc').paginate(page: params[:page], per_page: 6) + @following = @account.following.order('follows.created_at desc').paginate(page: params[:page], per_page: 12) end private diff --git a/app/controllers/api/v1/accounts_controller.rb b/app/controllers/api/v1/accounts_controller.rb index 9a356196c..0abdfd9fa 100644 --- a/app/controllers/api/v1/accounts_controller.rb +++ b/app/controllers/api/v1/accounts_controller.rb @@ -47,7 +47,7 @@ class Api::V1::AccountsController < ApiController end def statuses - @statuses = @account.statuses.paginate_by_max_id(DEFAULT_STATUSES_LIMIT, params[:max_id], params[:since_id]).to_a + @statuses = @account.statuses.paginate_by_max_id(DEFAULT_STATUSES_LIMIT, params[:max_id], params[:since_id]) @statuses = cache_collection(@statuses, Status) set_maps(@statuses) diff --git a/app/controllers/api/v1/timelines_controller.rb b/app/controllers/api/v1/timelines_controller.rb index 89e54e2cf..9727797e5 100644 --- a/app/controllers/api/v1/timelines_controller.rb +++ b/app/controllers/api/v1/timelines_controller.rb @@ -7,7 +7,7 @@ class Api::V1::TimelinesController < ApiController respond_to :json def home - @statuses = Feed.new(:home, current_account).get(DEFAULT_STATUSES_LIMIT, params[:max_id], params[:since_id]).to_a + @statuses = Feed.new(:home, current_account).get(DEFAULT_STATUSES_LIMIT, params[:max_id], params[:since_id]) @statuses = cache_collection(@statuses) set_maps(@statuses) @@ -23,7 +23,7 @@ class Api::V1::TimelinesController < ApiController end def mentions - @statuses = Feed.new(:mentions, current_account).get(DEFAULT_STATUSES_LIMIT, params[:max_id], params[:since_id]).to_a + @statuses = Feed.new(:mentions, current_account).get(DEFAULT_STATUSES_LIMIT, params[:max_id], params[:since_id]) @statuses = cache_collection(@statuses) set_maps(@statuses) @@ -39,7 +39,7 @@ class Api::V1::TimelinesController < ApiController end def public - @statuses = Status.as_public_timeline(current_account).paginate_by_max_id(DEFAULT_STATUSES_LIMIT, params[:max_id], params[:since_id]).to_a + @statuses = Status.as_public_timeline(current_account).paginate_by_max_id(DEFAULT_STATUSES_LIMIT, params[:max_id], params[:since_id]) @statuses = cache_collection(@statuses) set_maps(@statuses) @@ -56,7 +56,7 @@ class Api::V1::TimelinesController < ApiController def tag @tag = Tag.find_by(name: params[:id].downcase) - @statuses = @tag.nil? ? [] : Status.as_tag_timeline(@tag, current_account).paginate_by_max_id(DEFAULT_STATUSES_LIMIT, params[:max_id], params[:since_id]).to_a + @statuses = @tag.nil? ? [] : Status.as_tag_timeline(@tag, current_account).paginate_by_max_id(DEFAULT_STATUSES_LIMIT, params[:max_id], params[:since_id]) @statuses = cache_collection(@statuses) set_maps(@statuses) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9722f86b5..fbe4af07c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -61,6 +61,7 @@ class ApplicationController < ActionController::Base def cache_collection(raw, klass) return raw unless klass.respond_to?(:with_includes) + raw = raw.select(:id, :updated_at).to_a if raw.is_a?(ActiveRecord::Relation) uncached_ids = [] cached_keys_with_value = Rails.cache.read_multi(*raw.map(&:cache_key)) diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index a6b359485..4a70b2a8f 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -4,6 +4,7 @@ class TagsController < ApplicationController layout 'public' def show - @statuses = Tag.find_by!(name: params[:id].downcase).statuses.order('id desc').with_includes.with_counters.paginate(page: params[:page], per_page: 10) + @statuses = Tag.find_by!(name: params[:id].downcase).statuses.order('id desc').paginate_by_max_id(20, params[:max_id] || nil) + @statuses = cache_collection(@statuses, Status) end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index be82ff2fe..29c2c9120 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -4,4 +4,8 @@ module ApplicationHelper def active_nav_class(path) current_page?(path) ? 'active' : '' end + + def id_paginate(path, per_page, collection) + # todo + end end diff --git a/app/views/accounts/show.html.haml b/app/views/accounts/show.html.haml index 563b43849..c04faa32f 100644 --- a/app/views/accounts/show.html.haml +++ b/app/views/accounts/show.html.haml @@ -14,4 +14,4 @@ .activity-stream = render partial: 'stream_entries/status', collection: @statuses, as: :status -= will_paginate @statuses, pagination_options += id_paginate account_url(@account), 20, @statuses diff --git a/app/views/tags/show.html.haml b/app/views/tags/show.html.haml index 0e6fd2db7..bfe5c0439 100644 --- a/app/views/tags/show.html.haml +++ b/app/views/tags/show.html.haml @@ -5,4 +5,4 @@ .activity-stream = render partial: 'stream_entries/status', collection: @statuses, as: :status, cached: true -= will_paginate @statuses, pagination_options += id_paginate tag_path, 20, @statuses diff --git a/config/locales/devise.pt.yml b/config/locales/devise.pt.yml index 6c6f3d4d2..2de4b7ca1 100644 --- a/config/locales/devise.pt.yml +++ b/config/locales/devise.pt.yml @@ -8,10 +8,10 @@ pt: failure: already_authenticated: A sua sessão já está aberta. inactive: A sua contra ainda não está ativada. - invalid: %{authentication_keys} ou password inválidos. + invalid: "%{authentication_keys} ou password inválidos." last_attempt: Tem mais uma tentativa antes de a sua conta ser protegida. locked: A sua conta está protegida - not_found_in_database: %{authentication_keys} ou password inválidos. + not_found_in_database: "%{authentication_keys} ou password inválidos." timeout: A sua sessão expirou. Por favore entre de novo para continuar. unauthenticated: Você precsa de entrar ou registar-se antes de continuar. unconfirmed: Você tem de confirmar o seu endereço de email antes de continuar. diff --git a/config/locales/pt.yml b/config/locales/pt.yml index 2d74c7c85..321fdbe23 100644 --- a/config/locales/pt.yml +++ b/config/locales/pt.yml @@ -2,8 +2,7 @@ pt: about: about_instance: "<em>%{instance}</em> é uma instância de Mastodon." - about_mastodon: Mastodon é um servidor de rede social <em>grátis, e open-source</em>. Uma alternativa <em>descentralizada</em> - ás plataformas comerciais, que evita o risco de uma única empresa monopolizar a sua comunicação. Qualquer um pode ter uma instância Mastodon e assim participar na <em>rede social federada</em> sem problemas. + about_mastodon: Mastodon é um servidor de rede social <em>grátis, e open-source</em>. Uma alternativa <em>descentralizada</em> ás plataformas comerciais, que evita o risco de uma única empresa monopolizar a sua comunicação. Qualquer um pode ter uma instância Mastodon e assim participar na <em>rede social federada</em> sem problemas. get_started: Como começar source_code: Source code terms: Termos |