jekyll-chatgpt 0.2.0 → 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: 4897cd9cf94d69f8d4ce0416eba0bf76b685dabccca22e9e2c15f6c33920d074
4
- data.tar.gz: a6af3a6b8cbadba800968c8157557c310bf97736b0bfe48601277ba71cae2e8c
3
+ metadata.gz: 681dec7900a693bd5210549c18140bf1d993059effb4ad8bfdf474995479bafb
4
+ data.tar.gz: e84ff1e7a0c1a5d40f62660b3a4a6188d6c47d269db3f3c94a9b92b1d68e0942
5
5
  SHA512:
6
- metadata.gz: 58d614fee1d9bb4c82286a8b787a0224ae94da8101ffd084d579c2b1808e5875fa192c1cc2d481fb8687d85bb070006730d60643c0b3d2239189d23282fcae06
7
- data.tar.gz: 968d297f492fc523b6e8c28547e42cf7f63cdfc504aabacd1b873b0352f8f4d434f118a096d67e191643c1b2bbd92bf8bcefae31dc8db38db880beeadf904c07
6
+ metadata.gz: 454e7a3ea814cf55314315c8ccf750e7cc54eb3ef6f04b315025683e32d27079a41b9fa7df7b2f158c611716791f2927f645c88929f940945826d4ea0dc1c164
7
+ data.tar.gz: 608139a4c8b3874c7d2f59b86905a2c97fafda1b602d2e62f645bf256016cd08d4c8f573d9509ba8894b4e88291a0ec50754ebdb48e94c500f4a933865ac53f9
data/README.md CHANGED
@@ -32,6 +32,10 @@ Optionally, include a stylesheet for code syntax highlighting in ChatGPT output.
32
32
 
33
33
  The necessary styles will automatically be inlined when using the filter. You can override the default colors by providing the following variables in your `_sass/_colors.sass` file : `$color1`, `$color1-alt`, `$color2`, `$color2-alt`, `$cyan`
34
34
 
35
+ ### Customizing the SASS/CSS
36
+
37
+ You can put your custom SASS inside `_sass/_chatgpt_custom.sass`. If the file exists, it will be imported and the properties set in your custom stylesheet will take precedence by using [CSS layers](https://developer.mozilla.org/en-US/docs/Web/CSS/@layer). The demo uses this to add rounded borders to the controls.
38
+
35
39
  ### Live demo
36
40
 
37
41
  You can browse the [code for the live demo](https://github.com/pcouy/jekyll-chatgpt/tree/demo) which is intended to be a minimal example of using the plugin.
data/lib/chatgpt.sass CHANGED
@@ -4,72 +4,73 @@ $color2: #cc3 !default
4
4
  $color2-alt: #c3c !default
5
5
  $cyan: #2aa198 !default
6
6
 
7
- .chatgpt-conversation
8
- $tab-border: $color1-alt
9
- position: relative
10
- height: 400px
11
- overflow-y: scroll
12
- border: 1px solid $tab-border
13
- margin: 2em 0.5em
7
+ @layer chatgpt-default
8
+ .chatgpt-conversation
9
+ $tab-border: $color1-alt
10
+ position: relative
11
+ height: 400px
12
+ overflow-y: scroll
13
+ border: 1px solid $tab-border
14
+ margin: 2em 0.5em
14
15
 
15
- .chatgpt-message
16
- display: none
17
- position: absolute
18
- left: 0
19
- width: 100%
20
- top: 1.5em
21
- &:target
22
- border: 1px solid $color1
23
- border-radius: 5px
24
- width: 98%
25
- margin: 0.75%
26
- .chatgpt-control:checked ~ .chatgpt-message
27
- display: block
28
- &>.chatgpt-messagebody
29
- margin-bottom: 0.5em
30
- &>pre
31
- display: inline
32
- word-wrap: normal
33
- white-space: pre-wrap
34
- &>p
35
- margin-block-start: 0.25em
36
- margin-top: 0.25em
37
- &>.chatgpt-message
38
- display: block
39
- top: 3em
16
+ .chatgpt-message
17
+ display: none
18
+ position: absolute
19
+ left: 0
20
+ width: 100%
21
+ top: 1.5em
22
+ &:target
23
+ border: 1px solid $color1
24
+ border-radius: 5px
25
+ width: 98%
26
+ margin: 0.75%
27
+ .chatgpt-control:checked ~ .chatgpt-message
28
+ display: block
29
+ &>.chatgpt-messagebody
30
+ margin-bottom: 0.5em
31
+ &>pre
32
+ display: inline
33
+ word-wrap: normal
34
+ white-space: pre-wrap
35
+ &>p
36
+ margin-block-start: 0.25em
37
+ margin-top: 0.25em
38
+ &>.chatgpt-message
39
+ display: block
40
+ top: 3em
40
41
 
41
- .chatgpt-role-user::before
42
- content: "User : "
43
- color: $color2-alt
44
- /*border: 1px solid $color1-alt
45
- .chatgpt-role-assistant::before
46
- content: "ChatGPT : "
47
- color: $color2
48
- /*border: 1px solid $color2
42
+ .chatgpt-role-user::before
43
+ content: "User : "
44
+ color: $color2-alt
45
+ /*border: 1px solid $color1-alt
46
+ .chatgpt-role-assistant::before
47
+ content: "ChatGPT : "
48
+ color: $color2
49
+ /*border: 1px solid $color2
49
50
 
50
- .chatgpt-messagechild
51
- position: relative
52
- .chatgpt-control
53
- position: absolute
54
- left: -300vw
55
- &:only-child
56
- & > label
57
- display: none
58
- & > .chatgpt-message
59
- top: 0
60
- & > label
51
+ .chatgpt-messagechild
61
52
  position: relative
62
- display: block
63
- float: left
64
- padding-right: 0.2em
65
- padding-left: 0.2em
66
- margin-top: 0.1em
67
- &:first-child
53
+ .chatgpt-control
54
+ position: absolute
55
+ left: -300vw
56
+ &:only-child
57
+ & > label
58
+ display: none
59
+ & > .chatgpt-message
60
+ top: 0
61
+ & > label
62
+ position: relative
63
+ display: block
64
+ float: left
65
+ padding-right: 0.2em
66
+ padding-left: 0.2em
67
+ margin-top: 0.1em
68
+ &:first-child
69
+ margin-left: 0.3em
70
+ border-bottom: 1px solid $tab-border
71
+ .chatgpt-messagechild:first-child > label
68
72
  margin-left: 0.3em
69
- border-bottom: 1px solid $tab-border
70
- .chatgpt-messagechild:first-child > label
71
- margin-left: 0.3em
72
- .chatgpt-control:checked + label
73
- color: $cyan
74
- border: 1px solid $tab-border
75
- border-bottom: none
73
+ .chatgpt-control:checked + label
74
+ color: $cyan
75
+ border: 1px solid $tab-border
76
+ border-bottom: none
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JekyllChatgpt
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
@@ -3,6 +3,7 @@
3
3
  require_relative "jekyll-chatgpt/version"
4
4
  require "liquid"
5
5
  require "jekyll"
6
+ require "jekyll/converters/scss"
6
7
 
7
8
  module JekyllChatgpt
8
9
  class Error < StandardError; end
@@ -55,22 +56,44 @@ module JekyllChatgpt
55
56
  # Renders needed styles and JS
56
57
  class StyleGenerator < Jekyll::Generator
57
58
  safe true
58
- priority :lowest
59
+ priority :highest
60
+
61
+ def sass_converter(site)
62
+ @sass_converter ||= Jekyll::Converters::Sass.new(site.config)
63
+ end
64
+
65
+ def sass_exists(site, file)
66
+ sass_converter(site).sass_load_paths.each do |dir|
67
+ return true unless Dir.new(dir).children.index(file).nil?
68
+ end
69
+ false
70
+ end
71
+
72
+ def colors_exists?(site)
73
+ sass_exists(site, "_colors.sass")
74
+ end
75
+
76
+ def style_exists?(site)
77
+ sass_exists(site, "_chatgpt_custom.sass")
78
+ end
79
+
80
+ def add_js(site)
81
+ message_label_js = Jekyll::StaticFile.new(site, __dir__, "", "chatgpt_message_label.js")
82
+ site.static_files << message_label_js
83
+ end
59
84
 
60
85
  def generate(site)
61
86
  chatgpt_style = Jekyll::PageWithoutAFile.new(site, __dir__, "", "chatgpt.sass")
62
87
  chatgpt_style.tap do |file|
63
- colors_exists = site.pages.filter do |page|
64
- page.name =~ /colors\.sass$/i
65
- end.size
66
88
  file.content = ""
67
- file.content += "@import \"colors\"\n" if colors_exists
89
+ file.content += "@import \"colors\"\n\n" if colors_exists?(site)
90
+ file.content += "@layer chatgpt-default, chatgpt-custom\n\n"
91
+ file.content += "@layer chatgpt-custom\n @import \"chatgpt_custom\"\n\n" if style_exists?(site)
68
92
  file.content += File.read(File.expand_path("chatgpt.sass", __dir__))
69
93
  end
70
94
  site.pages << chatgpt_style
71
95
 
72
- message_label_js = Jekyll::StaticFile.new(site, __dir__, "", "chatgpt_message_label.js")
73
- site.static_files << message_label_js
96
+ add_js(site)
74
97
  end
75
98
  end
76
99
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-chatgpt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - pcouy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-15 00:00:00.000000000 Z
11
+ date: 2023-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll