class Majek::Application

Constants

MATCH_TITLE

Public Class Methods

new(argv) click to toggle source
# File lib/majek/application.rb, line 5
def initialize(argv)
  if argv.empty?
    @markdown = STDIN.read
    @base_dir = nil
  else
    filename = argv.first
    @markdown = File.read(filename)
    @base_dir = File.dirname(File.expand_path(filename))
  end
end

Public Instance Methods

run() click to toggle source
# File lib/majek/application.rb, line 16
def run
  match = @markdown.match(MATCH_TITLE)
  title = match ? match[1] : 'New Post'
  content = @markdown.sub(MATCH_TITLE, '').sub(/\n*/, '')

  tp = MdInc::TextProcessor.new(:base_dir => @base_dir)
  content = tp.process(content)

  # TODO make variables configurable
  page = JekyllPage.new content, :layout => 'post', :title => "\"#{title}\""
  puts page.render
end