Sha256: ba121899179414104fad0f119f84088b87f3683374f46dc122a9817bef9f1446

Contents?: true

Size: 1.28 KB

Versions: 2

Compression:

Stored size: 1.28 KB

Contents

require 'base64'

class Admin::PagesController < Admin::BaseController
  def index
    list
    render_action 'list'
  end

  def list
    @pages = Page.find(:all, :order => "id DESC")
    @page = Page.new(params[:page])
    @page.text_filter ||= this_blog.text_filter
  end

  def show
    @page = Page.find(params[:id])
  end

  def new
    @page = Page.new(params[:page])
    @page.user_id = session[:user].id
    @page.text_filter ||= this_blog.text_filter
    if request.post? and @page.save
      flash[:notice] = 'Page was successfully created.'
      redirect_to :action => 'show', :id => @page.id
    end
  end

  def edit
    @page = Page.find(params[:id])
    @page.attributes = params[:page]
    if request.post? and @page.save
      flash[:notice] = 'Page was successfully updated.'
      redirect_to :action => 'show', :id => @page.id
    end
  end

  def destroy
    @page = Page.find(params[:id])
    if request.post?
      @page.destroy
      redirect_to :action => 'list'
    end
  end

  def preview
    headers["Content-Type"] = "text/html; charset=utf-8"
    @page = this_blog.pages.build(params[:page])
    data = render_to_string(:layout => "minimal")
    data = Base64.encode64(data).gsub("\n", '')
    data = "data:text/html;charset=utf-8;base64,#{data}"
    render :text => data
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
typo-4.1.1 app/controllers/admin/pages_controller.rb
typo-4.1 app/controllers/admin/pages_controller.rb