Class: BuntoRedirectFrom::RedirectPage
- Inherits:
-
Bunto::Page
- Object
- Bunto::Page
- BuntoRedirectFrom::RedirectPage
- Defined in:
- lib/bunto-redirect-from/redirect_page.rb
Instance Method Summary collapse
- #generate_redirect_content(item_url) ⇒ Object
-
#initialize(site, base, dir, name) ⇒ RedirectPage
constructor
Initialize a new RedirectPage.
Constructor Details
#initialize(site, base, dir, name) ⇒ RedirectPage
Initialize a new RedirectPage.
site - The Site object. base - The String path to the source. dir - The String path between the source and the file. name - The String filename of the file.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/bunto-redirect-from/redirect_page.rb', line 11 def initialize(site, base, dir, name) @site = site @base = base @dir = dir @name = name self.process(name) self.data = { "layout" => nil, "sitemap" => false } data.default_proc = proc do |_, key| site.frontmatter_defaults.find(File.join(dir, name), type, key) end Bunto::Hooks.trigger :pages, :post_init, self if BuntoRedirectFrom.bunto_3? end |
Instance Method Details
#generate_redirect_content(item_url) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/bunto-redirect-from/redirect_page.rb', line 27 def generate_redirect_content(item_url) self.output = self.content = <<-EOF <!DOCTYPE html> <html lang="en-US"> <meta charset="utf-8"> <title>Redirecting…</title> <link rel="canonical" href="#{item_url}"> <meta http-equiv="refresh" content="0; url=#{item_url}"> <h1>Redirecting…</h1> <a href="#{item_url}">Click here if you are not redirected.</a> <script>location="#{item_url}"</script> </html> EOF end |