Class: Middleman::Sitemap::Extensions::Proxies::ProxyManager

Inherits:
Object
  • Object
show all
Defined in:
lib/middleman-core/sitemap/extensions/proxies.rb

Overview

Manages the list of proxy configurations and manipulates the sitemap to include new resources based on those configurations

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ProxyManager

Returns a new instance of ProxyManager.



85
86
87
88
# File 'lib/middleman-core/sitemap/extensions/proxies.rb', line 85

def initialize(app)
  @app = app
  @proxy_configs = Set.new
end

Instance Method Details

#manipulate_resource_list(resources) ⇒ void

This method returns an undefined value.

Update the main sitemap resource list



111
112
113
114
115
116
117
118
119
120
121
# File 'lib/middleman-core/sitemap/extensions/proxies.rb', line 111

def manipulate_resource_list(resources)
  resources + @proxy_configs.map do |config|
    p = ::Middleman::Sitemap::Resource.new(
      @app.sitemap,
      config.path
    )
    p.proxy_to(config.target)
    p.(config.)
    p
  end
end

#proxy(path, target, opts = {}, &block) ⇒ void

This method returns an undefined value.

Setup a proxy from a path to a target

Parameters:

  • path (String)
  • target (String)
  • opts (Hash) (defaults to: {})

    options to apply to the proxy, including things like :locals, :ignore to hide the proxy target, :layout, and :directory_indexes.



96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/middleman-core/sitemap/extensions/proxies.rb', line 96

def proxy(path, target, opts={}, &block)
   = { :options => {}, :locals => {}, :blocks => [] }
  [:blocks] << block if block_given?
  [:locals] = opts.delete(:locals) || {}

  @app.ignore(target) if opts.delete(:ignore)
  [:options] = opts

  @proxy_configs << ProxyConfiguration.new(:path => path, :target => target, :metadata => )

  @app.sitemap.rebuild_resource_list!(:added_proxy)
end