Sha256: e5227414ce4ba406caed1aaa3b4d2aaaea44f88ea8dbe33ce258f58b0d42ae2a

Contents?: true

Size: 838 Bytes

Versions: 3

Compression:

Stored size: 838 Bytes

Contents

# coding: utf-8
require 'pathname'
require 'date'
require 'json'
require 'time'

module WriteDown
  module Model
    # 代表博文
    class Post < Base

      def render
        template_file = File.expand_path('../../erb/post.erb', __FILE__)
        template = File.read(template_file)
        html_string = ERB.new(template).result(binding)
      end

      def build
        Layout.new(self, @target_file).render
        self
      end

      # 概览
      def summary
        @meta['summary']
      end

      # 标题
      def title
        @meta['title']
      end

      # 生成的链接
      def url
        if @draft
          "posts/drafts/#{@base_name}/index.html"
        else
          "posts/#{@base_name}/index.html"
        end
      end

      def link_to
        "posts/#{@base_name}/"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
write_down-0.2.2 lib/write_down/model/post.rb
write_down-0.2.1 lib/write_down/model/post.rb
write_down-0.2.0 lib/write_down/model/post.rb