bridgetown-core 0.18.3 → 0.19.1

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: aff1b7af860afa9442e9a9cc6f34b0dd48fa6677248a118acc794a60de6f6328
4
- data.tar.gz: 3cfc657c9c5958cdf45cddf6bac5b1c84de276a8b10000b6b7a4c28d977f4ec1
3
+ metadata.gz: 0f0497ddff13959e277afd7d937fc399ddd660154df97b511846919f1aaedf73
4
+ data.tar.gz: 1f623861feeb1404e1abfac2a4f60354eb57dffe73b32797b4440fba993a3aeb
5
5
  SHA512:
6
- metadata.gz: ab2136623a924cead3223313b7ccd2cf46ffcc3c1c34de6096162d309e7e91ae2e1ce7af61abba4bc564cef67906977efead5780a27e5c4c407f14c2250e591e
7
- data.tar.gz: 0a6a770a52c1d23906c5bfbe7fc45a60666dcdb25359eb184585594d94ef4de9ef97c4587b4272a3dc95f1a3a2bdeb8b9327ab92b621a0a9672e3ec33aeb7b83
6
+ metadata.gz: aaafe152fc932d7a34c328210b8c2f121367c17c1d03a79c0e80911c55e1db178ccdeacd705c2ee73e936a304e442a4faab57142787cd558c4cf0b3eb5caedfe
7
+ data.tar.gz: dfd72e5a7e482ab18fb2d5f8e4e7eebc2461bc5904a978a59ae2125324280359150092c12dda49b9e3bfbdbe46ec0b9a25a9c2328311a746956d4706cb731abb
@@ -5,6 +5,12 @@ STDOUT.sync = true
5
5
 
6
6
  $LOAD_PATH.unshift File.expand_path("../../bridgetown/lib", __dir__)
7
7
 
8
+ # Used by commands/automations
9
+ require "active_support"
10
+ require "active_support/core_ext/array/extract_options"
11
+ require "active_support/core_ext/string/strip"
12
+ require "active_support/core_ext/string/indent"
13
+
8
14
  require "bridgetown"
9
15
 
10
16
  Bridgetown::PluginManager.require_from_bundler
@@ -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
 
@@ -1,10 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Mostly not used here, but may come in handy in new automations
4
- require "active_support/core_ext/array/extract_options"
5
- require "active_support/core_ext/string/strip"
6
- require "active_support/core_ext/string/indent"
7
-
8
3
  module Bridgetown
9
4
  module Commands
10
5
  module Actions
@@ -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
@@ -26,6 +26,7 @@ module Bridgetown
26
26
  return content if convertible.data[:template_engine] != "liquid"
27
27
 
28
28
  self.class.cached_partials ||= {}
29
+ @payload = nil
29
30
 
30
31
  @site = convertible.site
31
32
  if convertible.is_a?(Bridgetown::Layout)
@@ -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.3"
5
- CODE_NAME = "Taylor Street"
4
+ VERSION = "0.19.1"
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.3
4
+ version: 0.19.1
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-11-01 00:00:00.000000000 Z
11
+ date: 2020-12-26 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!")