jekyll-chatgpt 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/chatgpt.sass +5 -0
- data/lib/chatgpt_message_label.js +10 -0
- data/lib/jekyll-chatgpt/version.rb +1 -1
- data/lib/jekyll-chatgpt.rb +33 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4897cd9cf94d69f8d4ce0416eba0bf76b685dabccca22e9e2c15f6c33920d074
|
4
|
+
data.tar.gz: a6af3a6b8cbadba800968c8157557c310bf97736b0bfe48601277ba71cae2e8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58d614fee1d9bb4c82286a8b787a0224ae94da8101ffd084d579c2b1808e5875fa192c1cc2d481fb8687d85bb070006730d60643c0b3d2239189d23282fcae06
|
7
|
+
data.tar.gz: 968d297f492fc523b6e8c28547e42cf7f63cdfc504aabacd1b873b0352f8f4d434f118a096d67e191643c1b2bbd92bf8bcefae31dc8db38db880beeadf904c07
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# JekyllChatgpt
|
2
2
|
|
3
|
-
This plugin inctroduces a `chatgpt` Liquid filter that formats ChatGPT conversations. It
|
3
|
+
This plugin inctroduces a `chatgpt` Liquid filter that formats ChatGPT conversations. It mostly uses CSS to navigate in branching conversations (except for links to specific messages inside a conversation, see "Usage" below). A [live demo of deploying the demo branch of this repository to Github pages is available](https://pierre-couy.dev/jekyll-chatgpt) ([code](https://github.com/pcouy/jekyll-chatgpt/tree/demo))
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -26,6 +26,7 @@ Optionally, include a stylesheet for code syntax highlighting in ChatGPT output.
|
|
26
26
|
|
27
27
|
1. Download a conversation from [your ChatGPT history](https://chat.openai.com/). When on the ChatGPT web page, open your browser dev-tools (usually using F12) and go to the "Network" tab. Now, pick a conversation in the web-app. The URL in your browser should now look like `chat.openapi.com/chat/{some-random-looking-id}`. In the network tab of the developer tools, find the request to `{some-random-looking-id}` and right-click on it and pick "Copy > Copy response". You can now paste what you just copied into a JSON file inside your `_data` folder (for instance, `_data/chatgpt/test_conversation.json`).
|
28
28
|
2. You can now use `{{ site.data.chatgpt['test_conversation'] | chatgpt }}` anywhere in your liquid-rendered content to include the conversation in your website. This will render markdown in messages by default. You can disable markdown rendering by passing the `false` argument to the filter : `{{ site.data.chatgpt['test_conversation'] | chatgpt: false }}`.
|
29
|
+
3. You will be able to link to specific messages in conversations by using the `chatgpt_message_lagel` tag in the following way : `{% chatgpt_message_label [MESSAGE_ID] in [CONVERSATION] %}[LABEL_TEXT]{% endchatgpt_message_label %}` where `[MESSAGE_ID]` is the start of a message id ; `[CONVERSATION]` is the variable representing a conversation ; `[LABEL_TEXT]` is the displayed link text. Here is an example from [the demo page](https://pierre-couy.dev/jekyll-chatgpt) : `{% chatgpt_message_label 55bb5 in site.data.chatgpt["date"] %}a message{% endchatgpt_message_label %}`. This functionality uses Javascript, if you want to use it you must add the following tag to your `<head>` : `<script defer src="/chatgpt_message_label.js"></script>` (the JS file is automatically written to your website's output directory)
|
29
30
|
|
30
31
|
### Customizing the colors
|
31
32
|
|
data/lib/chatgpt.sass
CHANGED
@@ -0,0 +1,10 @@
|
|
1
|
+
document.querySelectorAll('.chatgpt-deep-label').forEach(e=>{
|
2
|
+
e.addEventListener("click",ev=>{
|
3
|
+
ev.preventDefault();
|
4
|
+
t=document.querySelector(`.chatgpt-control + label[for=${e.attributes["for"].value}]`);
|
5
|
+
if(t) t.click();
|
6
|
+
if(e.parentElement.classList.contains("chatgpt-target")) {
|
7
|
+
e.parentElement.click();
|
8
|
+
}
|
9
|
+
})
|
10
|
+
});
|
data/lib/jekyll-chatgpt.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative "jekyll-chatgpt/version"
|
4
4
|
require "liquid"
|
5
|
+
require "jekyll"
|
5
6
|
|
6
7
|
module JekyllChatgpt
|
7
8
|
class Error < StandardError; end
|
@@ -24,7 +25,34 @@ module JekyllChatgpt
|
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
27
|
-
# Renders
|
28
|
+
# Renders nested `label` tags to display a message deep inside a branching
|
29
|
+
# conversation
|
30
|
+
class MessageLabel < Liquid::For
|
31
|
+
def render(context)
|
32
|
+
message_id_short = @variable_name
|
33
|
+
conversation = context.evaluate(@collection_name)
|
34
|
+
messages = conversation["mapping"]
|
35
|
+
message_id = messages.keys.filter do |id_candidate|
|
36
|
+
id_candidate.start_with? message_id_short
|
37
|
+
end.first
|
38
|
+
message_path = [message_id]
|
39
|
+
message = messages[message_id]
|
40
|
+
while message
|
41
|
+
message = messages[message["parent"]]
|
42
|
+
message_path.append(message["id"]) if message
|
43
|
+
end
|
44
|
+
res = "<a class=\"chatgpt-target\" href=\"\##{message_id}\">"
|
45
|
+
res += message_path.map do |path_id|
|
46
|
+
"<label class=\"chatgpt-deep-label\" for=\"chatgpt-control-#{path_id}\">"
|
47
|
+
end.join("")
|
48
|
+
res += @for_block.render(context)
|
49
|
+
res += message_path.map { |_| "</label>" }.join("")
|
50
|
+
res += "</a>"
|
51
|
+
res
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# Renders needed styles and JS
|
28
56
|
class StyleGenerator < Jekyll::Generator
|
29
57
|
safe true
|
30
58
|
priority :lowest
|
@@ -40,8 +68,12 @@ module JekyllChatgpt
|
|
40
68
|
file.content += File.read(File.expand_path("chatgpt.sass", __dir__))
|
41
69
|
end
|
42
70
|
site.pages << chatgpt_style
|
71
|
+
|
72
|
+
message_label_js = Jekyll::StaticFile.new(site, __dir__, "", "chatgpt_message_label.js")
|
73
|
+
site.static_files << message_label_js
|
43
74
|
end
|
44
75
|
end
|
45
76
|
end
|
46
77
|
|
47
78
|
Liquid::Template.register_filter(JekyllChatgpt::Filter)
|
79
|
+
Liquid::Template.register_tag("chatgpt_message_label", JekyllChatgpt::MessageLabel)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-chatgpt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pcouy
|
@@ -41,6 +41,7 @@ files:
|
|
41
41
|
- lib/chatgpt.sass
|
42
42
|
- lib/chatgpt_innermessage.html
|
43
43
|
- lib/chatgpt_message.html
|
44
|
+
- lib/chatgpt_message_label.js
|
44
45
|
- lib/jekyll-chatgpt.rb
|
45
46
|
- lib/jekyll-chatgpt/version.rb
|
46
47
|
- sig/jekyll_chatgpt.rbs
|