webgen 1.4.0 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/data/webgen/passive_sources/default.metainfo +4 -4
- data/lib/webgen/blackboard.rb +2 -2
- data/lib/webgen/bundle/built-in/init.rb +2 -2
- data/lib/webgen/content_processor/blocks.rb +1 -2
- data/lib/webgen/content_processor/sass.rb +2 -2
- data/lib/webgen/content_processor/tikz.rb +2 -2
- data/lib/webgen/content_processor/xmllint.rb +1 -1
- data/lib/webgen/destination/file_system.rb +1 -1
- data/lib/webgen/rake_task.rb +2 -2
- data/lib/webgen/source/file_system.rb +1 -1
- data/lib/webgen/tag/include_file.rb +2 -2
- data/lib/webgen/task/create_website.rb +9 -9
- data/lib/webgen/utils.rb +1 -1
- data/lib/webgen/vendor/rainpress.rb +26 -26
- data/lib/webgen/version.rb +1 -1
- data/test/test_documentation.rb +0 -3
- data/test/webgen/cli/test_logger.rb +1 -1
- data/test/webgen/content_processor/test_html_head.rb +1 -1
- data/test/webgen/content_processor/test_kramdown.rb +1 -1
- data/test/webgen/content_processor/test_ruby.rb +1 -1
- data/test/webgen/content_processor/test_sass.rb +2 -2
- data/test/webgen/content_processor/test_tags.rb +1 -1
- data/test/webgen/content_processor/test_tikz.rb +5 -2
- data/test/webgen/path_handler/test_api.rb +1 -1
- data/test/webgen/path_handler/test_base.rb +2 -2
- data/test/webgen/path_handler/test_copy.rb +1 -1
- data/test/webgen/path_handler/test_template.rb +1 -1
- data/test/webgen/path_handler/test_virtual.rb +1 -1
- data/test/webgen/tag/test_breadcrumb_trail.rb +1 -1
- data/test/webgen/tag/test_langbar.rb +1 -1
- data/test/webgen/test_cache.rb +2 -2
- data/test/webgen/test_cli.rb +2 -2
- data/test/webgen/test_destination.rb +1 -1
- data/test/webgen/test_node.rb +1 -1
- data/test/webgen/test_path.rb +2 -2
- data/test/webgen/test_tree.rb +13 -13
- data/test/webgen/utils/test_tag_parser.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d93b547db495a7469b8a3b038da5ab6eae16c083
|
4
|
+
data.tar.gz: d634fdc3f669cde58f29346d2a769c1ecd1bdbf3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e82628dd6abefd5c7eee3266e77b0a435671486a0460e014c9ba46b6c7e29552cb9bdcbf152e1be3ee1dcc66501ec71a4c6a4434d311ab68bb785ff94ab0d81
|
7
|
+
data.tar.gz: 838e654ae206a8a79554ac6c71d46daa4719758518c60a5e117f4068c07777fc6d0e0f917974081ed07dfbdbef1325fab144ec2442467820fd708f7ffad63f2b
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.4.
|
1
|
+
1.4.1
|
@@ -1,8 +1,4 @@
|
|
1
1
|
--- paths
|
2
|
-
/**/:
|
3
|
-
handler: directory
|
4
|
-
proxy_path: index.html
|
5
|
-
|
6
2
|
/**/*.template:
|
7
3
|
handler: template
|
8
4
|
blocks: {defaults: {pipeline: [erb,tags,blocks,html_head]}}
|
@@ -45,3 +41,7 @@
|
|
45
41
|
handler: copy
|
46
42
|
pipeline: scss
|
47
43
|
no_output: true
|
44
|
+
|
45
|
+
/**/:
|
46
|
+
handler: directory
|
47
|
+
proxy_path: index.html
|
data/lib/webgen/blackboard.rb
CHANGED
@@ -22,9 +22,9 @@ module Webgen
|
|
22
22
|
# unknown ID is specified, the listener is added as last entry in the listener array.
|
23
23
|
def add_listener(msg_name, id = nil, position = {}, &block)
|
24
24
|
position = if position[:before]
|
25
|
-
(@listener[msg_name] || []).index {|
|
25
|
+
(@listener[msg_name] || []).index {|lid, obj| lid == position[:before]}
|
26
26
|
elsif position[:after]
|
27
|
-
(pos = (@listener[msg_name] || []).index {|
|
27
|
+
(pos = (@listener[msg_name] || []).index {|lid, obj| lid == position[:after]}) && pos + 1
|
28
28
|
end
|
29
29
|
insert_listener_at_position(msg_name, id, position || -1, &block)
|
30
30
|
end
|
@@ -285,7 +285,7 @@ option('tag.include_file.escape_html', true, &true_or_false)
|
|
285
285
|
|
286
286
|
tag.register('Coderay', :mandatory => ['lang'])
|
287
287
|
option('tag.coderay.lang', 'ruby')
|
288
|
-
option('tag.coderay.process_body', true &true_or_false)
|
288
|
+
option('tag.coderay.process_body', true, &true_or_false)
|
289
289
|
option('tag.coderay.wrap', 'div') do |val|
|
290
290
|
val = val.to_s.intern
|
291
291
|
raise "The value has to be either div or span" unless val == :div || val == :span
|
@@ -313,7 +313,7 @@ option('tag.langbar.separator', ' | ')
|
|
313
313
|
option('tag.langbar.mapping', {}, &is_hash)
|
314
314
|
|
315
315
|
tag.register('BreadcrumbTrail')
|
316
|
-
option('tag.breadcrumb_trail.omit_dir_index', false &true_or_false)
|
316
|
+
option('tag.breadcrumb_trail.omit_dir_index', false, &true_or_false)
|
317
317
|
option('tag.breadcrumb_trail.start_level', 0, &is_integer)
|
318
318
|
option('tag.breadcrumb_trail.end_level', -1, &is_integer)
|
319
319
|
option('tag.breadcrumb_trail.separator', ' / ', &is_string)
|
@@ -55,15 +55,14 @@ module Webgen
|
|
55
55
|
used_chain = (context[:chain].length > 1 ? context[:chain][1..-1] : context[:chain].dup)
|
56
56
|
elsif options[:chain].kind_of?(Array)
|
57
57
|
used_chain = options[:chain]
|
58
|
-
dest_node = context.dest_node
|
59
58
|
else
|
60
59
|
paths = options[:chain].split(';')
|
61
60
|
used_chain = paths.collect do |path|
|
62
61
|
context.ref_node.resolve(path.strip, context.dest_node.lang, true)
|
63
62
|
end.compact
|
64
63
|
return '' if used_chain.length != paths.length
|
65
|
-
dest_node = context.dest_node
|
66
64
|
end
|
65
|
+
dest_node = context.dest_node
|
67
66
|
|
68
67
|
if options[:node] == 'first'
|
69
68
|
used_chain.shift while used_chain.length > 0 && !used_chain.first.blocks.has_key?(options[:name])
|
@@ -96,8 +96,8 @@ module Webgen
|
|
96
96
|
def possible_filenames(path)
|
97
97
|
dirname, basename = File.split(path)
|
98
98
|
basename, ext = basename.scan(/^(.*?)(?:\.(sass|scss))?$/).first
|
99
|
-
(ext.nil? ? %w{sass scss} : [ext]).map do |
|
100
|
-
[["#{dirname}/_#{basename}.#{
|
99
|
+
(ext.nil? ? %w{sass scss} : [ext]).map do |iext|
|
100
|
+
[["#{dirname}/_#{basename}.#{iext}", iext.to_sym], ["#{dirname}/#{basename}.#{iext}", iext.to_sym]]
|
101
101
|
end.flatten(1)
|
102
102
|
end
|
103
103
|
|
@@ -67,7 +67,7 @@ module Webgen
|
|
67
67
|
render_res, output_res = context['content_processor.tikz.resolution'].split(' ')
|
68
68
|
|
69
69
|
File.write(tex_file, context.content)
|
70
|
-
execute("pdflatex -shell-escape -interaction=nonstopmode -halt-on-error #{basename}.tex", cwd, context) do |
|
70
|
+
execute("pdflatex -shell-escape -interaction=nonstopmode -halt-on-error #{basename}.tex", cwd, context) do |_status, stdout, stderr|
|
71
71
|
errors = (stdout+stderr).scan(/^!(.*\n.*)/).join("\n")
|
72
72
|
raise Webgen::RenderError.new("Error while parsing TikZ picture commands with PDFLaTeX: #{errors}",
|
73
73
|
'content_processor.tikz', context.dest_node, context.ref_node)
|
@@ -84,7 +84,7 @@ module Webgen
|
|
84
84
|
execute(cmd, cwd, context)
|
85
85
|
|
86
86
|
if render_res != output_res
|
87
|
-
|
87
|
+
_status, stdout, _stderr = execute("identify #{basename}#{ext}", cwd, context)
|
88
88
|
width, height = stdout.scan(/\s\d+x\d+\s/).first.strip.split('x').collect do |s|
|
89
89
|
s.to_f * output_res.to_f / render_res.to_f
|
90
90
|
end
|
@@ -14,7 +14,7 @@ module Webgen
|
|
14
14
|
Webgen::Utils::ExternalCommand.ensure_available!('xmllint', '--version')
|
15
15
|
|
16
16
|
cmd = "xmllint #{context.website.config['content_processor.xmllint.options']} -"
|
17
|
-
status,
|
17
|
+
status, _stdout, stderr = systemu(cmd, 'stdin' => context.content)
|
18
18
|
if status.exitstatus != 0
|
19
19
|
stderr.scan(/^-:(\d+):(.*?\n)(.*?\n)/).each do |line, error_msg, line_context|
|
20
20
|
context.website.logger.warn do
|
data/lib/webgen/rake_task.rb
CHANGED
@@ -139,10 +139,10 @@ module Webgen
|
|
139
139
|
website.execute_task(:generate_website)
|
140
140
|
end
|
141
141
|
|
142
|
-
task :clobber =>
|
142
|
+
task :clobber => "clobber_#{@name}".intern
|
143
143
|
|
144
144
|
desc "Remove webgen products"
|
145
|
-
task
|
145
|
+
task "clobber_#{@name}".intern do
|
146
146
|
require 'webgen/website'
|
147
147
|
require 'webgen/cli'
|
148
148
|
website = Webgen::Website.new(@directory, Webgen::CLI::Logger.new($stdout), &@config_block)
|
@@ -28,7 +28,7 @@ module Webgen
|
|
28
28
|
# Return all paths under the root path which match the glob.
|
29
29
|
def paths
|
30
30
|
@paths ||= Dir.glob(File.join(@root, @glob), File::FNM_DOTMATCH|File::FNM_CASEFOLD).collect do |f|
|
31
|
-
next unless File.
|
31
|
+
next unless File.exist?(f) && f !~ /\/\.\.$/ # handle invalid links
|
32
32
|
temp = Pathname.new(f.sub(/^#{Regexp.escape(@root)}\/?/, '/')).cleanpath.to_s
|
33
33
|
temp += '/' if File.directory?(f) && temp[-1] != ?/
|
34
34
|
Path.new(temp, 'modified_at' => File.mtime(f)) {|mode| File.open(f, mode)}
|
@@ -11,10 +11,10 @@ module Webgen
|
|
11
11
|
|
12
12
|
# Include the specified file verbatim in the output, optionally escaping special HTML characters
|
13
13
|
# and/or processing tags in it.
|
14
|
-
def self.call(tag,
|
14
|
+
def self.call(tag, _body, context)
|
15
15
|
filename = context[:config]['tag.include_file.filename']
|
16
16
|
filename = File.join(context.website.directory, filename) unless filename =~ /^(\/|\w:)/
|
17
|
-
if !File.
|
17
|
+
if !File.exist?(filename)
|
18
18
|
raise Webgen::RenderError.new("File '#{filename}' cannot be included because it does not exist",
|
19
19
|
"tag.#{tag}", context.dest_node, context.ref_node)
|
20
20
|
end
|
@@ -55,7 +55,7 @@ module Webgen
|
|
55
55
|
#
|
56
56
|
# Returns +true+ if the website has been created.
|
57
57
|
def self.call(website, template = nil)
|
58
|
-
if File.
|
58
|
+
if File.exist?(website.directory)
|
59
59
|
raise Error.new("Directory <#{website.directory}> does already exist!")
|
60
60
|
end
|
61
61
|
if template && !website.ext.task.data(:create_website)[:templates].has_key?(template)
|
@@ -64,18 +64,18 @@ module Webgen
|
|
64
64
|
|
65
65
|
begin
|
66
66
|
Dir.mktmpdir do |tmpdir|
|
67
|
-
ws = Webgen::Website.new(tmpdir) do |
|
68
|
-
|
67
|
+
ws = Webgen::Website.new(tmpdir) do |iws|
|
68
|
+
iws.config['sources'] = [['/', :file_system, File.join(Webgen::Utils.data_dir, 'basic_website_template')]]
|
69
69
|
if template
|
70
|
-
|
70
|
+
iws.config['sources'].unshift(['/', :file_system, website.ext.task.data(:create_website)[:templates][template]])
|
71
71
|
end
|
72
|
-
|
73
|
-
|
72
|
+
iws.config['destination'] = [:file_system, File.expand_path(website.directory)]
|
73
|
+
iws.ext.path_handler.registered_extensions.each do |_name, data|
|
74
74
|
data.patterns = []
|
75
75
|
end
|
76
|
-
|
77
|
-
|
78
|
-
|
76
|
+
iws.ext.path_handler.registered_extensions[:copy].patterns = ['**/*', '**/']
|
77
|
+
iws.logger.level = ::Logger::INFO
|
78
|
+
iws.logger.formatter = Proc.new do |_severity, _timestamp, _progname, msg|
|
79
79
|
website.logger.vinfo(msg) if msg =~ /\[create\]/
|
80
80
|
end
|
81
81
|
end
|
data/lib/webgen/utils.rb
CHANGED
@@ -13,7 +13,7 @@ module Webgen
|
|
13
13
|
unless defined?(@@data_dir)
|
14
14
|
require 'rbconfig'
|
15
15
|
@@data_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'data', 'webgen'))
|
16
|
-
@@data_dir = File.expand_path(File.join(RbConfig::CONFIG["datadir"], "webgen")) if !File.
|
16
|
+
@@data_dir = File.expand_path(File.join(RbConfig::CONFIG["datadir"], "webgen")) if !File.exist?(@@data_dir)
|
17
17
|
raise "Could not find webgen data directory! This is a bug, report it please!" unless File.directory?(@@data_dir)
|
18
18
|
end
|
19
19
|
@@data_dir
|
@@ -72,7 +72,7 @@ class Rainpress
|
|
72
72
|
#
|
73
73
|
# We take care of Windows(\r\n), Unix(\n) and Mac(\r) newlines.
|
74
74
|
def remove_newlines!
|
75
|
-
@style.gsub!
|
75
|
+
@style.gsub!(/\n|\r/, '')
|
76
76
|
end
|
77
77
|
|
78
78
|
# Remove unneeded spaces
|
@@ -81,9 +81,9 @@ class Rainpress
|
|
81
81
|
# 2. Remove spaces around ;:{},
|
82
82
|
# 3. Remove tabs
|
83
83
|
def remove_spaces!
|
84
|
-
@style.gsub!
|
85
|
-
@style.gsub!
|
86
|
-
|
84
|
+
@style.gsub!(/\s*(\s|;|:|\}|\{|,)\s*/, '\1')
|
85
|
+
@style.gsub!("\t", '')
|
86
|
+
end
|
87
87
|
|
88
88
|
# Replace color values with their shorter equivalent
|
89
89
|
#
|
@@ -94,9 +94,9 @@ class Rainpress
|
|
94
94
|
# * black -> #000
|
95
95
|
# 4. Replace #-values with their shorter name
|
96
96
|
# * #f00 -> red
|
97
|
-
|
97
|
+
def shorten_colors!
|
98
98
|
# rgb(50,101,152) to #326598
|
99
|
-
@style.gsub!
|
99
|
+
@style.gsub!(/rgb\s*\(\s*([0-9,\s]+)\s*\)/) do |match|
|
100
100
|
out = '#'
|
101
101
|
$1.split(',').each do |num|
|
102
102
|
out += '0' if num.to_i < 16
|
@@ -105,7 +105,7 @@ class Rainpress
|
|
105
105
|
out
|
106
106
|
end
|
107
107
|
# Convert #AABBCC to #ABC, keep if preceed by a '='
|
108
|
-
@style.gsub!
|
108
|
+
@style.gsub!(/([^\"'=\s])(\s*)#([\da-f])\3([\da-f])\4([\da-f])\5/i, '\1#\3\4\5')
|
109
109
|
|
110
110
|
# At the moment we assume that colours only appear before ';' or '}' and
|
111
111
|
# after a ':', if there could be an occurence of a color before or after
|
@@ -114,55 +114,55 @@ class Rainpress
|
|
114
114
|
|
115
115
|
# shorten several names to numbers
|
116
116
|
## shorten white -> #fff
|
117
|
-
@style.gsub!
|
117
|
+
@style.gsub!(/:\s*white\s*(;|\})/, ':#fff\1')
|
118
118
|
|
119
119
|
## shorten black -> #000
|
120
|
-
@style.gsub!
|
120
|
+
@style.gsub!(/:\s*black\s*(;|\})/, ':#000\1')
|
121
121
|
|
122
122
|
# shotern several numbers to names
|
123
123
|
## shorten #f00 or #ff0000 -> red
|
124
|
-
@style.gsub!
|
124
|
+
@style.gsub!(/:\s*#f{1,2}0{2,4}(;|\})/i, ':red\1')
|
125
125
|
end
|
126
126
|
|
127
127
|
# Do miscellaneous compression methods on the style.
|
128
128
|
def do_misc!
|
129
129
|
# Replace 0(pt,px,em,%) with 0 but only when preceded by : or a white-space
|
130
|
-
@style.gsub!
|
130
|
+
@style.gsub!(/([\s:]+)(0)(px|em|%|in|cm|mm|pc|pt|ex)/i, '\1\2')
|
131
131
|
|
132
132
|
# Replace :0 0 0 0(;|}) with :0(;|})
|
133
|
-
@style.gsub!
|
133
|
+
@style.gsub!(/:0 0 0 0(;|\})/, ':0\1')
|
134
134
|
|
135
135
|
# Replace :0 0 0(;|}) with :0(;|})
|
136
|
-
@style.gsub!
|
136
|
+
@style.gsub!(/:0 0 0(;|\})/, ':0\1')
|
137
137
|
|
138
138
|
# Replace :0 0(;|}) with :0(;|})
|
139
|
-
@style.gsub!
|
139
|
+
@style.gsub!(/:0 0(;|\})/, ':0\1')
|
140
140
|
|
141
141
|
# Replace background-position:0; with background-position:0 0;
|
142
|
-
@style.gsub!
|
142
|
+
@style.gsub!('background-position:0;', 'background-position:0 0;')
|
143
143
|
|
144
144
|
# Replace 0.6 to .6, but only when preceded by : or a white-space
|
145
|
-
@style.gsub!
|
146
|
-
match.sub
|
145
|
+
@style.gsub!(/[:\s]0+\.(\d+)/) do |match|
|
146
|
+
match.sub('0', '') # only first '0' !!
|
147
147
|
end
|
148
148
|
|
149
149
|
# Replace multiple ';' with a single ';'
|
150
|
-
@style.gsub!
|
150
|
+
@style.gsub!(/[;]+/, ';')
|
151
151
|
|
152
152
|
# Replace ;} with }
|
153
|
-
@style.gsub!
|
153
|
+
@style.gsub!(';}', '}')
|
154
154
|
|
155
155
|
# Replace font-weight:normal; with 400
|
156
|
-
@style.gsub!
|
157
|
-
@style.gsub!
|
158
|
-
match.sub
|
156
|
+
@style.gsub!(/font-weight[\s]*:[\s]*normal[\s]*(;|\})/i,'font-weight:400\1')
|
157
|
+
@style.gsub!(/font[\s]*:[\s]*normal[\s;\}]*/) do |match|
|
158
|
+
match.sub('normal', '400')
|
159
159
|
end
|
160
160
|
|
161
161
|
# Replace font-weight:bold; with 700
|
162
|
-
@style.gsub!
|
163
|
-
@style.gsub!
|
164
|
-
match.sub
|
162
|
+
@style.gsub!(/font-weight[\s]*:[\s]*bold[\s]*(;|\})/,'font-weight:700\1')
|
163
|
+
@style.gsub!(/font[\s]*:[\s]*bold[\s;\}]*/) do |match|
|
164
|
+
match.sub('bold', '700')
|
165
165
|
end
|
166
166
|
end
|
167
167
|
|
168
|
-
end
|
168
|
+
end
|
data/lib/webgen/version.rb
CHANGED
data/test/test_documentation.rb
CHANGED
@@ -11,8 +11,6 @@ class TestExtensionDocumentation < Minitest::Test
|
|
11
11
|
def test_all_extensions_documented
|
12
12
|
ws = Webgen::Website.new(File.join(Dir.tmpdir, '/abcdefgh'))
|
13
13
|
documentation = ws.ext.bundle_infos.extensions.dup
|
14
|
-
author = "Thomas Leitner <t_leitner@gmx.at>"
|
15
|
-
docu_keys = Set.new(documentation.keys)
|
16
14
|
ext_keys = Set.new(ws.ext.instance_eval { @table.keys })
|
17
15
|
|
18
16
|
check_docu = lambda do |key|
|
@@ -47,7 +45,6 @@ class TestExtensionDocumentation < Minitest::Test
|
|
47
45
|
def test_all_config_options_documented
|
48
46
|
ws = Webgen::Website.new(File.join(Dir.tmpdir, '/abcdefgh'))
|
49
47
|
documentation = ws.ext.bundle_infos.options.dup
|
50
|
-
docu_keys = Set.new(documentation.keys)
|
51
48
|
|
52
49
|
check_docu = lambda do |key|
|
53
50
|
data = documentation.delete(key.to_s)
|
@@ -13,7 +13,7 @@ class TestLogger < Minitest::Test
|
|
13
13
|
def test_log_output
|
14
14
|
original = Webgen::CLI::Utils.use_colors
|
15
15
|
Webgen::CLI::Utils.use_colors = false
|
16
|
-
out,
|
16
|
+
out, _err = capture_io do
|
17
17
|
l = Webgen::CLI::Logger.new
|
18
18
|
l.level = ::Logger::DEBUG
|
19
19
|
l.info { "information" }
|
@@ -17,7 +17,7 @@ class TestHtmlHead < Minitest::Test
|
|
17
17
|
def test_call
|
18
18
|
context = Webgen::Context.new(@website, :chain => [@node])
|
19
19
|
context.content = "</head>"
|
20
|
-
|
20
|
+
Webgen::Node.new(@root, 'test', 'test.de', {'lang' => 'de'})
|
21
21
|
assert_equal("\n<link type=\"text/html\" rel=\"alternate\" hreflang=\"de\" href=\"test.de\" /></head>",
|
22
22
|
@obj.call(context).content)
|
23
23
|
end
|
@@ -11,7 +11,7 @@ class TestContentProcessorKramdown < Minitest::Test
|
|
11
11
|
setup_context
|
12
12
|
cp = Webgen::ContentProcessor::Kramdown
|
13
13
|
root = Webgen::Node.new(@website.tree.dummy_root, '/', '/')
|
14
|
-
|
14
|
+
Webgen::Node.new(root, 'hello.html', '/hello.en.html')
|
15
15
|
@website.config['content_processor.kramdown.options'] = {:auto_ids => true}
|
16
16
|
@website.config['content_processor.kramdown.handle_links'] = true
|
17
17
|
@website.config['content_processor.kramdown.ignore_unknown_fragments'] = false
|
@@ -15,7 +15,7 @@ class TestSass < Minitest::Test
|
|
15
15
|
cp = Webgen::ContentProcessor::Sass
|
16
16
|
|
17
17
|
@context.content = "#main\n :background-color #000"
|
18
|
-
result = "#main {\n background-color:
|
18
|
+
result = "#main {\n background-color: #000; }\n"
|
19
19
|
assert_equal(result, cp.call(@context).content)
|
20
20
|
|
21
21
|
@context.content = "#cont\n = 5"
|
@@ -33,7 +33,7 @@ class TestSass < Minitest::Test
|
|
33
33
|
partial2 = Webgen::Node.new(dirdir, '_other.scss', '/dir/dir/_other.scss')
|
34
34
|
partial2.node_info[:path] = Webgen::Path.new('test') { StringIO.new('#id { color:white; }') }
|
35
35
|
dir2 = Webgen::Node.new(root, 'dir2/', '/dir2/')
|
36
|
-
|
36
|
+
Webgen::Node.new(dir2, 'file.test', '/dir2/file.test')
|
37
37
|
|
38
38
|
@context[:chain] = [sass]
|
39
39
|
@context.content = "@import 'unknown'"
|
@@ -34,7 +34,7 @@ class TestContentProcessorTags < Minitest::Test
|
|
34
34
|
|
35
35
|
stag.set_block do |tag, params, body, local_context|
|
36
36
|
assert_equal('test', tag)
|
37
|
-
|
37
|
+
assert_nil(params)
|
38
38
|
assert_equal('', body)
|
39
39
|
assert_equal(@context, local_context)
|
40
40
|
end
|
@@ -15,9 +15,9 @@ class TestContentProcessorTikz < Minitest::Test
|
|
15
15
|
@website.ext.content_processor.register('Blocks')
|
16
16
|
@website.ext.content_processor.register('Erb')
|
17
17
|
template_data = File.read(File.join(Webgen::Utils.data_dir, 'passive_sources', 'templates', 'tikz.template'))
|
18
|
-
|
18
|
+
RenderNode.new(template_data, @website.tree.dummy_root, '/template', '/template')
|
19
19
|
|
20
|
-
@context.node.define_singleton_method(:[]) {|
|
20
|
+
@context.node.define_singleton_method(:[]) {|_ignored| nil}
|
21
21
|
|
22
22
|
call('\tikz \draw (0,0) -- (0,1);', 'test.png', [], '', '72 72', false)
|
23
23
|
Timeout.timeout(0.2) { call('\tikz \draw (0,0) -- (0,1);', 'test.png', [], '', '72 72', false) } # test cache
|
@@ -31,6 +31,9 @@ class TestContentProcessorTikz < Minitest::Test
|
|
31
31
|
|
32
32
|
def call(content, path, libs, opts, res, trans)
|
33
33
|
@context.content = content
|
34
|
+
if @context.dest_node.singleton_class.method_defined?(:dest_path)
|
35
|
+
@context.dest_node.singleton_class.send(:remove_method, :dest_path)
|
36
|
+
end
|
34
37
|
@context.dest_node.define_singleton_method(:dest_path) {path}
|
35
38
|
@context.website.config.update('content_processor.tikz.resolution' => res,
|
36
39
|
'content_processor.tikz.transparent' => trans,
|
@@ -15,7 +15,7 @@ class TestPathHandlerApi < Minitest::Test
|
|
15
15
|
|
16
16
|
@api = Webgen::PathHandler::Api.new(@website)
|
17
17
|
|
18
|
-
|
18
|
+
Webgen::Node.new(@website.tree.dummy_root, '/', '/')
|
19
19
|
|
20
20
|
@page_file = File.dirname(__FILE__) + "/../../../API.rdoc"
|
21
21
|
@path = Webgen::Path.new('/test.api', 'dest_path' => '<parent><basename><ext>',
|
@@ -100,7 +100,7 @@ class TestPathHandlerBase < Minitest::Test
|
|
100
100
|
|
101
101
|
check_dest_path.call('/', mi, '/', @website.tree.dummy_root)
|
102
102
|
|
103
|
-
|
103
|
+
Webgen::Node.new(node, 'index.page', '/index.html', {'lang' => 'en'})
|
104
104
|
check_dest_path.call('/index.en.html', mi, '/index.html')
|
105
105
|
check_dest_path.call('/index.en.html', {'dest_path' => "<parent>hallo.html"}, '/hallo.html')
|
106
106
|
check_dest_path.call('/other.de.html', {'dest_path' => "<parent>index(.<lang>)<ext>"}, '/index.de.html')
|
@@ -144,7 +144,7 @@ class TestPathHandlerBase < Minitest::Test
|
|
144
144
|
assert_equal(false, @obj.node_exists?(Webgen::Path.new('/somename.en.html', {'no_output' => true}),
|
145
145
|
'/somename.html'))
|
146
146
|
assert_equal(frag_de, @obj.node_exists?(Webgen::Path.new('/somename.de.html#othertest'), '/somename.html#no'))
|
147
|
-
|
147
|
+
assert_nil(@obj.node_exists?(Webgen::Path.new('/unknown'), '/unknown'))
|
148
148
|
end
|
149
149
|
|
150
150
|
def test_base_node_methods
|
@@ -27,7 +27,7 @@ class TestPathHandlerCopy < Minitest::Test
|
|
27
27
|
check_node = lambda do |src_path, mi, dest_path, pipeline|
|
28
28
|
node = @copy.create_nodes(Webgen::Path.new(src_path, {'dest_path' => '<parent><basename><ext>'}.merge(mi)))
|
29
29
|
refute_nil(node)
|
30
|
-
|
30
|
+
assert(pipeline == node.meta_info['pipeline'])
|
31
31
|
assert_equal(dest_path, node.dest_path)
|
32
32
|
end
|
33
33
|
|
@@ -11,7 +11,7 @@ class TestPathHandlerTemplate < Minitest::Test
|
|
11
11
|
|
12
12
|
def test_create_nodes
|
13
13
|
setup_website
|
14
|
-
|
14
|
+
Webgen::Node.new(@website.tree.dummy_root, '/', '/')
|
15
15
|
@template = Webgen::PathHandler::Template.new(@website)
|
16
16
|
|
17
17
|
path = Webgen::Path.new('/default.template', 'dest_path' => '<parent><basename><ext>') { StringIO.new('test') }
|
@@ -76,7 +76,7 @@ EOF
|
|
76
76
|
def test_create_node
|
77
77
|
@time = Time.now
|
78
78
|
path = Webgen::Path.new('/virtual', 'dest_path' => '<parent><basename>(.<lang>)<ext>', 'modified_at' => @time)
|
79
|
-
|
79
|
+
@virtual.create_nodes(path, Webgen::Page.from_data(CONTENT).blocks)
|
80
80
|
|
81
81
|
node_de = @root.tree['/path.de.html']
|
82
82
|
node_en = @root.tree['/directory/path.en.html']
|
@@ -22,7 +22,7 @@ class TestTagBreadcrumbTrail < Minitest::Test
|
|
22
22
|
{'lang' => 'en', 'routed_title' => 'Dir11', 'title' => 'Index'})
|
23
23
|
file11_en = Webgen::Node.new(dir11, 'file111.html', '/dir1/dir11/file111.html',
|
24
24
|
{'lang' => 'en', 'title' => 'File111'})
|
25
|
-
|
25
|
+
Webgen::Node.new(root, 'index.html', '/index.html', {'lang' => 'en'})
|
26
26
|
setup_tag_template(root)
|
27
27
|
|
28
28
|
context[:chain] = [file11_en]
|
@@ -17,7 +17,7 @@ class TestTagLangbar < Minitest::Test
|
|
17
17
|
|
18
18
|
root = Webgen::Node.new(@website.tree.dummy_root, '/', '/')
|
19
19
|
node = Webgen::Node.new(root, 'file.html', '/file.html', {'lang' => 'en'})
|
20
|
-
|
20
|
+
Webgen::Node.new(root, 'file.html', '/file.de.html', {'lang' => 'de'})
|
21
21
|
other = Webgen::Node.new(root, 'other.html', '/other.html', {'lang' => 'en'})
|
22
22
|
setup_tag_template(root)
|
23
23
|
|
data/test/webgen/test_cache.rb
CHANGED
@@ -37,11 +37,11 @@ class TestCache < Minitest::Test
|
|
37
37
|
@cache.volatile[:key] = :value
|
38
38
|
assert_equal(:value, @cache.volatile[:key])
|
39
39
|
dump_and_restore
|
40
|
-
|
40
|
+
assert_nil(@cache.volatile[:key])
|
41
41
|
|
42
42
|
@cache.volatile[:key] = :value
|
43
43
|
@cache.reset_volatile_cache
|
44
|
-
|
44
|
+
assert_nil(@cache.volatile[:key])
|
45
45
|
end
|
46
46
|
|
47
47
|
end
|
data/test/webgen/test_cli.rb
CHANGED
@@ -17,7 +17,7 @@ class TestCLICommandParser < Minitest::Test
|
|
17
17
|
|
18
18
|
def test_initialize
|
19
19
|
assert_equal(Logger::INFO, @cli.log_level)
|
20
|
-
|
20
|
+
assert_nil(@cli.directory)
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_website
|
@@ -27,7 +27,7 @@ class TestCLICommandParser < Minitest::Test
|
|
27
27
|
|
28
28
|
def test_parse
|
29
29
|
@cli.website.ext.cli.add_command(SampleCommand.new)
|
30
|
-
out,
|
30
|
+
out, _err = capture_io do
|
31
31
|
begin
|
32
32
|
@cli.parse(['help'])
|
33
33
|
assert_equal(Dir.pwd, @cli.directory)
|
data/test/webgen/test_node.rb
CHANGED
@@ -18,7 +18,7 @@ class TestNode < Minitest::Test
|
|
18
18
|
assert_equal(cn, node.cn)
|
19
19
|
assert_equal(lcn, node.lcn)
|
20
20
|
assert_equal(alcn, node.alcn)
|
21
|
-
|
21
|
+
assert(lang == node.lang)
|
22
22
|
assert_kind_of(Webgen::Language, node.lang) if node.lang
|
23
23
|
assert_equal(mi, node.meta_info)
|
24
24
|
assert_equal({}, node.node_info)
|
data/test/webgen/test_path.rb
CHANGED
@@ -70,13 +70,13 @@ class TestPath < Minitest::Test
|
|
70
70
|
assert_kind_of(String, o.path)
|
71
71
|
assert_equal(ppath, o.parent_path)
|
72
72
|
assert_equal(bn, o.basename)
|
73
|
-
|
73
|
+
assert(lang == o.meta_info['lang'])
|
74
74
|
assert_equal(ext, o.ext)
|
75
75
|
assert_equal(cn, o.cn)
|
76
76
|
assert_equal(lcn, o.lcn)
|
77
77
|
assert_equal(acn, o.acn)
|
78
78
|
assert_equal(alcn, o.alcn)
|
79
|
-
|
79
|
+
assert(oi == o.meta_info['sort_info'])
|
80
80
|
assert_equal(title, o.meta_info['title'])
|
81
81
|
end
|
82
82
|
|
data/test/webgen/test_tree.rb
CHANGED
@@ -13,7 +13,7 @@ class TestTree < Minitest::Test
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_initialize
|
16
|
-
|
16
|
+
refute_nil(@tree.dummy_root)
|
17
17
|
assert_equal('', @tree.dummy_root.alcn)
|
18
18
|
end
|
19
19
|
|
@@ -29,8 +29,8 @@ class TestTree < Minitest::Test
|
|
29
29
|
assert_equal(@tree['/file.de.html'], @tree.translate_node(@tree['/file.en.html'], 'de'))
|
30
30
|
assert_equal(@tree['/file.en.html'], @tree.translate_node(@tree['/file.en.html'], 'en'))
|
31
31
|
assert_equal(@tree['/file.en.html'], @tree.translate_node(@tree['/file.de.html'], 'en'))
|
32
|
-
|
33
|
-
|
32
|
+
assert_nil(@tree.translate_node(@tree['/file.de.html'], 'fr'))
|
33
|
+
assert_nil(@tree.translate_node(@tree['/file.en.html'], nil))
|
34
34
|
|
35
35
|
assert_equal(@tree['/other.en.html'], @tree.translate_node(@tree['/other.html'], 'en'))
|
36
36
|
assert_equal(@tree['/other.html'], @tree.translate_node(@tree['/other.html'], 'de'))
|
@@ -38,7 +38,7 @@ class TestTree < Minitest::Test
|
|
38
38
|
assert_equal(@tree['/other.html'], @tree.translate_node(@tree['/other.en.html'], nil))
|
39
39
|
assert_equal(@tree['/other.html'], @tree.translate_node(@tree['/other.en.html'], 'de'))
|
40
40
|
|
41
|
-
|
41
|
+
assert_nil(@tree.translate_node(@tree['/file.en.html#frag'], nil))
|
42
42
|
assert_equal(@tree['/file.en.html#frag'], @tree.translate_node(@tree['/file.en.html#frag'], 'en'))
|
43
43
|
assert_equal(@tree['/file.de.html#frag'], @tree.translate_node(@tree['/file.en.html#frag'], 'de'))
|
44
44
|
end
|
@@ -54,29 +54,29 @@ class TestTree < Minitest::Test
|
|
54
54
|
setup_default_nodes(@tree)
|
55
55
|
|
56
56
|
[@tree['/'], @tree['/file.de.html'], @tree['/file.en.html'], @tree['/other.html']].each do |n|
|
57
|
-
|
57
|
+
assert_nil(n.resolve('file.html', nil))
|
58
58
|
assert_equal(@tree['/file.en.html'], n.resolve('file.html', 'en'))
|
59
59
|
assert_equal(@tree['/file.de.html'], n.resolve('file.html', 'de'))
|
60
|
-
|
60
|
+
assert_nil(n.resolve('file.html', 'fr'))
|
61
61
|
assert_equal(@tree['/file.en.html'], n.resolve('file.en.html', nil))
|
62
62
|
assert_equal(@tree['/file.en.html'], n.resolve('file.en.html', 'en'))
|
63
63
|
assert_equal(@tree['/file.en.html'], n.resolve('file.en.html', 'de'))
|
64
|
-
|
64
|
+
assert_nil(n.resolve('somename.fr.html', 'de'))
|
65
65
|
|
66
66
|
assert_equal(@tree['/other.html'], n.resolve('other.html', nil))
|
67
67
|
assert_equal(@tree['/other.html'], n.resolve('other.html', 'fr'))
|
68
68
|
assert_equal(@tree['/other.en.html'], n.resolve('other.html', 'en'))
|
69
69
|
assert_equal(@tree['/other.en.html'], n.resolve('other.en.html', nil))
|
70
70
|
assert_equal(@tree['/other.en.html'], n.resolve('other.en.html', 'de'))
|
71
|
-
|
72
|
-
|
71
|
+
assert_nil(n.resolve('other.fr.html', nil))
|
72
|
+
assert_nil(n.resolve('other.fr.html', 'en'))
|
73
73
|
end
|
74
74
|
|
75
75
|
assert_equal(@tree['/file.en.html#frag'], @tree['/file.en.html'].resolve('#frag', 'de'))
|
76
76
|
assert_equal(@tree['/file.en.html#frag'], @tree['/file.en.html'].resolve('#frag', nil))
|
77
77
|
assert_equal(@tree['/file.en.html#nested'], @tree['/file.en.html'].resolve('#nested', nil))
|
78
78
|
|
79
|
-
|
79
|
+
assert_nil(@tree.resolve_node('/file.html#frag', nil))
|
80
80
|
assert_equal(@tree['/file.en.html#frag'], @tree.resolve_node('/file.html#frag', 'en'))
|
81
81
|
assert_equal(@tree['/file.de.html#frag'], @tree.resolve_node('/file.html#frag', 'de'))
|
82
82
|
assert_equal(@tree['/file.en.html#frag'], @tree.resolve_node('/file.en.html#frag', nil))
|
@@ -91,9 +91,9 @@ class TestTree < Minitest::Test
|
|
91
91
|
|
92
92
|
nrcalls = 0
|
93
93
|
@website.blackboard.add_listener(:node_resolution_failed) { nrcalls += 1 }
|
94
|
-
|
94
|
+
assert_nil(@tree['/'].resolve('other.fr.html', nil, false))
|
95
95
|
assert_equal(0, nrcalls)
|
96
|
-
|
96
|
+
assert_nil(@tree['/'].resolve('other.fr.html', nil, true))
|
97
97
|
assert_equal(1, nrcalls)
|
98
98
|
end
|
99
99
|
|
@@ -116,7 +116,7 @@ class TestTree < Minitest::Test
|
|
116
116
|
|
117
117
|
root = Webgen::Node.new(@tree.dummy_root, '/', '/')
|
118
118
|
file = Webgen::Node.new(root, 'testfile', 'testfile')
|
119
|
-
|
119
|
+
Webgen::Node.new(root, 'testdir/', 'testdir')
|
120
120
|
virtual_root = Webgen::Node.new(root, 'vroot', '/', 'no_output' => true)
|
121
121
|
|
122
122
|
@tree.delete_node(@tree.dummy_root)
|
@@ -65,7 +65,7 @@ class TestTagParser < Minitest::Test
|
|
65
65
|
i = 0
|
66
66
|
check_proc = proc do |tag, params, body|
|
67
67
|
assert_equal(data[i][0], tag, 'error on tag with content: ' + content)
|
68
|
-
|
68
|
+
assert(data[i][1] == params, 'error on params with content: ' + content)
|
69
69
|
assert_equal(data[i][2], body, 'error on body with content: ' + content)
|
70
70
|
i += 1
|
71
71
|
'test' + i.to_s
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webgen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Leitner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cmdparse
|
@@ -501,7 +501,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
501
501
|
version: '0'
|
502
502
|
requirements: []
|
503
503
|
rubyforge_project:
|
504
|
-
rubygems_version: 2.
|
504
|
+
rubygems_version: 2.6.8
|
505
505
|
signing_key:
|
506
506
|
specification_version: 4
|
507
507
|
summary: webgen is a fast, powerful, and extensible static website generator.
|