jekyll 0.12.1 → 1.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of jekyll might be problematic. Click here for more details.
- data/CONTRIBUTING.md +67 -0
- data/Gemfile +1 -1
- data/History.txt +50 -6
- data/README.textile +10 -6
- data/Rakefile +74 -36
- data/bin/jekyll +78 -276
- data/cucumber.yml +3 -1
- data/features/create_sites.feature +1 -1
- data/features/drafts.feature +25 -0
- data/features/site_configuration.feature +1 -1
- data/features/step_definitions/jekyll_steps.rb +13 -3
- data/features/support/env.rb +3 -1
- data/jekyll.gemspec +73 -17
- data/lib/jekyll.rb +31 -21
- data/lib/jekyll/command.rb +12 -0
- data/lib/jekyll/commands/build.rb +81 -0
- data/lib/jekyll/commands/serve.rb +28 -0
- data/lib/jekyll/converter.rb +1 -3
- data/lib/jekyll/converters/identity.rb +13 -14
- data/lib/jekyll/converters/markdown.rb +128 -128
- data/lib/jekyll/converters/textile.rb +37 -37
- data/lib/jekyll/convertible.rb +6 -4
- data/lib/jekyll/core_ext.rb +9 -1
- data/lib/jekyll/draft.rb +35 -0
- data/lib/jekyll/errors.rb +1 -3
- data/lib/jekyll/filters.rb +13 -4
- data/lib/jekyll/generator.rb +1 -4
- data/lib/jekyll/generators/pagination.rb +46 -46
- data/lib/jekyll/layout.rb +0 -2
- data/lib/jekyll/mime.types +1588 -0
- data/lib/jekyll/page.rb +24 -8
- data/lib/jekyll/plugin.rb +0 -2
- data/lib/jekyll/post.rb +66 -40
- data/lib/jekyll/site.rb +96 -20
- data/lib/jekyll/static_file.rb +0 -2
- data/lib/jekyll/tags/gist.rb +19 -0
- data/lib/jekyll/tags/highlight.rb +63 -62
- data/lib/jekyll/tags/include.rb +25 -25
- data/lib/jekyll/tags/post_url.rb +30 -25
- data/script/bootstrap +2 -0
- data/site/.gitignore +4 -0
- data/site/CNAME +1 -0
- data/site/README +1 -0
- data/site/_config.yml +5 -0
- data/site/_includes/analytics.html +32 -0
- data/site/_includes/docs_contents.html +82 -0
- data/site/_includes/footer.html +15 -0
- data/site/_includes/header.html +26 -0
- data/site/_includes/section_nav.html +22 -0
- data/site/_includes/top.html +14 -0
- data/site/_layouts/default.html +12 -0
- data/site/_layouts/docs.html +21 -0
- data/site/_posts/2012-07-01-configuration.md +277 -0
- data/site/_posts/2012-07-01-contributing.md +66 -0
- data/site/_posts/2012-07-01-deployment-methods.md +108 -0
- data/site/_posts/2012-07-01-extras.md +103 -0
- data/site/_posts/2012-07-01-frontmatter.md +120 -0
- data/site/_posts/2012-07-01-github-pages.md +34 -0
- data/site/_posts/2012-07-01-heroku.md +8 -0
- data/site/_posts/2012-07-01-home.md +47 -0
- data/site/_posts/2012-07-01-installation.md +43 -0
- data/site/_posts/2012-07-01-migrations.md +180 -0
- data/site/_posts/2012-07-01-pages.md +62 -0
- data/site/_posts/2012-07-01-pagination.md +116 -0
- data/site/_posts/2012-07-01-permalinks.md +163 -0
- data/site/_posts/2012-07-01-plugins.md +384 -0
- data/site/_posts/2012-07-01-posts.md +106 -0
- data/site/_posts/2012-07-01-resources.md +49 -0
- data/site/_posts/2012-07-01-sites.md +28 -0
- data/site/_posts/2012-07-01-structure.md +95 -0
- data/site/_posts/2012-07-01-templates.md +217 -0
- data/site/_posts/2012-07-01-troubleshooting.md +108 -0
- data/site/_posts/2012-07-01-usage.md +38 -0
- data/site/_posts/2012-07-01-variables.md +166 -0
- data/site/css/grid.css +62 -0
- data/site/css/normalize.css +504 -0
- data/site/css/pygments.css +70 -0
- data/site/css/style.css +697 -0
- data/site/docs/index.html +11 -0
- data/site/favicon.png +0 -0
- data/site/img/article-footer.png +0 -0
- data/site/img/footer-arrow.png +0 -0
- data/site/img/footer-logo.png +0 -0
- data/site/img/logo-2x.png +0 -0
- data/site/img/octojekyll.png +0 -0
- data/site/img/tube.png +0 -0
- data/site/img/tube1x.png +0 -0
- data/site/index.html +77 -0
- data/site/js/modernizr-2.5.3.min.js +4 -0
- data/test/fixtures/broken_front_matter2.erb +4 -0
- data/test/fixtures/broken_front_matter3.erb +7 -0
- data/test/fixtures/exploit_front_matter.erb +4 -0
- data/test/helper.rb +16 -0
- data/test/source/_posts/2013-01-12-nil-layout.textile +6 -0
- data/test/source/_posts/2013-01-12-no-layout.textile +5 -0
- data/test/source/contacts/bar.html +5 -0
- data/test/source/contacts/index.html +5 -0
- data/test/test_configuration.rb +7 -8
- data/test/test_convertible.rb +29 -0
- data/test/test_core_ext.rb +22 -0
- data/test/test_generated_site.rb +1 -1
- data/test/test_kramdown.rb +3 -3
- data/test/test_page.rb +88 -2
- data/test/test_post.rb +42 -6
- data/test/test_rdiscount.rb +1 -1
- data/test/test_redcarpet.rb +1 -1
- data/test/test_redcloth.rb +6 -6
- data/test/test_site.rb +73 -8
- data/test/test_tags.rb +36 -13
- metadata +150 -19
- data/lib/jekyll/migrators/csv.rb +0 -26
- data/lib/jekyll/migrators/drupal.rb +0 -103
- data/lib/jekyll/migrators/enki.rb +0 -49
- data/lib/jekyll/migrators/joomla.rb +0 -53
- data/lib/jekyll/migrators/marley.rb +0 -52
- data/lib/jekyll/migrators/mephisto.rb +0 -84
- data/lib/jekyll/migrators/mt.rb +0 -86
- data/lib/jekyll/migrators/posterous.rb +0 -67
- data/lib/jekyll/migrators/rss.rb +0 -47
- data/lib/jekyll/migrators/textpattern.rb +0 -58
- data/lib/jekyll/migrators/tumblr.rb +0 -195
- data/lib/jekyll/migrators/typo.rb +0 -51
- data/lib/jekyll/migrators/wordpress.rb +0 -294
- data/lib/jekyll/migrators/wordpressdotcom.rb +0 -70
data/lib/jekyll/migrators/csv.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
module Jekyll
|
2
|
-
module CSV
|
3
|
-
# Reads a csv with title, permalink, body, published_at, and filter.
|
4
|
-
# It creates a post file for each row in the csv
|
5
|
-
def self.process(file = "posts.csv")
|
6
|
-
FileUtils.mkdir_p "_posts"
|
7
|
-
posts = 0
|
8
|
-
FasterCSV.foreach(file) do |row|
|
9
|
-
next if row[0] == "title"
|
10
|
-
posts += 1
|
11
|
-
name = row[3].split(" ")[0]+"-"+row[1]+(row[4] =~ /markdown/ ? ".markdown" : ".textile")
|
12
|
-
File.open("_posts/#{name}", "w") do |f|
|
13
|
-
f.puts <<-HEADER
|
14
|
-
---
|
15
|
-
layout: post
|
16
|
-
title: #{row[0]}
|
17
|
-
---
|
18
|
-
|
19
|
-
HEADER
|
20
|
-
f.puts row[2]
|
21
|
-
end
|
22
|
-
end
|
23
|
-
"Created #{posts} posts!"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,103 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'sequel'
|
3
|
-
require 'fileutils'
|
4
|
-
require 'yaml'
|
5
|
-
|
6
|
-
# NOTE: This converter requires Sequel and the MySQL gems.
|
7
|
-
# The MySQL gem can be difficult to install on OS X. Once you have MySQL
|
8
|
-
# installed, running the following commands should work:
|
9
|
-
# $ sudo gem install sequel
|
10
|
-
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
|
11
|
-
|
12
|
-
module Jekyll
|
13
|
-
module Drupal
|
14
|
-
# Reads a MySQL database via Sequel and creates a post file for each post
|
15
|
-
# in wp_posts that has post_status = 'publish'. This restriction is made
|
16
|
-
# because 'draft' posts are not guaranteed to have valid dates.
|
17
|
-
QUERY = "SELECT n.nid, \
|
18
|
-
n.title, \
|
19
|
-
nr.body, \
|
20
|
-
n.created, \
|
21
|
-
n.status \
|
22
|
-
FROM node AS n, \
|
23
|
-
node_revisions AS nr \
|
24
|
-
WHERE (n.type = 'blog' OR n.type = 'story') \
|
25
|
-
AND n.vid = nr.vid"
|
26
|
-
|
27
|
-
def self.process(dbname, user, pass, host = 'localhost', prefix = '')
|
28
|
-
db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host, :encoding => 'utf8')
|
29
|
-
|
30
|
-
if prefix != ''
|
31
|
-
QUERY[" node "] = " " + prefix + "node "
|
32
|
-
QUERY[" node_revisions "] = " " + prefix + "node_revisions "
|
33
|
-
end
|
34
|
-
|
35
|
-
FileUtils.mkdir_p "_posts"
|
36
|
-
FileUtils.mkdir_p "_drafts"
|
37
|
-
|
38
|
-
# Create the refresh layout
|
39
|
-
# Change the refresh url if you customized your permalink config
|
40
|
-
File.open("_layouts/refresh.html", "w") do |f|
|
41
|
-
f.puts <<EOF
|
42
|
-
<!DOCTYPE html>
|
43
|
-
<html>
|
44
|
-
<head>
|
45
|
-
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
46
|
-
<meta http-equiv="refresh" content="0;url={{ page.refresh_to_post_id }}.html" />
|
47
|
-
</head>
|
48
|
-
</html>
|
49
|
-
EOF
|
50
|
-
end
|
51
|
-
|
52
|
-
db[QUERY].each do |post|
|
53
|
-
# Get required fields and construct Jekyll compatible name
|
54
|
-
node_id = post[:nid]
|
55
|
-
title = post[:title]
|
56
|
-
content = post[:body]
|
57
|
-
created = post[:created]
|
58
|
-
time = Time.at(created)
|
59
|
-
is_published = post[:status] == 1
|
60
|
-
dir = is_published ? "_posts" : "_drafts"
|
61
|
-
slug = title.strip.downcase.gsub(/(&|&)/, ' and ').gsub(/[\s\.\/\\]/, '-').gsub(/[^\w-]/, '').gsub(/[-_]{2,}/, '-').gsub(/^[-_]/, '').gsub(/[-_]$/, '')
|
62
|
-
name = time.strftime("%Y-%m-%d-") + slug + '.md'
|
63
|
-
|
64
|
-
# Get the relevant fields as a hash, delete empty fields and convert
|
65
|
-
# to YAML for the header
|
66
|
-
data = {
|
67
|
-
'layout' => 'post',
|
68
|
-
'title' => title.to_s,
|
69
|
-
'created' => created,
|
70
|
-
}.delete_if { |k,v| v.nil? || v == ''}.to_yaml
|
71
|
-
|
72
|
-
# Write out the data and content to file
|
73
|
-
File.open("#{dir}/#{name}", "w") do |f|
|
74
|
-
f.puts data
|
75
|
-
f.puts "---"
|
76
|
-
f.puts content
|
77
|
-
end
|
78
|
-
|
79
|
-
# Make a file to redirect from the old Drupal URL
|
80
|
-
if is_published
|
81
|
-
aliases = db["SELECT dst FROM #{prefix}url_alias WHERE src = ?", "node/#{node_id}"].all
|
82
|
-
|
83
|
-
aliases.push(:dst => "node/#{node_id}")
|
84
|
-
|
85
|
-
aliases.each do |url_alias|
|
86
|
-
FileUtils.mkdir_p url_alias[:dst]
|
87
|
-
File.open("#{url_alias[:dst]}/index.md", "w") do |f|
|
88
|
-
f.puts "---"
|
89
|
-
f.puts "layout: refresh"
|
90
|
-
f.puts "refresh_to_post_id: /#{time.strftime("%Y/%m/%d/") + slug}"
|
91
|
-
f.puts "---"
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
# TODO: Make dirs & files for nodes of type 'page'
|
98
|
-
# Make refresh pages for these as well
|
99
|
-
|
100
|
-
# TODO: Make refresh dirs & files according to entries in url_alias table
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
# Adapted by Rodrigo Pinto <rodrigopqn@gmail.com>
|
2
|
-
# Based on typo.rb by Toby DiPasquale
|
3
|
-
|
4
|
-
require 'fileutils'
|
5
|
-
require 'rubygems'
|
6
|
-
require 'sequel'
|
7
|
-
|
8
|
-
module Jekyll
|
9
|
-
module Enki
|
10
|
-
SQL = <<-EOS
|
11
|
-
SELECT p.id,
|
12
|
-
p.title,
|
13
|
-
p.slug,
|
14
|
-
p.body,
|
15
|
-
p.published_at as date,
|
16
|
-
p.cached_tag_list as tags
|
17
|
-
FROM posts p
|
18
|
-
EOS
|
19
|
-
|
20
|
-
# Just working with postgres, but can be easily adapted
|
21
|
-
# to work with both mysql and postgres.
|
22
|
-
def self.process(dbname, user, pass, host = 'localhost')
|
23
|
-
FileUtils.mkdir_p('_posts')
|
24
|
-
db = Sequel.postgres(:database => dbname,
|
25
|
-
:user => user,
|
26
|
-
:password => pass,
|
27
|
-
:host => host,
|
28
|
-
:encoding => 'utf8')
|
29
|
-
|
30
|
-
db[SQL].each do |post|
|
31
|
-
name = [ sprintf("%.04d", post[:date].year),
|
32
|
-
sprintf("%.02d", post[:date].month),
|
33
|
-
sprintf("%.02d", post[:date].day),
|
34
|
-
post[:slug].strip ].join('-')
|
35
|
-
name += '.textile'
|
36
|
-
|
37
|
-
File.open("_posts/#{name}", 'w') do |f|
|
38
|
-
f.puts({ 'layout' => 'post',
|
39
|
-
'title' => post[:title].to_s,
|
40
|
-
'enki_id' => post[:id],
|
41
|
-
'categories' => post[:tags]
|
42
|
-
}.delete_if { |k, v| v.nil? || v == '' }.to_yaml)
|
43
|
-
f.puts '---'
|
44
|
-
f.puts post[:body].delete("\r")
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'sequel'
|
3
|
-
require 'fileutils'
|
4
|
-
require 'yaml'
|
5
|
-
|
6
|
-
# NOTE: This migrator is made for Joomla 1.5 databases.
|
7
|
-
# NOTE: This converter requires Sequel and the MySQL gems.
|
8
|
-
# The MySQL gem can be difficult to install on OS X. Once you have MySQL
|
9
|
-
# installed, running the following commands should work:
|
10
|
-
# $ sudo gem install sequel
|
11
|
-
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
|
12
|
-
|
13
|
-
module Jekyll
|
14
|
-
module Joomla
|
15
|
-
def self.process(dbname, user, pass, host = 'localhost', table_prefix = 'jos_', section = '1')
|
16
|
-
db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host, :encoding => 'utf8')
|
17
|
-
|
18
|
-
FileUtils.mkdir_p("_posts")
|
19
|
-
|
20
|
-
# Reads a MySQL database via Sequel and creates a post file for each
|
21
|
-
# post in wp_posts that has post_status = 'publish'. This restriction is
|
22
|
-
# made because 'draft' posts are not guaranteed to have valid dates.
|
23
|
-
query = "SELECT `title`, `alias`, CONCAT(`introtext`,`fulltext`) as content, `created`, `id` FROM #{table_prefix}content WHERE state = '0' OR state = '1' AND sectionid = '#{section}'"
|
24
|
-
|
25
|
-
db[query].each do |post|
|
26
|
-
# Get required fields and construct Jekyll compatible name.
|
27
|
-
title = post[:title]
|
28
|
-
slug = post[:alias]
|
29
|
-
date = post[:created]
|
30
|
-
content = post[:content]
|
31
|
-
name = "%02d-%02d-%02d-%s.markdown" % [date.year, date.month, date.day,
|
32
|
-
slug]
|
33
|
-
|
34
|
-
# Get the relevant fields as a hash, delete empty fields and convert
|
35
|
-
# to YAML for the header.
|
36
|
-
data = {
|
37
|
-
'layout' => 'post',
|
38
|
-
'title' => title.to_s,
|
39
|
-
'joomla_id' => post[:id],
|
40
|
-
'joomla_url' => post[:alias],
|
41
|
-
'date' => date
|
42
|
-
}.delete_if { |k,v| v.nil? || v == '' }.to_yaml
|
43
|
-
|
44
|
-
# Write out the data and content to file
|
45
|
-
File.open("_posts/#{name}", "w") do |f|
|
46
|
-
f.puts data
|
47
|
-
f.puts "---"
|
48
|
-
f.puts content
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
require 'fileutils'
|
3
|
-
|
4
|
-
module Jekyll
|
5
|
-
module Marley
|
6
|
-
def self.regexp
|
7
|
-
{ :id => /^\d{0,4}-{0,1}(.*)$/,
|
8
|
-
:title => /^#\s*(.*)\s+$/,
|
9
|
-
:title_with_date => /^#\s*(.*)\s+\(([0-9\/]+)\)$/,
|
10
|
-
:published_on => /.*\s+\(([0-9\/]+)\)$/,
|
11
|
-
:perex => /^([^\#\n]+\n)$/,
|
12
|
-
:meta => /^\{\{\n(.*)\}\}\n$/mi # Multiline Regexp
|
13
|
-
}
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.process(marley_data_dir)
|
17
|
-
raise ArgumentError, "marley dir #{marley_data_dir} not found" unless File.directory?(marley_data_dir)
|
18
|
-
|
19
|
-
FileUtils.mkdir_p "_posts"
|
20
|
-
|
21
|
-
posts = 0
|
22
|
-
Dir["#{marley_data_dir}/**/*.txt"].each do |f|
|
23
|
-
next unless File.exists?(f)
|
24
|
-
|
25
|
-
#copied over from marley's app/lib/post.rb
|
26
|
-
file_content = File.read(f)
|
27
|
-
meta_content = file_content.slice!( self.regexp[:meta] )
|
28
|
-
body = file_content.sub( self.regexp[:title], '').sub( self.regexp[:perex], '').strip
|
29
|
-
|
30
|
-
title = file_content.scan( self.regexp[:title] ).first.to_s.strip
|
31
|
-
prerex = file_content.scan( self.regexp[:perex] ).first.to_s.strip
|
32
|
-
published_on = DateTime.parse( post[:published_on] ) rescue File.mtime( File.dirname(f) )
|
33
|
-
meta = ( meta_content ) ? YAML::load( meta_content.scan( self.regexp[:meta]).to_s ) : {}
|
34
|
-
meta['title'] = title
|
35
|
-
meta['layout'] = 'post'
|
36
|
-
|
37
|
-
formatted_date = published_on.strftime('%Y-%m-%d')
|
38
|
-
post_name = File.dirname(f).split(%r{/}).last.gsub(/\A\d+-/, '')
|
39
|
-
|
40
|
-
name = "#{formatted_date}-#{post_name}"
|
41
|
-
File.open("_posts/#{name}.markdown", "w") do |f|
|
42
|
-
f.puts meta.to_yaml
|
43
|
-
f.puts "---\n"
|
44
|
-
f.puts "\n#{prerex}\n\n" if prerex
|
45
|
-
f.puts body
|
46
|
-
end
|
47
|
-
posts += 1
|
48
|
-
end
|
49
|
-
"Created #{posts} posts!"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,84 +0,0 @@
|
|
1
|
-
# Quickly hacked together my Michael Ivey
|
2
|
-
# Based on mt.rb by Nick Gerakines, open source and publically
|
3
|
-
# available under the MIT license. Use this module at your own risk.
|
4
|
-
|
5
|
-
require 'rubygems'
|
6
|
-
require 'sequel'
|
7
|
-
require 'fastercsv'
|
8
|
-
require 'fileutils'
|
9
|
-
require File.join(File.dirname(__FILE__),"csv.rb")
|
10
|
-
|
11
|
-
# NOTE: This converter requires Sequel and the MySQL gems.
|
12
|
-
# The MySQL gem can be difficult to install on OS X. Once you have MySQL
|
13
|
-
# installed, running the following commands should work:
|
14
|
-
# $ sudo gem install sequel
|
15
|
-
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
|
16
|
-
|
17
|
-
module Jekyll
|
18
|
-
module Mephisto
|
19
|
-
#Accepts a hash with database config variables, exports mephisto posts into a csv
|
20
|
-
#export PGPASSWORD if you must
|
21
|
-
def self.postgres(c)
|
22
|
-
sql = <<-SQL
|
23
|
-
BEGIN;
|
24
|
-
CREATE TEMP TABLE jekyll AS
|
25
|
-
SELECT title, permalink, body, published_at, filter FROM contents
|
26
|
-
WHERE user_id = 1 AND type = 'Article' ORDER BY published_at;
|
27
|
-
COPY jekyll TO STDOUT WITH CSV HEADER;
|
28
|
-
ROLLBACK;
|
29
|
-
SQL
|
30
|
-
command = %Q(psql -h #{c[:host] || "localhost"} -c "#{sql.strip}" #{c[:database]} #{c[:username]} -o #{c[:filename] || "posts.csv"})
|
31
|
-
puts command
|
32
|
-
`#{command}`
|
33
|
-
CSV.process
|
34
|
-
end
|
35
|
-
|
36
|
-
# This query will pull blog posts from all entries across all blogs. If
|
37
|
-
# you've got unpublished, deleted or otherwise hidden posts please sift
|
38
|
-
# through the created posts to make sure nothing is accidently published.
|
39
|
-
QUERY = "SELECT id, \
|
40
|
-
permalink, \
|
41
|
-
body, \
|
42
|
-
published_at, \
|
43
|
-
title \
|
44
|
-
FROM contents \
|
45
|
-
WHERE user_id = 1 AND \
|
46
|
-
type = 'Article' AND \
|
47
|
-
published_at IS NOT NULL \
|
48
|
-
ORDER BY published_at"
|
49
|
-
|
50
|
-
def self.process(dbname, user, pass, host = 'localhost')
|
51
|
-
db = Sequel.mysql(dbname, :user => user,
|
52
|
-
:password => pass,
|
53
|
-
:host => host,
|
54
|
-
:encoding => 'utf8')
|
55
|
-
|
56
|
-
FileUtils.mkdir_p "_posts"
|
57
|
-
|
58
|
-
db[QUERY].each do |post|
|
59
|
-
title = post[:title]
|
60
|
-
slug = post[:permalink]
|
61
|
-
date = post[:published_at]
|
62
|
-
content = post[:body]
|
63
|
-
|
64
|
-
# Ideally, this script would determine the post format (markdown,
|
65
|
-
# html, etc) and create files with proper extensions. At this point
|
66
|
-
# it just assumes that markdown will be acceptable.
|
67
|
-
name = [date.year, date.month, date.day, slug].join('-') + ".markdown"
|
68
|
-
|
69
|
-
data = {
|
70
|
-
'layout' => 'post',
|
71
|
-
'title' => title.to_s,
|
72
|
-
'mt_id' => post[:entry_id],
|
73
|
-
}.delete_if { |k,v| v.nil? || v == ''}.to_yaml
|
74
|
-
|
75
|
-
File.open("_posts/#{name}", "w") do |f|
|
76
|
-
f.puts data
|
77
|
-
f.puts "---"
|
78
|
-
f.puts content
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
data/lib/jekyll/migrators/mt.rb
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
# Created by Nick Gerakines, open source and publically available under the
|
2
|
-
# MIT license. Use this module at your own risk.
|
3
|
-
# I'm an Erlang/Perl/C++ guy so please forgive my dirty ruby.
|
4
|
-
|
5
|
-
require 'rubygems'
|
6
|
-
require 'sequel'
|
7
|
-
require 'fileutils'
|
8
|
-
require 'yaml'
|
9
|
-
|
10
|
-
# NOTE: This converter requires Sequel and the MySQL gems.
|
11
|
-
# The MySQL gem can be difficult to install on OS X. Once you have MySQL
|
12
|
-
# installed, running the following commands should work:
|
13
|
-
# $ sudo gem install sequel
|
14
|
-
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
|
15
|
-
|
16
|
-
module Jekyll
|
17
|
-
module MT
|
18
|
-
# This query will pull blog posts from all entries across all blogs. If
|
19
|
-
# you've got unpublished, deleted or otherwise hidden posts please sift
|
20
|
-
# through the created posts to make sure nothing is accidently published.
|
21
|
-
QUERY = "SELECT entry_id, \
|
22
|
-
entry_basename, \
|
23
|
-
entry_text, \
|
24
|
-
entry_text_more, \
|
25
|
-
entry_authored_on, \
|
26
|
-
entry_title, \
|
27
|
-
entry_convert_breaks \
|
28
|
-
FROM mt_entry"
|
29
|
-
|
30
|
-
def self.process(dbname, user, pass, host = 'localhost')
|
31
|
-
db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host, :encoding => 'utf8')
|
32
|
-
|
33
|
-
FileUtils.mkdir_p "_posts"
|
34
|
-
|
35
|
-
db[QUERY].each do |post|
|
36
|
-
title = post[:entry_title]
|
37
|
-
slug = post[:entry_basename].gsub(/_/, '-')
|
38
|
-
date = post[:entry_authored_on]
|
39
|
-
content = post[:entry_text]
|
40
|
-
more_content = post[:entry_text_more]
|
41
|
-
entry_convert_breaks = post[:entry_convert_breaks]
|
42
|
-
|
43
|
-
# Be sure to include the body and extended body.
|
44
|
-
if more_content != nil
|
45
|
-
content = content + " \n" + more_content
|
46
|
-
end
|
47
|
-
|
48
|
-
# Ideally, this script would determine the post format (markdown,
|
49
|
-
# html, etc) and create files with proper extensions. At this point
|
50
|
-
# it just assumes that markdown will be acceptable.
|
51
|
-
name = [date.year, date.month, date.day, slug].join('-') + '.' +
|
52
|
-
self.suffix(entry_convert_breaks)
|
53
|
-
|
54
|
-
data = {
|
55
|
-
'layout' => 'post',
|
56
|
-
'title' => title.to_s,
|
57
|
-
'mt_id' => post[:entry_id],
|
58
|
-
'date' => date
|
59
|
-
}.delete_if { |k,v| v.nil? || v == '' }.to_yaml
|
60
|
-
|
61
|
-
File.open("_posts/#{name}", "w") do |f|
|
62
|
-
f.puts data
|
63
|
-
f.puts "---"
|
64
|
-
f.puts content
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def self.suffix(entry_type)
|
70
|
-
if entry_type.nil? || entry_type.include?("markdown")
|
71
|
-
# The markdown plugin I have saves this as
|
72
|
-
# "markdown_with_smarty_pants", so I just look for "markdown".
|
73
|
-
"markdown"
|
74
|
-
elsif entry_type.include?("textile")
|
75
|
-
# This is saved as "textile_2" on my installation of MT 5.1.
|
76
|
-
"textile"
|
77
|
-
elsif entry_type == "0" || entry_type.include?("richtext")
|
78
|
-
# Richtext looks to me like it's saved as HTML, so I include it here.
|
79
|
-
"html"
|
80
|
-
else
|
81
|
-
# Other values might need custom work.
|
82
|
-
entry_type
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|