Merge branch 'bzr/golem' of /Users/distler/Sites/code/instiki
This commit is contained in:
commit
8624a40bf8
5 changed files with 15 additions and 18 deletions
|
@ -71,10 +71,6 @@ class Page < ActiveRecord::Base
|
|||
def linked_from
|
||||
web.select.pages_that_link_to(name)
|
||||
end
|
||||
|
||||
def redirects_for
|
||||
wiki_references.select { |ref| ref.redirected_page?}.map { |ref| ref.referenced_name }
|
||||
end
|
||||
|
||||
def included_from
|
||||
web.select.pages_that_include(name)
|
||||
|
|
|
@ -54,14 +54,9 @@ class WikiReference < ActiveRecord::Base
|
|||
|
||||
def self.pages_redirected_to(web, page_name)
|
||||
names = []
|
||||
if web.has_page?(page_name)
|
||||
page = web.page(page_name)
|
||||
redirected_names = page.redirects_for
|
||||
redirected_names.each do |name|
|
||||
names = names | self.pages_that_reference(web, name)
|
||||
end
|
||||
end
|
||||
names
|
||||
page = web.page(page_name)
|
||||
Thread.current[:page_redirects][page.name].each { |name| names = names + self.pages_that_reference(web, name) }
|
||||
names.uniq
|
||||
end
|
||||
|
||||
def self.page_that_redirects_for(web, page_name)
|
||||
|
@ -70,8 +65,8 @@ class WikiReference < ActiveRecord::Base
|
|||
'WHERE wiki_references.referenced_name = ? ' +
|
||||
"AND wiki_references.link_type = '#{REDIRECTED_PAGE}' " +
|
||||
"AND pages.web_id = '#{web.id}'"
|
||||
names = connection.select_all(sanitize_sql([query, page_name])).map { |row| row['name'] }
|
||||
names[0]
|
||||
row = connection.select_one(sanitize_sql([query, page_name]))
|
||||
row['name'] if row
|
||||
end
|
||||
|
||||
def self.pages_in_category(web, category)
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
<% form_tag({ :action => 'save', :web => @web.address, :id => @page.name },
|
||||
{ 'id' => 'editForm', 'method' => 'post', 'onsubmit' => 'cleanAuthorName()',
|
||||
'accept-charset' => 'utf-8' }) do %>
|
||||
<div>
|
||||
<textarea name="content" id="content" rows="24" cols="60"><%= h(flash[:content] ||
|
||||
((params['content'] && params['content'].is_utf8?) ? params['content'] : @page.content).purify) %></textarea>
|
||||
<% if @page_name != 'HomePage' -%>
|
||||
<p>
|
||||
<%= check_box_tag :alter_title, value = "1", checked=false,
|
||||
|
@ -22,9 +25,6 @@
|
|||
<% else -%>
|
||||
<%= hidden_field_tag 'new_name', @page_name %>
|
||||
<% end%>
|
||||
<div>
|
||||
<textarea name="content" id="content" rows="24" cols="60"><%= h(flash[:content] ||
|
||||
((params['content'] && params['content'].is_utf8?) ? params['content'] : @page.content).purify) %></textarea>
|
||||
<div id="editFormButtons">
|
||||
<input type="submit" value="Submit" accesskey="s"/> as
|
||||
<%= text_field_tag :author, h(@author.purify),
|
||||
|
|
|
@ -179,7 +179,12 @@ class PageRenderer
|
|||
references.build :referenced_name => redirected_page_name,
|
||||
:link_type => WikiReference::REDIRECTED_PAGE
|
||||
end
|
||||
|
||||
|
||||
# ugly hack: store these in a thread-local variable, so that the cache-sweeper has access to it.
|
||||
Thread.current[:page_redirects] ?
|
||||
Thread.current[:page_redirects].update({ @revision.page.name => redirects}) :
|
||||
Thread.current[:page_redirects] = { @revision.page.name => redirects}
|
||||
|
||||
categories = rendering_result.find_chunks(Category).map { |cat| cat.list }.flatten
|
||||
categories.each do |category|
|
||||
references.build :referenced_name => category, :link_type => WikiReference::CATEGORY
|
||||
|
|
|
@ -524,6 +524,7 @@ END_THM
|
|||
end
|
||||
|
||||
def test_revisions_diff
|
||||
Thread.current[:page_redirects] = { @page.name => []}
|
||||
Revision.create(:page => @page, :content => 'What a blue and lovely morning',
|
||||
:author => Author.new('DavidHeinemeierHansson'), :revised_at => Time.now)
|
||||
Revision.create(:page => @page, :content => 'What a red and lovely morning today',
|
||||
|
|
Loading…
Reference in a new issue