Sha256: fdad4697bdd40accb705a6c6a45bb3bbe4040dda964b63e1bad28911cee61d56

Contents?: true

Size: 1.32 KB

Versions: 30

Compression:

Stored size: 1.32 KB

Contents

require 'awestruct/handler_chain'
require 'awestruct/handlers/base_handler'
require 'awestruct/handlers/file_handler'
require 'awestruct/handlers/front_matter_handler'
require 'awestruct/handlers/interpolation_handler'

module Awestruct
  module Handlers
    class RedirectHandler < BaseHandler


      CHAIN = Awestruct::HandlerChain.new( /\.redirect$/,
        Awestruct::Handlers::FileHandler,
        Awestruct::Handlers::FrontMatterHandler,
        Awestruct::Handlers::InterpolationHandler,
        Awestruct::Handlers::RedirectHandler
      )

      def initialize(site, delegate)
        super( site, delegate )
      end

      def simple_name
        File.basename( relative_source_path, '.redirect' ) 
      end

      def output_filename
        simple_name + output_extension
      end

      def output_extension
        '.html'
      end

      def content_syntax
        :text
      end

      def rendered_content(context, with_layouts=false)
        url = delegate.rendered_content( context, with_layouts ).strip
        # should we auto-qualify the URL?
        # they can use #{site.base_url}/path currently
        #if url.start_with? '/'
        #  url = File.join(@site.base_url, url)
        #end
        %{<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0;url=#{url}"></head></html>}
      end

    end
  end
end


Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
awestruct-0.6.0.alpha4 lib/awestruct/handlers/redirect_handler.rb
awestruct-0.6.0.alpha3 lib/awestruct/handlers/redirect_handler.rb
awestruct-0.6.0.alpha1 lib/awestruct/handlers/redirect_handler.rb
awestruct-0.5.7 lib/awestruct/handlers/redirect_handler.rb
awestruct-0.5.7.RC2 lib/awestruct/handlers/redirect_handler.rb
awestruct-0.5.7.RC1 lib/awestruct/handlers/redirect_handler.rb
awestruct-0.5.6 lib/awestruct/handlers/redirect_handler.rb
awestruct-0.5.6.beta9 lib/awestruct/handlers/redirect_handler.rb
awestruct-0.5.6.beta8 lib/awestruct/handlers/redirect_handler.rb
awestruct-0.5.6.beta7 lib/awestruct/handlers/redirect_handler.rb
awestruct-0.5.6.beta6 lib/awestruct/handlers/redirect_handler.rb
awestruct-0.5.6.beta5 lib/awestruct/handlers/redirect_handler.rb
awestruct-0.5.6.beta4 lib/awestruct/handlers/redirect_handler.rb
awestruct-0.5.6.beta3 lib/awestruct/handlers/redirect_handler.rb
awestruct-0.5.6.beta2 lib/awestruct/handlers/redirect_handler.rb
awestruct-0.5.6.beta lib/awestruct/handlers/redirect_handler.rb
awestruct-0.5.5 lib/awestruct/handlers/redirect_handler.rb
awestruct-0.5.4.2 lib/awestruct/handlers/redirect_handler.rb
awestruct-0.5.4.1 lib/awestruct/handlers/redirect_handler.rb
awestruct-0.5.4 lib/awestruct/handlers/redirect_handler.rb