lib/jekyll/converters/textpattern.rb in matflores-jekyll-0.4.3 vs lib/jekyll/converters/textpattern.rb in matflores-jekyll-0.5.0
- old
+ new
@@ -16,23 +16,23 @@
# Other statuses is 1 => draft, 2 => hidden and 3 => pending
QUERY = "select Title, url_title, Posted, Body, Keywords from textpattern where Status = '4' or Status = '5'"
def self.process(dbname, user, pass, host = 'localhost')
db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host)
-
+
FileUtils.mkdir_p "_posts"
-
+
db[QUERY].each do |post|
# Get required fields and construct Jekyll compatible name
title = post[:Title]
slug = post[:url_title]
date = post[:Posted]
content = post[:Body]
-
+
name = [date.strftime("%Y-%m-%d"), slug].join('-') + ".textile"
# Get the relevant fields as a hash, delete empty fields and convert
- # to YAML for the header
+ # to YAML for the header
data = {
'layout' => 'post',
'title' => title.to_s,
'tags' => post[:Keywords].split(',')
}.delete_if { |k,v| v.nil? || v == ''}.to_yaml
\ No newline at end of file