plain-rails 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 +17 -1
- data/app/assets/builds/plain.css +1 -1
- data/app/assets/stylesheets/plain/application.tailwind.css +4 -0
- data/app/controllers/plain/conversations_controller.rb +5 -7
- data/app/controllers/plain/docs_controller.rb +51 -16
- data/app/controllers/plain/documents_controller.rb +28 -0
- data/app/helpers/plain/documents_helper.rb +4 -0
- data/app/models/plain/document.rb +49 -0
- data/app/services/plain/ai_docs.rb +2 -1
- data/app/services/plain/docs_service.rb +21 -3
- data/app/views/layouts/plain/application.html.erb +126 -105
- data/app/views/plain/conversations/_conversation_item.html.erb +18 -5
- data/app/views/plain/conversations/_conversation_list.html.erb +1 -1
- data/app/views/plain/conversations/destroy.turbo_stream.erb +1 -0
- data/app/views/plain/conversations/index.html.erb +2 -2
- data/app/views/plain/conversations/show.html.erb +2 -0
- data/app/views/plain/docs/_form.html.erb +41 -0
- data/app/views/plain/docs/_menu.erb +1 -4
- data/app/views/plain/docs/edit.html.erb +3 -0
- data/app/views/plain/docs/show.html.erb +19 -5
- data/app/views/plain/docs/update.turbo_stream.erb +3 -0
- data/app/views/plain/documents/_form.erb +47 -0
- data/app/views/plain/documents/create.turbo_stream.erb +15 -0
- data/app/views/plain/documents/new.html.erb +3 -0
- data/app/views/plain/home/index.html.erb +1 -1
- data/app/views/plain/messages/_message_item.html.erb +7 -6
- data/config/routes.rb +6 -1
- data/lib/plain/configuration.rb +2 -1
- data/lib/plain/version.rb +1 -1
- data/lib/tasks/plain_tasks.rake +39 -0
- metadata +14 -4
@@ -1,114 +1,135 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
2
|
<html data-controller="dark-mode">
|
3
|
-
<head>
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
static values = {
|
50
|
-
content: String
|
51
|
-
}
|
52
|
-
|
53
|
-
static targets = ["container"]
|
54
|
-
|
55
|
-
connect(){
|
56
|
-
console.log("content", this.contentValue)
|
57
|
-
this.renderMarkdoc()
|
58
|
-
}
|
59
|
-
|
60
|
-
contentValueChanged() {
|
61
|
-
this.renderMarkdoc()
|
62
|
-
}
|
63
|
-
|
64
|
-
renderMarkdoc(){
|
65
|
-
const ast = Markdoc.parse(this.contentValue)
|
66
|
-
console.log(ast)
|
67
|
-
const content = Markdoc.transform(ast, /* config */);
|
68
|
-
const html = Markdoc.renderers.html(content)
|
69
|
-
console.log(html)
|
70
|
-
|
71
|
-
this.containerTarget.innerHTML = html
|
72
|
-
|
73
|
-
this.containerTarget.querySelectorAll('pre').forEach((el) => {
|
74
|
-
hljs.highlightElement(el);
|
75
|
-
});
|
76
|
-
// console.log(`${Markdoc.renderers.html(content)}`)
|
77
|
-
}
|
78
|
-
})
|
79
|
-
|
80
|
-
Stimulus.register("highlight", class extends Controller {
|
81
|
-
connect(){
|
82
|
-
this.element.querySelectorAll('pre').forEach((el) => {
|
83
|
-
hljs.highlightElement(el);
|
84
|
-
});
|
85
|
-
}
|
86
|
-
})
|
87
|
-
|
88
|
-
Stimulus.register("dark-mode", class extends Controller {
|
89
|
-
initialize() {
|
90
|
-
if (localStorage.getItem('dark-mode') === 'enabled') {
|
91
|
-
this.element.classList.add('dark');
|
3
|
+
<head>
|
4
|
+
<title>Plain</title>
|
5
|
+
<%= csrf_meta_tags %>
|
6
|
+
<%= csp_meta_tag %>
|
7
|
+
|
8
|
+
|
9
|
+
<% if params[:static].present? %>
|
10
|
+
<style>
|
11
|
+
<%= Rails.application.assets.find_asset('plain.css').to_s %>
|
12
|
+
</style>
|
13
|
+
<% else %>
|
14
|
+
<%= stylesheet_link_tag "plain", "data-turbo-track": "reload" %>
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
<!-- actual rails host app -->
|
18
|
+
<% #= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %>
|
19
|
+
|
20
|
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/dark.min.css">
|
21
|
+
<!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/default.min.css">-->
|
22
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min.js"></script>
|
23
|
+
|
24
|
+
<link
|
25
|
+
rel="stylesheet"
|
26
|
+
href="https://cdn.jsdelivr.net/npm/easymde/dist/easymde.min.css"
|
27
|
+
/>
|
28
|
+
<script src="https://cdn.jsdelivr.net/npm/easymde/dist/easymde.min.js"></script>
|
29
|
+
|
30
|
+
<script type="module">
|
31
|
+
import Markdoc from "https://cdn.skypack.dev/@markdoc/markdoc";
|
32
|
+
window.Markdoc = Markdoc
|
33
|
+
</script>
|
34
|
+
|
35
|
+
<script type="module">
|
36
|
+
import {Turbo} from 'https://jspm.dev/@hotwired/turbo-rails';
|
37
|
+
window.Turbo = Turbo
|
38
|
+
</script>
|
39
|
+
|
40
|
+
<script type="module">
|
41
|
+
import { Application, Controller } from "https://unpkg.com/@hotwired/stimulus/dist/stimulus.js"
|
42
|
+
window.Stimulus = Application.start()
|
43
|
+
|
44
|
+
Stimulus.debug = true
|
45
|
+
Stimulus.register("scroll-to", class extends Controller {
|
46
|
+
// static targets = [ "scroll" ]
|
47
|
+
connect() {
|
48
|
+
this.element.scrollIntoView()
|
92
49
|
}
|
93
|
-
}
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
50
|
+
})
|
51
|
+
|
52
|
+
Stimulus.register("toggle-class", class extends Controller {
|
53
|
+
toggle(event) {
|
54
|
+
// Toggle 'active' class on button
|
55
|
+
event.currentTarget.classList.toggle('active');
|
56
|
+
|
57
|
+
// Toggle 'hidden' class on controller's root element
|
58
|
+
this.element.classList.toggle('hidden');
|
101
59
|
}
|
102
|
-
}
|
103
|
-
});
|
60
|
+
})
|
104
61
|
|
105
|
-
|
106
|
-
|
62
|
+
Stimulus.register("markdoc", class extends Controller {
|
63
|
+
static values = {
|
64
|
+
content: String
|
65
|
+
}
|
66
|
+
|
67
|
+
static targets = ["container"]
|
107
68
|
|
108
|
-
|
109
|
-
|
69
|
+
connect(){
|
70
|
+
console.log("content", this.contentValue)
|
71
|
+
this.renderMarkdoc()
|
72
|
+
}
|
73
|
+
|
74
|
+
contentValueChanged() {
|
75
|
+
this.renderMarkdoc()
|
76
|
+
}
|
110
77
|
|
111
|
-
|
78
|
+
renderMarkdoc(){
|
79
|
+
const ast = Markdoc.parse(this.contentValue)
|
80
|
+
console.log(ast)
|
81
|
+
const content = Markdoc.transform(ast, /* config */);
|
82
|
+
const html = Markdoc.renderers.html(content)
|
83
|
+
console.log(html)
|
112
84
|
|
113
|
-
|
85
|
+
this.containerTarget.innerHTML = html
|
86
|
+
|
87
|
+
this.containerTarget.querySelectorAll('pre').forEach((el) => {
|
88
|
+
hljs.highlightElement(el);
|
89
|
+
});
|
90
|
+
// console.log(`${Markdoc.renderers.html(content)}`)
|
91
|
+
}
|
92
|
+
})
|
93
|
+
|
94
|
+
Stimulus.register("highlight", class extends Controller {
|
95
|
+
connect(){
|
96
|
+
this.element.querySelectorAll('pre').forEach((el) => {
|
97
|
+
hljs.highlightElement(el);
|
98
|
+
});
|
99
|
+
}
|
100
|
+
})
|
101
|
+
|
102
|
+
Stimulus.register("dark-mode", class extends Controller {
|
103
|
+
initialize() {
|
104
|
+
if (localStorage.getItem('dark-mode') === 'enabled') {
|
105
|
+
this.element.classList.add('dark');
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
toggleDarkMode(e) {
|
110
|
+
e.preventDefault()
|
111
|
+
if (this.element.classList.toggle('dark')) {
|
112
|
+
localStorage.setItem('dark-mode', 'enabled');
|
113
|
+
} else {
|
114
|
+
localStorage.setItem('dark-mode', 'disabled');
|
115
|
+
}
|
116
|
+
}
|
117
|
+
});
|
118
|
+
|
119
|
+
Stimulus.register("markdown-editor", class extends Controller {
|
120
|
+
initialize() {
|
121
|
+
this.editor = new EasyMDE({element: this.element });
|
122
|
+
}
|
123
|
+
|
124
|
+
disconnect(){
|
125
|
+
this.editor && this.editor.cleanup()
|
126
|
+
}
|
127
|
+
});
|
128
|
+
</script>
|
129
|
+
|
130
|
+
</head>
|
131
|
+
|
132
|
+
<body class="antialiased text-zinc-500 dark:text-zinc-400 bg-white dark:bg-zinc-900">
|
133
|
+
<%= yield %>
|
134
|
+
</body>
|
114
135
|
</html>
|
@@ -1,11 +1,24 @@
|
|
1
|
-
<div class="p-2 rounded-sm hover:bg-black/5">
|
1
|
+
<div class="p-2 rounded-sm hover:bg-black/5" id="conversation-<%= conversation.id%>">
|
2
2
|
|
3
|
-
<div class="flex
|
3
|
+
<div class="flex justify-between">
|
4
4
|
|
5
|
-
|
5
|
+
<div class="flex space-x-2 ">
|
6
|
+
<%= render "plain/conversations/status", conversation: conversation %>
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
<%= link_to conversation_path(conversation), data: {"turbo-frame": "plain"} do %>
|
9
|
+
<span><%= conversation.subject || "new chat" %> </span>
|
10
|
+
<% end %>
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<% if !Rails.env.production? %>
|
14
|
+
<%= link_to conversation_path(conversation),
|
15
|
+
class: "rounded-full p-1 hover:border dark:border-gray-600",
|
16
|
+
"data-turbo-method": "delete",
|
17
|
+
"data-turbo-confirm": "sure?" do %>
|
18
|
+
<svg class="h-3 w-3" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" aria-hidden="true">
|
19
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12"></path>
|
20
|
+
</svg>
|
21
|
+
<% end %>
|
9
22
|
<% end %>
|
10
23
|
</div>
|
11
24
|
<p class="text-xs text-gray-400">
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<%= turbo_frame_tag "conversation-list-#{@current_page}" do %>
|
2
|
-
<div class="divide divide-y">
|
2
|
+
<div class="divide divide-y dark:divide-zinc-700">
|
3
3
|
<%= render partial: "plain/conversations/conversation_item", collection: @conversations, as: :conversation %>
|
4
4
|
</div>
|
5
5
|
<% if @conversations.size.positive? %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= turbo_stream.remove "conversation-#{@conversation.id}" %>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<%= turbo_frame_tag "plain" do %>
|
2
2
|
<%= render "modal" do %>
|
3
3
|
|
4
|
-
<div class="border shadow-sm rounded-md bg-white dark:bg-zinc-800 m-4">
|
4
|
+
<div class="border dark:border-zinc-900 shadow-sm rounded-md bg-white dark:bg-zinc-800 m-4">
|
5
5
|
<h2 class=" p-4 inline-block text-md sm:text-lg font-extrabold text-zinc-900 tracking-tight dark:text-zinc-200">
|
6
6
|
Continue conversations
|
7
7
|
</h2>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<%= render "plain/conversations/conversation_list" %>
|
11
11
|
</div>
|
12
12
|
|
13
|
-
<div class="flex justify-between px-3 py-2 text-xs font-medium border-t rounded-b-lg bg-zinc-100/75">
|
13
|
+
<div class="flex justify-between px-3 py-2 text-xs font-medium border-t dark:border-zinc-700 rounded-b-lg bg-zinc-100/75 dark:bg-zinc-900/75">
|
14
14
|
<%= link_to "New conversation", new_conversation_path, class: "btn-dark" %>
|
15
15
|
<%= link_to "See previous chats", conversations_path, class: "link" %>
|
16
16
|
</div>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
|
2
|
+
<%= form_for @document, url: update_doc_path(@file_path), method: :put do |f| %>
|
3
|
+
<div class="flex space-x-2 dark:bg-zinc-800 p-10 rounded-lg ">
|
4
|
+
|
5
|
+
<% #= @document.errors.full_messages %>
|
6
|
+
<div class="w-2/3">
|
7
|
+
<%= f.text_area :content, "data-controller": "markdown-editor"%>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<div>
|
11
|
+
|
12
|
+
<div class="sm:col-span-3">
|
13
|
+
<%= f.label :title, class: "block text-sm font-medium leading-6 text-gray-900 dark:text-gray-100" %>
|
14
|
+
<div class="mt-2">
|
15
|
+
<%= f.text_field :title, class: "bg-white dark:bg-transparent block w-full rounded-md border-0 py-1.5 text-gray-900 dark:text-gray-100 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6" %>
|
16
|
+
</div>
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<div class="sm:col-span-3">
|
20
|
+
<%= f.label :menu_position, class: "block text-sm font-medium leading-6 text-gray-900 dark:text-gray-100" %>
|
21
|
+
<div class="mt-2">
|
22
|
+
<%= f.number_field :menu_position, class: "bg-white dark:bg-transparent block w-full rounded-md border-0 py-1.5 text-gray-900 dark:text-gray-100 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6" %>
|
23
|
+
</div>
|
24
|
+
</div>
|
25
|
+
|
26
|
+
<div class="sm:col-span-4">
|
27
|
+
<%= f.label :path, class: "block text-sm font-medium leading-6 text-gray-900 dark:text-gray-100" %>
|
28
|
+
<div class="mt-2">
|
29
|
+
<div class="flex rounded-md shadow-sm ring-1 ring-inset ring-gray-300 focus-within:ring-2 focus-within:ring-inset focus-within:ring-indigo-600 sm:max-w-md">
|
30
|
+
<span class="flex select-none items-center pl-3 text-gray-500 sm:text-sm">/docs/</span>
|
31
|
+
<%= f.text_field :path, class: "block flex-1 border-0 bg-transparent py-1.5 pl-1 text-gray-900 dark:text-gray-100 placeholder:text-gray-400 focus:ring-0 sm:text-sm sm:leading-6", placeholder: "janesmith" %>
|
32
|
+
</div>
|
33
|
+
</div>
|
34
|
+
</div>
|
35
|
+
|
36
|
+
<%= f.submit class: "btn-dark my-2" %>
|
37
|
+
|
38
|
+
</div>
|
39
|
+
|
40
|
+
</div>
|
41
|
+
<% end %>
|
@@ -1,13 +1,11 @@
|
|
1
|
-
|
2
1
|
<ul role="list" class="border-l border-transparent">
|
3
|
-
|
4
2
|
<% nodes.each do |node| %>
|
5
3
|
<% if node[:type] == 'directory' %>
|
6
4
|
<li class="relative">
|
7
5
|
<span class="<%= level == 1 ? 'text-xs font-semibold text-zinc-900 dark:text-white' : 'flex justify-between gap-2 py-1 pr-3 text-sm transition pl-4 text-zinc-900 dark:text-white'%>">
|
8
6
|
<%= node[:name].capitalize.humanize %>
|
9
7
|
</span>
|
10
|
-
<%= render partial: 'menu', locals: { nodes: node[:children], level: level + 1 } %>
|
8
|
+
<%= render partial: 'plain/docs/menu', locals: { nodes: node[:children], level: level + 1 } %>
|
11
9
|
</li>
|
12
10
|
<% else %>
|
13
11
|
<li class="relative">
|
@@ -15,5 +13,4 @@
|
|
15
13
|
</li>
|
16
14
|
<% end %>
|
17
15
|
<% end %>
|
18
|
-
|
19
16
|
</ul>
|
@@ -8,7 +8,7 @@
|
|
8
8
|
<div class="contents lg:pointer-events-auto lg:block lg:w-72 lg:overflow-y-auto lg:border-r lg:border-zinc-900/10 lg:px-6 lg:pb-8 lg:pt-4 lg:dark:border-white/10 xl:w-80">
|
9
9
|
<div class="hidden lg:flex">
|
10
10
|
<a aria-label="Home" href="/" class="flex space-x-2 items-center">
|
11
|
-
<% if @config["logo"] %>
|
11
|
+
<% if @config["logo"] && params[:static].blank? %>
|
12
12
|
<%= image_tag(@config["logo"], class: "h-10") %>
|
13
13
|
<% end %>
|
14
14
|
<span class="font-extrabold uppercase text-xl">
|
@@ -107,7 +107,7 @@
|
|
107
107
|
|
108
108
|
</div>
|
109
109
|
|
110
|
-
<nav class="hidden lg:mt-10 lg:block">
|
110
|
+
<nav id="docs-menu" class="hidden lg:mt-10 lg:block">
|
111
111
|
<%= render partial: 'menu', locals: { nodes: @docs_structure[:children], level: 1 } %>
|
112
112
|
</nav>
|
113
113
|
|
@@ -116,9 +116,23 @@
|
|
116
116
|
|
117
117
|
<div class="relative px-4 pt-14 sm:px-6 lg:px-8">
|
118
118
|
<main class="py-16">
|
119
|
-
|
120
|
-
|
121
|
-
|
119
|
+
|
120
|
+
<%= turbo_frame_tag "doc-frame" do %>
|
121
|
+
<article class="prose dark:prose-invert" data-controller="highlight">
|
122
|
+
<%= @content.html_safe unless @content.nil? %>
|
123
|
+
</article>
|
124
|
+
<% end %>
|
125
|
+
|
126
|
+
<% if params[:file_path].present? && Rails.env.development? %>
|
127
|
+
<div class="flex justify-start">
|
128
|
+
<%= link_to edit_doc_path(params[:file_path]), "data-turbo-frame": "doc-frame", class: "rounded-link flex space-x-2 items-center" do %>
|
129
|
+
<span>Edit</span>
|
130
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
|
131
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L10.582 16.07a4.5 4.5 0 01-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 011.13-1.897l8.932-8.931zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0115.75 21H5.25A2.25 2.25 0 013 18.75V8.25A2.25 2.25 0 015.25 6H10" />
|
132
|
+
</svg>
|
133
|
+
<% end %>
|
134
|
+
</div>
|
135
|
+
<% end %>
|
122
136
|
</main>
|
123
137
|
|
124
138
|
|
@@ -0,0 +1,47 @@
|
|
1
|
+
<div class="my-2 col-span-1 divide-y divide-gray-200 dark:divide-gray-900 rounded-lg bg-gray-100 border dark:bg-zinc-900 shadow">
|
2
|
+
|
3
|
+
|
4
|
+
<div class="flex w-full items-center justify-between space-x-6 p-6">
|
5
|
+
<!--<div class="flex-1 truncate">
|
6
|
+
<div class="flex items-center space-x-3">
|
7
|
+
<h3 class="truncate text-sm font-medium text-gray-900">Jane Cooper</h3>
|
8
|
+
<span class="inline-flex flex-shrink-0 items-center rounded-full bg-green-50 px-1.5 py-0.5 text-xs font-medium text-green-700 ring-1 ring-inset ring-green-600/20">Admin</span>
|
9
|
+
</div>
|
10
|
+
<p class="mt-1 truncate text-sm text-gray-500">Regional Paradigm Technician</p>
|
11
|
+
</div>
|
12
|
+
<img class="h-10 w-10 flex-shrink-0 rounded-full bg-gray-300" src="https://images.unsplash.com/photo-1494790108377-be9c29b29330?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=4&w=256&h=256&q=60" alt="">
|
13
|
+
-->
|
14
|
+
|
15
|
+
<%= form_for document, url: conversation_message_documents_path(message.conversation, message) do |f| %>
|
16
|
+
|
17
|
+
|
18
|
+
<% if document.errors.any? %>
|
19
|
+
<div class="sm:col-span-3">
|
20
|
+
<div class="bg-red-600 text-white p-2 rounded-md text-xs">
|
21
|
+
<%= document.errors.full_messages.join("\n") %>
|
22
|
+
</div>
|
23
|
+
</div>
|
24
|
+
<% end %>
|
25
|
+
|
26
|
+
<div class="sm:col-span-3">
|
27
|
+
<%= f.label :title, class: "block text-sm font-medium leading-6 text-gray-900 dark:text-gray-100" %>
|
28
|
+
<div class="mt-2">
|
29
|
+
<%= f.text_field :title, class: "bg-white dark:bg-transparent block w-full rounded-md border-0 py-1.5 text-gray-900 dark:text-gray-100 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6" %>
|
30
|
+
</div>
|
31
|
+
</div>
|
32
|
+
|
33
|
+
<div class="sm:col-span-4">
|
34
|
+
<%= f.label :path, class: "block text-sm font-medium leading-6 text-gray-900 dark:text-gray-100" %>
|
35
|
+
<div class="mt-2">
|
36
|
+
<div class="flex rounded-md shadow-sm ring-1 ring-inset ring-gray-300 focus-within:ring-2 focus-within:ring-inset focus-within:ring-indigo-600 sm:max-w-md">
|
37
|
+
<span class="flex select-none items-center pl-3 text-gray-500 sm:text-sm">/docs/</span>
|
38
|
+
<%= f.text_field :path, class: "block flex-1 border-0 bg-transparent py-1.5 pl-1 text-gray-900 dark:text-gray-100 placeholder:text-gray-400 focus:ring-0 sm:text-sm sm:leading-6", placeholder: "janesmith" %>
|
39
|
+
</div>
|
40
|
+
</div>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<%= f.submit class: "btn-dark my-2" %>
|
44
|
+
<% end %>
|
45
|
+
|
46
|
+
</div>
|
47
|
+
</div>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<%= turbo_stream.update "action-form-#{@message.id}" do %>
|
2
|
+
<% if @document.errors.any? %>
|
3
|
+
<%= render "form", document: @document, message: @message %>
|
4
|
+
<% else %>
|
5
|
+
<div class="sm:col-span-3 my-2">
|
6
|
+
<div class="bg-green-600 text-white p-2 rounded-md text-xs">
|
7
|
+
Document successfully created
|
8
|
+
</div>
|
9
|
+
</div>
|
10
|
+
<% end %>
|
11
|
+
<% end %>
|
12
|
+
|
13
|
+
<%= turbo_stream.update "docs-menu" do %>
|
14
|
+
<%= render partial: 'plain/docs/menu', locals: { nodes: @docs_structure[:children], level: 1 } %>
|
15
|
+
<% end %>
|
@@ -5,7 +5,7 @@
|
|
5
5
|
Continue conversations
|
6
6
|
</h2>
|
7
7
|
|
8
|
-
<div class="grid grid-cols-1 divide-y dark:divide-zinc-700">
|
8
|
+
<div class="grid grid-cols-1 divide-y dark:divide-zinc-700 max-h-[57vh] overflow-auto">
|
9
9
|
<%= render partial: "plain/conversations/conversation_item", collection: @conversations, as: :conversation %>
|
10
10
|
</div>
|
11
11
|
<div class="flex justify-between px-3 py-2 text-xs font-medium border-t dark:border-zinc-700 rounded-b-lg bg-zinc-100/75 dark:bg-zinc-900/75">
|
@@ -31,14 +31,15 @@
|
|
31
31
|
<%= raw message.content %>
|
32
32
|
</div>
|
33
33
|
|
34
|
+
<%= turbo_frame_tag "action-form-#{message.id}" do %>
|
35
|
+
|
36
|
+
<% end %>
|
37
|
+
|
34
38
|
<div class="flex space-x-2">
|
35
39
|
<% if message.assistant? %>
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
<button class="btn">
|
40
|
-
OTHER action?
|
41
|
-
</button>
|
40
|
+
<%= link_to "Convert to doc",
|
41
|
+
plain.new_conversation_message_document_path(message.conversation, message),
|
42
|
+
class: "btn", "data-turbo-frame": "action-form-#{message.id}" %>
|
42
43
|
<% end %>
|
43
44
|
</div>
|
44
45
|
<% if local_assigns[:scroll] %>
|
data/config/routes.rb
CHANGED
@@ -6,9 +6,14 @@ Plain::Engine.routes.draw do
|
|
6
6
|
member do
|
7
7
|
put :pin
|
8
8
|
end
|
9
|
-
resources :messages
|
9
|
+
resources :messages do
|
10
|
+
resources :documents
|
11
|
+
end
|
10
12
|
end
|
11
13
|
|
12
14
|
get '/docs/*file_path', to: 'docs#show', as: :docs
|
13
15
|
get '/docs/', to: 'docs#show'
|
16
|
+
get '/doc_editor/*file_path', to: 'docs#edit', as: :edit_doc
|
17
|
+
put '/doc_editor/*file_path', to: 'docs#update', as: :update_doc
|
18
|
+
|
14
19
|
end
|
data/lib/plain/configuration.rb
CHANGED
data/lib/plain/version.rb
CHANGED
data/lib/tasks/plain_tasks.rake
CHANGED
@@ -19,4 +19,43 @@ namespace :plain do
|
|
19
19
|
--minify -w"
|
20
20
|
end
|
21
21
|
end
|
22
|
+
|
23
|
+
namespace :site do
|
24
|
+
desc "Compile site"
|
25
|
+
task compile: :environment do
|
26
|
+
require 'rack/static'
|
27
|
+
require 'fileutils'
|
28
|
+
|
29
|
+
# Ensure public/docs directory exists
|
30
|
+
FileUtils.mkdir_p(Rails.root.join('public', 'docs'))
|
31
|
+
|
32
|
+
# Get the structure from the DocsService class
|
33
|
+
structure = Plain::DocsService.get_structure
|
34
|
+
|
35
|
+
# Get all files from the structure
|
36
|
+
files = Plain::DocsService.get_all_files(structure)
|
37
|
+
|
38
|
+
# Generate the proper paths and compile the files
|
39
|
+
files.each do |file|
|
40
|
+
path = file[:path]
|
41
|
+
content = Plain::DocsService.get_content(path)
|
42
|
+
|
43
|
+
# Create necessary directories
|
44
|
+
FileUtils.mkdir_p(File.dirname(Rails.root.join('public', 'static-plain/docs', "#{path}.html")))
|
45
|
+
|
46
|
+
response = Rails.application.call( 'PATH_INFO' => "/plain/docs/#{path}",'HTTP_HOST' => 'localhost', 'HTTP_PORT' => "3000",'REQUEST_METHOD' => 'GET', 'QUERY_STRING' => 'static=true', 'rack.input' => StringIO.new)
|
47
|
+
|
48
|
+
if response.first == 200
|
49
|
+
html = response[2].first
|
50
|
+
|
51
|
+
html.gsub!(/href="\/plain\/docs\/([^"]*)"/, 'href="/static-plain/docs/\1.html"')
|
52
|
+
|
53
|
+
# Save compiled file to public/docs directory
|
54
|
+
File.open(Rails.root.join('public', 'static-plain/docs', "#{path}.html"), 'w') do |f|
|
55
|
+
f.write(html)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
22
61
|
end
|