bookbindery 9.11.1 → 9.11.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bookbinder.gemspec +1 -1
- data/lib/bookbinder/commands/components/command_options.rb +1 -1
- data/lib/bookbinder/ingest/local_filesystem_cloner.rb +15 -17
- data/lib/bookbinder/postprocessing/link_checker.rb +8 -28
- data/lib/bookbinder/postprocessing/redirection.rb +38 -0
- data/lib/bookbinder/streams/filter_stream.rb +2 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fcd5e2f139245d235d3e225698f2985b6458ba73
|
4
|
+
data.tar.gz: 9e4a26c0cf99324f2a201cd801ec4d5ab0f4bfcb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 309ebaec04b27d5b89075c79cc1c735fbfc444646289436d6aa5a12e025526538e8e70c8e6a97bf377da8b003991d6a473a3d4306b88c7ebb1397989e1b04fc2
|
7
|
+
data.tar.gz: c8260a429816001b1c12bf883a37ae259d965a1c82f6a368d72f2a3bf932056972e693ce273266867183eea1454f69ab7cad53edba64b21a8a4cfe84d2c138e4
|
data/bookbinder.gemspec
CHANGED
@@ -2,7 +2,7 @@ require 'base64'
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'bookbindery'
|
5
|
-
s.version = '9.11.
|
5
|
+
s.version = '9.11.2'
|
6
6
|
s.summary = 'Markdown to Rackup application documentation generator'
|
7
7
|
s.description = 'A command line utility to be run in Book repositories to stitch together their constituent Markdown repos into a static-HTML-serving application'
|
8
8
|
s.authors = ['Mike Grafton', 'Lucas Marks', 'Gavin Morgan', 'Nikhil Gajwani', 'Dan Wendorf', 'Brenda Chan', 'Matthew Boedicker', 'Andrew Bruce', 'Frank Kotsianas', 'Elena Sharma', 'Christa Hartsock', 'Michael Trestman', 'Alpha Chen', 'Sarah McAlear', 'Gregg Van Hove']
|
@@ -32,7 +32,7 @@ module Bookbinder
|
|
32
32
|
def streams
|
33
33
|
base_streams.merge(
|
34
34
|
out: verbosity ? base_streams[:out] :
|
35
|
-
Streams::FilterStream.new(
|
35
|
+
Streams::FilterStream.new(/^(?:\s*error|Invalid CSS|Undefined mixin|\/)/i, Streams::ColorizedStream.new(Colorizer::Colors.red, base_streams[:out])),
|
36
36
|
)
|
37
37
|
end
|
38
38
|
|
@@ -29,31 +29,29 @@ module Bookbinder
|
|
29
29
|
|
30
30
|
def link!(source_repo_name, source_dir, dest_dir, source_ref)
|
31
31
|
source_exists = filesystem.file_exist?(source_dir)
|
32
|
+
unless source_exists
|
33
|
+
source_dir_with_ref = "#{source_dir}-#{source_ref}"
|
34
|
+
source_exists = filesystem.file_exist?(source_dir_with_ref)
|
35
|
+
source_dir = source_dir_with_ref if source_exists
|
36
|
+
end
|
37
|
+
|
38
|
+
if !source_exists
|
39
|
+
streams[:out].puts " skipping (not found) #{source_dir}"
|
40
|
+
MissingWorkingCopy.new(source_repo_name, source_dir)
|
41
|
+
else
|
42
|
+
streams[:out].puts " copying #{source_dir}"
|
43
|
+
|
44
|
+
unless filesystem.file_exist?(dest_dir)
|
45
|
+
filesystem.link_creating_intermediate_dirs(source_dir, dest_dir)
|
46
|
+
end
|
32
47
|
|
33
|
-
if source_exists && filesystem.file_exist?(dest_dir)
|
34
|
-
announce(source_dir)
|
35
|
-
WorkingCopy.new(
|
36
|
-
copied_to: dest_dir,
|
37
|
-
full_name: source_repo_name,
|
38
|
-
ref: source_ref
|
39
|
-
)
|
40
|
-
elsif source_exists
|
41
|
-
announce(source_dir)
|
42
|
-
filesystem.link_creating_intermediate_dirs(source_dir, dest_dir)
|
43
48
|
WorkingCopy.new(
|
44
49
|
copied_to: dest_dir,
|
45
50
|
full_name: source_repo_name,
|
46
51
|
ref: source_ref
|
47
52
|
)
|
48
|
-
else
|
49
|
-
streams[:out].puts " skipping (not found) #{source_dir}"
|
50
|
-
MissingWorkingCopy.new(source_repo_name, source_dir)
|
51
53
|
end
|
52
54
|
end
|
53
|
-
|
54
|
-
def announce(source_dir)
|
55
|
-
streams[:out].puts " copying #{source_dir}"
|
56
|
-
end
|
57
55
|
end
|
58
56
|
end
|
59
57
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'nokogiri'
|
2
2
|
require_relative '../css_link_checker'
|
3
|
+
require_relative 'redirection'
|
3
4
|
|
4
5
|
module Bookbinder
|
5
6
|
module Postprocessing
|
@@ -9,8 +10,6 @@ module Bookbinder
|
|
9
10
|
@root_path = root_path
|
10
11
|
@output_streams = output_streams
|
11
12
|
@broken_link_count = 0
|
12
|
-
@redirect_regexes = {}
|
13
|
-
@redirect_strings = {}
|
14
13
|
|
15
14
|
@convert_to_relative = %r{\A.*#{root_path.to_s}/public}
|
16
15
|
@default_link_exclusions = %r{\A(?:https?://|javascript:|mailto:)}
|
@@ -19,7 +18,7 @@ module Bookbinder
|
|
19
18
|
|
20
19
|
def check!(link_exclusions = /(?!.*)/)
|
21
20
|
@output_streams[:out].puts "\nChecking for broken links..."
|
22
|
-
|
21
|
+
@redirects = Redirection.new(@fs, File.join(@root_path, 'redirects.rb'))
|
23
22
|
load_page_links
|
24
23
|
|
25
24
|
report_broken_links!(link_exclusions)
|
@@ -53,6 +52,7 @@ module Bookbinder
|
|
53
52
|
end
|
54
53
|
|
55
54
|
broken_css_links = Dir.chdir(@root_path) { CssLinkChecker.new.broken_links_in_all_stylesheets }
|
55
|
+
broken_css_links.reject! { |link| link_exclusions.match(link) }
|
56
56
|
|
57
57
|
@broken_link_count += broken_css_links.size
|
58
58
|
broken_css_links.each do |link|
|
@@ -81,9 +81,7 @@ module Bookbinder
|
|
81
81
|
end
|
82
82
|
|
83
83
|
def page_exists?(link)
|
84
|
-
@page_links.has_key?(link) ||
|
85
|
-
@redirect_strings.has_key?(link) ||
|
86
|
-
@redirect_regexes.keys.detect {|reg| reg.match(link)}
|
84
|
+
@page_links.has_key?(link) || @redirects.redirected?(link)
|
87
85
|
end
|
88
86
|
|
89
87
|
def normalize_link(link, page)
|
@@ -107,19 +105,14 @@ module Bookbinder
|
|
107
105
|
if !@excluded_pages.match(public_path)
|
108
106
|
html = Nokogiri::HTML(@fs.read(file_path))
|
109
107
|
|
110
|
-
links[public_path] =
|
108
|
+
links[public_path] = [
|
109
|
+
html.css('a[href]').map { |link| link['href'] },
|
110
|
+
html.css('img').map { |image| image['src'] }
|
111
|
+
].flatten
|
111
112
|
end
|
112
113
|
end
|
113
114
|
end
|
114
115
|
|
115
|
-
def load_redirects!
|
116
|
-
redirects_path = File.join(@root_path, 'redirects.rb')
|
117
|
-
if @fs.is_file?(redirects_path)
|
118
|
-
contents = @fs.read(redirects_path)
|
119
|
-
instance_eval contents
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
116
|
def out(str)
|
124
117
|
@output_streams[:out].puts(str)
|
125
118
|
end
|
@@ -127,19 +120,6 @@ module Bookbinder
|
|
127
120
|
def err(str)
|
128
121
|
@output_streams[:err].puts(str)
|
129
122
|
end
|
130
|
-
|
131
|
-
def r301(source, dest, options={})
|
132
|
-
return if options.has_key?(:if)
|
133
|
-
|
134
|
-
case source
|
135
|
-
when Regexp
|
136
|
-
@redirect_regexes[source] = dest
|
137
|
-
when String
|
138
|
-
@redirect_strings[source] = dest
|
139
|
-
end
|
140
|
-
end
|
141
|
-
alias r302 r301
|
142
|
-
alias rewrite r301
|
143
123
|
end
|
144
124
|
end
|
145
125
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Bookbinder
|
2
|
+
module Postprocessing
|
3
|
+
class Redirection
|
4
|
+
def initialize(fs, file_path)
|
5
|
+
@redirect_regexes = {}
|
6
|
+
@redirect_strings = {}
|
7
|
+
load!(fs, file_path)
|
8
|
+
end
|
9
|
+
|
10
|
+
def redirected?(url)
|
11
|
+
@redirect_strings.has_key?(url) ||
|
12
|
+
@redirect_regexes.keys.detect {|regex| regex.match(url)}
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def load!(fs, file_path)
|
18
|
+
if fs.is_file?(file_path)
|
19
|
+
contents = fs.read(file_path)
|
20
|
+
instance_eval contents
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def r301(source, dest, options={})
|
25
|
+
return if options.has_key?(:if)
|
26
|
+
|
27
|
+
case source
|
28
|
+
when Regexp
|
29
|
+
@redirect_regexes[source] = dest
|
30
|
+
when String
|
31
|
+
@redirect_strings[source] = dest
|
32
|
+
end
|
33
|
+
end
|
34
|
+
alias r302 r301
|
35
|
+
alias rewrite r301
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -7,11 +7,11 @@ module Bookbinder
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def puts(line)
|
10
|
-
stream.puts(line) if line.match(matcher_regex)
|
10
|
+
stream.puts(line.gsub("\n", '')) if line.match(matcher_regex)
|
11
11
|
end
|
12
12
|
|
13
13
|
def <<(line)
|
14
|
-
stream << line if line.match(matcher_regex)
|
14
|
+
stream << line.gsub("\n", '') if line.match(matcher_regex)
|
15
15
|
end
|
16
16
|
|
17
17
|
private
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bookbindery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 9.11.
|
4
|
+
version: 9.11.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Grafton
|
@@ -22,7 +22,7 @@ authors:
|
|
22
22
|
autorequire:
|
23
23
|
bindir: install_bin
|
24
24
|
cert_chain: []
|
25
|
-
date: 2016-06-
|
25
|
+
date: 2016-06-23 00:00:00.000000000 Z
|
26
26
|
dependencies:
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: fog-aws
|
@@ -392,6 +392,7 @@ files:
|
|
392
392
|
- lib/bookbinder/local_filesystem_accessor.rb
|
393
393
|
- lib/bookbinder/middleman_runner.rb
|
394
394
|
- lib/bookbinder/postprocessing/link_checker.rb
|
395
|
+
- lib/bookbinder/postprocessing/redirection.rb
|
395
396
|
- lib/bookbinder/preprocessing/dita_html_preprocessor.rb
|
396
397
|
- lib/bookbinder/preprocessing/dita_pdf_preprocessor.rb
|
397
398
|
- lib/bookbinder/preprocessing/link_to_site_gen_dir.rb
|