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.



95
96
97
98
# File 'lib/middleman-core/sitemap/extensions/proxies.rb', line 95

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



121
122
123
124
125
126
127
128
129
130
131
# File 'lib/middleman-core/sitemap/extensions/proxies.rb', line 121

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.



106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/middleman-core/sitemap/extensions/proxies.rb', line 106

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