bridgetown-core 0.21.4 → 1.0.0.alpha4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +35 -0
  3. data/Rakefile +5 -5
  4. data/bin/bridgetown +2 -0
  5. data/bridgetown-core.gemspec +3 -0
  6. data/lib/bridgetown-core/cache.rb +3 -5
  7. data/lib/bridgetown-core/cleaner.rb +2 -10
  8. data/lib/bridgetown-core/collection.rb +62 -86
  9. data/lib/bridgetown-core/commands/base.rb +62 -2
  10. data/lib/bridgetown-core/commands/build.rb +33 -12
  11. data/lib/bridgetown-core/commands/concerns/actions.rb +2 -2
  12. data/lib/bridgetown-core/commands/concerns/build_options.rb +3 -10
  13. data/lib/bridgetown-core/commands/concerns/configuration_overridable.rb +3 -1
  14. data/lib/bridgetown-core/commands/console.rb +3 -3
  15. data/lib/bridgetown-core/commands/doctor.rb +13 -11
  16. data/lib/bridgetown-core/commands/new.rb +14 -6
  17. data/lib/bridgetown-core/commands/plugins.rb +8 -11
  18. data/lib/bridgetown-core/commands/serve/servlet.rb +4 -4
  19. data/lib/bridgetown-core/commands/serve.rb +37 -37
  20. data/lib/bridgetown-core/commands/start.rb +106 -0
  21. data/lib/bridgetown-core/commands/webpack/webpack.defaults.js.erb +2 -2
  22. data/lib/bridgetown-core/commands/webpack.rb +1 -1
  23. data/lib/bridgetown-core/component.rb +2 -6
  24. data/lib/bridgetown-core/concerns/liquid_renderable.rb +2 -2
  25. data/lib/bridgetown-core/concerns/site/configurable.rb +1 -13
  26. data/lib/bridgetown-core/concerns/site/content.rb +7 -118
  27. data/lib/bridgetown-core/concerns/site/extensible.rb +3 -4
  28. data/lib/bridgetown-core/concerns/site/localizable.rb +3 -1
  29. data/lib/bridgetown-core/concerns/site/processable.rb +8 -20
  30. data/lib/bridgetown-core/concerns/site/renderable.rb +19 -30
  31. data/lib/bridgetown-core/concerns/site/ssr.rb +53 -0
  32. data/lib/bridgetown-core/concerns/site/writable.rb +6 -9
  33. data/lib/bridgetown-core/configuration.rb +19 -48
  34. data/lib/bridgetown-core/configurations/minitesting.rb +1 -1
  35. data/lib/bridgetown-core/configurations/turbo.rb +1 -1
  36. data/lib/bridgetown-core/converter.rb +1 -0
  37. data/lib/bridgetown-core/converters/erb_templates.rb +8 -5
  38. data/lib/bridgetown-core/converters/liquid_templates.rb +5 -2
  39. data/lib/bridgetown-core/converters/markdown/kramdown_parser.rb +1 -1
  40. data/lib/bridgetown-core/converters/smartypants.rb +1 -0
  41. data/lib/bridgetown-core/current.rb +4 -0
  42. data/lib/bridgetown-core/drops/collection_drop.rb +1 -1
  43. data/lib/bridgetown-core/drops/drop.rb +4 -4
  44. data/lib/bridgetown-core/drops/generated_page_drop.rb +23 -0
  45. data/lib/bridgetown-core/drops/resource_drop.rb +3 -3
  46. data/lib/bridgetown-core/drops/site_drop.rb +3 -47
  47. data/lib/bridgetown-core/entry_filter.rb +1 -0
  48. data/lib/bridgetown-core/filters/url_filters.rb +2 -0
  49. data/lib/bridgetown-core/filters.rb +11 -12
  50. data/lib/bridgetown-core/frontmatter_defaults.rb +44 -82
  51. data/lib/bridgetown-core/{page.rb → generated_page.rb} +34 -60
  52. data/lib/bridgetown-core/generators/prototype_generator.rb +46 -58
  53. data/lib/bridgetown-core/helpers.rb +8 -3
  54. data/lib/bridgetown-core/hooks.rb +2 -2
  55. data/lib/bridgetown-core/layout.rb +15 -4
  56. data/lib/bridgetown-core/liquid_renderer.rb +1 -3
  57. data/lib/bridgetown-core/log_adapter.rb +1 -1
  58. data/lib/bridgetown-core/log_writer.rb +7 -1
  59. data/lib/bridgetown-core/model/base.rb +12 -4
  60. data/lib/bridgetown-core/model/builder_origin.rb +23 -11
  61. data/lib/bridgetown-core/model/origin.rb +3 -0
  62. data/lib/bridgetown-core/model/plugin_origin.rb +34 -0
  63. data/lib/bridgetown-core/model/repo_origin.rb +1 -1
  64. data/lib/bridgetown-core/plugin_manager.rb +10 -10
  65. data/lib/bridgetown-core/publisher.rb +1 -1
  66. data/lib/bridgetown-core/rack/boot.rb +55 -0
  67. data/lib/bridgetown-core/rack/logger.rb +22 -0
  68. data/lib/bridgetown-core/rack/roda.rb +66 -0
  69. data/lib/bridgetown-core/rack/routes.rb +88 -0
  70. data/lib/bridgetown-core/rack/static_indexes.rb +30 -0
  71. data/lib/bridgetown-core/reader.rb +16 -48
  72. data/lib/bridgetown-core/readers/layout_reader.rb +2 -2
  73. data/lib/bridgetown-core/readers/plugin_content_reader.rb +8 -7
  74. data/lib/bridgetown-core/renderer.rb +2 -12
  75. data/lib/bridgetown-core/resource/base.rb +34 -11
  76. data/lib/bridgetown-core/resource/permalink_processor.rb +23 -12
  77. data/lib/bridgetown-core/resource/relations.rb +2 -3
  78. data/lib/bridgetown-core/resource/taxonomy_term.rb +1 -5
  79. data/lib/bridgetown-core/resource/transformer.rb +8 -6
  80. data/lib/bridgetown-core/ruby_template_view.rb +6 -8
  81. data/lib/bridgetown-core/site.rb +4 -8
  82. data/lib/bridgetown-core/static_file.rb +14 -21
  83. data/lib/bridgetown-core/tags/find.rb +6 -6
  84. data/lib/bridgetown-core/tags/highlight.rb +5 -5
  85. data/lib/bridgetown-core/tags/include.rb +22 -32
  86. data/lib/bridgetown-core/tags/link.rb +4 -0
  87. data/lib/bridgetown-core/tags/live_reload_dev_js.rb +13 -0
  88. data/lib/bridgetown-core/tags/post_url.rb +9 -14
  89. data/lib/bridgetown-core/tags/render_content.rb +2 -2
  90. data/lib/bridgetown-core/tasks/bridgetown_tasks.rake +60 -0
  91. data/lib/bridgetown-core/url.rb +5 -4
  92. data/lib/bridgetown-core/utils/aux.rb +57 -0
  93. data/lib/bridgetown-core/utils/ruby_exec.rb +3 -45
  94. data/lib/bridgetown-core/utils/ruby_front_matter.rb +22 -7
  95. data/lib/bridgetown-core/utils.rb +44 -11
  96. data/lib/bridgetown-core/version.rb +2 -2
  97. data/lib/bridgetown-core/watcher.rb +4 -6
  98. data/lib/bridgetown-core.rb +16 -23
  99. data/lib/site_template/Gemfile.erb +6 -2
  100. data/lib/site_template/README.md +6 -6
  101. data/lib/site_template/Rakefile +49 -0
  102. data/lib/site_template/bridgetown.config.yml +2 -3
  103. data/lib/site_template/config/puma.rb +27 -0
  104. data/lib/site_template/config.ru +7 -0
  105. data/lib/site_template/package.json.erb +1 -9
  106. data/lib/site_template/server/roda_app.rb +22 -0
  107. data/lib/site_template/server/routes/hello.rb.sample +10 -0
  108. data/lib/site_template/src/_components/head.liquid +2 -1
  109. data/lib/site_template/src/_layouts/default.liquid +1 -1
  110. data/lib/site_template/src/about.md +0 -1
  111. data/lib/site_template/src/posts.md +2 -3
  112. metadata +63 -18
  113. data/lib/bridgetown-core/concerns/data_accessible.rb +0 -20
  114. data/lib/bridgetown-core/concerns/validatable.rb +0 -56
  115. data/lib/bridgetown-core/document.rb +0 -437
  116. data/lib/bridgetown-core/drops/document_drop.rb +0 -80
  117. data/lib/bridgetown-core/drops/excerpt_drop.rb +0 -19
  118. data/lib/bridgetown-core/drops/page_drop.rb +0 -18
  119. data/lib/bridgetown-core/excerpt.rb +0 -200
  120. data/lib/bridgetown-core/readers/data_reader.rb +0 -89
  121. data/lib/bridgetown-core/readers/page_reader.rb +0 -26
  122. data/lib/bridgetown-core/readers/post_reader.rb +0 -109
  123. data/lib/bridgetown-core/regenerator.rb +0 -202
  124. data/lib/bridgetown-core/related_posts.rb +0 -55
  125. data/lib/site_template/config/.keep +0 -0
  126. data/lib/site_template/start.js +0 -17
  127. data/lib/site_template/sync.js +0 -35
@@ -1,16 +1,18 @@
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
12
14
  SLUGIFY_MODES = %w(raw default pretty simple ascii latin).freeze
13
- SLUGIFY_RAW_REGEXP = Regexp.new('\\s+').freeze
15
+ SLUGIFY_RAW_REGEXP = Regexp.new("\\s+").freeze
14
16
  SLUGIFY_DEFAULT_REGEXP = Regexp.new("[^\\p{M}\\p{L}\\p{Nd}]+").freeze
15
17
  SLUGIFY_PRETTY_REGEXP = Regexp.new("[^\\p{M}\\p{L}\\p{Nd}._~!$&'()+,;=@]+").freeze
16
18
  SLUGIFY_ASCII_REGEXP = Regexp.new("[^[A-Za-z0-9]]+").freeze
@@ -201,7 +203,7 @@ module Bridgetown
201
203
  slug = replace_character_sequence_with_hyphen(string, mode: mode)
202
204
 
203
205
  # Remove leading/trailing hyphen
204
- slug.gsub!(%r!^\-|\-$!i, "")
206
+ slug.gsub!(%r!^-|-$!i, "")
205
207
 
206
208
  slug.downcase! unless cased
207
209
 
@@ -314,9 +316,7 @@ module Bridgetown
314
316
  lines.map do |line|
315
317
  continue_processing = !skip_pre_lines
316
318
 
317
- if skip_pre_lines
318
- skip_pre_lines = false if line.include?("</pre>")
319
- end
319
+ skip_pre_lines = false if skip_pre_lines && line.include?("</pre>")
320
320
  if line.include?("<pre")
321
321
  skip_pre_lines = true
322
322
  continue_processing = false
@@ -338,7 +338,7 @@ module Bridgetown
338
338
  else
339
339
  line
340
340
  end
341
- end.join("")
341
+ end.join
342
342
  end
343
343
  # rubocop:enable Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity
344
344
 
@@ -398,6 +398,39 @@ module Bridgetown
398
398
  "master"
399
399
  end
400
400
 
401
+ def live_reload_js(site) # rubocop:disable Metrics/MethodLength
402
+ return "" unless Bridgetown.env.development? && !site.config.skip_live_reload
403
+
404
+ code = <<~JAVASCRIPT
405
+ let first_mod = 0
406
+ let connection_errors = 0
407
+ const checkForReload = () => {
408
+ fetch("/_bridgetown/live_reload").then(response => {
409
+ if (response.ok) {
410
+ response.json().then(data => {
411
+ const last_mod = data.last_mod
412
+ if (first_mod === 0) {
413
+ first_mod = last_mod
414
+ } else if (last_mod > first_mod) {
415
+ location.reload()
416
+ }
417
+ setTimeout(() => checkForReload(), 700)
418
+ })
419
+ } else {
420
+ if (connection_errors < 20) setTimeout(() => checkForReload(), 6000)
421
+ connection_errors++
422
+ }
423
+ }).catch((err) => {
424
+ if (connection_errors < 20) setTimeout(() => checkForReload(), 6000)
425
+ connection_errors++
426
+ })
427
+ }
428
+ checkForReload()
429
+ JAVASCRIPT
430
+
431
+ %(<script type="module">#{code}</script>).html_safe
432
+ end
433
+
401
434
  private
402
435
 
403
436
  def merge_values(target, overwrite)
@@ -413,9 +446,9 @@ module Bridgetown
413
446
  end
414
447
 
415
448
  def merge_default_proc(target, overwrite)
416
- if target.is_a?(Hash) && overwrite.is_a?(Hash) && target.default_proc.nil?
417
- target.default_proc = overwrite.default_proc
418
- end
449
+ return unless target.is_a?(Hash) && overwrite.is_a?(Hash) && target.default_proc.nil?
450
+
451
+ target.default_proc = overwrite.default_proc
419
452
  end
420
453
 
421
454
  def duplicate_frozen_values(target)
@@ -447,7 +480,7 @@ module Bridgetown
447
480
  end
448
481
 
449
482
  # Strip according to the mode
450
- string.gsub(replaceable_char, "-")
483
+ string.to_s.gsub(replaceable_char, "-")
451
484
  end
452
485
  end
453
486
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bridgetown
4
- VERSION = "0.21.4"
5
- CODE_NAME = "Broughton Beach"
4
+ VERSION = "1.0.0.alpha4"
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."
@@ -118,7 +116,7 @@ module Bridgetown
118
116
  rescue ArgumentError
119
117
  # Could not find a relative path
120
118
  end
121
- end.compact + [%r!^\.bridgetown\-metadata!]
119
+ end.compact + [%r!^\.bridgetown-metadata!]
122
120
  end
123
121
 
124
122
  def sleep_forever
@@ -134,7 +132,7 @@ module Bridgetown
134
132
  site.plugin_manager.reload_component_loaders
135
133
  site.process
136
134
  Bridgetown.logger.info "Done! 🎉", "#{"Completed".green} in less than" \
137
- " #{(Time.now - time).ceil(2)} seconds."
135
+ " #{(Time.now - time).ceil(2)} seconds."
138
136
  rescue Exception => e
139
137
  Bridgetown.logger.error "Error:", e.message
140
138
 
@@ -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
  #
@@ -257,12 +249,13 @@ end
257
249
 
258
250
  module Bridgetown
259
251
  module Model; end
252
+
260
253
  module Resource
261
254
  def self.register_extension(mod)
262
255
  if mod.const_defined?(:LiquidResource)
263
256
  Bridgetown::Drops::ResourceDrop.include mod.const_get(:LiquidResource)
264
257
  end
265
- if mod.const_defined?(:RubyResource)
258
+ if mod.const_defined?(:RubyResource) # rubocop:disable Style/GuardClause
266
259
  Bridgetown::Resource::Base.include mod.const_get(:RubyResource)
267
260
  end
268
261
  end
@@ -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)
@@ -0,0 +1,49 @@
1
+ require "bridgetown"
2
+
3
+ Bridgetown.load_tasks
4
+
5
+ #
6
+ # Standard set of tasks, which you can customize if you wish:
7
+ #
8
+ desc "Build the Bridgetown site for deployment"
9
+ task :deploy => [:clean, "frontend:build"] do
10
+ Bridgetown::Commands::Build.start
11
+ end
12
+
13
+ desc "Build the site in a test environment"
14
+ task :test do
15
+ ENV["BRIDGETOWN_ENV"] = "test"
16
+ Bridgetown::Commands::Build.start
17
+ end
18
+
19
+ desc "Runs the clean command"
20
+ task :clean do
21
+ Bridgetown::Commands::Clean.start
22
+ end
23
+
24
+ namespace :frontend do
25
+ desc "Build the frontend with Webpack for deployment"
26
+ task :build do
27
+ sh "yarn run webpack-build"
28
+ end
29
+
30
+ desc "Watch the frontend with Webpack during development"
31
+ task :dev do
32
+ sh "yarn run webpack-dev --color"
33
+ rescue Interrupt
34
+ end
35
+ end
36
+
37
+ #
38
+ # Add your own Rake tasks here! You can use `environment` as a prerequisite
39
+ # in order to write automations or other commands requiring a loaded site.
40
+ #
41
+ # task :my_task => :environment do
42
+ # puts site.root_dir
43
+ # automation do
44
+ # say_status :rake, "I'm a Rake tast =) #{site.config.url}"
45
+ # end
46
+ # end
47
+
48
+ # Run rake without specifying any command to execute a deploy build by default.
49
+ task default: :deploy
@@ -4,11 +4,10 @@
4
4
  # which you are expected to set up once and rarely edit after that.
5
5
  #
6
6
  # For technical reasons, this file is *NOT* reloaded automatically when you use
7
- # 'bundle exec bridgetown serve'. If you change this file, please restart the
8
- # server process.
7
+ # `bin/bridgetown start`. If you change this file, please restart the server process.
9
8
  #
10
9
  # For reloadable site metadata like title, SEO description, social media
11
- # handles, etc., take a look at src/_data/site_metadata.yml
10
+ # handles, etc., take a look at `src/_data/site_metadata.yml`
12
11
  #
13
12
  # If you need help with YAML syntax, here are some quick references for you:
14
13
  # https://learn-the-web.algonquindesign.ca/topics/markdown-yaml-cheat-sheet/#yaml
@@ -0,0 +1,27 @@
1
+ # Puma is a fast, concurrent web server for Ruby & Rack
2
+ #
3
+ # Learn more at: https://puma.io
4
+ #
5
+ port ENV.fetch("BRIDGETOWN_PORT") { 4000 }
6
+
7
+ # You can adjust the number of workers (separate processes) and threads
8
+ # (per process) based on your production system
9
+ #
10
+ if ENV["BRIDGETOWN_ENV"] == "production"
11
+ workers ENV.fetch("BRIDGETOWN_CONCURRENCY") { 4 }
12
+ end
13
+
14
+ max_threads_count = ENV.fetch("BRIDGETOWN_MAX_THREADS") { 5 }
15
+ min_threads_count = ENV.fetch("BRIDGETOWN_MIN_THREADS") { max_threads_count }
16
+ threads min_threads_count, max_threads_count
17
+
18
+ # Preload the application for maximum performance
19
+ #
20
+ preload_app!
21
+
22
+ # Use the Bridgetown logger format
23
+ #
24
+ require "bridgetown-core/rack/logger"
25
+ log_formatter do |msg|
26
+ Bridgetown::Rack::Logger.message_with_prefix msg
27
+ end
@@ -0,0 +1,7 @@
1
+ # This file is used by Rack-based servers during the Bridgetown boot process.
2
+
3
+ require "bridgetown-core/rack/boot"
4
+
5
+ Bridgetown::Rack.boot
6
+
7
+ run RodaApp.freeze.app # see server/roda_app.rb
@@ -3,18 +3,10 @@
3
3
  "version": "1.0.0",
4
4
  "private": true,
5
5
  "scripts": {
6
- "build": "bundle exec bridgetown build",
7
- "serve": "bundle exec bridgetown serve",
8
- "clean": "bundle exec bridgetown clean",
9
6
  "webpack-build": "webpack --mode production",
10
- "webpack-dev": "webpack --mode development -w",
11
- "deploy": "yarn clean && yarn webpack-build && yarn build",
12
- "sync": "node sync.js",
13
- "start": "node start.js"
7
+ "webpack-dev": "webpack --mode development -w"
14
8
  },
15
9
  "devDependencies": {
16
- "browser-sync": "^2.26.7",
17
- "concurrently": "^5.2.0",
18
10
  "css-loader": "^4.3.0",
19
11
  "esbuild": "^0.12.7",
20
12
  "esbuild-loader": "^2.13.1",
@@ -0,0 +1,22 @@
1
+ # Roda is a simple Rack-based framework with a flexible architecture based
2
+ # on the concept of a routing tree. Bridgetown uses it for its development
3
+ # server, but you can also run it in production for fast, dynamic applications.
4
+ #
5
+ # Learn more at: http://roda.jeremyevans.net
6
+
7
+ # Uncomment to use the file-based routing for Bridgetown SSR:
8
+ # require "bridgetown-routes"
9
+
10
+ class RodaApp < Bridgetown::Rack::Roda
11
+ # Add additional Roda configuration here if needed
12
+
13
+ # Uncomment to use Bridgetown SSR:
14
+ # plugin :bridgetown_ssr
15
+ # plugin :bridgetown_routes
16
+
17
+ route do |r|
18
+ # Load all files in server/routes and src/_routes if "bridgetown-routes" is loaded
19
+ # (see server/routes/hello.rb.sample)
20
+ Bridgetown::Rack::Routes.start! self
21
+ end
22
+ end
@@ -0,0 +1,10 @@
1
+ # Rename this file to hello.rb to try out
2
+
3
+ class Routes::Hello < Bridgetown::Rack::Routes
4
+ route do |r|
5
+ # route: GET /hello/:name
6
+ r.get "hello", String do |name|
7
+ { hello: "friend #{name}" }
8
+ end
9
+ end
10
+ end
@@ -1,9 +1,10 @@
1
1
  <meta charset="utf-8" />
2
2
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
3
3
  {% capture page_title %}{{ title | strip_html | strip_newlines }}{% endcapture %}
4
- <title>{% if page_title != "" %}{{ page_title | escape }} | {{ metadata.title | escape }}{% else %}{{ metadata.title | escape }}: {{ metadata.tagline | escape }}{% endif %}</title>
4
+ <title>{% if page_title != "Index" %}{{ page_title | escape }} | {{ metadata.title | escape }}{% else %}{{ metadata.title | escape }}: {{ metadata.tagline | escape }}{% endif %}</title>
5
5
 
6
6
  <meta name="description" content="{{ metadata.description }}" />
7
7
 
8
8
  <link rel="stylesheet" href="{% webpack_path css %}" />
9
9
  <script src="{% webpack_path js %}" defer></script>
10
+ {% live_reload_dev_js %}
@@ -1,5 +1,5 @@
1
1
  <!doctype html>
2
- <html lang="en">
2
+ <html lang="{{ site.locale }}">
3
3
  <head>
4
4
  {% render "head", metadata: site.metadata, title: page.title %}
5
5
  </head>
@@ -1,7 +1,6 @@
1
1
  ---
2
2
  layout: page
3
3
  title: About
4
- permalink: /about/
5
4
  ---
6
5
 
7
6
  This is the basic Bridgetown site template. You can find out more info about customizing your Bridgetown site, as well as basic Bridgetown usage documentation at [bridgetownrb.com](https://bridgetownrb.com/)
@@ -1,13 +1,12 @@
1
1
  ---
2
2
  layout: page
3
3
  title: Posts
4
- permalink: /posts/
5
4
  ---
6
5
 
7
6
  <ul>
8
- {% for post in site.posts %}
7
+ {% for post in collections.posts.resources %}
9
8
  <li>
10
- <a href="{{ post.url }}">{{ post.title }}</a>
9
+ <a href="{{ post.relative_url }}">{{ post.title }}</a>
11
10
  </li>
12
11
  {% endfor %}
13
12
  </ul>