2012-01-31 16:40:46 +00:00
|
|
|
# -*- encoding : utf-8 -*-
|
2011-12-23 17:01:47 +00:00
|
|
|
module WikiHelper
|
2012-01-19 13:49:32 +00:00
|
|
|
|
2012-01-19 23:04:11 +00:00
|
|
|
def revert_path(project, first, second, name)
|
|
|
|
if name
|
|
|
|
revert_page_project_wiki_path(project, CGI.escape(name), first, second)
|
|
|
|
else
|
2012-01-28 12:10:43 +00:00
|
|
|
revert_project_wiki_index_path(project, first, second)
|
2012-01-19 13:49:32 +00:00
|
|
|
end
|
2012-01-19 23:04:11 +00:00
|
|
|
end
|
2012-01-19 13:49:32 +00:00
|
|
|
|
2012-01-19 23:04:11 +00:00
|
|
|
def compare_path(project, name)
|
|
|
|
if name
|
|
|
|
compare_project_wiki_path(@project, CGI.escape(name))
|
|
|
|
else
|
|
|
|
compare_project_wiki_index_path(@project)
|
2012-01-19 13:49:32 +00:00
|
|
|
end
|
|
|
|
end
|
2012-01-17 23:30:54 +00:00
|
|
|
|
2012-01-16 21:48:38 +00:00
|
|
|
def escaped_name
|
|
|
|
CGI.escape(@name)
|
|
|
|
end
|
|
|
|
|
|
|
|
def editor_path(project, name)
|
|
|
|
if @new
|
|
|
|
url_for(:controller => :wiki, :action => :create, :project_id => project.id)
|
|
|
|
else
|
|
|
|
url_for(:controller => :wiki, :action => :update, :project_id => project.id, :id => name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-01-17 23:30:54 +00:00
|
|
|
def view_path(project, name)
|
|
|
|
name == 'Home' ? project_wiki_index_path(project) : project_wiki_path(project, name)
|
|
|
|
end
|
|
|
|
|
2012-02-04 18:03:29 +00:00
|
|
|
def wiki_formats
|
2012-01-27 18:24:12 +00:00
|
|
|
APP_CONFIG['wiki_formats'].map do |key, val|
|
2012-01-16 21:48:38 +00:00
|
|
|
[ val, key.to_s ]
|
|
|
|
end.sort do |a, b|
|
|
|
|
a.first.downcase <=> b.first.downcase
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def footer
|
|
|
|
if @footer.nil?
|
2012-01-30 15:27:54 +00:00
|
|
|
@footer = !!@page.footer ? @page.footer : false
|
2012-01-16 21:48:38 +00:00
|
|
|
end
|
|
|
|
@footer
|
|
|
|
end
|
|
|
|
|
|
|
|
def sidebar
|
|
|
|
if @sidebar.nil?
|
2012-01-30 15:27:54 +00:00
|
|
|
@sidebar = !!@page.sidebar ? @page.sidebar : false
|
2012-01-16 21:48:38 +00:00
|
|
|
end
|
|
|
|
@sidebar
|
|
|
|
end
|
|
|
|
|
|
|
|
def has_footer?
|
|
|
|
@footer = (@page.footer || false) if @footer.nil? && @page
|
|
|
|
!!@footer
|
|
|
|
end
|
|
|
|
|
|
|
|
def has_sidebar?
|
|
|
|
@sidebar = (@page.sidebar || false) if @sidebar.nil? && @page
|
|
|
|
!!@sidebar
|
|
|
|
end
|
|
|
|
|
|
|
|
def footer_content
|
|
|
|
has_footer? && @footer.formatted_data
|
|
|
|
end
|
|
|
|
|
|
|
|
def footer_format
|
|
|
|
has_footer? && @footer.format.to_s
|
|
|
|
end
|
|
|
|
|
|
|
|
def sidebar_content
|
|
|
|
has_sidebar? && @sidebar.formatted_data
|
|
|
|
end
|
|
|
|
|
|
|
|
def sidebar_format
|
|
|
|
has_sidebar? && @sidebar.format.to_s
|
|
|
|
end
|
|
|
|
|
|
|
|
def author
|
2012-03-21 19:55:14 +00:00
|
|
|
@page.version.author.name
|
2012-01-16 21:48:38 +00:00
|
|
|
end
|
|
|
|
|
2012-01-29 18:03:42 +00:00
|
|
|
def author_email
|
|
|
|
@page.version.author.email
|
|
|
|
end
|
|
|
|
|
2012-02-03 00:04:20 +00:00
|
|
|
def user_path_by_user(user)
|
|
|
|
(user.present?) ? user_path(user) : 'javascript:void(0)'
|
|
|
|
end
|
|
|
|
|
|
|
|
def user_link_by_user(user)
|
|
|
|
link_to (user.present?) ? user.uname : author, user_path_by_user(user)
|
2012-01-29 18:03:42 +00:00
|
|
|
end
|
|
|
|
|
2012-01-16 21:48:38 +00:00
|
|
|
def date
|
|
|
|
@page.version.authored_date.strftime("%Y-%m-%d %H:%M:%S")
|
|
|
|
end
|
|
|
|
|
|
|
|
def format
|
|
|
|
@new ? 'markdown' : @page.format
|
|
|
|
end
|
2011-12-23 17:01:47 +00:00
|
|
|
end
|