Sha256: 5daad691d0782376a8826d20355de68b93396fb94415659d736dada82b3f9782

Contents?: true

Size: 1.66 KB

Versions: 10

Compression:

Stored size: 1.66 KB

Contents

module Kuztuscms
  class TemplatesController < KuztuscmsController
    before_filter :build_locales_list, :only => [:new, :edit, :create, :update]
    before_filter :build_handlers_list, :only => [:new, :edit, :create, :update]
    before_filter :build_formats_list, :only => [:new, :edit, :create, :update]

    # GET /templates
    def index
      @templates = Template.all
    end

    # GET /templates/1
    def show
      @template = Template.find(params[:id])
    end

    # GET /templates/new
    def new
      @template = Template.new(:format => 'html')
    end

    # GET /templates/1/edit
    def edit
      @template = Template.find(params[:id])
    end

    # POST /templates
    def create
      @template = Template.new(params[:template])
      @template.partial = true

      if @template.save
        redirect_to templates_url, notice: 'Template was successfully created.'
      else
        render action: "new"
      end
    end

    # PUT /templates/1
    def update
      @template = Template.find(params[:id])

      if @template.update_attributes(params[:template])
        redirect_to templates_url, notice: 'Template was successfully updated.'
      else
        render action: "edit"
      end
    end

    # DELETE /templates/1
    def destroy
      @template = Template.find(params[:id])
      @template.destroy
  
      redirect_to templates_url
    end

    private 

      def build_formats_list
        @formats = Mime::SET.symbols.map(&:to_s)
      end

      def build_locales_list
        @locales = I18n.available_locales.map(&:to_s)
      end

      def build_handlers_list
        @handlers = ActionView::Template::Handlers.extensions.map(&:to_s)
      end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
kuztuscms-0.0.10 app/controllers/kuztuscms/templates_controller.rb
kuztuscms-0.0.9 app/controllers/kuztuscms/templates_controller.rb
kuztuscms-0.0.8 app/controllers/kuztuscms/templates_controller.rb
kuztuscms-0.0.7 app/controllers/kuztuscms/templates_controller.rb
kuztuscms-0.0.6 app/controllers/kuztuscms/templates_controller.rb
kuztuscms-0.0.5 app/controllers/kuztuscms/templates_controller.rb
kuztuscms-0.0.4 app/controllers/kuztuscms/templates_controller.rb
kuztuscms-0.0.3 app/controllers/kuztuscms/templates_controller.rb
kuztuscms-0.0.2 app/controllers/kuztuscms/templates_controller.rb
kuztuscms-0.0.1 app/controllers/kuztuscms/templates_controller.rb