vita 0.1.0 → 0.2.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: 3d91b8ed0e012e5d41566ed51182c9c0626be2129e0ee942276f6ca845b43035
4
- data.tar.gz: 5e28af902f3f09d9d4096f21401c45c3d39a20120e82f04f1ea4df8af15abb23
3
+ metadata.gz: 86ecbe16917de241d894f019175d823a4e06606cee81f5d20534210e159ac814
4
+ data.tar.gz: f497eab7e3b8e2cd4828a9a39f16e792653f2583c4fa4e3b21b6fc6cdb75e806
5
5
  SHA512:
6
- metadata.gz: d8bfef7a32f9ebfd417ca52f14838fe3edc9dcdb506a276b6d8476e3967840d15f1f6b95e9749026a420c5b97c17e16e07d34f445b5720b2a3936455dd88c714
7
- data.tar.gz: cae831f65056900dcb9c439916b23fb09d9d48c9977bdad674099398d4fe558e8ffbb337057070970acd9b21f660eb526e18bafd1a34f8eff28f817c0b4d28bd
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
@@ -6,7 +6,13 @@ module Vita
6
6
  class Markdown
7
7
  include Singleton
8
8
  def initialize
9
- @markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML)
9
+ @markdown = Redcarpet::Markdown.new(
10
+ Redcarpet::Render::HTML,
11
+ fenced_code_blocks: true,
12
+ highlight: true,
13
+ space_after_headers: true,
14
+ strikethrough: true
15
+ )
10
16
  end
11
17
 
12
18
  def name
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/main.rb CHANGED
@@ -68,6 +68,7 @@ module Vita
68
68
  end
69
69
 
70
70
  def open_browser
71
+ Server.await_startup
71
72
  Launchy.open(server_url)
72
73
  end
73
74
 
data/lib/vita/server.rb CHANGED
@@ -2,6 +2,10 @@ require "sinatra"
2
2
 
3
3
  module Vita
4
4
  class Server < Sinatra::Base
5
+ def self.await_startup
6
+ sleep 0.1 until settings.running?
7
+ end
8
+
5
9
  configure do
6
10
  enable :quiet
7
11
  set :port, 9000
data/lib/vita/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Vita
2
- VERSION = "0.1.0"
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.0
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-19 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