Class: Middleman::Blog::AliasResource

Inherits:
Sitemap::Resource
  • Object
show all
Defined in:
lib/middleman-blog/alias_pages.rb

Overview

A resource that generates redirect HTML for alias pages

Instance Method Summary collapse

Constructor Details

#initialize(store, path, target_url, alias_resource) ⇒ AliasResource

Returns a new instance of AliasResource.



110
111
112
113
114
# File 'lib/middleman-blog/alias_pages.rb', line 110

def initialize(store, path, target_url, alias_resource)
  @target_url = target_url
  @alias_resource = alias_resource
  super(store, path)
end

Instance Method Details

#binary?Boolean

Returns:



144
145
146
# File 'lib/middleman-blog/alias_pages.rb', line 144

def binary?
  false
end

#ignored?Boolean

Returns:



152
153
154
# File 'lib/middleman-blog/alias_pages.rb', line 152

def ignored?
  false
end

#metadataObject



156
157
158
# File 'lib/middleman-blog/alias_pages.rb', line 156

def 
  @alias_resource.
end

#raw_dataObject



148
149
150
# File 'lib/middleman-blog/alias_pages.rb', line 148

def raw_data
  @alias_resource.raw_data
end

#render(*args, &block) ⇒ Object



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/middleman-blog/alias_pages.rb', line 124

def render(*args, &block)
  %[
    <html>
      <head>
        <link rel="canonical" href="#{@target_url}" />
        <meta name="robots" content="noindex,follow" />
        <meta http-equiv="cache-control" content="no-cache" />
        <script>
          // Attempt to keep search and hash
          window.location.replace("#{@target_url}"+window.location.search+window.location.hash);
        </script>
        <meta http-equiv=refresh content="0; url=#{@target_url}" />
      </head>
      <body>
        <a href="#{@target_url}">You are being redirected.</a>
      </body>
    </html>
  ]
end

#source_fileObject



116
117
118
# File 'lib/middleman-blog/alias_pages.rb', line 116

def source_file
  @alias_resource.source_file
end

#template?Boolean

Returns:



120
121
122
# File 'lib/middleman-blog/alias_pages.rb', line 120

def template?
  false
end