diff --git a/app/controllers/public/profile_controller.rb b/app/controllers/public/profile_controller.rb index 036b638..43bc410 100644 --- a/app/controllers/public/profile_controller.rb +++ b/app/controllers/public/profile_controller.rb @@ -11,12 +11,18 @@ class ProfileController < PublicController end def tags - @tags = profile.article_tags + @tags_cache_key = "tags_profile_#{profile.id.to_s}" + if is_cache_expired?(@tags_cache_key, true) + @tags = profile.article_tags + end end def tag @tag = params[:id] - @tagged = profile.find_tagged_with(@tag) + @tag_cache_key = "tag_#{@tag.to_s.gsub(' ', '%20')}_#{profile.id.to_s}_page_#{params[:npage]}" + if is_cache_expired?(@tag_cache_key, true) + @tagged = profile.find_tagged_with(@tag).paginate(:per_page => 20, :page => params[:npage]) + end end def communities diff --git a/app/controllers/public/search_controller.rb b/app/controllers/public/search_controller.rb index 1c20434..000c79d 100644 --- a/app/controllers/public/search_controller.rb +++ b/app/controllers/public/search_controller.rb @@ -219,15 +219,21 @@ class SearchController < PublicController attr_reader :category def tags - @tags = environment.tags.inject({}) do |memo,tag| - memo[tag.name] = tag.taggings.count - memo + @tags_cache_key = "tags_env_#{environment.id.to_s}" + if is_cache_expired?(@tags_cache_key, true) + @tags = environment.tags.inject({}) do |memo,tag| + memo[tag.name] = tag.taggings.count + memo + end end end def tag @tag = environment.tags.find_by_name(params[:tag]) - @tagged = environment.articles.find_tagged_with(@tag) + @tag_cache_key = "tag_#{@tag.to_s.gsub(' ', '%20')}_env_#{environment.id.to_s}_page_#{params[:npage]}" + if is_cache_expired?(@tag_cache_key, true) + @tagged = environment.articles.find_tagged_with(@tag).paginate(:per_page => 10, :page => params[:npage]) + end end ####################################################### diff --git a/app/views/layouts/application-ng.rhtml b/app/views/layouts/application-ng.rhtml index 9ff6b48..7e0c3c5 100644 --- a/app/views/layouts/application-ng.rhtml +++ b/app/views/layouts/application-ng.rhtml @@ -61,7 +61,7 @@ <%= link_to('' + _('Administration') + '', { :controller => 'admin_panel', :action => 'index' }, :id => "controlpanel", :title => _("Configure the environment")) %> <% end %> <% if (user.environment == environment) %> - <%= link_to('' + _('Control panel') + '', user.admin_url, :id => "controlpanel", :title => _("Configure your personal account and content")) if (user.environment == environment) %> + <%= link_to('' + _('Control panel') + '', user.admin_url, :id => "controlpanel", :title => _("Configure your personal account and content")) %> <% end %> <%= link_to('' + _('Logout') + '', { :controller => 'account', :action => 'logout'} , :id => "logout", :title => _("Leave the system")) %> <% else %> diff --git a/app/views/profile/sitemap.rhtml b/app/views/profile/sitemap.rhtml index 09b970e..fd74211 100644 --- a/app/views/profile/sitemap.rhtml +++ b/app/views/profile/sitemap.rhtml @@ -1,3 +1,3 @@

<%= _("%s: site map") % profile.name %>

-<%= list_articles(@articles, true) %> +<%= list_articles(@articles, false) %> diff --git a/app/views/profile/tag.rhtml b/app/views/profile/tag.rhtml index 1cf5857..581c1da 100644 --- a/app/views/profile/tag.rhtml +++ b/app/views/profile/tag.rhtml @@ -1,13 +1,17 @@

<%= _('Content tagged with "%s"') % @tag %>

-
- -
+<% cache_timeout(@tag_cache_key, 4.hour.from_now) do %> +
+ +
-
- <%= link_to _('See content tagged with "%s" in the entire site') % @tag, :controller => 'search', :action => 'tag', :tag => @tag %> -
+ <%= pagination_links @tagged, :param_name => 'npage' %> + +
+ <%= link_to _('See content tagged with "%s" in the entire site') % @tag, :controller => 'search', :action => 'tag', :tag => @tag %> +
+<% end %> diff --git a/app/views/profile/tags.rhtml b/app/views/profile/tags.rhtml index 48db95b..dd7f754 100644 --- a/app/views/profile/tags.rhtml +++ b/app/views/profile/tags.rhtml @@ -1,3 +1,5 @@

<%= _("%s's tags") % @profile.name %>

-<%= tag_cloud(@tags, :id, { :action => :tag}, {:show_count => true} ) %> +<% cache_timeout(@tags_cache_key, 4.hour.from_now) do %> + <%= tag_cloud(@tags, :id, { :action => :tag}, {:show_count => true} ) %> +<% end %> diff --git a/app/views/search/tag.rhtml b/app/views/search/tag.rhtml index 7eba3ea..8abe0f9 100644 --- a/app/views/search/tag.rhtml +++ b/app/views/search/tag.rhtml @@ -6,9 +6,14 @@ <%= button('back', _('Back to tag cloud'), :action => 'tags') %> <% end %> -
-<% @tagged.each do |hit| %> - <%= render :partial => partial_for_class(hit.class), :object => hit %> -
+<% cache_timeout(@tag_cache_key, 4.hour.from_now) do %> +
+ <% @tagged.each do |hit| %> + <%= render :partial => partial_for_class(hit.class), :object => hit %> +
+ <% end %> + +
+ <%= pagination_links @tagged, :param_name => 'npage' %> + <% end %> -
diff --git a/app/views/search/tags.rhtml b/app/views/search/tags.rhtml index 938320c..ba88e0f 100644 --- a/app/views/search/tags.rhtml +++ b/app/views/search/tags.rhtml @@ -1,4 +1,5 @@

<%= _('Tag cloud') %>

-<%= tag_cloud(@tags, :tag, :action => 'tag') %> - +<% cache_timeout(@tags_cache_key, 4.hour.from_now) do %> + <%= tag_cloud(@tags, :tag, :action => 'tag') %> +<% end %> -- libgit2 0.21.2