Removed sites.
Hesham E
committed Aug 20, 2010
commit 2457c12a5a020af9c535e5bdab3a8e3a0aadfa5b
Showing 10
changed files with
13 additions
and 81 deletions
app/controllers/cms_admin/pages_controller.rb
+2
-9
| @@ | @@ -6,12 +6,7 @@ class CmsAdmin::PagesController < CmsAdmin::BaseController |
| before_filter :build_page, :only => [ :new, :create ] | |
| def index | |
| - | if (ComfortableMexicanSofa::Config.multiple_sites) |
| - | @sites = CmsSite.all |
| - | @cms_pages = CmsPage.roots.group_by(&:cms_site_id) |
| - | else |
| - | params[:root] ? @cms_pages = CmsPage.find(params[:root]).children : @cms_pages = CmsPage.roots |
| - | end |
| + | params[:root] ? @cms_pages = CmsPage.find(params[:root]).children : @cms_pages = CmsPage.roots |
| end | |
| def toggle | |
| @@ | @@ -82,8 +77,6 @@ protected |
| @cms_page = CmsPage.new(params[:cms_page]) | |
| - | if (@cms_page.parent ||= @parent_page) |
| - | @cms_page.cms_site = @cms_page.parent.cms_site |
| - | end |
| + | @cms_page.parent ||= @parent_page |
| end | |
| end | |
app/controllers/cms_content_controller.rb
+1
-11
| @@ | @@ -3,12 +3,9 @@ class CmsContentController < ApplicationController |
| unloadable | |
| - | before_filter :assign_cms_root |
| - | |
| def show | |
| - | #path = params[:path] || "" |
| page_path = params[:path] || "" | |
| - | @cms_page = (@cms_site ? @cms_site.cms_pages : CmsPage).published.find_by_full_path(page_path) |
| + | @cms_page = CmsPage.published.find_by_full_path(page_path) |
| render_page | |
| end | |
| @@ | @@ -21,11 +18,4 @@ class CmsContentController < ApplicationController |
| end | |
| end | |
| - | protected |
| - | def assign_cms_root |
| - | if (ComfortableMexicanSofa::Config.multiple_sites) |
| - | @cms_site = CmsSite.find_by_hostname(request.host.downcase) |
| - | end |
| - | end |
| - | |
| end | |
app/models/cms_page.rb
+4
-21
| @@ | @@ -18,8 +18,7 @@ class CmsPage < ActiveRecord::Base |
| attr_accessor :rendered_content | |
| # -- Relationships -------------------------------------------------------- | |
| - | |
| - | belongs_to :cms_site |
| + | |
| belongs_to :cms_layout | |
| has_many :cms_blocks, | |
| :dependent => :destroy | |
| @@ | @@ -45,7 +44,7 @@ class CmsPage < ActiveRecord::Base |
| :if => :slug_required? | |
| validates :full_path, | |
| - | :uniqueness => { :scope => :cms_site_id } |
| + | :uniqueness => true |
| validate :validate_redirect_to | |
| @@ | @@ -53,8 +52,6 @@ class CmsPage < ActiveRecord::Base |
| before_validation :assign_full_path | |
| - | before_save :assign_site |
| - | |
| before_update :update_counter_cache | |
| after_save :save_blocks, :sync_child_slugs | |
| @@ | @@ -115,7 +112,7 @@ class CmsPage < ActiveRecord::Base |
| end | |
| def pages_for_select(page = nil, level = 0, exclude_self = false) | |
| - | page ||= self.cms_site ? self.cms_site.cms_pages.root : CmsPage.root |
| + | page ||= CmsPage.root |
| return [] if !page || (page == self && exclude_self) | |
| out = [["#{". . " * level} #{page.label}", page.id]] | |
| @@ | @@ -135,20 +132,12 @@ class CmsPage < ActiveRecord::Base |
| "/#{read_attribute(:full_path)}" | |
| end | |
| - | def full_path_with_site |
| - | (self.cms_site ? "http://#{self.cms_site.hostname}" : '') + full_path |
| - | end |
| - | |
| def cms_block_content(label, content) | |
| self.cms_blocks.select{|b| b.label.to_s == label.to_s}.first.try(content) | |
| end | |
| def slug_required? | |
| - | if (self.cms_site_id?) |
| - | return !self.site_root? |
| - | else |
| - | return (self != CmsPage.root or CmsPage.count == 0) |
| - | end |
| + | return (self != CmsPage.root or CmsPage.count == 0) |
| end | |
| def published_status | |
| @@ | @@ -159,12 +148,6 @@ protected |
| def assign_full_path | |
| self.full_path = (self.ancestors.reverse.collect{ |p| p.slug }.reject { |p| p.blank? } + [ self.slug ]).join('/') | |
| end | |
| - | |
| - | def assign_site |
| - | return if (self.cms_site_id.present?) |
| - | |
| - | self.cms_site_id = (self.parent and self.parent.cms_site_id) |
| - | end |
| def validate_redirect_to | |
| if self.redirect_to_page && (self == self.redirect_to_page || self.redirect_to_page.redirect_to_page) | |
app/views/cms_admin/pages/_form.html.haml
+1
-4
| @@ | @@ -6,10 +6,7 @@ |
| .form_element_group | |
| %h2 W3C Validation | |
| - | - if (ComfortableMexicanSofa::Config.multiple_sites) |
| - | = link_to 'Check Validation', 'http://validator.w3.org/check?uri='+@cms_page.full_path_with_site, :target => "_new" |
| - | - else |
| - | = link_to 'Check Validation', 'http://validator.w3.org/check?uri=http://'+request.host+@cms_page.full_path, :target => "_new" |
| + | = link_to 'Check Validation', 'http://validator.w3.org/check?uri=http://'+request.host+@cms_page.full_path, :target => "_new" |
| = render :partial => 'cms_admin/categories/category_subform', :locals => { :item => @cms_page } | |
app/views/cms_admin/pages/_tree_branch.html.haml
+1
-1
| @@ | @@ -26,7 +26,7 @@ |
| %br/ | |
| %div.url | |
| - | = link_to(page.full_path_with_site, page.full_path_with_site) |
| + | = link_to(page.full_path, page.full_path) |
| - unless (page.published?) | |
| (Unpublished) | |
app/views/cms_admin/pages/index.html.haml
+2
-17
| @@ | @@ -2,20 +2,5 @@ |
| %h2 Pages | |
| = render :partial => 'cms_admin/flash_message' | |
| - | - if (@sites) |
| - | - @sites.each do |site| |
| - | %h3= h(site.label) |
| - | %ul.tree_structure.sortable |
| - | - if (@cms_pages[site.id]) |
| - | = render(:partial => 'tree_branch', :collection => @cms_pages[site.id]) |
| - | - else |
| - | %li.empty_state |
| - | No pages defined. |
| - | |
| - | - if (@cms_pages[nil]) |
| - | %h3 Default Site |
| - | %ul.tree_structure.sortable |
| - | = render(:partial => 'tree_branch', :collection => @cms_pages[nil]) |
| - | - else |
| - | %ul.tree_structure.sortable |
| - | = render(:partial => 'tree_branch', :collection => @cms_pages) |
| + | %ul.tree_structure.sortable |
| + | = render(:partial => 'tree_branch', :collection => @cms_pages) |
app/views/layouts/cms_admin.html.haml
+0
-2
| @@ | @@ -24,8 +24,6 @@ |
| = link_to(image_tag(ComfortableMexicanSofa::Config.logo_path), cms_admin_pages_path) | |
| %ul.primary | |
| - | - if (ComfortableMexicanSofa::Config.multiple_sites) |
| - | %li= active_link_to 'Sites', cms_admin_sites_path |
| %li= active_link_to 'Layouts', cms_admin_layouts_path | |
| %li= active_link_to 'Pages', cms_admin_pages_path, :active => {:when => [['cms_admin/pages'], %w(index new edit create update)]} | |
| %li= active_link_to 'Snippets', cms_admin_snippets_path | |
config/routes.rb
+0
-2
| @@ | @@ -29,8 +29,6 @@ Rails.application.routes.draw do |
| end | |
| end | |
| - | resources :sites |
| - | |
| resources :categories do | |
| member do | |
| match :toggle | |
migrate/01_create_cms.rb b/db/migrate/01_create_cms.rb
+2
-13
| @@ | @@ -1,15 +1,7 @@ |
| class CreateCms < ActiveRecord::Migration | |
| def self.up | |
| - | create_table :cms_sites do |t| |
| - | t.string :label |
| - | t.string :hostname |
| - | end |
| - | |
| - | add_index :cms_sites, :label |
| - | add_index :cms_sites, :hostname, :unique => true |
| - | |
| + | |
| create_table :cms_layouts do |t| | |
| - | t.integer :cms_site_id |
| t.integer :parent_id | |
| t.string :label | |
| t.text :content | |
| @@ | @@ -25,7 +17,6 @@ class CreateCms < ActiveRecord::Migration |
| execute "INSERT INTO cms_layouts (id, label, app_layout, content) VALUES (1, 'Default Layout', 'application', '{{cms_page_block:default:text}}')" | |
| create_table :cms_pages do |t| | |
| - | t.integer :cms_site_id |
| t.integer :cms_layout_id | |
| t.integer :parent_id | |
| t.integer :redirect_to_page_id | |
| @@ | @@ -36,11 +27,10 @@ class CreateCms < ActiveRecord::Migration |
| t.integer :position, :null => false, :default => 0 | |
| t.boolean :published, :null => false, :default => true | |
| t.boolean :excluded_from_nav, :null => false, :default => false | |
| - | t.boolean :site_root, :null => false, :default => false |
| t.timestamps | |
| end | |
| add_index :cms_pages, [:parent_id, :slug] | |
| - | add_index :cms_pages, [ :cms_site_id, :full_path ], :unique => true |
| + | add_index :cms_pages, :full_path , :unique => true |
| add_index :cms_pages, [:published, :full_path] | |
| add_index :cms_pages, [:excluded_from_nav, :parent_id] | |
| @@ | @@ -98,7 +88,6 @@ class CreateCms < ActiveRecord::Migration |
| drop_table :cms_pages | |
| drop_table :cms_snippets | |
| drop_table :cms_blocks | |
| - | drop_table :cms_sites |
| drop_table :cms_categories | |
| drop_table :cms_page_categorizations | |
| end | |
comfortable_mexican_sofa.rb b/lib/comfortable_mexican_sofa.rb
+0
-1
| @@ | @@ -31,7 +31,6 @@ module ComfortableMexicanSofa |
| cattr_accessor_with_default :cms_title | |
| cattr_accessor_with_default :additional_cms_tabs, { } | |
| cattr_accessor_with_default :extension_tabs, { } | |
| - | cattr_accessor_with_default :multiple_sites, false |
| cattr_accessor_with_default :logo_path, '/images/cms/default-logo.png' | |
| end | |