Sha256: 5425b9a60683c0211f59f941a05d22d929f45d130fdb701d6f88c38d5809bac9

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

module Octopress
  module Ink
    class Page < Jekyll::Page

      # Override the destination for a page
      #
      # url - Path relative to destination directory.
      #       examples: 
      #         - '/' for the _site/index.html page
      #         - '/archive/' for the _site/archive/index.html page
      #
      def initialize(site, base, dir, name, config)
        @plugin_config = config
        super(site, base, dir, name)
      end

      def destination(dest)
        path = File.join(dest, self.url)
        if self.url =~ /\/$/
          if self.ext == '.xml'
            path = File.join(path, "index.xml")
          else
            path = File.join(path, "index.html")
          end
        end
        path
      end

      # Allow pages to read url from plugin configuration
      #
      def url
        if @url
          @url
        else
          begin
            if path_config = self.data['url_config']
              config = @plugin_config
              path_config.split('.').each { |key| config = config[key] }
              @url = config if config.is_a? String
            end
          rescue; end
          super
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
octopress-ink-1.0.0.alpha.33 lib/octopress-ink/jekyll/page.rb
octopress-ink-1.0.0.alpha.32 lib/octopress-ink/jekyll/page.rb