bridgetown-core 0.18.2 → 0.19.0

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: 306a26e30d93c885f8e9580f31df3f10757b8d686337ac851a33c354689be225
4
- data.tar.gz: 2e258edc76ea89224865c9cbc48d9ae5fcd9dacd2070d99953c6f567644237ac
3
+ metadata.gz: 5a0a5aeb69553f660c93b0f0a4026696fb075fbbaee350dab4591d43efc2268d
4
+ data.tar.gz: 97a706bb02102be600a8b5462612249c2ee4cf366ee5f994b70c6047f7746c00
5
5
  SHA512:
6
- metadata.gz: 9a03b2aaabcf0066e0cb634c95f9b5819db23b472887e1048b78e589c9815615986ed8bb943b77f8d272221448608a95f489d6db21508703dbf3123ec31623a1
7
- data.tar.gz: 2fc8d22203172c03db70520f430292833360c0eb39c91dde1a8d17d498c726295a8bc7183310468f981e5d236fa31a26fc3a564beb6e8179922d3975db6f876e
6
+ metadata.gz: bb0ce9658edcf29ecd07cab05c0b3dd97cac66d710d7447257e16ce1df584d9257cd4cb9d0aaadac54a829918084ef00c90540d0b97d3437d4467719b8052130
7
+ data.tar.gz: d051bf13d11a911562854c3190a206c0a6b2b6c824be1ecf2786dde0766eb25b1fef8d0910b13795a574d2945bacbe175f818d85e68b52676788639285eec778
@@ -52,4 +52,5 @@ Gem::Specification.new do |s|
52
52
  s.add_runtime_dependency("terminal-table", "~> 1.8")
53
53
  s.add_runtime_dependency("thor", "~> 1.0")
54
54
  s.add_runtime_dependency("tilt", "~> 2.0")
55
+ s.add_runtime_dependency("webrick", "~> 1.7")
55
56
  end
@@ -29,8 +29,12 @@ require "csv"
29
29
  require "json"
30
30
 
31
31
  # 3rd party
32
+ require "active_support"
33
+ require "active_support/core_ext/hash/keys"
32
34
  require "active_support/core_ext/object/blank"
33
35
  require "active_support/core_ext/string/inflections"
36
+ require "active_support/core_ext/string/inquiry"
37
+ require "active_support/core_ext/string/starts_ends_with"
34
38
  require "hash_with_dot_access"
35
39
  require "pathutil"
36
40
  require "addressable/uri"
@@ -44,12 +48,30 @@ require "i18n"
44
48
  require "faraday"
45
49
  require "thor"
46
50
 
51
+ module HashWithDotAccess
52
+ class Hash # :nodoc:
53
+ def to_liquid
54
+ to_h.to_liquid
55
+ end
56
+ end
57
+ end
58
+
47
59
  SafeYAML::OPTIONS[:suppress_warnings] = true
48
60
 
49
61
  # Create our little String subclass for Ruby Front Matter
50
62
  class Rb < String; end
51
63
  SafeYAML::OPTIONS[:whitelisted_tags] = ["!ruby/string:Rb"]
52
64
 
65
+ if RUBY_VERSION.start_with?("3.0")
66
+ # workaround for Ruby 3 preview 2, maybe can remove later
67
+ # rubocop:disable Style/GlobalVars
68
+ old_verbose = $VERBOSE
69
+ $VERBOSE = nil
70
+ SafeYAML::SafeToRubyVisitor.const_set(:INITIALIZE_ARITY, 2)
71
+ $verbose = old_verbose
72
+ # rubocop:enable Style/GlobalVars
73
+ end
74
+
53
75
  module Bridgetown
54
76
  # internal requires
55
77
  autoload :Cleaner, "bridgetown-core/cleaner"
@@ -118,7 +140,7 @@ module Bridgetown
118
140
  # Tells you which Bridgetown environment you are building in so
119
141
  # you can skip tasks if you need to.
120
142
  def environment
121
- ENV["BRIDGETOWN_ENV"] || "development"
143
+ (ENV["BRIDGETOWN_ENV"] || "development").inquiry
122
144
  end
123
145
  alias_method :env, :environment
124
146
 
@@ -28,6 +28,9 @@ module Bridgetown
28
28
  class_option :"skip-yarn",
29
29
  type: :boolean,
30
30
  desc: "Skip 'yarn install'"
31
+ class_option :"use-postcss",
32
+ type: :boolean,
33
+ desc: "Create an empty PostCSS configuration instead of using Sass"
31
34
 
32
35
  DOCSURL = "https://bridgetownrb.com/docs"
33
36
 
@@ -47,6 +50,8 @@ module Bridgetown
47
50
  raise ArgumentError, "You must specify a path." if args.empty?
48
51
 
49
52
  new_site_path = File.expand_path(args.join(" "), Dir.pwd)
53
+ @site_name = new_site_path.split(File::SEPARATOR).last
54
+
50
55
  if preserve_source_location?(new_site_path, options)
51
56
  say_status :conflict, "#{new_site_path} exists and is not empty.", :red
52
57
  Bridgetown.logger.abort_with "Ensure #{new_site_path} is empty or else " \
@@ -67,7 +72,7 @@ module Bridgetown
67
72
  end
68
73
 
69
74
  def create_site(new_site_path)
70
- directory ".", ".", exclude_pattern: %r!\.erb|DS_Store$!
75
+ directory ".", ".", exclude_pattern: %r!\.erb|DS_Store$|\.(s[ac]|c)ss$!
71
76
  FileUtils.chmod_R "u+w", new_site_path
72
77
 
73
78
  template(
@@ -75,6 +80,20 @@ module Bridgetown
75
80
  "src/_posts/#{Time.now.strftime("%Y-%m-%d")}-welcome-to-bridgetown.md"
76
81
  )
77
82
  template("Gemfile.erb", "Gemfile")
83
+ template("package.json.erb", "package.json")
84
+ template("webpack.config.js.erb", "webpack.config.js")
85
+ template("frontend/javascript/index.js.erb", "frontend/javascript/index.js")
86
+
87
+ options["use-postcss"] ? configure_postcss : configure_sass
88
+ end
89
+
90
+ def configure_sass
91
+ copy_file("frontend/styles/index.scss")
92
+ end
93
+
94
+ def configure_postcss
95
+ template("postcss.config.js.erb", "postcss.config.js")
96
+ copy_file("frontend/styles/index.css")
78
97
  end
79
98
 
80
99
  # After a new site has been created, print a success notification and
@@ -101,6 +101,8 @@ module Bridgetown
101
101
  #
102
102
  # @return [String] The converted content.
103
103
  def convert(content, convertible)
104
+ return content if convertible.data[:template_engine] != "erb"
105
+
104
106
  erb_view = Bridgetown::ERBView.new(convertible)
105
107
 
106
108
  erb_renderer = Tilt::ErubiTemplate.new(
@@ -123,10 +125,13 @@ module Bridgetown
123
125
  if convertible.data[:template_engine] == "erb" ||
124
126
  (convertible.data[:template_engine].nil? &&
125
127
  @config[:template_engine] == "erb")
128
+ convertible.data[:template_engine] = "erb"
126
129
  return true
127
130
  end
128
131
 
129
- super(ext)
132
+ super(ext).tap do |ext_matches|
133
+ convertible.data[:template_engine] = "erb" if ext_matches
134
+ end
130
135
  end
131
136
 
132
137
  def output_ext(ext)
@@ -23,7 +23,10 @@ module Bridgetown
23
23
  #
24
24
  # @return [String] The converted content.
25
25
  def convert(content, convertible)
26
+ return content if convertible.data[:template_engine] != "liquid"
27
+
26
28
  self.class.cached_partials ||= {}
29
+ @payload = nil
27
30
 
28
31
  @site = convertible.site
29
32
  if convertible.is_a?(Bridgetown::Layout)
@@ -53,9 +56,14 @@ module Bridgetown
53
56
  # rubocop: enable Metrics/AbcSize
54
57
 
55
58
  def matches(ext, convertible)
56
- return true if convertible.render_with_liquid?
59
+ if convertible.render_with_liquid?
60
+ convertible.data[:template_engine] = "liquid"
61
+ return true
62
+ end
57
63
 
58
- super(ext)
64
+ super(ext).tap do |ext_matches|
65
+ convertible.data[:template_engine] = "liquid" if ext_matches
66
+ end
59
67
  end
60
68
 
61
69
  def output_ext(ext)
@@ -126,8 +126,8 @@ module Bridgetown
126
126
  # @return [String] a link unreadable for bots but will be recovered on focus or mouseover
127
127
  def obfuscate_link(input, prefix = "mailto")
128
128
  link = "<a href=\"#{prefix}:#{input}\">#{input}</a>"
129
- script = "<script type=\"text/javascript\">document.currentScript.insertAdjacentHTML("
130
- script += "beforebegin', '#{rot47(link)}'.replace(/[!-~]/g,"
129
+ script = "<script type=\"text/javascript\">document.currentScript.insertAdjacentHTML('"
130
+ script += "beforebegin', '#{rot47(link).gsub(%r!\\!, '\\\\\\')}'.replace(/[!-~]/g,"
131
131
  script += "function(c){{var j=c.charCodeAt(0);if((j>=33)&&(j<=126)){"
132
132
  script += "return String.fromCharCode(33+((j+ 14)%94));}"
133
133
  script += "else{return String.fromCharCode(j);}}}));</script>"
@@ -7,6 +7,9 @@ module Bridgetown
7
7
  # The class instance is basically just a bare-bones entity with just
8
8
  # attributes "dir", "name", "path", "url" defined on it.
9
9
  class PageWithoutAFile < Page
10
+ Bridgetown.logger.warn "NOTICE: the PageWithoutAFile class is deprecated and" \
11
+ " will be removed in Bridgetown 0.20."
12
+
10
13
  def read_yaml(*)
11
14
  @data ||= {}
12
15
  end
@@ -6,7 +6,7 @@ module Bridgetown
6
6
 
7
7
  def initialize(site)
8
8
  @site = site
9
- @layouts = {}
9
+ @layouts = HashWithDotAccess::Hash.new
10
10
  end
11
11
 
12
12
  def read
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "digest"
4
- require "active_support/core_ext/hash/keys"
5
4
 
6
5
  module Bridgetown
7
6
  class RubyTemplateView
@@ -20,14 +20,14 @@ module Bridgetown
20
20
  v.each do |nested_k, nested_v|
21
21
  next unless nested_v.is_a?(Rb)
22
22
 
23
- Bridgetown.logger.warn("Executing inline Ruby…", convertible.relative_path)
23
+ Bridgetown.logger.debug("Executing inline Ruby…", convertible.relative_path)
24
24
  convertible.data[k][nested_k] = run(nested_v, convertible, renderer)
25
- Bridgetown.logger.warn("Inline Ruby completed!", convertible.relative_path)
25
+ Bridgetown.logger.debug("Inline Ruby completed!", convertible.relative_path)
26
26
  end
27
27
  else
28
- Bridgetown.logger.warn("Executing inline Ruby…", convertible.relative_path)
28
+ Bridgetown.logger.debug("Executing inline Ruby…", convertible.relative_path)
29
29
  convertible.data[k] = run(v, convertible, renderer)
30
- Bridgetown.logger.warn("Inline Ruby completed!", convertible.relative_path)
30
+ Bridgetown.logger.debug("Inline Ruby completed!", convertible.relative_path)
31
31
  end
32
32
  end
33
33
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bridgetown
4
- VERSION = "0.18.2"
5
- CODE_NAME = "Taylor Street"
4
+ VERSION = "0.19.0"
5
+ CODE_NAME = "Arbor Lodge"
6
6
  end
@@ -0,0 +1,11 @@
1
+ <% if options["use-postcss"] %>
2
+ import "index.css"
3
+ <% else %>
4
+ import "index.scss"
5
+ <% end %>
6
+
7
+ // Import all javascript files from src/_components
8
+ const componentsContext = require.context("bridgetownComponents", true, /.js$/)
9
+ componentsContext.keys().forEach(componentsContext)
10
+
11
+ console.info("Bridgetown is loaded!")
@@ -0,0 +1,19 @@
1
+ :root {
2
+ --body-background: #fafafa;
3
+ --body-color: #444;
4
+ }
5
+
6
+ body {
7
+ background: var(--body-background);
8
+ color: var(--body-color);
9
+ font-family: sans-serif;
10
+ }
11
+
12
+ h1, nav, footer {
13
+ text-align: center;
14
+ }
15
+
16
+ main {
17
+ margin: 4rem auto;
18
+ max-width: 60rem;
19
+ }
@@ -1,13 +1,14 @@
1
1
  {
2
- "name": "new-bridgetown-site",
2
+ "name": "<%= @site_name %>",
3
3
  "version": "1.0.0",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "build": "bundle exec bridgetown build",
7
7
  "serve": "bundle exec bridgetown serve",
8
+ "clean": "bundle exec bridgetown clean",
8
9
  "webpack-build": "webpack --mode production",
9
10
  "webpack-dev": "webpack --mode development -w",
10
- "deploy": "yarn webpack-build && yarn build",
11
+ "deploy": "yarn clean && yarn webpack-build && yarn build",
11
12
  "sync": "node sync.js",
12
13
  "start": "node start.js"
13
14
  },
@@ -20,14 +21,20 @@
20
21
  "babel-loader": "^8.1.0",
21
22
  "browser-sync": "^2.26.7",
22
23
  "concurrently": "^5.2.0",
23
- "css-loader": "^3.4.2",
24
- "file-loader": "^6.0.0",
25
- "mini-css-extract-plugin": "^0.9.0",
24
+ "css-loader": "^4.3.0",
25
+ "file-loader": "^6.2.0",
26
+ "mini-css-extract-plugin": "^1.3.1",
27
+ <% if options["use-postcss"] %>
28
+ "postcss": "^8.1.9",
29
+ "postcss-flexbugs-fixes": "^4.1.0",
30
+ "postcss-loader": "^4.1.0",
31
+ "postcss-preset-env": "^6.7.0",
32
+ <% else %>
26
33
  "node-sass": "^4.13.1",
27
- "sass-loader": "^8.0.2",
28
- "style-loader": "^1.1.3",
29
- "webpack": "^4.42.1",
34
+ "sass-loader": "^8.0.2",
35
+ <% end %>
36
+ "webpack": "^4.44.2",
30
37
  "webpack-cli": "^3.3.11",
31
- "webpack-manifest-plugin": "^2.2.0"
38
+ "webpack-manifest-plugin": "^2.1.0"
32
39
  }
33
40
  }
@@ -0,0 +1,11 @@
1
+ module.exports = {
2
+ plugins: {
3
+ 'postcss-flexbugs-fixes': {},
4
+ 'postcss-preset-env': {
5
+ autoprefixer: {
6
+ flexbox: 'no-2009'
7
+ },
8
+ stage: 3
9
+ }
10
+ }
11
+ }
@@ -1,3 +1,3 @@
1
1
  <footer>
2
- Contact me at {{ metadata.email }}
2
+ Contact me at <a href="mailto:{{ metadata.email }}">{{ metadata.email }}</a>
3
3
  </footer>
@@ -23,4 +23,4 @@ print_hi('Tom')
23
23
  #=> prints 'Hi, Tom' to STDOUT.
24
24
  ````
25
25
 
26
- Check out the [Bridgetown docs](https://bridgetownrb.com/docs/) for more info on how to get the most out of Bridgetown. File all bugs/feature requests at [Bridgetown’s GitHub repo](https://github.com/bridgetownrb/bridgetown). If you have questions, you can ask them on [Bridgetown Community Forum](https://community.bridgetownrb.com).
26
+ Check out the [Bridgetown docs](https://bridgetownrb.com/docs/) for more info on how to get the most out of Bridgetown. File all bugs/feature requests at [Bridgetown’s GitHub repo](https://github.com/bridgetownrb/bridgetown). If you have questions, you can ask them on [Bridgetown Discussions on GitHub](https://github.com/bridgetownrb/bridgetown/discussions).
@@ -18,6 +18,14 @@ module.exports = {
18
18
  },
19
19
  resolve: {
20
20
  extensions: [".js", ".jsx"],
21
+ modules: [
22
+ path.resolve(__dirname, 'frontend', 'javascript'),
23
+ path.resolve(__dirname, 'frontend', 'styles'),
24
+ path.resolve('./node_modules')
25
+ ],
26
+ alias: {
27
+ bridgetownComponents: path.resolve(__dirname, "src", "_components")
28
+ }
21
29
  },
22
30
  plugins: [
23
31
  new MiniCssExtractPlugin({
@@ -48,6 +56,21 @@ module.exports = {
48
56
  },
49
57
  },
50
58
  },
59
+ <% if options["use-postcss"] %>
60
+ {
61
+ test: /\.(s[ac]|c)ss$/,
62
+ use: [
63
+ MiniCssExtractPlugin.loader,
64
+ {
65
+ loader: "css-loader",
66
+ options: {
67
+ importLoaders: 1
68
+ }
69
+ },
70
+ "postcss-loader"
71
+ ],
72
+ },
73
+ <% else %>
51
74
  {
52
75
  test: /\.(s[ac]|c)ss$/,
53
76
  use: [
@@ -65,6 +88,7 @@ module.exports = {
65
88
  },
66
89
  ],
67
90
  },
91
+ <% end %>
68
92
  {
69
93
  test: /\.woff2?$|\.ttf$|\.eot$|\.svg$/,
70
94
  loader: "file-loader",
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.18.2
4
+ version: 0.19.0
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-10-30 00:00:00.000000000 Z
11
+ date: 2020-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -304,6 +304,20 @@ dependencies:
304
304
  - - "~>"
305
305
  - !ruby/object:Gem::Version
306
306
  version: '2.0'
307
+ - !ruby/object:Gem::Dependency
308
+ name: webrick
309
+ requirement: !ruby/object:Gem::Requirement
310
+ requirements:
311
+ - - "~>"
312
+ - !ruby/object:Gem::Version
313
+ version: '1.7'
314
+ type: :runtime
315
+ prerelease: false
316
+ version_requirements: !ruby/object:Gem::Requirement
317
+ requirements:
318
+ - - "~>"
319
+ - !ruby/object:Gem::Version
320
+ version: '1.7'
307
321
  description: Bridgetown is a Webpack-aware, Ruby-powered static site generator for
308
322
  the modern Jamstack era
309
323
  email: maintainers@bridgetownrb.com
@@ -435,11 +449,13 @@ files:
435
449
  - lib/site_template/.gitignore
436
450
  - lib/site_template/Gemfile.erb
437
451
  - lib/site_template/bridgetown.config.yml
438
- - lib/site_template/frontend/javascript/index.js
452
+ - lib/site_template/frontend/javascript/index.js.erb
453
+ - lib/site_template/frontend/styles/index.css
439
454
  - lib/site_template/frontend/styles/index.scss
440
- - lib/site_template/package.json
455
+ - lib/site_template/package.json.erb
441
456
  - lib/site_template/plugins/builders/.keep
442
457
  - lib/site_template/plugins/site_builder.rb
458
+ - lib/site_template/postcss.config.js.erb
443
459
  - lib/site_template/src/404.html
444
460
  - lib/site_template/src/_components/footer.liquid
445
461
  - lib/site_template/src/_components/head.liquid
@@ -457,7 +473,7 @@ files:
457
473
  - lib/site_template/src/posts.md
458
474
  - lib/site_template/start.js
459
475
  - lib/site_template/sync.js
460
- - lib/site_template/webpack.config.js
476
+ - lib/site_template/webpack.config.js.erb
461
477
  homepage: https://www.bridgetownrb.com
462
478
  licenses:
463
479
  - MIT
@@ -1,3 +0,0 @@
1
- import "../styles/index.scss"
2
-
3
- console.info("Bridgetown is loaded!")