Added meta robots tag to the default layout; added error handling to published pages

This commit is contained in:
Alexey Verkhovsky 2005-11-01 07:31:44 +00:00
parent 9e7306fb0a
commit d3b25c8a19
3 changed files with 18 additions and 8 deletions

View file

@ -2,7 +2,7 @@
# Likewise will all the methods added be available for all controllers.
class ApplicationController < ActionController::Base
before_filter :connect_to_model, :setup_url_generator, :set_content_type_header
before_filter :connect_to_model, :setup_url_generator, :set_content_type_header, :set_robots_metatag
after_filter :remember_location, :teardown_url_generator
observer :page_observer
@ -152,6 +152,14 @@ class ApplicationController < ActionController::Base
end
end
def set_robots_metatag
if controller_name == 'wiki' and %w(show published).include? action_name
@robots_metatag_value = 'index,follow'
else
@robots_metatag_value = 'noindex,nofollow'
end
end
def setup_url_generator
PageRenderer.setup_url_generator(UrlGenerator.new(self))
end

View file

@ -195,12 +195,13 @@ class WikiController < ApplicationController
end
def published
if @web.published?
page = wiki.read_page(@web_name, @page_name || 'HomePage')
render_text("Published version of web '#{@web_name}' is not available", 404) and return if not @web.published?
page_name = @page_name || 'HomePage'
page = wiki.read_page(@web_name, page_name)
render_text("Page '#{page_name}' not found", 404) and return unless page
@renderer = PageRenderer.new(page.revisions.last)
else
redirect_home
end
end
def revision

View file

@ -14,6 +14,7 @@ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="robots" content="<%= @robots_metatag_value %>" />
<style type="text/css">
h1#pageName, .newWikiWord a, a.existingWikiWord, .newWikiWord a:hover, #TextileHelp h3 {