bridgetown-core 0.19.2 → 0.21.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bridgetown-core.gemspec +1 -2
- data/lib/bridgetown-core.rb +37 -29
- data/lib/bridgetown-core/cleaner.rb +9 -3
- data/lib/bridgetown-core/collection.rb +177 -78
- data/lib/bridgetown-core/commands/base.rb +9 -0
- data/lib/bridgetown-core/commands/build.rb +0 -11
- data/lib/bridgetown-core/commands/concerns/git_helpers.rb +20 -0
- data/lib/bridgetown-core/commands/configure.rb +8 -3
- data/lib/bridgetown-core/commands/console.rb +4 -0
- data/lib/bridgetown-core/commands/doctor.rb +1 -19
- data/lib/bridgetown-core/commands/new.rb +2 -2
- data/lib/bridgetown-core/commands/plugins.rb +14 -13
- data/lib/bridgetown-core/commands/serve.rb +0 -14
- data/lib/bridgetown-core/component.rb +178 -0
- data/lib/bridgetown-core/concerns/data_accessible.rb +1 -0
- data/lib/bridgetown-core/concerns/front_matter_importer.rb +52 -0
- data/lib/bridgetown-core/concerns/site/configurable.rb +10 -10
- data/lib/bridgetown-core/concerns/site/content.rb +56 -15
- data/lib/bridgetown-core/concerns/site/localizable.rb +3 -5
- data/lib/bridgetown-core/concerns/site/processable.rb +6 -4
- data/lib/bridgetown-core/concerns/site/renderable.rb +26 -0
- data/lib/bridgetown-core/concerns/site/writable.rb +12 -2
- data/lib/bridgetown-core/concerns/validatable.rb +2 -5
- data/lib/bridgetown-core/configuration.rb +51 -30
- data/lib/bridgetown-core/configurations/bt-postcss.rb +1 -3
- data/lib/bridgetown-core/configurations/netlify.rb +1 -0
- data/lib/bridgetown-core/configurations/tailwindcss.rb +1 -3
- data/lib/bridgetown-core/converter.rb +23 -0
- data/lib/bridgetown-core/converters/erb_templates.rb +51 -35
- data/lib/bridgetown-core/converters/identity.rb +0 -9
- data/lib/bridgetown-core/converters/liquid_templates.rb +1 -1
- data/lib/bridgetown-core/converters/markdown.rb +14 -4
- data/lib/bridgetown-core/converters/markdown/kramdown_parser.rb +5 -38
- data/lib/bridgetown-core/converters/ruby_templates.rb +17 -0
- data/lib/bridgetown-core/converters/smartypants.rb +3 -1
- data/lib/bridgetown-core/core_ext/psych.rb +19 -0
- data/lib/bridgetown-core/current.rb +10 -0
- data/lib/bridgetown-core/document.rb +9 -16
- data/lib/bridgetown-core/drops/collection_drop.rb +1 -1
- data/lib/bridgetown-core/drops/page_drop.rb +4 -0
- data/lib/bridgetown-core/drops/relations_drop.rb +23 -0
- data/lib/bridgetown-core/drops/resource_drop.rb +83 -0
- data/lib/bridgetown-core/drops/site_drop.rb +33 -8
- data/lib/bridgetown-core/drops/unified_payload_drop.rb +5 -0
- data/lib/bridgetown-core/entry_filter.rb +17 -28
- data/lib/bridgetown-core/errors.rb +0 -2
- data/lib/bridgetown-core/filters.rb +3 -26
- data/lib/bridgetown-core/filters/from_liquid.rb +23 -0
- data/lib/bridgetown-core/filters/url_filters.rb +12 -0
- data/lib/bridgetown-core/frontmatter_defaults.rb +1 -1
- data/lib/bridgetown-core/generators/prototype_generator.rb +37 -19
- data/lib/bridgetown-core/helpers.rb +48 -9
- data/lib/bridgetown-core/layout.rb +28 -13
- data/lib/bridgetown-core/liquid_renderer/file.rb +1 -0
- data/lib/bridgetown-core/liquid_renderer/table.rb +1 -0
- data/lib/bridgetown-core/model/base.rb +138 -0
- data/lib/bridgetown-core/model/builder_origin.rb +40 -0
- data/lib/bridgetown-core/model/origin.rb +38 -0
- data/lib/bridgetown-core/model/repo_origin.rb +126 -0
- data/lib/bridgetown-core/page.rb +11 -2
- data/lib/bridgetown-core/plugin_manager.rb +1 -3
- data/lib/bridgetown-core/publisher.rb +8 -2
- data/lib/bridgetown-core/reader.rb +37 -22
- data/lib/bridgetown-core/readers/data_reader.rb +5 -5
- data/lib/bridgetown-core/readers/defaults_reader.rb +1 -1
- data/lib/bridgetown-core/readers/page_reader.rb +1 -0
- data/lib/bridgetown-core/readers/post_reader.rb +5 -4
- data/lib/bridgetown-core/regenerator.rb +9 -2
- data/lib/bridgetown-core/related_posts.rb +9 -6
- data/lib/bridgetown-core/renderer.rb +6 -13
- data/lib/bridgetown-core/resource/base.rb +313 -0
- data/lib/bridgetown-core/resource/destination.rb +49 -0
- data/lib/bridgetown-core/resource/permalink_processor.rb +179 -0
- data/lib/bridgetown-core/resource/relations.rb +132 -0
- data/lib/bridgetown-core/resource/taxonomy_term.rb +34 -0
- data/lib/bridgetown-core/resource/taxonomy_type.rb +56 -0
- data/lib/bridgetown-core/resource/transformer.rb +177 -0
- data/lib/bridgetown-core/ruby_template_view.rb +11 -11
- data/lib/bridgetown-core/site.rb +13 -6
- data/lib/bridgetown-core/static_file.rb +33 -10
- data/lib/bridgetown-core/tags/highlight.rb +2 -15
- data/lib/bridgetown-core/tags/include.rb +1 -1
- data/lib/bridgetown-core/tags/post_url.rb +2 -2
- data/lib/bridgetown-core/url.rb +1 -0
- data/lib/bridgetown-core/utils.rb +49 -43
- data/lib/bridgetown-core/utils/require_gems.rb +60 -0
- data/lib/bridgetown-core/utils/ruby_exec.rb +6 -9
- data/lib/bridgetown-core/utils/ruby_front_matter.rb +39 -0
- data/lib/bridgetown-core/version.rb +2 -2
- data/lib/bridgetown-core/watcher.rb +1 -1
- data/lib/bridgetown-core/yaml_parser.rb +22 -0
- data/lib/site_template/package.json.erb +2 -2
- data/lib/site_template/plugins/site_builder.rb +1 -1
- data/lib/site_template/src/_posts/0000-00-00-welcome-to-bridgetown.md.erb +1 -1
- data/lib/site_template/webpack.config.js.erb +26 -6
- metadata +39 -40
- data/lib/bridgetown-core/external.rb +0 -58
- data/lib/bridgetown-core/page_without_a_file.rb +0 -17
- data/lib/bridgetown-core/path_manager.rb +0 -31
- data/lib/bridgetown-core/readers/collection_reader.rb +0 -23
- data/lib/bridgetown-core/readers/static_file_reader.rb +0 -25
- data/lib/bridgetown-core/utils/exec.rb +0 -26
- data/lib/bridgetown-core/utils/internet.rb +0 -37
- data/lib/bridgetown-core/utils/platforms.rb +0 -80
- data/lib/bridgetown-core/utils/thread_event.rb +0 -31
- data/lib/bridgetown-core/utils/win_tz.rb +0 -75
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Bridgetown
|
4
|
-
module Utils
|
5
|
-
# Based on the pattern and code from
|
6
|
-
# https://emptysqua.re/blog/an-event-synchronization-primitive-for-ruby/
|
7
|
-
class ThreadEvent
|
8
|
-
attr_reader :flag
|
9
|
-
|
10
|
-
def initialize
|
11
|
-
@lock = Mutex.new
|
12
|
-
@cond = ConditionVariable.new
|
13
|
-
@flag = false
|
14
|
-
end
|
15
|
-
|
16
|
-
def set
|
17
|
-
@lock.synchronize do
|
18
|
-
yield if block_given?
|
19
|
-
@flag = true
|
20
|
-
@cond.broadcast
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def wait
|
25
|
-
@lock.synchronize do
|
26
|
-
@cond.wait(@lock) unless @flag
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,75 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Bridgetown
|
4
|
-
module Utils
|
5
|
-
module WinTZ
|
6
|
-
extend self
|
7
|
-
|
8
|
-
# Public: Calculate the Timezone for Windows when the config file has a defined
|
9
|
-
# 'timezone' key.
|
10
|
-
#
|
11
|
-
# timezone - the IANA Time Zone specified in "_config.yml"
|
12
|
-
#
|
13
|
-
# Returns a string that ultimately re-defines ENV["TZ"] in Windows
|
14
|
-
def calculate(timezone)
|
15
|
-
External.require_with_graceful_fail("tzinfo") unless defined?(TZInfo)
|
16
|
-
tz = TZInfo::Timezone.get(timezone)
|
17
|
-
difference = Time.now.to_i - tz.now.to_i
|
18
|
-
#
|
19
|
-
# POSIX style definition reverses the offset sign.
|
20
|
-
# e.g. Eastern Standard Time (EST) that is 5Hrs. to the 'west' of Prime Meridian
|
21
|
-
# is denoted as:
|
22
|
-
# EST+5 (or) EST+05:00
|
23
|
-
# Reference: http://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
|
24
|
-
sign = difference.negative? ? "-" : "+"
|
25
|
-
offset = sign == "-" ? "+" : "-" unless difference.zero?
|
26
|
-
#
|
27
|
-
# convert the difference (in seconds) to hours, as a rational number, and perform
|
28
|
-
# a modulo operation on it.
|
29
|
-
modulo = modulo_of(rational_hour(difference))
|
30
|
-
#
|
31
|
-
# Format the hour as a two-digit number.
|
32
|
-
# Establish the minutes based on modulo expression.
|
33
|
-
hh = format("%<hour>02d", hour: absolute_hour(difference).ceil)
|
34
|
-
mm = modulo.zero? ? "00" : "30"
|
35
|
-
|
36
|
-
Bridgetown.logger.debug "Timezone:", "#{timezone} #{offset}#{hh}:#{mm}"
|
37
|
-
#
|
38
|
-
# Note: The 3-letter-word below doesn't have a particular significance.
|
39
|
-
"WTZ#{sign}#{hh}:#{mm}"
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
# Private: Convert given seconds to an hour as a rational number.
|
45
|
-
#
|
46
|
-
# seconds - supplied as an integer, it is converted to a rational number.
|
47
|
-
# 3600 - no. of seconds in an hour.
|
48
|
-
#
|
49
|
-
# Returns a rational number.
|
50
|
-
def rational_hour(seconds)
|
51
|
-
seconds.to_r / 3600
|
52
|
-
end
|
53
|
-
|
54
|
-
# Private: Convert given seconds to an hour as an absolute number.
|
55
|
-
#
|
56
|
-
# seconds - supplied as an integer, it is converted to its absolute.
|
57
|
-
# 3600 - no. of seconds in an hour.
|
58
|
-
#
|
59
|
-
# Returns an integer.
|
60
|
-
def absolute_hour(seconds)
|
61
|
-
seconds.abs / 3600
|
62
|
-
end
|
63
|
-
|
64
|
-
# Private: Perform a modulo operation on a given fraction.
|
65
|
-
#
|
66
|
-
# fraction - supplied as a rational number, its numerator is divided
|
67
|
-
# by its denominator and the remainder returned.
|
68
|
-
#
|
69
|
-
# Returns an integer.
|
70
|
-
def modulo_of(fraction)
|
71
|
-
fraction.numerator % fraction.denominator
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|