bridgetown-core 0.19.3 → 0.21.0.beta4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/bridgetown-core.gemspec +1 -2
  3. data/lib/bridgetown-core.rb +37 -29
  4. data/lib/bridgetown-core/cleaner.rb +9 -3
  5. data/lib/bridgetown-core/collection.rb +177 -78
  6. data/lib/bridgetown-core/commands/base.rb +9 -0
  7. data/lib/bridgetown-core/commands/build.rb +0 -11
  8. data/lib/bridgetown-core/commands/concerns/git_helpers.rb +20 -0
  9. data/lib/bridgetown-core/commands/configure.rb +8 -3
  10. data/lib/bridgetown-core/commands/console.rb +4 -0
  11. data/lib/bridgetown-core/commands/doctor.rb +1 -19
  12. data/lib/bridgetown-core/commands/new.rb +6 -6
  13. data/lib/bridgetown-core/commands/plugins.rb +14 -13
  14. data/lib/bridgetown-core/commands/serve.rb +0 -14
  15. data/lib/bridgetown-core/commands/webpack.rb +75 -0
  16. data/lib/bridgetown-core/commands/webpack/enable-postcss.rb +12 -0
  17. data/lib/bridgetown-core/commands/webpack/setup.rb +4 -0
  18. data/lib/bridgetown-core/commands/webpack/update.rb +3 -0
  19. data/lib/bridgetown-core/commands/webpack/webpack.config.js +18 -0
  20. data/lib/{site_template/webpack.config.js.erb → bridgetown-core/commands/webpack/webpack.defaults.js.erb} +32 -16
  21. data/lib/bridgetown-core/component.rb +183 -0
  22. data/lib/bridgetown-core/concerns/data_accessible.rb +1 -0
  23. data/lib/bridgetown-core/concerns/front_matter_importer.rb +52 -0
  24. data/lib/bridgetown-core/concerns/layout_placeable.rb +1 -1
  25. data/lib/bridgetown-core/concerns/site/configurable.rb +10 -10
  26. data/lib/bridgetown-core/concerns/site/content.rb +56 -15
  27. data/lib/bridgetown-core/concerns/site/localizable.rb +3 -5
  28. data/lib/bridgetown-core/concerns/site/processable.rb +6 -4
  29. data/lib/bridgetown-core/concerns/site/renderable.rb +26 -0
  30. data/lib/bridgetown-core/concerns/site/writable.rb +12 -2
  31. data/lib/bridgetown-core/concerns/validatable.rb +2 -5
  32. data/lib/bridgetown-core/configuration.rb +61 -33
  33. data/lib/bridgetown-core/configurations/bt-postcss.rb +6 -6
  34. data/lib/bridgetown-core/configurations/netlify.rb +1 -0
  35. data/lib/bridgetown-core/configurations/tailwindcss.rb +6 -6
  36. data/lib/bridgetown-core/converter.rb +23 -0
  37. data/lib/bridgetown-core/converters/erb_templates.rb +51 -35
  38. data/lib/bridgetown-core/converters/identity.rb +0 -9
  39. data/lib/bridgetown-core/converters/liquid_templates.rb +1 -1
  40. data/lib/bridgetown-core/converters/markdown.rb +14 -4
  41. data/lib/bridgetown-core/converters/markdown/kramdown_parser.rb +5 -38
  42. data/lib/bridgetown-core/converters/ruby_templates.rb +17 -0
  43. data/lib/bridgetown-core/converters/smartypants.rb +3 -1
  44. data/lib/bridgetown-core/core_ext/psych.rb +19 -0
  45. data/lib/bridgetown-core/current.rb +10 -0
  46. data/lib/bridgetown-core/document.rb +9 -16
  47. data/lib/bridgetown-core/drops/collection_drop.rb +1 -1
  48. data/lib/bridgetown-core/drops/page_drop.rb +4 -0
  49. data/lib/bridgetown-core/drops/relations_drop.rb +23 -0
  50. data/lib/bridgetown-core/drops/resource_drop.rb +83 -0
  51. data/lib/bridgetown-core/drops/site_drop.rb +33 -8
  52. data/lib/bridgetown-core/drops/unified_payload_drop.rb +5 -0
  53. data/lib/bridgetown-core/entry_filter.rb +17 -28
  54. data/lib/bridgetown-core/errors.rb +0 -2
  55. data/lib/bridgetown-core/filters.rb +3 -26
  56. data/lib/bridgetown-core/filters/from_liquid.rb +23 -0
  57. data/lib/bridgetown-core/filters/url_filters.rb +12 -0
  58. data/lib/bridgetown-core/frontmatter_defaults.rb +1 -1
  59. data/lib/bridgetown-core/generators/prototype_generator.rb +59 -20
  60. data/lib/bridgetown-core/helpers.rb +48 -9
  61. data/lib/bridgetown-core/layout.rb +53 -21
  62. data/lib/bridgetown-core/liquid_renderer/file.rb +1 -0
  63. data/lib/bridgetown-core/liquid_renderer/table.rb +1 -0
  64. data/lib/bridgetown-core/model/base.rb +138 -0
  65. data/lib/bridgetown-core/model/builder_origin.rb +40 -0
  66. data/lib/bridgetown-core/model/origin.rb +38 -0
  67. data/lib/bridgetown-core/model/repo_origin.rb +126 -0
  68. data/lib/bridgetown-core/page.rb +11 -2
  69. data/lib/bridgetown-core/plugin_manager.rb +1 -3
  70. data/lib/bridgetown-core/publisher.rb +8 -2
  71. data/lib/bridgetown-core/reader.rb +37 -22
  72. data/lib/bridgetown-core/readers/data_reader.rb +5 -5
  73. data/lib/bridgetown-core/readers/defaults_reader.rb +1 -1
  74. data/lib/bridgetown-core/readers/layout_reader.rb +1 -1
  75. data/lib/bridgetown-core/readers/page_reader.rb +1 -0
  76. data/lib/bridgetown-core/readers/post_reader.rb +5 -4
  77. data/lib/bridgetown-core/regenerator.rb +9 -2
  78. data/lib/bridgetown-core/related_posts.rb +9 -6
  79. data/lib/bridgetown-core/renderer.rb +6 -13
  80. data/lib/bridgetown-core/resource/base.rb +329 -0
  81. data/lib/bridgetown-core/resource/destination.rb +49 -0
  82. data/lib/bridgetown-core/resource/permalink_processor.rb +179 -0
  83. data/lib/bridgetown-core/resource/relations.rb +132 -0
  84. data/lib/bridgetown-core/resource/taxonomy_term.rb +34 -0
  85. data/lib/bridgetown-core/resource/taxonomy_type.rb +56 -0
  86. data/lib/bridgetown-core/resource/transformer.rb +177 -0
  87. data/lib/bridgetown-core/ruby_template_view.rb +11 -11
  88. data/lib/bridgetown-core/site.rb +13 -6
  89. data/lib/bridgetown-core/static_file.rb +33 -10
  90. data/lib/bridgetown-core/tags/highlight.rb +2 -15
  91. data/lib/bridgetown-core/tags/include.rb +1 -1
  92. data/lib/bridgetown-core/tags/post_url.rb +2 -2
  93. data/lib/bridgetown-core/url.rb +1 -0
  94. data/lib/bridgetown-core/utils.rb +49 -43
  95. data/lib/bridgetown-core/utils/require_gems.rb +60 -0
  96. data/lib/bridgetown-core/utils/ruby_exec.rb +6 -9
  97. data/lib/bridgetown-core/utils/ruby_front_matter.rb +39 -0
  98. data/lib/bridgetown-core/version.rb +2 -2
  99. data/lib/bridgetown-core/watcher.rb +2 -1
  100. data/lib/bridgetown-core/yaml_parser.rb +22 -0
  101. data/lib/site_template/config/.keep +0 -0
  102. data/lib/site_template/package.json.erb +4 -4
  103. data/lib/site_template/plugins/site_builder.rb +1 -1
  104. data/lib/site_template/src/_posts/0000-00-00-welcome-to-bridgetown.md.erb +1 -1
  105. metadata +46 -41
  106. data/lib/bridgetown-core/external.rb +0 -58
  107. data/lib/bridgetown-core/page_without_a_file.rb +0 -17
  108. data/lib/bridgetown-core/path_manager.rb +0 -31
  109. data/lib/bridgetown-core/readers/collection_reader.rb +0 -23
  110. data/lib/bridgetown-core/readers/static_file_reader.rb +0 -25
  111. data/lib/bridgetown-core/utils/exec.rb +0 -26
  112. data/lib/bridgetown-core/utils/internet.rb +0 -37
  113. data/lib/bridgetown-core/utils/platforms.rb +0 -80
  114. data/lib/bridgetown-core/utils/thread_event.rb +0 -31
  115. data/lib/bridgetown-core/utils/win_tz.rb +0 -75
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bridgetown
4
+ module Utils
5
+ module RubyFrontMatterDSL
6
+ def front_matter(&block)
7
+ RubyFrontMatter.new.tap { |fm| fm.instance_exec(&block) }
8
+ end
9
+ end
10
+
11
+ class RubyFrontMatter
12
+ def initialize
13
+ @data = {}
14
+ end
15
+
16
+ def method_missing(key, value) # rubocop:disable Style/MissingRespondToMissing
17
+ return super if respond_to?(key)
18
+
19
+ set(key, value)
20
+ end
21
+
22
+ def each(&block)
23
+ @data.each(&block)
24
+ end
25
+
26
+ def get(key)
27
+ @data[key]
28
+ end
29
+
30
+ def set(key, value)
31
+ @data[key] = value
32
+ end
33
+
34
+ def to_h
35
+ @data
36
+ end
37
+ end
38
+ end
39
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bridgetown
4
- VERSION = "0.19.3"
5
- CODE_NAME = "Arbor Lodge"
4
+ VERSION = "0.21.0.beta4"
5
+ CODE_NAME = "Broughton Beach"
6
6
  end
@@ -127,6 +127,7 @@ module Bridgetown
127
127
 
128
128
  def process(site, time, options)
129
129
  begin
130
+ I18n.reload! # make sure any locale files get read again
130
131
  Bridgetown::Hooks.trigger :site, :pre_reload, site
131
132
  Bridgetown::Hooks.clear_reloadable_hooks
132
133
  site.plugin_manager.reload_plugin_files
@@ -140,7 +141,7 @@ module Bridgetown
140
141
  if options[:trace]
141
142
  Bridgetown.logger.info e.backtrace.join("\n")
142
143
  else
143
- Bridgetown.logger.warn "Error:", "Use the --trace option for more information."
144
+ Bridgetown.logger.warn "Backtrace:", "Use the --trace option for more information."
144
145
  end
145
146
  end
146
147
  Bridgetown.logger.info ""
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bridgetown
4
+ class YAMLParser
5
+ PERMITTED_CLASSES = [Date, Time, Rb].freeze
6
+
7
+ class << self
8
+ def load_file(filename, **kwargs)
9
+ kwargs = { permitted_classes: PERMITTED_CLASSES }.merge(kwargs)
10
+ YAML.safe_load_file(filename, **kwargs)
11
+ end
12
+
13
+ def load(yaml)
14
+ if RUBY_VERSION.start_with?("2.5")
15
+ YAML.safe_load yaml, PERMITTED_CLASSES
16
+ else
17
+ YAML.safe_load yaml, permitted_classes: PERMITTED_CLASSES
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
File without changes
@@ -25,13 +25,13 @@
25
25
  "file-loader": "^6.2.0",
26
26
  "mini-css-extract-plugin": "^1.3.1",
27
27
  <% if options["use-postcss"] %>
28
- "postcss": "^8.1.9",
28
+ "postcss": "^8.3.0",
29
29
  "postcss-flexbugs-fixes": "^4.1.0",
30
- "postcss-loader": "^4.1.0",
30
+ "postcss-loader": "^4.3.0",
31
31
  "postcss-preset-env": "^6.7.0",
32
32
  <% else %>
33
- "node-sass": "^4.13.1",
34
- "sass-loader": "^8.0.2",
33
+ "sass": "^1.32.8",
34
+ "sass-loader": "^8.0.2",
35
35
  <% end %>
36
36
  "webpack": "^4.44.2",
37
37
  "webpack-cli": "^3.3.11",
@@ -1,4 +1,4 @@
1
1
  class SiteBuilder < Bridgetown::Builder
2
- # write builders which subclass SiteBuilder in plugins/builder
2
+ # write builders which subclass SiteBuilder in plugins/builders
3
3
  end
4
4
 
@@ -21,6 +21,6 @@ def print_hi(name)
21
21
  end
22
22
  print_hi('Tom')
23
23
  #=> prints 'Hi, Tom' to STDOUT.
24
- ````
24
+ ```
25
25
 
26
26
  Check out the [Bridgetown docs](https://bridgetownrb.com/docs/) for more info on how to get the most out of Bridgetown. File all bugs/feature requests at [Bridgetown’s GitHub repo](https://github.com/bridgetownrb/bridgetown). If you have questions, you can ask them on [Bridgetown Discussions on GitHub](https://github.com/bridgetownrb/bridgetown/discussions).
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bridgetown-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.3
4
+ version: 0.21.0.beta4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bridgetown Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-11 00:00:00.000000000 Z
11
+ date: 2021-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activemodel
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '6.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '6.0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: activesupport
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -206,20 +220,6 @@ dependencies:
206
220
  - - "~>"
207
221
  - !ruby/object:Gem::Version
208
222
  version: '3.0'
209
- - !ruby/object:Gem::Dependency
210
- name: pathutil
211
- requirement: !ruby/object:Gem::Requirement
212
- requirements:
213
- - - "~>"
214
- - !ruby/object:Gem::Version
215
- version: '0.9'
216
- type: :runtime
217
- prerelease: false
218
- version_requirements: !ruby/object:Gem::Requirement
219
- requirements:
220
- - - "~>"
221
- - !ruby/object:Gem::Version
222
- version: '0.9'
223
223
  - !ruby/object:Gem::Dependency
224
224
  name: rouge
225
225
  requirement: !ruby/object:Gem::Requirement
@@ -234,20 +234,6 @@ dependencies:
234
234
  - - "~>"
235
235
  - !ruby/object:Gem::Version
236
236
  version: '3.0'
237
- - !ruby/object:Gem::Dependency
238
- name: safe_yaml
239
- requirement: !ruby/object:Gem::Requirement
240
- requirements:
241
- - - "~>"
242
- - !ruby/object:Gem::Version
243
- version: '1.0'
244
- type: :runtime
245
- prerelease: false
246
- version_requirements: !ruby/object:Gem::Requirement
247
- requirements:
248
- - - "~>"
249
- - !ruby/object:Gem::Version
250
- version: '1.0'
251
237
  - !ruby/object:Gem::Dependency
252
238
  name: terminal-table
253
239
  requirement: !ruby/object:Gem::Requirement
@@ -327,6 +313,7 @@ files:
327
313
  - lib/bridgetown-core/commands/concerns/actions.rb
328
314
  - lib/bridgetown-core/commands/concerns/build_options.rb
329
315
  - lib/bridgetown-core/commands/concerns/configuration_overridable.rb
316
+ - lib/bridgetown-core/commands/concerns/git_helpers.rb
330
317
  - lib/bridgetown-core/commands/concerns/summarizable.rb
331
318
  - lib/bridgetown-core/commands/configure.rb
332
319
  - lib/bridgetown-core/commands/console.rb
@@ -336,7 +323,15 @@ files:
336
323
  - lib/bridgetown-core/commands/registrations.rb
337
324
  - lib/bridgetown-core/commands/serve.rb
338
325
  - lib/bridgetown-core/commands/serve/servlet.rb
326
+ - lib/bridgetown-core/commands/webpack.rb
327
+ - lib/bridgetown-core/commands/webpack/enable-postcss.rb
328
+ - lib/bridgetown-core/commands/webpack/setup.rb
329
+ - lib/bridgetown-core/commands/webpack/update.rb
330
+ - lib/bridgetown-core/commands/webpack/webpack.config.js
331
+ - lib/bridgetown-core/commands/webpack/webpack.defaults.js.erb
332
+ - lib/bridgetown-core/component.rb
339
333
  - lib/bridgetown-core/concerns/data_accessible.rb
334
+ - lib/bridgetown-core/concerns/front_matter_importer.rb
340
335
  - lib/bridgetown-core/concerns/layout_placeable.rb
341
336
  - lib/bridgetown-core/concerns/liquid_renderable.rb
342
337
  - lib/bridgetown-core/concerns/publishable.rb
@@ -369,7 +364,10 @@ files:
369
364
  - lib/bridgetown-core/converters/liquid_templates.rb
370
365
  - lib/bridgetown-core/converters/markdown.rb
371
366
  - lib/bridgetown-core/converters/markdown/kramdown_parser.rb
367
+ - lib/bridgetown-core/converters/ruby_templates.rb
372
368
  - lib/bridgetown-core/converters/smartypants.rb
369
+ - lib/bridgetown-core/core_ext/psych.rb
370
+ - lib/bridgetown-core/current.rb
373
371
  - lib/bridgetown-core/deprecator.rb
374
372
  - lib/bridgetown-core/document.rb
375
373
  - lib/bridgetown-core/drops/bridgetown_drop.rb
@@ -378,6 +376,8 @@ files:
378
376
  - lib/bridgetown-core/drops/drop.rb
379
377
  - lib/bridgetown-core/drops/excerpt_drop.rb
380
378
  - lib/bridgetown-core/drops/page_drop.rb
379
+ - lib/bridgetown-core/drops/relations_drop.rb
380
+ - lib/bridgetown-core/drops/resource_drop.rb
381
381
  - lib/bridgetown-core/drops/site_drop.rb
382
382
  - lib/bridgetown-core/drops/static_file_drop.rb
383
383
  - lib/bridgetown-core/drops/unified_payload_drop.rb
@@ -385,10 +385,10 @@ files:
385
385
  - lib/bridgetown-core/entry_filter.rb
386
386
  - lib/bridgetown-core/errors.rb
387
387
  - lib/bridgetown-core/excerpt.rb
388
- - lib/bridgetown-core/external.rb
389
388
  - lib/bridgetown-core/filters.rb
390
389
  - lib/bridgetown-core/filters/condition_helpers.rb
391
390
  - lib/bridgetown-core/filters/date_filters.rb
391
+ - lib/bridgetown-core/filters/from_liquid.rb
392
392
  - lib/bridgetown-core/filters/grouping_filters.rb
393
393
  - lib/bridgetown-core/filters/url_filters.rb
394
394
  - lib/bridgetown-core/frontmatter_defaults.rb
@@ -405,24 +405,31 @@ files:
405
405
  - lib/bridgetown-core/log_adapter.rb
406
406
  - lib/bridgetown-core/log_writer.rb
407
407
  - lib/bridgetown-core/mime.types
408
+ - lib/bridgetown-core/model/base.rb
409
+ - lib/bridgetown-core/model/builder_origin.rb
410
+ - lib/bridgetown-core/model/origin.rb
411
+ - lib/bridgetown-core/model/repo_origin.rb
408
412
  - lib/bridgetown-core/page.rb
409
- - lib/bridgetown-core/page_without_a_file.rb
410
- - lib/bridgetown-core/path_manager.rb
411
413
  - lib/bridgetown-core/plugin.rb
412
414
  - lib/bridgetown-core/plugin_manager.rb
413
415
  - lib/bridgetown-core/publisher.rb
414
416
  - lib/bridgetown-core/reader.rb
415
- - lib/bridgetown-core/readers/collection_reader.rb
416
417
  - lib/bridgetown-core/readers/data_reader.rb
417
418
  - lib/bridgetown-core/readers/defaults_reader.rb
418
419
  - lib/bridgetown-core/readers/layout_reader.rb
419
420
  - lib/bridgetown-core/readers/page_reader.rb
420
421
  - lib/bridgetown-core/readers/plugin_content_reader.rb
421
422
  - lib/bridgetown-core/readers/post_reader.rb
422
- - lib/bridgetown-core/readers/static_file_reader.rb
423
423
  - lib/bridgetown-core/regenerator.rb
424
424
  - lib/bridgetown-core/related_posts.rb
425
425
  - lib/bridgetown-core/renderer.rb
426
+ - lib/bridgetown-core/resource/base.rb
427
+ - lib/bridgetown-core/resource/destination.rb
428
+ - lib/bridgetown-core/resource/permalink_processor.rb
429
+ - lib/bridgetown-core/resource/relations.rb
430
+ - lib/bridgetown-core/resource/taxonomy_term.rb
431
+ - lib/bridgetown-core/resource/taxonomy_type.rb
432
+ - lib/bridgetown-core/resource/transformer.rb
426
433
  - lib/bridgetown-core/ruby_template_view.rb
427
434
  - lib/bridgetown-core/site.rb
428
435
  - lib/bridgetown-core/static_file.rb
@@ -439,18 +446,17 @@ files:
439
446
  - lib/bridgetown-core/url.rb
440
447
  - lib/bridgetown-core/utils.rb
441
448
  - lib/bridgetown-core/utils/ansi.rb
442
- - lib/bridgetown-core/utils/exec.rb
443
- - lib/bridgetown-core/utils/internet.rb
444
- - lib/bridgetown-core/utils/platforms.rb
449
+ - lib/bridgetown-core/utils/require_gems.rb
445
450
  - lib/bridgetown-core/utils/ruby_exec.rb
446
- - lib/bridgetown-core/utils/thread_event.rb
447
- - lib/bridgetown-core/utils/win_tz.rb
451
+ - lib/bridgetown-core/utils/ruby_front_matter.rb
448
452
  - lib/bridgetown-core/version.rb
449
453
  - lib/bridgetown-core/watcher.rb
454
+ - lib/bridgetown-core/yaml_parser.rb
450
455
  - lib/site_template/.gitignore
451
456
  - lib/site_template/Gemfile.erb
452
457
  - lib/site_template/README.md
453
458
  - lib/site_template/bridgetown.config.yml
459
+ - lib/site_template/config/.keep
454
460
  - lib/site_template/frontend/javascript/index.js.erb
455
461
  - lib/site_template/frontend/styles/index.css
456
462
  - lib/site_template/frontend/styles/index.scss
@@ -475,7 +481,6 @@ files:
475
481
  - lib/site_template/src/posts.md
476
482
  - lib/site_template/start.js
477
483
  - lib/site_template/sync.js
478
- - lib/site_template/webpack.config.js.erb
479
484
  homepage: https://www.bridgetownrb.com
480
485
  licenses:
481
486
  - MIT
@@ -1,58 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Bridgetown
4
- module External
5
- class << self
6
- #
7
- # Require a gem or file if it's present, otherwise silently fail.
8
- #
9
- # names - a string gem name or array of gem names
10
- #
11
- def require_if_present(names)
12
- Array(names).each do |name|
13
- require name
14
- rescue LoadError
15
- Bridgetown.logger.debug "Couldn't load #{name}. Skipping."
16
- yield(name, version_constraint(name)) if block_given?
17
- false
18
- end
19
- end
20
-
21
- #
22
- # The version constraint required to activate a given gem.
23
- #
24
- # Returns a String version constraint in a parseable form for
25
- # RubyGems.
26
- def version_constraint
27
- "> 0"
28
- end
29
-
30
- #
31
- # Require a gem or gems. If it's not present, show a very nice error
32
- # message that explains everything and is much more helpful than the
33
- # normal LoadError.
34
- #
35
- # names - a string gem name or array of gem names
36
- #
37
- def require_with_graceful_fail(names)
38
- Array(names).each do |name|
39
- Bridgetown.logger.debug "Requiring:", name.to_s
40
- require name
41
- rescue LoadError => e
42
- Bridgetown.logger.error "Dependency Error:", <<~MSG
43
- Yikes! It looks like you don't have #{name} or one of its dependencies installed.
44
- In order to use Bridgetown as currently configured, you'll need to install this gem.
45
-
46
- If you've run Bridgetown with `bundle exec`, ensure that you have included the #{name}
47
- gem in your Gemfile as well.
48
-
49
- The full error message from Ruby is: '#{e.message}'
50
-
51
- If you run into trouble, you can find helpful resources at https://www.bridgetownrb.com/docs/community/
52
- MSG
53
- raise Bridgetown::Errors::MissingDependencyException, name
54
- end
55
- end
56
- end
57
- end
58
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Bridgetown
4
- # A Bridgetown::Page subclass to handle processing files without reading it to
5
- # determine the page-data and page-content based on Front Matter delimiters.
6
- #
7
- # The class instance is basically just a bare-bones entity with just
8
- # attributes "dir", "name", "path", "url" defined on it.
9
- class PageWithoutAFile < Page
10
- Bridgetown.logger.warn "NOTICE: the PageWithoutAFile class is deprecated and" \
11
- " will be removed in Bridgetown 0.20."
12
-
13
- def read_yaml(*)
14
- @data ||= {}
15
- end
16
- end
17
- end
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Bridgetown
4
- # A singleton class that caches frozen instances of path strings returned from its methods.
5
- #
6
- # NOTE:
7
- # This class exists because `File.join` allocates an Array and returns a new String on every
8
- # call using **the same arguments**. Caching the result means reduced memory usage.
9
- # However, the caches are never flushed so that they can be used even when a site is
10
- # regenerating. The results are frozen to deter mutation of the cached string.
11
- #
12
- # Therefore, employ this class only for situations where caching the result is necessary
13
- # for performance reasons.
14
- #
15
- class PathManager
16
- # This class cannot be initialized from outside
17
- private_class_method :new
18
-
19
- # Wraps `File.join` to cache the frozen result.
20
- # Reassigns `nil`, empty strings and empty arrays to a frozen empty string beforehand.
21
- #
22
- # Returns a frozen string.
23
- def self.join(base, item)
24
- base = "" if base.nil? || base.empty?
25
- item = "" if item.nil? || item.empty?
26
- @join ||= {}
27
- @join[base] ||= {}
28
- @join[base][item] ||= File.join(base, item).freeze
29
- end
30
- end
31
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Bridgetown
4
- class CollectionReader
5
- SPECIAL_COLLECTIONS = %w(posts data).freeze
6
-
7
- attr_reader :site, :content
8
-
9
- def initialize(site)
10
- @site = site
11
- @content = {}
12
- end
13
-
14
- # Read in all collections specified in the configuration
15
- #
16
- # Returns nothing.
17
- def read
18
- site.collections.each_value do |collection|
19
- collection.read unless SPECIAL_COLLECTIONS.include?(collection.label)
20
- end
21
- end
22
- end
23
- end