module Middleman::BlogPage

Constants

VERSION

Public Class Methods

included(app, options_hash={}, &block)
Alias for: registered
registered(app, options_hash={}) { |options| ... } click to toggle source
# File lib/middleman-blog_page/extension_3_0.rb, line 24
def registered(app, options_hash={}, &block)
  require 'middleman-blog/blog_page_data'
  require 'middleman-blog/blog_page_article'
  require 'active_support/core_ext/time/zones'

  app.send :include, Helpers

  options = Options.new(options_hash)
  yield options if block_given?

  options.permalink            ||= ":title.html"
  options.sources              ||= "pages/:title.html"
  options.layout               ||= "layout"
  options.default_extension    ||= ".markdown"

  # If "prefix" option is specified, all other paths are relative to it.
  if options.prefix
    options.prefix = "/#{options.prefix}" unless options.prefix.start_with? '/'
    options.permalink = File.join(options.prefix, options.permalink)
    options.sources = File.join(options.prefix, options.sources)
  end

  app.after_configuration do
    # Make sure ActiveSupport's TimeZone stuff has something to work with,
    # allowing people to set their desired time zone via Time.zone or
    # set :time_zone
    Time.zone = self.time_zone if self.respond_to?(:time_zone)
    time_zone = Time.zone if Time.zone
    zone_default = Time.find_zone!(time_zone || 'UTC')
    unless zone_default
      raise 'Value assigned to time_zone not recognized.'
    end
    Time.zone_default = zone_default

    # Initialize blog with options
    blog_page(options)

    sitemap.register_resource_list_manipulator(
                                               :blog_pages,
                                               blog_page,
                                               false
                                               )

  end
end
Also aliased as: included