Sha256: 86c8d8168abd9ecbb64502359c309250c15a27e719a882c969af9a937d064084

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

module Octopress
  module Ink
    class Page < Jekyll::Page
      include Ink::Convertible
      attr_reader :asset, :plugin

      # Purpose: Configs can override a page's permalink
      #
      # 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, asset)
        @asset = asset
        @plugin = asset.plugin
        super(site, base, dir, name)
      end

      def destination(dest)
        unless @dest
          @dest = File.join(dest, self.url)
        end
        @dest
      end

      def relative_asset_path
        site_source = Pathname.new Octopress.site.source
        page_source = Pathname.new @base
        page_source.relative_path_from(site_source).to_s
      end

      # Allow pages to read url from plugin configuration
      #
      def url
        @url ||= begin
          @asset.permalink ||= self.data['permalink']
          url = @asset.permalink

          super

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

          url
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
octopress-ink-1.0.0.rc.40 lib/octopress-ink/jekyll/page.rb
octopress-ink-1.0.0.rc.39 lib/octopress-ink/jekyll/page.rb