bookbindery 7.3.0 → 7.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 88ea31dee49567678221b2f7ec08271dbee24d4d
4
- data.tar.gz: dc7bc2856531c909147a8c215466e4ca78f29224
3
+ metadata.gz: 6fbb90bb60080378f6d5e9080fa9739307cc1f73
4
+ data.tar.gz: 7f59d507842d42be00fd7084ef8764ca50415fe1
5
5
  SHA512:
6
- metadata.gz: 7edb2efc47d478fa5908c40ad733bcfd1ab73b56af875dcbbc00c49768c6356f544b1c4ff5e378e3c9ff8623a598d8628c3e53d81d8ead55a023a0e42791054c
7
- data.tar.gz: 5899419c8b5cd1ab847ba3dd9d556f2dbc68a4fc832deb1536b306fae063fe6bfe28705dccb894c5175d342c85bb4593025e54f0ce45eb4edebcd63ef691ea42
6
+ metadata.gz: 0c374ea381928402b7acf3b9bbbcd3958e8696ef6377d5207250f855e056ef11f3c9903a415b7f879771ad1932dcb4b711726b3ea9c06b2c80e60ddd647a396b
7
+ data.tar.gz: 1d1c6a97884de5e8bb5ce86829c43d40bdccf7e17a3b128cec15ad703b04e31369712312b053727980d3f496e30e9c3494d73ba884d6f6ff9815737cd6a77258
@@ -2,10 +2,10 @@ require 'base64'
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'bookbindery'
5
- s.version = '7.3.0'
5
+ s.version = '7.4.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
- s.authors = ['Mike Grafton', 'Lucas Marks', 'Gavin Morgan', 'Nikhil Gajwani', 'Dan Wendorf', 'Brenda Chan', 'Matthew Boedicker', 'Frank Kotsianas', 'Elena Sharma', 'Christa Hartsock']
8
+ s.authors = ['Mike Grafton', 'Lucas Marks', 'Gavin Morgan', 'Nikhil Gajwani', 'Dan Wendorf', 'Brenda Chan', 'Matthew Boedicker', 'Frank Kotsianas', 'Elena Sharma', 'Christa Hartsock', 'Michael Trestman']
9
9
  s.email = Base64.decode64('Z21vcmdhbkBnb3Bpdm90YWwuY29t') # Gavin's
10
10
 
11
11
  s.files = Dir['lib/**/*'] + Dir['template_app/**/*'] + Dir['master_middleman/**/*'] + Dir['install_bin/**/*'] + Dir['bookbinder.gemspec']
@@ -3,7 +3,7 @@ Dir.glob(File.expand_path('../../commands/*.rb', __FILE__)).each do |command_fil
3
3
  end
4
4
 
5
5
  require_relative '../commands/bind/directory_preparer'
6
- require_relative '../config/archive_menu_configuration'
6
+ require_relative '../config/configuration_decorator'
7
7
  require_relative '../config/fetcher'
8
8
  require_relative '../config/remote_yaml_credential_provider'
9
9
  require_relative '../config/validator'
@@ -90,7 +90,7 @@ module Bookbinder
90
90
  streams,
91
91
  output_locations,
92
92
  configuration_fetcher,
93
- Config::ArchiveMenuConfiguration.new(loader: config_loader, config_filename: 'bookbinder.yml'),
93
+ Config::ConfigurationDecorator.new(loader: config_loader, config_filename: 'bookbinder.yml'),
94
94
  local_filesystem_accessor,
95
95
  runner,
96
96
  Postprocessing::SitemapWriter.build(logger, final_app_directory, sitemap_port),
@@ -116,7 +116,7 @@ module Bookbinder
116
116
  middleman_runner: runner,
117
117
  output_locations: output_locations,
118
118
  config_fetcher: configuration_fetcher,
119
- config_decorator: Config::ArchiveMenuConfiguration.new(loader: config_loader, config_filename: 'bookbinder.yml'),
119
+ config_decorator: Config::ConfigurationDecorator.new(loader: config_loader, config_filename: 'bookbinder.yml'),
120
120
  file_system_accessor: local_filesystem_accessor,
121
121
  preprocessor: Preprocessing::Preprocessor.new(Preprocessing::LinkToSiteGenDir.new(local_filesystem_accessor, subnav_generator_factory)),
122
122
  cloner: local_file_system_cloner,
@@ -66,7 +66,7 @@ module Bookbinder
66
66
  end
67
67
 
68
68
  CONFIG_REQUIRED_KEYS = %w(book_repo public_host)
69
- CONFIG_OPTIONAL_KEYS = %w(archive_menu book_repo_url cred_repo cred_repo_url layout_repo layout_repo_ref layout_repo_url sections subnav_exclusions feedback_enabled)
69
+ CONFIG_OPTIONAL_KEYS = %w(archive_menu book_repo_url cred_repo cred_repo_url repo_link_enabled repo_links feedback_enabled layout_repo layout_repo_ref layout_repo_url sections subnav_exclusions)
70
70
 
71
71
  CONFIG_REQUIRED_KEYS.each do |method_name|
72
72
  define_method(method_name) do
@@ -2,7 +2,7 @@ require_relative 'configuration'
2
2
 
3
3
  module Bookbinder
4
4
  module Config
5
- class ArchiveMenuConfiguration
5
+ class ConfigurationDecorator
6
6
  def initialize(loader: nil, config_filename: nil)
7
7
  @loader = loader
8
8
  @config_filename = config_filename
@@ -11,13 +11,29 @@ module Bookbinder
11
11
  def generate(base_config, sections)
12
12
  base_config.merge(
13
13
  Configuration.new(
14
- archive_menu: root_config(base_config).merge(section_config(sections))))
14
+ repo_links: repo_link_config(base_config, sections),
15
+ archive_menu: root_config(base_config).merge(section_config(sections)))
16
+ )
15
17
  end
16
18
 
17
19
  private
18
20
 
19
21
  attr_reader :loader, :config_filename
20
22
 
23
+ def repo_link_config(base_config, sections)
24
+ if base_config.repo_link_enabled
25
+ sections.reduce({}) {|config, section|
26
+ config.merge(
27
+ section.desired_directory_name => {
28
+ 'repo' => section.repo_name,
29
+ 'ref' => section.source_ref,
30
+ 'at_path' => section.at_repo_path
31
+ }
32
+ )
33
+ }
34
+ end
35
+ end
36
+
21
37
  def root_config(base_config)
22
38
  { '.' => base_config.archive_menu }
23
39
  end
@@ -39,7 +39,7 @@ module Bookbinder
39
39
  end
40
40
 
41
41
  def revert_to_erb(text)
42
- text.gsub('&lt;%', '<%').gsub('%&gt;', '%>')
42
+ text.gsub('&lt;%', '<%').gsub('%&gt;', '%>').gsub('&lt;\%', '&lt;%')
43
43
  end
44
44
  end
45
45
  end
@@ -62,11 +62,15 @@ module Bookbinder
62
62
  end
63
63
  end
64
64
 
65
- def author_date(path)
65
+ def author_date(path, exclusion_flag: '[exclude]')
66
66
  Pathname(path).dirname.ascend do |current_dir|
67
67
  if current_dir.to_s.include?(source_dir_name) && current_dir.entries.include?(Pathname(".git"))
68
68
  git = Git.open(current_dir)
69
- return git.gblob(path).log.first.author.date
69
+ logs = git.gblob(path).log
70
+
71
+ last_non_excluded_commit = logs.detect { |log| !log.message.include?(exclusion_flag) }
72
+
73
+ return last_non_excluded_commit.author.date
70
74
  end
71
75
  end
72
76
  end
@@ -24,6 +24,7 @@ module Bookbinder
24
24
  WorkingCopy.new(
25
25
  copied_to: copied_to,
26
26
  full_name: source_repo_name,
27
+ ref: source_ref
27
28
  )
28
29
  end
29
30
 
@@ -1,9 +1,10 @@
1
1
  module Bookbinder
2
2
  module Ingest
3
3
  class MissingWorkingCopy
4
- def initialize(source_repo_name, source_dir)
4
+ def initialize(source_repo_name, source_dir, source_ref=nil)
5
5
  @source_repo_name = source_repo_name
6
- @source_dir= source_dir
6
+ @source_dir = source_dir
7
+ @source_ref = source_ref
7
8
  end
8
9
 
9
10
  def full_name
@@ -14,6 +15,10 @@ module Bookbinder
14
15
  Pathname(@source_dir)
15
16
  end
16
17
 
18
+ def ref
19
+ @source_ref
20
+ end
21
+
17
22
  def available?
18
23
  false
19
24
  end
@@ -32,7 +32,9 @@ module Bookbinder
32
32
  section_config.subnav_template,
33
33
  section_config.subnav_name,
34
34
  section_config.preprocessor_config,
35
- section_config.at_repo_path
35
+ section_config.at_repo_path,
36
+ section_config.repo_name,
37
+ working_copy.ref
36
38
  )
37
39
  end
38
40
  end
@@ -3,15 +3,17 @@ require_relative '../errors/programmer_mistake'
3
3
  module Bookbinder
4
4
  module Ingest
5
5
  class WorkingCopy
6
- attr_reader :full_name
6
+ attr_reader :full_name, :ref
7
7
 
8
8
  def initialize(copied_to: nil,
9
- full_name: nil)
9
+ full_name: nil,
10
+ ref: nil)
10
11
  if [copied_to, full_name].none?
11
12
  raise Errors::ProgrammerMistake.new("Must provide copied_to and/or full_name to WorkingCopy.new")
12
13
  else
13
14
  @copied_to = copied_to
14
15
  @full_name = full_name
16
+ @ref = ref
15
17
  end
16
18
  end
17
19
 
@@ -24,9 +26,10 @@ module Bookbinder
24
26
  end
25
27
 
26
28
  def ==(other)
27
- [@copied_to, @full_name] ==
29
+ [@copied_to, @full_name, @ref] ==
28
30
  [other.instance_variable_get(:@copied_to),
29
- other.instance_variable_get(:@full_name)]
31
+ other.instance_variable_get(:@full_name),
32
+ other.instance_variable_get(:@ref)]
30
33
  end
31
34
  end
32
35
  end
@@ -25,7 +25,9 @@ module Bookbinder
25
25
  template_variables: config.template_variables,
26
26
  local_repo_dir: local_repo_dir,
27
27
  workspace: output_locations.workspace_dir,
28
- feedback_enabled: config.feedback_enabled
28
+ feedback_enabled: config.feedback_enabled,
29
+ repo_link_enabled: config.repo_link_enabled,
30
+ repo_links: config.repo_links
29
31
  }
30
32
  fs.write(to: "bookbinder_config.yml", text: YAML.dump(config))
31
33
  sheller.run_command({'MM_ROOT' => output_locations.master_dir.to_s},
@@ -8,7 +8,9 @@ module Bookbinder
8
8
  :subnav_templ,
9
9
  :desired_subnav_name,
10
10
  :preprocessor_config,
11
- :at_repo_path) do
11
+ :at_repo_path,
12
+ :repo_name,
13
+ :source_ref) do
12
14
  def path_to_repo_dir
13
15
  at_repo_path.nil? ? path_to_repository : path_to_repository.join(at_repo_path)
14
16
  end
@@ -62,6 +62,16 @@ module Bookbinder
62
62
  partial 'layouts/feedback' if config[:feedback_enabled] && !current_page.metadata[:page][:feedback_disabled]
63
63
  end
64
64
 
65
+ def exclude_repo_link
66
+ current_page.add_metadata({page: {repo_link_disabled: true}})
67
+ end
68
+
69
+ def render_repo_link
70
+ if config[:repo_link_enabled] && !current_page.metadata[:page][:repo_link_disabled] && repo_url
71
+ "<a href='#{repo_url}'>View the source for this page in GitHub</a>"
72
+ end
73
+ end
74
+
65
75
  def mermaid_diagram(&blk)
66
76
  escaped_text = capture(&blk).gsub('-','\-')
67
77
 
@@ -112,6 +122,39 @@ module Bookbinder
112
122
  'NUMERIC_CLASS_PREFIX'
113
123
  end
114
124
 
125
+ def repo_url
126
+ nested_dir, filename = parse_out_nested_dir_and_filename
127
+ repo_dir = config[:repo_links].keys.select{|key| nested_dir.include? key }[0]
128
+ page_repo_config = config[:repo_links][repo_dir]
129
+
130
+ if page_repo_config && page_repo_config['ref']
131
+ at_path = at_path(page_repo_config)
132
+ ref = Pathname(page_repo_config['ref'])
133
+ org_repo = Pathname(page_repo_config['repo'])
134
+
135
+ nested_dir = extract_nested_directory(nested_dir, repo_dir)
136
+
137
+ "http://github.com/#{org_repo.join(Pathname('blob'), ref, Pathname(nested_dir), at_path, filename)}.md.erb"
138
+ end
139
+ end
140
+
141
+ def parse_out_nested_dir_and_filename
142
+ current_page.path.match(/\/?(.*?)\/?([^\/]*.html$?)/).captures
143
+ end
144
+
145
+ def extract_nested_directory(nested_dir, repo_dir)
146
+ nested_dir = nested_dir.gsub("#{repo_dir}", '')
147
+ nested_dir = nested_dir.sub('/', '') if nested_dir[0] == '/'
148
+
149
+ nested_dir
150
+ end
151
+
152
+ def at_path(page_repo_config)
153
+ path = page_repo_config['at_path'] || ""
154
+
155
+ Pathname(path)
156
+ end
157
+
115
158
  def add_ancestors_of(page, ancestors)
116
159
  if page
117
160
  add_ancestors_of(page.parent, ancestors + [page])
@@ -5,3 +5,4 @@ ruby '2.0.0'
5
5
  gem 'vienna'
6
6
  gem 'rack-rewrite'
7
7
  gem 'therubyracer'
8
+ gem 'sendgrid-ruby'
@@ -1,10 +1,19 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
+ faraday (0.9.2)
5
+ multipart-post (>= 1.2, < 3)
4
6
  libv8 (3.16.14.7)
7
+ mimemagic (0.3.0)
8
+ multipart-post (2.0.0)
5
9
  rack (1.5.2)
6
10
  rack-rewrite (1.5.0)
7
11
  ref (1.0.5)
12
+ sendgrid-ruby (1.1.5)
13
+ faraday (~> 0.9)
14
+ mimemagic
15
+ smtpapi (~> 0.1)
16
+ smtpapi (0.1.0)
8
17
  therubyracer (0.12.1)
9
18
  libv8 (~> 3.16.14.0)
10
19
  ref
@@ -16,5 +25,9 @@ PLATFORMS
16
25
 
17
26
  DEPENDENCIES
18
27
  rack-rewrite
28
+ sendgrid-ruby
19
29
  therubyracer
20
30
  vienna
31
+
32
+ BUNDLED WITH
33
+ 1.10.6
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: 7.3.0
4
+ version: 7.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Grafton
@@ -14,10 +14,11 @@ authors:
14
14
  - Frank Kotsianas
15
15
  - Elena Sharma
16
16
  - Christa Hartsock
17
+ - Michael Trestman
17
18
  autorequire:
18
19
  bindir: install_bin
19
20
  cert_chain: []
20
- date: 2015-11-11 00:00:00.000000000 Z
21
+ date: 2015-12-03 00:00:00.000000000 Z
21
22
  dependencies:
22
23
  - !ruby/object:Gem::Dependency
23
24
  name: fog-aws
@@ -316,7 +317,6 @@ files:
316
317
  - lib/bookbinder/commands/update_local_doc_repos.rb
317
318
  - lib/bookbinder/commands/version.rb
318
319
  - lib/bookbinder/commands/watch.rb
319
- - lib/bookbinder/config/archive_menu_configuration.rb
320
320
  - lib/bookbinder/config/aws_credentials.rb
321
321
  - lib/bookbinder/config/cf_credentials.rb
322
322
  - lib/bookbinder/config/checkers/archive_menu_checker.rb
@@ -327,6 +327,7 @@ files:
327
327
  - lib/bookbinder/config/checkers/subnavs_checker.rb
328
328
  - lib/bookbinder/config/checkers/topics_checker.rb
329
329
  - lib/bookbinder/config/configuration.rb
330
+ - lib/bookbinder/config/configuration_decorator.rb
330
331
  - lib/bookbinder/config/fetcher.rb
331
332
  - lib/bookbinder/config/remote_yaml_credential_provider.rb
332
333
  - lib/bookbinder/config/section_config.rb