Cache Revisions
Fix config/routes.rb to make revisions cacheable. Cache revisions. Modify the history page so that it links to the current page (and diff).
This commit is contained in:
parent
73a7ceef03
commit
69bfc1028b
4 changed files with 13 additions and 4 deletions
|
@ -9,7 +9,7 @@ class WikiController < ApplicationController
|
|||
before_filter :load_page
|
||||
before_filter :dnsbl_check, :only => [:edit, :new, :save, :export_html, :export_markup]
|
||||
caches_action :show, :published, :authors, :tex, :s5, :print, :recently_revised, :list, :file_list,
|
||||
:history, :atom_with_content, :atom_with_headlines, :if => Proc.new { |c| c.send(:do_caching?) }
|
||||
:history, :revision, :atom_with_content, :atom_with_headlines, :if => Proc.new { |c| c.send(:do_caching?) }
|
||||
cache_sweeper :revision_sweeper
|
||||
|
||||
layout 'default', :except => [:atom_with_content, :atom_with_headlines, :atom, :tex, :s5, :export_html]
|
||||
|
|
|
@ -54,7 +54,12 @@ module ApplicationHelper
|
|||
|
||||
# Create a hyperlink to a particular revision of a Wiki page
|
||||
def link_to_revision(page, revision_number, text = nil, mode = nil, html_options = {})
|
||||
link_to(
|
||||
revision_number == page.revisions.length ?
|
||||
link_to(
|
||||
text || page.plain_name,
|
||||
{:web => @web.address, :action => 'show', :id => page.name,
|
||||
:mode => mode}, html_options) :
|
||||
link_to(
|
||||
text || page.plain_name + "(rev # #{revision_number})",
|
||||
{:web => @web.address, :action => 'revision', :id => page.name,
|
||||
:rev => revision_number, :mode => mode}, html_options)
|
||||
|
|
|
@ -7,7 +7,10 @@
|
|||
<%- for rev in @revisions_by_day[day] -%>
|
||||
<li>
|
||||
<%= link_to_revision(rev.page, @revision_numbers[rev.id],
|
||||
text="Revision #{@revision_numbers[rev.id]}") %>
|
||||
text= (rev.page.revisions.length == @revision_numbers[rev.id] ?
|
||||
"Current" :
|
||||
"Revision #{@revision_numbers[rev.id]}" )
|
||||
) %>
|
||||
<%- if @revision_numbers[rev.id] > 1 -%>
|
||||
(<%= link_to_revision(rev.page, @revision_numbers[rev.id],
|
||||
text="diff", mode='diff') %>)
|
||||
|
|
|
@ -26,7 +26,8 @@ ActionController::Routing::Routes.draw do |map|
|
|||
connect_to_web map, ':web/login', :controller => 'wiki', :action => 'login'
|
||||
connect_to_web map, ':web/web_list', :controller => 'wiki', :action => 'web_list'
|
||||
connect_to_web map, ':web/show/diff/:id', :controller => 'wiki', :action => 'show', :mode => 'diff'
|
||||
connect_to_web map, ':web/revision/diff/:id', :controller => 'wiki', :action => 'revision', :mode => 'diff'
|
||||
connect_to_web map, ':web/revision/diff/:id/:rev', :controller => 'wiki', :action => 'revision', :mode => 'diff', :requirements => { :rev => /\d*/}
|
||||
connect_to_web map, ':web/revision/:id/:rev', :controller => 'wiki', :action => 'revision', :requirements => { :rev => /\d*/}
|
||||
connect_to_web map, ':web/list/:category', :controller => 'wiki', :action => 'list', :requirements => { :category => /.*/}, :category => nil
|
||||
connect_to_web map, ':web/recently_revised/:category', :controller => 'wiki', :action => 'recently_revised', :requirements => { :category => /.*/}, :category => nil
|
||||
connect_to_web map, ':web/:action/:id', :controller => 'wiki'
|
||||
|
|
Loading…
Reference in a new issue