bridgetown-core 1.0.0.alpha8 → 1.0.0.alpha9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0d6ef82d9ee9b28132bda459264d887de83f704a67277a0c9d4046a755e2508
4
- data.tar.gz: d39e9bb5399b5d5d7167cc20a81d3ce89fff1626c7ec13847cc5042b48a802e7
3
+ metadata.gz: 913ec78ef91ecd5b8e9f56777878f68bcb31625c9af575597bf56a0bf025f252
4
+ data.tar.gz: f1e4b3292c9f4edf1ebf0318ba2d2751d0b220dc7346536014d4328772cb1879
5
5
  SHA512:
6
- metadata.gz: ff214944686584ddbc3ec0f853e60d233af3cc2d34a580141fe3771d76822770c6040429266b967133356588a01aec468b54fcd40d87cdffe844b1b307f48e85
7
- data.tar.gz: d6028a5f062ae873bac66ff929315e884844aae412999180484316d774c5480849c854ea731f993419552693058ada6aeb2abef74c5176e98802acb6d1c5a274
6
+ metadata.gz: f8affaf97ca29c3e093bf0562259bd9d878ccc216ba63a52ceb3388cfd735b92a32add0dadb8a2b748b7ba416c5a9167c0f6983dc5705b9622fbac445f4fd352
7
+ data.tar.gz: 56917b674308b501407ab2a4eb7882cc679794e895291db31f4bc80724c1d1e8cbcabd25b86784300e91b0ec3a0cc80bc8789f01730615965fe4b267b8a6570f
data/.rubocop.yml CHANGED
@@ -11,6 +11,7 @@ AllCops:
11
11
  - vendor/**/*
12
12
  - tmp/**/*
13
13
  - test/source/**/*
14
+ - test/resources/src/_pages/*.rb
14
15
  - lib/site_template/Rakefile
15
16
  - lib/site_template/config.ru
16
17
  - lib/site_template/config/**/*
data/bin/bridgetown CHANGED
@@ -19,11 +19,18 @@ Bridgetown::PluginManager.require_from_bundler
19
19
  # TODO: need to change behavior of Colorator gem
20
20
  ENV["THOR_SHELL"] = "Basic" if ENV["NO_COLOR"]
21
21
 
22
- output_version = if ARGV[0] == "-v"
22
+ output_version = if ARGV[0] == "-v" || ARGV[0] == "--version"
23
23
  puts "bridgetown #{Bridgetown::VERSION} \"#{Bridgetown::CODE_NAME}\""
24
24
  true
25
25
  end
26
26
 
27
+ if env_index = ARGV.index { |arg| arg == "-e" } # rubocop:disable Lint/AssignmentInCondition
28
+ env = ARGV[env_index + 1]
29
+ ENV["BRIDGETOWN_ENV"] = env if env
30
+ elsif env_flag = ARGV.find { |arg| arg.start_with?("--environment=") } # rubocop:disable Lint/AssignmentInCondition
31
+ ENV["BRIDGETOWN_ENV"] = env_flag.split("=").last
32
+ end
33
+
27
34
  ENV["RACK_ENV"] = ENV["BRIDGETOWN_ENV"]
28
35
 
29
36
  require "bridgetown-core/commands/base"
@@ -43,12 +43,12 @@ Gem::Specification.new do |s|
43
43
  s.add_runtime_dependency("kramdown", "~> 2.1")
44
44
  s.add_runtime_dependency("kramdown-parser-gfm", "~> 1.0")
45
45
  s.add_runtime_dependency("liquid", "~> 5.0")
46
- s.add_runtime_dependency("liquid-component", ">= 0.1")
47
46
  s.add_runtime_dependency("listen", "~> 3.0")
48
47
  s.add_runtime_dependency("rack-indifferent", ">= 1.2.0")
49
48
  s.add_runtime_dependency("rake", ">= 13.0")
50
49
  s.add_runtime_dependency("roda", "~> 3.46")
51
50
  s.add_runtime_dependency("rouge", "~> 3.0")
51
+ s.add_runtime_dependency("serbea", "~> 1.0")
52
52
  s.add_runtime_dependency("terminal-table", "~> 1.8")
53
53
  s.add_runtime_dependency("thor", "~> 1.1")
54
54
  s.add_runtime_dependency("tilt", "~> 2.0")
@@ -3,6 +3,13 @@
3
3
  module Bridgetown
4
4
  module Commands
5
5
  module ConfigurationOverridable
6
+ def self.included(klass)
7
+ desc = "The environment used for this command (aka development, test, production, etc.)"
8
+ klass.class_option :environment,
9
+ aliases: "-e",
10
+ desc: desc
11
+ end
12
+
6
13
  # Create a full Bridgetown configuration with the options passed in as overrides
7
14
  #
8
15
  # options - the configuration overrides
@@ -1,6 +1,38 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bridgetown
4
+ module ConsoleMethods
5
+ def site
6
+ Bridgetown::Current.site
7
+ end
8
+
9
+ def collections
10
+ site.collections
11
+ end
12
+
13
+ def reload!
14
+ Bridgetown.logger.info "Reloading site..."
15
+
16
+ I18n.reload! # make sure any locale files get read again
17
+ Bridgetown::Hooks.trigger :site, :pre_reload, site
18
+ Bridgetown::Hooks.clear_reloadable_hooks
19
+ site.plugin_manager.reload_plugin_files
20
+ site.loaders_manager.reload_loaders
21
+
22
+ ConsoleMethods.site_reset(site)
23
+ end
24
+
25
+ def self.site_reset(site)
26
+ site.reset
27
+ Bridgetown.logger.info "Reading files..."
28
+ site.read
29
+ Bridgetown.logger.info "", "done!"
30
+ Bridgetown.logger.info "Running generators..."
31
+ site.generate
32
+ Bridgetown.logger.info "", "done!"
33
+ end
34
+ end
35
+
4
36
  module Commands
5
37
  class Console < Thor::Group
6
38
  extend Summarizable
@@ -37,24 +69,18 @@ module Bridgetown
37
69
  Bridgetown.logger.info "Environment:", Bridgetown.environment.cyan
38
70
  site = Bridgetown::Site.new(configuration_with_overrides(options))
39
71
 
40
- unless options[:blank]
41
- site.reset
42
- Bridgetown.logger.info "Reading files..."
43
- site.read
44
- Bridgetown.logger.info "", "done!"
45
- Bridgetown.logger.info "Running generators..."
46
- site.generate
47
- Bridgetown.logger.info "", "done!"
48
- end
72
+ ConsoleMethods.site_reset(site) unless options[:blank]
49
73
 
50
- $BRIDGETOWN_SITE = site
74
+ IRB::ExtendCommandBundle.include ConsoleMethods
51
75
  IRB.setup(nil)
52
76
  workspace = IRB::WorkSpace.new
53
77
  irb = IRB::Irb.new(workspace)
54
78
  IRB.conf[:IRB_RC]&.call(irb.context)
55
79
  IRB.conf[:MAIN_CONTEXT] = irb.context
56
- eval("site = $BRIDGETOWN_SITE", workspace.binding, __FILE__, __LINE__)
57
- Bridgetown.logger.info "Console:", "Now loaded as #{"site".cyan} variable."
80
+ Bridgetown.logger.info "Console:", "Your site is now available as #{"site".cyan}"
81
+ Bridgetown.logger.info "",
82
+ "You can also access #{"collections".cyan} or perform a" \
83
+ " #{"reload!".cyan}"
58
84
 
59
85
  trap("SIGINT") do
60
86
  irb.signal_handle
@@ -57,8 +57,7 @@ module Bridgetown
57
57
  def conflicting_urls(site)
58
58
  conflicting_urls = false
59
59
  urls = {}
60
- urls = collect_urls(urls, site.pages, site.dest)
61
- urls = collect_urls(urls, site.collections.posts.docs, site.dest)
60
+ urls = collect_urls(urls, site.contents, site.dest)
62
61
  urls.each do |url, paths|
63
62
  next unless paths.size > 1
64
63
 
@@ -98,7 +97,11 @@ module Bridgetown
98
97
 
99
98
  def collect_urls(urls, things, destination)
100
99
  things.each do |thing|
101
- dest = thing.destination(destination)
100
+ dest = if thing.method(:destination).arity == 1
101
+ thing.destination(destination)
102
+ else
103
+ thing.destination
104
+ end
102
105
  if urls[dest]
103
106
  urls[dest] << thing.path
104
107
  else
@@ -110,8 +113,8 @@ module Bridgetown
110
113
 
111
114
  def case_insensitive_urls(things, _destination)
112
115
  things.each_with_object({}) do |thing, memo|
113
- dest = thing.destination.output_path
114
- (memo[dest.downcase] ||= []) << dest
116
+ dest = thing.destination&.output_path
117
+ (memo[dest.downcase] ||= []) << dest if dest
115
118
  end
116
119
  end
117
120
 
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "serbea"
4
+ require "rouge/lexers/serbea"
5
+
6
+ module Bridgetown
7
+ class SerbeaView < ERBView
8
+ include Serbea::Helpers
9
+
10
+ def partial(partial_name, options = {}, &block)
11
+ options.merge!(options[:locals]) if options[:locals]
12
+ options[:content] = capture(&block) if block
13
+
14
+ partial_segments = partial_name.split("/")
15
+ partial_segments.last.sub!(%r!^!, "_")
16
+ partial_name = partial_segments.join("/")
17
+
18
+ Tilt::SerbeaTemplate.new(
19
+ site.in_source_dir(site.config[:partials_dir], "#{partial_name}.serb")
20
+ ).render(self, options)
21
+ end
22
+ end
23
+
24
+ module Converters
25
+ class SerbeaTemplates < Converter
26
+ priority :highest
27
+ input :serb
28
+
29
+ # Logic to do the Serbea content conversion.
30
+ #
31
+ # @param content [String] Content of the file (without front matter).
32
+ # @param convertible [
33
+ # Bridgetown::GeneratedPage, Bridgetown::Resource::Base, Bridgetown::Layout]
34
+ # The instantiated object which is processing the file.
35
+ #
36
+ # @return [String] The converted content.
37
+ def convert(content, convertible)
38
+ return content if convertible.data[:template_engine].to_s != "serbea"
39
+
40
+ serb_view = Bridgetown::SerbeaView.new(convertible)
41
+
42
+ serb_renderer = Tilt::SerbeaTemplate.new(convertible.relative_path) { content }
43
+
44
+ if convertible.is_a?(Bridgetown::Layout)
45
+ serb_renderer.render(serb_view) do
46
+ convertible.current_document_output
47
+ end
48
+ else
49
+ serb_renderer.render(serb_view)
50
+ end
51
+ end
52
+
53
+ def matches(ext, convertible)
54
+ if convertible.data[:template_engine].to_s == "serbea" ||
55
+ (convertible.data[:template_engine].nil? &&
56
+ @config[:template_engine].to_s == "serbea")
57
+ convertible.data[:template_engine] = "serbea"
58
+ return true
59
+ end
60
+
61
+ super(ext).tap do |ext_matches|
62
+ convertible.data[:template_engine] = "serbea" if ext_matches
63
+ end
64
+ end
65
+
66
+ def output_ext(ext)
67
+ ext == ".serb" ? ".html" : ext
68
+ end
69
+ end
70
+ end
71
+ end
@@ -31,9 +31,7 @@ module Bridgetown
31
31
  raise Liquid::FileSystemError, "No such template '#{template_path}'" if found_paths.empty?
32
32
 
33
33
  # Last path in the list wins
34
- LiquidComponent.parse(
35
- ::File.read(found_paths.last, **site.file_read_opts)
36
- ).content
34
+ ::File.read(found_paths.last, **site.file_read_opts)
37
35
  end
38
36
  end
39
37
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bridgetown
4
- VERSION = "1.0.0.alpha8"
4
+ VERSION = "1.0.0.alpha9"
5
5
  CODE_NAME = "Pearl"
6
6
  end
@@ -46,7 +46,6 @@ require "active_support/descendants_tracker"
46
46
  require "hash_with_dot_access"
47
47
  require "addressable/uri"
48
48
  require "liquid"
49
- require "liquid-component"
50
49
  require "listen"
51
50
  require "kramdown"
52
51
  require "colorator"
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: 1.0.0.alpha8
4
+ version: 1.0.0.alpha9
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-11-05 00:00:00.000000000 Z
11
+ date: 2021-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -192,20 +192,6 @@ dependencies:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
194
  version: '5.0'
195
- - !ruby/object:Gem::Dependency
196
- name: liquid-component
197
- requirement: !ruby/object:Gem::Requirement
198
- requirements:
199
- - - ">="
200
- - !ruby/object:Gem::Version
201
- version: '0.1'
202
- type: :runtime
203
- prerelease: false
204
- version_requirements: !ruby/object:Gem::Requirement
205
- requirements:
206
- - - ">="
207
- - !ruby/object:Gem::Version
208
- version: '0.1'
209
195
  - !ruby/object:Gem::Dependency
210
196
  name: listen
211
197
  requirement: !ruby/object:Gem::Requirement
@@ -276,6 +262,20 @@ dependencies:
276
262
  - - "~>"
277
263
  - !ruby/object:Gem::Version
278
264
  version: '3.0'
265
+ - !ruby/object:Gem::Dependency
266
+ name: serbea
267
+ requirement: !ruby/object:Gem::Requirement
268
+ requirements:
269
+ - - "~>"
270
+ - !ruby/object:Gem::Version
271
+ version: '1.0'
272
+ type: :runtime
273
+ prerelease: false
274
+ version_requirements: !ruby/object:Gem::Requirement
275
+ requirements:
276
+ - - "~>"
277
+ - !ruby/object:Gem::Version
278
+ version: '1.0'
279
279
  - !ruby/object:Gem::Dependency
280
280
  name: terminal-table
281
281
  requirement: !ruby/object:Gem::Requirement
@@ -418,6 +418,7 @@ files:
418
418
  - lib/bridgetown-core/converters/markdown.rb
419
419
  - lib/bridgetown-core/converters/markdown/kramdown_parser.rb
420
420
  - lib/bridgetown-core/converters/ruby_templates.rb
421
+ - lib/bridgetown-core/converters/serbea_templates.rb
421
422
  - lib/bridgetown-core/converters/smartypants.rb
422
423
  - lib/bridgetown-core/core_ext/psych.rb
423
424
  - lib/bridgetown-core/current.rb