2007-09-27 01:15:22 -04:00
|
|
|
module ApplicationHelper
|
2007-10-03 02:34:21 -04:00
|
|
|
##
|
|
|
|
# Returns the title for a page. This could be a Page title or something else.
|
|
|
|
#
|
|
|
|
def page_title
|
2007-11-15 19:57:44 -05:00
|
|
|
"BarleySodas :: #{content_title} :: #{secondary_title}"
|
2007-11-15 18:42:26 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# Returns a pretty name for the current chunk.
|
|
|
|
#
|
|
|
|
def content_title
|
2007-11-28 01:17:25 -05:00
|
|
|
return h(@content_title) if @content_title
|
2007-11-15 19:57:44 -05:00
|
|
|
controller.class.to_s.gsub(/Controller/, '')
|
2007-10-03 02:34:21 -04:00
|
|
|
end
|
2007-10-04 00:54:21 -04:00
|
|
|
|
2007-11-15 01:49:33 -05:00
|
|
|
##
|
|
|
|
# Returns a secondary title for a page. Returns @secondary_title or the
|
|
|
|
# action in the controller.
|
|
|
|
#
|
|
|
|
def secondary_title
|
2007-11-28 01:17:25 -05:00
|
|
|
return h(@secondary_title) if @secondary_title
|
2007-11-15 19:57:44 -05:00
|
|
|
params[:action].to_s.capitalize.gsub(/_/) do |x|
|
2007-11-15 01:49:33 -05:00
|
|
|
$1.capitalize
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2007-10-04 00:54:21 -04:00
|
|
|
##
|
|
|
|
# Returns a link for a Page model.
|
|
|
|
#
|
|
|
|
def link_to_page(page)
|
2007-11-28 01:17:25 -05:00
|
|
|
link_to h(page.title), page_path({ :id => page.title_for_url })
|
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# Helper to set the allow_discussions field in the Page model.
|
|
|
|
#
|
|
|
|
def allow_page_discussions
|
|
|
|
@page.allow_discussions = true
|
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# Helper to check if Discussion is allowed. This should check the underlying
|
|
|
|
# permissions first instead of looking in the model.
|
|
|
|
#
|
|
|
|
def discussions_allowed?
|
|
|
|
@page and @page.allow_discussions?
|
2007-10-04 00:54:21 -04:00
|
|
|
end
|
2007-09-27 01:15:22 -04:00
|
|
|
end
|