examples/wiktacular/src/model.rb in ramaze-0.3.5 vs examples/wiktacular/src/model.rb in ramaze-0.3.9

- old
+ new

@@ -3,11 +3,13 @@ class WikiEntry ENTRIES_DIR = __DIR__/'../mkd' class << self def [](name) - new(name) + if File.exist?(ENTRIES_DIR/File.basename(File.expand_path(name))) + new(name) + end end def titles Dir[ENTRIES_DIR/'*'].entries end end @@ -77,19 +79,23 @@ File.basename(File.expand_path(path)) end end class EntryView + include Ramaze::Helper::Methods + helper :cgi, :link + class << self + def render content mkd2html(content || "No Entry") end def mkd2html text html = BlueCloth.new(text).to_html html.gsub!(/\[\[(.*?)\]\]/) do |m| exists = WikiEntry[$1] ? 'exists' : 'nonexists' - %{<a href="/#{CGI.escape($1)}" class="#{exists}">#{$1}</a>} + A(h($1), :href => $1, :class => exists) end html end end end