Merge branch 'bzr/golem' of /Users/distler/Sites/code/instiki

This commit is contained in:
Jacques Distler 2009-06-06 12:39:44 -05:00
commit 42a84d8b32
3 changed files with 11 additions and 4 deletions

View file

@ -72,6 +72,10 @@ class Page < ActiveRecord::Base
web.select.pages_that_link_to(name) web.select.pages_that_link_to(name)
end end
def redirects
wiki_references.select { |ref| ref.redirected_page? }.map { |ref| ref.referenced_name }
end
def included_from def included_from
web.select.pages_that_include(name) web.select.pages_that_include(name)
end end

View file

@ -67,8 +67,8 @@ class PageSet < Array
if never_orphans.include? page.name if never_orphans.include? page.name
false false
else else
# references = pages_that_reference(page.name) references = WikiReference.pages_that_reference(@web, page.name) +
references = WikiReference.pages_that_reference(@web, page.name) WikiReference.pages_redirected_to(@web, page.name)
references.empty? or references == [page.name] references.empty? or references == [page.name]
end end
} }

View file

@ -60,9 +60,12 @@ class WikiReference < ActiveRecord::Base
def self.pages_redirected_to(web, page_name) def self.pages_redirected_to(web, page_name)
names = [] names = []
redirected_pages = []
page = web.page(page_name) page = web.page(page_name)
redirected_pages = Thread.current[:page_redirects][page.name] redirected_pages.concat page.redirects
redirected_pages.each { |name| names = names + self.pages_that_reference(web, name) } if redirected_pages redirected_pages.concat Thread.current[:page_redirects][page.name] if
Thread.current[:page_redirects] && Thread.current[:page_redirects][page.name]
redirected_pages.uniq.each { |name| names = names + self.pages_that_reference(web, name) }
names.uniq names.uniq
end end