Sha256: 814f3b5e460a119e266877a20fe7e36f62c5c7d957ad86c55867046158c8e4aa

Contents?: true

Size: 875 Bytes

Versions: 3

Compression:

Stored size: 875 Bytes

Contents

#
# Blogaze
# Copyright (C) 2011-2013 Jack Polgar
#
# Blogaze is released under the BSD 3-clause license.
# @license http://opensource.org/licenses/BSD-3-Clause
#

module Blogaze
  module Controllers
    class MainController < Controller
      map '/'
      helper :paginate

      ##
      # Index page
      #
      def index(page = 1)
        # Check if we should change the title to include
        # what page we're on.
        if page.to_i > 1
          @title = "Page #{page} - #{@settings[:title]}"
        else
          @title = @settings[:title]
        end

        # Get the data and paginate it.
        data = ::Blogaze::Models::Post.order(:published_at.desc)
        @posts = paginate(data, :limit => @settings[:posts_per_page].to_i, :page => page.to_i)

        respond(view_file(:index))
      end
    end # MainController
  end # Controllers
end # Blogaze

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
blogaze-0.1.0 lib/blogaze/controllers/main_controller.rb
blogaze-0.0.3 lib/blogaze/controllers/main_controller.rb
blogaze-0.0.2 lib/blogaze/controllers/main_controller.rb