vita 0.1.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 30ec3104878bed6bb49429fa0c92603a7620ec376351c446c293715f35ea0e5b
4
- data.tar.gz: e81e41f8df895e5f62364df1a42bfc7d44faf40a41815676dd71cad0e38f8e72
3
+ metadata.gz: 86ecbe16917de241d894f019175d823a4e06606cee81f5d20534210e159ac814
4
+ data.tar.gz: f497eab7e3b8e2cd4828a9a39f16e792653f2583c4fa4e3b21b6fc6cdb75e806
5
5
  SHA512:
6
- metadata.gz: 69a47a2d3dd45ac46ab4fe9d807f5b441e667499822c0ee2f61689a7dcafba664879659455bbaf46c0212fafb54cf0697ff5edbc44f2959964d984985c47b466
7
- data.tar.gz: 1be52214d2daee544a50fecf7f68295efaf3fae9435a61c37524f66012d26092e6e4adcd0905e4c7610e15534d6d91bcd9ea0fa5bd5015f10408052d472b1b1c
6
+ metadata.gz: 73a39e21fdfe22f0b143b387e8ed06edc534ed8cd46e519f70a395b7307bc354304780111d05ee9753986393521d6f6202eeb687c99c83d770bebd623a79ffe7
7
+ data.tar.gz: 5fea8bdbc8437cb18639f6f4bc5f88205ecac87621a75e57245097c95ff8000c41eabd65424ee6660c4cebb59b50a021781b2c9dfd6993d29d077dc9c1a0b4ab
data/README.md CHANGED
@@ -43,17 +43,31 @@ Vita creates a `publish` folder containing HTML files for publishing to a web se
43
43
 
44
44
  ## Links between notes
45
45
 
46
- Vita looks for connections between notes.
46
+ 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.
47
47
 
48
- When a note's content includes the title of another note, Vita creates a link between the two notes.
48
+ When viewing a note, links in the note's content are hyperlinked:
49
49
 
50
- Links are clickable. Wherever a note's title appears in another note's content, clicking on it navigates to that note:
50
+ <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%">
51
51
 
52
- <img src="doc/outlinks.png" alt="Screenshot of a note in Vita, showing hyperlinks from a note's content to other notes">
52
+ A list of links from other notes to the current note follows the note's content:
53
53
 
54
- Each note lists the other notes that link to it, along with an excerpt from the source note. Clicking on any of these navigates to the source note:
54
+ <img src="doc/backlinks.png" alt="Screenshot of the &quot;links to this note&quot; panel in Vita, showing notes that reference the current note" style="width: 75%">
55
55
 
56
- <img src="doc/backlinks.png" alt="Screenshot of the &quot;links to this note&quot; panel in Vita, showing notes that reference the currently-displayed note">
56
+ Each link includes an excerpt from the other note. Clicking one of these links navigates to the other note.
57
+
58
+ ## Synonyms
59
+
60
+ 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.
61
+
62
+ 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.
63
+
64
+ 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`:
65
+
66
+ ```
67
+ Synonyms: cohesive, coherent, coherence
68
+
69
+ A module is cohesive if the elements in the module are related and the module is coherent as a whole.
70
+ ```
57
71
 
58
72
  ## Home note
59
73
 
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
@@ -60,7 +60,9 @@ module Vita
60
60
 
61
61
  def notes=(notes)
62
62
  @notes = notes.map { |note| GardenNote.new(self, note) }.sort_by(&:title)
63
- @notes_hash = @notes.map { |note| [note.title.downcase, note] }.to_h
63
+ @notes_hash = @notes.flat_map { |note|
64
+ note.all_names.map { |name| [name.downcase, note] }
65
+ }.to_h
64
66
 
65
67
  if home_note
66
68
  @notes.delete(home_note)
@@ -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
- def title_regexp
20
- /\b#{Regexp.quote(title)}\b/i
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(&:title_regexp))
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/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Vita
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
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.1.1
4
+ version: 0.2.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-02-20 00:00:00.000000000 Z
11
+ date: 2024-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redcarpet