diff --git a/app/controllers/admin/homes_controller.rb b/app/controllers/admin/homes_controller.rb
deleted file mode 100644
index fdfc855f..00000000
--- a/app/controllers/admin/homes_controller.rb
+++ /dev/null
@@ -1,50 +0,0 @@
-class Admin::HomesController < ApplicationController
-
- layout "admin"
- before_filter :authenticate_user!
- before_filter :is_admin?
-
- def show
- #TODO
- end
-
- def new
- @home = Home.new
- @home.is_published = true
- @home.parent_id = nil
- end
-
- def edit
- @home = Home.find(params[:id])
- @i18n_variable = @home.i18n_variable
- end
-
- def create
- @home = Home.new(params[:home])
-
- if @home.save
- flash[:notice] = t('admin.create_success_home')
- redirect_to admin_items_url
- else
- render :action => "new"
- end
- end
-
- def update
- @home = Home.find(params[:id])
- if @home.update_attributes(params[:home])
- flash[:notice] = t('admin.update_success_home')
- redirect_to admin_items_url
- else
- render :action => "edit"
- end
- end
-
- def destroy
- @home = Home.find(params[:id])
- @home.destroy
-
- redirect_to admin_items_url
- end
-
-end
diff --git a/app/controllers/admin/items_controller.rb b/app/controllers/admin/items_controller.rb
index 65980b53..eb780d73 100644
--- a/app/controllers/admin/items_controller.rb
+++ b/app/controllers/admin/items_controller.rb
@@ -1,6 +1,6 @@
class Admin::ItemsController < ApplicationController
- layout "admin"
+ layout "content"
before_filter :authenticate_user!
before_filter :find_parent_item
@@ -8,8 +8,11 @@ class Admin::ItemsController < ApplicationController
before_filter :is_admin?
def index
- @items = Item.where(:parent_id => @parent_item.id).entries rescue []
- @items = Item.where(:_type => 'Home').entries unless (!@items.empty? || @parent_item)
+ if params[:item_id]
+ @page = Item.find(params[:item_id])
+ else
+ @page = Item.first(:conditions => {:parent_id => nil})
+ end
end
diff --git a/app/controllers/admin/pages_controller.rb b/app/controllers/admin/pages_controller.rb
index 5fa4cc66..1373ea4a 100644
--- a/app/controllers/admin/pages_controller.rb
+++ b/app/controllers/admin/pages_controller.rb
@@ -1,6 +1,6 @@
class Admin::PagesController < ApplicationController
- layout "admin"
+ layout "content"
before_filter :authenticate_user!
before_filter :find_parent_item
before_filter :is_admin?
diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb
index 19c69d38..9c093571 100644
--- a/app/controllers/pages_controller.rb
+++ b/app/controllers/pages_controller.rb
@@ -1,7 +1,7 @@
class PagesController < ApplicationController
def index
- @page = Home.find_by_name('home')
+ @page = Page.find_by_name('home')
if @page
render_page
else
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 49d10822..f6c77ceb 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -48,5 +48,26 @@ module ApplicationHelper
message % item
end
end
+
+ def render_node_and_children(node, current_name = 'home')
+ ret = ''
+ if node
+ ret << "
"
+ ret << (link_to node.name, admin_items_path(:item_id => node.id), :remote => true, :class => (current_name.eql?(node.name) ? 'sidebar_no_link' : 'sidebar_link'))
+ ret << render_children(node) if node.children.size > 0
+ ret << ""
+ end
+ ret.html_safe
+ end
+
+ def render_children(parent)
+ ret = ''
+ ret << ""
+ parent.children.each do |child|
+ ret << render_node_and_children(child)
+ end
+ ret << "
"
+ ret
+ end
end
diff --git a/app/models/component.rb b/app/models/component.rb
new file mode 100644
index 00000000..82327815
--- /dev/null
+++ b/app/models/component.rb
@@ -0,0 +1,10 @@
+class Component
+
+ include Mongoid::Document
+ include Mongoid::Timestamps
+
+ field :key
+ field :document_class, :type => String
+ field :parent_id, :type => BSON::ObjectId, :index => true
+
+end
\ No newline at end of file
diff --git a/app/models/home.rb b/app/models/home.rb
deleted file mode 100644
index 92a96118..00000000
--- a/app/models/home.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-class Home < Page
-
- private
-
- # Remove the validation for parent_id
- def validates_presence_of_parent_id?
- false
- end
-
-end
diff --git a/app/models/item.rb b/app/models/item.rb
index a3fa8b9c..c9218454 100644
--- a/app/models/item.rb
+++ b/app/models/item.rb
@@ -15,10 +15,9 @@ class Item
validates :name, :exclusion => { :in => LIST[:forbidden_item_names] }
validates_uniqueness_of :name, :scope => :parent_id
validates_presence_of :name, :full_name, :position, :is_published
- validates_presence_of :parent_id, :if => :validates_presence_of_parent_id?
- referenced_in :parent, :class_name => "Item"
- references_many :children, :class_name => "Item"
+ belongs_to :parent, :class_name => "Item"
+ has_many :children, :class_name => "Item", :as => 'parent'
before_validation :setup_default_value
@@ -59,11 +58,6 @@ class Item
@i18n_variable ||= I18nVariable.find(self.i18n_variable_id) rescue nil
end
- # Check if the page is home
- def is_home?
- self.name.eql?('home') && (self.parent_id.nil? || self.parent_id.empty?)
- end
-
# Build the url from the array of ancestors
def url
urls = ancestors.map{ |a| a.name } << self.name
diff --git a/app/views/admin/homes/_form.html.erb b/app/views/admin/homes/_form.html.erb
deleted file mode 100644
index aa0395c6..00000000
--- a/app/views/admin/homes/_form.html.erb
+++ /dev/null
@@ -1,30 +0,0 @@
-<%= f.hidden_field :parent_id %>
-
-
-<%= f.label :name, t('admin.name') %>
-<%= f.text_field :name, :class => 'text', :value => 'home', :disabled => true %>
-<%= f.hidden_field :name, :value => 'home' %>
-
-
-
-<% @site_valid_locales.each do |locale| %>
-
- <%= label_tag "home[title]", "#{t('admin.title')} #{locale}" %>
- <%= text_field_tag "home[i18n_variable][#{locale}]", (@i18n_variable[locale] if @i18n_variable), :class => 'text' %>
-
-<% end %>
-
-
-<%= f.label :layout_id, t('admin.layout_name') %>
-<%= f.select :layout_id, Layout.all.map{ |l| [l.description, l.id] } %>
-
-
-
-<%= f.label "content", t('admin.content') %>
-<%= f.text_area "content", :size => '100x30' %>
-
-
-
-<%= f.label :is_published, "#{t('admin.is_published')} ?" %>
-<%= f.radio_button :is_published, true %>Yes <%= f.radio_button :is_published, false %> No
-
diff --git a/app/views/admin/homes/edit.html.erb b/app/views/admin/homes/edit.html.erb
deleted file mode 100644
index 5d9807f8..00000000
--- a/app/views/admin/homes/edit.html.erb
+++ /dev/null
@@ -1,10 +0,0 @@
-<%= t('admin.editing_home') %>
-
-<%= form_for @home, :url => admin_home_path(@home) do |f| %>
- <%= f.error_messages %>
- <%= render :partial => "form", :locals => { :f => f } %>
-
-
- <%= f.submit t('update') %> <%= link_back %>
-
-<% end %>
diff --git a/app/views/admin/homes/new.html.erb b/app/views/admin/homes/new.html.erb
deleted file mode 100644
index 38f2e842..00000000
--- a/app/views/admin/homes/new.html.erb
+++ /dev/null
@@ -1,11 +0,0 @@
-<%= t('admin.new_home') %>
-
-<%= form_for :home, :url => admin_homes_path do |f| %>
- <%= f.error_messages %>
- <%= render :partial => "form", :locals => { :f => f } %>
-
-
- <%= f.submit t('create') %> <%= link_back %>
-
-
-<% end %>
diff --git a/app/views/admin/items/index.html.erb b/app/views/admin/items/index.html.erb
index 40217fcb..fc47481c 100644
--- a/app/views/admin/items/index.html.erb
+++ b/app/views/admin/items/index.html.erb
@@ -1,27 +1,36 @@
-<% content_for :secondary do %>
-
- <% if (@items.empty? && !@parent_item ) || (!@items.empty? && @items[0].is_home?) %>
- - <%= t('admin.new_page') %>
- - <%= t('admin.new_link') %>
- - <%= t('admin.new_snippet') %>
- <% else %>
- - <%= link_to t('admin.new_page'), new_admin_page_path( :parent_id => @parent_item.id ), :class => 'button positive' %>
- - <%= link_to t('admin.new_link'), new_admin_link_path( :parent_id => @parent_item.id ) %>
-
- <%= link_to t('admin.new_snippet'), new_admin_snippet_path( :parent_id => @parent_item.id ), :class => 'button positive' %>
- <% end %>
-
+<% content_for :sidebar do %>
+
<% end -%>
-<%= flash_messages %>
+<% content_for :page_specific_javascript do %>
+
+<% end -%>
+
+<% content_for :page_specific_css do %>
+
+<% end %>
+
+<%= render 'layouts/page' %>
+
+
diff --git a/app/views/admin/items/index.js.erb b/app/views/admin/items/index.js.erb
new file mode 100644
index 00000000..2338f947
--- /dev/null
+++ b/app/views/admin/items/index.js.erb
@@ -0,0 +1,9 @@
+$('#main').empty();
+switch ("<%= escape_javascript(@page._type)%>") {
+ case 'Link':
+ $('#main').append("TODO: page to edit the link");
+ break;
+ case 'Page':
+ $('#main').append("<%= escape_javascript(render(:partial => 'layouts/page')) %>");
+ break;
+};
\ No newline at end of file
diff --git a/app/views/admin/pages/_form.html.erb b/app/views/admin/pages/_form.html.erb
index a84b872a..f6f8c567 100644
--- a/app/views/admin/pages/_form.html.erb
+++ b/app/views/admin/pages/_form.html.erb
@@ -2,12 +2,7 @@
<%= f.label :name, t('admin.name') %>
-<% if @page.parent_id.nil? %>
- <%= f.text_field :name, :class => 'text', :value => 'home', :disabled => true %>
- <%= f.hidden_field :name, :value => 'home' %>
-<% else %>
- <%= f.text_field :name, :class => 'text' %>
-<% end %>
+<%= f.text_field :name, :class => 'text' %>
diff --git a/app/views/layouts/_page.html.erb b/app/views/layouts/_page.html.erb
new file mode 100644
index 00000000..221e472b
--- /dev/null
+++ b/app/views/layouts/_page.html.erb
@@ -0,0 +1 @@
+<%= parse_page(@page).html_safe if @page._type.eql?('Page') %>
\ No newline at end of file
diff --git a/app/views/layouts/_site_map_left_bar.html.erb b/app/views/layouts/_site_map_left_bar.html.erb
new file mode 100644
index 00000000..c9291de1
--- /dev/null
+++ b/app/views/layouts/_site_map_left_bar.html.erb
@@ -0,0 +1 @@
+<%= render_node_and_children(@page) %>
\ No newline at end of file
diff --git a/app/views/layouts/content.html.erb b/app/views/layouts/content.html.erb
new file mode 100644
index 00000000..b4acc1e5
--- /dev/null
+++ b/app/views/layouts/content.html.erb
@@ -0,0 +1,30 @@
+
+
+
+
+ <%= @title %>
+
+ <%= yield :page_specific_link %>
+ <%= stylesheet_link_tag "easy", "main", "devise", "content", :media => "screen, projection" %>
+ <%= stylesheet_link_tag "easyprint", :media => "print" %>
+ <%= javascript_include_tag "jquery", "jquery-ui", "rails", "easy", "application", :cache => 'all' %>
+ <%= yield :page_specific_javascript %>
+
+ <%= yield :page_specific_css %>
+ <%= csrf_meta_tag %>
+
+
+
+
+
+
+
+
+
diff --git a/config/application.rb b/config/application.rb
index d436dc1f..b2aeefc3 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -24,6 +24,7 @@ module PrototypeR4
# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)
+ config.autoload_paths = %W(#{config.root}/lib)
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
diff --git a/app/models/parser.rb b/lib/parser.rb
similarity index 94%
rename from app/models/parser.rb
rename to lib/parser.rb
index 7171fffd..8ba2d08f 100644
--- a/app/models/parser.rb
+++ b/lib/parser.rb
@@ -82,10 +82,16 @@ module Parser
end
def parse_page(page)
- layout_content = (page.layout)? page.layout.content : ""
+ if page._type == 'Page'
+ layout_content = (page.layout)? page.layout.content : ""
context = parser_context(page.content)
parser = Radius::Parser.new(context, :tag_prefix => 'r')
parser.parse(parser.parse(layout_content))
end
+ end
+
+ def self.included(base)
+ base.send :helper_method, :parse_page if base.respond_to? :helper_method
+ end
end
diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake
index 4d9651a1..c19fef1e 100644
--- a/lib/tasks/dev.rake
+++ b/lib/tasks/dev.rake
@@ -47,7 +47,7 @@ namespace :dev do
layout = Layout.create!( :name => 'root', :description => 'root', :content => File.open("#{RAILS_ROOT}/lib/template/root.layout").read )
- home = Home.create!( :i18n_variable_id => var_10.id, :layout_id => layout.id, :name => 'home', :is_published => true, :content => File.open("#{RAILS_ROOT}/lib/template/root.home").read )
+ home = Page.create!( :i18n_variable_id => var_10.id, :layout_id => layout.id, :name => 'home', :is_published => true, :content => File.open("#{RAILS_ROOT}/lib/template/root.home").read )
Page.create!( :i18n_variable_id => var_11.id, :layout_id => layout.id, :name => 'about', :is_published => true, :parent_id => home.id, :content => File.open("#{RAILS_ROOT}/lib/template/about.page").read )
diff --git a/public/stylesheets/content.css b/public/stylesheets/content.css
new file mode 100644
index 00000000..9c20023e
--- /dev/null
+++ b/public/stylesheets/content.css
@@ -0,0 +1,4 @@
+html{
+ height:100%;
+ width:100%;
+ }
\ No newline at end of file