diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index fd7abeb6..2bd72b50 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,7 +1,7 @@ # The filters added to this controller will be run for all controllers in the application. # Likewise will all the methods added be available for all controllers. class ApplicationController < ActionController::Base -# require 'dnsbl_check' + protect_forms_from_spam before_filter :connect_to_model, :check_authorization, :setup_url_generator, :set_content_type_header, :set_robots_metatag after_filter :remember_location, :teardown_url_generator @@ -19,6 +19,10 @@ class ApplicationController < ActionController::Base Wiki.new end + def xhtml_enabled? + in_a_web? and [:markdownMML, :markdownPNG, :markdown].include?(@web.markup) + end + protected def check_authorization @@ -166,8 +170,6 @@ class ApplicationController < ActionController::Base end end - public - def set_content_type_header response.charset = 'utf-8' if %w(atom_with_content atom_with_headlines).include?(action_name) @@ -190,12 +192,6 @@ class ApplicationController < ActionController::Base end end - def xhtml_enabled? - in_a_web? and (@web.markup == :markdownMML or @web.markup == :markdownPNG or @web.markup == :markdown) - end - - protected - def set_robots_metatag if controller_name == 'wiki' and %w(show published s5).include? action_name and !(params[:mode] == 'diff') @robots_metatag_value = 'index,follow' diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index 31360927..270fbebd 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -389,19 +389,6 @@ class WikiController < ApplicationController end end - def truncate(text, length = 30, truncate_string = '...') - return text if text.length <= length - len = length - truncate_string.length - t = '' - text.split.collect do |word| - if t.length + word.length <= len - t << word + ' ' - else - return t.chop + truncate_string - end - end - end - protected def do_caching? diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 154d54fd..893faa70 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -111,4 +111,17 @@ module ApplicationHelper PageRenderer.new(page.revisions.last).display_content end + def truncate(text, length = 30, truncate_string = '...') + return text if text.length <= length + len = length - truncate_string.length + t = '' + text.split.collect do |word| + if t.length + word.length <= len + t << word + ' ' + else + return t.chop + truncate_string + end + end + end + end diff --git a/app/views/wiki/list.rhtml b/app/views/wiki/list.rhtml index 12dc2571..fb42a0bd 100644 --- a/app/views/wiki/list.rhtml +++ b/app/views/wiki/list.rhtml @@ -13,7 +13,7 @@