tigefa 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.markdown +0 -144
- data/LICENSE +1 -1
- data/README.markdown +6 -10
- data/Rakefile +6 -13
- data/bin/tigefa +22 -26
- data/features/create_sites.feature +0 -11
- data/features/include_tag.feature +0 -22
- data/features/markdown.feature +4 -41
- data/features/site_configuration.feature +4 -33
- data/features/site_data.feature +4 -4
- data/features/step_definitions/{tigefa_steps.rb → jekyll_steps.rb} +17 -32
- data/features/support/env.rb +2 -38
- data/lib/site_template/_config.yml +2 -2
- data/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb +1 -0
- data/lib/site_template/css/main.css +15 -15
- data/lib/tigefa.rb +2 -5
- data/lib/tigefa/cleaner.rb +8 -8
- data/lib/tigefa/commands/build.rb +8 -14
- data/lib/tigefa/commands/new.rb +1 -1
- data/lib/tigefa/commands/serve.rb +0 -2
- data/lib/tigefa/configuration.rb +5 -21
- data/lib/tigefa/converters/markdown/kramdown_parser.rb +1 -1
- data/lib/tigefa/converters/markdown/maruku_parser.rb +1 -6
- data/lib/tigefa/convertible.rb +6 -17
- data/lib/tigefa/core_ext.rb +0 -19
- data/lib/tigefa/deprecator.rb +1 -1
- data/lib/tigefa/filters.rb +2 -12
- data/lib/tigefa/generators/pagination.rb +6 -9
- data/lib/tigefa/page.rb +1 -1
- data/lib/tigefa/post.rb +4 -4
- data/lib/tigefa/related_posts.rb +1 -1
- data/lib/tigefa/site.rb +50 -90
- data/lib/tigefa/stevenson.rb +4 -4
- data/lib/tigefa/tags/gist.rb +1 -9
- data/lib/tigefa/tags/highlight.rb +1 -1
- data/lib/tigefa/tags/include.rb +32 -75
- data/lib/tigefa/tags/post_url.rb +4 -6
- data/lib/tigefa/url.rb +0 -2
- data/site/_includes/docs_contents.html +1 -1
- data/site/_includes/docs_contents_mobile.html +1 -1
- data/site/_includes/top.html +1 -1
- data/site/docs/configuration.md +0 -19
- data/site/docs/deployment-methods.md +3 -3
- data/site/docs/drafts.md +3 -4
- data/site/docs/history.md +3 -147
- data/site/docs/installation.md +0 -10
- data/site/docs/migrations.md +240 -3
- data/site/docs/pages.md +7 -7
- data/site/docs/pagination.md +37 -16
- data/site/docs/plugins.md +7 -72
- data/site/docs/posts.md +1 -1
- data/site/docs/structure.md +0 -17
- data/site/docs/templates.md +7 -40
- data/site/docs/upgrading.md +3 -3
- data/site/docs/usage.md +1 -1
- data/site/docs/variables.md +2 -2
- data/test/helper.rb +1 -4
- data/test/test_configuration.rb +7 -16
- data/test/test_convertible.rb +1 -1
- data/test/test_excerpt.rb +3 -3
- data/test/test_filters.rb +0 -11
- data/test/test_generated_site.rb +1 -1
- data/test/test_kramdown.rb +5 -32
- data/test/test_new_command.rb +1 -1
- data/test/test_page.rb +0 -10
- data/test/test_post.rb +1 -12
- data/test/test_redcloth.rb +3 -3
- data/test/test_site.rb +64 -58
- data/test/test_tags.rb +35 -68
- data/tigefa.gemspec +15 -39
- metadata +101 -126
- checksums.yaml +0 -7
- data/features/data.feature +0 -65
- data/lib/tigefa/entry_filter.rb +0 -35
- data/site/_posts/2013-10-28-jekyll-1-3-0-rc1-released.markdown +0 -19
- data/site/_posts/2013-11-04-jekyll-1-3-0-released.markdown +0 -43
- data/site/_posts/2013-11-26-jekyll-1-3-1-released.markdown +0 -21
- data/site/_posts/2013-12-07-jekyll-1-4-0-released.markdown +0 -30
- data/site/_posts/2013-12-16-jekyll-1-4-2-released.markdown +0 -18
- data/site/_posts/2014-01-13-jekyll-1-4-3-released.markdown +0 -27
- data/site/docs/datafiles.md +0 -63
- data/test/source/_config.dev.toml +0 -2
- data/test/source/_data/languages.yml +0 -2
- data/test/source/_data/members.yaml +0 -7
- data/test/source/_data/products.yml +0 -1
- data/test/source/_includes/tmp +0 -1
- data/test/source/_layouts/post/simple.html +0 -1
- data/test/source/_posts/2014-01-06-permalink-traversal.md +0 -5
- data/test/source/exploit.md +0 -5
- data/test/source/products.yml +0 -4
- data/test/source/symlink-test/_data +0 -1
- data/test/test_entry_filter.rb +0 -74
@@ -31,33 +31,27 @@ module Tigefa
|
|
31
31
|
#
|
32
32
|
# Returns nothing.
|
33
33
|
def self.watch(site, options)
|
34
|
-
require '
|
34
|
+
require 'directory_watcher'
|
35
35
|
|
36
36
|
source = options['source']
|
37
37
|
destination = options['destination']
|
38
38
|
|
39
|
-
begin
|
40
|
-
dest = Pathname.new(destination).relative_path_from(Pathname.new(source)).to_s
|
41
|
-
ignored = Regexp.new(Regexp.escape(dest))
|
42
|
-
rescue ArgumentError
|
43
|
-
# Destination is outside the source, no need to ignore it.
|
44
|
-
ignored = nil
|
45
|
-
end
|
46
|
-
|
47
39
|
Tigefa.logger.info "Auto-regeneration:", "enabled"
|
48
40
|
|
49
|
-
|
41
|
+
dw = DirectoryWatcher.new(source, :glob => self.globs(source, destination), :pre_load => true)
|
42
|
+
dw.interval = 1
|
43
|
+
|
44
|
+
dw.add_observer do |*args|
|
50
45
|
t = Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
51
|
-
|
52
|
-
print Tigefa.logger.formatted_topic("Regenerating:") + "#{n} files at #{t} "
|
46
|
+
print Tigefa.logger.formatted_topic("Regenerating:") + "#{args.size} files at #{t} "
|
53
47
|
self.process_site(site)
|
54
48
|
puts "...done."
|
55
49
|
end
|
56
|
-
|
50
|
+
|
51
|
+
dw.start
|
57
52
|
|
58
53
|
unless options['serving']
|
59
54
|
trap("INT") do
|
60
|
-
listener.stop
|
61
55
|
puts " Halting auto-regeneration."
|
62
56
|
exit 0
|
63
57
|
end
|
data/lib/tigefa/commands/new.rb
CHANGED
@@ -18,8 +18,6 @@ module Tigefa
|
|
18
18
|
|
19
19
|
s.mount(options['baseurl'], HTTPServlet::FileHandler, destination, fh_option)
|
20
20
|
|
21
|
-
Tigefa.logger.info "Server address:", "http://#{s.config[:BindAddress]}:#{s.config[:Port]}"
|
22
|
-
|
23
21
|
if options['detach'] # detach the server
|
24
22
|
pid = Process.fork { s.start }
|
25
23
|
Process.detach(pid)
|
data/lib/tigefa/configuration.rb
CHANGED
@@ -10,14 +10,10 @@ module Tigefa
|
|
10
10
|
'destination' => File.join(Dir.pwd, '_site'),
|
11
11
|
'plugins' => '_plugins',
|
12
12
|
'layouts' => '_layouts',
|
13
|
-
'data_source' => '_data',
|
14
13
|
'keep_files' => ['.git','.svn'],
|
15
|
-
'gems' => [],
|
16
14
|
|
17
15
|
'timezone' => nil, # use the local timezone
|
18
16
|
|
19
|
-
'encoding' => nil, # use the system encoding
|
20
|
-
|
21
17
|
'safe' => false,
|
22
18
|
'detach' => false, # default to not detaching the server
|
23
19
|
'show_drafts' => nil,
|
@@ -27,7 +23,7 @@ module Tigefa
|
|
27
23
|
'pygments' => true,
|
28
24
|
|
29
25
|
'relative_permalinks' => true, # backwards-compatibility with < 1.0
|
30
|
-
# will be set to false once
|
26
|
+
# will be set to false once 1.1 hits
|
31
27
|
|
32
28
|
'markdown' => 'maruku',
|
33
29
|
'permalink' => 'date',
|
@@ -45,7 +41,6 @@ module Tigefa
|
|
45
41
|
'excerpt_separator' => "\n\n",
|
46
42
|
|
47
43
|
'maruku' => {
|
48
|
-
'fenced_code_blocks' => true,
|
49
44
|
'use_tex' => false,
|
50
45
|
'use_divs' => false,
|
51
46
|
'png_engine' => 'blahtex',
|
@@ -100,17 +95,6 @@ module Tigefa
|
|
100
95
|
override['source'] || self['source'] || DEFAULTS['source']
|
101
96
|
end
|
102
97
|
|
103
|
-
def safe_load_file(filename)
|
104
|
-
case File.extname(filename)
|
105
|
-
when '.toml'
|
106
|
-
TOML.load_file(filename)
|
107
|
-
when /\.y(a)?ml/
|
108
|
-
YAML.safe_load_file(filename)
|
109
|
-
else
|
110
|
-
raise ArgumentError, "No parser for '#{filename}' is available. Use a .toml or .y(a)ml file instead."
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
98
|
# Public: Generate list of configuration files from the override
|
115
99
|
#
|
116
100
|
# override - the command-line options hash
|
@@ -133,8 +117,8 @@ module Tigefa
|
|
133
117
|
#
|
134
118
|
# Returns this configuration, overridden by the values in the file
|
135
119
|
def read_config_file(file)
|
136
|
-
next_config = safe_load_file(file)
|
137
|
-
raise ArgumentError.new("Configuration file: (INVALID) #{file}".yellow)
|
120
|
+
next_config = YAML.safe_load_file(file)
|
121
|
+
raise ArgumentError.new("Configuration file: (INVALID) #{file}".yellow) if !next_config.is_a?(Hash)
|
138
122
|
Tigefa.logger.info "Configuration file:", file
|
139
123
|
next_config
|
140
124
|
rescue SystemCallError
|
@@ -143,7 +127,7 @@ module Tigefa
|
|
143
127
|
{}
|
144
128
|
else
|
145
129
|
Tigefa.logger.error "Fatal:", "The configuration file '#{file}' could not be found."
|
146
|
-
raise LoadError
|
130
|
+
raise LoadError
|
147
131
|
end
|
148
132
|
end
|
149
133
|
|
@@ -180,7 +164,7 @@ module Tigefa
|
|
180
164
|
end
|
181
165
|
|
182
166
|
# Public: Ensure the proper options are set in the configuration to allow for
|
183
|
-
# backwards-compatibility with
|
167
|
+
# backwards-compatibility with Tigefa pre-1.0
|
184
168
|
#
|
185
169
|
# Returns the backwards-compatible configuration
|
186
170
|
def backwards_compatibilize
|
@@ -16,7 +16,7 @@ module Tigefa
|
|
16
16
|
if @config['kramdown']['use_coderay']
|
17
17
|
%w[wrap line_numbers line_numbers_start tab_width bold_every css default_lang].each do |opt|
|
18
18
|
key = "coderay_#{opt}"
|
19
|
-
@config['kramdown'][key] = @config['kramdown']['coderay'][key] unless @config['kramdown'].has_key?(key)
|
19
|
+
@config['kramdown'][key.to_sym] = @config['kramdown']['coderay'][key] unless @config['kramdown'].has_key?(key)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -8,7 +8,6 @@ module Tigefa
|
|
8
8
|
@errors = []
|
9
9
|
load_divs_library if @config['maruku']['use_divs']
|
10
10
|
load_blahtext_library if @config['maruku']['use_tex']
|
11
|
-
enable_fenced_code_blocks if @config['maruku']['fenced_code_blocks']
|
12
11
|
rescue LoadError
|
13
12
|
STDERR.puts 'You are missing a library required for Markdown. Please run:'
|
14
13
|
STDERR.puts ' $ [sudo] gem install maruku'
|
@@ -36,17 +35,13 @@ module Tigefa
|
|
36
35
|
MaRuKu::Globals[:html_png_url] = @config['maruku']['png_url']
|
37
36
|
end
|
38
37
|
|
39
|
-
def enable_fenced_code_blocks
|
40
|
-
MaRuKu::Globals[:fenced_code_blocks] = true
|
41
|
-
end
|
42
|
-
|
43
38
|
def print_errors_and_fail
|
44
39
|
print @errors.join
|
45
40
|
raise MaRuKu::Exception, "MaRuKu encountered problem(s) while converting your markup."
|
46
41
|
end
|
47
42
|
|
48
43
|
def convert(content)
|
49
|
-
converted = Maruku.new(content, :error_stream => @errors).to_html
|
44
|
+
converted = Maruku.new(content, :error_stream => @errors).to_html
|
50
45
|
print_errors_and_fail unless @errors.empty?
|
51
46
|
converted
|
52
47
|
end
|
data/lib/tigefa/convertible.rb
CHANGED
@@ -20,23 +20,16 @@ module Tigefa
|
|
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
|
-
|
29
23
|
# Read the YAML frontmatter.
|
30
24
|
#
|
31
25
|
# base - The String path to the dir containing the file.
|
32
26
|
# name - The String filename of the file.
|
33
|
-
# opts - optional parameter to File.read, default at site configs
|
34
27
|
#
|
35
28
|
# Returns nothing.
|
36
|
-
def read_yaml(base, name
|
29
|
+
def read_yaml(base, name)
|
37
30
|
begin
|
38
|
-
self.content = File.
|
39
|
-
|
31
|
+
self.content = File.read(File.join(base, name))
|
32
|
+
|
40
33
|
if self.content =~ /\A(---\s*\n.*?\n?)^(---\s*$\n?)/m
|
41
34
|
self.content = $POSTMATCH
|
42
35
|
self.data = YAML.safe_load($1)
|
@@ -84,13 +77,10 @@ module Tigefa
|
|
84
77
|
# info - the info for Liquid
|
85
78
|
#
|
86
79
|
# Returns the converted content
|
87
|
-
def render_liquid(content, payload, info
|
80
|
+
def render_liquid(content, payload, info)
|
88
81
|
Liquid::Template.parse(content).render!(payload, info)
|
89
|
-
rescue Tags::IncludeTagError => e
|
90
|
-
Tigefa.logger.error "Liquid Exception:", "#{e.message} in #{e.path}, included in #{path || self.path}"
|
91
|
-
raise e
|
92
82
|
rescue Exception => e
|
93
|
-
Tigefa.logger.error "Liquid Exception:", "#{e.message} in #{
|
83
|
+
Tigefa.logger.error "Liquid Exception:", "#{e.message} in #{self.path}"
|
94
84
|
raise e
|
95
85
|
end
|
96
86
|
|
@@ -121,8 +111,7 @@ module Tigefa
|
|
121
111
|
|
122
112
|
self.output = self.render_liquid(layout.content,
|
123
113
|
payload,
|
124
|
-
info
|
125
|
-
File.join(self.site.config['layouts'], layout.name))
|
114
|
+
info)
|
126
115
|
|
127
116
|
if layout = layouts[layout.data["layout"]]
|
128
117
|
if used.include?(layout)
|
data/lib/tigefa/core_ext.rb
CHANGED
@@ -69,22 +69,3 @@ module Enumerable
|
|
69
69
|
any? { |exp| File.fnmatch?(exp, e) }
|
70
70
|
end
|
71
71
|
end
|
72
|
-
|
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
|
-
|
82
|
-
def self.realpath(filename)
|
83
|
-
Pathname.new(filename).realpath.to_s
|
84
|
-
end
|
85
|
-
else
|
86
|
-
def self.read_with_options(path, opts = {})
|
87
|
-
self.read(path, opts)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
data/lib/tigefa/deprecator.rb
CHANGED
@@ -19,7 +19,7 @@ module Tigefa
|
|
19
19
|
def self.no_subcommand(args)
|
20
20
|
if args.size > 0 && args.first =~ /^--/ && !%w[--help --version].include?(args.first)
|
21
21
|
Tigefa.logger.error "Deprecation:", "Tigefa now uses subcommands instead of just \
|
22
|
-
switches. Run `
|
22
|
+
switches. Run `tigefa help' to find out more."
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
data/lib/tigefa/filters.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'uri'
|
2
|
-
require 'json'
|
3
2
|
|
4
3
|
module Tigefa
|
5
4
|
module Filters
|
@@ -10,7 +9,7 @@ module Tigefa
|
|
10
9
|
# Returns the HTML formatted String.
|
11
10
|
def textilize(input)
|
12
11
|
site = @context.registers[:site]
|
13
|
-
converter = site.getConverterImpl(
|
12
|
+
converter = site.getConverterImpl(Tigefa::Converters::Textile)
|
14
13
|
converter.convert(input)
|
15
14
|
end
|
16
15
|
|
@@ -21,7 +20,7 @@ module Tigefa
|
|
21
20
|
# Returns the HTML formatted String.
|
22
21
|
def markdownify(input)
|
23
22
|
site = @context.registers[:site]
|
24
|
-
converter = site.getConverterImpl(
|
23
|
+
converter = site.getConverterImpl(Tigefa::Converters::Markdown)
|
25
24
|
converter.convert(input)
|
26
25
|
end
|
27
26
|
|
@@ -149,15 +148,6 @@ module Tigefa
|
|
149
148
|
end
|
150
149
|
end
|
151
150
|
|
152
|
-
# Convert the input into json string
|
153
|
-
#
|
154
|
-
# input - The Array or Hash to be converted
|
155
|
-
#
|
156
|
-
# Returns the converted json string
|
157
|
-
def jsonify(input)
|
158
|
-
input.to_json
|
159
|
-
end
|
160
|
-
|
161
151
|
private
|
162
152
|
def time(input)
|
163
153
|
case input
|
@@ -4,9 +4,6 @@ module Tigefa
|
|
4
4
|
# This generator is safe from arbitrary code execution.
|
5
5
|
safe true
|
6
6
|
|
7
|
-
# This generator should be passive with regard to its execution
|
8
|
-
priority :lowest
|
9
|
-
|
10
7
|
# Generate paginated pages if necessary.
|
11
8
|
#
|
12
9
|
# site - The Site.
|
@@ -17,7 +14,7 @@ module Tigefa
|
|
17
14
|
if template = template_page(site)
|
18
15
|
paginate(site, template)
|
19
16
|
else
|
20
|
-
Tigefa.logger.warn "Pagination:", "Pagination is enabled, but I couldn't find
|
17
|
+
Tigefa.logger.warn "Pagination:", "Pagination is enabled, but I couldn't find" +
|
21
18
|
"an index.html page to use as the pagination template. Skipping pagination."
|
22
19
|
end
|
23
20
|
end
|
@@ -98,7 +95,7 @@ module Tigefa
|
|
98
95
|
|
99
96
|
# Determine if pagination is enabled the site.
|
100
97
|
#
|
101
|
-
# site - the
|
98
|
+
# site - the Tigefa::Site object
|
102
99
|
#
|
103
100
|
# Returns true if pagination is enabled, false otherwise.
|
104
101
|
def self.pagination_enabled?(site)
|
@@ -111,7 +108,7 @@ module Tigefa
|
|
111
108
|
# between the site source and `paginate_path`.
|
112
109
|
#
|
113
110
|
# config - the site configuration hash
|
114
|
-
# page - the
|
111
|
+
# page - the Tigefa::Page about which we're inquiring
|
115
112
|
#
|
116
113
|
# Returns true if the
|
117
114
|
def self.pagination_candidate?(config, page)
|
@@ -125,7 +122,7 @@ module Tigefa
|
|
125
122
|
# Determine if the subdirectories of the two paths are the same relative to source
|
126
123
|
#
|
127
124
|
# source - the site source
|
128
|
-
# page_dir - the directory of the
|
125
|
+
# page_dir - the directory of the Tigefa::Page
|
129
126
|
# paginate_path - the absolute paginate path (from root of FS)
|
130
127
|
#
|
131
128
|
# Returns whether the subdirectories are the same relative to source
|
@@ -138,7 +135,7 @@ module Tigefa
|
|
138
135
|
|
139
136
|
# Static: Return the pagination path of the page
|
140
137
|
#
|
141
|
-
# site - the
|
138
|
+
# site - the Tigefa::Site object
|
142
139
|
# num_page - the pagination page number
|
143
140
|
#
|
144
141
|
# Returns the pagination path as a string
|
@@ -172,7 +169,7 @@ module Tigefa
|
|
172
169
|
|
173
170
|
# Initialize a new Pager.
|
174
171
|
#
|
175
|
-
# site - the
|
172
|
+
# site - the Tigefa::Site object
|
176
173
|
# page - The Integer page number.
|
177
174
|
# all_posts - The Array of all the site's Posts.
|
178
175
|
# num_pages - The Integer number of pages or nil if you'd like the number
|
data/lib/tigefa/page.rb
CHANGED
@@ -133,7 +133,7 @@ module Tigefa
|
|
133
133
|
#
|
134
134
|
# Returns the destination file path String.
|
135
135
|
def destination(dest)
|
136
|
-
path = File.join(dest,
|
136
|
+
path = File.join(dest, self.url)
|
137
137
|
path = File.join(path, "index.html") if self.url =~ /\/$/
|
138
138
|
path
|
139
139
|
end
|
data/lib/tigefa/post.rb
CHANGED
@@ -19,10 +19,10 @@ module Tigefa
|
|
19
19
|
]
|
20
20
|
|
21
21
|
# Attributes for Liquid templates
|
22
|
-
ATTRIBUTES_FOR_LIQUID = EXCERPT_ATTRIBUTES_FOR_LIQUID
|
22
|
+
ATTRIBUTES_FOR_LIQUID = EXCERPT_ATTRIBUTES_FOR_LIQUID.concat(%w[
|
23
23
|
content
|
24
24
|
excerpt
|
25
|
-
]
|
25
|
+
])
|
26
26
|
|
27
27
|
# Post name validator. Post filenames must be like:
|
28
28
|
# 2008-11-05-my-awesome-post.textile
|
@@ -236,7 +236,7 @@ module Tigefa
|
|
236
236
|
#
|
237
237
|
# Returns an Array of related Posts.
|
238
238
|
def related_posts(posts)
|
239
|
-
|
239
|
+
Jekyll::RelatedPosts.new(self).build
|
240
240
|
end
|
241
241
|
|
242
242
|
# Add any necessary layouts to this post.
|
@@ -266,7 +266,7 @@ module Tigefa
|
|
266
266
|
# Returns destination file path String.
|
267
267
|
def destination(dest)
|
268
268
|
# The url needs to be unescaped in order to preserve the correct filename
|
269
|
-
path = File.join(dest,
|
269
|
+
path = File.join(dest, CGI.unescape(self.url))
|
270
270
|
path = File.join(path, "index.html") if path[/\.html$/].nil?
|
271
271
|
path
|
272
272
|
end
|
data/lib/tigefa/related_posts.rb
CHANGED
data/lib/tigefa/site.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
module
|
1
|
+
module TigefaTigefa
|
2
2
|
class Site
|
3
3
|
attr_accessor :config, :layouts, :posts, :pages, :static_files,
|
4
4
|
:categories, :exclude, :include, :source, :dest, :lsi, :pygments,
|
5
5
|
:permalink_style, :tags, :time, :future, :safe, :plugins, :limit_posts,
|
6
|
-
:show_drafts, :keep_files, :baseurl
|
6
|
+
:show_drafts, :keep_files, :baseurl
|
7
7
|
|
8
8
|
attr_accessor :converters, :generators
|
9
9
|
|
@@ -13,7 +13,7 @@ module Tigefa
|
|
13
13
|
def initialize(config)
|
14
14
|
self.config = config.clone
|
15
15
|
|
16
|
-
%w[safe lsi pygments baseurl exclude include future show_drafts limit_posts keep_files
|
16
|
+
%w[safe lsi pygments baseurl exclude include future show_drafts limit_posts keep_files].each do |opt|
|
17
17
|
self.send("#{opt}=", config[opt])
|
18
18
|
end
|
19
19
|
|
@@ -22,9 +22,6 @@ module Tigefa
|
|
22
22
|
self.plugins = plugins_path
|
23
23
|
self.permalink_style = config['permalink'].to_sym
|
24
24
|
|
25
|
-
self.file_read_opts = {}
|
26
|
-
self.file_read_opts[:encoding] = config['encoding'] if config['encoding']
|
27
|
-
|
28
25
|
self.reset
|
29
26
|
self.setup
|
30
27
|
end
|
@@ -56,7 +53,6 @@ module Tigefa
|
|
56
53
|
self.static_files = []
|
57
54
|
self.categories = Hash.new { |hash, key| hash[key] = [] }
|
58
55
|
self.tags = Hash.new { |hash, key| hash[key] = [] }
|
59
|
-
self.data = {}
|
60
56
|
|
61
57
|
if self.limit_posts < 0
|
62
58
|
raise ArgumentError, "limit_posts must be a non-negative number"
|
@@ -67,41 +63,31 @@ module Tigefa
|
|
67
63
|
#
|
68
64
|
# Returns nothing.
|
69
65
|
def setup
|
70
|
-
|
66
|
+
# Check that the destination dir isn't the source dir or a directory
|
67
|
+
# parent to the source dir.
|
68
|
+
if self.source =~ /^#{self.dest}/
|
69
|
+
raise FatalException.new "Destination directory cannot be or contain the Source directory."
|
70
|
+
end
|
71
71
|
|
72
72
|
# If safe mode is off, load in any Ruby files under the plugins
|
73
73
|
# directory.
|
74
74
|
unless self.safe
|
75
75
|
self.plugins.each do |plugins|
|
76
|
-
Dir[File.join(plugins, "**/*.rb")].
|
76
|
+
Dir[File.join(plugins, "**/*.rb")].each do |f|
|
77
77
|
require f
|
78
78
|
end
|
79
79
|
end
|
80
|
-
self.gems.each do |gem|
|
81
|
-
require gem
|
82
|
-
end
|
83
80
|
end
|
84
81
|
|
85
|
-
self.converters = instantiate_subclasses(
|
86
|
-
self.generators = instantiate_subclasses(
|
87
|
-
end
|
88
|
-
|
89
|
-
# Check that the destination dir isn't the source dir or a directory
|
90
|
-
# parent to the source dir.
|
91
|
-
def ensure_not_in_dest
|
92
|
-
dest = Pathname.new(self.dest)
|
93
|
-
Pathname.new(self.source).ascend do |path|
|
94
|
-
if path == dest
|
95
|
-
raise FatalException.new "Destination directory cannot be or contain the Source directory."
|
96
|
-
end
|
97
|
-
end
|
82
|
+
self.converters = instantiate_subclasses(Tigefa::Converter)
|
83
|
+
self.generators = instantiate_subclasses(Tigefa::Generator)
|
98
84
|
end
|
99
85
|
|
100
86
|
# Internal: Setup the plugin search path
|
101
87
|
#
|
102
88
|
# Returns an Array of plugin search paths
|
103
89
|
def plugins_path
|
104
|
-
if (config['plugins'] ==
|
90
|
+
if (config['plugins'] == Tigefa::Configuration::DEFAULTS['plugins'])
|
105
91
|
[File.join(self.source, config['plugins'])]
|
106
92
|
else
|
107
93
|
Array(config['plugins']).map { |d| File.expand_path(d) }
|
@@ -114,7 +100,6 @@ module Tigefa
|
|
114
100
|
def read
|
115
101
|
self.read_layouts
|
116
102
|
self.read_directories
|
117
|
-
self.read_data(config['data_source'])
|
118
103
|
end
|
119
104
|
|
120
105
|
# Read all the files in <source>/<layouts> and create a new Layout object
|
@@ -125,7 +110,7 @@ module Tigefa
|
|
125
110
|
base = File.join(self.source, self.config['layouts'])
|
126
111
|
return unless File.exists?(base)
|
127
112
|
entries = []
|
128
|
-
Dir.chdir(base) { entries = filter_entries(Dir['
|
113
|
+
Dir.chdir(base) { entries = filter_entries(Dir['*.*']) }
|
129
114
|
|
130
115
|
entries.each do |f|
|
131
116
|
name = f.split(".")[0..-2].join(".")
|
@@ -169,14 +154,19 @@ module Tigefa
|
|
169
154
|
#
|
170
155
|
# Returns nothing.
|
171
156
|
def read_posts(dir)
|
172
|
-
|
157
|
+
entries = get_entries(dir, '_posts')
|
158
|
+
|
159
|
+
# first pass processes, but does not yet render post content
|
160
|
+
entries.each do |f|
|
161
|
+
if Post.valid?(f)
|
162
|
+
post = Post.new(self, self.source, dir, f)
|
173
163
|
|
174
|
-
|
175
|
-
|
176
|
-
|
164
|
+
if post.published && (self.future || post.date <= self.time)
|
165
|
+
aggregate_post_info(post)
|
166
|
+
end
|
177
167
|
end
|
178
168
|
end
|
179
|
-
|
169
|
+
end
|
180
170
|
|
181
171
|
# Read all the files in <source>/<dir>/_drafts and create a new Post
|
182
172
|
# object with each one.
|
@@ -185,37 +175,15 @@ module Tigefa
|
|
185
175
|
#
|
186
176
|
# Returns nothing.
|
187
177
|
def read_drafts(dir)
|
188
|
-
|
189
|
-
|
190
|
-
drafts.each do |draft|
|
191
|
-
aggregate_post_info(draft)
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
def read_things(dir, magic_dir, klass)
|
196
|
-
get_entries(dir, magic_dir).map do |entry|
|
197
|
-
klass.new(self, self.source, dir, entry) if klass.valid?(entry)
|
198
|
-
end.reject do |entry|
|
199
|
-
entry.nil?
|
200
|
-
end
|
201
|
-
end
|
202
|
-
|
203
|
-
# Read and parse all yaml files under <source>/<dir>
|
204
|
-
#
|
205
|
-
# Returns nothing
|
206
|
-
def read_data(dir)
|
207
|
-
base = File.join(self.source, dir)
|
208
|
-
return unless File.directory?(base) && (!self.safe || !File.symlink?(base))
|
178
|
+
entries = get_entries(dir, '_drafts')
|
209
179
|
|
210
|
-
|
211
|
-
entries.
|
212
|
-
|
213
|
-
|
214
|
-
path = File.join(self.source, dir, entry)
|
215
|
-
next if File.symlink?(path) && self.safe
|
180
|
+
# first pass processes, but does not yet render draft content
|
181
|
+
entries.each do |f|
|
182
|
+
if Draft.valid?(f)
|
183
|
+
draft = Draft.new(self, self.source, dir, f)
|
216
184
|
|
217
|
-
|
218
|
-
|
185
|
+
aggregate_post_info(draft)
|
186
|
+
end
|
219
187
|
end
|
220
188
|
end
|
221
189
|
|
@@ -232,11 +200,14 @@ module Tigefa
|
|
232
200
|
#
|
233
201
|
# Returns nothing.
|
234
202
|
def render
|
235
|
-
relative_permalinks_deprecation_method
|
236
|
-
|
237
203
|
payload = site_payload
|
238
|
-
|
239
|
-
|
204
|
+
self.posts.each do |post|
|
205
|
+
post.render(self.layouts, payload)
|
206
|
+
end
|
207
|
+
|
208
|
+
self.pages.each do |page|
|
209
|
+
relative_permalinks_deprecation_method if page.uses_relative_permalinks
|
210
|
+
page.render(self.layouts, payload)
|
240
211
|
end
|
241
212
|
|
242
213
|
self.categories.values.map { |ps| ps.sort! { |a, b| b <=> a } }
|
@@ -281,14 +252,6 @@ module Tigefa
|
|
281
252
|
hash
|
282
253
|
end
|
283
254
|
|
284
|
-
# Prepare site data for site payload. The method maintains backward compatibility
|
285
|
-
# if the key 'data' is already used in _config.yml.
|
286
|
-
#
|
287
|
-
# Returns the Hash to be hooked to site.data.
|
288
|
-
def site_data
|
289
|
-
self.config['data'] || self.data
|
290
|
-
end
|
291
|
-
|
292
255
|
# The Hash payload containing site-wide data.
|
293
256
|
#
|
294
257
|
# Returns the Hash: { "site" => data } where data is a Hash with keys:
|
@@ -303,15 +266,14 @@ module Tigefa
|
|
303
266
|
# "tags" - The Hash of tag values and Posts.
|
304
267
|
# See Site#post_attr_hash for type info.
|
305
268
|
def site_payload
|
306
|
-
{"
|
269
|
+
{"tigefa" => { "version" => Tigefa::VERSION },
|
307
270
|
"site" => self.config.merge({
|
308
271
|
"time" => self.time,
|
309
272
|
"posts" => self.posts.sort { |a, b| b <=> a },
|
310
273
|
"pages" => self.pages,
|
311
274
|
"html_pages" => self.pages.reject { |page| !page.html? },
|
312
275
|
"categories" => post_attr_hash('categories'),
|
313
|
-
"tags" => post_attr_hash('tags')
|
314
|
-
"data" => site_data})}
|
276
|
+
"tags" => post_attr_hash('tags')})}
|
315
277
|
end
|
316
278
|
|
317
279
|
# Filter out any files/directories that are hidden or backup files (start
|
@@ -323,7 +285,14 @@ module Tigefa
|
|
323
285
|
#
|
324
286
|
# Returns the Array of filtered entries.
|
325
287
|
def filter_entries(entries)
|
326
|
-
|
288
|
+
entries.reject do |e|
|
289
|
+
unless self.include.glob_include?(e)
|
290
|
+
['.', '_', '#'].include?(e[0..0]) ||
|
291
|
+
e[-1..-1] == '~' ||
|
292
|
+
self.exclude.glob_include?(e) ||
|
293
|
+
(File.symlink?(e) && self.safe)
|
294
|
+
end
|
295
|
+
end
|
327
296
|
end
|
328
297
|
|
329
298
|
# Get the implementation class for the given Converter.
|
@@ -380,14 +349,15 @@ module Tigefa
|
|
380
349
|
end
|
381
350
|
|
382
351
|
def relative_permalinks_deprecation_method
|
383
|
-
if config['relative_permalinks'] &&
|
352
|
+
if config['relative_permalinks'] && !@deprecated_relative_permalinks
|
384
353
|
$stderr.puts # Places newline after "Generating..."
|
385
|
-
Tigefa.logger.warn "Deprecation:", "Starting in
|
354
|
+
Tigefa.logger.warn "Deprecation:", "Starting in 1.1, permalinks for pages" +
|
386
355
|
" in subfolders must be relative to the" +
|
387
356
|
" site source directory, not the parent" +
|
388
357
|
" directory. Check http://jekyllrb.com/docs/upgrading/"+
|
389
358
|
" for more info."
|
390
359
|
$stderr.print Tigefa.logger.formatted_topic("") + "..." # for "done."
|
360
|
+
@deprecated_relative_permalinks = true
|
391
361
|
end
|
392
362
|
end
|
393
363
|
|
@@ -401,10 +371,6 @@ module Tigefa
|
|
401
371
|
|
402
372
|
private
|
403
373
|
|
404
|
-
def has_relative_page?
|
405
|
-
self.pages.any? { |page| page.uses_relative_permalinks }
|
406
|
-
end
|
407
|
-
|
408
374
|
def has_yaml_header?(file)
|
409
375
|
"---" == File.open(file) { |fd| fd.read(3) }
|
410
376
|
end
|
@@ -417,11 +383,5 @@ module Tigefa
|
|
417
383
|
def site_cleaner
|
418
384
|
@site_cleaner ||= Cleaner.new(self)
|
419
385
|
end
|
420
|
-
|
421
|
-
def sanitize_filename(name)
|
422
|
-
name = name.gsub(/[^\w\s_-]+/, '')
|
423
|
-
name = name.gsub(/(^|\b\s)\s+($|\s?\b)/, '\\1\\2')
|
424
|
-
name = name.gsub(/\s+/, '_')
|
425
|
-
end
|
426
386
|
end
|
427
387
|
end
|