Module: Middleman::Sitemap::Extensions::Proxies::ResourceInstanceMethods
- Defined in:
- lib/middleman-core/sitemap/extensions/proxies.rb
Instance Method Summary collapse
- #get_source_file ⇒ Object
-
#proxied_to ⇒ String
The path of the page this page is proxied to, or nil if it’s not proxied.
-
#proxy? ⇒ Boolean
Whether this page is a proxy.
-
#proxy_to(target) ⇒ void
Set this page to proxy to a target path.
-
#template? ⇒ Boolean
Whether this page has a template file.
Instance Method Details
#get_source_file ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/middleman-core/sitemap/extensions/proxies.rb', line 55 def get_source_file if proxy? 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.source_file 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 |
#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 |
#template? ⇒ Boolean
Whether this page has a template file
47 48 49 50 51 52 53 |
# File 'lib/middleman-core/sitemap/extensions/proxies.rb', line 47 def template? if proxy? store.find_resource_by_path(proxied_to).template? else super end end |