diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb index bba3127..2117398 100644 --- a/app/controllers/my_profile/cms_controller.rb +++ b/app/controllers/my_profile/cms_controller.rb @@ -15,347 +15,4 @@ class CmsController < MyProfileController end - public - - ############################################################# - # everything below was copied from comatose - ############################################################# - - define_option :original_template_root, nil - define_option :plugin_layout_path, File.join( '..', '..', '..', 'vendor', 'plugins', 'comatose', 'views', 'layouts' ) - - before_filter :handle_authorization - before_filter :set_content_type - - # Shows the page tree - def index - @root_pages = [fetch_root_page].flatten - end - - # Edit a specfic page (posts back) - def edit - # Clear the page cache for this page... ? - @page = page_class.find params[:id] - @root_pages = [fetch_root_page].flatten - if request.post? - @page.update_attributes(params[:page]) - @page.updated_on = Time.now - @page.author = fetch_author_name - if @page.save - expire_cms_page @page - expire_cms_fragment @page - flash[:notice] = "Saved changes to '#{@page.title}'" - redirect_to :controller=>self.controller_name, :action=>'index' - end - end - end - - # Create a new page (posts back) - def new - @root_pages = [fetch_root_page].flatten - if request.post? - @page = page_class.new params[:page] - @page.author = fetch_author_name - if @page.save - flash[:notice] = "Created page '#{@page.title}'" - redirect_to :controller=>self.controller_name, :action=>'index' - end - else - @page = page_class.new(:parent_id=>(params[:parent] || nil)) - end - end - - # Saves position of child pages - def reorder - # If it's AJAX, do our thing and move on... - if request.xhr? - params["page_list_#{params[:id]}"].each_with_index { |id,idx| page_class.update(id, :position => idx) } - expire_cms_page page_class.find(params[:id]) - render :text=>'Updated sort order', :layout=>false - else - @page = page_class.find params[:id] - if params.has_key? :cmd - @target = page_class.find params[:page] - case params[:cmd] - when 'up' then @target.move_higher - when 'down' then @target.move_lower - end - redirect_to :action=>'reorder', :id=>@page - end - end - end - - # Allows comparing between two versions of a page's content - def versions - @page = page_class.find params[:id] - @version_num = (params[:version] || @page.versions.length).to_i - @version = @page.find_version(@version_num) - end - - # Reverts a page to a specific version... - def set_version - if request.post? - @page = page_class.find params[:id] - @version_num = params[:version] - @page.revert_to!(@version_num) - end - redirect_to :controller=>self.controller_name, :action=>'index' - end - - # Deletes the specified page - def delete - @page = page_class.find params[:id] - if request.post? - expire_cms_pages_from_bottom @page - expire_cms_fragments_from_bottom @page - @page.destroy - flash[:notice] = "Deleted page '#{@page.title}'" - redirect_to :controller=>self.controller_name, :action=>'index' - end - end - - # Returns a preview of the page content... - def preview - begin - page = page_class.new(params[:page]) - page.author = fetch_author_name - if params.has_key? :version - content = page.to_html( {'params'=>params.stringify_keys, 'version'=>params[:version]} ) - else - content = page.to_html( {'params'=>params.stringify_keys} ) - end - rescue SyntaxError - content = "

There was an error generating the preview.

#{$!.to_s.gsub(/\

" - rescue - content = "

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') + "
", block.binding) end diff --git a/app/helpers/cms_helper.rb b/app/helpers/cms_helper.rb index 3cf98f6..e476188 100644 --- a/app/helpers/cms_helper.rb +++ b/app/helpers/cms_helper.rb @@ -1,41 +1,3 @@ module CmsHelper - ########################################################### - # content below was copied from comoatose - ########################################################### - - # Checks the hidden_meta_fields class variable for a specified field name... - def show_field?(key) - !Comatose.config.hidden_meta_fields.include? key - end - - # Used in the Page Form to build an indented drop-down list of pages - def tree_select_box(nodes, selected= nil, hide= nil, label="Parent", add_initial=false) - level = 0 - select_box = add_initial ? "\n" : "" - selected = nodes[0].id if selected.nil? and not add_initial - nodes.each {|node| select_box += add_select_tree_node(node, selected, level, hide) } - select_box += '' - end - # Called by tree_select_box - def add_select_tree_node(node, selected, level, hide) - padding = " " * level * 4 - padding += '» ' unless level==0 - hide_values = Array.new - hide_values << hide if hide - if node.id == selected - select_box = %Q|\n| - else - if hide_values.include?(node.id) - select_box = '' - else - select_box = %Q|\n| - end - end - node.children.each do |child| - select_box += add_select_tree_node(child, selected, level + 1, hide) unless hide_values.include?(node.id) - end - select_box - end - end diff --git a/app/helpers/document_helper.rb b/app/helpers/document_helper.rb index 3085430..86912ac 100644 --- a/app/helpers/document_helper.rb +++ b/app/helpers/document_helper.rb @@ -7,7 +7,7 @@ module DocumentHelper def icon_for_document(doc) icon = case doc - when Comatose::Page + when Article 'text-x-generic' else if doc.class.respond_to?(:icon) diff --git a/app/models/article.rb b/app/models/article.rb index 7baea91..c5ca000 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -1,4 +1,5 @@ -class Article < Comatose::Page +class Article + acts_as_taggable # acts_as_ferret :fields => [:title, :body] @@ -19,12 +20,6 @@ class Article < Comatose::Page @profile ||= Profile.find_by_identifier(self.full_path.split(/\//).first) end - def title=(value) - super - # taken from comatose, added a call to transliterate right before downcase. - if (self[:slug].nil? or self[:slug].empty?) and !self[:title].nil? - self[:slug] = self[:title].transliterate.downcase.gsub( /[^-a-z0-9~\s\.:;+=_]/, '').gsub(/[\s\.:;=_+]+/, '-').gsub(/[\-]{2,}/, '-').to_s - end - end + # FIXME add code from Category to make article acts as a "file system" end diff --git a/app/models/category.rb b/app/models/category.rb index 8180ca8..02362a0 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -72,6 +72,8 @@ class Category < ActiveRecord::Base self[:name] = value unless self.name.blank? + # FIXME encapsulate this patter (transliterate -> downcase -> gsub ...) + # in a String method, say, to_slug self.slug = self.name.transliterate.downcase.gsub( /[^-a-z0-9~\s\.:;+=_]/, '').gsub(/[\s\.:;=_+]+/, '-').gsub(/[\-]{2,}/, '-').to_s end end diff --git a/app/models/profile.rb b/app/models/profile.rb index df14d29..40e189b 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -11,19 +11,6 @@ class Profile < ActiveRecord::Base 'edit_profile_design' => N_('Edit profile design'), } - after_create do |profile| - homepage = Article.new - homepage.title = profile.name - homepage.parent = Comatose::Page.root - homepage.slug = profile.identifier - homepage.save! - end - - after_destroy do |profile| - article = Article.find_by_path(profile.identifier) - article.destroy if article - end - acts_as_accessible acts_as_design @@ -84,8 +71,8 @@ class Profile < ActiveRecord::Base end def homepage(reload = false) - @homepage = nil if reload - @homepage ||= Article.find_by_path(self.identifier) + # FIXME + raise 'needs to be implemented' end # Returns information about the profile's owner that was made public by diff --git a/app/views/cms/_form.rhtml b/app/views/cms/_form.rhtml deleted file mode 100644 index 93fe0bb..0000000 --- a/app/views/cms/_form.rhtml +++ /dev/null @@ -1,106 +0,0 @@ - -<%= javascript_include_tag 'tiny_mce/tiny_mce.js' %> -<%= javascript_include_tag 'noosfero_tiny_mce.js' %> - - - - - -<%= error_messages_for :page %> - -<% form_for :page, @page do |f| %> - -
- - <%= f.text_field :title, :tabindex => 1, :maxlength => 255, :size => 30 %> <%= link_to_function _("More..."), "ComatoseEditForm.toggle_extra_fields(this, '%s', '%s')" % [_('More...'), _('Less...')], :id => 'more-options' %> -
- -
- - <%= f.text_field :slug, :tabindex=>6, :maxlength=>255, :size=>50, :disabled=>@root_pages.include?(@page) %> -
- -
- <% if show_field? 'keywords' %> - - <%= f.text_field :keywords, :tabindex=>7, :maxlength=>1000, :size=>50 %> - <% end %> -
- -
- <% if show_field? 'parent' %> - - <% if mode != :new and @root_pages.include? @page %> - - <% else %> - - <% end %> - <% end %> -
- -
- - <%= text_editor('page', 'body', 'filter_type', :tabindex => 2) %> -
- -
- <% if show_field? 'filter' %> - - <%= select_filter_type('page', 'filter_type', :tabindex => 3 ) %> - <%= _('Converts plain text into HTML') %> - <% end %> -
- -
- <% if show_field? 'created_on' %> - - <%= f.datetime_select :created_on %> - <% end %> -
- -
-<% end %> - - - -<%= javascript_tag "ComatoseEditForm.init('#{mode.to_s}');" %> diff --git a/app/views/cms/_page_list_item.rhtml b/app/views/cms/_page_list_item.rhtml deleted file mode 100644 index fc43141..0000000 --- a/app/views/cms/_page_list_item.rhtml +++ /dev/null @@ -1,57 +0,0 @@ -<%# Params: -# - page (Page Node) -# - level (integer indicating current tree depth) -# Called From: -# - index -# Description: -# This partial is used recursively. Render it with the root node, and it will recurse -# down all of the child nodes to build a list with proper indentation to indicate -# tree depth. -%> - -<% -# Create the page-level links... -links = [] -links << link_to((page.versions.length == 1 ? _('%d revision') : _('%d revisions')) % page.versions.length, :action=>'versions', :id=>page) if page.versions.length > 0 -links << link_to(_('add child document'), {:action=>'new', :parent=>page}, :title=> _("Add a child to '%s'") % page.title, :class=>'add-page') -links << link_to_function(_('reorder children'), "ComatoseList.toggle_reorder('page_list_#{page.id}',this,#{page.id}, '%s', '%s')" % [_('reorder children'), _('finished reordering')], :title=> _("Reorder children of '%s'") % page.title, :class=>'reorder-children', :href=>url_for(:action=>'reorder', :id=>page)) if !page.children.empty? and page.children.length > 1 -links << link_to(_('delete'), {:action=>'delete', :id=>page}, :confirm=> _('This will delete this page, and any children. Are you sure?'), :title=> _("Delete page '%s' and all it's children") % page.title, :class=>'delete-page', :method=>'post', :onmouseover=>"ComatoseList.item_hover('page_#{page.id}', 'over', true)", :onmouseout=>"ComatoseList.item_hover('page_#{page.id}', 'out', true)") unless @root_pages.include? page -# Level check, one, two, three... -collapse_children = (level >= Comatose.config.default_tree_level) -%> - -
  • - - - - - - - -
    - <% 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(', ') %>. -
    - -
      - <% for child in page.children %> - <%= render :partial=>'page_list_item', :locals=>{ :page=>child, :level=>level+1 } %> - <% end %> -
    - - <%= sortable_element( "page_list_#{page.id}", - :complete => visual_effect(:highlight, "page_list_#{page.id}"), - :handle=>'handle', - :update=>'flash-content', - :url => { :action => "reorder", :id=>page } ) if !page.children.empty? and page.children.length > 1 %> -
  • diff --git a/app/views/cms/delete.rhtml b/app/views/cms/delete.rhtml deleted file mode 100644 index fd3dd07..0000000 --- a/app/views/cms/delete.rhtml +++ /dev/null @@ -1,18 +0,0 @@ -

    - Page Delete Confirmation -

    - -
    -

    <%= _('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 %> -
    - -<%= start_form_tag %> -
    - <%= submit_tag _("Yes, Delete The Page") %> - or - <%= link_to _("Cancel"), :action=>'index' %> -
    -<%= 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 @@ -

    - <%= _("Edit Page") %> -

    - -<%= render :partial=>'form', :locals=>{:mode=>:edit} %> diff --git a/app/views/cms/index.rhtml b/app/views/cms/index.rhtml deleted file mode 100644 index 3a14de5..0000000 --- a/app/views/cms/index.rhtml +++ /dev/null @@ -1,22 +0,0 @@ -
    - <%= link_to _('Clear Page Cache'), :controller=>controller.controller_name, :action=>'expire_page_cache' %> -
    - -

    - <%= _('Articles') %> - <%= image_tag 'comatose/spinner.gif', :id=>'spinner', :align=>'absmiddle', :style=>'display:none;' %> -

    - - - -
    - <%= link_to _('New article'), :action => 'new' %> -
    - -
    - -<%= javascript_tag "ComatoseList.init()" %> diff --git a/app/views/cms/new.rhtml b/app/views/cms/new.rhtml deleted file mode 100644 index 26bf982..0000000 --- a/app/views/cms/new.rhtml +++ /dev/null @@ -1,5 +0,0 @@ -

    - <%= _('New Page') %> -

    - -<%= render :partial=>'form', :locals=>{:mode=>:new} %> diff --git a/app/views/cms/reorder.rhtml b/app/views/cms/reorder.rhtml deleted file mode 100644 index d839538..0000000 --- a/app/views/cms/reorder.rhtml +++ /dev/null @@ -1,30 +0,0 @@ -

    <%= _('Reorder Pages') %>

    - -

    <%= _('"%s" child pages:') % @page.title %>

    - - - -
    - <%= link_to _("Finished"), :action=>'index' %> -
    diff --git a/app/views/cms/versions.rhtml b/app/views/cms/versions.rhtml deleted file mode 100644 index c470c55..0000000 --- a/app/views/cms/versions.rhtml +++ /dev/null @@ -1,44 +0,0 @@ -

    <%= _('Page Revisions') %>

    -
    -
    -
    -
    - <% form_tag :action => 'versions', :id => @page, :html => { :method => :get } do %> - <%= _('View Version:') %><%= select_tag "version", options_from_collection_for_select(@page.versions, 'version', 'version', @version_num), {'onchange'=>'this.form.submit();'} %> - <%= submit_tag 'Go', {'id'=>'go-btn'} %> - <% end %> -
    - <%= _('Version %s') % @version_num %> -
    -
    - - - <% if show_field? 'keywords' %> - - <% end %> -
    - <%= @version.body.split("\n").join('
    ') unless @version.body.nil? %> - -
    - -
    -
    - <% _('Current Version') %> -
    -
    - - - <% if show_field? 'keywords' %> - - <% end %> -
    - <%= @page.body.split("\n").join('
    ') unless @page.body.nil? %> -
    - -
     
    diff --git a/app/views/layouts/application.rhtml b/app/views/layouts/application.rhtml index 34647a2..23d81ed 100644 --- a/app/views/layouts/application.rhtml +++ b/app/views/layouts/application.rhtml @@ -67,7 +67,6 @@
    -
    diff --git a/config/environment.rb b/config/environment.rb index ebf8011..bbcc881 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -75,30 +75,5 @@ Localist.callback = lambda { |l| GetText.locale= l } Tag.hierarchical = true -Comatose.configure do |config| - config.admin_get_root_page do - Comatose::Page.find_by_path(request.parameters[:profile]) - end - config.admin_authorization do |config| - Profile.exists?(:identifier => request.parameters[:profile]) - # FIXME: also check permissions - end - - config.default_filter = '[No Filter]' -end -#Comatose::AdminController.design :holder => 'environment' -Comatose::AdminController.before_filter do |controller| - # TODO: copy/paste; extract this into a method (see - # app/controllers/application.rb) - domain = Domain.find_by_name(controller.request.host) - if domain.nil? - environment = Environment.default - else - environment = domain.environment - profile = domain.profile - end - controller.instance_variable_set('@environment', environment) -end - # string transliteration require 'noosfero/transliterations' diff --git a/db/migrate/007_add_comatose_support.rb b/db/migrate/007_add_comatose_support.rb deleted file mode 100644 index 2a39602..0000000 --- a/db/migrate/007_add_comatose_support.rb +++ /dev/null @@ -1,40 +0,0 @@ -module Comatose - class Page < ActiveRecord::Base - set_table_name 'comatose_pages' - acts_as_versioned :if_changed => [:title, :slug, :keywords, :body] - end -end - -class AddComatoseSupport < ActiveRecord::Migration - - # Schema for Comatose version 0.7+ - def self.up - create_table :comatose_pages do |t| - t.column "parent_id", :integer - t.column "full_path", :text, :default => '' - t.column "title", :string, :limit => 255 - t.column "slug", :string, :limit => 255 - t.column "keywords", :string, :limit => 255 - t.column "body", :text - t.column "filter_type", :string, :limit => 25, :default => "[No Filter]" - t.column "author", :string, :limit => 255 - t.column "position", :integer, :default => 0 - t.column "version", :integer - t.column "updated_on", :datetime - t.column "created_on", :datetime - - # added for STI in noosfero - t.column 'type', :string - - end - Comatose::Page.create_versioned_table - puts "Creating the default 'Home Page'..." - Comatose::Page.create!( :title=>'Home Page', :body=>"h1. Welcome\n\nYour content goes here...", :author=>'System' ) - end - - def self.down - Comatose::Page.drop_versioned_table - drop_table :comatose_pages - end - -end diff --git a/test/functional/content_viewer_controller_test.rb b/test/functional/content_viewer_controller_test.rb index c8e6157..67131cb 100644 --- a/test/functional/content_viewer_controller_test.rb +++ b/test/functional/content_viewer_controller_test.rb @@ -6,8 +6,8 @@ class ContentViewerController; def rescue_action(e) raise e end; end class ContentViewerControllerTest < Test::Unit::TestCase -# all_fixtures:domains, :environments, :users, :profiles, :comatose_pages -all_fixtures + all_fixtures + def setup @controller = ContentViewerController.new @request = ActionController::TestRequest.new diff --git a/test/integration/editing_person_info_test.rb b/test/integration/editing_person_info_test.rb index 9acab18..c2f2c4e 100644 --- a/test/integration/editing_person_info_test.rb +++ b/test/integration/editing_person_info_test.rb @@ -2,7 +2,7 @@ require "#{File.dirname(__FILE__)}/../test_helper" class EditingPersonInfoTest < ActionController::IntegrationTest - fixtures :users, :profiles, :comatose_pages, :domains, :environments, :person_infos + fixtures :users, :profiles, :domains, :environments, :person_infos should 'allow to edit person info' do diff --git a/test/integration/manage_documents_test.rb b/test/integration/manage_documents_test.rb index 303156b..e79cb4d 100644 --- a/test/integration/manage_documents_test.rb +++ b/test/integration/manage_documents_test.rb @@ -5,69 +5,18 @@ class ManageDocumentsTest < ActionController::IntegrationTest all_fixtures def test_creation_of_a_new_article - count = Article.count - - login('ze', 'test') - - assert_tag :tag => 'a', :attributes => { :href => '/myprofile/ze/cms' } - - get '/myprofile/ze/cms' - assert_response :success - - assert_tag :tag => 'a', :attributes => { :href => '/myprofile/ze/cms/new' } - get '/myprofile/ze/cms/new' - assert_response :success - assert_tag :tag => 'form', :attributes => { :action => '/myprofile/ze/cms/new' } - - post '/myprofile/ze/cms/new', :page => { :title => 'my new article', :body => 'this is the text of my new article' , :parent_id => Article.find_by_path('ze').id } - assert_response :redirect - - follow_redirect! - assert_response :success - assert_equal '/myprofile/ze/cms', path - - assert_equal count + 1, Article.count - + # FIXME + fail 'need to be rewritten' end def test_update_of_an_existing_article - login('ze', 'test') - - get '/myprofile/ze/cms' - assert_response :success - - id = Comatose::Page.find_by_path('ze').id - get "myprofile/ze/cms/edit/#{id}" - assert_response :success - assert_tag :tag => 'form', :attributes => { :action => "/myprofile/ze/cms/edit/#{id}" } - - post "myprofile/ze/cms/edit/#{id}", :page => { :body => 'changed_body' } - assert_response :redirect - follow_redirect! - assert_equal '/myprofile/ze/cms', path - + # FIXME + fail 'need to be rewritten' end def test_removing_an_article - - login('ze', 'test') - - article = Article.create!(:title => 'to be removed', :body => 'go to hell', :parent_id => Article.find_by_path('ze').id) - - get '/myprofile/ze/cms' - assert_response :success - assert_tag :tag => 'a', :attributes => { :href => "/myprofile/ze/cms/delete/#{article.id}" } - - post "/myprofile/ze/cms/delete/#{article.id}" - assert_response :redirect - follow_redirect! - assert_equal '/myprofile/ze/cms', path - - assert_raise ActiveRecord::RecordNotFound do - Article.find(article.id) - end + # FIXME + fail 'need to be rewritten' end - # FIXME: add tests for page reordering - end diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb index 36bd66e..6ebd8fe 100644 --- a/test/integration/routing_test.rb +++ b/test/integration/routing_test.rb @@ -30,7 +30,7 @@ class RoutingTest < ActionController::IntegrationTest assert_routing('/account/new_password/90dfhga7sadgd0as6saas', :controller => 'account', :action => 'new_password', :code => '90dfhga7sadgd0as6saas') end - def test_comatose_admin + def test_cms assert_routing('/myprofile/ze/cms', :profile => 'ze', :controller => 'cms', :action => 'index') end diff --git a/test/mocks/test/comatose_admin_controller.rb b/test/mocks/test/comatose_admin_controller.rb deleted file mode 100644 index bbee843..0000000 --- a/test/mocks/test/comatose_admin_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class ComatoseAdminController < ActionController::Base -end diff --git a/test/unit/article_test.rb b/test/unit/article_test.rb index c8d1c66..869b1c7 100644 --- a/test/unit/article_test.rb +++ b/test/unit/article_test.rb @@ -1,7 +1,6 @@ require File.dirname(__FILE__) + '/../test_helper' class ArticleTest < Test::Unit::TestCase - fixtures :comatose_pages def test_should_use_keywords_as_tags article = Article.new @@ -17,8 +16,8 @@ class ArticleTest < Test::Unit::TestCase end should 'have an associated profile' do + # FIXME this is now wrong article = Article.new(:title => 'someuser', :body => "some text") - article.parent = Comatose::Page.root article.save! Profile.expects(:find_by_identifier).with("someuser") diff --git a/test/unit/enterprise_test.rb b/test/unit/enterprise_test.rb index 3ec4d52..9bb3cfb 100644 --- a/test/unit/enterprise_test.rb +++ b/test/unit/enterprise_test.rb @@ -1,7 +1,7 @@ require File.dirname(__FILE__) + '/../test_helper' class EnterpriseTest < Test::Unit::TestCase - fixtures :profiles, :environments, :users, :comatose_pages + fixtures :profiles, :environments, :users def test_identifier_validation p = Enterprise.new diff --git a/test/unit/person_test.rb b/test/unit/person_test.rb index a32632d..12b0b7d 100644 --- a/test/unit/person_test.rb +++ b/test/unit/person_test.rb @@ -1,7 +1,7 @@ require File.dirname(__FILE__) + '/../test_helper' class PersonTest < Test::Unit::TestCase - fixtures :profiles, :users, :comatose_pages + fixtures :profiles, :users def test_person_must_come_form_the_cration_of_an_user p = Person.new(:name => 'John', :identifier => 'john') diff --git a/test/unit/profile_test.rb b/test/unit/profile_test.rb index c5544cf..88c06fe 100644 --- a/test/unit/profile_test.rb +++ b/test/unit/profile_test.rb @@ -1,7 +1,7 @@ require File.dirname(__FILE__) + '/../test_helper' class ProfileTest < Test::Unit::TestCase - fixtures :profiles, :environments, :users, :comatose_pages + fixtures :profiles, :environments, :users def test_identifier_validation p = Profile.new @@ -45,15 +45,7 @@ class ProfileTest < Test::Unit::TestCase p.identifier = 'other_profile' end end - - # when a profile called a page named after it must also be created. - def test_should_create_homepage_when_creating_profile - Profile.create!(:identifier => 'newprofile', :name => 'New Profile') - page = Comatose::Page.find_by_path('newprofile') - assert_not_nil page - assert_equal 'New Profile', page.title - end - + def test_should_provide_access_to_homepage profile = Profile.create!(:identifier => 'newprofile', :name => 'New Profile') page = profile.homepage @@ -97,10 +89,7 @@ class ProfileTest < Test::Unit::TestCase end def test_should_remove_pages_when_removing_profile - profile = Profile.create(:name => 'To bee removed', :identifier => 'to_be_removed') - assert Comatose::Page.find_by_path('to_be_removed') - profile.destroy - assert !Comatose::Page.find_by_path('to_be_removed') + fail 'neet to be reimplemented' end def test_should_define_info diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index 954d98b..fc2f184 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -4,7 +4,7 @@ class UserTest < Test::Unit::TestCase # Be sure to include AuthenticatedTestHelper in test/test_helper.rb instead. # Then, you can remove it from this and the functional test. include AuthenticatedTestHelper - fixtures :users, :comatose_pages + fixtures :users def test_should_create_user assert_difference User, :count do -- libgit2 0.21.2