Class: Thoth::PageController

### Home Classes Methods

### In Files

- lib/thoth/controller/page.rb

### Parent

Ramaze::Controller

### Methods

- #delete
- #edit
- #index
- #list
- #new

### Files

- robots.txt

### Class/Module Index

Quicksearch

- Thoth
- Thoth::AdminController
- Thoth::ArchiveController
- Thoth::Comment
- Thoth::CommentApiController
- Thoth::CommentController
- Thoth::Config
- Thoth::Error
- Thoth::Importer
- Thoth::MainController
- Thoth::Media
- Thoth::MediaController
- Thoth::MinifyController
- Thoth::Page
- Thoth::PageApiController
- Thoth::PageController
- Thoth::Pager
- Thoth::Plugin
- Thoth::Plugin::Delicious
- Thoth::Plugin::Flickr
- Thoth::Plugin::Tags
- Thoth::Plugin::Twitter
- Thoth::Post
- Thoth::PostApiController
- Thoth::PostController
- Thoth::SchemaError
- Thoth::SearchController
- Thoth::Tag
- Thoth::TagApiController
- Thoth::TagController
- Thoth::TagsPostsMap
- Ramaze
- Ramaze::Dispatcher
- Ramaze::Dispatcher::File
- Ramaze::Helper
- Ramaze::Helper::Admin
- Ramaze::Helper::Cookie
- Ramaze::Helper::Error
- Ramaze::Helper::Pagination
- Ramaze::Helper::Sanitize
- Ramaze::Helper::Wiki
- Ramaze::Helper::Ysearch
- Ramaze::Helper::Ysearch::SearchError
- AddMediaSize
- CreateSchema
- PantsImporter
- PoseidonImporter

No matching classes.

# Thoth::PageController

### Public Instance Methods

delete(id = nil) click to toggle source

    # File lib/thoth/controller/page.rb, line 48
    def delete(id = nil)
      require_auth

      error_404 unless id && @page = Page[id]

      if request.post?
        error_403 unless form_token_valid?

        if request[:confirm] == 'yes'
          @page.destroy
          action_cache.clear
          flash[:success] = 'Page deleted.'
          redirect(R(MainController))
        else
          redirect(@page.url)
        end
      end

      @title          = "Delete Page: #{@page.title}"
      @show_page_edit = true
    end

edit(id = nil) click to toggle source

    # File lib/thoth/controller/page.rb, line 70
    def edit(id = nil)
      require_auth

      unless @page = Page[id]
        flash[:error] = 'Invalid page id.'
        redirect(Rs(:new))
      end

      if request.post?
        error_403 unless form_token_valid?

        @page.name  = request[:name]
        @page.title = request[:title]
        @page.body  = request[:body]

        if @page.valid? && request[:action] == 'Post'
          begin
            raise unless @page.save
          rescue => e
            @page_error = "There was an error saving your page: #{e}"
          else
            action_cache.clear
            flash[:success] = 'Page saved.'
            redirect(Rs(@page.name))
          end
        end
      end

      @title          = "Edit page - #{@page.title}"
      @form_action    = Rs(:edit, id)
      @show_page_edit = true
    end

index(name = nil) click to toggle source

    # File lib/thoth/controller/page.rb, line 41
    def index(name = nil)
      error_404 unless name && @page = Page[:name => name.strip.downcase]

      @title          = @page.title
      @show_page_edit = true
    end

list(page = 1) click to toggle source

    # File lib/thoth/controller/page.rb, line 103
    def list(page = 1)
      require_auth

      page = page.to_i

      @columns  = [:name, :title, :created_at, :updated_at]
      @order    = (request[:order] || :desc).to_sym
      @sort     = (request[:sort]  || :created_at).to_sym
      @sort     = :created_at unless @columns.include?(@sort)
      @sort_url = Rs(:list, page)

      @pages = Page.paginate(page, 20).order(@order == :desc ? @sort.desc :
          @sort)

      @title = "Pages (page #{page} of #{[@pages.page_count, 1].max})"
      @pager = pager(@pages, Rs(:list, '%s', :sort => @sort, :order => @order))
    end

new() click to toggle source

    # File lib/thoth/controller/page.rb, line 121
    def new
      require_auth

      @title       = "New page - Untitled"
      @form_action = Rs(:new)

      if request.post?
        error_403 unless form_token_valid?

        @page = Page.new do |p|
          p.name  = request[:name]
          p.title = request[:title]
          p.body  = request[:body]
        end

        if @page.valid? && request[:action] == 'Post'
          begin
            raise unless @page.save
          rescue => e
            @page_error = "There was an error saving your page: #{e}"
          else
            action_cache.clear
            flash[:success] = 'Page created.'
            redirect(Rs(@page.name))
          end
        end

        @title = "New page - #{@page.title}"
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.