Class: Middleman::Sitemap::Extensions::RedirectResource
- Defined in:
- lib/middleman-core/sitemap/extensions/redirects.rb
Constant Summary
Constants inherited from Resource
Constants included from Contracts
Instance Attribute Summary collapse
-
#output ⇒ Object
Returns the value of attribute output.
Attributes inherited from Resource
#destination_path, #file_descriptor, #ignored, #metadata, #path
Instance Method Summary collapse
- #ignored? ⇒ Boolean
-
#initialize(store, path, target) ⇒ RedirectResource
constructor
A new instance of RedirectResource.
- #render ⇒ Object
- #template? ⇒ Boolean
Methods inherited from Resource
#Any, #Bool, #Hash, #METADATA_HASH, #String, #add_metadata, #binary?, #content_type, #data, #ext, #ignore!, #indifferent_access?, #locals, #normalized_path, #options, #page_id, #proxy_to, #source_file, #to_s, #url
Methods included from Traversal
#children, #directory_index?, #eponymous_directory?, #eponymous_directory_path, #parent, #siblings, #traversal_root
Methods included from Contracts
Constructor Details
#initialize(store, path, target) ⇒ RedirectResource
Returns a new instance of RedirectResource.
41 42 43 44 45 |
# File 'lib/middleman-core/sitemap/extensions/redirects.rb', line 41 def initialize(store, path, target) @request_path = target super(store, path) end |
Instance Attribute Details
#output ⇒ Object
Returns the value of attribute output.
39 40 41 |
# File 'lib/middleman-core/sitemap/extensions/redirects.rb', line 39 def output @output end |
Instance Method Details
#ignored? ⇒ Boolean
77 78 79 |
# File 'lib/middleman-core/sitemap/extensions/redirects.rb', line 77 def ignored? false end |
#render ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/middleman-core/sitemap/extensions/redirects.rb', line 53 def render(*) url = ::Middleman::Util.url_for(@store.app, @request_path, relative: false, find_resource: true) if output output.call(path, url) else <<-END <html> <head> <link rel="canonical" href="#{url}" /> <meta http-equiv=refresh content="0; url=#{url}" /> <meta name="robots" content="noindex,follow" /> <meta http-equiv="cache-control" content="no-cache" /> </head> <body> </body> </html> END end end |
#template? ⇒ Boolean
48 49 50 |
# File 'lib/middleman-core/sitemap/extensions/redirects.rb', line 48 def template? true end |