monad 0.0.2 → 0.0.3
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.
- checksums.yaml +7 -0
- data/CONTRIBUTING.markdown +91 -0
- data/Gemfile +1 -1
- data/History.markdown +772 -0
- data/{README.md → README.markdown} +5 -2
- data/Rakefile +163 -1
- data/bin/monad +86 -30
- data/features/create_sites.feature +54 -25
- data/features/data.feature +65 -0
- data/features/data_sources.feature +10 -10
- data/features/drafts.feature +5 -5
- data/features/embed_filters.feature +10 -10
- data/features/include_tag.feature +48 -0
- data/features/markdown.feature +5 -5
- data/features/pagination.feature +38 -10
- data/features/permalinks.feature +31 -11
- data/features/post_data.feature +41 -41
- data/features/post_excerpts.feature +50 -0
- data/features/site_configuration.feature +47 -26
- data/features/site_data.feature +30 -24
- data/features/step_definitions/{monad_steps.rb → jekyll_steps.rb} +66 -52
- data/features/support/env.rb +27 -8
- data/lib/jekyll.rb +99 -0
- data/lib/jekyll/cleaner.rb +73 -0
- data/lib/{monad → jekyll}/command.rb +6 -6
- data/lib/{monad → jekyll}/commands/build.rb +9 -9
- data/lib/jekyll/commands/doctor.rb +67 -0
- data/lib/jekyll/commands/new.rb +67 -0
- data/lib/jekyll/commands/serve.rb +65 -0
- data/lib/{monad → jekyll}/configuration.rb +60 -18
- data/lib/{monad → jekyll}/converter.rb +1 -1
- data/lib/{monad → jekyll}/converters/identity.rb +1 -1
- data/lib/{monad → jekyll}/converters/markdown.rb +2 -2
- data/lib/jekyll/converters/markdown/kramdown_parser.rb +29 -0
- data/lib/{monad → jekyll}/converters/markdown/maruku_parser.rb +12 -8
- data/lib/{monad → jekyll}/converters/markdown/rdiscount_parser.rb +4 -2
- data/lib/{monad → jekyll}/converters/markdown/redcarpet_parser.rb +1 -1
- data/lib/{monad → jekyll}/converters/textile.rb +1 -1
- data/lib/{monad → jekyll}/convertible.rb +39 -17
- data/lib/{monad → jekyll}/core_ext.rb +22 -4
- data/lib/jekyll/deprecator.rb +36 -0
- data/lib/{monad → jekyll}/draft.rb +1 -1
- data/lib/{monad → jekyll}/drivers/json_driver.rb +1 -1
- data/lib/{monad → jekyll}/drivers/yaml_driver.rb +1 -1
- data/lib/{monad → jekyll}/errors.rb +1 -1
- data/lib/jekyll/excerpt.rb +113 -0
- data/lib/{monad → jekyll}/filters.rb +16 -6
- data/lib/{monad → jekyll}/generator.rb +1 -1
- data/lib/jekyll/generators/pagination.rb +214 -0
- data/lib/{monad → jekyll}/layout.rb +4 -1
- data/lib/{monad → jekyll}/mime.types +0 -0
- data/lib/{monad → jekyll}/page.rb +36 -39
- data/lib/{monad → jekyll}/plugin.rb +1 -1
- data/lib/{monad → jekyll}/post.rb +58 -123
- data/lib/jekyll/related_posts.rb +59 -0
- data/lib/{monad → jekyll}/site.rb +120 -123
- data/lib/{monad → jekyll}/static_file.rb +1 -1
- data/lib/jekyll/stevenson.rb +89 -0
- data/lib/jekyll/tags/gist.rb +48 -0
- data/lib/{monad → jekyll}/tags/highlight.rb +3 -3
- data/lib/jekyll/tags/include.rb +135 -0
- data/lib/{monad → jekyll}/tags/post_url.rb +8 -6
- data/lib/jekyll/url.rb +67 -0
- data/lib/monad.rb +36 -27
- data/lib/site_template/_config.yml +2 -1
- data/lib/site_template/_layouts/default.html +21 -23
- data/lib/site_template/_layouts/post.html +1 -1
- data/lib/site_template/_posts/{0000-00-00-welcome-to-monad.markdown.erb → 0000-00-00-welcome-to-jekyll.markdown.erb} +6 -6
- data/lib/site_template/css/main.css +22 -27
- data/lib/site_template/index.html +2 -2
- data/monad.gemspec +153 -52
- data/site/.gitignore +4 -0
- data/site/CNAME +1 -0
- data/site/README +1 -0
- data/site/_config.yml +6 -0
- data/site/_includes/analytics.html +32 -0
- data/site/_includes/docs_contents.html +16 -0
- data/site/_includes/docs_contents_mobile.html +23 -0
- data/site/_includes/docs_option.html +11 -0
- data/site/_includes/docs_ul.html +20 -0
- data/site/_includes/footer.html +15 -0
- data/site/_includes/header.html +18 -0
- data/site/_includes/news_contents.html +23 -0
- data/site/_includes/news_contents_mobile.html +11 -0
- data/site/_includes/news_item.html +24 -0
- data/site/_includes/primary-nav-items.html +14 -0
- data/site/_includes/section_nav.html +22 -0
- data/site/_includes/top.html +17 -0
- data/site/_layouts/default.html +12 -0
- data/site/_layouts/docs.html +23 -0
- data/site/_layouts/news.html +19 -0
- data/site/_layouts/news_item.html +27 -0
- data/site/_posts/2013-05-06-jekyll-1-0-0-released.markdown +23 -0
- data/site/_posts/2013-05-08-jekyll-1-0-1-released.markdown +27 -0
- data/site/_posts/2013-05-12-jekyll-1-0-2-released.markdown +28 -0
- data/site/_posts/2013-06-07-jekyll-1-0-3-released.markdown +25 -0
- data/site/_posts/2013-07-14-jekyll-1-1-0-released.markdown +27 -0
- data/site/_posts/2013-07-24-jekyll-1-1-1-released.markdown +31 -0
- data/site/_posts/2013-07-25-jekyll-1-0-4-released.markdown +20 -0
- data/site/_posts/2013-07-25-jekyll-1-1-2-released.markdown +20 -0
- data/site/_posts/2013-09-06-jekyll-1-2-0-released.markdown +23 -0
- data/site/_posts/2013-09-14-jekyll-1-2-1-released.markdown +19 -0
- data/site/css/gridism.css +110 -0
- data/site/css/normalize.css +1 -0
- data/site/css/pygments.css +70 -0
- data/site/css/style.css +946 -0
- data/site/docs/configuration.md +373 -0
- data/site/docs/contributing.md +128 -0
- data/site/docs/datafiles.md +63 -0
- data/site/docs/deployment-methods.md +109 -0
- data/site/docs/drafts.md +20 -0
- data/site/docs/extras.md +56 -0
- data/site/docs/frontmatter.md +180 -0
- data/site/docs/github-pages.md +91 -0
- data/site/docs/heroku.md +9 -0
- data/site/docs/history.md +722 -0
- data/site/docs/index.md +52 -0
- data/site/docs/installation.md +76 -0
- data/site/docs/migrations.md +257 -0
- data/site/docs/pages.md +86 -0
- data/site/docs/pagination.md +211 -0
- data/site/docs/permalinks.md +180 -0
- data/site/docs/plugins.md +508 -0
- data/site/docs/posts.md +181 -0
- data/site/docs/quickstart.md +32 -0
- data/site/docs/resources.md +46 -0
- data/site/docs/sites.md +29 -0
- data/site/docs/structure.md +190 -0
- data/site/docs/templates.md +319 -0
- data/site/docs/troubleshooting.md +150 -0
- data/site/docs/upgrading.md +146 -0
- data/site/docs/usage.md +63 -0
- data/site/docs/variables.md +322 -0
- data/site/favicon.png +0 -0
- data/site/feed.xml +36 -0
- data/site/freenode.txt +1 -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 +90 -0
- data/site/js/modernizr-2.5.3.min.js +4 -0
- data/site/news/index.html +10 -0
- data/site/news/releases/index.html +10 -0
- data/test/helper.rb +6 -3
- data/test/source/+/foo.md +7 -0
- data/test/source/_data/languages.yml +2 -0
- data/test/source/_data/members.yaml +7 -0
- data/test/source/_data/products.yml +4 -0
- data/test/source/_includes/params.html +7 -0
- data/test/source/_layouts/default.html +1 -1
- data/test/source/_layouts/post/simple.html +1 -0
- data/test/source/_plugins/dummy.rb +1 -1
- data/test/source/_posts/2013-01-02-post-excerpt.markdown +1 -1
- data/test/source/_posts/2013-07-22-post-excerpt-with-layout.markdown +23 -0
- data/test/source/_posts/2013-08-01-mkdn-extension.mkdn +0 -0
- data/test/source/deal.with.dots.html +1 -1
- data/test/source/products.yml +4 -0
- data/test/test_configuration.rb +46 -11
- data/test/test_convertible.rb +2 -2
- data/test/test_excerpt.rb +78 -0
- data/test/test_filters.rb +4 -4
- data/test/test_generated_site.rb +13 -13
- data/test/test_json_driver.rb +9 -9
- data/test/test_kramdown.rb +32 -5
- data/test/test_new_command.rb +8 -8
- data/test/test_page.rb +12 -3
- data/test/test_pager.rb +34 -33
- data/test/test_post.rb +34 -26
- data/test/test_redcloth.rb +3 -3
- data/test/test_related_posts.rb +47 -0
- data/test/test_site.rb +102 -44
- data/test/test_tags.rb +168 -23
- data/test/test_url.rb +28 -0
- data/test/test_yaml_driver.rb +6 -6
- metadata +215 -137
- data/lib/monad/commands/doctor.rb +0 -29
- data/lib/monad/commands/new.rb +0 -50
- data/lib/monad/commands/serve.rb +0 -33
- data/lib/monad/converters/markdown/kramdown_parser.rb +0 -44
- data/lib/monad/deprecator.rb +0 -32
- data/lib/monad/generators/pagination.rb +0 -143
- data/lib/monad/logger.rb +0 -54
- data/lib/monad/tags/gist.rb +0 -30
- data/lib/monad/tags/include.rb +0 -37
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module Jekyll
|
|
4
4
|
class Configuration < Hash
|
|
5
5
|
|
|
6
6
|
# Default options. Overridden by values in _config.yml.
|
|
@@ -10,11 +10,15 @@ module Monad
|
|
|
10
10
|
'destination' => File.join(Dir.pwd, '_site'),
|
|
11
11
|
'plugins' => '_plugins',
|
|
12
12
|
'layouts' => '_layouts',
|
|
13
|
+
'data_source' => '_data',
|
|
13
14
|
'keep_files' => ['.git','.svn'],
|
|
14
15
|
|
|
15
16
|
'timezone' => nil, # use the local timezone
|
|
16
17
|
|
|
18
|
+
'encoding' => nil, # use the system encoding
|
|
19
|
+
|
|
17
20
|
'safe' => false,
|
|
21
|
+
'detach' => false, # default to not detaching the server
|
|
18
22
|
'show_drafts' => nil,
|
|
19
23
|
'limit_posts' => 0,
|
|
20
24
|
'lsi' => false,
|
|
@@ -29,7 +33,7 @@ module Monad
|
|
|
29
33
|
'baseurl' => '/',
|
|
30
34
|
'include' => ['.htaccess'],
|
|
31
35
|
'exclude' => [],
|
|
32
|
-
'paginate_path' => 'page:num',
|
|
36
|
+
'paginate_path' => '/page:num',
|
|
33
37
|
|
|
34
38
|
'markdown_ext' => 'markdown,mkd,mkdn,md',
|
|
35
39
|
'textile_ext' => 'textile',
|
|
@@ -85,11 +89,11 @@ module Monad
|
|
|
85
89
|
reduce({}) { |hsh,(k,v)| hsh.merge(k.to_s => v) }
|
|
86
90
|
end
|
|
87
91
|
|
|
88
|
-
# Public: Directory of the
|
|
92
|
+
# Public: Directory of the Jekyll source folder
|
|
89
93
|
#
|
|
90
94
|
# override - the command-line options hash
|
|
91
95
|
#
|
|
92
|
-
# Returns the path to the
|
|
96
|
+
# Returns the path to the Jekyll source directory
|
|
93
97
|
def source(override)
|
|
94
98
|
override['source'] || self['source'] || DEFAULTS['source']
|
|
95
99
|
end
|
|
@@ -102,7 +106,10 @@ module Monad
|
|
|
102
106
|
def config_files(override)
|
|
103
107
|
# Get configuration from <source>/_config.yml or <source>/<config_file>
|
|
104
108
|
config_files = override.delete('config')
|
|
105
|
-
|
|
109
|
+
if config_files.to_s.empty?
|
|
110
|
+
config_files = File.join(source(override), "_config.yml")
|
|
111
|
+
@default_config_file = true
|
|
112
|
+
end
|
|
106
113
|
config_files = [config_files] unless config_files.is_a? Array
|
|
107
114
|
config_files
|
|
108
115
|
end
|
|
@@ -114,9 +121,17 @@ module Monad
|
|
|
114
121
|
# Returns this configuration, overridden by the values in the file
|
|
115
122
|
def read_config_file(file)
|
|
116
123
|
next_config = YAML.safe_load_file(file)
|
|
117
|
-
raise "Configuration file: (INVALID) #{file}".yellow if !next_config.is_a?(Hash)
|
|
118
|
-
|
|
124
|
+
raise ArgumentError.new("Configuration file: (INVALID) #{file}".yellow) if !next_config.is_a?(Hash)
|
|
125
|
+
Jekyll.logger.info "Configuration file:", file
|
|
119
126
|
next_config
|
|
127
|
+
rescue SystemCallError
|
|
128
|
+
if @default_config_file
|
|
129
|
+
Jekyll.logger.warn "Configuration file:", "none"
|
|
130
|
+
{}
|
|
131
|
+
else
|
|
132
|
+
Jekyll.logger.error "Fatal:", "The configuration file '#{file}' could not be found."
|
|
133
|
+
raise LoadError
|
|
134
|
+
end
|
|
120
135
|
end
|
|
121
136
|
|
|
122
137
|
# Public: Read in a list of configuration files and merge with this hash
|
|
@@ -133,27 +148,33 @@ module Monad
|
|
|
133
148
|
new_config = read_config_file(config_file)
|
|
134
149
|
configuration = configuration.deep_merge(new_config)
|
|
135
150
|
end
|
|
136
|
-
rescue
|
|
137
|
-
|
|
138
|
-
Monad::Logger.warn "Configuration file:", "none"
|
|
139
|
-
rescue => err
|
|
140
|
-
Monad::Logger.warn "WARNING:", "Error reading configuration. " +
|
|
151
|
+
rescue ArgumentError => err
|
|
152
|
+
Jekyll.logger.warn "WARNING:", "Error reading configuration. " +
|
|
141
153
|
"Using defaults (and options)."
|
|
142
154
|
$stderr.puts "#{err}"
|
|
143
155
|
end
|
|
144
156
|
|
|
145
|
-
configuration.backwards_compatibilize
|
|
157
|
+
configuration.fix_common_issues.backwards_compatibilize
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# Public: Split a CSV string into an array containing its values
|
|
161
|
+
#
|
|
162
|
+
# csv - the string of comma-separated values
|
|
163
|
+
#
|
|
164
|
+
# Returns an array of the values contained in the CSV
|
|
165
|
+
def csv_to_array(csv)
|
|
166
|
+
csv.split(",").map(&:strip)
|
|
146
167
|
end
|
|
147
168
|
|
|
148
169
|
# Public: Ensure the proper options are set in the configuration to allow for
|
|
149
|
-
# backwards-compatibility with
|
|
170
|
+
# backwards-compatibility with Jekyll pre-1.0
|
|
150
171
|
#
|
|
151
172
|
# Returns the backwards-compatible configuration
|
|
152
173
|
def backwards_compatibilize
|
|
153
174
|
config = clone
|
|
154
175
|
# Provide backwards-compatibility
|
|
155
176
|
if config.has_key?('auto') || config.has_key?('watch')
|
|
156
|
-
|
|
177
|
+
Jekyll.logger.warn "Deprecation:", "Auto-regeneration can no longer" +
|
|
157
178
|
" be set from your configuration file(s). Use the"+
|
|
158
179
|
" --watch/-w command-line option instead."
|
|
159
180
|
config.delete('auto')
|
|
@@ -161,14 +182,14 @@ module Monad
|
|
|
161
182
|
end
|
|
162
183
|
|
|
163
184
|
if config.has_key? 'server'
|
|
164
|
-
|
|
165
|
-
" is no longer accepted. Use the '
|
|
185
|
+
Jekyll.logger.warn "Deprecation:", "The 'server' configuration option" +
|
|
186
|
+
" is no longer accepted. Use the 'jekyll serve'" +
|
|
166
187
|
" subcommand to serve your site with WEBrick."
|
|
167
188
|
config.delete('server')
|
|
168
189
|
end
|
|
169
190
|
|
|
170
191
|
if config.has_key? 'server_port'
|
|
171
|
-
|
|
192
|
+
Jekyll.logger.warn "Deprecation:", "The 'server_port' configuration option" +
|
|
172
193
|
" has been renamed to 'port'. Please update your config" +
|
|
173
194
|
" file accordingly."
|
|
174
195
|
# copy but don't overwrite:
|
|
@@ -176,6 +197,27 @@ module Monad
|
|
|
176
197
|
config.delete('server_port')
|
|
177
198
|
end
|
|
178
199
|
|
|
200
|
+
%w[include exclude].each do |option|
|
|
201
|
+
if config.fetch(option, []).is_a?(String)
|
|
202
|
+
Jekyll.logger.warn "Deprecation:", "The '#{option}' configuration option" +
|
|
203
|
+
" must now be specified as an array, but you specified" +
|
|
204
|
+
" a string. For now, we've treated the string you provided" +
|
|
205
|
+
" as a list of comma-separated values."
|
|
206
|
+
config[option] = csv_to_array(config[option])
|
|
207
|
+
end
|
|
208
|
+
end
|
|
209
|
+
config
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
def fix_common_issues
|
|
213
|
+
config = clone
|
|
214
|
+
|
|
215
|
+
if config.has_key?('paginate') && (!config['paginate'].is_a?(Integer) || config['paginate'] < 1)
|
|
216
|
+
Jekyll.logger.warn "Config Warning:", "The `paginate` key must be a" +
|
|
217
|
+
" positive integer or nil. It's currently set to '#{config['paginate'].inspect}'."
|
|
218
|
+
config['paginate'] = nil
|
|
219
|
+
end
|
|
220
|
+
|
|
179
221
|
config
|
|
180
222
|
end
|
|
181
223
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module
|
|
1
|
+
module Jekyll
|
|
2
2
|
module Converters
|
|
3
3
|
class Markdown < Converter
|
|
4
4
|
safe true
|
|
@@ -26,7 +26,7 @@ module Monad
|
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def matches(ext)
|
|
29
|
-
rgx = '(' + @config['markdown_ext'].gsub(',','|') +')'
|
|
29
|
+
rgx = '^\.(' + @config['markdown_ext'].gsub(',','|') +')$'
|
|
30
30
|
ext =~ Regexp.new(rgx, Regexp::IGNORECASE)
|
|
31
31
|
end
|
|
32
32
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Jekyll
|
|
2
|
+
module Converters
|
|
3
|
+
class Markdown
|
|
4
|
+
class KramdownParser
|
|
5
|
+
def initialize(config)
|
|
6
|
+
require 'kramdown'
|
|
7
|
+
@config = config
|
|
8
|
+
rescue LoadError
|
|
9
|
+
STDERR.puts 'You are missing a library required for Markdown. Please run:'
|
|
10
|
+
STDERR.puts ' $ [sudo] gem install kramdown'
|
|
11
|
+
raise FatalException.new("Missing dependency: kramdown")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def convert(content)
|
|
15
|
+
# Check for use of coderay
|
|
16
|
+
if @config['kramdown']['use_coderay']
|
|
17
|
+
%w[wrap line_numbers line_numbers_start tab_width bold_every css default_lang].each do |opt|
|
|
18
|
+
key = "coderay_#{opt}"
|
|
19
|
+
@config['kramdown'][key] = @config['kramdown']['coderay'][key] unless @config['kramdown'].has_key?(key)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
Kramdown::Document.new(content, @config["kramdown"].symbolize_keys).to_html
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
module
|
|
1
|
+
module Jekyll
|
|
2
2
|
module Converters
|
|
3
3
|
class Markdown
|
|
4
4
|
class MarukuParser
|
|
5
5
|
def initialize(config)
|
|
6
6
|
require 'maruku'
|
|
7
7
|
@config = config
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if @config['maruku']['use_tex']
|
|
12
|
-
load_blahtext_library
|
|
13
|
-
end
|
|
8
|
+
@errors = []
|
|
9
|
+
load_divs_library if @config['maruku']['use_divs']
|
|
10
|
+
load_blahtext_library if @config['maruku']['use_tex']
|
|
14
11
|
rescue LoadError
|
|
15
12
|
STDERR.puts 'You are missing a library required for Markdown. Please run:'
|
|
16
13
|
STDERR.puts ' $ [sudo] gem install maruku'
|
|
@@ -38,8 +35,15 @@ module Monad
|
|
|
38
35
|
MaRuKu::Globals[:html_png_url] = @config['maruku']['png_url']
|
|
39
36
|
end
|
|
40
37
|
|
|
38
|
+
def print_errors_and_fail
|
|
39
|
+
print @errors.join
|
|
40
|
+
raise MaRuKu::Exception, "MaRuKu encountered problem(s) while converting your markup."
|
|
41
|
+
end
|
|
42
|
+
|
|
41
43
|
def convert(content)
|
|
42
|
-
Maruku.new(content).to_html
|
|
44
|
+
converted = Maruku.new(content, :error_stream => @errors).to_html
|
|
45
|
+
print_errors_and_fail unless @errors.empty?
|
|
46
|
+
converted
|
|
43
47
|
end
|
|
44
48
|
end
|
|
45
49
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module
|
|
1
|
+
module Jekyll
|
|
2
2
|
module Converters
|
|
3
3
|
class Markdown
|
|
4
4
|
class RDiscountParser
|
|
@@ -24,7 +24,9 @@ module Monad
|
|
|
24
24
|
private
|
|
25
25
|
def replace_generated_toc(rd, html, toc_token)
|
|
26
26
|
if rd.generate_toc && html.include?(toc_token)
|
|
27
|
-
|
|
27
|
+
utf8_toc = rd.toc_content
|
|
28
|
+
utf8_toc.force_encoding('utf-8') if utf8_toc.respond_to?(:force_encoding)
|
|
29
|
+
html.gsub(toc_token, utf8_toc)
|
|
28
30
|
else
|
|
29
31
|
html
|
|
30
32
|
end
|
|
@@ -6,36 +6,43 @@ require 'set'
|
|
|
6
6
|
# from a certain type of markup into actual content
|
|
7
7
|
#
|
|
8
8
|
# Requires
|
|
9
|
-
# self.site ->
|
|
9
|
+
# self.site -> Jekyll::Site
|
|
10
10
|
# self.content
|
|
11
11
|
# self.content=
|
|
12
12
|
# self.data=
|
|
13
13
|
# self.ext=
|
|
14
14
|
# self.output=
|
|
15
15
|
# self.name
|
|
16
|
-
module
|
|
16
|
+
module Jekyll
|
|
17
17
|
module Convertible
|
|
18
18
|
# Returns the contents as a String.
|
|
19
19
|
def to_s
|
|
20
20
|
self.content || ''
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
+
# Returns merged optin hash for File.read of self.site (if exists)
|
|
24
|
+
# and a given param
|
|
25
|
+
def merged_file_read_opts(opts)
|
|
26
|
+
(self.site ? self.site.file_read_opts : {}).merge(opts)
|
|
27
|
+
end
|
|
28
|
+
|
|
23
29
|
# Read the YAML frontmatter.
|
|
24
30
|
#
|
|
25
31
|
# base - The String path to the dir containing the file.
|
|
26
32
|
# name - The String filename of the file.
|
|
33
|
+
# opts - optional parameter to File.read, default at site configs
|
|
27
34
|
#
|
|
28
35
|
# Returns nothing.
|
|
29
|
-
def read_yaml(base, name)
|
|
36
|
+
def read_yaml(base, name, opts = {})
|
|
30
37
|
begin
|
|
31
|
-
self.content = File.
|
|
32
|
-
|
|
38
|
+
self.content = File.read_with_options(File.join(base, name),
|
|
39
|
+
merged_file_read_opts(opts))
|
|
33
40
|
if self.content =~ /\A(---\s*\n.*?\n?)^(---\s*$\n?)/m
|
|
34
41
|
self.content = $POSTMATCH
|
|
35
42
|
self.data = YAML.safe_load($1)
|
|
36
43
|
end
|
|
37
44
|
rescue SyntaxError => e
|
|
38
|
-
puts "YAML Exception reading #{File.join(base, name)}: #{e.message}"
|
|
45
|
+
puts "YAML Exception reading #{File.join(base, name)}: #{e.message}"
|
|
39
46
|
rescue Exception => e
|
|
40
47
|
puts "Error reading file #{File.join(base, name)}: #{e.message}"
|
|
41
48
|
end
|
|
@@ -48,6 +55,10 @@ module Monad
|
|
|
48
55
|
# Returns nothing.
|
|
49
56
|
def transform
|
|
50
57
|
self.content = converter.convert(self.content)
|
|
58
|
+
rescue => e
|
|
59
|
+
Jekyll.logger.error "Conversion error:", "There was an error converting" +
|
|
60
|
+
" '#{self.path}'."
|
|
61
|
+
raise e
|
|
51
62
|
end
|
|
52
63
|
|
|
53
64
|
# Determine the extension depending on content_type.
|
|
@@ -73,14 +84,24 @@ module Monad
|
|
|
73
84
|
# info - the info for Liquid
|
|
74
85
|
#
|
|
75
86
|
# Returns the converted content
|
|
76
|
-
def render_liquid(content, payload, info)
|
|
87
|
+
def render_liquid(content, payload, info, path = nil)
|
|
77
88
|
Liquid::Template.parse(content).render!(payload, info)
|
|
89
|
+
rescue Tags::IncludeTagError => e
|
|
90
|
+
Jekyll.logger.error "Liquid Exception:", "#{e.message} in #{e.path}"
|
|
91
|
+
raise e
|
|
78
92
|
rescue Exception => e
|
|
79
|
-
|
|
80
|
-
e
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
93
|
+
Jekyll.logger.error "Liquid Exception:", "#{e.message} in #{path || self.path}"
|
|
94
|
+
raise e
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# Convert this Convertible's data to a Hash suitable for use by Liquid.
|
|
98
|
+
#
|
|
99
|
+
# Returns the Hash representation of this Convertible.
|
|
100
|
+
def to_liquid(attrs = nil)
|
|
101
|
+
further_data = Hash[(attrs || self.class::ATTRIBUTES_FOR_LIQUID).map { |attribute|
|
|
102
|
+
[attribute, send(attribute)]
|
|
103
|
+
}]
|
|
104
|
+
data.deep_merge(further_data)
|
|
84
105
|
end
|
|
85
106
|
|
|
86
107
|
# Recursively render layouts
|
|
@@ -99,8 +120,9 @@ module Monad
|
|
|
99
120
|
payload = payload.deep_merge({"content" => self.output, "page" => layout.data})
|
|
100
121
|
|
|
101
122
|
self.output = self.render_liquid(layout.content,
|
|
102
|
-
payload
|
|
103
|
-
info
|
|
123
|
+
payload,
|
|
124
|
+
info,
|
|
125
|
+
File.join(self.site.config['layouts'], layout.name))
|
|
104
126
|
|
|
105
127
|
if layout = layouts[layout.data["layout"]]
|
|
106
128
|
if used.include?(layout)
|
|
@@ -119,14 +141,14 @@ module Monad
|
|
|
119
141
|
#
|
|
120
142
|
# Returns nothing.
|
|
121
143
|
def do_layout(payload, layouts)
|
|
122
|
-
info = { :filters => [
|
|
144
|
+
info = { :filters => [Jekyll::Filters], :registers => { :site => self.site, :page => payload['page'] } }
|
|
123
145
|
|
|
124
146
|
# render and transform content (this becomes the final content of the object)
|
|
125
147
|
payload["pygments_prefix"] = converter.pygments_prefix
|
|
126
148
|
payload["pygments_suffix"] = converter.pygments_suffix
|
|
127
149
|
|
|
128
150
|
self.content = self.render_liquid(self.content,
|
|
129
|
-
payload
|
|
151
|
+
payload,
|
|
130
152
|
info)
|
|
131
153
|
self.transform
|
|
132
154
|
|
|
@@ -144,7 +166,7 @@ module Monad
|
|
|
144
166
|
def write(dest)
|
|
145
167
|
path = destination(dest)
|
|
146
168
|
FileUtils.mkdir_p(File.dirname(path))
|
|
147
|
-
File.open(path, '
|
|
169
|
+
File.open(path, 'wb') do |f|
|
|
148
170
|
f.write(self.output)
|
|
149
171
|
end
|
|
150
172
|
end
|
|
@@ -41,6 +41,17 @@ class Hash
|
|
|
41
41
|
end
|
|
42
42
|
array || []
|
|
43
43
|
end
|
|
44
|
+
|
|
45
|
+
def symbolize_keys!
|
|
46
|
+
keys.each do |key|
|
|
47
|
+
self[(key.to_sym rescue key) || key] = delete(key)
|
|
48
|
+
end
|
|
49
|
+
self
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def symbolize_keys
|
|
53
|
+
dup.symbolize_keys!
|
|
54
|
+
end
|
|
44
55
|
end
|
|
45
56
|
|
|
46
57
|
# Thanks, ActiveSupport!
|
|
@@ -59,10 +70,17 @@ module Enumerable
|
|
|
59
70
|
end
|
|
60
71
|
end
|
|
61
72
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
73
|
+
# Ruby 1.8's File.read don't support option.
|
|
74
|
+
# read_with_options ignore optional parameter for 1.8,
|
|
75
|
+
# and act as alias for 1.9 or later.
|
|
76
|
+
class File
|
|
77
|
+
if RUBY_VERSION < '1.9'
|
|
78
|
+
def self.read_with_options(path, opts = {})
|
|
79
|
+
self.read(path)
|
|
80
|
+
end
|
|
81
|
+
else
|
|
82
|
+
def self.read_with_options(path, opts = {})
|
|
83
|
+
self.read(path, opts)
|
|
66
84
|
end
|
|
67
85
|
end
|
|
68
86
|
end
|