Merge branch 'bzr/golem' of /Users/distler/Sites/code/instiki
This commit is contained in:
commit
42a84d8b32
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue