Class: Middleman::BlogExtension
- Inherits:
-
Extension
- Object
- Extension
- Middleman::BlogExtension
- Defined in:
- lib/middleman-blog/extension_3_1.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#uid ⇒ Object
Returns the value of attribute uid.
Instance Method Summary collapse
- #after_configuration ⇒ Object
-
#initialize(app, options_hash = {}, &block) ⇒ BlogExtension
constructor
A new instance of BlogExtension.
Constructor Details
#initialize(app, options_hash = {}, &block) ⇒ BlogExtension
Returns a new instance of BlogExtension.
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 |
# File 'lib/middleman-blog/extension_3_1.rb', line 30 def initialize(app, ={}, &block) super @uid = .name require 'middleman-blog/blog_data' require 'middleman-blog/blog_article' require 'active_support/core_ext/time/zones' # app.set :time_zone, 'UTC' # optional: :tag_template # optional: :year_template # optional: :month_template # optional: :day_template # Allow one setting to set all the calendar templates if .calendar_template .year_template ||= .calendar_template .month_template ||= .calendar_template .day_template ||= .calendar_template end # If "prefix" option is specified, all other paths are relative to it. if .prefix .prefix = "/#{.prefix}" unless .prefix.start_with? '/' .permalink = File.join(.prefix, .permalink) .sources = File.join(.prefix, .sources) .taglink = File.join(.prefix, .taglink) .year_link = File.join(.prefix, .year_link) .month_link = File.join(.prefix, .month_link) .day_link = File.join(.prefix, .day_link) end end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
28 29 30 |
# File 'lib/middleman-blog/extension_3_1.rb', line 28 def data @data end |
#uid ⇒ Object
Returns the value of attribute uid.
28 29 30 |
# File 'lib/middleman-blog/extension_3_1.rb', line 28 def uid @uid end |
Instance Method Details
#after_configuration ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/middleman-blog/extension_3_1.rb', line 64 def after_configuration @uid ||= "blog#{@app.blog_instances.keys.length}" @app.ignore(.calendar_template) if .calendar_template @app.ignore(.year_template) if .year_template @app.ignore(.month_template) if .month_template @app.ignore(.day_template) if .day_template @app.blog_instances[@uid.to_sym] = self # 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 = app.config[:time_zone] if app.config[: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 @data = ::Middleman::Blog::BlogData.new(@app, , self) @app.sitemap.register_resource_list_manipulator( :"blog_#{uid}_articles", @data, false ) if .tag_template @app.ignore .tag_template require 'middleman-blog/tag_pages' @app.sitemap.register_resource_list_manipulator( :"blog_#{uid}_tags", ::Middleman::Blog::TagPages.new(@app, self), false ) end if .year_template || .month_template || .day_template require 'middleman-blog/calendar_pages' @app.sitemap.register_resource_list_manipulator( :"blog_#{uid}_calendar", ::Middleman::Blog::CalendarPages.new(@app, self), false ) end if .paginate require 'middleman-blog/paginator' @app.sitemap.register_resource_list_manipulator( :"blog_#{uid}_paginate", ::Middleman::Blog::Paginator.new(@app, self), false ) end end |