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

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

Constant Summary

Constants inherited from Resource

Resource::FILTER, Resource::MAYBE_METADATA_CONTRACT, Resource::METADATA_CONTRACT

Constants included from Contracts

Contracts::ImmutableSetOf, Contracts::ImmutableSortedSetOf, Contracts::OldResourceList, Contracts::PATH_MATCHER, Contracts::ResourceList, Contracts::VectorOf

Instance Attribute Summary collapse

Attributes inherited from Resource

#app, #destination_path, #file_descriptor, #path, #priority, #vertices

Instance Method Summary collapse

Methods inherited from Resource

#<=>, #Any, #Bool, #Hash, #String, #add_filter, #add_metadata, #add_metadata_locals, #add_metadata_options, #add_metadata_page, #binary?, #content_type, #data, #ext, #ignore!, #locals, #metadata, #normalized_path, #options, #page, #page_id, #proxy_to, #render_without_filters, #source_file, #static_file?, #to_s, #url

Methods included from Traversal

#children, #directory_index?, #eponymous_directory?, #eponymous_directory_path, #parent, #parent_helper, #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 'middleman-core/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 'middleman-core/lib/middleman-core/sitemap/extensions/redirects.rb', line 39

def output
  @output
end

Instance Method Details

#ignored?Boolean

Returns:

  • (Boolean)

77
78
79
# File 'middleman-core/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 'middleman-core/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 'middleman-core/lib/middleman-core/sitemap/extensions/redirects.rb', line 48

def template?
  true
end