alb3rtobr-test 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bookbinder.gemspec +43 -0
- data/install_bin/bookbinder +5 -0
- data/lib/bookbinder/cli.rb +105 -0
- data/lib/bookbinder/code_example_reader.rb +95 -0
- data/lib/bookbinder/colorizer.rb +16 -0
- data/lib/bookbinder/commands/bind.rb +120 -0
- data/lib/bookbinder/commands/collection.rb +181 -0
- data/lib/bookbinder/commands/components/bind/directory_preparer.rb +33 -0
- data/lib/bookbinder/commands/components/bind/layout_preparer.rb +27 -0
- data/lib/bookbinder/commands/components/command_options.rb +45 -0
- data/lib/bookbinder/commands/components/imprint/directory_preparer.rb +24 -0
- data/lib/bookbinder/commands/generate.rb +92 -0
- data/lib/bookbinder/commands/imprint.rb +55 -0
- data/lib/bookbinder/commands/punch.rb +33 -0
- data/lib/bookbinder/commands/update_local_doc_repos.rb +42 -0
- data/lib/bookbinder/commands/watch.rb +100 -0
- data/lib/bookbinder/config/checkers/archive_menu_checker.rb +29 -0
- data/lib/bookbinder/config/checkers/ditamap_presence_checker.rb +27 -0
- data/lib/bookbinder/config/checkers/duplicate_section_name_checker.rb +33 -0
- data/lib/bookbinder/config/checkers/products_checker.rb +34 -0
- data/lib/bookbinder/config/checkers/repository_name_presence_checker.rb +34 -0
- data/lib/bookbinder/config/checkers/required_keys_checker.rb +18 -0
- data/lib/bookbinder/config/checkers/section_presence_checker.rb +15 -0
- data/lib/bookbinder/config/configuration.rb +119 -0
- data/lib/bookbinder/config/configuration_decorator.rb +54 -0
- data/lib/bookbinder/config/dita_config_generator.rb +61 -0
- data/lib/bookbinder/config/fetcher.rb +64 -0
- data/lib/bookbinder/config/imprint/configuration.rb +24 -0
- data/lib/bookbinder/config/product_config.rb +34 -0
- data/lib/bookbinder/config/section_config.rb +85 -0
- data/lib/bookbinder/config/validator.rb +33 -0
- data/lib/bookbinder/config/yaml_loader.rb +34 -0
- data/lib/bookbinder/css_link_checker.rb +67 -0
- data/lib/bookbinder/directory_helpers.rb +15 -0
- data/lib/bookbinder/dita_command_creator.rb +95 -0
- data/lib/bookbinder/dita_html_for_middleman_formatter.rb +45 -0
- data/lib/bookbinder/errors/programmer_mistake.rb +5 -0
- data/lib/bookbinder/html_document_manipulator.rb +21 -0
- data/lib/bookbinder/ingest/cloner_factory.rb +26 -0
- data/lib/bookbinder/ingest/destination_directory.rb +21 -0
- data/lib/bookbinder/ingest/git_accessor.rb +102 -0
- data/lib/bookbinder/ingest/git_cloner.rb +36 -0
- data/lib/bookbinder/ingest/local_filesystem_cloner.rb +66 -0
- data/lib/bookbinder/ingest/missing_working_copy.rb +27 -0
- data/lib/bookbinder/ingest/repo_identifier.rb +45 -0
- data/lib/bookbinder/ingest/section_repository.rb +49 -0
- data/lib/bookbinder/ingest/update_failure.rb +15 -0
- data/lib/bookbinder/ingest/update_success.rb +12 -0
- data/lib/bookbinder/ingest/working_copy.rb +36 -0
- data/lib/bookbinder/local_filesystem_accessor.rb +122 -0
- data/lib/bookbinder/middleman_runner.rb +50 -0
- data/lib/bookbinder/postprocessing/link_checker.rb +125 -0
- data/lib/bookbinder/postprocessing/redirection.rb +38 -0
- data/lib/bookbinder/preprocessing/dita_html_preprocessor.rb +91 -0
- data/lib/bookbinder/preprocessing/dita_pdf_preprocessor.rb +48 -0
- data/lib/bookbinder/preprocessing/link_to_site_gen_dir.rb +39 -0
- data/lib/bookbinder/preprocessing/preprocessor.rb +26 -0
- data/lib/bookbinder/server_director.rb +30 -0
- data/lib/bookbinder/sheller.rb +52 -0
- data/lib/bookbinder/streams/colorized_stream.rb +25 -0
- data/lib/bookbinder/streams/filter_stream.rb +22 -0
- data/lib/bookbinder/subnav/navigation_entries_from_html_toc.rb +59 -0
- data/lib/bookbinder/subnav/navigation_entries_from_markdown_root.rb +116 -0
- data/lib/bookbinder/subnav/pdf_config_creator.rb +50 -0
- data/lib/bookbinder/subnav/subnav_generator.rb +28 -0
- data/lib/bookbinder/subnav/subnav_generator_factory.rb +29 -0
- data/lib/bookbinder/subnav/template_creator.rb +71 -0
- data/lib/bookbinder/terminal.rb +19 -0
- data/lib/bookbinder/values/output_locations.rb +91 -0
- data/lib/bookbinder/values/product_info.rb +11 -0
- data/lib/bookbinder/values/section.rb +58 -0
- data/lib/bookbinder/values/subnav_template.rb +4 -0
- data/lib/bookbinder/values/user_message.rb +15 -0
- data/master_middleman/archive_drop_down_menu.rb +50 -0
- data/master_middleman/bookbinder_helpers.rb +282 -0
- data/master_middleman/compass_runner.rb +0 -0
- data/master_middleman/config.rb +45 -0
- data/master_middleman/proof.rb +90 -0
- data/master_middleman/quicklinks_renderer.rb +80 -0
- data/master_middleman/source/javascripts/all.js +2 -0
- data/master_middleman/source/javascripts/book.js +1 -0
- data/master_middleman/source/javascripts/bookbinder.js +130 -0
- data/master_middleman/source/layouts/_additional-scripts.erb +0 -0
- data/master_middleman/source/layouts/_book-footer.erb +0 -0
- data/master_middleman/source/layouts/_book-search.erb +0 -0
- data/master_middleman/source/layouts/_book-title.erb +3 -0
- data/master_middleman/source/layouts/_header.erb +34 -0
- data/master_middleman/source/layouts/_local-header.erb +0 -0
- data/master_middleman/source/layouts/_page-footer.erb +1 -0
- data/master_middleman/source/layouts/_title.erb +5 -0
- data/master_middleman/source/layouts/layout.erb +70 -0
- data/master_middleman/source/stylesheets/all.css.scss +3 -0
- data/master_middleman/source/stylesheets/base.scss +324 -0
- data/master_middleman/source/stylesheets/book-styles.scss +0 -0
- data/master_middleman/source/stylesheets/layout-styles.scss +0 -0
- data/master_middleman/source/stylesheets/partials/_book-base-values.scss +0 -0
- data/master_middleman/source/stylesheets/partials/_book-vars.scss +0 -0
- data/master_middleman/source/stylesheets/partials/_default.scss +302 -0
- data/master_middleman/source/stylesheets/partials/_footer.scss +64 -0
- data/master_middleman/source/stylesheets/partials/_header.scss +419 -0
- data/master_middleman/source/stylesheets/partials/_layout-vars.scss +0 -0
- data/master_middleman/source/stylesheets/partials/_mixins.scss +53 -0
- data/master_middleman/source/stylesheets/partials/_reset.scss +233 -0
- data/master_middleman/source/stylesheets/partials/_search.scss +78 -0
- data/master_middleman/source/stylesheets/partials/_sidenav.scss +191 -0
- data/master_middleman/source/stylesheets/partials/_syntax-highlight.scss +64 -0
- data/master_middleman/source/stylesheets/partials/_vars.scss +64 -0
- data/master_middleman/source/stylesheets/print-book-styles.scss +0 -0
- data/master_middleman/source/stylesheets/print-layout-styles.scss +0 -0
- data/master_middleman/source/stylesheets/print.css.scss +57 -0
- data/master_middleman/source/subnavs/_default.erb +0 -0
- data/master_middleman/source/subnavs/_nav-links.erb +10 -0
- data/master_middleman/source/subnavs/_subnav_template.erb +8 -0
- data/master_middleman/subdirectory_aware_assets.rb +36 -0
- data/template_app/Gemfile +10 -0
- data/template_app/Gemfile.lock +46 -0
- data/template_app/config.ru +9 -0
- data/template_app/lib/rack_static_if_exists.rb +19 -0
- data/template_app/lib/search/handler.rb +73 -0
- data/template_app/lib/search/hit.rb +21 -0
- data/template_app/lib/search/query.rb +74 -0
- data/template_app/lib/search/renderer.rb +30 -0
- data/template_app/lib/server.rb +52 -0
- data/template_app/mail_sender.rb +61 -0
- data/template_app/rack_app.rb +110 -0
- data/template_app/search-results.html.erb +81 -0
- data/template_app/search.yml +23 -0
- metadata +562 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d9c184c9d464d6adc52417786e7fe992fa6a28716cee4409e3079a9583667ca5
|
4
|
+
data.tar.gz: 5fc606dec88ceb9d853d23aae52b6b4b38f54b21260bd97bd04bda8be5686eb6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: eb0b6594fae63b811aa3870c5929594a14e03cef2f39035c4d5d1f139432fece0117a3e7fd4cafe98321497e5c3ec0c0df4f3da77321bab9a9bda2fc124811d4
|
7
|
+
data.tar.gz: 7f97c840bdfb767756fa3933834642a848695da201c84ce6da35eaef679989440330949230c38a39e82eb50e6df4e04ba470c9d6453e423e6570159b7fdfbf6b
|
data/bookbinder.gemspec
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'base64'
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'alb3rtobr-test'
|
5
|
+
s.version = '1.0.1'
|
6
|
+
s.summary = 'test'
|
7
|
+
s.authors = 'test'
|
8
|
+
s.files = Dir['lib/**/*'] + Dir['template_app/**/*'] + Dir['master_middleman/**/*'] + Dir['install_bin/bookbinder'] + Dir['bookbinder.gemspec']
|
9
|
+
s.license = 'MIT'
|
10
|
+
s.bindir = 'install_bin'
|
11
|
+
s.executable = 'bookbinder'
|
12
|
+
|
13
|
+
s.required_ruby_version = '>= 2.3.3'
|
14
|
+
s.add_runtime_dependency 'fog-aws', ['~> 0.7.1']
|
15
|
+
s.add_runtime_dependency 'ansi', ['~> 1.4']
|
16
|
+
s.add_runtime_dependency 'middleman', ['4.1.10']
|
17
|
+
s.add_runtime_dependency 'middleman-livereload'
|
18
|
+
s.add_runtime_dependency 'middleman-syntax', ['2.1.0']
|
19
|
+
s.add_runtime_dependency 'rouge', '!= 1.9.1'
|
20
|
+
s.add_runtime_dependency 'redcarpet', ['~> 3.2.3']
|
21
|
+
s.add_runtime_dependency 'css_parser'
|
22
|
+
s.add_runtime_dependency 'puma'
|
23
|
+
s.add_runtime_dependency 'rack-rewrite'
|
24
|
+
s.add_runtime_dependency 'therubyracer'
|
25
|
+
s.add_runtime_dependency 'git', '~> 1.2.8'
|
26
|
+
s.add_runtime_dependency 'nokogiri', ['1.10.1']
|
27
|
+
s.add_runtime_dependency 'thor', ['~> 0.19.1']
|
28
|
+
s.add_runtime_dependency 'elasticsearch'
|
29
|
+
s.add_runtime_dependency 'font-awesome-sass', ['4.7.0']
|
30
|
+
s.add_runtime_dependency 'middleman-sprockets'
|
31
|
+
s.add_runtime_dependency 'middleman-compass'
|
32
|
+
s.add_runtime_dependency 'sprockets', '~> 3.7.2'
|
33
|
+
s.add_runtime_dependency 'mimemagic', '0.4.1'
|
34
|
+
|
35
|
+
s.add_development_dependency 'license_finder'
|
36
|
+
s.add_development_dependency 'pry-byebug'
|
37
|
+
s.add_development_dependency 'rake'
|
38
|
+
s.add_development_dependency 'rspec'
|
39
|
+
s.add_development_dependency 'sendgrid-ruby', '< 3.0'
|
40
|
+
s.add_development_dependency 'sinatra', '1.4.8'
|
41
|
+
s.add_development_dependency 'jasmine'
|
42
|
+
s.add_development_dependency 'rack-test'
|
43
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
require_relative 'ingest/git_accessor'
|
4
|
+
require_relative 'streams/colorized_stream'
|
5
|
+
require_relative 'colorizer'
|
6
|
+
require_relative 'commands/collection'
|
7
|
+
|
8
|
+
module Bookbinder
|
9
|
+
class CLI < Thor
|
10
|
+
def self.exit_on_failure?
|
11
|
+
true
|
12
|
+
end
|
13
|
+
|
14
|
+
map '--version' => :version
|
15
|
+
map '--help' => :help
|
16
|
+
|
17
|
+
desc '--version', 'Print the version of bookbinder'
|
18
|
+
def version
|
19
|
+
gemspec = File.expand_path('../../../bookbinder.gemspec', __FILE__)
|
20
|
+
say "bookbinder #{Gem::Specification::load(gemspec).version}"
|
21
|
+
end
|
22
|
+
|
23
|
+
desc '--help', 'Print this message'
|
24
|
+
def help(command=nil)
|
25
|
+
super
|
26
|
+
end
|
27
|
+
|
28
|
+
desc 'generate <book_name>', 'Generate a skeleton book that can be bound with "bookbinder bind"'
|
29
|
+
def generate(book_name)
|
30
|
+
code = legacy_commands.generate(book_name)
|
31
|
+
raise Thor::Error, '' if code != 0
|
32
|
+
end
|
33
|
+
|
34
|
+
desc 'bind <local|remote> [options]', 'Bind the sections specified in config.yml from <local> or <remote> into the final_app directory'
|
35
|
+
option :verbose, type: :boolean
|
36
|
+
option :proof, type: :boolean, default: false, desc:'Shows author proof details'
|
37
|
+
option 'dita-flags', desc: '--dita-flags=\"<dita-option>=<value>\"'
|
38
|
+
option :require_valid_subnav_links, type: :boolean, desc: 'Check that subnav link targets exist, always true for remote'
|
39
|
+
def bind(source)
|
40
|
+
code = legacy_commands.bind(source, options[:verbose], options['dita-flags'], options[:require_valid_subnav_links], options[:proof])
|
41
|
+
raise Thor::Error, '' if code != 0
|
42
|
+
end
|
43
|
+
|
44
|
+
desc 'punch <git tag>', 'Apply the specified <git tag> to your book, sections, and layout repo'
|
45
|
+
def punch(git_tag)
|
46
|
+
code = legacy_commands.punch(git_tag)
|
47
|
+
raise Thor::Error, '' if code != 0
|
48
|
+
end
|
49
|
+
|
50
|
+
desc 'update_local_doc_repos', 'Run `git pull` on all sections that exist at the same directory level as your book directory'
|
51
|
+
def update_local_doc_repos
|
52
|
+
code = legacy_commands.update_local_doc_repos
|
53
|
+
raise Thor::Error, '' if code != 0
|
54
|
+
end
|
55
|
+
|
56
|
+
desc 'watch [repo1 [repo2]]', 'Bind and serve a local book, watching for changes'
|
57
|
+
long_desc <<-LONG_DESC
|
58
|
+
Bind and serve a local book, watching for changes
|
59
|
+
|
60
|
+
Optionally, you can provide a subset of the repositories in the book to be watched.
|
61
|
+
This will exclude any repositories not specified from being available in the bound book, even if they exist on your file system.
|
62
|
+
LONG_DESC
|
63
|
+
def watch(*repos)
|
64
|
+
code = legacy_commands.watch(repos)
|
65
|
+
raise Thor::Error, '' if code != 0
|
66
|
+
end
|
67
|
+
|
68
|
+
desc 'imprint <local|remote> [options]', 'Generate a PDF for a given book'
|
69
|
+
option :verbose, type: :boolean
|
70
|
+
option 'dita-flags', desc: '--dita-flags=\"<dita-option>=<value>\"'
|
71
|
+
def imprint(source)
|
72
|
+
code = legacy_commands.imprint(source, options[:verbose], options['dita-flags'])
|
73
|
+
raise Thor::Error, '' if code != 0
|
74
|
+
end
|
75
|
+
|
76
|
+
def method_missing(command, *args)
|
77
|
+
puts "Unknown command '#{command}'"
|
78
|
+
puts ""
|
79
|
+
help
|
80
|
+
end
|
81
|
+
|
82
|
+
private
|
83
|
+
|
84
|
+
attr_reader :legacy_commands
|
85
|
+
|
86
|
+
def initialize(*)
|
87
|
+
super
|
88
|
+
|
89
|
+
@legacy_commands = Bookbinder::Commands::Collection.new(colorized_streams, git)
|
90
|
+
end
|
91
|
+
|
92
|
+
def git
|
93
|
+
@git ||= Ingest::GitAccessor.new
|
94
|
+
end
|
95
|
+
|
96
|
+
def colorized_streams
|
97
|
+
@streams ||= {
|
98
|
+
err: Streams::ColorizedStream.new(Colorizer::Colors.red, $stderr),
|
99
|
+
out: $stdout,
|
100
|
+
success: Streams::ColorizedStream.new(Colorizer::Colors.green, $stdout),
|
101
|
+
warn: Streams::ColorizedStream.new(Colorizer::Colors.yellow, $stdout),
|
102
|
+
}
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
module Bookbinder
|
2
|
+
class CodeExampleReader
|
3
|
+
class InvalidSnippet < StandardError
|
4
|
+
def initialize(repo, marker)
|
5
|
+
super "Error with marker #{marker} in #{repo}."
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(streams, fs)
|
10
|
+
@out = streams[:out]
|
11
|
+
@fs = fs
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_snippet_and_language_at(marker, working_copy)
|
15
|
+
if working_copy.available?
|
16
|
+
process_snippet(marker, working_copy)
|
17
|
+
else
|
18
|
+
out.puts(" skipping (not found) #{working_copy.full_name}")
|
19
|
+
''
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class Snippet
|
24
|
+
def initialize(text, language_pattern)
|
25
|
+
@text = text
|
26
|
+
@language_pattern = language_pattern
|
27
|
+
end
|
28
|
+
|
29
|
+
def valid?
|
30
|
+
! text.empty?
|
31
|
+
end
|
32
|
+
|
33
|
+
def language
|
34
|
+
language_match = lines[0].match(language_pattern)
|
35
|
+
Array(language_match)[1]
|
36
|
+
end
|
37
|
+
|
38
|
+
def content
|
39
|
+
lines[1..-2].join("\n").strip
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
attr_reader :text, :language_pattern
|
45
|
+
|
46
|
+
def lines
|
47
|
+
text.split("\n")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
attr_reader :out, :fs
|
54
|
+
|
55
|
+
def process_snippet(marker, working_copy)
|
56
|
+
snippet = Snippet.new(
|
57
|
+
find_text(working_copy.path, pattern_for(marker)),
|
58
|
+
language_pattern_for(marker)
|
59
|
+
)
|
60
|
+
if snippet.valid?
|
61
|
+
[snippet.content, snippet.language]
|
62
|
+
else
|
63
|
+
raise InvalidSnippet.new(working_copy.full_name, marker)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def find_text(start_path, pattern)
|
68
|
+
fs.find_files_recursively(start_path).
|
69
|
+
lazy.
|
70
|
+
select {|path| fs.file_exist?(path) }.
|
71
|
+
map {|path| fs.read(path) }.
|
72
|
+
map {|contents|
|
73
|
+
begin
|
74
|
+
contents.scan(pattern)
|
75
|
+
rescue ArgumentError => e
|
76
|
+
cannot_scan
|
77
|
+
end
|
78
|
+
}.
|
79
|
+
map(&:first).
|
80
|
+
detect(Proc.new {""}) {|text| text}
|
81
|
+
end
|
82
|
+
|
83
|
+
def pattern_for(marker)
|
84
|
+
/code_snippet #{Regexp.escape(marker)} start.*code_snippet #{Regexp.escape(marker)} end/m
|
85
|
+
end
|
86
|
+
|
87
|
+
def language_pattern_for(marker)
|
88
|
+
/code_snippet #{Regexp.escape(marker)} start (\w+)/
|
89
|
+
end
|
90
|
+
|
91
|
+
def cannot_scan
|
92
|
+
[]
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'ansi/code'
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
module Bookbinder
|
5
|
+
class Colorizer
|
6
|
+
Colors = OpenStruct.new(
|
7
|
+
green: ->(msg) { ANSI.green {msg} },
|
8
|
+
red: ->(msg) { ANSI.red {msg} },
|
9
|
+
yellow: ->(msg) { ANSI.yellow {msg} },
|
10
|
+
)
|
11
|
+
|
12
|
+
def colorize(string, color)
|
13
|
+
color.call string.to_s
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'middleman-syntax'
|
2
|
+
|
3
|
+
require_relative 'components/command_options'
|
4
|
+
|
5
|
+
module Bookbinder
|
6
|
+
module Commands
|
7
|
+
class Bind
|
8
|
+
def initialize(base_streams,
|
9
|
+
output_locations: nil,
|
10
|
+
config_fetcher: nil,
|
11
|
+
config_decorator: nil,
|
12
|
+
file_system_accessor: nil,
|
13
|
+
middleman_runner: nil,
|
14
|
+
link_checker: nil,
|
15
|
+
preprocessor: nil,
|
16
|
+
cloner_factory: nil,
|
17
|
+
section_repository: nil,
|
18
|
+
directory_preparer: nil)
|
19
|
+
|
20
|
+
@base_streams = base_streams
|
21
|
+
@output_locations = output_locations
|
22
|
+
@config_fetcher = config_fetcher
|
23
|
+
@config_decorator = config_decorator
|
24
|
+
@file_system_accessor = file_system_accessor
|
25
|
+
@middleman_runner = middleman_runner
|
26
|
+
@link_checker = link_checker
|
27
|
+
@preprocessor = preprocessor
|
28
|
+
@cloner_factory = cloner_factory
|
29
|
+
@section_repository = section_repository
|
30
|
+
@directory_preparer = directory_preparer
|
31
|
+
end
|
32
|
+
|
33
|
+
def run(bind_type, verbose = false, dita_flags = nil, require_valid_subnav_links = false, proof = false)
|
34
|
+
bind_options = Components::CommandOptions.new([bind_type], base_streams, verbose)
|
35
|
+
bind_config = config_fetcher.fetch_config
|
36
|
+
cloner = cloner_factory.produce(bind_options.local_repo_dir)
|
37
|
+
|
38
|
+
require_valid_subnav_links = true unless bind_type == 'local'
|
39
|
+
|
40
|
+
directory_preparer.prepare_directories(
|
41
|
+
bind_config,
|
42
|
+
File.expand_path('../../../../', __FILE__),
|
43
|
+
output_locations,
|
44
|
+
cloner,
|
45
|
+
ref_override: bind_options.ref_override
|
46
|
+
)
|
47
|
+
|
48
|
+
sections = section_repository.fetch(
|
49
|
+
configured_sections: bind_config.sections,
|
50
|
+
destination_dir: output_locations.cloned_preprocessing_dir,
|
51
|
+
ref_override: bind_options.ref_override,
|
52
|
+
cloner: cloner,
|
53
|
+
streams: base_streams
|
54
|
+
)
|
55
|
+
preprocessor.preprocess(
|
56
|
+
sections,
|
57
|
+
output_locations,
|
58
|
+
options: { dita_flags: dita_flags, require_valid_subnav_links: require_valid_subnav_links },
|
59
|
+
output_streams: bind_options.streams,
|
60
|
+
config: bind_config
|
61
|
+
)
|
62
|
+
if file_system_accessor.file_exist?('redirects.rb')
|
63
|
+
file_system_accessor.copy('redirects.rb', output_locations.final_app_dir)
|
64
|
+
end
|
65
|
+
|
66
|
+
generation_result = middleman_runner.run(
|
67
|
+
'build --verbose',
|
68
|
+
streams: bind_options.streams,
|
69
|
+
output_locations: output_locations,
|
70
|
+
config: config_decorator.generate(bind_config, sections),
|
71
|
+
local_repo_dir: bind_options.local_repo_dir,
|
72
|
+
subnavs: subnavs(sections),
|
73
|
+
product_info: product_infos(sections),
|
74
|
+
proof: proof
|
75
|
+
)
|
76
|
+
if generation_result.success?
|
77
|
+
file_system_accessor.copy(output_locations.build_dir, output_locations.public_dir)
|
78
|
+
|
79
|
+
link_checker.check!(bind_config.broken_link_exclusions)
|
80
|
+
|
81
|
+
bind_options.streams[:success].puts "Bookbinder bound your book into #{output_locations.final_app_dir}"
|
82
|
+
|
83
|
+
link_checker.has_errors? ? 1 : 0
|
84
|
+
else
|
85
|
+
bind_options.streams[:err].puts "Your bind failed. Rerun with --verbose to troubleshoot."
|
86
|
+
1
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
attr_reader(
|
93
|
+
:base_streams,
|
94
|
+
:cloner_factory,
|
95
|
+
:config_decorator,
|
96
|
+
:config_fetcher,
|
97
|
+
:directory_preparer,
|
98
|
+
:file_system_accessor,
|
99
|
+
:final_app_directory,
|
100
|
+
:output_locations,
|
101
|
+
:preprocessor,
|
102
|
+
:section_repository,
|
103
|
+
:link_checker,
|
104
|
+
:middleman_runner,
|
105
|
+
)
|
106
|
+
|
107
|
+
def subnavs(sections)
|
108
|
+
sections.map(&:subnav).reduce({}, :merge)
|
109
|
+
end
|
110
|
+
|
111
|
+
def product_infos(sections)
|
112
|
+
temp = Hash.new
|
113
|
+
sections.each do |section|
|
114
|
+
temp[section.namespace] = section.product_info
|
115
|
+
end
|
116
|
+
temp
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,181 @@
|
|
1
|
+
Dir.glob(File.expand_path('../../commands/*.rb', __FILE__)).each do |command_file|
|
2
|
+
require command_file unless command_file =~ /collection\.rb\z/
|
3
|
+
end
|
4
|
+
|
5
|
+
require_relative '../commands/components/bind/directory_preparer'
|
6
|
+
require_relative '../commands/components/imprint/directory_preparer'
|
7
|
+
require_relative '../config/configuration_decorator'
|
8
|
+
require_relative '../config/fetcher'
|
9
|
+
require_relative '../config/validator'
|
10
|
+
require_relative '../config/yaml_loader'
|
11
|
+
require_relative '../config/configuration'
|
12
|
+
require_relative '../config/imprint/configuration'
|
13
|
+
require_relative '../dita_command_creator'
|
14
|
+
require_relative '../dita_html_for_middleman_formatter'
|
15
|
+
require_relative '../html_document_manipulator'
|
16
|
+
require_relative '../ingest/cloner_factory'
|
17
|
+
require_relative '../ingest/section_repository'
|
18
|
+
require_relative '../local_filesystem_accessor'
|
19
|
+
require_relative '../middleman_runner'
|
20
|
+
require_relative '../postprocessing/link_checker'
|
21
|
+
require_relative '../preprocessing/dita_html_preprocessor'
|
22
|
+
require_relative '../preprocessing/dita_pdf_preprocessor'
|
23
|
+
require_relative '../preprocessing/link_to_site_gen_dir'
|
24
|
+
require_relative '../preprocessing/preprocessor'
|
25
|
+
require_relative '../subnav/subnav_generator_factory'
|
26
|
+
require_relative '../sheller'
|
27
|
+
require_relative '../values/output_locations'
|
28
|
+
|
29
|
+
module Bookbinder
|
30
|
+
module Commands
|
31
|
+
class Collection
|
32
|
+
include Enumerable
|
33
|
+
|
34
|
+
def initialize(streams, version_control_system)
|
35
|
+
@streams = streams
|
36
|
+
@version_control_system = version_control_system
|
37
|
+
end
|
38
|
+
|
39
|
+
def generate(*args)
|
40
|
+
Commands::Generate.new(
|
41
|
+
local_filesystem_accessor,
|
42
|
+
sheller,
|
43
|
+
Dir.pwd,
|
44
|
+
streams
|
45
|
+
).run(*args)
|
46
|
+
end
|
47
|
+
|
48
|
+
def punch(*args)
|
49
|
+
Commands::Punch.new(
|
50
|
+
streams,
|
51
|
+
configuration_fetcher(Config::Configuration),
|
52
|
+
version_control_system
|
53
|
+
).run(*args)
|
54
|
+
end
|
55
|
+
|
56
|
+
def update_local_doc_repos
|
57
|
+
Commands::UpdateLocalDocRepos.new(
|
58
|
+
streams,
|
59
|
+
configuration_fetcher(Config::Configuration),
|
60
|
+
version_control_system
|
61
|
+
).run
|
62
|
+
end
|
63
|
+
|
64
|
+
def bind(*args)
|
65
|
+
@bind ||= Commands::Bind.new(
|
66
|
+
streams,
|
67
|
+
middleman_runner: runner,
|
68
|
+
output_locations: output_locations,
|
69
|
+
config_fetcher: configuration_fetcher(Config::Configuration),
|
70
|
+
config_decorator: Config::ConfigurationDecorator.new(loader: config_loader, config_filename: 'bookbinder.yml'),
|
71
|
+
file_system_accessor: local_filesystem_accessor,
|
72
|
+
link_checker: Postprocessing::LinkChecker.new(local_filesystem_accessor, final_app_directory, streams),
|
73
|
+
preprocessor: Preprocessing::Preprocessor.new(
|
74
|
+
Preprocessing::DitaHTMLPreprocessor.new(
|
75
|
+
local_filesystem_accessor,
|
76
|
+
subnav_generator_factory,
|
77
|
+
DitaHtmlForMiddlemanFormatter.new(local_filesystem_accessor, html_document_manipulator),
|
78
|
+
dita_command_creator,
|
79
|
+
sheller
|
80
|
+
),
|
81
|
+
Preprocessing::LinkToSiteGenDir.new(local_filesystem_accessor, subnav_generator_factory)
|
82
|
+
),
|
83
|
+
cloner_factory: Ingest::ClonerFactory.new(streams, local_filesystem_accessor, version_control_system),
|
84
|
+
section_repository: Ingest::SectionRepository.new,
|
85
|
+
directory_preparer: directory_preparer
|
86
|
+
).run(*args)
|
87
|
+
end
|
88
|
+
|
89
|
+
def watch(repos=[])
|
90
|
+
@watch ||= Commands::Watch.new(
|
91
|
+
streams,
|
92
|
+
middleman_runner: runner,
|
93
|
+
output_locations: output_locations,
|
94
|
+
config_fetcher: configuration_fetcher(Config::Configuration),
|
95
|
+
config_decorator: Config::ConfigurationDecorator.new(loader: config_loader, config_filename: 'bookbinder.yml'),
|
96
|
+
file_system_accessor: local_filesystem_accessor,
|
97
|
+
preprocessor: Preprocessing::Preprocessor.new(Preprocessing::LinkToSiteGenDir.new(local_filesystem_accessor, subnav_generator_factory)),
|
98
|
+
cloner: local_file_system_cloner,
|
99
|
+
section_repository: Ingest::SectionRepository.new,
|
100
|
+
directory_preparer: directory_preparer,
|
101
|
+
repo_restrictions: repos
|
102
|
+
).run
|
103
|
+
end
|
104
|
+
|
105
|
+
def imprint(*args)
|
106
|
+
Bookbinder::Commands::Imprint.new(
|
107
|
+
streams,
|
108
|
+
output_locations: output_locations,
|
109
|
+
config_fetcher: configuration_fetcher(Config::Imprint::Configuration),
|
110
|
+
preprocessor: Preprocessing::Preprocessor.new(Preprocessing::DitaPDFPreprocessor.new(local_filesystem_accessor, dita_command_creator, sheller)),
|
111
|
+
cloner_factory: Ingest::ClonerFactory.new(streams, local_filesystem_accessor, version_control_system),
|
112
|
+
section_repository: Ingest::SectionRepository.new,
|
113
|
+
directory_preparer: Commands::Components::Imprint::DirectoryPreparer.new(local_filesystem_accessor)
|
114
|
+
).run(*args)
|
115
|
+
end
|
116
|
+
|
117
|
+
private
|
118
|
+
|
119
|
+
attr_reader :streams, :version_control_system
|
120
|
+
|
121
|
+
def dita_command_creator
|
122
|
+
DitaCommandCreator.new(ENV['PATH_TO_DITA_OT_LIBRARY'])
|
123
|
+
end
|
124
|
+
|
125
|
+
def configuration_fetcher(config_class)
|
126
|
+
Bookbinder::Config::Fetcher.new(
|
127
|
+
Bookbinder::Config::Validator.new(local_filesystem_accessor),
|
128
|
+
config_loader,
|
129
|
+
config_class
|
130
|
+
).tap do |fetcher|
|
131
|
+
fetcher.set_config_file_path './config.yml'
|
132
|
+
fetcher.set_config_dir_path './config/'
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def config_loader
|
137
|
+
@config_loader ||= Config::YAMLLoader.new
|
138
|
+
end
|
139
|
+
|
140
|
+
def subnav_generator_factory
|
141
|
+
Subnav::SubnavGeneratorFactory.new(local_filesystem_accessor, output_locations)
|
142
|
+
end
|
143
|
+
|
144
|
+
def directory_preparer
|
145
|
+
Commands::Components::Bind::DirectoryPreparer.new(local_filesystem_accessor)
|
146
|
+
end
|
147
|
+
|
148
|
+
def output_locations
|
149
|
+
OutputLocations.new(final_app_dir: final_app_directory, context_dir: File.absolute_path('.'))
|
150
|
+
end
|
151
|
+
|
152
|
+
def final_app_directory
|
153
|
+
@final_app_directory ||= File.absolute_path('final_app')
|
154
|
+
end
|
155
|
+
|
156
|
+
def html_document_manipulator
|
157
|
+
@html_document_manipulator ||= HtmlDocumentManipulator.new
|
158
|
+
end
|
159
|
+
|
160
|
+
def local_filesystem_accessor
|
161
|
+
@local_filesystem_accessor ||= LocalFilesystemAccessor.new
|
162
|
+
end
|
163
|
+
|
164
|
+
def sheller
|
165
|
+
@sheller ||= Sheller.new
|
166
|
+
end
|
167
|
+
|
168
|
+
def sitemap_port
|
169
|
+
41722
|
170
|
+
end
|
171
|
+
|
172
|
+
def runner
|
173
|
+
MiddlemanRunner.new(local_filesystem_accessor, sheller)
|
174
|
+
end
|
175
|
+
|
176
|
+
def local_file_system_cloner
|
177
|
+
Ingest::LocalFilesystemCloner.new(streams, local_filesystem_accessor, File.expand_path('..'))
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|