diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 5d2f4eee..b0e5a832 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 9a356196..0abdfd9f 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 89e54e2c..9727797e 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 9722f86b..fbe4af07 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 a6b35948..4a70b2a8 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 be82ff2f..29c2c912 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 563b4384..c04faa32 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 0e6fd2db..bfe5c043 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 6c6f3d4d..2de4b7ca 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 2d74c7c8..321fdbe2 100644 --- a/config/locales/pt.yml +++ b/config/locales/pt.yml @@ -2,8 +2,7 @@ pt: about: about_instance: "%{instance} é uma instância de Mastodon." - about_mastodon: Mastodon é um servidor de rede social grátis, e open-source. Uma alternativa descentralizada - á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 rede social federada sem problemas. + about_mastodon: Mastodon é um servidor de rede social grátis, e open-source. Uma alternativa descentralizada á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 rede social federada sem problemas. get_started: Como começar source_code: Source code terms: Termos