diff --git a/app/views/content_viewer/view_page.rhtml b/app/views/content_viewer/view_page.rhtml index 993f6a4..d37ca39 100644 --- a/app/views/content_viewer/view_page.rhtml +++ b/app/views/content_viewer/view_page.rhtml @@ -1 +1,3 @@ +

<%= @page.title %>

+ <%= @page.to_html %> diff --git a/config/environment.rb b/config/environment.rb index ee863dc..95a8046 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -54,3 +54,13 @@ end require 'gettext/rails' 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 +end diff --git a/config/routes.rb b/config/routes.rb index e1c489c..d4e59de 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -13,22 +13,25 @@ ActionController::Routing::Routes.draw do |map| # -- just remember to delete public/index.html. map.connect '', :controller => "home" + # documentation browser + map.connect 'doc', :controller => 'doc' + # user account controller map.connect 'account/:action', :controller => 'account' - map.connect 'doc', :controller => 'doc' + + # TODO: profile customization for profiles + # map.connect 'customize/:profile/:controller/:action/:id' + + # content administration + map.comatose_admin 'cms/:profile' # administrative tasks for a virtual community map.connect 'admin/:controller/:action/:id' - # profile customization for profiles - map.connect 'customize/:profile/:controller/:action/:id' - - # content viewwing: + # content viewing: map.connect ':profile/*page', :controller => 'content_viewer', :action => 'view_page' - # Install the default route as the lowest priority. - map.connect ':controller/:action/:id' - - # TODO: comatose here + # no default route + # map.connect ':controller/:action/:id' end diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb index c9f8e14..2481f3e 100644 --- a/test/integration/routing_test.rb +++ b/test/integration/routing_test.rb @@ -2,19 +2,36 @@ require "#{File.dirname(__FILE__)}/../test_helper" class RoutingTest < ActionController::IntegrationTest - def test_features_controller - assert_routing('/admin/features', :controller => 'features', :action => 'index') + def test_homepage + assert_routing('/', :controller => 'home', :action => 'index') + end + + def test_doc_controller + #FIXME: assert_routing cannot find controllers in plugins' + flunk 'FIXME: assert_routing cannot find controllers in plugins' + assert_routing('/doc', :controller => 'doc', :action => 'index') end def test_account_controller assert_routing('/account', :controller => 'account', :action => 'index') end - def test_content_viewer_controller_for_profile_root - assert_routing('/ze', :controller => 'content_viewer', :action => 'view_page', :profile => 'ze', :page => []) + def test_comatose_admin + #FIXME: assert_routing cannot find controllers in plugins' + flunk 'FIXME: assert_routing cannot find controllers in plugins' + assert_routing('/cms/ze', :controller => 'comatose_admin') + end + + def test_features_controller + assert_routing('/admin/features', :controller => 'features', :action => 'index') end - def test_content_viewer_controller_for_page_inside_profile + def test_content_viewer + + # profile root: + assert_routing('/ze', :controller => 'content_viewer', :action => 'view_page', :profile => 'ze', :page => []) + + # some non-root page assert_routing('/ze/work/2007', :controller => 'content_viewer', :action => 'view_page', :profile => 'ze', :page => ['work', "2007"]) end -- libgit2 0.21.2