Remove FragmentLocalization and localized_cache helper
We replace the `localized_cache` helper with just simple keys provided to the `cache` helper, with `locale=#{I18n.locale}` inlined. End of an era!
This commit is contained in:
parent
d27c03606f
commit
c0e4291745
5 changed files with 5 additions and 27 deletions
|
@ -2,8 +2,6 @@ require 'async'
|
||||||
require 'async/container'
|
require 'async/container'
|
||||||
|
|
||||||
class ApplicationController < ActionController::Base
|
class ApplicationController < ActionController::Base
|
||||||
include FragmentLocalization
|
|
||||||
|
|
||||||
protect_from_forgery
|
protect_from_forgery
|
||||||
|
|
||||||
helper_method :current_user, :user_signed_in?
|
helper_method :current_user, :user_signed_in?
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
module ApplicationHelper
|
module ApplicationHelper
|
||||||
include FragmentLocalization
|
|
||||||
|
|
||||||
def absolute_url(path_or_url)
|
def absolute_url(path_or_url)
|
||||||
if path_or_url.include?('://') # already an absolute URL
|
if path_or_url.include?('://') # already an absolute URL
|
||||||
path_or_url
|
path_or_url
|
||||||
|
@ -166,13 +164,6 @@ module ApplicationHelper
|
||||||
options
|
options
|
||||||
end
|
end
|
||||||
|
|
||||||
def localized_cache(key={}, &block)
|
|
||||||
localized_key = localize_fragment_key(key, locale)
|
|
||||||
# TODO: The digest feature is handy, but it's not compatible with how we
|
|
||||||
# check for fragments existence in the controller, so skip it for now.
|
|
||||||
cache(localized_key, skip_digest: true, &block)
|
|
||||||
end
|
|
||||||
|
|
||||||
def auth_user_sign_in_path_with_return_to
|
def auth_user_sign_in_path_with_return_to
|
||||||
new_auth_user_session_path :return_to => request.fullpath
|
new_auth_user_session_path :return_to => request.fullpath
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
%h2= t '.newest_items.header'
|
%h2= t '.newest_items.header'
|
||||||
= render @newest_items
|
= render @newest_items
|
||||||
|
|
||||||
- localized_cache :action_suffix => 'species_search_links' do
|
- cache "items/index species_search_links locale=#{I18n.locale}" do
|
||||||
#species-search-links
|
#species-search-links
|
||||||
%h2= t '.species_search.header'
|
%h2= t '.species_search.header'
|
||||||
= standard_species_search_links
|
= standard_species_search_links
|
||||||
|
|
|
@ -90,7 +90,7 @@
|
||||||
%h3= t '.newest_items.unmodeled.header'
|
%h3= t '.newest_items.unmodeled.header'
|
||||||
%ul#newest-unmodeled-items
|
%ul#newest-unmodeled-items
|
||||||
- @newest_unmodeled_items.each do |item|
|
- @newest_unmodeled_items.each do |item|
|
||||||
- localized_cache "items/#{item.id} modeling_progress updated_at=#{item.updated_at.to_i}" do
|
- cache "items/#{item.id} modeling_progress locale=#{I18n.locale} updated_at=#{item.updated_at.to_i}" do
|
||||||
%li{'data-item-id' => item.id}
|
%li{'data-item-id' => item.id}
|
||||||
= link_to image_tag(item.thumbnail_url), item, :class => 'image-link'
|
= link_to image_tag(item.thumbnail_url), item, :class => 'image-link'
|
||||||
= link_to item, :class => 'header' do
|
= link_to item, :class => 'header' do
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
module FragmentLocalization
|
|
||||||
def localize_fragment_key(key, locale)
|
|
||||||
if key.is_a?(Hash)
|
|
||||||
{:locale => locale}.merge(key)
|
|
||||||
elsif key.is_a?(String)
|
|
||||||
"#{key} #{locale}"
|
|
||||||
else
|
|
||||||
raise TypeError, "unexpected fragment key type: #{key.class}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Reference in a new issue