See Changes as a separate page (still implemented within show and revision actions)

This commit is contained in:
Alexey Verkhovsky 2006-03-11 22:10:32 +00:00
parent c435bf2f2b
commit f8b3e2b11d
6 changed files with 27 additions and 36 deletions

View file

@ -49,10 +49,6 @@ class WikiController < ApplicationController
@authors = @page_names_by_author.keys.sort
end
def changes
raise "Not implemented yet"
end
def export_html
stylesheet = File.read(File.join(RAILS_ROOT, 'public', 'stylesheets', 'instiki.css'))
export_pages_as_zip('html') do |page|
@ -212,6 +208,7 @@ class WikiController < ApplicationController
def revision
get_page_and_revision
@show_diff = (@params[:mode] == 'diff')
@renderer = PageRenderer.new(@revision)
end
@ -250,6 +247,7 @@ class WikiController < ApplicationController
if @page
begin
@renderer = PageRenderer.new(@page.revisions.last)
@show_diff = (@params[:mode] == 'diff')
render_action 'page'
# TODO this rescue should differentiate between errors due to rendering and errors in
# the application itself (for application errors, it's better not to rescue the error at all)

View file

@ -5,12 +5,13 @@ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<head>
<title>
<% if @page and (@page.name == 'HomePage') and (%w( show published print ).include?(@action_name)) %>
<%= @web.name %>
<%= h @web.name %>
<% elsif @web %>
<%= @title %> in <%= @web.name %>
<%= @title %> in <%= h @web.name %>
<% else %>
<%= @title %>
<% end %>
<%= @show_diff ? ' (changes)' : '' %>
</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
@ -42,7 +43,7 @@ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<div id="Content">
<h1 id="pageName">
<% if @page and (@page.name == 'HomePage') and %w( show published print ).include?(@action_name) %>
<%= @web.name %>
<%= h(@web.name) + (@show_diff ? ' (changes)' : '') %>
<% elsif @web %>
<small><%= @web.name %></small><br />
<%= @title %>

View file

@ -1,10 +1,11 @@
<%
@title = @page.plain_name
@title = @page.plain_name
@title += ' (changes)' if @show_diff
@show_footer = true
%>
<div id="revision">
<%= @renderer.display_content %>
<%= @show_diff ? @renderer.display_diff : @renderer.display_content %>
</div>
<div class="byline">
@ -43,12 +44,11 @@
{:class => 'navlink', :accesskey => 'R', :name => 'to_previous_revision'})
%>
<small>(<%= @page.revisions.length - 1 %> revisions)</small>
<% end %>
<% if @page.revisions.length > 1 %>
<%= link_to('See changes',
{:web => @web.address, :action => 'changes', :id => @page.name},
{:class => 'navlink', :accesskey => 'C', :name => 'see_changes'})
|
<%= link_to(@show_diff ? 'Hide changes' : 'See changes',
{ :web => @web.address, :action => 'show', :id => @page.name,
:mode => (@show_diff ? nil : 'diff') },
{ :class => 'navlink', :accesskey => 'C', :name => 'see_changes' })
%>
<% end %>

View file

@ -1,21 +1,12 @@
<% @title = "#{@page.plain_name} (Rev ##{@revision_number})" %>
<%
@title = "#{@page.plain_name} (Rev ##{@revision_number}#{@show_diff ? ', changes' : ''})"
%>
<div id="revision">
<%= @renderer.display_content %>
<%= @show_diff ? @renderer.display_diff : @renderer.display_content %>
</div>
<div id="changes" style="display: none">
<p style="background: #eee; padding: 3px; border: 1px solid silver">
<small>
Showing changes from revision #<%= @revision_number - 1 %> to #<%= @revision_number %>:
<ins class="diffins">Added</ins> | <del class="diffdel">Removed</del>
</small>
</p>
<%= @renderer.display_diff %>
</div>
<div class="byline">
<%= "Revision from #{format_date(@revision.revised_at)} by" %>
<%= link_to_page @revision.author %>
@ -58,12 +49,12 @@
%>
<% if @revision_number > 0 %>
<span id="show_changes">
| <a href="#" onClick="toggleChanges(); return false;">See changes</a>
</span>
<span id="hide_changes" style="display: none">
| <a href="#" onClick="toggleChanges(); return false;">Hide changes</a>
</span>
|
<%= link_to(@show_diff ? 'Hide changes' : 'See changes',
{:web => @web.address, :action => 'revision', :id => @page.name,
:rev => @revision_number, :mode => (@show_diff ? nil : 'diff') },
{:class => 'navlink', :accesskey => 'C', :name => 'see_changes'})
%>
<% end %>
|

View file

@ -19,6 +19,8 @@ ActionController::Routing::Routes.draw do |map|
connect_to_web map, ':web/import/:id', :controller => 'file', :action => 'import'
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/:action/:id', :controller => 'wiki'
connect_to_web map, ':web/:action', :controller => 'wiki'
connect_to_web map, ':web', :controller => 'wiki', :action => 'index'

View file

@ -613,7 +613,6 @@ class WikiControllerTest < Test::Unit::TestCase
assert_response :missing
end
def test_tex
r = process('tex', 'web' => 'wiki1', 'id' => 'HomePage')
assert_success