jekyll-kw-sri 0.0.6 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +21 -0
- data/README.md +5 -0
- data/_includes/kw-integrity-css.html +42 -0
- data/_includes/kw-integrity-js.html +1 -0
- data/lib/jekyll-kw-sri.rb +0 -15
- data/lib/version.rb +1 -1
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 819489bf76dbdfc30a65dea0be4194cf7e5413feb9cdf466b2fc016ebc5d548c
|
4
|
+
data.tar.gz: adfe552b0323b916bd2ac982f55ba77edacdd69c42c5a96c88956e579f2f3dfd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9636fd290730383df237c912a2db7e0d665894a8f6fe880ffafbf6ea5e11a09fa2277cc39f86885926a14373b0309121d5d088cb7f82128f82dd1a14e4d03da3
|
7
|
+
data.tar.gz: 549d6ff11bc9789e295d87840339f16108482308961945d3bc22faae6b76280c6364f2521cf5e8e406a7d391b576f7153d48603249d587ddbffc1b1ddd81c480
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2020 n13.org
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -8,6 +8,11 @@ A plugin for jekyll to calculate [Subresource Integrity][Wikipedia SRI] (SRI) ha
|
|
8
8
|
|
9
9
|
from [Mozilla docs][Mozilla Subresource Integrity]
|
10
10
|
|
11
|
+
## Changelog
|
12
|
+
|
13
|
+
* 0.0.x Add the custom tag `{% sri_scss_hash %}`
|
14
|
+
* 0.1.0 Add html iclude files to use them with `{% include kw-integrity-css.html %}` or `{% include kw-integrity-js.html %}`
|
15
|
+
|
11
16
|
## Configuration
|
12
17
|
|
13
18
|
Add `kw-sri` section to `_config.yml` configure the plugin globally. If you want to use defauls you can ommit the config-section.
|
@@ -0,0 +1,42 @@
|
|
1
|
+
{% assign para_file = include.file | default: "main.scss" %}
|
2
|
+
{% assign para_path = include.path | default: "assets/css/" %}
|
3
|
+
{% assign para_hash = include.hash | default: "sha384" %}
|
4
|
+
|
5
|
+
{% assign filename_no_path = para_file | split: "/" | last %}
|
6
|
+
{% assign source_file = "/" | append: para_path | append: para_file %}
|
7
|
+
{% assign source_file_ex = para_file | split: "." | last %}
|
8
|
+
{% assign path_no_filename = para_file | remove: filename_no_path %}
|
9
|
+
{% assign target_file_ex = para_file | replace: ".scss", ".css" %}
|
10
|
+
{% assign target_file = para_path | append: target_file_ex %}
|
11
|
+
{% assign integrity_file = "/integrity/" | append: para_file | append: "." | append: para_hash %}
|
12
|
+
|
13
|
+
{% comment %}{% raw %}
|
14
|
+
<!-- DEBUG BEGINN
|
15
|
+
{{ para_file }}
|
16
|
+
{{ para_path }}
|
17
|
+
{{ para_hash }}
|
18
|
+
{{ filename_no_path }}
|
19
|
+
{{ source_file }}
|
20
|
+
{{ source_file_ex }}
|
21
|
+
{{ path_no_filename }}
|
22
|
+
{{ target_file }}
|
23
|
+
{{ integrity_file }}
|
24
|
+
DEBUG END -->
|
25
|
+
{% endraw %}{% endcomment %}
|
26
|
+
|
27
|
+
{% case source_file_ex %}
|
28
|
+
{% when "css" %}
|
29
|
+
<link rel="stylesheet" href="{{ target_file }}" integrity="{{ para_hash }}-{% include {{ integrity_file }} %}" crossorigin="anonymous">
|
30
|
+
{% when "scss" %}
|
31
|
+
<link rel="stylesheet" href="{{ target_file }}" integrity="{% sri_scss_hash {{ source_file }} %}" crossorigin="anonymous">
|
32
|
+
{% else %}
|
33
|
+
<link rel="stylesheet" href="{{ target_file }}">
|
34
|
+
{% endcase %}
|
35
|
+
|
36
|
+
{% comment %}{% raw %}
|
37
|
+
|
38
|
+
<!-- Trailing Slash Handling ? -->
|
39
|
+
{% assign trainling_slash = para_path | slice: -1, 1 %}
|
40
|
+
{% if trainling_slash = "/" %}
|
41
|
+
|
42
|
+
{% endraw %}{% endcomment %}
|
@@ -0,0 +1 @@
|
|
1
|
+
<script src="/assets/js/{{ include.file }}" integrity="sha384-{% include /integrity/{{ include.file }}.sha384 %}" crossorigin="anonymous"></script>
|
data/lib/jekyll-kw-sri.rb
CHANGED
@@ -9,10 +9,6 @@ module Jekyll
|
|
9
9
|
module KargWare
|
10
10
|
# jekyll-kw-sri custom tag
|
11
11
|
class SriScssHashTag < Jekyll::Tags::IncludeRelativeTag
|
12
|
-
# class SriScssHashTag < Liquid::Tag
|
13
|
-
|
14
|
-
# alias super_render render
|
15
|
-
|
16
12
|
def initialize(tag_name, input, tokens)
|
17
13
|
super
|
18
14
|
|
@@ -20,10 +16,6 @@ module Jekyll
|
|
20
16
|
# File.exists? is file?
|
21
17
|
end
|
22
18
|
|
23
|
-
# def syntax_example
|
24
|
-
# "{% #{@tag_name} css/main.scss %}"
|
25
|
-
# end
|
26
|
-
|
27
19
|
def render(context)
|
28
20
|
cache_compiled_scss(@file, context, lambda {
|
29
21
|
if context.nil? || context.registers[:site].nil?
|
@@ -55,13 +47,6 @@ module Jekyll
|
|
55
47
|
end
|
56
48
|
|
57
49
|
def cache_compiled_scss(path, _context, compute)
|
58
|
-
# @@cached_scss ||= {}
|
59
|
-
# if @@cached_scss.key?(path)
|
60
|
-
# @@cached_scss[path]
|
61
|
-
# else
|
62
|
-
# @@cached_scss[path] = compute.call
|
63
|
-
# end
|
64
|
-
|
65
50
|
@cached_scss ||= {}
|
66
51
|
if @cached_scss.key?(path)
|
67
52
|
@cached_scss[path]
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-kw-sri
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicolas Karg
|
@@ -32,7 +32,10 @@ executables: []
|
|
32
32
|
extensions: []
|
33
33
|
extra_rdoc_files: []
|
34
34
|
files:
|
35
|
+
- LICENSE
|
35
36
|
- README.md
|
37
|
+
- _includes/kw-integrity-css.html
|
38
|
+
- _includes/kw-integrity-js.html
|
36
39
|
- lib/jekyll-kw-sri.rb
|
37
40
|
- lib/jekyll-kw-sri/configuration.rb
|
38
41
|
- lib/jekyll-kw-sri/parser.rb
|