bridgetown-core 0.21.1 → 1.0.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/bin/bridgetown +2 -0
  3. data/bridgetown-core.gemspec +3 -0
  4. data/lib/bridgetown-core/cleaner.rb +0 -8
  5. data/lib/bridgetown-core/collection.rb +59 -81
  6. data/lib/bridgetown-core/commands/base.rb +60 -1
  7. data/lib/bridgetown-core/commands/build.rb +26 -6
  8. data/lib/bridgetown-core/commands/concerns/build_options.rb +3 -10
  9. data/lib/bridgetown-core/commands/concerns/configuration_overridable.rb +3 -1
  10. data/lib/bridgetown-core/commands/doctor.rb +3 -3
  11. data/lib/bridgetown-core/commands/new.rb +9 -3
  12. data/lib/bridgetown-core/commands/plugins.rb +1 -2
  13. data/lib/bridgetown-core/commands/serve.rb +14 -12
  14. data/lib/bridgetown-core/commands/start.rb +106 -0
  15. data/lib/bridgetown-core/commands/webpack/webpack.defaults.js.erb +2 -2
  16. data/lib/bridgetown-core/concerns/site/configurable.rb +0 -12
  17. data/lib/bridgetown-core/concerns/site/content.rb +16 -117
  18. data/lib/bridgetown-core/concerns/site/localizable.rb +3 -1
  19. data/lib/bridgetown-core/concerns/site/processable.rb +9 -20
  20. data/lib/bridgetown-core/concerns/site/renderable.rb +19 -30
  21. data/lib/bridgetown-core/concerns/site/ssr.rb +53 -0
  22. data/lib/bridgetown-core/concerns/site/writable.rb +5 -8
  23. data/lib/bridgetown-core/configuration.rb +18 -47
  24. data/lib/bridgetown-core/configurations/minitesting.rb +1 -1
  25. data/lib/bridgetown-core/configurations/turbo.rb +1 -1
  26. data/lib/bridgetown-core/converters/erb_templates.rb +2 -1
  27. data/lib/bridgetown-core/converters/liquid_templates.rb +3 -2
  28. data/lib/bridgetown-core/current.rb +4 -0
  29. data/lib/bridgetown-core/drops/collection_drop.rb +1 -1
  30. data/lib/bridgetown-core/drops/generated_page_drop.rb +23 -0
  31. data/lib/bridgetown-core/drops/resource_drop.rb +3 -3
  32. data/lib/bridgetown-core/drops/site_drop.rb +3 -47
  33. data/lib/bridgetown-core/errors.rb +0 -2
  34. data/lib/bridgetown-core/filters/url_filters.rb +3 -1
  35. data/lib/bridgetown-core/frontmatter_defaults.rb +52 -88
  36. data/lib/bridgetown-core/{page.rb → generated_page.rb} +34 -58
  37. data/lib/bridgetown-core/generators/prototype_generator.rb +13 -24
  38. data/lib/bridgetown-core/helpers.rb +7 -2
  39. data/lib/bridgetown-core/layout.rb +15 -4
  40. data/lib/bridgetown-core/log_writer.rb +6 -0
  41. data/lib/bridgetown-core/model/base.rb +10 -2
  42. data/lib/bridgetown-core/model/builder_origin.rb +22 -10
  43. data/lib/bridgetown-core/model/origin.rb +3 -0
  44. data/lib/bridgetown-core/model/plugin_origin.rb +34 -0
  45. data/lib/bridgetown-core/model/repo_origin.rb +1 -1
  46. data/lib/bridgetown-core/plugin_manager.rb +8 -8
  47. data/lib/bridgetown-core/rack/boot.rb +47 -0
  48. data/lib/bridgetown-core/rack/logger.rb +22 -0
  49. data/lib/bridgetown-core/rack/roda.rb +66 -0
  50. data/lib/bridgetown-core/rack/routes.rb +92 -0
  51. data/lib/bridgetown-core/rack/static_indexes.rb +30 -0
  52. data/lib/bridgetown-core/reader.rb +20 -47
  53. data/lib/bridgetown-core/readers/plugin_content_reader.rb +8 -7
  54. data/lib/bridgetown-core/renderer.rb +1 -11
  55. data/lib/bridgetown-core/resource/base.rb +50 -26
  56. data/lib/bridgetown-core/resource/permalink_processor.rb +20 -10
  57. data/lib/bridgetown-core/resource/relations.rb +2 -3
  58. data/lib/bridgetown-core/resource/transformer.rb +1 -1
  59. data/lib/bridgetown-core/ruby_template_view.rb +5 -5
  60. data/lib/bridgetown-core/site.rb +4 -8
  61. data/lib/bridgetown-core/static_file.rb +10 -15
  62. data/lib/bridgetown-core/tags/include.rb +0 -13
  63. data/lib/bridgetown-core/tags/link.rb +4 -0
  64. data/lib/bridgetown-core/tags/live_reload_dev_js.rb +13 -0
  65. data/lib/bridgetown-core/tags/post_url.rb +4 -9
  66. data/lib/bridgetown-core/tasks/bridgetown_tasks.rake +54 -0
  67. data/lib/bridgetown-core/url.rb +2 -1
  68. data/lib/bridgetown-core/utils/aux.rb +57 -0
  69. data/lib/bridgetown-core/utils/ruby_exec.rb +3 -45
  70. data/lib/bridgetown-core/utils/ruby_front_matter.rb +22 -7
  71. data/lib/bridgetown-core/utils.rb +53 -24
  72. data/lib/bridgetown-core/version.rb +2 -2
  73. data/lib/bridgetown-core/watcher.rb +2 -4
  74. data/lib/bridgetown-core.rb +14 -22
  75. data/lib/site_template/Gemfile.erb +6 -2
  76. data/lib/site_template/README.md +6 -6
  77. data/lib/site_template/Rakefile +49 -0
  78. data/lib/site_template/bridgetown.config.yml +2 -3
  79. data/lib/site_template/config/puma.rb +27 -0
  80. data/lib/site_template/config.ru +7 -0
  81. data/lib/site_template/frontend/javascript/index.js.erb +3 -3
  82. data/lib/site_template/package.json.erb +8 -13
  83. data/lib/site_template/server/roda_app.rb +22 -0
  84. data/lib/site_template/server/routes/hello.rb.sample +10 -0
  85. data/lib/site_template/src/_components/head.liquid +2 -1
  86. data/lib/site_template/src/about.md +0 -1
  87. data/lib/site_template/src/posts.md +2 -3
  88. metadata +62 -18
  89. data/lib/bridgetown-core/concerns/data_accessible.rb +0 -20
  90. data/lib/bridgetown-core/concerns/validatable.rb +0 -56
  91. data/lib/bridgetown-core/document.rb +0 -437
  92. data/lib/bridgetown-core/drops/document_drop.rb +0 -80
  93. data/lib/bridgetown-core/drops/excerpt_drop.rb +0 -19
  94. data/lib/bridgetown-core/drops/page_drop.rb +0 -18
  95. data/lib/bridgetown-core/excerpt.rb +0 -200
  96. data/lib/bridgetown-core/readers/data_reader.rb +0 -89
  97. data/lib/bridgetown-core/readers/page_reader.rb +0 -26
  98. data/lib/bridgetown-core/readers/post_reader.rb +0 -109
  99. data/lib/bridgetown-core/regenerator.rb +0 -202
  100. data/lib/bridgetown-core/related_posts.rb +0 -55
  101. data/lib/site_template/config/.keep +0 -0
  102. data/lib/site_template/start.js +0 -17
  103. data/lib/site_template/sync.js +0 -35
@@ -119,16 +119,12 @@ module Bridgetown
119
119
  end
120
120
 
121
121
  def render(context)
122
- site = context.registers[:site]
123
-
124
122
  file = render_variable(context) || @file
125
123
  validate_file_name(file)
126
124
 
127
125
  path = locate_include_file(context, file)
128
126
  return unless path
129
127
 
130
- add_include_to_dependency(site, path, context)
131
-
132
128
  partial = load_cached_partial(path, context)
133
129
 
134
130
  context.stack do
@@ -143,15 +139,6 @@ module Bridgetown
143
139
  end
144
140
  end
145
141
 
146
- def add_include_to_dependency(site, path, context)
147
- if context.registers[:page]&.key?("path")
148
- site.regenerator.add_dependency(
149
- site.in_source_dir(context.registers[:page]["path"]),
150
- path
151
- )
152
- end
153
- end
154
-
155
142
  def load_cached_partial(path, context)
156
143
  context.registers[:cached_partials] ||= {}
157
144
  cached_partial = context.registers[:cached_partials]
@@ -23,6 +23,10 @@ module Bridgetown
23
23
  relative_path = Liquid::Template.parse(@relative_path).render(context)
24
24
 
25
25
  site.each_site_file do |item|
26
+ # Resource engine:
27
+ if item.respond_to?(:relative_url) && item.relative_path.to_s == relative_path
28
+ return item.relative_url
29
+ end
26
30
  return relative_url(item) if item.relative_path == relative_path
27
31
  # This takes care of the case for static files that have a leading /
28
32
  return relative_url(item) if item.relative_path == "/#{relative_path}"
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bridgetown
4
+ module Tags
5
+ class LiveReloadJsTag < Liquid::Tag
6
+ def render(context)
7
+ Bridgetown::Utils.live_reload_js(context.registers[:site])
8
+ end
9
+ end
10
+ end
11
+ end
12
+
13
+ Liquid::Template.register_tag("live_reload_dev_js", Bridgetown::Tags::LiveReloadJsTag)
@@ -29,7 +29,7 @@ module Bridgetown
29
29
  end
30
30
 
31
31
  def ==(other)
32
- other.relative_path.match(@name_regex)
32
+ other.relative_path.to_s.match(@name_regex)
33
33
  end
34
34
 
35
35
  def deprecated_equality(other)
@@ -47,12 +47,7 @@ module Bridgetown
47
47
  #
48
48
  # Returns the post slug with the subdirectory (relative to _posts)
49
49
  def post_slug(other)
50
- path = other.basename.split("/")[0...-1].join("/")
51
- if path.nil? || path == ""
52
- other.data["slug"]
53
- else
54
- path + "/" + other.data["slug"]
55
- end
50
+ other.data.slug
56
51
  end
57
52
  end
58
53
 
@@ -77,14 +72,14 @@ module Bridgetown
77
72
  @context = context
78
73
  site = context.registers[:site]
79
74
 
80
- site.collections.posts.docs.each do |document|
75
+ site.collections.posts.resources.each do |document|
81
76
  return relative_url(document) if @post == document
82
77
  end
83
78
 
84
79
  # New matching method did not match, fall back to old method
85
80
  # with deprecation warning if this matches
86
81
 
87
- site.collections.posts.docs.each do |document|
82
+ site.collections.posts.resources.each do |document|
88
83
  next unless @post.deprecated_equality document
89
84
 
90
85
  Bridgetown::Deprecator.deprecation_message "A call to "\
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :frontend do
4
+ desc "Run frontend bundler independently"
5
+ task :watcher, :sidecar do |_task, args|
6
+ # sidecar is when the task is running alongside the start command
7
+ sidecar = args[:sidecar] == true
8
+ Bridgetown::Utils::Aux.group do
9
+ run_process "Frontend", :yellow, "bundle exec bridgetown frontend:dev"
10
+ end
11
+ if sidecar
12
+ sleep 4 # give Webpack time to boot before returning control to the start command
13
+ else
14
+ trap("INT") do
15
+ Bridgetown::Utils::Aux.kill_processes
16
+ sleep 0.5
17
+ exit(0)
18
+ end
19
+ loop { sleep 1000 }
20
+ end
21
+ end
22
+ end
23
+
24
+ desc "Prerequisite task which loads site and provides automation"
25
+ task :environment do
26
+ class HammerActions < Thor
27
+ include Thor::Actions
28
+ include Bridgetown::Commands::Actions
29
+
30
+ def self.source_root
31
+ Dir.pwd
32
+ end
33
+
34
+ def self.exit_on_failure?
35
+ true
36
+ end
37
+
38
+ private
39
+
40
+ def site
41
+ @site ||= Bridgetown::Site.new(Bridgetown.configuration)
42
+ end
43
+ end
44
+
45
+ define_singleton_method :automation do |*args, &block|
46
+ @hammer ||= HammerActions.new
47
+ @hammer.instance_exec(*args, &block)
48
+ end
49
+
50
+ define_singleton_method :site do
51
+ @hammer ||= HammerActions.new
52
+ @hammer.send(:site)
53
+ end
54
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Public: Methods that generate a URL for a resource such as a Post or a Page.
3
+ # Public: Methods that generate a URL for GeneratedPage.
4
4
  #
5
5
  # Examples
6
6
  #
@@ -10,6 +10,7 @@
10
10
  # }).to_s
11
11
  #
12
12
  module Bridgetown
13
+ # TODO: remove this class in favor of the new Resource permalink processor
13
14
  class URL
14
15
  # options - One of :permalink or :template must be supplied.
15
16
  # :template - The String used as template for URL generation,
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bridgetown
4
+ module Utils
5
+ module Aux
6
+ def self.with_color(name, message)
7
+ return message unless !name.nil? && Bridgetown::Utils::Ansi::COLORS[name.to_sym]
8
+
9
+ Bridgetown::Utils::Ansi.send(name, message)
10
+ end
11
+
12
+ def self.running_pids
13
+ @running_pids ||= []
14
+ end
15
+
16
+ def self.add_pid(pid)
17
+ running_pids << pid
18
+ end
19
+
20
+ def self.run_process(name, color, cmd)
21
+ Thread.new do
22
+ rd, wr = IO.pipe("BINARY")
23
+ pid = Process.spawn(cmd, out: wr, err: wr, pgroup: true)
24
+ @mutex.synchronize do
25
+ add_pid pid
26
+ end
27
+
28
+ loop do
29
+ line = rd.gets
30
+ line.to_s.lines.map(&:chomp).each do |message|
31
+ output = +""
32
+ output << with_color(color, "[#{name}] ") if color
33
+ output << message
34
+ @mutex.synchronize do
35
+ $stdout.puts output
36
+ $stdout.flush
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ def self.group(&block)
44
+ @mutex = Thread::Mutex.new
45
+ instance_exec(&block)
46
+ end
47
+
48
+ def self.kill_processes
49
+ Bridgetown.logger.info "Stopping auxiliary processes..."
50
+ running_pids.each do |pid|
51
+ Process.kill("SIGTERM", -Process.getpgid(pid))
52
+ rescue Errno::ESRCH, Errno::EPERM, Errno::ECHILD # rubocop:disable Lint/SuppressedException
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -3,10 +3,7 @@
3
3
  module Bridgetown
4
4
  module Utils
5
5
  module RubyExec
6
- extend self
7
-
8
- # TODO: Deprecate storing Ruby code in YAML, Rb, etc. and just use native Ruby Front Matter
9
- def search_data_for_ruby_code(convertible, renderer) # rubocop:todo Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
6
+ def self.search_data_for_ruby_code(convertible)
10
7
  return if convertible.data.empty?
11
8
 
12
9
  # Iterate using `keys` here so inline Ruby script can add new data keys
@@ -14,49 +11,10 @@ module Bridgetown
14
11
  data_keys = convertible.data.keys
15
12
  data_keys.each do |k|
16
13
  v = convertible.data[k]
17
- next unless v.is_a?(Rb) || v.is_a?(Hash) || v.is_a?(Proc)
18
-
19
- if v.is_a?(Proc)
20
- convertible.data[k] = convertible.instance_exec(&v)
21
- elsif v.is_a?(Hash)
22
- v.each do |nested_k, nested_v|
23
- next unless nested_v.is_a?(Rb)
24
-
25
- convertible.data[k][nested_k] = run(nested_v, convertible, renderer)
26
- end
27
- else
28
- convertible.data[k] = run(v, convertible, renderer)
29
- end
30
- end
31
- end
32
-
33
- # Sets up a new context in which to eval Ruby coming from front matter.
34
- #
35
- # ruby_code - a string of code
36
- # convertible - the Document/Page/Layout with the Ruby front matter
37
- # renderer - the Renderer instance that's processing the document (optional)
38
- #
39
- # Returns the transformed output of the code
40
- def run(ruby_code, convertible, renderer)
41
- return unless ruby_code.is_a?(Rb)
14
+ next unless v.is_a?(Proc)
42
15
 
43
- klass = Class.new
44
- obj = klass.new
45
-
46
- if convertible.is_a?(Layout)
47
- klass.attr_accessor :layout, :site, :data
48
- obj.layout = convertible
49
- else
50
- klass.attr_accessor :document, :page, :renderer, :site, :data
51
- obj.document = obj.page = convertible
52
- obj.renderer = renderer
16
+ convertible.data[k] = convertible.instance_exec(&v)
53
17
  end
54
- obj.site = convertible.site
55
- obj.data = convertible.data
56
-
57
- # This is where the magic happens! DON'T BE EVIL!!! ;-)
58
- output = obj.instance_eval(ruby_code)
59
- output.is_a?(Hash) ? output.with_dot_access : output
60
18
  end
61
19
  end
62
20
  end
@@ -3,20 +3,23 @@
3
3
  module Bridgetown
4
4
  module Utils
5
5
  module RubyFrontMatterDSL
6
- def front_matter(&block)
7
- RubyFrontMatter.new.tap { |fm| fm.instance_exec(&block) }
6
+ def front_matter(scope: nil, &block)
7
+ RubyFrontMatter.new(scope: scope).tap { |fm| fm.instance_exec(&block) }
8
8
  end
9
9
  end
10
10
 
11
11
  class RubyFrontMatter
12
- def initialize
12
+ def initialize(scope: nil)
13
13
  @data = {}
14
+ @scope = scope
14
15
  end
15
16
 
16
- def method_missing(key, value) # rubocop:disable Style/MissingRespondToMissing
17
- return super if respond_to?(key)
17
+ def method_missing(key, *value, &block) # rubocop:disable Metrics/CyclomaticComplexity, Style/MissingRespondToMissing
18
+ return super if respond_to?(key) || (value.length.zero? && block.nil? && !@data.key?(key))
18
19
 
19
- set(key, value)
20
+ return get(key) if value.length.zero? && block.nil? && @data.key?(key)
21
+
22
+ set(key, value[0], &block)
20
23
  end
21
24
 
22
25
  def each(&block)
@@ -27,7 +30,19 @@ module Bridgetown
27
30
  @data[key]
28
31
  end
29
32
 
30
- def set(key, value)
33
+ def set(key, value = nil, &block)
34
+ # Handle nested data within a block
35
+ if block
36
+ value = self.class.new(scope: @scope).tap do |fm|
37
+ fm.instance_exec(&block)
38
+ end.to_h
39
+ end
40
+
41
+ # Execute lambda value within the resolver
42
+ if @scope && value.is_a?(Hash) && value[:from].is_a?(Proc)
43
+ value = @scope.instance_exec(&value[:from])
44
+ end
45
+
31
46
  @data[key] = value
32
47
  end
33
48
 
@@ -1,11 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bridgetown
4
- module Utils
4
+ module Utils # rubocop:todo Metrics/ModuleLength
5
5
  extend self
6
6
  autoload :Ansi, "bridgetown-core/utils/ansi"
7
+ autoload :Aux, "bridgetown-core/utils/aux"
7
8
  autoload :RequireGems, "bridgetown-core/utils/require_gems"
8
9
  autoload :RubyExec, "bridgetown-core/utils/ruby_exec"
10
+ autoload :RubyFrontMatter, "bridgetown-core/utils/ruby_front_matter"
9
11
  autoload :RubyFrontMatterDSL, "bridgetown-core/utils/ruby_front_matter"
10
12
 
11
13
  # Constants for use in #slugify
@@ -354,28 +356,19 @@ module Bridgetown
354
356
  # @raise [WebpackAssetError] if unable to find css or js in the manifest
355
357
  # file
356
358
  def parse_webpack_manifest_file(site, asset_type)
357
- manifest_file = site.in_root_dir(".bridgetown-webpack", "manifest.json")
358
- return "MISSING_WEBPACK_MANIFEST" unless File.exist?(manifest_file)
359
+ return log_webpack_asset_error("Webpack manifest") if site.frontend_manifest.nil?
359
360
 
360
- manifest = JSON.parse(File.read(manifest_file))
361
+ asset_path = if %w(js css).include?(asset_type)
362
+ site.frontend_manifest["main.#{asset_type}"]
363
+ else
364
+ site.frontend_manifest.find do |item, _|
365
+ item.sub(%r{^../(frontend/|src/)?}, "") == asset_type
366
+ end&.last
367
+ end
361
368
 
362
- known_assets = %w(js css)
363
- asset_path = nil
364
- if known_assets.include?(asset_type)
365
- asset_path = manifest["main.#{asset_type}"]
366
- log_webpack_asset_error(asset_type) && return if asset_path.nil?
367
- else
368
- asset_path = manifest.find do |item, _|
369
- item.sub(%r{^../(frontend/|src/)?}, "") == asset_type
370
- end&.last
371
- end
369
+ return log_webpack_asset_error(asset_type) if asset_path.nil?
372
370
 
373
- if asset_path
374
- static_frontend_path(site, ["js", asset_path])
375
- else
376
- Bridgetown.logger.error("Unknown Webpack asset type", asset_type)
377
- nil
378
- end
371
+ static_frontend_path site, ["js", asset_path]
379
372
  end
380
373
 
381
374
  def static_frontend_path(site, additional_parts = [])
@@ -389,10 +382,13 @@ module Bridgetown
389
382
  end
390
383
 
391
384
  def log_webpack_asset_error(asset_type)
392
- error_message = "There was an error parsing your #{asset_type} files. \
393
- Please check your #{asset_type} for any errors."
385
+ Bridgetown.logger.warn(
386
+ "Webpack:",
387
+ "There was an error parsing your #{asset_type} file. \
388
+ Please check your #{asset_type} file for any errors."
389
+ )
394
390
 
395
- Bridgetown.logger.warn(Errors::WebpackAssetError, error_message)
391
+ "MISSING_WEBPACK_MANIFEST_FILE"
396
392
  end
397
393
 
398
394
  def default_github_branch_name(repo_url)
@@ -404,6 +400,39 @@ module Bridgetown
404
400
  "master"
405
401
  end
406
402
 
403
+ def live_reload_js(site) # rubocop:disable Metrics/MethodLength
404
+ return "" unless Bridgetown.env.development? && !site.config.skip_live_reload
405
+
406
+ code = <<~JAVASCRIPT
407
+ let first_mod = 0
408
+ let connection_errors = 0
409
+ const checkForReload = () => {
410
+ fetch("/_bridgetown/live_reload").then(response => {
411
+ if (response.ok) {
412
+ response.json().then(data => {
413
+ const last_mod = data.last_mod
414
+ if (first_mod === 0) {
415
+ first_mod = last_mod
416
+ } else if (last_mod > first_mod) {
417
+ location.reload()
418
+ }
419
+ setTimeout(() => checkForReload(), 700)
420
+ })
421
+ } else {
422
+ if (connection_errors < 20) setTimeout(() => checkForReload(), 6000)
423
+ connection_errors++
424
+ }
425
+ }).catch((err) => {
426
+ if (connection_errors < 20) setTimeout(() => checkForReload(), 6000)
427
+ connection_errors++
428
+ })
429
+ }
430
+ checkForReload()
431
+ JAVASCRIPT
432
+
433
+ %(<script type="module">#{code}</script>).html_safe
434
+ end
435
+
407
436
  private
408
437
 
409
438
  def merge_values(target, overwrite)
@@ -453,7 +482,7 @@ module Bridgetown
453
482
  end
454
483
 
455
484
  # Strip according to the mode
456
- string.gsub(replaceable_char, "-")
485
+ string.to_s.gsub(replaceable_char, "-")
457
486
  end
458
487
  end
459
488
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bridgetown
4
- VERSION = "0.21.1"
5
- CODE_NAME = "Broughton Beach"
4
+ VERSION = "1.0.0.alpha1"
5
+ CODE_NAME = "Pearl"
6
6
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "listen"
4
-
5
3
  module Bridgetown
6
4
  module Watcher
7
5
  extend self
@@ -19,9 +17,9 @@ module Bridgetown
19
17
  listener = build_listener(site, options)
20
18
  listener.start
21
19
 
22
- Bridgetown.logger.info "Auto-regeneration:", "enabled."
20
+ Bridgetown.logger.info "Auto-regeneration:", "enabled." unless options[:using_puma]
23
21
 
24
- unless options["serving"]
22
+ unless options[:serving]
25
23
  trap("INT") do
26
24
  listener.stop
27
25
  Bridgetown.logger.info "", "Halting auto-regeneration."
@@ -47,6 +47,7 @@ require "hash_with_dot_access"
47
47
  require "addressable/uri"
48
48
  require "liquid"
49
49
  require "liquid-component"
50
+ require "listen"
50
51
  require "kramdown"
51
52
  require "colorator"
52
53
  require "i18n"
@@ -66,53 +67,39 @@ end
66
67
  class Rb < String; end
67
68
 
68
69
  module Bridgetown
70
+ autoload :Cache, "bridgetown-core/cache"
71
+ autoload :Current, "bridgetown-core/current"
69
72
  autoload :Cleaner, "bridgetown-core/cleaner"
70
73
  autoload :Collection, "bridgetown-core/collection"
71
74
  autoload :Component, "bridgetown-core/component"
72
75
  autoload :Configuration, "bridgetown-core/configuration"
73
- autoload :DataAccessible, "bridgetown-core/concerns/data_accessible"
76
+ autoload :DefaultsReader, "bridgetown-core/readers/defaults_reader"
74
77
  autoload :Deprecator, "bridgetown-core/deprecator"
75
- autoload :Document, "bridgetown-core/document"
76
78
  autoload :EntryFilter, "bridgetown-core/entry_filter"
77
79
  # TODO: we have too many errors! This is silly
78
80
  autoload :Errors, "bridgetown-core/errors"
79
- autoload :Excerpt, "bridgetown-core/excerpt"
80
81
  autoload :FrontmatterDefaults, "bridgetown-core/frontmatter_defaults"
81
82
  autoload :FrontMatterImporter, "bridgetown-core/concerns/front_matter_importer"
83
+ autoload :GeneratedPage, "bridgetown-core/generated_page"
82
84
  autoload :Hooks, "bridgetown-core/hooks"
83
85
  autoload :Layout, "bridgetown-core/layout"
84
86
  autoload :LayoutPlaceable, "bridgetown-core/concerns/layout_placeable"
85
- autoload :Cache, "bridgetown-core/cache"
86
- autoload :Current, "bridgetown-core/current"
87
- # TODO: remove this when legacy content engine is gone:
88
- autoload :DataReader, "bridgetown-core/readers/data_reader"
89
- autoload :DefaultsReader, "bridgetown-core/readers/defaults_reader"
90
87
  autoload :LayoutReader, "bridgetown-core/readers/layout_reader"
91
- # TODO: remove this when legacy content engine is gone:
92
- autoload :PostReader, "bridgetown-core/readers/post_reader"
93
- # TODO: remove this when legacy content engine is gone:
94
- autoload :PageReader, "bridgetown-core/readers/page_reader"
95
- autoload :PluginContentReader, "bridgetown-core/readers/plugin_content_reader"
88
+ autoload :LiquidRenderable, "bridgetown-core/concerns/liquid_renderable"
89
+ autoload :LiquidRenderer, "bridgetown-core/liquid_renderer"
96
90
  autoload :LogAdapter, "bridgetown-core/log_adapter"
97
- autoload :Page, "bridgetown-core/page"
98
- autoload :GeneratedPage, "bridgetown-core/page"
91
+ autoload :PluginContentReader, "bridgetown-core/readers/plugin_content_reader"
99
92
  autoload :PluginManager, "bridgetown-core/plugin_manager"
100
93
  autoload :Publishable, "bridgetown-core/concerns/publishable"
101
94
  autoload :Publisher, "bridgetown-core/publisher"
102
95
  autoload :Reader, "bridgetown-core/reader"
103
- # TODO: remove this when the incremental regenerator is gone:
104
- autoload :Regenerator, "bridgetown-core/regenerator"
105
- autoload :RelatedPosts, "bridgetown-core/related_posts"
106
96
  autoload :Renderer, "bridgetown-core/renderer"
107
- autoload :LiquidRenderable, "bridgetown-core/concerns/liquid_renderable"
108
- autoload :LiquidRenderer, "bridgetown-core/liquid_renderer"
109
97
  autoload :RubyTemplateView, "bridgetown-core/ruby_template_view"
110
98
  autoload :LogWriter, "bridgetown-core/log_writer"
111
99
  autoload :Site, "bridgetown-core/site"
112
100
  autoload :StaticFile, "bridgetown-core/static_file"
113
101
  autoload :URL, "bridgetown-core/url"
114
102
  autoload :Utils, "bridgetown-core/utils"
115
- autoload :Validatable, "bridgetown-core/concerns/validatable"
116
103
  autoload :VERSION, "bridgetown-core/version"
117
104
  autoload :Watcher, "bridgetown-core/watcher"
118
105
  autoload :YAMLParser, "bridgetown-core/yaml_parser"
@@ -126,7 +113,6 @@ module Bridgetown
126
113
  require "bridgetown-core/filters"
127
114
 
128
115
  require "bridgetown-core/drops/drop"
129
- require "bridgetown-core/drops/document_drop"
130
116
  require "bridgetown-core/drops/resource_drop"
131
117
  require_all "bridgetown-core/converters"
132
118
  require_all "bridgetown-core/converters/markdown"
@@ -173,6 +159,12 @@ module Bridgetown
173
159
  Bridgetown::Commands::Registrations.register(&block)
174
160
  end
175
161
 
162
+ def load_tasks
163
+ require "bridgetown-core/commands/base"
164
+ Bridgetown::PluginManager.require_from_bundler
165
+ load File.expand_path("bridgetown-core/tasks/bridgetown_tasks.rake", __dir__)
166
+ end
167
+
176
168
  # Determines the correct Bundler environment block method to use and passes
177
169
  # the block on to it.
178
170
  #
@@ -3,9 +3,9 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
3
 
4
4
  # Hello! This is where you manage which Bridgetown version is used to run.
5
5
  # When you want to use a different version, change it below, save the
6
- # file and run `bundle install`. Run Bridgetown with `bundle exec`, like so:
6
+ # file and run `bundle install`. Run Bridgetown like so:
7
7
  #
8
- # bundle exec bridgetown serve
8
+ # bin/bridgetown start (or console, etc.)
9
9
  #
10
10
  # This will help ensure the proper Bridgetown version is running.
11
11
  #
@@ -17,3 +17,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
17
17
  # Happy Bridgetowning!
18
18
 
19
19
  gem "bridgetown", "~> <%= Bridgetown::VERSION %>"
20
+
21
+ # Puma is a Rack-compatible server
22
+ # (you can optionally limit this to the "development" group)
23
+ gem "puma", "~> 5.2"
@@ -18,9 +18,9 @@ Welcome to your new Bridgetown website! You can update this README file to provi
18
18
  - [Ruby](https://www.ruby-lang.org/en/downloads/)
19
19
  - `>= 2.5`
20
20
  - [Bridgetown Gem](https://rubygems.org/gems/bridgetown)
21
- - `gem install bundler bridgetown -N`
21
+ - `gem install bridgetown -N`
22
22
  - [Node](https://nodejs.org)
23
- - `>= 10.13`
23
+ - `>= 12`
24
24
  - [Yarn](https://yarnpkg.com)
25
25
 
26
26
  ## Install
@@ -33,7 +33,7 @@ bundle install && yarn install
33
33
 
34
34
  ## Development
35
35
 
36
- To start your site in development mode, run `yarn start` and navigate to [localhost:4000](https://localhost:4000/)!
36
+ To start your site in development mode, run `bin/bridgetown start` and navigate to [localhost:4000](https://localhost:4000/)!
37
37
 
38
38
  Use a [theme](https://github.com/topics/bridgetown-theme), add some [plugins](https://www.bridgetownrb.com/plugins/), and/or run some [automations](https://github.com/topics/bridgetown-automation) to get started quickly.
39
39
 
@@ -41,13 +41,13 @@ Use a [theme](https://github.com/topics/bridgetown-theme), add some [plugins](ht
41
41
 
42
42
  ```sh
43
43
  # running locally
44
- yarn start
44
+ bin/bridgetown start
45
45
 
46
46
  # build & deploy to production
47
- yarn deploy
47
+ bin/bridgetown deploy
48
48
 
49
49
  # load the site up within a Ruby console (IRB)
50
- bundle exec bridgetown console
50
+ bin/bridgetown console
51
51
  ```
52
52
 
53
53
  > Learn more: [Bridgetown CLI Documentation](https://www.bridgetownrb.com/docs/command-line-usage)