Class: Middleman::Sitemap::Extensions::RedirectResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/middleman-core/sitemap/extensions/redirects.rb

Constant Summary

Constants inherited from Resource

Resource::METADATA_HASH

Constants included from Contracts

Contracts::PATH_MATCHER

Instance Attribute Summary collapse

Attributes inherited from Resource

#destination_path, #file_descriptor, #ignored, #metadata, #path

Instance Method Summary collapse

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

#Contract

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

#outputObject

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

Returns:

  • (Boolean)


77
78
79
# File 'lib/middleman-core/sitemap/extensions/redirects.rb', line 77

def ignored?
  false
end

#renderObject



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

Returns:

  • (Boolean)


48
49
50
# File 'lib/middleman-core/sitemap/extensions/redirects.rb', line 48

def template?
  true
end