Module: Middleman::Sitemap::Extensions::Proxies::ResourceInstanceMethods
- Defined in:
- lib/middleman-core/sitemap/extensions/proxies.rb
Instance Method Summary collapse
- #content_type ⇒ Object
- #get_source_file ⇒ Object
-
#proxied_to ⇒ String
The path of the page this page is proxied to, or nil if it’s not proxied.
-
#proxied_to_resource ⇒ Sitemap::Resource
The resource for the page this page is proxied to.
-
#proxy? ⇒ Boolean
Whether this page is a proxy.
-
#proxy_to(target) ⇒ void
Set this page to proxy to a target path.
Instance Method Details
#content_type ⇒ Object
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/middleman-core/sitemap/extensions/proxies.rb', line 70 def content_type mime_type = super return mime_type if mime_type if proxy? proxied_to_resource.content_type else nil end end |
#get_source_file ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/middleman-core/sitemap/extensions/proxies.rb', line 62 def get_source_file if proxy? proxied_to_resource.source_file else super end end |
#proxied_to ⇒ String
The path of the page this page is proxied to, or nil if it’s not proxied.
41 42 43 |
# File 'lib/middleman-core/sitemap/extensions/proxies.rb', line 41 def proxied_to @proxied_to end |
#proxied_to_resource ⇒ Sitemap::Resource
The resource for the page this page is proxied to. Throws an exception if there is no resource.
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/middleman-core/sitemap/extensions/proxies.rb', line 48 def proxied_to_resource proxy_resource = store.find_resource_by_path(proxied_to) unless proxy_resource raise "Path #{path} proxies to unknown file #{proxied_to}:#{store.resources.map(&:path)}" end if proxy_resource.proxy? raise "You can't proxy #{path} to #{proxied_to} which is itself a proxy." end proxy_resource end |
#proxy? ⇒ Boolean
Whether this page is a proxy
26 27 28 |
# File 'lib/middleman-core/sitemap/extensions/proxies.rb', line 26 def proxy? !!@proxied_to end |
#proxy_to(target) ⇒ void
This method returns an undefined value.
Set this page to proxy to a target path
33 34 35 36 37 |
# File 'lib/middleman-core/sitemap/extensions/proxies.rb', line 33 def proxy_to(target) target = ::Middleman::Util.normalize_path(target) raise "You can't proxy #{path} to itself!" if target == path @proxied_to = target end |