hyde-page-css 0.2.2 → 0.3.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47a306a1505adce319c2e7e2c872029f0ae792feab9d164163a74b5933166267
|
4
|
+
data.tar.gz: 84b56ab510348dd9b2c0401e9cb3f0d6c332cec97f5d4ca5aa78222412b7c5f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c3da3407955bd07c45d39f2e1b0c033a2e25b6812d4e7f95ae590e45cb4baeb7d5447720355b1cc230ed078542b3990e4a5dbe45f2ff5af1afe564543e5b812
|
7
|
+
data.tar.gz: 80ceca52abdde3699e55e025cdc39350ed0f7ce84aa96417614ac512b659857709ddf5f315b5f0d429712425250175646b47af851fa70cd0871811b4e61d0e06
|
@@ -1,31 +1,12 @@
|
|
1
1
|
require 'jekyll'
|
2
|
-
require_relative
|
3
|
-
|
4
|
-
module Jekyll
|
5
|
-
class Renderer
|
6
|
-
def render_layout(output, layout, info)
|
7
|
-
Hyde::Page::Css.new(layout, info).generate
|
8
|
-
|
9
|
-
# TODO Would be nice to call super here instead of cloned logic from Jekyll internals
|
10
|
-
payload["content"] = output
|
11
|
-
payload["layout"] = Utils.deep_merge_hashes(layout.data, payload["layout"] || {})
|
12
|
-
|
13
|
-
render_liquid(
|
14
|
-
layout.content,
|
15
|
-
payload,
|
16
|
-
info,
|
17
|
-
layout.path
|
18
|
-
)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
2
|
+
require_relative "generated_page_css_file"
|
22
3
|
|
23
4
|
module Hyde
|
24
5
|
module Page
|
25
6
|
class Css
|
26
7
|
@@config = {
|
27
|
-
"asset_path" =>
|
28
|
-
"file_output_path" =>
|
8
|
+
"asset_path" => "assets/css",
|
9
|
+
"file_output_path" => "assets/css",
|
29
10
|
"css_minify" => true,
|
30
11
|
"enable" => true,
|
31
12
|
"keep_files" => true,
|
@@ -36,24 +17,24 @@ module Hyde
|
|
36
17
|
@site = info[:registers][:site]
|
37
18
|
@page = info[:registers][:page]
|
38
19
|
@data = layout.data
|
39
|
-
@config = @@config.merge(@site.config.dig(
|
20
|
+
@config = @@config.merge(@site.config.dig("hyde_page_css") || {})
|
40
21
|
|
41
|
-
@qualified_asset_path = File.join(*[@site.source, @config[
|
22
|
+
@qualified_asset_path = File.join(*[@site.source, @config["asset_path"]].compact)
|
42
23
|
|
43
|
-
if config(
|
44
|
-
@site.config[
|
24
|
+
if config("keep_files") == true && config("dev_mode") == false
|
25
|
+
@site.config["keep_files"].push(config("file_output_path"))
|
45
26
|
end
|
46
27
|
|
47
|
-
if @page["css"].nil?
|
48
|
-
|
28
|
+
@page["css"] = if @page["css"].nil?
|
29
|
+
[]
|
49
30
|
else
|
50
|
-
|
31
|
+
[@page["css"]]
|
51
32
|
end
|
52
33
|
end
|
53
34
|
|
54
35
|
def generate
|
55
|
-
return unless config(
|
56
|
-
@page["css"].unshift(@data[
|
36
|
+
return unless config("enable") == true
|
37
|
+
@page["css"].unshift(@data["css"])
|
57
38
|
|
58
39
|
file_groups = flatten_group(@page["css"])
|
59
40
|
|
@@ -80,13 +61,13 @@ module Hyde
|
|
80
61
|
end
|
81
62
|
|
82
63
|
# the recursive nature of this will sometimes have duplicate css files
|
83
|
-
@page[
|
64
|
+
@page["css_files"] = css_files.uniq
|
84
65
|
end
|
85
66
|
|
86
|
-
|
67
|
+
private
|
87
68
|
|
88
|
-
def config(*
|
89
|
-
@config.dig(*
|
69
|
+
def config(*)
|
70
|
+
@config.dig(*)
|
90
71
|
end
|
91
72
|
|
92
73
|
def flatten_group(arr, acc = [])
|
@@ -96,18 +77,18 @@ module Hyde
|
|
96
77
|
acc += flatten_group(arr.last)
|
97
78
|
end
|
98
79
|
|
99
|
-
def concatenate_files(files, data =
|
80
|
+
def concatenate_files(files, data = "")
|
100
81
|
for file in files do
|
101
82
|
# tmp page required to handle anything with frontmatter/yaml header
|
102
|
-
tmp_page = Jekyll::PageWithoutAFile.new(@site, nil, config(
|
83
|
+
tmp_page = Jekyll::PageWithoutAFile.new(@site, nil, config("asset_path"), file)
|
103
84
|
path = File.join([@qualified_asset_path, file])
|
104
85
|
|
105
86
|
begin
|
106
87
|
file_contents = File.read(path)
|
107
88
|
tmp_page.content = file_contents
|
108
|
-
data << Jekyll::Renderer.new(@site, tmp_page).run
|
89
|
+
data << Jekyll::Renderer.new(@site, tmp_page).run
|
109
90
|
rescue
|
110
|
-
Jekyll.logger.warn(
|
91
|
+
Jekyll.logger.warn("Page CSS Warning:", "Unable to find #{path}")
|
111
92
|
end
|
112
93
|
end
|
113
94
|
|
@@ -115,25 +96,34 @@ module Hyde
|
|
115
96
|
end
|
116
97
|
|
117
98
|
def minify(data)
|
118
|
-
|
119
|
-
|
99
|
+
style = if config("dev_mode") == true
|
100
|
+
"expanded"
|
101
|
+
elsif config("css_minify") == false
|
102
|
+
"expanded"
|
103
|
+
else
|
104
|
+
"compressed"
|
105
|
+
end
|
120
106
|
|
121
|
-
converter_config = {
|
107
|
+
converter_config = {"sass" => {"style" => style}}
|
122
108
|
Jekyll::Converters::Scss.new(converter_config).convert(data)
|
123
109
|
end
|
124
110
|
|
125
111
|
def generate_file(files, data)
|
126
112
|
file_name = generate_file_name(files, data)
|
127
113
|
|
128
|
-
Hyde::Page::GeneratedPageCssFile.new(@site, config(
|
114
|
+
Hyde::Page::GeneratedPageCssFile.new(@site, config("asset_path"), file_name)
|
129
115
|
end
|
130
116
|
|
131
|
-
def generate_file_name(files, data)
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
117
|
+
def generate_file_name(files, data, prefix: nil)
|
118
|
+
file_names = [prefix]
|
119
|
+
|
120
|
+
if config("dev_mode")
|
121
|
+
files.each { |file| file_names.push(file.gsub(".css", "")) }
|
136
122
|
end
|
123
|
+
|
124
|
+
file_names.push(Digest::MD5.hexdigest(data)[0, 6])
|
125
|
+
|
126
|
+
file_names.compact.join("-") + ".css"
|
137
127
|
end
|
138
128
|
end
|
139
129
|
end
|
@@ -9,12 +9,12 @@ module Hyde
|
|
9
9
|
|
10
10
|
def initialize(site, dir, name)
|
11
11
|
@site = site
|
12
|
-
@dir
|
12
|
+
@dir = dir
|
13
13
|
@name = name
|
14
14
|
@relative_path = File.join(*[@dir, @name].compact)
|
15
15
|
@extname = File.extname(@name)
|
16
16
|
@type = @collection&.label&.to_sym
|
17
|
-
@generator =
|
17
|
+
@generator = "hyde-page-css"
|
18
18
|
end
|
19
19
|
|
20
20
|
def write(dest)
|
@@ -24,7 +24,7 @@ module Hyde
|
|
24
24
|
FileUtils.mkdir_p(File.dirname(dest_path))
|
25
25
|
FileUtils.rm(dest_path) if File.exist?(dest_path)
|
26
26
|
|
27
|
-
File.open(dest_path,
|
27
|
+
File.open(dest_path, "w") do |output_file|
|
28
28
|
output_file << file_contents
|
29
29
|
end
|
30
30
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Jekyll
|
2
|
+
class Renderer
|
3
|
+
def render_layout(output, layout, info)
|
4
|
+
Hyde::Page::Css.new(layout, info).generate
|
5
|
+
|
6
|
+
# TODO Would be nice to call super here instead of cloned logic from Jekyll internals
|
7
|
+
payload["content"] = output
|
8
|
+
payload["layout"] = Utils.deep_merge_hashes(layout.data, payload["layout"] || {})
|
9
|
+
|
10
|
+
render_liquid(
|
11
|
+
layout.content,
|
12
|
+
payload,
|
13
|
+
info,
|
14
|
+
layout.path
|
15
|
+
)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hyde-page-css
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregory Daynes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-12-
|
11
|
+
date: 2023-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -37,9 +37,10 @@ executables: []
|
|
37
37
|
extensions: []
|
38
38
|
extra_rdoc_files: []
|
39
39
|
files:
|
40
|
-
- lib/
|
41
|
-
- lib/
|
42
|
-
- lib/
|
40
|
+
- lib/hyde-page-css.rb
|
41
|
+
- lib/hyde/page/css.rb
|
42
|
+
- lib/hyde/page/generated_page_css_file.rb
|
43
|
+
- lib/hyde/renderer.rb
|
43
44
|
homepage: https://github.com/gregdaynes/hyde-page-css
|
44
45
|
licenses:
|
45
46
|
- MIT
|
@@ -59,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
59
60
|
- !ruby/object:Gem::Version
|
60
61
|
version: '0'
|
61
62
|
requirements: []
|
62
|
-
rubygems_version: 3.4.
|
63
|
+
rubygems_version: 3.4.10
|
63
64
|
signing_key:
|
64
65
|
specification_version: 4
|
65
66
|
summary: Plugin for jekyll to enable per page css files
|