Sha256: 98ca4b7e3519a3b23b201b6d12bfdc2cf781a5e9c4c55cb84d7a7980b1862d98

Contents?: true

Size: 966 Bytes

Versions: 2

Compression:

Stored size: 966 Bytes

Contents

require_dependency "fuel/application_controller"

module Fuel
  class PostsController < ApplicationController
    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])
    end

    def show
      # delete || Fuel::Post.find_by_id(params[:id]) once done testing pagination
      @post = Fuel::Post.find_by_slug(params[:id]) || Fuel::Post.find_by_id(params[:id])
      @title = truncate_on_space(@post.title, 70)
      @disqus_name = Fuel.configuration.disqus_name
    end

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

    private

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fuel-0.3.3 app/controllers/fuel/posts_controller.rb
fuel-0.3.2 app/controllers/fuel/posts_controller.rb