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 } wiki_references.select { |ref| ref.wiki_word? }.map { |ref| ref.referenced_name }
end end
def categories
wiki_references.select { |ref| ref.category? }.map { |ref| ref.referenced_name }
end
def linked_from def linked_from
web.select.pages_that_link_to(name) web.select.pages_that_link_to(name)
end end

View file

@ -81,16 +81,6 @@ class WikiReference < ActiveRecord::Base
row['name'].as_utf8 if row row['name'].as_utf8 if row
end 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) def self.pages_in_category(web, category)
query = query =
"SELECT name FROM pages JOIN wiki_references " + "SELECT name FROM pages JOIN wiki_references " +
@ -142,4 +132,8 @@ class WikiReference < ActiveRecord::Base
link_type == WANTED_FILE link_type == WANTED_FILE
end end
def category?
link_type == CATEGORY
end
end end

View file

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