Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding tags to Typo and forcing their encoding to UTF-8 #11

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/jekyll/importers/typo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module Typo
c.body body,
c.published_at date,
c.state state,
c.keywords keywords,
COALESCE(tf.name, 'html') filter
FROM contents c
LEFT OUTER JOIN text_filters tf
Expand All @@ -25,7 +26,7 @@ def self.process dbname, user, pass, host='localhost'
FileUtils.mkdir_p '_posts'
db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host, :encoding => 'utf8')
db[SQL].each do |post|
next unless post[:state] =~ /published/
next unless post[:state] =~ /published/i

name = [ sprintf("%.04d", post[:date].year),
sprintf("%.02d", post[:date].month),
Expand All @@ -38,7 +39,8 @@ def self.process dbname, user, pass, host='localhost'

File.open("_posts/#{name}", 'w') do |f|
f.puts({ 'layout' => 'post',
'title' => post[:title].to_s,
'title' => (post[:title] and post[:title].to_s.force_encoding('UTF-8')),
'tags' => (post[:keywords] and post[:keywords].to_s.force_encoding('UTF-8')),
'typo_id' => post[:id]
}.delete_if { |k, v| v.nil? || v == '' }.to_yaml)
f.puts '---'
Expand All @@ -48,4 +50,4 @@ def self.process dbname, user, pass, host='localhost'
end

end
end
end