ascii_binder 0.2.0 → 1.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
  SHA256:
3
- metadata.gz: f2f0c681a484a802db17a50ebbbd8813c8398d4d79cf7b6f91a53cdfb1f460a4
4
- data.tar.gz: fdf32199cf71677ae3ca7ff5b8962bde144b03f07feec8686df567c953c48aed
3
+ metadata.gz: 26f9de41f109228dfa1478976e8d1b8f08a178300d092e3250dcca610e4e70b6
4
+ data.tar.gz: 4cf902ff6c38a7a9ce622cdfaef927ed3943c750bcf71051a0bf00d430fce603
5
5
  SHA512:
6
- metadata.gz: 759f9f9df03df35eaf06e104a62f01aac906860b8e3ee83b3160ea46def33a16a249034482dcbd37007568c75975fd4ea1e33127fc7b2c51e988bf41d2626332
7
- data.tar.gz: 6e3d69dc9de3af08151615a57bf501a61501a0c3d1fee5c43c4b4f874861efb131b82f783ea8df7c3a953ff6a06ef0dc4cf4020555842f74093ff3678bc7b7f6
6
+ metadata.gz: d978b66122655791fcefc86a04741b94940fdfffab86e2ace9dd2454bef63849bda46b8776b90bad9bf7f9a87a7cce42ca4115bb2650fd0ee7836f23ed5ca7cb
7
+ data.tar.gz: e8b18ebdb1a1fbc8114645692e91342f6d48b8bb42b63f5c763a18550fbf45d7c3cac73c6ebd164910400448e3a0a2babcf0faa51a5cf06e98def1d66f9bae76
data/bin/asciibinder CHANGED
@@ -31,9 +31,9 @@ def repo_check(docs_basedir)
31
31
  end
32
32
  end
33
33
  # Either of these must be present
34
- unless File.exist?(File.join(docs_basedir, '_build_cfg.yml')) or File.exist?(File.join(docs_basedir, '_topic_map.yml'))
35
- missing_files = true
36
- end
34
+ # unless File.exist?(File.join("#{docs_basedir}/#{TOPIC_MAP_FOLDER}", '_topic_map.yml'))
35
+ # missing_files = true
36
+ # end
37
37
  if missing_files or not in_git_repo(docs_basedir)
38
38
  Trollop::die "The specified docs base directory '#{docs_basedir}' does not appear to be part of an AsciiBinder-compatible repo."
39
39
  end
@@ -183,11 +183,9 @@ Description:
183
183
  ...except that the Guardfile automatically detects and runs this as
184
184
  you work.
185
185
 
186
- This is meant to be used in conjunction with a web browser that is
187
- running a LiveReload plugin. If you are viewing the output HTML page
188
- in a browser where LiveReload is active, then every time you save a
189
- new version of the .adoc file, the new HTML is automatically
190
- regenerated and your page view is automatically refreshed.
186
+ This is meant to be used in conjunction with a web browser that is viewing the
187
+ output HTML page. Every time you save a new version of the .adoc file, you can
188
+ manually refresh your page to view the newly-generated HTML.
191
189
  EOF
192
190
  opt :log_level, "Set the logging output level for this operation.", :default => 'warn'
193
191
  end
@@ -302,7 +300,7 @@ if cmd == 'clone'
302
300
  Dir.chdir(docs_basedir)
303
301
  puts "Tracking branch setup:"
304
302
  cloned_map.distro_branches.each do |doc_branch|
305
- next if doc_branch == 'master'
303
+ next if doc_branch == 'main'
306
304
  puts "- #{doc_branch}"
307
305
  system("git branch #{doc_branch} origin/#{doc_branch}")
308
306
  end
@@ -299,9 +299,9 @@ module Helpers
299
299
  end
300
300
  system("cd #{working_dir} && git add . > /dev/null && git commit -am 'test commit' > /dev/null")
301
301
  if multiple_distros
302
- system("cd #{working_dir} && git checkout -b branch1 > /dev/null 2>&1 && git checkout -b branch2 > /dev/null 2>&1 && git checkout master > /dev/null 2>&1")
302
+ system("cd #{working_dir} && git checkout -b branch1 > /dev/null 2>&1 && git checkout -b branch2 > /dev/null 2>&1 && git checkout main > /dev/null 2>&1")
303
303
  end
304
- set_initial_working_branch('master')
304
+ set_initial_working_branch('main')
305
305
  end
306
306
  working_dir
307
307
  end
@@ -325,7 +325,7 @@ module Helpers
325
325
  if run_command('create',[],remote_dir)[:status].exitstatus == 0
326
326
  clone_map = File.join(gem_root,'features','support','_clone_distro_map.yml')
327
327
  FileUtils.cp(clone_map,File.join(remote_dir,'_distro_map.yml'))
328
- system("cd #{remote_dir} && git add . > /dev/null && git commit -am 'remote commit' > /dev/null && git checkout -b branch1 > /dev/null 2>&1 && git checkout master > /dev/null 2>&1")
328
+ system("cd #{remote_dir} && git add . > /dev/null && git commit -am 'remote commit' > /dev/null && git checkout -b branch1 > /dev/null 2>&1 && git checkout main > /dev/null 2>&1")
329
329
  else
330
330
  puts "ERROR: Could not initialize remote repo"
331
331
  exit 1
@@ -78,18 +78,50 @@ module AsciiBinder
78
78
 
79
79
  # Protip: Don't cache these! The topic map needs to be reread every time we change branches.
80
80
  def topic_map_file
81
+
82
+ # new stuff 1/Nov/2021
83
+ # allow users to break up the topic map into multiple topic maps
84
+ # load topic maps from a single folder called _topic_maps.
85
+ # we assume that all files in this folder are correctly formatted topic maps. If not, you will get normal asciibinder errors
86
+ topic_map_folder = TOPIC_MAP_FOLDER
81
87
  topic_file = TOPIC_MAP_FILENAME
82
- unless File.exist?(File.join(docs_root_dir,topic_file))
83
- # The new filename '_topic_map.yml' couldn't be found;
84
- # switch to the old one and warn the user.
85
- topic_file = BUILD_FILENAME
86
- unless File.exist?(File.join(docs_root_dir,topic_file))
87
- # Critical error - no topic map file at all.
88
- Trollop::die "Could not find any topic map file ('#{TOPIC_MAP_FILENAME}' or '#{BUILD_FILENAME}') at #{docs_root_dir} in branch '#{git.branch}'"
88
+
89
+ if !Dir.exist?(File.join(docs_root_dir, topic_map_folder))
90
+ # if the _topic_maps directory doesn't exist or is empty, see if we can find the topic map in the root folder to maintain backward compatibility
91
+
92
+ if !File.exist?(File.join(docs_root_dir, topic_file))
93
+ # fall back to looking for a _topic_map in the root directory
94
+
95
+ topic_file = BUILD_FILENAME # old folders use build_config.yml
96
+
97
+ if !File.exist?(File.join(docs_root_dir, topic_file))
98
+ # Critical error - no topic map file at all.
99
+ Trollop::die "Could not find a valid topic map file. There is no #{TOPIC_MAP_FOLDER} folder and the fall back files #{TOPIC_MAP_FILENAME} or #{BUILD_FILENAME} in branch '#{git.branch}' were also not found."
100
+ else
101
+ t = File.join(docs_root_dir, topic_file) # found build_config
102
+ end
103
+ else
104
+ t = File.join(docs_root_dir, topic_file) # found topic_map in root
89
105
  end
90
- log_warn("'#{BUILD_FILENAME}' is a deprecated filename. Rename this to '#{TOPIC_MAP_FILENAME}'.")
106
+
107
+ else
108
+
109
+ # topic map files are in the _topic_maps folder
110
+
111
+ # create a combined temp file with all topic maps
112
+ tf = Tempfile.new("#{TOPIC_MAP_FILENAME}")
113
+
114
+ Dir.glob("#{topic_map_folder}/*.yml").each do |filename|
115
+ lines = IO.read(filename)
116
+ tf << lines
117
+ end
118
+
119
+ t = tf.path
91
120
  end
92
- topic_file
121
+
122
+ # returns the path to the final file
123
+ t
124
+
93
125
  end
94
126
 
95
127
  def topic_map
@@ -451,7 +483,7 @@ module AsciiBinder
451
483
 
452
484
  def configure_and_generate_page(topic,branch_config,navigation)
453
485
  distro = branch_config.distro
454
- topic_adoc = File.open(topic.source_path,'r').read
486
+ # topic_adoc = File.open(topic.source_path,'r').read
455
487
 
456
488
  page_attrs = asciidoctor_page_attrs([
457
489
  "imagesdir=#{File.join(topic.parent.source_path,'images')}",
@@ -459,61 +491,71 @@ module AsciiBinder
459
491
  "product-title=#{branch_config.distro_name}",
460
492
  "product-version=#{branch_config.name}",
461
493
  "product-author=#{branch_config.distro_author}",
462
- "repo_path=#{topic.repo_path}"
494
+ "repo_path=#{topic.repo_path}",
495
+ "allow-uri-read="
463
496
  ])
464
497
 
465
- doc = without_warnings { Asciidoctor.load topic_adoc, :header_footer => false, :safe => :unsafe, :attributes => page_attrs }
466
- article_title = doc.doctitle || topic.name
467
-
468
- topic_html = doc.render
469
-
470
- # This is logic bridges newer arbitrary-depth-tolerant code to
471
- # older depth-limited code. Truly removing depth limitations will
472
- # require changes to page templates in user docs repos.
473
- breadcrumb = topic.breadcrumb
474
- group_title = breadcrumb[0][:name]
475
- group_id = breadcrumb[0][:id]
476
- topic_title = breadcrumb[-1][:name]
477
- topic_id = breadcrumb[-1][:id]
478
- subgroup_title = nil
479
- subgroup_id = nil
480
- if breadcrumb.length == 3
481
- subgroup_title = breadcrumb[1][:name]
482
- subgroup_id = breadcrumb[1][:id]
483
- end
484
- dir_depth = '../' * topic.breadcrumb[-1][:id].split('::').length
485
- dir_depth = '' if dir_depth.nil?
498
+ File.open topic.source_path, 'r' do |topic_file|
499
+
500
+ doc = without_warnings { Asciidoctor.load topic_file, :header_footer => false, :safe => :unsafe, :attributes => page_attrs, :base_dir => "." }
501
+ article_title = doc.doctitle || topic.name
502
+
503
+ topic_html = doc.render
504
+
505
+ # This is logic bridges newer arbitrary-depth-tolerant code to
506
+ # older depth-limited code. Truly removing depth limitations will
507
+ # require changes to page templates in user docs repos.
508
+ breadcrumb = topic.breadcrumb
509
+ group_title = breadcrumb[0][:name]
510
+ group_id = breadcrumb[0][:id]
511
+ topic_title = breadcrumb[-1][:name]
512
+ topic_id = breadcrumb[-1][:id]
513
+ subgroup_title = nil
514
+ subgroup_id = nil
515
+ if breadcrumb.length == 3
516
+ subgroup_title = breadcrumb[1][:name]
517
+ subgroup_id = breadcrumb[1][:id]
518
+ end
519
+ dir_depth = '../' * topic.breadcrumb[-1][:id].split('::').length
520
+ dir_depth = '' if dir_depth.nil?
521
+
522
+ preview_path = topic.preview_path(distro.id,branch_config.dir)
523
+ topic_publish_url = topic.topic_publish_url(distro.site.url,branch_config.dir)
524
+
525
+ page_args = {
526
+ :distro_key => distro.id,
527
+ :distro => branch_config.distro_name,
528
+ :branch => branch_config.id,
529
+ :site_name => distro.site.name,
530
+ :site_url => distro.site.url,
531
+ :topic_url => preview_path,
532
+ :topic_publish_url => topic_publish_url,
533
+ :version => branch_config.name,
534
+ :group_title => group_title,
535
+ :subgroup_title => subgroup_title,
536
+ :topic_title => topic_title,
537
+ :article_title => article_title,
538
+ :content => topic_html,
539
+ :navigation => navigation,
540
+ :group_id => group_id,
541
+ :subgroup_id => subgroup_id,
542
+ :topic_id => topic_id,
543
+ :css_path => "#{dir_depth}#{branch_config.dir}/#{STYLESHEET_DIRNAME}/",
544
+ :javascripts_path => "#{dir_depth}#{branch_config.dir}/#{JAVASCRIPT_DIRNAME}/",
545
+ :images_path => "#{dir_depth}#{branch_config.dir}/#{IMAGE_DIRNAME}/",
546
+ :site_home_path => "#{dir_depth}index.html",
547
+ :template_path => template_dir,
548
+ :repo_path => topic.repo_path,
549
+ }
550
+ full_file_text = page(page_args)
551
+
552
+
553
+ File.open(preview_path, 'w') { |file| file.write(full_file_text) }
554
+
555
+
556
+ # File.write(preview_path,full_file_text)
486
557
 
487
- preview_path = topic.preview_path(distro.id,branch_config.dir)
488
- topic_publish_url = topic.topic_publish_url(distro.site.url,branch_config.dir)
489
-
490
- page_args = {
491
- :distro_key => distro.id,
492
- :distro => branch_config.distro_name,
493
- :branch => branch_config.id,
494
- :site_name => distro.site.name,
495
- :site_url => distro.site.url,
496
- :topic_url => preview_path,
497
- :topic_publish_url => topic_publish_url,
498
- :version => branch_config.name,
499
- :group_title => group_title,
500
- :subgroup_title => subgroup_title,
501
- :topic_title => topic_title,
502
- :article_title => article_title,
503
- :content => topic_html,
504
- :navigation => navigation,
505
- :group_id => group_id,
506
- :subgroup_id => subgroup_id,
507
- :topic_id => topic_id,
508
- :css_path => "#{dir_depth}#{branch_config.dir}/#{STYLESHEET_DIRNAME}/",
509
- :javascripts_path => "#{dir_depth}#{branch_config.dir}/#{JAVASCRIPT_DIRNAME}/",
510
- :images_path => "#{dir_depth}#{branch_config.dir}/#{IMAGE_DIRNAME}/",
511
- :site_home_path => "#{dir_depth}index.html",
512
- :template_path => template_dir,
513
- :repo_path => topic.repo_path,
514
- }
515
- full_file_text = page(page_args)
516
- File.write(preview_path,full_file_text)
558
+ end
517
559
  end
518
560
 
519
561
  # package_docs
@@ -4,6 +4,7 @@ require 'stringio'
4
4
  module AsciiBinder
5
5
  module Helpers
6
6
  BUILD_FILENAME = '_build_cfg.yml'
7
+ TOPIC_MAP_FOLDER = '_topic_maps'
7
8
  TOPIC_MAP_FILENAME = '_topic_map.yml'
8
9
  DISTRO_MAP_FILENAME = '_distro_map.yml'
9
10
  PREVIEW_DIRNAME = '_preview'
@@ -7,7 +7,7 @@ module AsciiBinder
7
7
  @name = distro.site.name
8
8
  @url = distro.site.url
9
9
  @distros = {}
10
- @branches = ['master']
10
+ @branches = ['main']
11
11
  add_distro(distro)
12
12
  end
13
13
 
@@ -10,12 +10,13 @@ module AsciiBinder
10
10
  attr_reader :list
11
11
 
12
12
  def initialize(topic_file,distro_keys)
13
- @topic_yaml = YAML.load_stream(open(File.join(docs_root_dir,topic_file)))
13
+ @topic_yaml = YAML.load_stream(open(topic_file))
14
14
  @distro_keys = distro_keys
15
15
  @list = []
16
16
  @topic_yaml.each do |topic_entity|
17
17
  @list << AsciiBinder::TopicEntity.new(topic_entity,distro_keys)
18
18
  end
19
+
19
20
  end
20
21
 
21
22
  def filepaths
@@ -1,3 +1,3 @@
1
1
  module AsciiBinder
2
- VERSION = "0.2.0"
2
+ VERSION = "1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ascii_binder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: '1.0'
5
5
  platform: ruby
6
6
  authors:
7
7
  - N. Harrison Ripps
@@ -9,10 +9,10 @@ authors:
9
9
  - Carlos Munoz
10
10
  - Brian Exelbierd
11
11
  - Vikram Goyal
12
- autorequire:
12
+ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2020-06-14 00:00:00.000000000 Z
15
+ date: 2021-11-23 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: bundler
@@ -351,7 +351,7 @@ homepage: https://github.com/redhataccess/ascii_binder
351
351
  licenses:
352
352
  - MIT
353
353
  metadata: {}
354
- post_install_message:
354
+ post_install_message:
355
355
  rdoc_options: []
356
356
  require_paths:
357
357
  - lib
@@ -366,8 +366,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
366
366
  - !ruby/object:Gem::Version
367
367
  version: '0'
368
368
  requirements: []
369
- rubygems_version: 3.0.3
370
- signing_key:
369
+ rubygems_version: 3.2.3
370
+ signing_key:
371
371
  specification_version: 4
372
372
  summary: AsciiBinder is an AsciiDoc-based system for authoring and publishing closely
373
373
  related documentation sets from a single source.