2007-01-22 14:43:50 +01:00
|
|
|
module WikiHelper
|
|
|
|
|
|
|
|
def navigation_menu_for_revision
|
|
|
|
menu = []
|
|
|
|
menu << forward
|
|
|
|
menu << back_for_revision if @revision_number > 1
|
|
|
|
menu << current_revision
|
|
|
|
menu << see_or_hide_changes_for_revision if @revision_number > 1
|
2009-09-04 07:09:39 +02:00
|
|
|
menu << history if @page.revisions.size > 1
|
2007-01-22 14:43:50 +01:00
|
|
|
menu << rollback
|
|
|
|
menu
|
|
|
|
end
|
|
|
|
|
|
|
|
def navigation_menu_for_page
|
|
|
|
menu = []
|
|
|
|
menu << edit_page
|
|
|
|
menu << edit_web if @page.name == "HomePage"
|
2009-09-04 07:09:39 +02:00
|
|
|
if @page.revisions.size > 1
|
2007-01-22 14:43:50 +01:00
|
|
|
menu << back_for_page
|
|
|
|
menu << see_or_hide_changes_for_page
|
|
|
|
end
|
2009-09-04 07:09:39 +02:00
|
|
|
menu << history if @page.revisions.size > 1
|
2007-01-22 14:43:50 +01:00
|
|
|
menu
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit_page
|
|
|
|
link_text = (@page.name == "HomePage" ? 'Edit Page' : 'Edit')
|
|
|
|
link_to(link_text, {:web => @web.address, :action => 'edit', :id => @page.name},
|
2007-09-28 03:04:27 +02:00
|
|
|
{:class => 'navlink', :accesskey => 'E', :id => 'edit', :rel => 'nofollow'})
|
2007-01-22 14:43:50 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def edit_web
|
|
|
|
link_to('Edit Web', {:web => @web.address, :action => 'edit_web'},
|
2007-09-28 03:04:27 +02:00
|
|
|
{:class => 'navlink', :accesskey => 'W', :id => 'edit_web', :rel => 'nofollow'})
|
2007-01-22 14:43:50 +01:00
|
|
|
end
|
2009-03-31 06:50:06 +02:00
|
|
|
|
|
|
|
def history
|
|
|
|
link_to_history(@page, 'History',
|
|
|
|
{:class => 'navlink', :accesskey => 'S', :id => 'history', :rel => 'nofollow'})
|
|
|
|
end
|
2007-01-22 14:43:50 +01:00
|
|
|
|
|
|
|
def forward
|
2009-09-04 07:09:39 +02:00
|
|
|
if @revision_number < @page.revisions.size - 1
|
2007-01-22 14:43:50 +01:00
|
|
|
link_to('Forward in time',
|
|
|
|
{:web => @web.address, :action => 'revision', :id => @page.name, :rev => @revision_number + 1},
|
2007-09-28 03:04:27 +02:00
|
|
|
{:class => 'navlink', :accesskey => 'F', :id => 'to_next_revision', :rel => 'nofollow'}) +
|
2009-09-04 07:09:39 +02:00
|
|
|
" <span class='revisions'>(#{@revision.page.revisions.size - @revision_number} more)</span> "
|
2007-01-22 14:43:50 +01:00
|
|
|
else
|
|
|
|
link_to('Forward in time', {:web => @web.address, :action => 'show', :id => @page.name},
|
2007-09-28 03:04:27 +02:00
|
|
|
{:class => 'navlink', :accesskey => 'F', :id => 'to_next_revision', :rel => 'nofollow'}) +
|
2007-02-20 00:35:32 +01:00
|
|
|
" <span class='revisions'>(to current)</span>"
|
2007-01-22 14:43:50 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def back_for_revision
|
|
|
|
link_to('Back in time',
|
|
|
|
{:web => @web.address, :action => 'revision', :id => @page.name, :rev => @revision_number - 1},
|
2007-09-28 03:04:27 +02:00
|
|
|
{:class => 'navlink', :id => 'to_previous_revision', :rel => 'nofollow'}) +
|
2007-02-20 00:35:32 +01:00
|
|
|
" <span class='revisions'>(#{@revision_number - 1} more)</span>"
|
2007-01-22 14:43:50 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def back_for_page
|
|
|
|
link_to('Back in time',
|
|
|
|
{:web => @web.address, :action => 'revision', :id => @page.name,
|
2009-09-04 07:09:39 +02:00
|
|
|
:rev => @page.revisions.size - 1},
|
2007-09-28 03:04:27 +02:00
|
|
|
{:class => 'navlink', :accesskey => 'B', :id => 'to_previous_revision', :rel => 'nofollow'}) +
|
2009-09-04 07:09:39 +02:00
|
|
|
" <span class='revisions'>(#{@page.revisions.size - 1} #{@page.revisions.size - 1 == 1 ? 'revision' : 'revisions'})</span>"
|
2007-01-22 14:43:50 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def current_revision
|
|
|
|
link_to('See current', {:web => @web.address, :action => 'show', :id => @page.name},
|
2007-02-15 15:26:47 +01:00
|
|
|
{:class => 'navlink', :id => 'to_current_revision'})
|
2007-01-22 14:43:50 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def see_or_hide_changes_for_revision
|
|
|
|
link_to(@show_diff ? 'Hide changes' : 'See changes',
|
|
|
|
{:web => @web.address, :action => 'revision', :id => @page.name, :rev => @revision_number,
|
|
|
|
:mode => (@show_diff ? nil : 'diff') },
|
2007-09-28 03:04:27 +02:00
|
|
|
{:class => 'navlink', :accesskey => 'C', :id => 'see_changes', :rel => 'nofollow'})
|
2007-01-22 14:43:50 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def see_or_hide_changes_for_page
|
|
|
|
link_to(@show_diff ? 'Hide changes' : 'See changes',
|
|
|
|
{:web => @web.address, :action => 'show', :id => @page.name, :mode => (@show_diff ? nil : 'diff') },
|
2007-09-28 03:04:27 +02:00
|
|
|
{:class => 'navlink', :accesskey => 'C', :id => 'see_changes', :rel => 'nofollow'})
|
2007-01-22 14:43:50 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def rollback
|
|
|
|
link_to('Rollback',
|
|
|
|
{:web => @web.address, :action => 'rollback', :id => @page.name, :rev => @revision_number},
|
2007-09-28 03:04:27 +02:00
|
|
|
{:class => 'navlink', :id => 'rollback', :rel => 'nofollow'})
|
2007-01-22 14:43:50 +01:00
|
|
|
end
|
|
|
|
|
2007-02-15 15:26:47 +01:00
|
|
|
end
|