vita 0.1.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +22 -6
- data/doc/backlinks.png +0 -0
- data/doc/notes.png +0 -0
- data/doc/outlinks.png +0 -0
- data/lib/vita/garden.rb +12 -2
- data/lib/vita/garden_note.rb +26 -4
- data/lib/vita/server.rb +11 -0
- data/lib/vita/version.rb +1 -1
- data/lib/vita/watcher.rb +13 -0
- data/lib/vita.rb +1 -0
- data/templates/note.html.erb +5 -0
- metadata +33 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1718643c6633bbe89990a662fd29739153a7233dd21352d8784b7af27a74383a
|
4
|
+
data.tar.gz: 89cf60afa27e2b06d8d43251c9ebe64f81a2f7b19ac8c3ecc154acd95af77943
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18f962183bc9bf35ca240b8820ca882770b6edc3b82d0a183f3adf6553044c207ec3705dc2f6098e2113618ac9258c0d6e39c8356fd4d383989cf8cb0aed3303
|
7
|
+
data.tar.gz: e129b89cc3194e9eca15fdb1e14a786150df89a53c278fef0f250e0449d520e09f2dad7a2913158bc532736fad5d8f4b24d0bfd24dcd85d6986a7e9e46280cdd
|
data/README.md
CHANGED
@@ -33,6 +33,8 @@ __ _(_) |_ __ _
|
|
33
33
|
Starting Vita at http://localhost:9000
|
34
34
|
```
|
35
35
|
|
36
|
+
Your web browser refreshes as you make changes to your files.
|
37
|
+
|
36
38
|
To publish:
|
37
39
|
|
38
40
|
```
|
@@ -43,17 +45,31 @@ Vita creates a `publish` folder containing HTML files for publishing to a web se
|
|
43
45
|
|
44
46
|
## Links between notes
|
45
47
|
|
46
|
-
Vita looks for connections between notes.
|
48
|
+
Vita looks for connections between notes. When a note's title (or a [synonym](#synonyms)) appears in the content of another note, Vita creates a link between the two.
|
49
|
+
|
50
|
+
When viewing a note, links in the note's content are hyperlinked:
|
51
|
+
|
52
|
+
<img src="doc/outlinks.png" alt="Screenshot of a note in Vita, showing hyperlinks from a note's content to other notes" style="width: 75%">
|
53
|
+
|
54
|
+
A list of links from other notes to the current note follows the note's content:
|
55
|
+
|
56
|
+
<img src="doc/backlinks.png" alt="Screenshot of the "links to this note" panel in Vita, showing notes that reference the current note" style="width: 75%">
|
47
57
|
|
48
|
-
|
58
|
+
Each link includes an excerpt from the other note. Clicking one of these links navigates to the other note.
|
49
59
|
|
50
|
-
|
60
|
+
## Synonyms
|
51
61
|
|
52
|
-
|
62
|
+
Synonyms allow referring to notes using multiple names. Adding synonyms can be helpful when a note's title appears in other notes in different forms or tenses.
|
53
63
|
|
54
|
-
|
64
|
+
For example, notes may refer to a note titled "Cohesion" using terms like "cohesive", "coherent", or "coherence". Adding these words as synonyms to the "Cohesion" note allows Vita to connect the notes with links.
|
55
65
|
|
56
|
-
|
66
|
+
To specify a note's synonyms, add a `Synonyms:` line at the start of the file containing a comma-separated list of alternative names. For example, in a file called `Cohesion.txt`:
|
67
|
+
|
68
|
+
```
|
69
|
+
Synonyms: cohesive, coherent, coherence
|
70
|
+
|
71
|
+
A module is cohesive if the elements in the module are related and the module is coherent as a whole.
|
72
|
+
```
|
57
73
|
|
58
74
|
## Home note
|
59
75
|
|
data/doc/backlinks.png
CHANGED
Binary file
|
data/doc/notes.png
CHANGED
Binary file
|
data/doc/outlinks.png
CHANGED
Binary file
|
data/lib/vita/garden.rb
CHANGED
@@ -15,7 +15,11 @@ module Vita
|
|
15
15
|
raise Vita::Error.new("Directory not found at #{root}")
|
16
16
|
end
|
17
17
|
|
18
|
-
Dir[
|
18
|
+
Dir[note_filename_pattern(root)].map { |filename| Note.new(filename) }
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.note_filename_pattern(root)
|
22
|
+
File.join(root, "*.*")
|
19
23
|
end
|
20
24
|
|
21
25
|
def initialize(root, notes)
|
@@ -56,11 +60,17 @@ module Vita
|
|
56
60
|
links.filter { |link| link.to_note == note }
|
57
61
|
end
|
58
62
|
|
63
|
+
def note_filename_pattern
|
64
|
+
self.class.note_filename_pattern(root)
|
65
|
+
end
|
66
|
+
|
59
67
|
private
|
60
68
|
|
61
69
|
def notes=(notes)
|
62
70
|
@notes = notes.map { |note| GardenNote.new(self, note) }.sort_by(&:title)
|
63
|
-
@notes_hash = @notes.
|
71
|
+
@notes_hash = @notes.flat_map { |note|
|
72
|
+
note.all_names.map { |name| [name.downcase, note] }
|
73
|
+
}.to_h
|
64
74
|
|
65
75
|
if home_note
|
66
76
|
@notes.delete(home_note)
|
data/lib/vita/garden_note.rb
CHANGED
@@ -12,12 +12,30 @@ module Vita
|
|
12
12
|
@note = note
|
13
13
|
end
|
14
14
|
|
15
|
+
# Get this note's primary title.
|
15
16
|
def title
|
16
17
|
@note.title
|
17
18
|
end
|
18
19
|
|
19
|
-
|
20
|
-
|
20
|
+
# Get alternative names for this note.
|
21
|
+
def synonyms
|
22
|
+
if @note.content.start_with? "Synonyms:"
|
23
|
+
@note.content[9..@note.content.index("\n")].split(",").map(&:strip)
|
24
|
+
else
|
25
|
+
[]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Get all names for this note, including its title and synonyms.
|
30
|
+
def all_names
|
31
|
+
[title, *synonyms]
|
32
|
+
end
|
33
|
+
|
34
|
+
# Get a regular expression that matches any of this note's names surrounded
|
35
|
+
# by word boundaries.
|
36
|
+
def names_regexp
|
37
|
+
elements = all_names.map { |name| /#{Regexp.quote(name)}/i }
|
38
|
+
/\b#{Regexp.union(elements)}\b/
|
21
39
|
end
|
22
40
|
|
23
41
|
def path
|
@@ -29,7 +47,11 @@ module Vita
|
|
29
47
|
end
|
30
48
|
|
31
49
|
def content
|
32
|
-
@note.content
|
50
|
+
if @note.content.start_with? "Synonyms:"
|
51
|
+
@note.content[@note.content.index("\n") + 1..]
|
52
|
+
else
|
53
|
+
@note.content
|
54
|
+
end
|
33
55
|
end
|
34
56
|
|
35
57
|
def html
|
@@ -62,7 +84,7 @@ module Vita
|
|
62
84
|
|
63
85
|
def create_outlinks
|
64
86
|
notes = garden.linkable_notes - [self]
|
65
|
-
regexp = Regexp.union(notes.map(&:
|
87
|
+
regexp = Regexp.union(notes.map(&:names_regexp))
|
66
88
|
matches = NoteScanner.new(content).scan(regexp)
|
67
89
|
|
68
90
|
matches.map do |match|
|
data/lib/vita/server.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
require "sinatra"
|
2
|
+
require "sinatra/streaming"
|
2
3
|
|
3
4
|
module Vita
|
4
5
|
class Server < Sinatra::Base
|
6
|
+
helpers Sinatra::Streaming
|
7
|
+
|
5
8
|
def self.await_startup
|
6
9
|
sleep 0.1 until settings.running?
|
7
10
|
end
|
@@ -25,6 +28,14 @@ module Vita
|
|
25
28
|
end
|
26
29
|
end
|
27
30
|
|
31
|
+
get "/events", provides: "text/event-stream" do
|
32
|
+
stream do |out|
|
33
|
+
Watcher.new(garden).watch do
|
34
|
+
out << "event: change\ndata: {}\n\n"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
28
39
|
get "/:path.html" do |path|
|
29
40
|
note = garden.note_at_path("#{path}.html")
|
30
41
|
|
data/lib/vita/version.rb
CHANGED
data/lib/vita/watcher.rb
ADDED
data/lib/vita.rb
CHANGED
data/templates/note.html.erb
CHANGED
@@ -16,6 +16,7 @@
|
|
16
16
|
<script defer src="https://unpkg.com/htmx.org@1.9.10"></script>
|
17
17
|
</head>
|
18
18
|
<body>
|
19
|
+
<div hx-trigger="sse:change" hx-get="/<%= h note.path %>" hx-target="body">
|
19
20
|
<nav class="navbar bg-body-tertiary mb-3">
|
20
21
|
<div class="container">
|
21
22
|
<a class="navbar-brand" href="/">
|
@@ -70,10 +71,14 @@
|
|
70
71
|
</div>
|
71
72
|
</div>
|
72
73
|
</div>
|
74
|
+
</div>
|
73
75
|
<script defer>
|
74
76
|
if (location.protocol !== "file:") {
|
75
77
|
document.body.setAttribute('hx-boost', true);
|
76
78
|
}
|
79
|
+
if (location.port === "9000") {
|
80
|
+
document.body.setAttribute('hx-sse', 'connect:/events');
|
81
|
+
}
|
77
82
|
</script>
|
78
83
|
</body>
|
79
84
|
</html>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vita
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alec Cursley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redcarpet
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '4.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: sinatra-contrib
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '4.0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '4.0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rackup
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +108,20 @@ dependencies:
|
|
94
108
|
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '6.4'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: filewatcher
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '2.1'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '2.1'
|
97
125
|
- !ruby/object:Gem::Dependency
|
98
126
|
name: rake
|
99
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -170,14 +198,14 @@ dependencies:
|
|
170
198
|
requirements:
|
171
199
|
- - "~>"
|
172
200
|
- !ruby/object:Gem::Version
|
173
|
-
version: 1.
|
201
|
+
version: 1.35.1
|
174
202
|
type: :development
|
175
203
|
prerelease: false
|
176
204
|
version_requirements: !ruby/object:Gem::Requirement
|
177
205
|
requirements:
|
178
206
|
- - "~>"
|
179
207
|
- !ruby/object:Gem::Version
|
180
|
-
version: 1.
|
208
|
+
version: 1.35.1
|
181
209
|
description:
|
182
210
|
email:
|
183
211
|
- alec@cursley.net
|
@@ -210,6 +238,7 @@ files:
|
|
210
238
|
- lib/vita/rendering_context.rb
|
211
239
|
- lib/vita/server.rb
|
212
240
|
- lib/vita/version.rb
|
241
|
+
- lib/vita/watcher.rb
|
213
242
|
- templates/note.html.erb
|
214
243
|
homepage: https://github.com/cursley/vita
|
215
244
|
licenses:
|