Merge branch 'bzr/golem' of /Users/distler/Sites/code/instiki
This commit is contained in:
commit
085783d308
5 changed files with 22 additions and 25 deletions
|
@ -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'
|
||||
|
|
|
@ -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?
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<ul>
|
||||
<%- @pages_in_category.each do |page| -%>
|
||||
<li>
|
||||
<%= link_to_existing_page page, truncate(page.plain_name, :length => 35) %>
|
||||
<%= link_to_existing_page page, truncate(page.plain_name, 35) %>
|
||||
</li>
|
||||
<%- end -%>
|
||||
</ul>
|
||||
|
@ -37,7 +37,7 @@
|
|||
<ul style="margin-bottom: 10px">
|
||||
<%- @page_names_that_are_wanted.each do |wanted_page_name| -%>
|
||||
<li>
|
||||
<%= link_to_page(wanted_page_name, @web, truncate(WikiWords.separate(wanted_page_name), :length => 35)) %>
|
||||
<%= link_to_page(wanted_page_name, @web, truncate(WikiWords.separate(wanted_page_name), 35)) %>
|
||||
wanted by
|
||||
<%= @web.select.pages_that_reference(wanted_page_name).collect { |referring_page|
|
||||
link_to_existing_page referring_page
|
||||
|
@ -57,7 +57,7 @@
|
|||
<ul style="margin-bottom: 35px">
|
||||
<%- @pages_that_are_orphaned.each do |orphan_page| -%>
|
||||
<li>
|
||||
<%= link_to_existing_page orphan_page, truncate(orphan_page.plain_name, :length => 35) %>
|
||||
<%= link_to_existing_page orphan_page, truncate(orphan_page.plain_name, 35) %>
|
||||
</li>
|
||||
<%- end -%>
|
||||
</ul>
|
||||
|
|
|
@ -19,6 +19,7 @@ class WikiControllerTest < ActionController::TestCase
|
|||
|
||||
def setup
|
||||
@controller = WikiController.new
|
||||
@controller.extend ApplicationHelper
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
class << @request.session
|
||||
|
|
Loading…
Reference in a new issue