From b4494c043d66d8b9bb6c5b71add813c326f4bebe Mon Sep 17 00:00:00 2001
From: AntonioTerceiro There was an error generating the preview.#{$!.to_s.gsub(/\, '<')}
There was an error generating the preview.
#{$!.to_s.gsub(/\, '<')}"
- end
- render :text=>content, :layout => false
- end
-
- # Expires the entire page cache
- def expire_page_cache
- expire_cms_pages_from_bottom( fetch_root_page )
- expire_cms_fragments_from_bottom( fetch_root_page )
- flash[:notice] = "Page cache has been flushed"
- redirect_to :controller=>self.controller_name, :action=>'index'
- end
-
- # Walks the page tree and generates HTML files in your /public
- # folder... It will skip pages that have a 'nocache' keyword
- # TODO: Make page cache generation work when in :plugin mode
- def generate_page_cache
- if runtime_mode == :plugin
- @errors = ["Page cache cannot be generated in plugin mode"]
- else
- @errors = generate_all_pages_html(params)
- end
- if @errors.length == 0
- flash[:notice] = "Pages Cached Successfully"
- else
- flash[:notice] = "Pages Cache Error(s): #{@errors.join(', ')}"
- flash[:cache_errors] = @errors
- end
- redirect_to :controller=>self.controller_name, :action=>'index'
- end
-
-
- protected
-
- def handle_authorization
- if Comatose.config.admin_authorization.is_a? Proc
- instance_eval &Comatose.config.admin_authorization
- elsif Comatose.config.admin_authorization.is_a? Symbol
- send(Comatose.config.admin_authorization)
- elsif defined? authorize
- authorize
- else
- true
- end
- end
-
- def fetch_author_name
- if Comatose.config.admin_get_author.is_a? Proc
- instance_eval &Comatose.config.admin_get_author
- elsif Comatose.config.admin_get_author.is_a? Symbol
- send(Comatose.config.admin_get_author)
- elsif defined? get_author
- get_author
- end
- end
-
- # Can be overridden -- return your root comtase page
- def fetch_root_page
- if Comatose.config.admin_get_root_page.is_a? Proc
- instance_eval &Comatose.config.admin_get_root_page
- elsif Comatose.config.admin_get_root_page.is_a? Symbol
- send(Comatose.config.admin_get_root_page)
- elsif defined? get_root_page
- get_root_page
- end
- end
-
- # Sets the HTTP content-type header based on what's configured
- # in Comatose.config.content_type
- def set_content_type
- response.headers["Content-Type"] = "text/html; charset=#{Comatose.config.content_type}" unless Comatose.config.content_type.nil?
- end
-
- # Calls generate_page_html for each mount point..
- def generate_all_pages_html(params={})
- @errors = []
- @been_cached = []
- Comatose.mount_points.each do |root_info|
- page_class.active_mount_info = root_info
- generate_page_html(page_class.find_by_path( root_info[:index] ), root_info, params)
- end
- @errors
- end
-
- # Accepts a Comatose Page and a root_info object to generate
- # the page as a static HTML page -- using the layout that was
- # defined on the mount point
- def generate_page_html(page, root_info, params={})
- @been_cached ||= []
- unless page.has_keyword? :nocache or @been_cached.include? page.id
- uri = page.uri
- uri = "#{uri}/index".split('/').flatten.join('/') if page.full_path == root_info[:index]
- @page = Comatose::PageWrapper.new(page)
- begin
- page_layout = get_page_layout(root_info)
- #puts "mode = #{runtime_mode}, layout = #{page_layout}, template_root = #{template_root}, original_template_root = #{original_template_root}"
- html = render_to_string( :text=>page.to_html({'params'=>params.stringify_keys}), :layout=>page_layout )
- cache_page( html, uri )
- rescue
- logger.error "Comatose CMS Page Cache Exception: #{$!}"
- @errors << "(#{page}/#{page.slug}) - #{$!}"
- end
- @been_cached << page.id
- # recurse...
- page.children.each do |child|
- generate_page_html(child, root_info)
- end
- end
- end
-
- # Calls the class methods of the same name...
- def expire_cms_page(page)
- self.class.expire_cms_page(page)
- end
- def expire_cms_pages_from_bottom(page)
- self.class.expire_cms_pages_from_bottom(page)
- end
-
-
- # expire the page from the fragment cache
- def expire_cms_fragment(page)
- key = page.full_path.gsub(/\//, '+')
- expire_fragment(key)
- end
-
- # expire pages starting at a specific node
- def expire_cms_fragments_from_bottom(page)
- pages = page.is_a?(Array) ? page : [page]
- pages.each do |page|
- page.children.each {|c| expire_cms_fragments_from_bottom( c ) } if !page.children.empty?
- expire_cms_fragment( page )
- end
- end
-
- # Class Methods...
- class << self
-
- # Walks all the way down, and back up the tree -- the allows the expire_cms_page
- # to delete empty directories better
- def expire_cms_pages_from_bottom(page)
- pages = page.is_a?(Array) ? page : [page]
- pages.each do |page|
- page.children.each {|c| expire_cms_pages_from_bottom( c ) } if !page.children.empty?
- expire_cms_page( page )
- end
- end
-
- # Expire the page from all the mount points...
- def expire_cms_page(page)
- Comatose.mount_points.each do |path_info|
- page_class.active_mount_info = path_info
- expire_page(page.uri)
- # If the page is the index page for the root, expire it too
- if path_info[:root] == page.uri
- expire_page("#{path_info[:root]}/index")
- end
- begin # I'm not sure this matters too much -- but it keeps things clean
- dir_path = File.join(RAILS_ROOT, 'public', page.uri[1..-1])
- Dir.delete( dir_path ) if FileTest.directory?( dir_path ) and !page.parent.nil?
- rescue
- # It probably isn't empty -- just as well we leave it be
- #STDERR.puts " - Couldn't delete dir #{dir_path} -> #{$!}"
- end
- end
- end
-
- # Returns a path to plugin layout, if it's unspecified, otherwise
- # a path to an application layout...
- def get_page_layout(params)
- if params[:layout] == 'comatose_content'
- File.join(plugin_layout_path, params[:layout])
- else
- params[:layout]
- end
- end
-
- def configure_template_root
- if self.runtime_mode == :unknown
- if FileTest.exist? File.join(RAILS_ROOT, 'public', 'javascripts', 'comatose_admin.js')
- self.runtime_mode = :application
- else
- self.runtime_mode = :plugin
- end
- end
- end
-
- def runtime_mode
- @@runtime_mode ||= :unknown
- end
-
- def runtime_mode=(mode)
- case mode
- when :plugin
- self.original_template_root = self.template_root
- self.template_root = File.join( File.dirname(__FILE__), '..', '..', 'views')
- when :application
- self.template_root = self.original_template_root if self.original_template_root
- end
- @@runtime_mode = mode
- end
-
- end
-
- # Check to see if we are in 'embedded' mode, or are being 'customized'
- # embedded = runtime_mode of :plugin
- # customized = runtime_mode of :application
- configure_template_root
-
- #
- # Include any modules...
- Comatose.config.admin_includes.each do |mod|
- if mod.is_a? String
- include mod.constantize
- elsif mod.is_a? Symbol
- include mod.to_s.classify.constantize
- else
- include mod
- end
- end
-
- # Include any helpers...
- Comatose.config.admin_helpers.each do |mod|
- if mod.is_a? String
- helper mod.constantize
- elsif mod.is_a? Symbol
- helper mod.to_s.classify.constantize
- else
- helper mod
- end
- end
-
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 18cf0b8..3feb172 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -100,7 +100,7 @@ module ApplicationHelper
def link_to_myprofile(text, url = {}, profile = nil, options = {})
profile ||= current_user.login
- link_to text, { :profile => profile }.merge(url), options
+ link_to text, { :profile => profile, :controller => 'profile_editor' }.merge(url), options
end
def link_to_document(doc, text = nil)
@@ -114,7 +114,7 @@ module ApplicationHelper
# TODO: test this helper
def user_links
links = [
- ( link_to_homepage( _('My account') )),
+ ( link_to_myprofile( _('My profile') )),
( link_to_myprofile _('My Enterprises'), {:controller => 'membership_editor'} ),
( link_to(_('Admin'), { :controller => 'admin_panel' }) if current_user.person.is_admin?),
].join("\n")
@@ -124,7 +124,7 @@ module ApplicationHelper
def shortcut_header_links
if logged_in?
[
- ( link_to_homepage( content_tag('span', _('My account')),nil, { :id => 'icon_go_home'} ) ),
+ ( link_to_myprofile( content_tag('span', _('My profile')), {}, nil, { :id => 'icon_go_home'} ) ),
# MUDAR, O ID acima deve ser no Link 'admin_panel' }, :id => 'icon_admin' if current_user.person.is_admin?),
@@ -303,16 +303,6 @@ module ApplicationHelper
end
end
- def select_filter_type(object, method, html_options)
- options = [
- [ _('No Filter at all'), '[No Filter]' ],
- [ _('RDoc filter'), 'RDoc' ],
- [ _('Simple'), 'Simple' ],
- [ _('Textile'), 'Textile' ]
- ]
- select_tag "#{object}[#{method}]", options_for_select(options, @page.filter_type || Comatose.config.default_filter), { :id=> "#{object}_#{method}" }.merge(html_options)
- end
-
def file_manager(&block)
concat(content_tag('div', capture(&block), :class => 'file-manager') + "| - <% if !page.children.empty? %> - <%= image_tag( ((collapse_children) ? 'comatose/collapsed.gif' : 'comatose/expanded.gif'), :title=>'Expand/Collapse', :onclick=>"ComatoseList.toggle_tree_nodes(this,#{page.id});", :class=>'tree-controller', :size=>'12x12', :id=>"page_controller_#{page.id}" ) %> - <% else %> - <%= image_tag 'comatose/no-children.gif', :size=>'12x12', :class=>'tree-controller' %> - <% end %> - | -- <%= icon_for_document(page) %> - <%= _('DRAG') %> - | -- <%= link_to page.title, {:action=>'edit', :id=>page}, :title=>"Path:#{page.full_path}", :class=>'page' %> - | -- <%= links.join(', ') %>. - | -
-- -<%= start_form_tag %> - -<%= end_form_tag %> diff --git a/app/views/cms/edit.rhtml b/app/views/cms/edit.rhtml deleted file mode 100644 index 6b2f158..0000000 --- a/app/views/cms/edit.rhtml +++ /dev/null @@ -1,5 +0,0 @@ -<%= _('Are you sure you want to delete the page titled "%s"?') % content_tag('strong', @page.title) %>
- <% unless @page.children.empty? %> -<%= _("It has %s child pages that will also be deleted...") % content_tag('strong', @page.children.length) %>
-<% end %> -
| - <%= image_tag 'comatose/page.gif', :size=>'25x31', :align=>"absmiddle" %> - | -- <%= page.title %> - | -
| - <%= link_to _("Move Up"), :action=>'reorder', :cmd=>'up', :page=>page.id %>, - <%= link_to _("Move Down"), :action=>'reorder', :cmd=>'down', :page=>page.id %> - | -