realityforge-jekyll 0.7.1-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +255 -0
- data/LICENSE +21 -0
- data/README.textile +41 -0
- data/Rakefile +159 -0
- data/bin/jekyll +178 -0
- data/cucumber.yml +1 -0
- data/features/create_sites.feature +94 -0
- data/features/embed_filters.feature +60 -0
- data/features/markdown.feature +30 -0
- data/features/pagination.feature +27 -0
- data/features/permalinks.feature +65 -0
- data/features/post_data.feature +153 -0
- data/features/site_configuration.feature +103 -0
- data/features/site_data.feature +82 -0
- data/features/step_definitions/jekyll_steps.rb +145 -0
- data/features/support/env.rb +16 -0
- data/jekyll.gemspec +135 -0
- data/lib/jekyll.rb +109 -0
- data/lib/jekyll/albino.rb +120 -0
- data/lib/jekyll/converter.rb +50 -0
- data/lib/jekyll/converters/identity.rb +22 -0
- data/lib/jekyll/converters/markdown.rb +80 -0
- data/lib/jekyll/converters/textile.rb +33 -0
- data/lib/jekyll/convertible.rb +82 -0
- data/lib/jekyll/core_ext.rb +52 -0
- data/lib/jekyll/errors.rb +6 -0
- data/lib/jekyll/filters.rb +47 -0
- data/lib/jekyll/generator.rb +7 -0
- data/lib/jekyll/generators/pagination.rb +87 -0
- data/lib/jekyll/layout.rb +36 -0
- data/lib/jekyll/migrators/csv.rb +26 -0
- data/lib/jekyll/migrators/mephisto.rb +79 -0
- data/lib/jekyll/migrators/mt.rb +59 -0
- data/lib/jekyll/migrators/textpattern.rb +50 -0
- data/lib/jekyll/migrators/typo.rb +49 -0
- data/lib/jekyll/migrators/wordpress.rb +55 -0
- data/lib/jekyll/page.rb +133 -0
- data/lib/jekyll/plugin.rb +76 -0
- data/lib/jekyll/post.rb +242 -0
- data/lib/jekyll/site.rb +235 -0
- data/lib/jekyll/static_file.rb +76 -0
- data/lib/jekyll/tags/highlight.rb +73 -0
- data/lib/jekyll/tags/include.rb +31 -0
- data/test/helper.rb +33 -0
- data/test/source/_includes/sig.markdown +3 -0
- data/test/source/_layouts/default.html +27 -0
- data/test/source/_layouts/simple.html +1 -0
- data/test/source/_posts/2008-02-02-not-published.textile +8 -0
- data/test/source/_posts/2008-02-02-published.textile +8 -0
- data/test/source/_posts/2008-10-18-foo-bar.textile +8 -0
- data/test/source/_posts/2008-11-21-complex.textile +8 -0
- data/test/source/_posts/2008-12-03-permalinked-post.textile +9 -0
- data/test/source/_posts/2008-12-13-include.markdown +8 -0
- data/test/source/_posts/2009-01-27-array-categories.textile +10 -0
- data/test/source/_posts/2009-01-27-categories.textile +7 -0
- data/test/source/_posts/2009-01-27-category.textile +7 -0
- data/test/source/_posts/2009-01-27-empty-categories.textile +7 -0
- data/test/source/_posts/2009-01-27-empty-category.textile +7 -0
- data/test/source/_posts/2009-03-12-hash-#1.markdown +6 -0
- data/test/source/_posts/2009-05-18-empty-tag.textile +6 -0
- data/test/source/_posts/2009-05-18-empty-tags.textile +6 -0
- data/test/source/_posts/2009-05-18-tag.textile +6 -0
- data/test/source/_posts/2009-05-18-tags.textile +9 -0
- data/test/source/_posts/2009-06-22-empty-yaml.textile +3 -0
- data/test/source/_posts/2009-06-22-no-yaml.textile +1 -0
- data/test/source/_posts/2010-01-08-triple-dash.markdown +5 -0
- data/test/source/_posts/2010-01-09-date-override.textile +7 -0
- data/test/source/_posts/2010-01-09-time-override.textile +7 -0
- data/test/source/_posts/2010-01-09-timezone-override.textile +7 -0
- data/test/source/_posts/2010-01-16-override-data.textile +4 -0
- data/test/source/about.html +6 -0
- data/test/source/category/_posts/2008-9-23-categories.textile +6 -0
- data/test/source/contacts.html +5 -0
- data/test/source/css/screen.css +76 -0
- data/test/source/foo/_posts/bar/2008-12-12-topical-post.textile +8 -0
- data/test/source/index.html +22 -0
- data/test/source/sitemap.xml +32 -0
- data/test/source/win/_posts/2009-05-24-yaml-linebreak.markdown +7 -0
- data/test/source/z_category/_posts/2008-9-23-categories.textile +6 -0
- data/test/suite.rb +9 -0
- data/test/test_configuration.rb +29 -0
- data/test/test_core_ext.rb +66 -0
- data/test/test_filters.rb +49 -0
- data/test/test_generated_site.rb +44 -0
- data/test/test_page.rb +98 -0
- data/test/test_pager.rb +113 -0
- data/test/test_post.rb +396 -0
- data/test/test_rdiscount.rb +18 -0
- data/test/test_site.rb +153 -0
- data/test/test_tags.rb +116 -0
- metadata +282 -0
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
|
|
40
|
+
QUERY = "SELECT id, permalink, body, published_at, title FROM contents WHERE user_id = 1 AND type = 'Article' AND published_at IS NOT NULL ORDER BY published_at"
|
|
41
|
+
|
|
42
|
+
def self.process(dbname, user, pass, host = 'localhost')
|
|
43
|
+
db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host)
|
|
44
|
+
|
|
45
|
+
FileUtils.mkdir_p "_posts"
|
|
46
|
+
|
|
47
|
+
db[QUERY].each do |post|
|
|
48
|
+
title = post[:title]
|
|
49
|
+
slug = post[:permalink]
|
|
50
|
+
date = post[:published_at]
|
|
51
|
+
content = post[:body]
|
|
52
|
+
# more_content = ''
|
|
53
|
+
|
|
54
|
+
# Be sure to include the body and extended body.
|
|
55
|
+
# if more_content != nil
|
|
56
|
+
# content = content + " \n" + more_content
|
|
57
|
+
# end
|
|
58
|
+
|
|
59
|
+
# Ideally, this script would determine the post format (markdown, html
|
|
60
|
+
# , etc) and create files with proper extensions. At this point it
|
|
61
|
+
# just assumes that markdown will be acceptable.
|
|
62
|
+
name = [date.year, date.month, date.day, slug].join('-') + ".markdown"
|
|
63
|
+
|
|
64
|
+
data = {
|
|
65
|
+
'layout' => 'post',
|
|
66
|
+
'title' => title.to_s,
|
|
67
|
+
'mt_id' => post[:entry_id],
|
|
68
|
+
}.delete_if { |k,v| v.nil? || v == ''}.to_yaml
|
|
69
|
+
|
|
70
|
+
File.open("_posts/#{name}", "w") do |f|
|
|
71
|
+
f.puts data
|
|
72
|
+
f.puts "---"
|
|
73
|
+
f.puts content
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
|
|
9
|
+
# NOTE: This converter requires Sequel and the MySQL gems.
|
|
10
|
+
# The MySQL gem can be difficult to install on OS X. Once you have MySQL
|
|
11
|
+
# installed, running the following commands should work:
|
|
12
|
+
# $ sudo gem install sequel
|
|
13
|
+
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
|
|
14
|
+
|
|
15
|
+
module Jekyll
|
|
16
|
+
module MT
|
|
17
|
+
# This query will pull blog posts from all entries across all blogs. If
|
|
18
|
+
# you've got unpublished, deleted or otherwise hidden posts please sift
|
|
19
|
+
# through the created posts to make sure nothing is accidently published.
|
|
20
|
+
QUERY = "SELECT entry_id, entry_basename, entry_text, entry_text_more, entry_created_on, entry_title FROM mt_entry"
|
|
21
|
+
|
|
22
|
+
def self.process(dbname, user, pass, host = 'localhost')
|
|
23
|
+
db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host)
|
|
24
|
+
|
|
25
|
+
FileUtils.mkdir_p "_posts"
|
|
26
|
+
|
|
27
|
+
db[QUERY].each do |post|
|
|
28
|
+
title = post[:entry_title]
|
|
29
|
+
slug = post[:entry_basename]
|
|
30
|
+
date = post[:entry_created_on]
|
|
31
|
+
content = post[:entry_text]
|
|
32
|
+
more_content = post[:entry_text_more]
|
|
33
|
+
|
|
34
|
+
# Be sure to include the body and extended body.
|
|
35
|
+
if more_content != nil
|
|
36
|
+
content = content + " \n" + more_content
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Ideally, this script would determine the post format (markdown, html
|
|
40
|
+
# , etc) and create files with proper extensions. At this point it
|
|
41
|
+
# just assumes that markdown will be acceptable.
|
|
42
|
+
name = [date.year, date.month, date.day, slug].join('-') + ".markdown"
|
|
43
|
+
|
|
44
|
+
data = {
|
|
45
|
+
'layout' => 'post',
|
|
46
|
+
'title' => title.to_s,
|
|
47
|
+
'mt_id' => post[:entry_id],
|
|
48
|
+
}.delete_if { |k,v| v.nil? || v == ''}.to_yaml
|
|
49
|
+
|
|
50
|
+
File.open("_posts/#{name}", "w") do |f|
|
|
51
|
+
f.puts data
|
|
52
|
+
f.puts "---"
|
|
53
|
+
f.puts content
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'sequel'
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
|
|
5
|
+
# NOTE: This converter requires Sequel and the MySQL gems.
|
|
6
|
+
# The MySQL gem can be difficult to install on OS X. Once you have MySQL
|
|
7
|
+
# installed, running the following commands should work:
|
|
8
|
+
# $ sudo gem install sequel
|
|
9
|
+
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
|
|
10
|
+
|
|
11
|
+
module Jekyll
|
|
12
|
+
module TextPattern
|
|
13
|
+
# Reads a MySQL database via Sequel and creates a post file for each post.
|
|
14
|
+
# The only posts selected are those with a status of 4 or 5, which means "live"
|
|
15
|
+
# and "sticky" respectively.
|
|
16
|
+
# Other statuses is 1 => draft, 2 => hidden and 3 => pending
|
|
17
|
+
QUERY = "select Title, url_title, Posted, Body, Keywords from textpattern where Status = '4' or Status = '5'"
|
|
18
|
+
|
|
19
|
+
def self.process(dbname, user, pass, host = 'localhost')
|
|
20
|
+
db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host)
|
|
21
|
+
|
|
22
|
+
FileUtils.mkdir_p "_posts"
|
|
23
|
+
|
|
24
|
+
db[QUERY].each do |post|
|
|
25
|
+
# Get required fields and construct Jekyll compatible name
|
|
26
|
+
title = post[:Title]
|
|
27
|
+
slug = post[:url_title]
|
|
28
|
+
date = post[:Posted]
|
|
29
|
+
content = post[:Body]
|
|
30
|
+
|
|
31
|
+
name = [date.strftime("%Y-%m-%d"), slug].join('-') + ".textile"
|
|
32
|
+
|
|
33
|
+
# Get the relevant fields as a hash, delete empty fields and convert
|
|
34
|
+
# to YAML for the header
|
|
35
|
+
data = {
|
|
36
|
+
'layout' => 'post',
|
|
37
|
+
'title' => title.to_s,
|
|
38
|
+
'tags' => post[:Keywords].split(',')
|
|
39
|
+
}.delete_if { |k,v| v.nil? || v == ''}.to_yaml
|
|
40
|
+
|
|
41
|
+
# Write out the data and content to file
|
|
42
|
+
File.open("_posts/#{name}", "w") do |f|
|
|
43
|
+
f.puts data
|
|
44
|
+
f.puts "---"
|
|
45
|
+
f.puts content
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Author: Toby DiPasquale <toby@cbcg.net>
|
|
2
|
+
require 'fileutils'
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
require 'sequel'
|
|
5
|
+
|
|
6
|
+
module Jekyll
|
|
7
|
+
module Typo
|
|
8
|
+
# this SQL *should* work for both MySQL and PostgreSQL, but I haven't
|
|
9
|
+
# tested PostgreSQL yet (as of 2008-12-16)
|
|
10
|
+
SQL = <<-EOS
|
|
11
|
+
SELECT c.id id,
|
|
12
|
+
c.title title,
|
|
13
|
+
c.permalink slug,
|
|
14
|
+
c.body body,
|
|
15
|
+
c.published_at date,
|
|
16
|
+
c.state state,
|
|
17
|
+
COALESCE(tf.name, 'html') filter
|
|
18
|
+
FROM contents c
|
|
19
|
+
LEFT OUTER JOIN text_filters tf
|
|
20
|
+
ON c.text_filter_id = tf.id
|
|
21
|
+
EOS
|
|
22
|
+
|
|
23
|
+
def self.process dbname, user, pass, host='localhost'
|
|
24
|
+
FileUtils.mkdir_p '_posts'
|
|
25
|
+
db = Sequel.mysql dbname, :user => user, :password => pass, :host => host
|
|
26
|
+
db[SQL].each do |post|
|
|
27
|
+
next unless post[:state] =~ /Published/
|
|
28
|
+
|
|
29
|
+
name = [ sprintf("%.04d", post[:date].year),
|
|
30
|
+
sprintf("%.02d", post[:date].month),
|
|
31
|
+
sprintf("%.02d", post[:date].day),
|
|
32
|
+
post[:slug].strip ].join('-')
|
|
33
|
+
# Can have more than one text filter in this field, but we just want
|
|
34
|
+
# the first one for this
|
|
35
|
+
name += '.' + post[:filter].split(' ')[0]
|
|
36
|
+
|
|
37
|
+
File.open("_posts/#{name}", 'w') do |f|
|
|
38
|
+
f.puts({ 'layout' => 'post',
|
|
39
|
+
'title' => post[:title].to_s,
|
|
40
|
+
'typo_id' => post[:id]
|
|
41
|
+
}.delete_if { |k, v| v.nil? || v == '' }.to_yaml)
|
|
42
|
+
f.puts '---'
|
|
43
|
+
f.puts post[:body].delete("\r")
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
end # module Typo
|
|
49
|
+
end # module Jekyll
|
|
@@ -0,0 +1,55 @@
|
|
|
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 WordPress
|
|
14
|
+
|
|
15
|
+
# Reads a MySQL database via Sequel and creates a post file for each
|
|
16
|
+
# post in wp_posts that has post_status = 'publish'.
|
|
17
|
+
# This restriction is made because 'draft' posts are not guaranteed to
|
|
18
|
+
# have valid dates.
|
|
19
|
+
QUERY = "select post_title, post_name, post_date, post_content, post_excerpt, ID, guid from wp_posts where post_status = 'publish' and post_type = 'post'"
|
|
20
|
+
|
|
21
|
+
def self.process(dbname, user, pass, host = 'localhost')
|
|
22
|
+
db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host)
|
|
23
|
+
|
|
24
|
+
FileUtils.mkdir_p "_posts"
|
|
25
|
+
|
|
26
|
+
db[QUERY].each do |post|
|
|
27
|
+
# Get required fields and construct Jekyll compatible name
|
|
28
|
+
title = post[:post_title]
|
|
29
|
+
slug = post[:post_name]
|
|
30
|
+
date = post[:post_date]
|
|
31
|
+
content = post[:post_content]
|
|
32
|
+
name = "%02d-%02d-%02d-%s.markdown" % [date.year, date.month, date.day,
|
|
33
|
+
slug]
|
|
34
|
+
|
|
35
|
+
# Get the relevant fields as a hash, delete empty fields and convert
|
|
36
|
+
# to YAML for the header
|
|
37
|
+
data = {
|
|
38
|
+
'layout' => 'post',
|
|
39
|
+
'title' => title.to_s,
|
|
40
|
+
'excerpt' => post[:post_excerpt].to_s,
|
|
41
|
+
'wordpress_id' => post[:ID],
|
|
42
|
+
'wordpress_url' => post[:guid]
|
|
43
|
+
}.delete_if { |k,v| v.nil? || v == ''}.to_yaml
|
|
44
|
+
|
|
45
|
+
# Write out the data and content to file
|
|
46
|
+
File.open("_posts/#{name}", "w") do |f|
|
|
47
|
+
f.puts data
|
|
48
|
+
f.puts "---"
|
|
49
|
+
f.puts content
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
data/lib/jekyll/page.rb
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
module Jekyll
|
|
2
|
+
|
|
3
|
+
class Page
|
|
4
|
+
include Convertible
|
|
5
|
+
|
|
6
|
+
attr_accessor :site, :pager
|
|
7
|
+
attr_accessor :name, :ext, :basename, :dir
|
|
8
|
+
attr_accessor :data, :content, :output
|
|
9
|
+
|
|
10
|
+
# Initialize a new Page.
|
|
11
|
+
# +site+ is the Site
|
|
12
|
+
# +base+ is the String path to the <source>
|
|
13
|
+
# +dir+ is the String path between <source> and the file
|
|
14
|
+
# +name+ is the String filename of the file
|
|
15
|
+
#
|
|
16
|
+
# Returns <Page>
|
|
17
|
+
def initialize(site, base, dir, name)
|
|
18
|
+
@site = site
|
|
19
|
+
@base = base
|
|
20
|
+
@dir = dir
|
|
21
|
+
@name = name
|
|
22
|
+
|
|
23
|
+
self.process(name)
|
|
24
|
+
self.read_yaml(File.join(base, dir), name)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# The generated directory into which the page will be placed
|
|
28
|
+
# upon generation. This is derived from the permalink or, if
|
|
29
|
+
# permalink is absent, set to '/'
|
|
30
|
+
#
|
|
31
|
+
# Returns <String>
|
|
32
|
+
def dir
|
|
33
|
+
url[-1, 1] == '/' ? url : File.dirname(url)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# The full path and filename of the post.
|
|
37
|
+
# Defined in the YAML of the post body
|
|
38
|
+
# (Optional)
|
|
39
|
+
#
|
|
40
|
+
# Returns <String>
|
|
41
|
+
def permalink
|
|
42
|
+
self.data && self.data['permalink']
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def template
|
|
46
|
+
if self.site.permalink_style == :pretty && !index? && html?
|
|
47
|
+
"/:basename/"
|
|
48
|
+
else
|
|
49
|
+
"/:basename:output_ext"
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# The generated relative url of this page
|
|
54
|
+
# e.g. /about.html
|
|
55
|
+
#
|
|
56
|
+
# Returns <String>
|
|
57
|
+
def url
|
|
58
|
+
return permalink if permalink
|
|
59
|
+
|
|
60
|
+
@url ||= {
|
|
61
|
+
"basename" => self.basename,
|
|
62
|
+
"output_ext" => self.output_ext,
|
|
63
|
+
}.inject(template) { |result, token|
|
|
64
|
+
result.gsub(/:#{token.first}/, token.last)
|
|
65
|
+
}.gsub(/\/\//, "/")
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Extract information from the page filename
|
|
69
|
+
# +name+ is the String filename of the page file
|
|
70
|
+
#
|
|
71
|
+
# Returns nothing
|
|
72
|
+
def process(name)
|
|
73
|
+
self.ext = File.extname(name)
|
|
74
|
+
self.basename = name.split('.')[0..-2].first
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Add any necessary layouts to this post
|
|
78
|
+
# +layouts+ is a Hash of {"name" => "layout"}
|
|
79
|
+
# +site_payload+ is the site payload hash
|
|
80
|
+
#
|
|
81
|
+
# Returns nothing
|
|
82
|
+
def render(layouts, site_payload)
|
|
83
|
+
payload = {
|
|
84
|
+
"page" => self.to_liquid,
|
|
85
|
+
'paginator' => pager.to_liquid
|
|
86
|
+
}.deep_merge(site_payload)
|
|
87
|
+
|
|
88
|
+
do_layout(payload, layouts)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def to_liquid
|
|
92
|
+
self.data.deep_merge({
|
|
93
|
+
"url" => File.join(@dir, self.url),
|
|
94
|
+
"content" => self.content })
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# Write the generated page file to the destination directory.
|
|
98
|
+
# +dest_prefix+ is the String path to the destination dir
|
|
99
|
+
# +dest_suffix+ is a suffix path to the destination dir
|
|
100
|
+
#
|
|
101
|
+
# Returns nothing
|
|
102
|
+
def write(dest_prefix, dest_suffix = nil)
|
|
103
|
+
dest = File.join(dest_prefix, @dir)
|
|
104
|
+
dest = File.join(dest, dest_suffix) if dest_suffix
|
|
105
|
+
FileUtils.mkdir_p(dest)
|
|
106
|
+
|
|
107
|
+
# The url needs to be unescaped in order to preserve the correct filename
|
|
108
|
+
path = File.join(dest, CGI.unescape(self.url))
|
|
109
|
+
if self.url =~ /\/$/
|
|
110
|
+
FileUtils.mkdir_p(path)
|
|
111
|
+
path = File.join(path, "index.html")
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
File.open(path, 'w') do |f|
|
|
115
|
+
f.write(self.output)
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def inspect
|
|
120
|
+
"#<Jekyll:Page @name=#{self.name.inspect}>"
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def html?
|
|
124
|
+
output_ext == '.html'
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def index?
|
|
128
|
+
basename == 'index'
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
module Jekyll
|
|
2
|
+
|
|
3
|
+
class Plugin
|
|
4
|
+
PRIORITIES = { :lowest => -100,
|
|
5
|
+
:low => -10,
|
|
6
|
+
:normal => 0,
|
|
7
|
+
:high => 10,
|
|
8
|
+
:highest => 100 }
|
|
9
|
+
|
|
10
|
+
# Install a hook so that subclasses are recorded. This method is only
|
|
11
|
+
# ever called by Ruby itself.
|
|
12
|
+
#
|
|
13
|
+
# base - The Class subclass.
|
|
14
|
+
#
|
|
15
|
+
# Returns nothing.
|
|
16
|
+
def self.inherited(base)
|
|
17
|
+
subclasses << base
|
|
18
|
+
subclasses.sort!
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# The list of Classes that have been subclassed.
|
|
22
|
+
#
|
|
23
|
+
# Returns an Array of Class objects.
|
|
24
|
+
def self.subclasses
|
|
25
|
+
@subclasses ||= []
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Get or set the priority of this plugin. When called without an
|
|
29
|
+
# argument it returns the priority. When an argument is given, it will
|
|
30
|
+
# set the priority.
|
|
31
|
+
#
|
|
32
|
+
# priority - The Symbol priority (default: nil). Valid options are:
|
|
33
|
+
# :lowest, :low, :normal, :high, :highest
|
|
34
|
+
#
|
|
35
|
+
# Returns the Symbol priority.
|
|
36
|
+
def self.priority(priority = nil)
|
|
37
|
+
if priority && PRIORITIES.has_key?(priority)
|
|
38
|
+
@priority = priority
|
|
39
|
+
end
|
|
40
|
+
@priority || :normal
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Get or set the safety of this plugin. When called without an argument
|
|
44
|
+
# it returns the safety. When an argument is given, it will set the
|
|
45
|
+
# safety.
|
|
46
|
+
#
|
|
47
|
+
# safe - The Boolean safety (default: nil).
|
|
48
|
+
#
|
|
49
|
+
# Returns the safety Boolean.
|
|
50
|
+
def self.safe(safe = nil)
|
|
51
|
+
if safe
|
|
52
|
+
@safe = safe
|
|
53
|
+
end
|
|
54
|
+
@safe || false
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Spaceship is priority [higher -> lower]
|
|
58
|
+
#
|
|
59
|
+
# other - The class to be compared.
|
|
60
|
+
#
|
|
61
|
+
# Returns -1, 0, 1.
|
|
62
|
+
def self.<=>(other)
|
|
63
|
+
PRIORITIES[other.priority] <=> PRIORITIES[self.priority]
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Initialize a new plugin. This should be overridden by the subclass.
|
|
67
|
+
#
|
|
68
|
+
# config - The Hash of configuration options.
|
|
69
|
+
#
|
|
70
|
+
# Returns a new instance.
|
|
71
|
+
def initialize(config = {})
|
|
72
|
+
# no-op for default
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
end
|