Sha256: 9ad2b3719f6108c881f1d845b846da53458e7b252bc55f9eefa4a63a15b1aeea

Contents?: true

Size: 976 Bytes

Versions: 3

Compression:

Stored size: 976 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 Pages < Controller
      map '/pages'

      ##
      # View page
      #
      def view(slug = nil)
        if slug == nil
          slug = request.env["REQUEST_PATH"]
        end

        # Chomp chomp chomp, let's trim any unwanted
        # forward slashes from the begning and end of the url.
        slug = slug.chomp("/").reverse.chomp("/").reverse

        @page = ::Blogaze::Models::Page[:slug => slug]

        # Check if the page exists, if not render the
        # not found page.
        if !@page.respond_to?('title')
          respond(view_file('pages/notfound'))
        else
          @title = "#{@page.title} - #{@settings[:title]}"
          respond(view_file('pages/page'))
        end
      end
    end # Pages
  end # Controllers
end # Blogaze

Version data entries

3 entries across 3 versions & 1 rubygems

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