bookbindery 9.9.0 → 9.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d3e9b9d9984fdb5afedfa756024384d4a9bf9e5b
4
- data.tar.gz: 9cdf1c79a329c48f0811bfa4f418d17f7ec5a8e9
3
+ metadata.gz: 99c1606223bcc841a9f5c9abd0f8bb3df7212e13
4
+ data.tar.gz: f92ba6323770d66d4f00db7194535ff46bac06e3
5
5
  SHA512:
6
- metadata.gz: aab7f18000c610ea0fb322f403ebc2c3703b734fb3ff6867f260bf4666e375bf76564a12465a199205c8a5392f787c2ec8c686e37f15fe3fb53c46eb2924a43b
7
- data.tar.gz: 55271d726387b9e4108c0519373c31eb26ff4e05e5e4166585c933f7d59f201442ba825fba387b2b121341514a1e372660a88e381bea513b7b35beca0e02fd0c
6
+ metadata.gz: 04376d1753d497e4b55ef42960ef90948de5a106d7706d296e8c225081e54b7b4e73cea9ee1c85e8791a4ce849a3c3563e9d623f95fe0c36b55aeadbd7ee47d1
7
+ data.tar.gz: 58d72ca85fda5c537c48da63752c041c1785da464b77e7928cfb34e4c289e1e4e1153d58eca3710a10f75d73ea7e98a95a7570ec4c12951b846d29f0c9dcdd30
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.9.0'
5
+ s.version = '9.10.0'
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']
@@ -52,9 +52,15 @@ module Bookbinder
52
52
  raise Thor::Error, '' if code != 0
53
53
  end
54
54
 
55
- desc 'watch', 'Bind and serve a local book, watching for changes'
56
- def watch
57
- code = legacy_commands.watch
55
+ desc 'watch [repo1 [repo2]]', 'Bind and serve a local book, watching for changes'
56
+ long_desc <<-LONG_DESC
57
+ Bind and serve a local book, watching for changes
58
+
59
+ Optionally, you can provide a subset of the repositories in the book to be watched.
60
+ This will exclude any repositories not specified from being available in the bound book, even if they exist on your file system.
61
+ LONG_DESC
62
+ def watch(*repos)
63
+ code = legacy_commands.watch(repos)
58
64
  raise Thor::Error, '' if code != 0
59
65
  end
60
66
 
@@ -64,11 +64,11 @@ module Bookbinder
64
64
  def bind(*args)
65
65
  @bind ||= Commands::Bind.new(
66
66
  streams,
67
+ middleman_runner: runner,
67
68
  output_locations: output_locations,
68
69
  config_fetcher: configuration_fetcher(Config::Configuration),
69
70
  config_decorator: Config::ConfigurationDecorator.new(loader: config_loader, config_filename: 'bookbinder.yml'),
70
71
  file_system_accessor: local_filesystem_accessor,
71
- middleman_runner: runner,
72
72
  broken_links_checker: Postprocessing::BrokenLinksChecker.build(final_app_directory, sitemap_port),
73
73
  preprocessor: Preprocessing::Preprocessor.new(
74
74
  Preprocessing::DitaHTMLPreprocessor.new(
@@ -86,7 +86,7 @@ module Bookbinder
86
86
  ).run(*args)
87
87
  end
88
88
 
89
- def watch
89
+ def watch(repos=[])
90
90
  @watch ||= Commands::Watch.new(
91
91
  streams,
92
92
  middleman_runner: runner,
@@ -97,7 +97,8 @@ module Bookbinder
97
97
  preprocessor: Preprocessing::Preprocessor.new(Preprocessing::LinkToSiteGenDir.new(local_filesystem_accessor, subnav_generator_factory)),
98
98
  cloner: local_file_system_cloner,
99
99
  section_repository: Ingest::SectionRepository.new,
100
- directory_preparer: directory_preparer
100
+ directory_preparer: directory_preparer,
101
+ repo_restrictions: repos
101
102
  ).run
102
103
  end
103
104
 
@@ -10,7 +10,8 @@ module Bookbinder
10
10
  preprocessor: nil,
11
11
  cloner: nil,
12
12
  section_repository: nil,
13
- directory_preparer: nil)
13
+ directory_preparer: nil,
14
+ repo_restrictions: [])
14
15
  @streams = streams
15
16
  @middleman_runner = middleman_runner
16
17
  @output_locations = output_locations
@@ -21,6 +22,7 @@ module Bookbinder
21
22
  @cloner = cloner
22
23
  @section_repository = section_repository
23
24
  @directory_preparer = directory_preparer
25
+ @repo_restrictions = repo_restrictions
24
26
  end
25
27
 
26
28
  def run
@@ -33,7 +35,7 @@ module Bookbinder
33
35
  cloner
34
36
  )
35
37
  sections = section_repository.fetch(
36
- configured_sections: watch_config.sections,
38
+ configured_sections: filter_sections(watch_config.sections),
37
39
  destination_dir: output_locations.cloned_preprocessing_dir,
38
40
  cloner: cloner,
39
41
  streams: streams
@@ -84,6 +86,15 @@ module Bookbinder
84
86
  end
85
87
  temp
86
88
  end
89
+
90
+ def filter_sections(section_configs)
91
+ return section_configs if @repo_restrictions.nil? || @repo_restrictions.empty?
92
+
93
+ section_configs.select do |config|
94
+ repo_name = (config.repo_name || '').split('/').last
95
+ @repo_restrictions.include?(repo_name)
96
+ end
97
+ end
87
98
  end
88
99
  end
89
100
  end
@@ -42,8 +42,7 @@ Found #{@broken_links.count} broken links!
42
42
  def find_broken_links(port, broken_link_exclusions: /(?!.*)/)
43
43
  temp_host = "localhost:#{port}"
44
44
  sieve = Sieve.new domain: "http://#{temp_host}"
45
- links = crawl_from "http://#{temp_host}#{ENV['CUSTOM_ROOT']}/index.html", sieve
46
- broken_links = links.first
45
+ broken_links = crawl_from "http://#{temp_host}#{ENV['CUSTOM_ROOT']}/index.html", sieve
47
46
  public_broken_links = broken_links.reject {|l| l.match(broken_link_exclusions)}
48
47
 
49
48
  Result.new(public_broken_links)
@@ -55,22 +54,20 @@ Found #{@broken_links.count} broken links!
55
54
 
56
55
  def crawl_from(url, sieve)
57
56
  broken_links = []
58
- sitemap = [url]
59
57
  2.times do |i|
60
58
  is_first_pass = (i==0)
61
59
 
62
- Anemone.crawl(url) do |anemone|
60
+ Anemone.crawl(url, discard_page_bodies: true) do |anemone|
63
61
  dont_visit_fragments(anemone)
64
62
  anemone.on_every_page do |page|
65
63
  broken, working = sieve.links_from(Stabilimentum.new(page), is_first_pass)
66
64
  broken_links.concat broken
67
- sitemap.concat working
68
65
  end
69
66
  end
70
67
  end
71
68
 
72
69
  broken_links.concat Dir.chdir(@app_dir) { CssLinkChecker.new.broken_links_in_all_stylesheets }
73
- [broken_links.compact.uniq, sitemap.compact.uniq]
70
+ broken_links.compact.uniq
74
71
  end
75
72
 
76
73
  def dont_visit_fragments(anemone)
@@ -1,4 +1,5 @@
1
1
  require 'erb'
2
+ require 'rack/utils'
2
3
 
3
4
  module Bookbinder
4
5
  module Subnav
@@ -60,6 +61,10 @@ module Bookbinder
60
61
  def links?(links)
61
62
  (links || []).empty?
62
63
  end
64
+
65
+ def escape_html(str)
66
+ Rack::Utils.escape_html(str)
67
+ end
63
68
  end
64
69
  end
65
70
  end
@@ -2,7 +2,7 @@
2
2
  <ul>
3
3
  <% @links.each do |link| %>
4
4
  <li class="<%= submenu_class(link) %>">
5
- <a href="<%= link[:url] %>"><%= link[:text] %></a>
5
+ <a href="<%= link[:url] %>"><%= escape_html link[:text] %></a>
6
6
  <%= render_links link[:nested_links] %>
7
7
  </li>
8
8
  <% end %>
@@ -8,7 +8,11 @@ module Bookbinder
8
8
  @product_name = source_fields['product_name']
9
9
  @product_version = source_fields['product_version']
10
10
 
11
- @text = attrs.fetch('highlight').fetch('text').first.strip
11
+ if attrs.has_key?('highlight')
12
+ @text = attrs.fetch('highlight').fetch('text').first.strip
13
+ else
14
+ @text = source_fields.fetch('summary')
15
+ end
12
16
  end
13
17
 
14
18
  attr_reader :title, :url, :text, :product_name, :product_version
@@ -1,3 +1,9 @@
1
+ <%
2
+ def escape_html(str)
3
+ Rack::Utils.escape_html(str)
4
+ end
5
+ %>
6
+
1
7
  <div class="search-results">
2
8
  <form method="get">
3
9
 
@@ -8,12 +14,12 @@
8
14
  <% end %>
9
15
  </h4>
10
16
  <% end %>
11
- <input name="q" value="<%= search_term %>"/>
17
+ <input name="q" value="<%= escape_html search_term %>"/>
12
18
  <% unless product_name.nil? %>
13
- <input type="hidden" name="product_name" value="<%= product_name %>"/>
19
+ <input type="hidden" name="product_name" value="<%= escape_html product_name %>"/>
14
20
  <% end %>
15
21
  <% unless product_version.nil? %>
16
- <input type="hidden" name="product_version" value="<%= product_version %>"/>
22
+ <input type="hidden" name="product_version" value="<%= escape_html product_version %>"/>
17
23
  <% end %>
18
24
  </form>
19
25
 
@@ -13,6 +13,7 @@ size: 10
13
13
  _source:
14
14
  - url
15
15
  - title
16
+ - summary
16
17
  - product_name
17
18
  - product_version
18
19
  highlight:
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.9.0
4
+ version: 9.10.0
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-10 00:00:00.000000000 Z
25
+ date: 2016-06-14 00:00:00.000000000 Z
26
26
  dependencies:
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: fog-aws