Sha256: 3bbf12b9a79a0ca7cecd106f221b8d8a0415d57791ee4a95f2df4191690ca748

Contents?: true

Size: 1.13 KB

Versions: 9

Compression:

Stored size: 1.13 KB

Contents

module Fuel
  class PostsController < FuelController
    include ActionView::Helpers::TextHelper
    layout Fuel.configuration.layout if Fuel.configuration.layout
    before_filter :define_title

    def define_title
      @blog_title = Fuel.configuration.blog_title
    end

    def index
      @posts = Fuel::Post.recent_published_posts.page(params[:page])
      @title = Fuel.configuration.blog_title
      @description = Fuel.configuration.blog_description
    end

    def show
      @post = Fuel::Post.find_by_slug(params[:id]) || Fuel::Post.find_by_id(params[:id]) || not_found
      @title = truncate_on_space(@post.seo_title, 70)
      @description = @post.seo_description
      @disqus_name = Fuel.configuration.disqus_name
    end

    def preview
      @content = params[:content]
      respond_to do |format|
        format.js
      end
    end

    def redirect
      post = Fuel::Post.find_by_slug(params[:id]) || Fuel::Post.find_by_id(params[:id])
      return redirect_to fuel.post_path(post)
    end

    private

      def truncate_on_space(text = "", length)
        truncate(text, length: length, separator: ' ')
      end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
fuel-0.3.28 app/controllers/fuel/posts_controller.rb
fuel-0.3.27 app/controllers/fuel/posts_controller.rb
fuel-0.3.26 app/controllers/fuel/posts_controller.rb
fuel-0.3.25 app/controllers/fuel/posts_controller.rb
fuel-0.3.24 app/controllers/fuel/posts_controller.rb
fuel-0.3.23 app/controllers/fuel/posts_controller.rb
fuel-0.3.22 app/controllers/fuel/posts_controller.rb
fuel-0.3.21 app/controllers/fuel/posts_controller.rb
fuel-0.3.20 app/controllers/fuel/posts_controller.rb