Class: Middleman::VersionsExtension

Inherits:
Extension
  • Object
show all
Defined in:
lib/middleman/versions/extension.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, options_hash = {}, &block) ⇒ VersionsExtension

Returns a new instance of VersionsExtension.



8
9
10
# File 'lib/middleman/versions/extension.rb', line 8

def initialize(app, options_hash={}, &block)
  super
end

Instance Method Details

#after_configurationObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/middleman/versions/extension.rb', line 13

def after_configuration
  app.config[:versions_options] = options
  versions_list = options.versions.map{|x| x[:decorated_name]}
  versions_paths = options.versions.map{|x| x[:decorated_name] + "/" + options.destination_template}

  options.versions.each do |version|
    full_version_path = options.versions_path + version[:path]
    version_data = Versions::FileHandler::load_file(full_version_path)
    current_path = "#{version[:decorated_name]}/#{options.destination_template}"

    app.proxy "#{current_path}", "/#{options.origin_template}",
    :locals => {
      :versions_paths => versions_paths,
      :versions_list => versions_list,
      :version_data => version_data ,
      :current_version => version[:decorated_name],
      :current_path => "#{current_path}"
      },
    :ignore => true
  end
end