diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d89a3b6..cf0a233 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1310,4 +1310,8 @@ module ApplicationHelper ) + content_tag('span', ' | ', :class => 'comment-footer comment-footer-hide') end end + + def cache_timeout(key, timeout, &block) + cache(key, { :expires_in => timeout }, &block) + end end diff --git a/app/helpers/sweeper_helper.rb b/app/helpers/sweeper_helper.rb index 48a6f9e..8540c66 100644 --- a/app/helpers/sweeper_helper.rb +++ b/app/helpers/sweeper_helper.rb @@ -4,9 +4,7 @@ module SweeperHelper ActionController::Base.new().expire_fragment(*args) end - def expire_timeout_fragment(*args) - ActionController::Base.new().expire_timeout_fragment(*args) - end + alias :expire_timeout_fragment :expire_fragment def expire_friends(profile) # public friends page diff --git a/app/views/friends/index.rhtml b/app/views/friends/index.rhtml index d2f3e3c..9a97bcb 100644 --- a/app/views/friends/index.rhtml +++ b/app/views/friends/index.rhtml @@ -2,7 +2,7 @@
diff --git a/app/views/profile/_common.rhtml b/app/views/profile/_common.rhtml
index 69b4099..f543901 100644
--- a/app/views/profile/_common.rhtml
+++ b/app/views/profile/_common.rhtml
@@ -9,7 +9,7 @@
<% unless @action %>
- <% cache_timeout(profile.cache_key + '-profile-general-info', 4.hours.from_now) do %>
+ <% cache_timeout(profile.cache_key + '-profile-general-info', 4.hours) do %>
<%= _('Content') %>
diff --git a/app/views/profile/_person_profile.rhtml b/app/views/profile/_person_profile.rhtml
index e6bffab..bfd19e3 100644
--- a/app/views/profile/_person_profile.rhtml
+++ b/app/views/profile/_person_profile.rhtml
@@ -23,7 +23,7 @@
<%= display_field(_('e-Mail:'), profile, :email, true) { |email| link_to_email(email) } %>
<% end %>
- <% cache_timeout(profile.relationships_cache_key, 4.hours.from_now) do %>
+ <% cache_timeout(profile.relationships_cache_key, 4.hours) do %>
<% if !(profile.organization.blank? && profile.organization_website.blank?) && (profile.active_fields.include?('organization') || profile.active_fields.include?('organization_website')) %>
<%= _('Work')%>
diff --git a/app/views/profile/communities.rhtml b/app/views/profile/communities.rhtml
index 22e0252..8ecb9eb 100644
--- a/app/views/profile/communities.rhtml
+++ b/app/views/profile/communities.rhtml
@@ -2,7 +2,7 @@
<%= _("%s's communities") % profile.name %>
-<% cache_timeout(profile.communities_cache_key(params), 4.hour.from_now) do %>
+<% cache_timeout(profile.communities_cache_key(params), 4.hour) do %>
<% @communities.each do |community| %>
<% for doc in @tagged %>
diff --git a/app/views/profile/friends.rhtml b/app/views/profile/friends.rhtml
index 385ad8a..1da9c59 100644
--- a/app/views/profile/friends.rhtml
+++ b/app/views/profile/friends.rhtml
@@ -2,7 +2,7 @@
<%= __("%s's friends") % profile.name %>
-<% cache_timeout(profile.friends_cache_key(params), 4.hours.from_now) do %>
+<% cache_timeout(profile.friends_cache_key(params), 4.hours) do %>
<% @friends.each do |friend| %>
<%= profile_image_link(friend) %>
diff --git a/app/views/profile/members.rhtml b/app/views/profile/members.rhtml
index a675ab6..50ef8d6 100644
--- a/app/views/profile/members.rhtml
+++ b/app/views/profile/members.rhtml
@@ -2,7 +2,7 @@
<%= _("%s's members") % profile.name %>
-<% cache_timeout(profile.members_cache_key(params), 4.hours.from_now) do %>
+<% cache_timeout(profile.members_cache_key(params), 4.hours) do %>
<% @members.each do |member| %>
<%= profile_image_link(member) %>
diff --git a/app/views/profile/tags.rhtml b/app/views/profile/tags.rhtml
index 9e4013c..cff2f92 100644
--- a/app/views/profile/tags.rhtml
+++ b/app/views/profile/tags.rhtml
@@ -1,7 +1,7 @@
<%= _("%s's tags") % @profile.name %>
diff --git a/app/views/search/tags.rhtml b/app/views/search/tags.rhtml
index ec9e7f0..03b2995 100644
--- a/app/views/search/tags.rhtml
+++ b/app/views/search/tags.rhtml
@@ -1,7 +1,7 @@
<%= _('Tag cloud') %>
- <% for post in @posts %>
-
- <%end%>
-
-To enforce the timeout cache value within the controller don't use the read_fragment method -- unless really needed. The method that is provided to check that the timeout value has is expired is is_cache_expired?. The method takes the argument of the cache key.
-
-Example Usage within controller:
-
-def list
- if is_cache_expired?('forum_listing')
- @posts = Post.find(:all)
- end
-end
\ No newline at end of file
diff --git a/vendor/plugins/timed_cached_fragment/Rakefile b/vendor/plugins/timed_cached_fragment/Rakefile
deleted file mode 100644
index 4c554b9..0000000
--- a/vendor/plugins/timed_cached_fragment/Rakefile
+++ /dev/null
@@ -1,22 +0,0 @@
-require 'rake'
-require 'rake/testtask'
-require 'rake/rdoctask'
-
-desc 'Default: run unit tests.'
-task :default => :test
-
-desc 'Test the timed_cache_fragment plugin.'
-Rake::TestTask.new(:test) do |t|
- t.libs << 'lib'
- t.pattern = 'test/**/*_test.rb'
- t.verbose = true
-end
-
-desc 'Generate documentation for the timed_cache_fragment plugin.'
-Rake::RDocTask.new(:rdoc) do |rdoc|
- rdoc.rdoc_dir = 'rdoc'
- rdoc.title = 'TimedCacheFragment'
- rdoc.options << '--line-numbers' << '--inline-source'
- rdoc.rdoc_files.include('README')
- rdoc.rdoc_files.include('lib/**/*.rb')
-end
diff --git a/vendor/plugins/timed_cached_fragment/init.rb b/vendor/plugins/timed_cached_fragment/init.rb
deleted file mode 100644
index 68d4918..0000000
--- a/vendor/plugins/timed_cached_fragment/init.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-# Include hook code here
-require 'timed_cache_fragment'
\ No newline at end of file
diff --git a/vendor/plugins/timed_cached_fragment/install.rb b/vendor/plugins/timed_cached_fragment/install.rb
deleted file mode 100644
index f7732d3..0000000
--- a/vendor/plugins/timed_cached_fragment/install.rb
+++ /dev/null
@@ -1 +0,0 @@
-# Install hook code here
diff --git a/vendor/plugins/timed_cached_fragment/lib/timed_cache_fragment.rb b/vendor/plugins/timed_cached_fragment/lib/timed_cache_fragment.rb
deleted file mode 100644
index 9bb32d0..0000000
--- a/vendor/plugins/timed_cached_fragment/lib/timed_cache_fragment.rb
+++ /dev/null
@@ -1,75 +0,0 @@
-# TimedCacheFragment
-module ActionController
- module Cache
- module TimedCache
- #handles standard ERB fragments used in RHTML
- def cache_timeout(key={}, expire = 10.minutes.from_now, &block)
- unless perform_caching then block.call; return end
- if is_cache_expired?(key,true)
- expire_timeout_fragment(key)
- set_timeout(key, expire)
- end
- cache_erb_fragment(block,key)
- end
- #handles the expiration of timeout fragment
- def expire_timeout_fragment(key)
- delete_timeout(key)
- expire_fragment(key)
- end
- #checks to see if a cache has fully expired
- def is_cache_expired?(name, is_key = false)
- key = is_key ? name : fragment_cache_key(name)
- return true unless read_fragment(key)
- timeout = get_timeout(key)
- return (!timeout) || (timeout < Time.now)
- end
-
- # from http://code.google.com/p/timedcachedfragment/issues/detail?id=1
- def cache_erb_fragment(block, name = {}, options = nil)
- unless perform_caching then block.call; return end
-
- buffer = eval(ActionView::Base.erb_variable, block.binding)
-
- if cache = read_fragment(name, options)
- buffer.concat(cache)
- else
- pos = buffer.length
- block.call
- write_fragment(name, buffer[pos..-1], options)
- end
- end
-
- def delete_timeout(key)
- expire_fragment('timeout:' + key)
- end
- def get_timeout(key)
- frag = read_fragment('timeout:' + key)
- frag ? frag.to_time : nil
- end
- def set_timeout(key, value)
- write_fragment('timeout:' + key, value)
- end
-
- end
- end
-end
-
-
-module ActionView
- module Helpers
- module TimedCacheHelper
- def is_cache_expired?(name = nil)
- return false if name.nil?
- key = fragment_cache_key(name)
- return @controller.send('is_cache_expired?', key)
- end
- def cache_timeout(name,expire=10.minutes.from_now, &block)
- @controller.cache_timeout(name,expire,&block)
- end
- end
- end
-end
-
-#add to the respective controllers
-ActionView::Base.send(:include, ActionView::Helpers::TimedCacheHelper)
-ActionController::Base.send(:include, ActionController::Cache::TimedCache)
diff --git a/vendor/plugins/timed_cached_fragment/tasks/timed_cache_fragment_tasks.rake b/vendor/plugins/timed_cached_fragment/tasks/timed_cache_fragment_tasks.rake
deleted file mode 100644
index 84c0b4a..0000000
--- a/vendor/plugins/timed_cached_fragment/tasks/timed_cache_fragment_tasks.rake
+++ /dev/null
@@ -1,4 +0,0 @@
-# desc "Explaining what the task does"
-# task :timed_cache_fragment do
-# # Task goes here
-# end
\ No newline at end of file
diff --git a/vendor/plugins/timed_cached_fragment/test/timed_cache_fragment_test.rb b/vendor/plugins/timed_cached_fragment/test/timed_cache_fragment_test.rb
deleted file mode 100644
index 34fd4a8..0000000
--- a/vendor/plugins/timed_cached_fragment/test/timed_cache_fragment_test.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require 'test/unit'
-
-class TimedCacheFragmentTest < Test::Unit::TestCase
- # Replace this with your real tests.
- def test_this_plugin
- flunk
- end
-end
diff --git a/vendor/plugins/timed_cached_fragment/uninstall.rb b/vendor/plugins/timed_cached_fragment/uninstall.rb
deleted file mode 100644
index 9738333..0000000
--- a/vendor/plugins/timed_cached_fragment/uninstall.rb
+++ /dev/null
@@ -1 +0,0 @@
-# Uninstall hook code here
--
libgit2 0.21.2