require 'html_diff/lib/html_diff' module ApplicationHelper def nlink_to(name, options = {}, html_options = {}, *parameters_for_method_reference) link_to(name, options, html_options.update(:class => "navlink"), *parameters_for_method_reference) end def page_title if @page && (@page.title == 'Home Page') && (%w( show published print ).include?(@controller.action_name)) @book.name elsif @book "#{@title} in #{@book.name}" else @title end end def page_heading if @page && (@page.title == 'Home Page') && (%w( show published print ).include?(@controller.action_name)) @book.name elsif @book link_to(@book.name + ':', pages_url) + ' ' + @title else @title end end def markup(body, existing_page_titles = @book.existing_page_titles) # require 'redcloth303' # Use local, specific version in 'lib' text = linkize(auto_link(body), existing_page_titles) # textilized = RedCloth.new(text, [ :hard_breaks ]) # textilized.hard_breaks = true if textilized.respond_to?("hard_breaks=") # textilized.to_html RedCloth.new(text).to_html end def differences(original, new) HTMLDiff.diff(original, new) end def link_to_author(author) link_to(author.name, page_url(:page_title => author)) + " (#{author.ip})" end private def linkize(body, existing_titles) body.gsub(Version::PAGE_LINK) do page = title = $1 title = $2 unless $2.empty? if existing_titles.include?(page) link_to(title, page_url(:page_title => page), :class => "existingWikiWord") else content_tag("span", title + link_to("?", page_url(:page_title => page)), :class => "newWikiWord") end end end end