Sha256: af638b93bd86a6137262f93e3bc821abec09b0c4b60882f951e60e39ed80b75b

Contents?: true

Size: 1.92 KB

Versions: 11

Compression:

Stored size: 1.92 KB

Contents

class Admin::PagesController < Admin::ResourceController
  before_filter :initialize_meta_rows_and_buttons, :only => [:new, :edit, :create, :update]
  before_filter :count_deleted_pages, :only => [:destroy]

  responses do |r|
    r.plural.js do
      @level = params[:level].to_i
      @template_name = 'index'
      response.headers['Content-Type'] = 'text/html;charset=utf-8'
      render :action => 'children.html.haml', :layout => false
    end
  end

  def index
    @homepage = Page.find_by_parent_id(nil)
    response_for :plural
  end

  def show
    respond_to do |format|
      format.xml { super }
      format.html { redirect_to edit_admin_page_path(params[:id]) }
    end
  end

  def new
    self.model = model_class.new_with_defaults(config)
    if params[:page_id].blank?
      self.model.slug = '/'
    end
    response_for :singular
  end

  private
    def model_class
      if params[:page_id]
        Page.find(params[:page_id]).children
      else
        Page
      end
    end

    def announce_saved(message = nil)
      flash[:notice] = message || "Your page has been saved below."
    end

    def announce_removed
      flash[:notice] = if @count > 0
        "The pages were successfully removed from the site."
      else
        "The page was successfully removed from the site."
      end
    end

    def count_deleted_pages
      @count = model.children.count + 1
    end

    def initialize_meta_rows_and_buttons
      @buttons_partials ||= []
      @meta ||= []
      @meta << {:field => "slug", :type => "text_field", :args => [{:class => 'textbox', :maxlength => 100}]}
      @meta << {:field => "breadcrumb", :type => "text_field", :args => [{:class => 'textbox', :maxlength => 160}]}
      @meta << {:field => "description", :type => "text_field", :args => [{:class => 'textbox', :maxlength => 200}]}
      @meta << {:field => "keywords", :type => "text_field", :args => [{:class => 'textbox', :maxlength => 200}]}
    end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
radiantcms-couchrest_model-0.2.4 app/controllers/admin/pages_controller.rb
radiantcms-couchrest_model-0.2.2 app/controllers/admin/pages_controller.rb
radiantcms-couchrest_model-0.2.1 app/controllers/admin/pages_controller.rb
radiantcms-couchrest_model-0.2 app/controllers/admin/pages_controller.rb
radiantcms-couchrest_model-0.1.9 app/controllers/admin/pages_controller.rb
radiantcms-couchrest_model-0.1.8 app/controllers/admin/pages_controller.rb
radiantcms-couchrest_model-0.1.7 app/controllers/admin/pages_controller.rb
radiantcms-couchrest_model-0.1.6 app/controllers/admin/pages_controller.rb
radiantcms-couchrest_model-0.1.5 app/controllers/admin/pages_controller.rb
radiant-0.8.2 app/controllers/admin/pages_controller.rb
radiant-0.8.1 app/controllers/admin/pages_controller.rb