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

This commit is contained in:
Jacques Distler 2010-01-29 11:15:56 -06:00
commit 1373963fe3
3 changed files with 9 additions and 12 deletions

View file

@ -72,6 +72,10 @@ class Page < ActiveRecord::Base
wiki_references.select { |ref| ref.wiki_word? }.map { |ref| ref.referenced_name }
end
def categories
wiki_references.select { |ref| ref.category? }.map { |ref| ref.referenced_name }
end
def linked_from
web.select.pages_that_link_to(name)
end

View file

@ -81,16 +81,6 @@ class WikiReference < ActiveRecord::Base
row['name'].as_utf8 if row
end
def self.page_categories(web, page_name)
query =
"SELECT referenced_name FROM wiki_references JOIN pages " +
"ON wiki_references.page_id = pages.id " +
"WHERE pages.name = ? " +
"AND wiki_references.link_type = '#{CATEGORY}' " +
"AND pages.web_id = '#{web.id}'"
names = connection.select_all(sanitize_sql([query, page_name])).map { |row| row['referenced_name'].as_utf8 }
end
def self.pages_in_category(web, category)
query =
"SELECT name FROM pages JOIN wiki_references " +
@ -142,4 +132,8 @@ class WikiReference < ActiveRecord::Base
link_type == WANTED_FILE
end
def category?
link_type == CATEGORY
end
end

View file

@ -69,8 +69,7 @@ function cleanAuthorName() {
}
document.forms["editForm"].elements["content"].focus();
<%- if [:markdownMML, :markdownPNG, :markdown].include?(@web.markup) and
!WikiReference.page_categories(@web, @page.name).include?('S5-slideshow') -%>
<%- if [:markdownMML, :markdownPNG, :markdown].include?(@web.markup) and !@page.categories.include?('S5-slideshow') -%>
addS5button('<%= CGI.escapeHTML(@page.name) %>');
<%- end -%>
//--><!]]>