bridgetown-core 0.15.0.beta2 → 0.16.0.beta2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +14 -0
  3. data/bridgetown-core.gemspec +3 -0
  4. data/lib/bridgetown-core.rb +6 -1
  5. data/lib/bridgetown-core/commands/concerns/actions.rb +41 -19
  6. data/lib/bridgetown-core/commands/console.rb +12 -2
  7. data/lib/bridgetown-core/commands/serve.rb +5 -0
  8. data/lib/bridgetown-core/concerns/data_accessible.rb +19 -0
  9. data/lib/bridgetown-core/concerns/layout_placeable.rb +17 -0
  10. data/lib/bridgetown-core/concerns/liquid_renderable.rb +20 -0
  11. data/lib/bridgetown-core/concerns/publishable.rb +10 -0
  12. data/lib/bridgetown-core/concerns/site/configurable.rb +62 -31
  13. data/lib/bridgetown-core/concerns/site/content.rb +88 -29
  14. data/lib/bridgetown-core/concerns/site/extensible.rb +15 -12
  15. data/lib/bridgetown-core/concerns/site/processable.rb +12 -10
  16. data/lib/bridgetown-core/concerns/site/renderable.rb +23 -4
  17. data/lib/bridgetown-core/concerns/site/writable.rb +16 -2
  18. data/lib/bridgetown-core/concerns/validatable.rb +59 -0
  19. data/lib/bridgetown-core/configuration.rb +1 -0
  20. data/lib/bridgetown-core/converter.rb +34 -0
  21. data/lib/bridgetown-core/converters/erb_templates.rb +78 -0
  22. data/lib/bridgetown-core/converters/markdown.rb +6 -23
  23. data/lib/bridgetown-core/converters/smartypants.rb +0 -10
  24. data/lib/bridgetown-core/document.rb +8 -52
  25. data/lib/bridgetown-core/drops/document_drop.rb +9 -1
  26. data/lib/bridgetown-core/errors.rb +2 -0
  27. data/lib/bridgetown-core/excerpt.rb +5 -7
  28. data/lib/bridgetown-core/filters.rb +2 -0
  29. data/lib/bridgetown-core/layout.rb +24 -1
  30. data/lib/bridgetown-core/liquid_renderer/file.rb +1 -4
  31. data/lib/bridgetown-core/liquid_renderer/file_system.rb +1 -1
  32. data/lib/bridgetown-core/page.rb +34 -25
  33. data/lib/bridgetown-core/plugin_manager.rb +36 -14
  34. data/lib/bridgetown-core/regenerator.rb +1 -1
  35. data/lib/bridgetown-core/renderer.rb +41 -15
  36. data/lib/bridgetown-core/ruby_template_view.rb +98 -0
  37. data/lib/bridgetown-core/tags/class_map.rb +90 -0
  38. data/lib/bridgetown-core/tags/include.rb +2 -0
  39. data/lib/bridgetown-core/tags/render_content.rb +14 -2
  40. data/lib/bridgetown-core/tags/webpack_path.rb +19 -22
  41. data/lib/bridgetown-core/utils.rb +97 -0
  42. data/lib/bridgetown-core/version.rb +2 -2
  43. data/lib/site_template/bridgetown.config.yml +5 -3
  44. data/lib/site_template/src/_components/{footer.html → footer.liquid} +0 -0
  45. data/lib/site_template/src/_components/{head.html → head.liquid} +0 -0
  46. data/lib/site_template/src/_components/{navbar.html → navbar.liquid} +0 -0
  47. data/lib/site_template/src/_layouts/{default.html → default.liquid} +1 -1
  48. data/lib/site_template/src/_layouts/{home.html → home.liquid} +0 -0
  49. data/lib/site_template/src/_layouts/{page.html → page.liquid} +0 -0
  50. data/lib/site_template/src/_layouts/{post.html → post.liquid} +0 -0
  51. metadata +59 -10
  52. data/lib/bridgetown-core/concerns/convertible.rb +0 -238
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bridgetown
4
- VERSION = "0.15.0.beta2"
5
- CODE_NAME = "Overlook"
4
+ VERSION = "0.16.0.beta2"
5
+ CODE_NAME = "Crystal Springs"
6
6
  end
@@ -10,12 +10,14 @@
10
10
  # For reloadable site metadata like title, SEO description, social media
11
11
  # handles, etc., take a look at src/_data/site_metadata.yml
12
12
  #
13
- # If you need help with YAML syntax, here are some quick references for you:
13
+ # If you need help with YAML syntax, here are some quick references for you:
14
14
  # https://learn-the-web.algonquindesign.ca/topics/markdown-yaml-cheat-sheet/#yaml
15
15
  # https://learnxinyminutes.com/docs/yaml/
16
16
  #
17
17
 
18
18
  baseurl: "" # OPTIONAL: the subpath of your site, e.g. /blog
19
- url: "" # the base hostname & protocol for your site, e.g. http://example.com
19
+ url: "" # the base hostname & protocol for your site, e.g. https://example.com
20
20
 
21
- # Additional build settings go here
21
+ permalink: pretty
22
+
23
+ # timezone: America/Los_Angeles
@@ -4,7 +4,7 @@
4
4
  {% render "head", metadata: site.metadata, title: page.title %}
5
5
  </head>
6
6
  <body class="{{ page.layout }} {{ page.page_class }}">
7
- {% render "navbar" %}
7
+ {% render "navbar", metadata: site.metadata, page: page %}
8
8
 
9
9
  <main>
10
10
  {{ content }}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bridgetown-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0.beta2
4
+ version: 0.16.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bridgetown Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-31 00:00:00.000000000 Z
11
+ date: 2020-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.4'
41
+ - !ruby/object:Gem::Dependency
42
+ name: awesome_print
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.8'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.8'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: colorator
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +66,20 @@ dependencies:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
68
  version: '1.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: erubi
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.9'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.9'
55
83
  - !ruby/object:Gem::Dependency
56
84
  name: faraday
57
85
  requirement: !ruby/object:Gem::Requirement
@@ -248,6 +276,20 @@ dependencies:
248
276
  - - "~>"
249
277
  - !ruby/object:Gem::Version
250
278
  version: '1.0'
279
+ - !ruby/object:Gem::Dependency
280
+ name: tilt
281
+ requirement: !ruby/object:Gem::Requirement
282
+ requirements:
283
+ - - "~>"
284
+ - !ruby/object:Gem::Version
285
+ version: '2.0'
286
+ type: :runtime
287
+ prerelease: false
288
+ version_requirements: !ruby/object:Gem::Requirement
289
+ requirements:
290
+ - - "~>"
291
+ - !ruby/object:Gem::Version
292
+ version: '2.0'
251
293
  description: Bridgetown is a Webpack-aware, Ruby-powered static site generator for
252
294
  the modern Jamstack era
253
295
  email: maintainers@bridgetownrb.com
@@ -278,15 +320,20 @@ files:
278
320
  - lib/bridgetown-core/commands/registrations.rb
279
321
  - lib/bridgetown-core/commands/serve.rb
280
322
  - lib/bridgetown-core/commands/serve/servlet.rb
281
- - lib/bridgetown-core/concerns/convertible.rb
323
+ - lib/bridgetown-core/concerns/data_accessible.rb
324
+ - lib/bridgetown-core/concerns/layout_placeable.rb
325
+ - lib/bridgetown-core/concerns/liquid_renderable.rb
326
+ - lib/bridgetown-core/concerns/publishable.rb
282
327
  - lib/bridgetown-core/concerns/site/configurable.rb
283
328
  - lib/bridgetown-core/concerns/site/content.rb
284
329
  - lib/bridgetown-core/concerns/site/extensible.rb
285
330
  - lib/bridgetown-core/concerns/site/processable.rb
286
331
  - lib/bridgetown-core/concerns/site/renderable.rb
287
332
  - lib/bridgetown-core/concerns/site/writable.rb
333
+ - lib/bridgetown-core/concerns/validatable.rb
288
334
  - lib/bridgetown-core/configuration.rb
289
335
  - lib/bridgetown-core/converter.rb
336
+ - lib/bridgetown-core/converters/erb_templates.rb
290
337
  - lib/bridgetown-core/converters/identity.rb
291
338
  - lib/bridgetown-core/converters/markdown.rb
292
339
  - lib/bridgetown-core/converters/markdown/kramdown_parser.rb
@@ -341,8 +388,10 @@ files:
341
388
  - lib/bridgetown-core/regenerator.rb
342
389
  - lib/bridgetown-core/related_posts.rb
343
390
  - lib/bridgetown-core/renderer.rb
391
+ - lib/bridgetown-core/ruby_template_view.rb
344
392
  - lib/bridgetown-core/site.rb
345
393
  - lib/bridgetown-core/static_file.rb
394
+ - lib/bridgetown-core/tags/class_map.rb
346
395
  - lib/bridgetown-core/tags/highlight.rb
347
396
  - lib/bridgetown-core/tags/include.rb
348
397
  - lib/bridgetown-core/tags/link.rb
@@ -370,14 +419,14 @@ files:
370
419
  - lib/site_template/plugins/builders/.keep
371
420
  - lib/site_template/plugins/site_builder.rb
372
421
  - lib/site_template/src/404.html
373
- - lib/site_template/src/_components/footer.html
374
- - lib/site_template/src/_components/head.html
375
- - lib/site_template/src/_components/navbar.html
422
+ - lib/site_template/src/_components/footer.liquid
423
+ - lib/site_template/src/_components/head.liquid
424
+ - lib/site_template/src/_components/navbar.liquid
376
425
  - lib/site_template/src/_data/site_metadata.yml
377
- - lib/site_template/src/_layouts/default.html
378
- - lib/site_template/src/_layouts/home.html
379
- - lib/site_template/src/_layouts/page.html
380
- - lib/site_template/src/_layouts/post.html
426
+ - lib/site_template/src/_layouts/default.liquid
427
+ - lib/site_template/src/_layouts/home.liquid
428
+ - lib/site_template/src/_layouts/page.liquid
429
+ - lib/site_template/src/_layouts/post.liquid
381
430
  - lib/site_template/src/_posts/0000-00-00-welcome-to-bridgetown.md.erb
382
431
  - lib/site_template/src/about.md
383
432
  - lib/site_template/src/favicon.ico
@@ -1,238 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Convertible provides methods for converting a pagelike item
4
- # from a certain type of markup into actual content
5
- #
6
- # Requires
7
- # self.site -> Bridgetown::Site
8
- # self.content
9
- # self.content=
10
- # self.data=
11
- # self.ext=
12
- # self.output=
13
- # self.name
14
- # self.path
15
- # self.type -> :page or :post
16
-
17
- module Bridgetown
18
- module Convertible
19
- # Returns the contents as a String.
20
- def to_s
21
- content || ""
22
- end
23
-
24
- # Whether the file is published or not, as indicated in YAML front-matter
25
- def published?
26
- !(data.key?("published") && data["published"] == false)
27
- end
28
-
29
- # Read the YAML frontmatter.
30
- #
31
- # base - The String path to the dir containing the file.
32
- # name - The String filename of the file.
33
- # opts - optional parameter to File.read, default at site configs
34
- #
35
- # Returns nothing.
36
- # rubocop:disable Metrics/AbcSize
37
- def read_yaml(base, name, opts = {})
38
- filename = File.join(base, name)
39
-
40
- begin
41
- self.content = File.read(@path || site.in_source_dir(base, name),
42
- **Utils.merged_file_read_opts(site, opts))
43
- if content =~ Document::YAML_FRONT_MATTER_REGEXP
44
- self.content = $POSTMATCH
45
- self.data = SafeYAML.load(Regexp.last_match(1))&.with_indifferent_access
46
- end
47
- rescue Psych::SyntaxError => e
48
- Bridgetown.logger.warn "YAML Exception reading #{filename}: #{e.message}"
49
- raise e if site.config["strict_front_matter"]
50
- rescue StandardError => e
51
- Bridgetown.logger.warn "Error reading file #{filename}: #{e.message}"
52
- raise e if site.config["strict_front_matter"]
53
- end
54
-
55
- self.data ||= ActiveSupport::HashWithIndifferentAccess.new
56
-
57
- validate_data! filename
58
- validate_permalink! filename
59
-
60
- self.data
61
- end
62
- # rubocop:enable Metrics/AbcSize
63
-
64
- def validate_data!(filename)
65
- unless self.data.is_a?(Hash)
66
- raise Errors::InvalidYAMLFrontMatterError,
67
- "Invalid YAML front matter in #{filename}"
68
- end
69
- end
70
-
71
- def validate_permalink!(filename)
72
- if self.data["permalink"]&.to_s&.empty?
73
- raise Errors::InvalidPermalinkError, "Invalid permalink in #{filename}"
74
- end
75
- end
76
-
77
- # TODO: this method never seems to get called...why's it here?
78
- # Transform the contents based on the content type.
79
- #
80
- # Returns the transformed contents.
81
- def transform
82
- _renderer.convert(content)
83
- end
84
-
85
- # Determine the extension depending on content_type.
86
- #
87
- # Returns the String extension for the output file.
88
- # e.g. ".html" for an HTML output file.
89
- def output_ext
90
- _renderer.output_ext
91
- end
92
-
93
- # Determine which converter to use based on this convertible's
94
- # extension.
95
- #
96
- # Returns the Converter instance.
97
- def converters
98
- _renderer.converters
99
- end
100
-
101
- # Render Liquid in the content
102
- #
103
- # content - the raw Liquid content to render
104
- # payload - the payload for Liquid
105
- # info - the info for Liquid
106
- #
107
- # Returns the converted content
108
- def render_liquid(content, payload, info, path)
109
- _renderer.render_liquid(content, payload, info, path)
110
- end
111
-
112
- # Convert this Convertible's data to a Hash suitable for use by Liquid.
113
- #
114
- # Returns the Hash representation of this Convertible.
115
- def to_liquid(attrs = nil)
116
- further_data = \
117
- (attrs || self.class::ATTRIBUTES_FOR_LIQUID).each_with_object({}) do |attribute, hsh|
118
- hsh[attribute] = send(attribute)
119
- end
120
-
121
- defaults = site.frontmatter_defaults.all(relative_path, type)
122
- Utils.deep_merge_hashes defaults, Utils.deep_merge_hashes(data, further_data)
123
- end
124
-
125
- # The type of a document,
126
- # i.e., its classname downcase'd and to_sym'd.
127
- #
128
- # Returns the type of self.
129
- def type
130
- :pages if is_a?(Page)
131
- end
132
-
133
- # returns the owner symbol for hook triggering
134
- def hook_owner
135
- :pages if is_a?(Page)
136
- end
137
-
138
- # TODO: Depricated
139
- # Used to determine CoffeeScript and Sass/SCSS files.
140
- def asset_file?
141
- false
142
- end
143
-
144
- # Determine whether the file should be rendered with Liquid.
145
- #
146
- # Returns true if the file has Liquid Tags or Variables, false otherwise.
147
- def render_with_liquid?
148
- return false if data["render_with_liquid"] == false
149
-
150
- Bridgetown::Utils.has_liquid_construct?(content)
151
- end
152
-
153
- # Determine whether the file should be placed into layouts.
154
- #
155
- # Returns false if the document is an asset file or if the front matter
156
- # specifies `layout: none`
157
- def place_in_layout?
158
- !(asset_file? || no_layout?)
159
- end
160
-
161
- # Checks if the layout specified in the document actually exists
162
- #
163
- # layout - the layout to check
164
- #
165
- # Returns true if the layout is invalid, false if otherwise
166
- def invalid_layout?(layout)
167
- !data["layout"].nil? && layout.nil? && !(is_a? Bridgetown::Excerpt)
168
- end
169
-
170
- # Recursively render layouts
171
- #
172
- # layouts - a list of the layouts
173
- # payload - the payload for Liquid
174
- # info - the info for Liquid
175
- #
176
- # Returns nothing
177
- def render_all_layouts(layouts, payload, info)
178
- _renderer.layouts = layouts
179
- self.output = _renderer.place_in_layouts(output, payload, info)
180
- ensure
181
- @_renderer = nil # this will allow the modifications above to disappear
182
- end
183
-
184
- # Add any necessary layouts to this convertible document.
185
- #
186
- # payload - The site payload Drop or Hash.
187
- # layouts - A Hash of {"name" => "layout"}.
188
- #
189
- # Returns nothing.
190
- def do_layout(payload, layouts)
191
- self.output = _renderer.tap do |renderer|
192
- renderer.layouts = layouts
193
- renderer.payload = payload
194
- end.run
195
-
196
- Bridgetown.logger.debug "Post-Render Hooks:", relative_path
197
- Bridgetown::Hooks.trigger hook_owner, :post_render, self
198
- ensure
199
- @_renderer = nil # this will allow the modifications above to disappear
200
- end
201
-
202
- # Write the generated page file to the destination directory.
203
- #
204
- # dest - The String path to the destination dir.
205
- #
206
- # Returns nothing.
207
- def write(dest)
208
- path = destination(dest)
209
- FileUtils.mkdir_p(File.dirname(path))
210
- Bridgetown.logger.debug "Writing:", path
211
- File.write(path, output, mode: "wb")
212
- Bridgetown::Hooks.trigger hook_owner, :post_write, self
213
- end
214
-
215
- # Accessor for data properties by Liquid.
216
- #
217
- # property - The String name of the property to retrieve.
218
- #
219
- # Returns the String value or nil if the property isn't included.
220
- def [](property)
221
- if self.class::ATTRIBUTES_FOR_LIQUID.include?(property)
222
- send(property)
223
- else
224
- data[property]
225
- end
226
- end
227
-
228
- private
229
-
230
- def _renderer
231
- @_renderer ||= Bridgetown::Renderer.new(site, self)
232
- end
233
-
234
- def no_layout?
235
- data["layout"] == "none"
236
- end
237
- end
238
- end