blowing away all views

Oleg committed Aug 27, 2010
commit 905c66d620cd32be6c792c7aa51a0dc421218e4b
Showing 30 changed files with 21 additions and 576 deletions
app/controllers/application_controller.rb +2 -0
@@ @@ -1,3 +1,5 @@
class ApplicationController < ActionController::Base
+
protect_from_forgery
+
end
app/controllers/cms_admin/base_controller.rb +1 -33
@@ @@ -1,37 +1,5 @@
class CmsAdmin::BaseController < ApplicationController
- before_filter :authenticate
-
- layout 'cms_admin'
-
- def index
- # the jQuery in utilities.js uses the current path to define the scope (i.e: layouts vs. pages).
- # So having /cms-admin as a path for pages will break the js.
- redirect_to cms_admin_pages_path
- end
-
- def save_tree_state(object)
- name = object.class.name.underscore.to_sym
- session[name] ||= []
- session[name] = if session[name].include?(object.id)
- session[name] - [object.id]
- else
- session[name] + [object.id]
- end
- end
-
- def js_helper_installed?(name, library = nil)
- File.exists?(File.expand_path("public/javascripts/#{name}/#{library||name}.js", Rails.root))
- end
- helper_method :js_helper_installed?
-
- protected
-
- def authenticate
- authenticate_or_request_with_http_basic do |username, password|
- username == ComfortableMexicanSofa::Config.http_auth_username &&
- password == ComfortableMexicanSofa::Config.http_auth_password
- end if ComfortableMexicanSofa::Config.http_auth_enabled
- end
+ #TODO
end
app/controllers/cms_admin/layouts_controller.rb +1 -64
@@ @@ -1,68 +1,5 @@
class CmsAdmin::LayoutsController < CmsAdmin::BaseController
- before_filter :load_layout, :only => [:toggle, :edit, :update, :destroy]
- before_filter :build_layout, :only => [ :new, :create ]
- def index
- @cms_layouts = CmsLayout.roots
- end
+ #TODO
- def toggle
- save_tree_state(@cms_layout)
- render :nothing => true
- end
-
- def new
- end
-
- def create
- @cms_layout.save!
-
- flash[:notice] = 'Layout created'
- redirect_to edit_cms_admin_layout_path(@cms_layout)
- rescue ActiveRecord::RecordInvalid
- render :action => :new
- end
-
- def edit
- # ...
- end
-
- def update
- @cms_layout.update_attributes!(params[:cms_layout])
-
- flash[:notice] = 'Layout updated'
- redirect_to edit_cms_admin_layout_path(@cms_layout)
-
- rescue ActiveRecord::RecordInvalid
- render :action => :edit
- end
-
- def destroy
- @cms_layout.destroy
-
- flash[:notice] = 'Layout removed'
- redirect_to cms_admin_layouts_path
- end
-
- def reorder
- params[:cms_layout].each_with_index do |id, index|
- CmsLayout.update_all(['position = %d', index], ['id = %d', id])
- end
-
- render :nothing => true
- end
-
- protected
- def build_layout
- params[:cms_layout] ||= {
- :parent_id => params[:parent_id],
- :content => '{{cms_page_block:default:text}}'
- }
-
- @cms_layout = CmsLayout.new(params[:cms_layout])
- end
-
- def load_layout
- @cms_layout = CmsLayout.find_by_id(params[:id])
- end
end
app/controllers/cms_admin/pages_controller.rb +1 -78
@@ @@ -1,82 +1,5 @@
class CmsAdmin::PagesController < CmsAdmin::BaseController
- include CmsCommon::RenderPage
+ # TODO
- before_filter :load_page, :only => [:toggle, :edit, :update, :destroy, :reorder]
- before_filter :build_page, :only => [ :new, :create ]
-
- def index
- params[:root] ? @cms_pages = CmsPage.find(params[:root]).children : @cms_pages = CmsPage.roots
- end
-
- def toggle
- save_tree_state(@cms_page)
- render :nothing => true
- end
-
- def new
- @cms_page.cms_layout = @cms_page.parent.cms_layout if @cms_page.parent
- end
-
- def edit
- # ...
- end
-
- def create
- return render_page if !params[:preview].blank? && @cms_page.valid?
-
- @cms_page.save!
-
- flash[:notice] = 'Page created'
- redirect_to edit_cms_admin_page_path(@cms_page)
-
- rescue ActiveRecord::RecordInvalid
- render :action => :new
- end
-
- def update
- @cms_page.attributes = params[:cms_page]
-
- return render_page if !params[:preview].blank? && @cms_page.valid?
-
- @cms_page.save!
-
- flash[:notice] = 'Page updated'
- redirect_to edit_cms_admin_page_path(@cms_page)
-
- rescue ActiveRecord::RecordInvalid
- render :action => :edit
- end
-
- def destroy
- @cms_page.destroy
-
- flash[:notice] = 'Page removed'
- redirect_to cms_admin_pages_path
- end
-
- def form_blocks
- @cms_page = CmsPage.find_by_id(params[:id])
- @layout = CmsLayout.find(params[:layout_id])
- end
-
- def reorder
- params[:cms_page].each_with_index do |id, index|
- CmsPage.update_all(['position = %d', index], ['id = %d', id])
- end
- render :nothing => true
- end
-
- protected
- def load_page
- @cms_page = CmsPage.find_by_id(params[:id])
- end
-
- def build_page
- @parent_page = (params[:parent_id] and CmsPage.find_by_id(params[:parent_id]))
-
- @cms_page = CmsPage.new(params[:cms_page])
-
- @cms_page.parent ||= @parent_page
- end
end
app/controllers/cms_admin/snippets_controller.rb +3 -47
@@ @@ -1,49 +1,5 @@
class CmsAdmin::SnippetsController < CmsAdmin::BaseController
- before_filter :load_cms_snippet,
- :only => [:edit, :update, :destroy]
- before_filter :build_cms_snippet,
- :only => [:new, :create]
-
- def index
- @cms_snippets = CmsSnippet.all
- end
-
- def new
- # ...
- end
-
- def edit
- # ...
- end
-
- def create
- @cms_snippet.save!
- redirect_to({ :action => :edit, :id => @cms_snippet }, :notice => 'Snippet created')
- rescue ActiveRecord::RecordInvalid
- render :action => :new
- end
-
- def update
- @cms_snippet.update_attributes!(params[:cms_snippet])
- redirect_to({ :action => :edit, :id => @cms_snippet }, :notice => 'Snippet updated')
- rescue ActiveRecord::RecordInvalid
- render :action => :edit
- end
-
- def destroy
- @cms_snippet.destroy
- redirect_to({ :action => :index }, :notice => 'Snippet removed')
- end
-
- protected
- def load_cms_snippet
- @cms_snippet = CmsSnippet.find(params[:id])
- rescue ActiveRecord::RecordNotFound
- render_not_found
- end
-
- def build_cms_snippet
- params[:cms_snippet] ||= { }
- @cms_snippet = CmsSnippet.new(params[:cms_snippet])
- end
+
+ # TODO
+
end
app/controllers/cms_common/render_page.rb +0 -20
@@ @@ -1,20 +0,0 @@
- module CmsCommon::RenderPage
-
- def render_page(options = { })
- if @cms_page.blank?
- if (@cms_page = CmsPage.published.find_by_full_path('404'))
- render :inline => @cms_page.content, :layout => (@cms_page.cms_layout.app_layout || false), :status => 404
- else
- render :text => '404 Page Not Found', :status => 404
- end
- else
- if @cms_page.redirect_to_page
- redirect_to @cms_page.redirect_to_page.full_path
- else
- layout = (@cms_page.cms_layout.app_layout || false)
- render :inline => @cms_page.content, :layout => layout
- end
- end
- end
-
- end
app/controllers/cms_content_controller.rb +1 -17
@@ @@ -1,21 +1,5 @@
class CmsContentController < ApplicationController
- include CmsCommon::RenderPage
- unloadable
-
- def show
- page_path = params[:path] || ""
- @cms_page = CmsPage.published.find_by_full_path(page_path)
-
- render_page
- end
-
- def sitemap
- respond_to do |format|
- format.xml do
- @cms_pages = CmsPage.published
- end
- end
- end
+ # TODO
end
app/helpers/cms_helper.rb +1 -23
@@ @@ -1,27 +1,5 @@
module CmsHelper
- def application_name
- ComfortableMexicanSofa::Config.cms_title || 'CMS'
- end
+ # TODO
- def tree_state(object)
- name = object.class.name.underscore.to_sym
- if session[name].present?
- session[name].include?(object.id) ? '' : 'closed'
- else
- 'closed'
- end
- end
-
- def link_to_toggle(object, children_count)
- link_to_function(children_count, '', :class => ['tree_toggle', tree_state(object)].join(' '), :title => 'Expand/Collapse', :onclick => "object_id = '#{object.id}'")
- end
-
- def cms_form_for(record_or_name_or_array, *args, &proc)
- options = args.extract_options!
- options.merge!(:builder => CmsFormBuilder)
- (options[:html] ||= {}).merge!(:class => (options[:html][:class].to_s + ' formatted'))
- form_for(record_or_name_or_array, *(args << options), &proc)
- end
-
end
app/views/cms_admin/_flash_message.html.haml +0 -3
@@ @@ -1,3 +0,0 @@
- - flash.each do |type, value|
- .flash{ :class => type.to_s }
- = value
\ No newline at end of file
app/views/cms_admin/layouts/_details.html.haml +0 -10
@@ @@ -1,10 +0,0 @@
- - layout ||= details
-
- %table{:class => 'details', :id => dom_id(layout, :details), :style => 'display: none'}
- %tr
- %th Last Updated:
- %td
- - if (layout.updated_at?)
- #{time_ago_in_words(layout.updated_at)} ago
- - else
- Never
app/views/cms_admin/layouts/_form.html.haml +0 -13
@@ @@ -1,13 +0,0 @@
- %h2= @cms_layout.new_record? ? "New Layout" : "Editing \"#{@cms_layout.label}\""
- = render :partial => 'cms_admin/flash_message'
- = f.error_messages
- .form_left_column
- .form_element_group.horizontal
- = f.text_field :label, :label => 'Layout Name'
- = f.select :parent_id, @cms_layout.extendable_for_select, :label => 'Parent Layout'
- = f.select :app_layout, CmsLayout.app_layouts_for_select, :label => 'Application Layout'
- = f.text_area :content
- .submit
- = f.submit 'Save All Changes'
- or
- = link_to 'Return to List', cms_admin_layouts_path
app/views/cms_admin/layouts/_tree_branch.html.haml +0 -30
@@ @@ -1,30 +0,0 @@
- - layout = tree_branch
- - children = layout.children
-
- %li[layout]
- - if children.size > 0
- = link_to_toggle(layout, children.size)
-
- .item
- .icon
- - if layout.siblings.size > 0
- .dragger
-
- = link_to layout.label, edit_cms_admin_layout_path(layout), :class => 'label'
-
- %span.action_links
- [
- = link_to_function 'Toggle Details', "", :class => 'details_toggle'
- |
- - if layout.is_extendable?
- = link_to 'Add Child Layout', new_cms_admin_layout_path(:parent_id => layout.id)
- |
- = link_to 'Edit', edit_cms_admin_layout_path(layout)
- |
- = link_to 'Remove', cms_admin_layout_path(layout), :method => 'delete', :confirm => 'Are you sure you want to remove this layout?'
- ]
- = render :partial => 'details', :object => layout
-
- - if children.size > 0
- %ul{:id => dom_id(layout, :children), :class => "sortable #{tree_state(layout)}"}
- = render :partial => 'tree_branch', :collection => children
\ No newline at end of file
app/views/cms_admin/layouts/edit.html.haml +0 -2
@@ @@ -1,2 +0,0 @@
- = cms_form_for @cms_layout, :url => cms_admin_layout_path(@cms_layout) do |form|
- = render :partial => 'form', :locals => {:f => form}
app/views/cms_admin/layouts/index.html.haml +0 -5
@@ @@ -1,5 +0,0 @@
- = link_to 'Add New Layout', new_cms_admin_layout_path, :class => 'top_button'
- %h2 Layouts
- = render :partial => 'cms_admin/flash_message'
- %ul.tree_structure.sortable
- = render(:partial => 'tree_branch', :collection => @cms_layouts)
app/views/cms_admin/layouts/new.html.haml +0 -2
@@ @@ -1,2 +0,0 @@
- = cms_form_for @cms_layout, :url => cms_admin_layouts_path do |form|
- = render :partial => 'form', :locals => {:f => form}
app/views/cms_admin/pages/_details.html.haml +0 -25
@@ @@ -1,25 +0,0 @@
- - page ||= details
-
- %table{:class => 'details', :id => "page_details_#{page.id}", :style => 'display: none'}
-
- - if page.redirect_to_page
- %tr
- %th Redirecting To:
- %td
- = link_to page.redirect_to_page.label, cms_admin_page_path(page.redirect_to_page)
- = "(#{link_to page.redirect_to_page.full_path, page.redirect_to_page.full_path})"
-
- - if page.redirected_from_page
- %tr
- %th Redirected From:
- %td
- = link_to page.redirected_from_page.label, cms_admin_page_path(page.redirected_from_page)
- = "(#{link_to page.redirected_from_page.full_path, page.redirected_from_page.full_path})"
-
- - if page.cms_layout
- %tr
- %th Layout:
- %td= link_to page.cms_layout.label, edit_cms_admin_layout_path(page.cms_layout)
- %tr
- %th Blocks:
- %td= page.cms_blocks.collect(&:label).join(', ')
app/views/cms_admin/pages/_form.html.haml +0 -32
@@ @@ -1,32 +0,0 @@
- - content_for :right_column do
- .form_element_group.publishing
- %h2 Publishing Options
- = f.check_box :published, :label => 'Is Published?'
- = f.check_box :excluded_from_nav, :label => 'Exclude from Navigation?'
-
- .form_element_group
- %h2 W3C Validation
- = link_to 'Check Validation', 'http://validator.w3.org/check?uri=http://'+request.host+@cms_page.full_path, :target => "_new"
-
- %h2= @cms_page.new_record? ? "New Page" : "Editing \"#{@cms_page.label}\""
- = render :partial => 'cms_admin/flash_message'
- = f.error_messages
- .form_element_group.vertical
- = f.text_field :label, :id => (@cms_page.new_record? ? "slugify" : nil)
- - unless CmsPage.count == 0 || @cms_page == CmsPage.root
- = f.text_field :slug, :id => 'slug'
- = f.custom_element('&nbsp;', link_to_function('Show more', '', :id => 'more_options'))
- .form_element_group.vertical.advanced
- - unless CmsPage.count == 0 || @cms_page == CmsPage.root
- = f.select :parent_id, @cms_page.pages_for_select(nil, 0, true)
- = f.select :redirect_to_page_id, [['---', nil]] + @cms_page.pages_for_select
- = f.select :cms_layout_id, CmsLayout.options_for_select, {}
- :javascript
- page_id = #{@cms_page.new_record? ? 0 : @cms_page.id}
- #form_blocks
- = render :partial => 'form_blocks', :locals => {:f => f}
- .submit
- = f.submit 'Save All Changes', :id => 'save'
- -# f.submit 'Preview Page', :id => 'preview', :name => 'preview'
- or
- = link_to 'Return to List', cms_admin_pages_path
app/views/cms_admin/pages/_form_blocks.html.haml +0 -25
@@ @@ -1,25 +0,0 @@
- - @layout ||= @cms_page.cms_layout
- - @layout && tags = @layout.tags(:view => self, :page => @cms_page).reject{|t| !t.class.has_form?}.group_by(&:tag_type)
-
- - unless tags.blank?
- - unless (cms_block_tags = tags.delete('cms_block')).blank?
- .form_element_group.block
- - cms_block_tags.each do |tag|
- .form_element{:class => tag.format}
- .label= tag.form_label
- .value= tag.form_input
-
- - unless (cms_page_block_tags = tags.delete('cms_page_block')).blank?
- .form_element_group.page_block
- - cms_page_block_tags.each do |tag|
- .form_element{:class => tag.format}
- .label= tag.form_label
- .value= tag.form_input
-
- - # outputting any other tag that has a form element
- - tags.each do |type, tags|
- .form_element_group{:class => type.to_s}
- - tags.each do |tag|
- .form_element
- .label= tag.form_label
- .value= tag.form_input
\ No newline at end of file
app/views/cms_admin/pages/_tree_branch.html.haml +0 -37
@@ @@ -1,37 +0,0 @@
- - page = tree_branch
- - children = page.children
-
- %li[page]
-
- - if children.size > 0
- = link_to_toggle(page, children.size)
-
- .item
- .icon{:class => page.published_status}
- - if page.siblings.size > 0
- .dragger
-
- = link_to page.label, edit_cms_admin_page_path(page), :class => 'label'
-
- %span.action_links
- [
- = link_to_function 'Toggle Details', "", :class => 'details_toggle'
- |
- = link_to 'Add Child Page', new_cms_admin_page_path(:parent_id => page.id)
- |
- = link_to 'Edit', edit_cms_admin_page_path(page)
- |
- = link_to 'Remove', cms_admin_page_path(page), :method => 'delete', :confirm => 'Are you sure you want to remove this page?'
- ]
-
- %br/
- %div.url
- = link_to(page.full_path, page.full_path)
- - unless (page.published?)
- (Unpublished)
-
- = render :partial => 'details', :object => page
-
- - if children.size > 0
- %ul{:id => dom_id(page, :children), :class => "sortable #{tree_state(page)}"}
- = render :partial => 'tree_branch', :collection => children
\ No newline at end of file
app/views/cms_admin/pages/edit.html.haml +0 -2
@@ @@ -1,2 +0,0 @@
- = cms_form_for @cms_page, :url => cms_admin_page_path(@cms_page) do |form|
- = render :partial => 'form', :locals => {:f => form }
app/views/cms_admin/pages/form_blocks.js.erb +0 -1
@@ @@ -1 +0,0 @@
- $('#form_blocks').html('<%= escape_javascript(render(:partial => "form_blocks")) %>')
\ No newline at end of file
app/views/cms_admin/pages/index.html.haml +0 -6
@@ @@ -1,6 +0,0 @@
- = link_to 'Add New Page', new_cms_admin_page_path, :class => 'top_button'
-
- %h2 Pages
- = render :partial => 'cms_admin/flash_message'
- %ul.tree_structure.sortable
- = render(:partial => 'tree_branch', :collection => @cms_pages)
app/views/cms_admin/pages/new.html.haml +0 -2
@@ @@ -1,2 +0,0 @@
- = cms_form_for @cms_page, :url => {:action => 'create'} do |form|
- = render :partial => 'form', :locals => {:f => form }
app/views/cms_admin/snippets/_form.html.haml +0 -10
@@ @@ -1,10 +0,0 @@
- %h2= @cms_snippet.new_record? ? "New Snippet" : "Editing \"#{@cms_snippet.label}\""
- = render :partial => 'cms_admin/flash_message'
- = f.error_messages
- .form_element_group.horizontal
- = f.text_field :label, :label => "Snippet Name"
- = f.text_area :content
- .submit
- = f.submit 'Save All Changes', :onclick => 'this.f.target = ""'
- or
- = link_to 'Return to List', cms_admin_snippets_path
app/views/cms_admin/snippets/edit.html.haml +0 -2
@@ @@ -1,2 +0,0 @@
- = cms_form_for @cms_snippet, :url => {:action => :update}, :html => {:method => :put} do |form|
- = render :partial => 'form', :locals => {:f => form}
app/views/cms_admin/snippets/index.html.haml +0 -19
@@ @@ -1,19 +0,0 @@
- = link_to 'Add New Snippet', new_cms_admin_snippet_path, :class => 'top_button'
-
- %h2 Snippets
- = render :partial => 'cms_admin/flash_message'
- %table.formatted
- - if @cms_snippets.blank?
- %tr
- %td No Snippets Defined
- - @cms_snippets.each do |snippet|
- %tr
- %td
- .icon
- %td.main
- = link_to snippet.label.titleize, edit_cms_admin_snippet_path(snippet), :class => 'label'
- %br/
- = link_to snippet.label, edit_cms_admin_snippet_path(snippet), :class => 'slug'
- %td.action_links
- = link_to 'Edit', edit_cms_admin_snippet_path(snippet), :class => 'button'
- = link_to 'Remove', cms_admin_snippet_path(snippet), :class => 'button', :method => 'delete', :confirm => 'Are you sure you want to remove this snippet?'
app/views/cms_admin/snippets/new.html.haml +0 -2
@@ @@ -1,2 +0,0 @@
- = cms_form_for @cms_snippet, :url => {:action => :create } do |form|
- = render :partial => 'form', :locals => {:f => form}
app/views/cms_content/sitemap.xml.rxml +0 -16
@@ @@ -1,16 +0,0 @@
- xml.instruct!
-
- xml.urlset(
- "xmlns" => "http://www.google.com/schemas/sitemap/0.84",
- "xmlns:xsi" => "http://www.w3.org/3004/XMLSchema-instance",
- "xsi:schemaLocation" => "http://www.google.com/schemas/sitemap/0.84 http://www.google.com/schemas/sitemap/0.84/sitemap.xsd"
- ) do
-
- @cms_pages.each do |page|
- xml.url do
- xml.loc "http://#{request.host_with_port}" + page.full_path
- xml.lastmod page.updated_at.utc.strftime("%Y-%m-%dT%H:%M:%S+00:00")
- xml.changefreq 'daily'
- end
- end
- end
\ No newline at end of file
app/views/layouts/cms_admin.html.erb +11 -0
@@ @@ -0,0 +1,11 @@
+ <!DOCTYPE html>
+ <html>
+ <head>
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
+ <title>Comfortable Mexican Sofa</title>
+ <%= yield :head %>
+ </head>
+ <body>
+ <%= yield %>
+ </body>
+ </html>
\ No newline at end of file
app/views/layouts/cms_admin.html.haml +0 -50
@@ @@ -1,50 +0,0 @@
- !!!
- %html
- %head
- %title= application_name
- = csrf_meta_tag
- = stylesheet_link_tag 'cms_master'
- = stylesheet_link_tag 'jquery_ui'
- = javascript_include_tag 'cms/jquery', 'cms/jquery-ui', 'cms/cms'
- = javascript_include_tag 'cms/rails'
-
- - if js_helper_installed?('ckeditor')
- = javascript_include_tag 'ckeditor/ckeditor', 'ckeditor/adapters/jquery', 'cms/rteditor'
- - if js_helper_installed?('codemirror')
- = javascript_include_tag 'codemirror/codemirror', 'cms/codemirror'
-
- = yield :head
-
- %body{ :id => "#{params[:controller]}_#{params[:action]}".idify }
- .content_wrapper
- .left_column
- .header
- %h1
- = h(application_name)
- = link_to(image_tag(ComfortableMexicanSofa::Config.logo_path), cms_admin_pages_path)
-
- %ul.primary
- %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
-
- - if (tabs = ComfortableMexicanSofa::Config.extension_tabs)
- %ul.secondary
- - tabs.each do |label, url|
- %li= active_link_to label, url
-
- - unless ComfortableMexicanSofa::Config.additional_cms_tabs.blank?
- %ul.secondary
- - ComfortableMexicanSofa::Config.additional_cms_tabs.each do |label, url|
- %li= active_link_to label, url
-
- .content_column
- .right_column
- = yield :right_column
- .center_column
- = yield
-
- .footer
- = link_to('The Working Group', 'http://twg.ca/', :target => '_twg')
- &copy;
- = [ 2009, Date.today.year ].uniq.join(' - ')