diff --git a/README b/README
index 4330c16..b2f666b 100644
--- a/README
+++ b/README
@@ -7,3 +7,19 @@ out of the box than any other Rails CMS we’re aware of.
By combing the CMSes of Isshen Solutions and Isotope 11, we plan to create
a best-of-breed technology suitable for production use on a myriad of sites.
Ansuz will be licensed initially via GPLv2.
+
+== Quick Start
+
+ 1. clone from github: git clone git://github.com/knewter/ansuz.git
+ 2. create database config in config/database.yml (see config/database.yml.example if you need help)
+ 3. create databases: rake db:create:all
+ 4. run migrations: rake db:migrate
+ 5. run tests: rake spec
+ 6. start console: script/console
+ 7. create a new user: u = User.new :login => ‘admin’, :email => ‘admin@example.com’, :password => ‘admin’, :password_confirmation => ‘admin’
+ 8. save the user: u.save
+ 9. check the user exists: User.last
+10. exist console: exit
+11. start server: script/server -p 3000
+12. goto: http://localhost:3000/admin
+13. login with admin/admin
diff --git a/app/controllers/content_sections_controller.rb b/app/controllers/content_sections_controller.rb
new file mode 100644
index 0000000..53f602b
--- /dev/null
+++ b/app/controllers/content_sections_controller.rb
@@ -0,0 +1,23 @@
+class ContentSectionsController < ApplicationController
+ before_filter :load_content_section, :only => [:show, :edit, :update, :destroy]
+ protected
+ def load_content_section
+ @content_section = Ansuz::JAdams::ContentSection.find(params[:id])
+ end
+ public
+ def show
+ end
+
+ def edit
+ end
+
+ def update
+ if @content_section.update_attributes(params[:content_section])
+ flash[:notice] = "Content Section has been updated."
+ redirect_to content_section_path(@content_section)
+ else
+ flash.now[:error] = "There was a problem updating the ContentSection. Please try again."
+ render :action => 'edit'
+ end
+ end
+end
diff --git a/app/controllers/page_plugins_controller.rb b/app/controllers/page_plugins_controller.rb
new file mode 100644
index 0000000..d815914
--- /dev/null
+++ b/app/controllers/page_plugins_controller.rb
@@ -0,0 +1,37 @@
+class PagePluginsController < ApplicationController
+ before_filter :load_page, :only => [:new, :create]
+ before_filter :load_new_page_plugin, :only => [:new, :create]
+ before_filter :load_page_plugin, :only => [:edit]
+
+ protected
+ def load_page
+ @page = Page.find(params[:page_id])
+ end
+
+ def load_new_page_plugin
+ @page_plugin = PagePlugin.new(params[:page_plugin])
+ @page_plugin.page = @page
+ end
+
+ def load_page_plugin
+ @page_plugin = PagePlugin.find(params[:id])
+ end
+
+ public
+ def new
+ end
+
+ def edit
+ redirect_to @page_plugin.module.edit_path
+ end
+
+ def create
+ if @page_plugin.save
+ flash[:notice] = "Successfully saved the Page Plugin"
+ redirect_to '/admin'
+ else
+ flash.now[:error] = "There was a problem saving the Page Plugin"
+ render :action => 'new'
+ end
+ end
+end
diff --git a/app/controllers/plugins_controller.rb b/app/controllers/plugins_controller.rb
new file mode 100644
index 0000000..41c49eb
--- /dev/null
+++ b/app/controllers/plugins_controller.rb
@@ -0,0 +1,5 @@
+class PluginsController < ApplicationController
+ def index
+ end
+
+end
diff --git a/app/helpers/page_plugins_helper.rb b/app/helpers/page_plugins_helper.rb
new file mode 100644
index 0000000..a80579b
--- /dev/null
+++ b/app/helpers/page_plugins_helper.rb
@@ -0,0 +1,2 @@
+module PagePluginsHelper
+end
diff --git a/app/helpers/plugins_helper.rb b/app/helpers/plugins_helper.rb
new file mode 100644
index 0000000..75f3122
--- /dev/null
+++ b/app/helpers/plugins_helper.rb
@@ -0,0 +1,2 @@
+module PluginsHelper
+end
diff --git a/app/models/page.rb b/app/models/page.rb
index 6f0fb27..4d4b8a6 100644
--- a/app/models/page.rb
+++ b/app/models/page.rb
@@ -20,9 +20,10 @@
#
class Page < ActiveRecord::Base
- acts_as_tree :order => 'page_order'
- before_save :check_page_type, :check_page_order
+ acts_as_tree :order => 'page_order'
+ before_save :check_page_type, :check_page_order
attr_protected :page_number, :pages
+ has_many :page_plugins
def full_title
full_title = read_attribute('full_title')
diff --git a/app/models/page_plugin.rb b/app/models/page_plugin.rb
new file mode 100644
index 0000000..85719d6
--- /dev/null
+++ b/app/models/page_plugin.rb
@@ -0,0 +1,24 @@
+class PagePlugin < ActiveRecord::Base
+ belongs_to :page
+ after_create :create_module
+
+ def module
+ if module_type and module_id
+ module_class.find(module_id)
+ end
+ end
+
+ def module_class
+ module_type.constantize
+ end
+
+ def module_default_name
+ "Module for Page Plugin ##{self.id}"
+ end
+
+ def create_module
+ the_module = module_class.find_or_create_by_name(module_default_name)
+ self.module_id = the_module.id
+ self.save
+ end
+end
diff --git a/app/views/content/page.html.erb b/app/views/content/page.html.erb
index d91e156..e136b3c 100644
--- a/app/views/content/page.html.erb
+++ b/app/views/content/page.html.erb
@@ -1,4 +1,8 @@
<% if @page.display_title %>
<%= @page.full_title %>
<% end %>
-<%= @page.page_body %>
\ No newline at end of file
+<% if @page.page_plugins.any? -%>
+ <% @page.page_plugins.each do |plugin| -%>
+ <%= render :partial => plugin.module_class.view_partial, :locals => { :plugin_module => plugin.module } -%>
+ <% end -%>
+<% end -%>
diff --git a/app/views/content_sections/_content_section.html.erb b/app/views/content_sections/_content_section.html.erb
new file mode 100644
index 0000000..87d2c62
--- /dev/null
+++ b/app/views/content_sections/_content_section.html.erb
@@ -0,0 +1 @@
+<%= plugin_module.contents -%>
diff --git a/app/views/content_sections/_edit.html.erb b/app/views/content_sections/_edit.html.erb
new file mode 100644
index 0000000..8e893a6
--- /dev/null
+++ b/app/views/content_sections/_edit.html.erb
@@ -0,0 +1 @@
+This is the edit view
diff --git a/app/views/content_sections/edit.html.erb b/app/views/content_sections/edit.html.erb
new file mode 100644
index 0000000..6ee8979
--- /dev/null
+++ b/app/views/content_sections/edit.html.erb
@@ -0,0 +1,6 @@
+Editing Content Section
+<% form_for :content_section, :url => content_section_path(@content_section), :html => { :method => :put } do |f| -%>
+ <%= f.text_field(:name) -%>
+ <%= f.text_area(:contents) -%>
+ <%= submit_tag("Update Content Section") -%>
+<% end -%>
diff --git a/app/views/menu/_main.html.erb b/app/views/menu/_main.html.erb
index 7c43ee4..eac7449 100644
--- a/app/views/menu/_main.html.erb
+++ b/app/views/menu/_main.html.erb
@@ -3,8 +3,9 @@
Admin
<%= link_to_remote "Manage Pages", :update => "sitetree", :url => { :controller => 'page_admin', :action => "manage_tree" } %>
+ <%= link_to_remote 'List Plugins', :update => 'main', :url => { :controller => 'plugins', :action => 'index' } %>
<%= link_to_remote 'Account Settings', :update => 'main', :url => { :controller => 'account', :action => 'update' } %>
<%= link_to "Logout", :controller => 'account', :action => 'logout' %>
-<% end %>
\ No newline at end of file
+<% end %>
diff --git a/app/views/page_admin/_form.html.erb b/app/views/page_admin/_form.html.erb
index 9c67a0d..65bab73 100644
--- a/app/views/page_admin/_form.html.erb
+++ b/app/views/page_admin/_form.html.erb
@@ -20,7 +20,5 @@
Linked
<%= options_for_select [true, false], @page.linked %>
- Body:
- <%= text_area 'page', 'body', "cols" => 80, "rows" => 20 %>
-
\ No newline at end of file
+
diff --git a/app/views/page_admin/edit.html.erb b/app/views/page_admin/edit.html.erb
index 25d1726..191bdd2 100644
--- a/app/views/page_admin/edit.html.erb
+++ b/app/views/page_admin/edit.html.erb
@@ -8,4 +8,12 @@
:html => { 'name' => 'page_form' } do -%>
<%= render :partial => 'form' %>
<%= submit_tag 'Update', :class => 'submit' -%>
-<% end -%>
\ No newline at end of file
+<% end -%>
+
+Plugins on this page
+
+ <% @page.page_plugins.each do |plugin| -%>
+ <%= link_to(plugin.module_type, edit_page_plugin_path(plugin.id)) -%>
+ <% end -%>
+
+<%= link_to "Add Plugin", new_page_plugin_path(:page_id => @page.id) -%>
diff --git a/app/views/page_plugins/create.html.erb b/app/views/page_plugins/create.html.erb
new file mode 100644
index 0000000..f4c6b2c
--- /dev/null
+++ b/app/views/page_plugins/create.html.erb
@@ -0,0 +1,2 @@
+PagePlugins#create
+Find me in app/views/page_plugins/create.html.erb
diff --git a/app/views/page_plugins/edit.html.erb b/app/views/page_plugins/edit.html.erb
new file mode 100644
index 0000000..e33be01
--- /dev/null
+++ b/app/views/page_plugins/edit.html.erb
@@ -0,0 +1,2 @@
+Edit
+<%= render :partial => @page_plugin.module_class.edit_template -%>
diff --git a/app/views/page_plugins/new.html.erb b/app/views/page_plugins/new.html.erb
new file mode 100644
index 0000000..24487ee
--- /dev/null
+++ b/app/views/page_plugins/new.html.erb
@@ -0,0 +1,6 @@
+New PagePlugin
+<% form_for @page_plugin do |f| -%>
+ <%= hidden_field_tag(:page_id, params[:page_id]) -%>
+ <%= f.select(:module_type, Ansuz::PluginManagerInstance.plugins.map(&:to_s)) -%>
+ <%= submit_tag("Add Plugin") -%>
+<% end -%>
diff --git a/app/views/plugins/index.html.erb b/app/views/plugins/index.html.erb
new file mode 100644
index 0000000..2b52777
--- /dev/null
+++ b/app/views/plugins/index.html.erb
@@ -0,0 +1,6 @@
+Installed Plugins
+
+ <% Ansuz::PluginManagerInstance.plugins.each do |plugin| -%>
+ <%= plugin.to_s -%>
+ <% end -%>
+
diff --git a/config/environment.rb b/config/environment.rb
index f814c37..6428d8e 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -10,6 +10,10 @@
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
+require 'ansuz'
+# Initialize the Ansuz Plugin Manager instance
+Ansuz::PluginManagerInstance = Ansuz::PluginManager.new
+
Rails::Initializer.run do |config|
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
diff --git a/config/routes.rb b/config/routes.rb
index fa8ffaf..5700b86 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,4 +1,6 @@
ActionController::Routing::Routes.draw do |map|
+ map.resources :page_plugins
+ map.resources :content_sections
# The priority is based upon order of creation: first created -> highest priority.
# Sample of regular route:
@@ -39,8 +41,9 @@
# map.resource :admin, :controller => 'admin_pages'
map.connect 'admin/account/:action/:id', :controller => 'account'
map.connect 'admin/:action/:id', :controller => 'page_admin'
- map.connect '*path', :controller => 'page', :action => 'indexer'
# stock rails routes
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
+ # Ansuz route
+ map.connect '*path', :controller => 'page', :action => 'indexer'
end
diff --git a/db/migrate/20080824195700_create_page_plugins.rb b/db/migrate/20080824195700_create_page_plugins.rb
new file mode 100644
index 0000000..4795b9e
--- /dev/null
+++ b/db/migrate/20080824195700_create_page_plugins.rb
@@ -0,0 +1,15 @@
+class CreatePagePlugins < ActiveRecord::Migration
+ def self.up
+ create_table :page_plugins do |t|
+ t.integer :page_id
+ t.string :module_type
+ t.integer :module_id
+
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :page_plugins
+ end
+end
diff --git a/db/migrate/20080824204532_add_content_sections.rb b/db/migrate/20080824204532_add_content_sections.rb
new file mode 100644
index 0000000..24cf489
--- /dev/null
+++ b/db/migrate/20080824204532_add_content_sections.rb
@@ -0,0 +1,13 @@
+class AddContentSections < ActiveRecord::Migration
+ def self.up
+ create_table :content_sections do |t|
+ t.string :name
+ t.text :contents
+
+ t.timestamps
+ end
+ end
+
+ def self.down
+ end
+end
diff --git a/lib/ansuz.rb b/lib/ansuz.rb
new file mode 100644
index 0000000..d84972b
--- /dev/null
+++ b/lib/ansuz.rb
@@ -0,0 +1 @@
+require 'ansuz/plugin_manager'
diff --git a/lib/ansuz/plugin_manager.rb b/lib/ansuz/plugin_manager.rb
new file mode 100644
index 0000000..f77e5b4
--- /dev/null
+++ b/lib/ansuz/plugin_manager.rb
@@ -0,0 +1,14 @@
+class Ansuz
+ class PluginManager
+ attr_accessor :plugins
+
+ def initialize
+ @plugins = []
+ end
+
+ # A plugin can call register_plugin(ClassName) to add itself to the plugins array
+ def register_plugin klass
+ self.plugins << klass
+ end
+ end
+end
diff --git a/lib/ansuz_plugin.rb b/lib/ansuz_plugin.rb
new file mode 100644
index 0000000..9087af0
--- /dev/null
+++ b/lib/ansuz_plugin.rb
@@ -0,0 +1,2 @@
+class AnsuzPlugin
+end
diff --git a/test/fixtures/page_plugins.yml b/test/fixtures/page_plugins.yml
new file mode 100644
index 0000000..032099c
--- /dev/null
+++ b/test/fixtures/page_plugins.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+
+one:
+ page_id: 1
+ module_type: MyString
+ module_id:
+
+two:
+ page_id: 1
+ module_type: MyString
+ module_id:
diff --git a/test/functional/page_plugins_controller_test.rb b/test/functional/page_plugins_controller_test.rb
new file mode 100644
index 0000000..f9b9112
--- /dev/null
+++ b/test/functional/page_plugins_controller_test.rb
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class PagePluginsControllerTest < ActionController::TestCase
+ # Replace this with your real tests.
+ def test_truth
+ assert true
+ end
+end
diff --git a/test/functional/plugins_controller_test.rb b/test/functional/plugins_controller_test.rb
new file mode 100644
index 0000000..b6db0c1
--- /dev/null
+++ b/test/functional/plugins_controller_test.rb
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class PluginsControllerTest < ActionController::TestCase
+ # Replace this with your real tests.
+ def test_truth
+ assert true
+ end
+end
diff --git a/test/unit/page_plugin_test.rb b/test/unit/page_plugin_test.rb
new file mode 100644
index 0000000..823b6c6
--- /dev/null
+++ b/test/unit/page_plugin_test.rb
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class PagePluginTest < ActiveSupport::TestCase
+ # Replace this with your real tests.
+ def test_truth
+ assert true
+ end
+end
diff --git a/vendor/plugins/ansuz_content_section/MIT-LICENSE b/vendor/plugins/ansuz_content_section/MIT-LICENSE
new file mode 100644
index 0000000..8eaf6db
--- /dev/null
+++ b/vendor/plugins/ansuz_content_section/MIT-LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2008 [name of plugin creator]
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/plugins/ansuz_content_section/README b/vendor/plugins/ansuz_content_section/README
new file mode 100644
index 0000000..43c08aa
--- /dev/null
+++ b/vendor/plugins/ansuz_content_section/README
@@ -0,0 +1,13 @@
+AnsuzContentSection
+===================
+
+Introduction goes here.
+
+
+Example
+=======
+
+Example goes here.
+
+
+Copyright (c) 2008 [name of plugin creator], released under the MIT license
diff --git a/vendor/plugins/ansuz_content_section/Rakefile b/vendor/plugins/ansuz_content_section/Rakefile
new file mode 100644
index 0000000..5e0d3e4
--- /dev/null
+++ b/vendor/plugins/ansuz_content_section/Rakefile
@@ -0,0 +1,22 @@
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+desc 'Default: run unit tests.'
+task :default => :test
+
+desc 'Test the ansuz_content_section plugin.'
+Rake::TestTask.new(:test) do |t|
+ t.libs << 'lib'
+ t.pattern = 'test/**/*_test.rb'
+ t.verbose = true
+end
+
+desc 'Generate documentation for the ansuz_content_section plugin.'
+Rake::RDocTask.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = 'AnsuzContentSection'
+ rdoc.options << '--line-numbers' << '--inline-source'
+ rdoc.rdoc_files.include('README')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
diff --git a/vendor/plugins/ansuz_content_section/init.rb b/vendor/plugins/ansuz_content_section/init.rb
new file mode 100644
index 0000000..218b147
--- /dev/null
+++ b/vendor/plugins/ansuz_content_section/init.rb
@@ -0,0 +1,3 @@
+# Include hook code here
+require 'content_section'
+Ansuz::PluginManagerInstance.register_plugin(Ansuz::JAdams::ContentSection)
diff --git a/vendor/plugins/ansuz_content_section/install.rb b/vendor/plugins/ansuz_content_section/install.rb
new file mode 100644
index 0000000..f7732d3
--- /dev/null
+++ b/vendor/plugins/ansuz_content_section/install.rb
@@ -0,0 +1 @@
+# Install hook code here
diff --git a/vendor/plugins/ansuz_content_section/lib/content_section.rb b/vendor/plugins/ansuz_content_section/lib/content_section.rb
new file mode 100644
index 0000000..96613f1
--- /dev/null
+++ b/vendor/plugins/ansuz_content_section/lib/content_section.rb
@@ -0,0 +1,13 @@
+class Ansuz
+ class JAdams
+ class ContentSection < ActiveRecord::Base
+ def edit_path
+ "/content_sections/#{id}/edit"
+ end
+
+ def self.view_partial
+ "/content_sections/content_section"
+ end
+ end
+ end
+end
diff --git a/vendor/plugins/ansuz_content_section/tasks/ansuz_content_section_tasks.rake b/vendor/plugins/ansuz_content_section/tasks/ansuz_content_section_tasks.rake
new file mode 100644
index 0000000..a61e7b6
--- /dev/null
+++ b/vendor/plugins/ansuz_content_section/tasks/ansuz_content_section_tasks.rake
@@ -0,0 +1,4 @@
+# desc "Explaining what the task does"
+# task :ansuz_content_section do
+# # Task goes here
+# end
diff --git a/vendor/plugins/ansuz_content_section/test/ansuz_content_section_test.rb b/vendor/plugins/ansuz_content_section/test/ansuz_content_section_test.rb
new file mode 100644
index 0000000..d3fb99a
--- /dev/null
+++ b/vendor/plugins/ansuz_content_section/test/ansuz_content_section_test.rb
@@ -0,0 +1,8 @@
+require 'test/unit'
+
+class AnsuzContentSectionTest < Test::Unit::TestCase
+ # Replace this with your real tests.
+ def test_this_plugin
+ flunk
+ end
+end
diff --git a/vendor/plugins/ansuz_content_section/uninstall.rb b/vendor/plugins/ansuz_content_section/uninstall.rb
new file mode 100644
index 0000000..9738333
--- /dev/null
+++ b/vendor/plugins/ansuz_content_section/uninstall.rb
@@ -0,0 +1 @@
+# Uninstall hook code here