bridgetown-core 0.18.6 → 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/bin/bridgetown +6 -0
  3. data/bridgetown-core.gemspec +4 -4
  4. data/lib/bridgetown-core.rb +46 -13
  5. data/lib/bridgetown-core/cleaner.rb +7 -1
  6. data/lib/bridgetown-core/collection.rb +173 -77
  7. data/lib/bridgetown-core/commands/apply.rb +4 -3
  8. data/lib/bridgetown-core/commands/base.rb +9 -0
  9. data/lib/bridgetown-core/commands/concerns/actions.rb +0 -5
  10. data/lib/bridgetown-core/commands/configure.rb +66 -0
  11. data/lib/bridgetown-core/commands/console.rb +4 -0
  12. data/lib/bridgetown-core/commands/new.rb +28 -1
  13. data/lib/bridgetown-core/commands/plugins.rb +1 -0
  14. data/lib/bridgetown-core/concerns/data_accessible.rb +1 -0
  15. data/lib/bridgetown-core/concerns/site/configurable.rb +7 -3
  16. data/lib/bridgetown-core/concerns/site/content.rb +57 -15
  17. data/lib/bridgetown-core/concerns/site/processable.rb +1 -0
  18. data/lib/bridgetown-core/concerns/site/renderable.rb +26 -0
  19. data/lib/bridgetown-core/concerns/site/writable.rb +11 -1
  20. data/lib/bridgetown-core/concerns/validatable.rb +1 -0
  21. data/lib/bridgetown-core/configuration.rb +39 -19
  22. data/lib/bridgetown-core/configurations/.keep +0 -0
  23. data/lib/bridgetown-core/configurations/bt-postcss.rb +26 -0
  24. data/lib/bridgetown-core/configurations/bt-postcss/postcss.config.js +21 -0
  25. data/lib/bridgetown-core/configurations/minitesting.rb +95 -0
  26. data/lib/bridgetown-core/configurations/netlify.rb +6 -0
  27. data/lib/bridgetown-core/configurations/netlify/netlify.sh +14 -0
  28. data/lib/bridgetown-core/configurations/netlify/netlify.toml +44 -0
  29. data/lib/bridgetown-core/configurations/purgecss.rb +49 -0
  30. data/lib/bridgetown-core/configurations/stimulus.rb +49 -0
  31. data/lib/bridgetown-core/configurations/swup.rb +37 -0
  32. data/lib/bridgetown-core/configurations/tailwindcss.rb +29 -0
  33. data/lib/bridgetown-core/configurations/tailwindcss/css_imports.css +4 -0
  34. data/lib/bridgetown-core/configurations/tailwindcss/postcss.config.js +12 -0
  35. data/lib/bridgetown-core/configurations/turbo.rb +16 -0
  36. data/lib/bridgetown-core/converter.rb +14 -0
  37. data/lib/bridgetown-core/converters/erb_templates.rb +6 -13
  38. data/lib/bridgetown-core/converters/identity.rb +0 -9
  39. data/lib/bridgetown-core/converters/markdown.rb +14 -4
  40. data/lib/bridgetown-core/converters/markdown/kramdown_parser.rb +3 -0
  41. data/lib/bridgetown-core/current.rb +10 -0
  42. data/lib/bridgetown-core/document.rb +6 -14
  43. data/lib/bridgetown-core/drops/collection_drop.rb +1 -1
  44. data/lib/bridgetown-core/drops/page_drop.rb +4 -0
  45. data/lib/bridgetown-core/drops/resource_drop.rb +81 -0
  46. data/lib/bridgetown-core/drops/site_drop.rb +33 -8
  47. data/lib/bridgetown-core/drops/unified_payload_drop.rb +4 -0
  48. data/lib/bridgetown-core/entry_filter.rb +10 -23
  49. data/lib/bridgetown-core/errors.rb +0 -2
  50. data/lib/bridgetown-core/filters.rb +4 -3
  51. data/lib/bridgetown-core/generator.rb +2 -1
  52. data/lib/bridgetown-core/generators/prototype_generator.rb +37 -19
  53. data/lib/bridgetown-core/layout.rb +2 -2
  54. data/lib/bridgetown-core/liquid_renderer/file.rb +1 -0
  55. data/lib/bridgetown-core/liquid_renderer/table.rb +1 -0
  56. data/lib/bridgetown-core/model/base.rb +138 -0
  57. data/lib/bridgetown-core/model/builder_origin.rb +40 -0
  58. data/lib/bridgetown-core/model/file_origin.rb +119 -0
  59. data/lib/bridgetown-core/model/origin.rb +38 -0
  60. data/lib/bridgetown-core/page.rb +9 -1
  61. data/lib/bridgetown-core/plugin.rb +2 -26
  62. data/lib/bridgetown-core/plugin_manager.rb +0 -2
  63. data/lib/bridgetown-core/publisher.rb +7 -1
  64. data/lib/bridgetown-core/reader.rb +25 -12
  65. data/lib/bridgetown-core/readers/data_reader.rb +3 -4
  66. data/lib/bridgetown-core/readers/post_reader.rb +1 -1
  67. data/lib/bridgetown-core/regenerator.rb +8 -1
  68. data/lib/bridgetown-core/related_posts.rb +1 -1
  69. data/lib/bridgetown-core/renderer.rb +5 -12
  70. data/lib/bridgetown-core/resource/base.rb +275 -0
  71. data/lib/bridgetown-core/resource/destination.rb +49 -0
  72. data/lib/bridgetown-core/resource/permalink_processor.rb +179 -0
  73. data/lib/bridgetown-core/resource/taxonomy_term.rb +25 -0
  74. data/lib/bridgetown-core/resource/taxonomy_type.rb +47 -0
  75. data/lib/bridgetown-core/resource/transformer.rb +173 -0
  76. data/lib/bridgetown-core/ruby_template_view.rb +13 -2
  77. data/lib/bridgetown-core/site.rb +9 -1
  78. data/lib/bridgetown-core/static_file.rb +33 -10
  79. data/lib/bridgetown-core/url.rb +1 -0
  80. data/lib/bridgetown-core/utils.rb +40 -40
  81. data/lib/bridgetown-core/utils/platforms.rb +1 -0
  82. data/lib/bridgetown-core/version.rb +2 -2
  83. data/lib/site_template/README.md +70 -0
  84. data/lib/site_template/frontend/javascript/index.js.erb +11 -0
  85. data/lib/site_template/frontend/styles/index.css +19 -0
  86. data/lib/site_template/{package.json → package.json.erb} +14 -8
  87. data/lib/site_template/postcss.config.js.erb +11 -0
  88. data/lib/site_template/src/_components/footer.liquid +1 -1
  89. data/lib/site_template/src/_posts/0000-00-00-welcome-to-bridgetown.md.erb +1 -1
  90. data/lib/site_template/{webpack.config.js → webpack.config.js.erb} +47 -5
  91. metadata +67 -42
  92. data/lib/bridgetown-core/page_without_a_file.rb +0 -14
  93. data/lib/bridgetown-core/readers/collection_reader.rb +0 -23
  94. data/lib/bridgetown-core/utils/exec.rb +0 -26
  95. data/lib/bridgetown-core/utils/internet.rb +0 -37
  96. data/lib/bridgetown-core/utils/win_tz.rb +0 -75
  97. data/lib/site_template/frontend/javascript/index.js +0 -3
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Bridgetown
4
- # A Bridgetown::Page subclass to handle processing files without reading it to
5
- # determine the page-data and page-content based on Front Matter delimiters.
6
- #
7
- # The class instance is basically just a bare-bones entity with just
8
- # attributes "dir", "name", "path", "url" defined on it.
9
- class PageWithoutAFile < Page
10
- def read_yaml(*)
11
- @data ||= {}
12
- end
13
- end
14
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Bridgetown
4
- class CollectionReader
5
- SPECIAL_COLLECTIONS = %w(posts data).freeze
6
-
7
- attr_reader :site, :content
8
-
9
- def initialize(site)
10
- @site = site
11
- @content = {}
12
- end
13
-
14
- # Read in all collections specified in the configuration
15
- #
16
- # Returns nothing.
17
- def read
18
- site.collections.each_value do |collection|
19
- collection.read unless SPECIAL_COLLECTIONS.include?(collection.label)
20
- end
21
- end
22
- end
23
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "open3"
4
-
5
- module Bridgetown
6
- module Utils
7
- module Exec
8
- extend self
9
-
10
- # Runs a program in a sub-shell.
11
- #
12
- # *args - a list of strings containing the program name and arguments
13
- #
14
- # Returns a Process::Status and a String of output in an array in
15
- # that order.
16
- def run(*args)
17
- stdin, stdout, stderr, process = Open3.popen3(*args)
18
- out = stdout.read.strip
19
- err = stderr.read.strip
20
-
21
- [stdin, stdout, stderr].each(&:close)
22
- [process.value, out + err]
23
- end
24
- end
25
- end
26
- end
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Bridgetown
4
- module Utils
5
- module Internet
6
- # Public: Determine whether the present device has a connection to
7
- # the Internet. This allows plugin writers which require the outside
8
- # world to have a neat fallback mechanism for offline building.
9
- #
10
- # Example:
11
- # if Internet.connected?
12
- # Typhoeus.get("https://pages.github.com/versions.json")
13
- # else
14
- # Bridgetown.logger.warn "Warning:", "Version check has been disabled."
15
- # Bridgetown.logger.warn "", "Connect to the Internet to enable it."
16
- # nil
17
- # end
18
- #
19
- # Returns true if a DNS call can successfully be made, or false if not.
20
-
21
- module_function
22
-
23
- def connected?
24
- !dns("example.com").nil?
25
- end
26
-
27
- def dns(domain)
28
- require "resolv"
29
- Resolv::DNS.open do |resolver|
30
- resolver.getaddress(domain)
31
- end
32
- rescue Resolv::ResolvError, Resolv::ResolvTimeout
33
- nil
34
- end
35
- end
36
- end
37
- 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
@@ -1,3 +0,0 @@
1
- import "../styles/index.scss"
2
-
3
- console.info("Bridgetown is loaded!")