Merge branch 'bzr/golem' of /Users/distler/Sites/code/instiki
This commit is contained in:
commit
6b09f76864
|
@ -314,6 +314,27 @@ class WikiController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def history
|
||||||
|
if @page
|
||||||
|
@revisions_by_day = Hash.new { |h, day| h[day] = [] }
|
||||||
|
@revision_numbers = Hash.new { |h, id| h[id] = [] }
|
||||||
|
revision_number = @page.revisions.length
|
||||||
|
@page.revisions.reverse.each do |rev|
|
||||||
|
day = Date.new(rev.revised_at.year, rev.revised_at.month, rev.revised_at.day)
|
||||||
|
@revisions_by_day[day] << rev
|
||||||
|
@revision_numbers[rev.id] = revision_number
|
||||||
|
revision_number = revision_number - 1
|
||||||
|
end
|
||||||
|
render :action => 'history'
|
||||||
|
else
|
||||||
|
if not @page_name.nil? and @page_name.is_utf8? and not @page_name.empty?
|
||||||
|
redirect_to :web => @web_name, :action => 'new', :id => @page_name
|
||||||
|
else
|
||||||
|
render :text => 'Page name is not specified', :status => 404, :layout => 'error'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def tex
|
def tex
|
||||||
if @web.markup == :markdownMML or @web.markup == :markdownPNG or @web.markup == :markdown
|
if @web.markup == :markdownMML or @web.markup == :markdownPNG or @web.markup == :markdown
|
||||||
@tex_content = Maruku.new(@page.content).to_latex
|
@tex_content = Maruku.new(@page.content).to_latex
|
||||||
|
|
|
@ -52,6 +52,22 @@ module ApplicationHelper
|
||||||
UrlGenerator.new(@controller).make_link(page.author.name, page.web, nil, options)
|
UrlGenerator.new(@controller).make_link(page.author.name, page.web, nil, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# 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(
|
||||||
|
text || page.plain_name + "(rev # #{revision_number})",
|
||||||
|
{:web => @web.address, :action => 'revision', :id => page.name,
|
||||||
|
:rev => revision_number, :mode => mode}, html_options)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Create a hyperlink to the history of a particular Wiki page
|
||||||
|
def link_to_history(page, text = nil, html_options = {})
|
||||||
|
link_to(
|
||||||
|
text || page.plain_name + "(history)",
|
||||||
|
{:web => @web.address, :action => 'history', :id => page.name},
|
||||||
|
html_options)
|
||||||
|
end
|
||||||
|
|
||||||
def base_url
|
def base_url
|
||||||
home_page_url = url_for :controller => 'admin', :action => 'create_system', :only_path => true
|
home_page_url = url_for :controller => 'admin', :action => 'create_system', :only_path => true
|
||||||
home_page_url.sub(%r-/create_system/?$-, '')
|
home_page_url.sub(%r-/create_system/?$-, '')
|
||||||
|
|
|
@ -6,6 +6,7 @@ module WikiHelper
|
||||||
menu << back_for_revision if @revision_number > 1
|
menu << back_for_revision if @revision_number > 1
|
||||||
menu << current_revision
|
menu << current_revision
|
||||||
menu << see_or_hide_changes_for_revision if @revision_number > 1
|
menu << see_or_hide_changes_for_revision if @revision_number > 1
|
||||||
|
menu << history if @page.revisions.length > 1
|
||||||
menu << rollback
|
menu << rollback
|
||||||
menu
|
menu
|
||||||
end
|
end
|
||||||
|
@ -18,6 +19,7 @@ module WikiHelper
|
||||||
menu << back_for_page
|
menu << back_for_page
|
||||||
menu << see_or_hide_changes_for_page
|
menu << see_or_hide_changes_for_page
|
||||||
end
|
end
|
||||||
|
menu << history if @page.revisions.length > 1
|
||||||
menu
|
menu
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -31,6 +33,11 @@ module WikiHelper
|
||||||
link_to('Edit Web', {:web => @web.address, :action => 'edit_web'},
|
link_to('Edit Web', {:web => @web.address, :action => 'edit_web'},
|
||||||
{:class => 'navlink', :accesskey => 'W', :id => 'edit_web', :rel => 'nofollow'})
|
{:class => 'navlink', :accesskey => 'W', :id => 'edit_web', :rel => 'nofollow'})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def history
|
||||||
|
link_to_history(@page, 'History',
|
||||||
|
{:class => 'navlink', :accesskey => 'S', :id => 'history', :rel => 'nofollow'})
|
||||||
|
end
|
||||||
|
|
||||||
def forward
|
def forward
|
||||||
if @revision_number < @page.revisions.length - 1
|
if @revision_number < @page.revisions.length - 1
|
||||||
|
|
23
app/views/wiki/history.html.erb
Normal file
23
app/views/wiki/history.html.erb
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<%- @title = @page.plain_name + " (history)" -%>
|
||||||
|
<%- @show_footer = true -%>
|
||||||
|
|
||||||
|
<%- @revisions_by_day.keys.sort.reverse.each do |day| -%>
|
||||||
|
<h3><%= format_date(day, include_time = false) %></h3>
|
||||||
|
<ul>
|
||||||
|
<%- for rev in @revisions_by_day[day] -%>
|
||||||
|
<li>
|
||||||
|
<%= link_to_revision(rev.page, @revision_numbers[rev.id],
|
||||||
|
text="Revision #{@revision_numbers[rev.id]}") %>
|
||||||
|
<%- if @revision_numbers[rev.id] > 1 -%>
|
||||||
|
(<%= link_to_revision(rev.page, @revision_numbers[rev.id],
|
||||||
|
text="diff", mode='diff') %>)
|
||||||
|
<%- end -%>
|
||||||
|
<div class="byline" style="margin-bottom: 0px">
|
||||||
|
by <%= link_to_page(rev.author) %>
|
||||||
|
at <%= format_date(rev.revised_at) %>
|
||||||
|
<%= "from #{rev.author.ip}" if rev.author.respond_to?(:ip) %>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<%- end -%>
|
||||||
|
</ul>
|
||||||
|
<%- end -%>
|
|
@ -8,6 +8,11 @@
|
||||||
<%- for page in @pages_by_day[day] -%>
|
<%- for page in @pages_by_day[day] -%>
|
||||||
<li>
|
<li>
|
||||||
<%= link_to_existing_page page %>
|
<%= link_to_existing_page page %>
|
||||||
|
<%- if page.revisions.length > 1 %>
|
||||||
|
(<%= link_to_revision(page, page.revisions.length, text='diff',
|
||||||
|
mode='diff') %>)
|
||||||
|
(<%= link_to_history(page, text='history') %>)
|
||||||
|
<%- end -%>
|
||||||
<div class="byline" style="margin-bottom: 0px">
|
<div class="byline" style="margin-bottom: 0px">
|
||||||
by <%= link_to_page(page.author) %>
|
by <%= link_to_page(page.author) %>
|
||||||
at <%= format_date(page.revised_at) %>
|
at <%= format_date(page.revised_at) %>
|
||||||
|
|
|
@ -102,7 +102,7 @@ class PageRenderer
|
||||||
the_wiki_words = wiki_links(rendering_result)
|
the_wiki_words = wiki_links(rendering_result)
|
||||||
# Exclude backslash-escaped wiki words, such as \WikiWord, as well as links to files
|
# Exclude backslash-escaped wiki words, such as \WikiWord, as well as links to files
|
||||||
# and pictures, such as [[foo.txt:file]] or [[foo.jpg:pic]]
|
# and pictures, such as [[foo.txt:file]] or [[foo.jpg:pic]]
|
||||||
the_wiki_words.delete_if { |link| link.escaped? or [:pic, :file, :delete].include?(link.link_type) }
|
the_wiki_words.delete_if { |link| link.escaped? or [:pic, :file, :audio, :video, :delete].include?(link.link_type) }
|
||||||
# convert to the list of unique page names
|
# convert to the list of unique page names
|
||||||
the_wiki_words.map { |link| ( link.page_name ) }.uniq
|
the_wiki_words.map { |link| ( link.page_name ) }.uniq
|
||||||
end
|
end
|
||||||
|
@ -114,7 +114,7 @@ class PageRenderer
|
||||||
|
|
||||||
def find_wiki_files(rendering_result)
|
def find_wiki_files(rendering_result)
|
||||||
the_wiki_files = wiki_links(rendering_result)
|
the_wiki_files = wiki_links(rendering_result)
|
||||||
the_wiki_files.delete_if { |link| ![:pic, :file].include?(link.link_type) }
|
the_wiki_files.delete_if { |link| ![:pic, :file, :audio, :video].include?(link.link_type) }
|
||||||
the_wiki_files.map { |link| ( link.page_name ) }.uniq
|
the_wiki_files.map { |link| ( link.page_name ) }.uniq
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue