codemac / hriki

The Happily Ruby Ikiwiki Clone

This URL has Read+Write access

hriki / hriki / page.rb
100644 22 lines (20 sloc) 0.731 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
require 'lib/haml'
require 'lib/maruku'
require 'hriki/config'
require 'hriki/preprocess'
 
module Hriki
  class Page
    def initialize(path)
      @srcfile = File.new(File.expand_path(path))
      @destfile = File.new(File.expand_path(
                                           File.join(
                                                     Config.destdir,
                                                     File.basename(path, Config.srcext)
                                                     ) + Config.htmlext), "w")
      preproc = PreProcess.run_plugins(File.read(path))
      mdwnsrc = Maruku.new(preproc.to_s).to_html
      hengine = Haml::Engine.new(mdwnsrc)
      @destfile.write(hengine.to_html)
    end
  end
end