class Middleman::Sitemap::Extensions::RequestEndpoints::EndpointManager
Manages the list of proxy configurations and manipulates the sitemap to include new resources based on those configurations
Public Class Methods
new(app)
click to toggle source
# File lib/middleman-core/sitemap/extensions/request_endpoints.rb, line 29 def initialize(app) @app = app @endpoints = {} end
Public Instance Methods
create_endpoint(path, opts={}, &block)
click to toggle source
Setup a proxy from a path to a target @param [String] path @param [Hash] opts The :path value gives a request path if it differs from the output path
# File lib/middleman-core/sitemap/extensions/request_endpoints.rb, line 38 def create_endpoint(path, opts={}, &block) endpoint = { request_path: path } if block_given? endpoint[:output] = block else endpoint[:request_path] = opts[:path] if opts.key?(:path) end @endpoints[path] = endpoint @app.sitemap.rebuild_resource_list!(:added_endpoint) end
manipulate_resource_list(resources)
click to toggle source
Update the main sitemap resource list @return [void]
# File lib/middleman-core/sitemap/extensions/request_endpoints.rb, line 56 def manipulate_resource_list(resources) resources + @endpoints.map do |path, config| r = EndpointResource.new( @app.sitemap, path, config[:request_path] ) r.output = config[:output] if config.key?(:output) r end end