bridgetown-inline-svg 1.0.0 → 1.1.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: b9624c29ddfe8b72346295787cc97fbc6826deb12968a62a220e52b01ceae484
4
- data.tar.gz: e69c862e4452c343de96a6d38e62ed7db4ab22df9f0e7c3205961d724234800c
3
+ metadata.gz: c3ab68b27ce5c6ea4b77ff2340e106747d674029911ee582d9ee6eaf0e5ee222
4
+ data.tar.gz: 3b8e527ff95606f74e10c42f99e80ae65769378bec2f69998060b514a4dd6baf
5
5
  SHA512:
6
- metadata.gz: 1bbdcea04c2ed84d83bc46c686453b5a8ab2facf4514c029d090cdc959a1d501aa0dc108f8723042181a62a730b93d5112e700a73eaf428d8a0e524ff0d45c03
7
- data.tar.gz: 130b6bfa5898d48d5b491732b7cb71fb89fab881ddf1564296b876bed05895dd23e78b30d7350faf6b267a8a54cbaaf8f0dae36d63c3a1849176401e6a8087a2
6
+ metadata.gz: df96ce63b617fe79b877c1a0b6ac08d2df0bc10464c57dab78fca651f2bbc813f34bb90e7c8a1b1efe38f42471e780ffc487513a0625d21c6d02e1000a95053f
7
+ data.tar.gz: f1d22d0f9ac90a71cf717e6b469fcfc51cb595f30b7bc0d6f9a42d16e5bb989c8d41667a2597c87e40f174e28014cf84284d54364244a868cc24bea9bbba34ec
@@ -1,4 +1,3 @@
1
1
  bump:
2
2
  file: lib/bridgetown-inline-svg/version.rb
3
- skip_ci: true
4
- message: "feat(release): :bookmark: Bump %{name} to %{version} %{skip_ci}"
3
+ message: "chore(release): :bookmark: Bump %{name} to %{version} [nodoc]"
@@ -0,0 +1,32 @@
1
+ name: Changelog
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ jobs:
8
+ changelog:
9
+ name: Changelog Entry Action
10
+ runs-on: ubuntu-latest
11
+ timeout-minutes: 4
12
+ if: "!contains(github.event.head_commit.message, '[nodoc]')"
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - uses: actions/setup-ruby@v1
16
+ with:
17
+ ruby-version: "2.7"
18
+ - name: Create local changes
19
+ run: |
20
+ gem install github_changelog_generator
21
+ github_changelog_generator -u andrewmcodes -p bridgetown-inline-svg --token ${{ secrets.GITHUB_TOKEN }}
22
+ - name: Commit files
23
+ run: |
24
+ git config --local user.email "andrewmcodes@protonmail.com"
25
+ git config --local user.name "Andrew Mason"
26
+ git add CHANGELOG.md
27
+ git commit -m "docs: :pencil: Update changelog [ci skip]"
28
+ - name: Push changes
29
+ uses: ad-m/github-push-action@master
30
+ with:
31
+ github_token: ${{ secrets.GITHUB_TOKEN }}
32
+ branch: main
@@ -1,10 +1,18 @@
1
1
  # Changelog
2
2
 
3
- # (2020-07-11)
3
+ ## [Unreleased](https://github.com/andrewmcodes/bridgetown-inline-svg/tree/HEAD)
4
4
 
5
- ### Features
5
+ [Full Changelog](https://github.com/andrewmcodes/bridgetown-inline-svg/compare/v1.0.0...HEAD)
6
6
 
7
- * **dependencies:** :heavy_plus_sign: Add simplecov and coveralls ([1369d37](https://github.com/andrewmcodes/bridgetown-inline-svg/commit/1369d3756d7c55ea9015e0cb1dda34723d6eff82))
8
- * **release:** :bookmark: Bump bridgetown-inline-svg to 0.0.1 [skip ci] ([cef6587](https://github.com/andrewmcodes/bridgetown-inline-svg/commit/cef6587bd4e17f7912fd2b3ef2cafab137630af4))
9
- * **release:** :building_construction: Update gem release command settings ([aea38c8](https://github.com/andrewmcodes/bridgetown-inline-svg/commit/aea38c8e1a4ad8e4a135aa6c09b77134df26b68f))
10
- * :tada: Initial Commit ([dcf77a7](https://github.com/andrewmcodes/bridgetown-inline-svg/commit/dcf77a73d7fee38fdc00dfce3b6a7f50ebd27636))
7
+ **Merged pull requests:**
8
+
9
+ - Update documentation [\#5](https://github.com/andrewmcodes/bridgetown-inline-svg/pull/5) ([andrewmcodes](https://github.com/andrewmcodes))
10
+ - bug: Allow svg in partial without passing "site: site" explicitly [\#4](https://github.com/andrewmcodes/bridgetown-inline-svg/pull/4) ([MikeRogers0](https://github.com/MikeRogers0))
11
+
12
+ ## [v1.0.0](https://github.com/andrewmcodes/bridgetown-inline-svg/tree/v1.0.0) (2020-07-11)
13
+
14
+ [Full Changelog](https://github.com/andrewmcodes/bridgetown-inline-svg/compare/dcf77a73d7fee38fdc00dfce3b6a7f50ebd27636...v1.0.0)
15
+
16
+
17
+
18
+ \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
data/README.md CHANGED
@@ -1,27 +1,32 @@
1
- <h1 align="center">Welcome to bridgetown-inline-svg 👋</h1>
2
- <p>
3
- <a href="LICENSE" target="_blank">
4
- <img alt="License: GPL-3.0" src="https://img.shields.io/github/license/andrewmcodes/bridgetown-inline-svg" />
5
- </a>
6
- <a href="https://badge.fury.io/rb/bridgetown-inline-svg"><img src="https://badge.fury.io/rb/bridgetown-inline-svg.svg" alt="Gem Version" height="18"></a>
7
- <a href="https://depfu.com"><img src="https://badges.depfu.com/badges/54fe87f2b14868b7c6e69aa0322e3764/status.svg" alt="Depfu"></a>
8
- <a href="https://depfu.com/github/andrewmcodes/bridgetown-inline-svg?project_id=14094"><img src="https://badges.depfu.com/badges/54fe87f2b14868b7c6e69aa0322e3764/count.svg" alt="Depfu"></a>
9
- <a href="https://codeclimate.com/github/andrewmcodes/bridgetown-inline-svg/maintainability"><img src="https://api.codeclimate.com/v1/badges/f9756d6568f43c7a407b/maintainability" /></a>
10
- <a href="https://www.codacy.com/manual/andrewmcodes/bridgetown-inline-svg?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=andrewmcodes/bridgetown-inline-svg&amp;utm_campaign=Badge_Grade"><img src="https://app.codacy.com/project/badge/Grade/caad1b16367242ff973fe2e977985364" alt="Codacy Badge"></a>
11
- <a href='https://coveralls.io/github/andrewmcodes/bridgetown-inline-svg?branch=main'><img src='https://coveralls.io/repos/github/andrewmcodes/bridgetown-inline-svg/badge.svg?branch=main' alt='Coverage Status' /></a>
12
- <img alt="Tests" src="https://github.com/andrewmcodes/bridgetown-inline-svg/workflows/Tests/badge.svg" />
13
- <img alt="Linters" src="https://github.com/andrewmcodes/bridgetown-inline-svg/workflows/Linters/badge.svg" />
14
- </p>
15
-
16
- > SVG optimizer and inliner for Bridgetown
1
+ <div align="center">
2
+ <img alt="Banner" width="100%" height="350" src="media/banner.png" />
3
+ <h1>bridgetown-inline-svg</h1>
4
+ <p>
5
+ <a href="LICENSE" target="_blank">
6
+ <img alt="License: GPL-3.0" src="https://img.shields.io/github/license/andrewmcodes/bridgetown-inline-svg" />
7
+ </a>
8
+ <a href="https://badge.fury.io/rb/bridgetown-inline-svg"><img src="https://badge.fury.io/rb/bridgetown-inline-svg.svg" alt="Gem Version" height="18"></a>
9
+ <a href="https://depfu.com"><img src="https://badges.depfu.com/badges/54fe87f2b14868b7c6e69aa0322e3764/status.svg" alt="Depfu"></a>
10
+ <a href="https://depfu.com/github/andrewmcodes/bridgetown-inline-svg?project_id=14094"><img src="https://badges.depfu.com/badges/54fe87f2b14868b7c6e69aa0322e3764/count.svg" alt="Depfu"></a>
11
+ <a href="https://codeclimate.com/github/andrewmcodes/bridgetown-inline-svg/maintainability"><img src="https://api.codeclimate.com/v1/badges/f9756d6568f43c7a407b/maintainability" /></a>
12
+ <a href="https://www.codacy.com/manual/andrewmcodes/bridgetown-inline-svg?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=andrewmcodes/bridgetown-inline-svg&amp;utm_campaign=Badge_Grade"><img src="https://app.codacy.com/project/badge/Grade/caad1b16367242ff973fe2e977985364" alt="Codacy Badge"></a>
13
+ <a href='https://coveralls.io/github/andrewmcodes/bridgetown-inline-svg?branch=main'><img src='https://coveralls.io/repos/github/andrewmcodes/bridgetown-inline-svg/badge.svg?branch=main' alt='Coverage Status' /></a>
14
+ <img alt="Tests" src="https://github.com/andrewmcodes/bridgetown-inline-svg/workflows/Tests/badge.svg" />
15
+ <img alt="Linters" src="https://github.com/andrewmcodes/bridgetown-inline-svg/workflows/Linters/badge.svg" />
16
+ <img alt="Changelog" src="https://github.com/andrewmcodes/bridgetown-inline-svg/workflows/Changelog/badge.svg" />
17
+ </p>
18
+ </div>
17
19
 
18
20
  - [Installation](#installation)
19
- - [Optional configuration options](#optional-configuration-options)
21
+ - [Optional Configuration](#optional-configuration)
22
+ - [Demo](#demo)
20
23
  - [Usage](#usage)
24
+ - [Attributes](#attributes)
25
+ - [Height and Width](#height-and-width)
26
+ - [Paths](#paths)
27
+ - [Variables](#variables)
21
28
  - [Optimizations](#optimizations)
22
- - [Author](#author)
23
29
  - [Contributing](#contributing)
24
- - [Show your support](#show-your-support)
25
30
  - [Acknowledgement](#acknowledgement)
26
31
  - [License](#license)
27
32
 
@@ -37,63 +42,96 @@ or add the following to your `Gemfile`:
37
42
 
38
43
  ```ruby
39
44
  group :bridgetown_plugins do
40
- gem "bridgetown-inline-svg", "~> 0.0.1"
45
+ gem "bridgetown-inline-svg", "~> 1.1.0"
41
46
  end
42
47
  ```
43
48
 
44
- ### Optional configuration options
49
+ ## Optional Configuration
45
50
 
46
- Optimization is opt-in and can be enabled by adding this to your `bridgetown.config.yml`
51
+ ```yml
52
+ # bridgetown.config.yml
47
53
 
48
- ```
49
54
  svg:
55
+ # Whether to optimize the SVG files with svg_optimizer.
56
+ #
57
+ # Type: Boolean
58
+ # Optional: true
59
+ # Default: false
50
60
  optimize: true
51
61
  ```
52
62
 
63
+ ## Demo
64
+
65
+ [bridgetown-inline-svg-starter](https://github.com/andrewmcodes/bridgetown-inline-svg-starter)
66
+
67
+ This starter can be used to reproduce issues as well as provide an example of the plugin's usage.
68
+
53
69
  ## Usage
54
70
 
55
- Use the Liquid tag in your pages :
71
+ This plugin provides the `svg` Liquid tag to your site.
72
+
73
+ Use the tag in your pages, collections, components, etc. by passing the tag the name of a file:
74
+
75
+ ```liquid
76
+ {% svg path/to/my.svg %}
77
+ ```
78
+
79
+ **Note**: The `.svg` file extension is required.
80
+
81
+ ### Attributes
82
+
83
+ Set attributes just like you would in HTML.
84
+
85
+ For example:
56
86
 
57
87
  ```liquid
58
- {% svg /path/to/square.svg width=24 foo="bar" %}
88
+ {% svg assets/svg/square.svg width=24 class="text-indigo-600" foo="bar" %}
59
89
  ```
60
90
 
61
- Bridgetown will include the svg file in your output HTML like this :
91
+ Bridgetown will include the SVG file in your output HTML like this:
62
92
 
63
93
  ```html
64
- <svg width=24 foo="bar" version="1.1" id="square" xmlns="http://www.w3.org/2000/svg" x="0" y="0" viewBox="0 0 24 24" >
94
+ <svg width="24" height="24" class="text-indigo-600" foo="bar" version="1.1" id="square" xmlns="http://www.w3.org/2000/svg" x="0" y="0" viewBox="0 0 24 24" >
65
95
  <rect width="20" height="20" x="2" y="2" />
66
96
  </svg>
67
97
  ```
68
98
 
69
- **Note** : You will generally want to set the width/height of your SVG or a `style` attribute, but anything can be passed through.
99
+ **Note**: Anything can be passed through, but we'd recommend only setting [valid attributes](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/svg#Attributes).
100
+
101
+ #### Height and Width
102
+
103
+ `height` is automatically set to match `width` if omitted, and vice versa. Height specifically can't be left unset because IE11 won't use the viewport attribute to calculate the image's aspect ratio.
70
104
 
71
- Paths with a space should be quoted :
105
+ ### Paths
106
+
107
+ Paths with a space should be quoted with single or double quotes:
72
108
 
73
109
  ```liquid
74
- {% svg "/path/to/foo bar.svg" %}
75
- # or :
76
- {% svg '/path/to/foo bar.svg' %}
110
+ {% svg "/path/to/my asset.svg" %}
77
111
  ```
78
- Otherwise anything after the first space will be considered an attribute.
79
112
 
80
- Liquid variables will be interpreted if enclosed in double brackets :
113
+ If the path is not in quotes, anything after the __first space__ will be considered an attribute.
114
+
115
+ Relative paths and absolute paths will both be interpreted from Bridgetown's `src` directory. So both:
81
116
 
82
117
  ```liquid
83
- {% assign size=40 %}
84
- {% svg "/path/to/{{site.foo-name}}.svg" width="{{size}}" %}
118
+ {% svg "/path/to/my.svg" %}
119
+ {% svg "path/to/my.svg" %}
85
120
  ```
86
121
 
87
- `height` is automatically set to match `width` if omitted. It can't be left unset because IE11 won't use the viewport attribute to calculate the image's aspect ratio.
122
+ Should resolve to `/your/site/src/path/to/my.svg` and are equivalent.
88
123
 
89
- Relative paths and absolute paths will both be interpreted from Bridgetown's `src` directory. So both:
124
+ ### Variables
125
+
126
+ Liquid variables will be interpolated if enclosed in double brackets:
90
127
 
91
128
  ```liquid
92
- {% svg "/path/to/foo.svg" %}
93
- {% svg "path/to/foo.svg" %}
129
+ {% assign svg_name="my" %}
130
+ {% assign size=40 %}
131
+ {% svg "/path/to/{{svg_name}}.svg" width="{{size}}" %}
94
132
  ```
95
133
 
96
- Should resolve to `/your/site/src/path/to/foo.svg`.
134
+ This is especially helpful inside of Liquid components!
97
135
 
98
136
  ### Optimizations
99
137
 
@@ -109,22 +147,10 @@ If any important data gets removed, or the output SVG looks different from input
109
147
 
110
148
  It does not perform any input validation on attributes. They will be appended as-is to the root node.
111
149
 
112
- ## Author
113
-
114
- 👤 **Andrew Mason**
115
-
116
- * Website: https://www.andrewm.codes
117
- * Twitter: [@andrewmcodes](https://twitter.com/andrewmcodes)
118
- * Github: [@andrewmason](https://github.com/andrewmason)
119
-
120
150
  ## Contributing
121
151
 
122
152
  Contributions, issues and feature requests are welcome!<br />Feel free to check [issues page](https://github.com/andrewmcodes/bridgetown-inline-svg/issues). You can also take a look at the [contributing guide](https://github.com/andrewmcodes/bridgetown-inline-svg/blob/main/CONTRIBUTING.md).
123
153
 
124
- ## Show your support
125
-
126
- Give a ⭐️ if this project helped you!
127
-
128
154
  ## Acknowledgement
129
155
 
130
156
  This project was initially forked from [jekyll-inline-svg](https://github.com/sdumetz/jekyll-inline-svg).
@@ -135,5 +161,3 @@ Copyright © 2017-2020 [Sebastien Dumetz](https://github.com/sdumetz)
135
161
  Copyright © 2020 [Andrew Mason](https://github.com/andrewmcodes)
136
162
 
137
163
  The following code is a derivative work of the code from the [jekyll-inline-svg](https://github.com/sdumetz/jekyll-inline-svg) project, which is licensed GPLv3. This code therefore is also licensed under the terms of the GNU Public License, verison 3.
138
-
139
- <a href="https://app.fossa.com/projects/git%2Bgithub.com%2Fandrewmcodes%2Fbridgetown-inline-svg?ref=badge_large" alt="FOSSA Status"><img src="https://app.fossa.com/api/projects/git%2Bgithub.com%2Fandrewmcodes%2Fbridgetown-inline-svg.svg?type=large"/></a>
@@ -74,7 +74,7 @@ module BridgetownInlineSvg
74
74
  matched = markup.strip.match(PATH_SYNTAX)
75
75
  unless matched
76
76
  raise SyntaxError, <<~END
77
- Syntax Error in tag 'highlight' while parsing the following markup:
77
+ Syntax Error in tag 'svg' while parsing the following markup:
78
78
  #{markup}
79
79
  Valid syntax: svg <path> [property=value]
80
80
  END
@@ -119,6 +119,7 @@ module BridgetownInlineSvg
119
119
  # check if given name is a variable. Otherwise use it as a file name
120
120
  svg_file = Bridgetown.sanitized_path(site.source, interpolate(@svg, context))
121
121
  return unless svg_file
122
+
122
123
  add_file_to_dependency(site, svg_file, context)
123
124
  # replace variables with their current value
124
125
  params = split_params(@params, context)
@@ -128,15 +129,16 @@ module BridgetownInlineSvg
128
129
  end
129
130
  # params = @params
130
131
  file = File.open(svg_file, "rb").read
131
- conf = lookup_variable(context, "site.svg")
132
+
133
+ conf = site.config["svg"] || {}
134
+
132
135
  if conf["optimize"] == true
133
- xml = SvgOptimizer.optimize(file, [create_plugin(params)] + PLUGINS)
136
+ SvgOptimizer.optimize(file, [create_plugin(params)] + PLUGINS)
134
137
  else
135
138
  xml = Nokogiri::XML(file)
136
139
  params.each { |key, val| xml.root.set_attribute(key, val) }
137
- xml = xml.root.to_xml
140
+ xml.root.to_xml
138
141
  end
139
- xml
140
142
  end
141
143
  end
142
144
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BridgetownInlineSvg
4
- VERSION = "1.0.0"
4
+ VERSION = "1.1.0"
5
5
  end
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bridgetown-inline-svg
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Mason
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-11 00:00:00.000000000 Z
11
+ date: 2020-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bridgetown
@@ -73,6 +73,7 @@ files:
73
73
  - ".github/ISSUE_TEMPLATE/bug_report.md"
74
74
  - ".github/ISSUE_TEMPLATE/feature_request.md"
75
75
  - ".github/PULL_REQUEST_TEMPLATE.md"
76
+ - ".github/workflows/changelog.yml"
76
77
  - ".github/workflows/linters.yml"
77
78
  - ".github/workflows/pr_tests.yml"
78
79
  - ".github/workflows/tests.yml"
@@ -88,7 +89,6 @@ files:
88
89
  - README.md
89
90
  - Rakefile
90
91
  - SECURITY.md
91
- - _README.md
92
92
  - bin/check
93
93
  - bin/checks/standardrb
94
94
  - bin/console
@@ -101,6 +101,7 @@ files:
101
101
  - lib/bridgetown-inline-svg.rb
102
102
  - lib/bridgetown-inline-svg/svg-tag.rb
103
103
  - lib/bridgetown-inline-svg/version.rb
104
+ - media/banner.png
104
105
  homepage: https://github.com/andrewmcodes/bridgetown-inline-svg
105
106
  licenses:
106
107
  - GPL-3.0
data/_README.md DELETED
@@ -1,5 +0,0 @@
1
- # bridgetown-inline-svg
2
-
3
- SVG optimizer and inliner for [Bridgetown](https://www.bridgetownrb.com)
4
-
5
- This liquid tag will let you inline SVG images in your bridgetown sites. It will add `{%svg %}` to `Liquid::Tag`.