Module: Middleman::BlogPage

Defined in:
lib/middleman-blog_page/version.rb,
lib/middleman-blog_page/extension_3_0.rb,
lib/middleman-blog_page/blog_page_data.rb,
lib/middleman-blog_page/blog_page_article.rb

Defined Under Namespace

Modules: BlogPageArticle, Helpers Classes: BlogPageData, Options

Constant Summary collapse

VERSION =
"0.0.3"

Class Method Summary collapse

Class Method Details

.registered(app, options_hash = {}) {|options| ... } ⇒ Object Also known as: included

Yields:

  • (options)


24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# 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