cnote 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/cnote.gemspec +0 -1
- data/lib/cnote/note.rb +19 -14
- data/lib/cnote/notes.rb +10 -12
- data/lib/cnote/version.rb +1 -1
- data/lib/cnote.rb +0 -4
- metadata +1 -17
- data/gems.locked +0 -14
- data/gems.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f576ae8756a70983786ca2c5fd60e057103e520
|
4
|
+
data.tar.gz: 4f8d882001c3402892ee357a925e04b491bd2a52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d50be2e44a608d3f58cbba5d861e16f34086319abbea7e541cf0e08864af389f83fdb8f88e7dd87db1551f228132f3073d9304017220c27998a66b55c9d39dfe
|
7
|
+
data.tar.gz: 862a4fe135058318ca4c4014b5bbd9eb8ac4fd03ef11787f8d83f66508d832eef57c1249045fefd01b1fba17c348b2c773d46c6f21e5ce9103aee18ba422a542
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# CNote
|
2
2
|
> CLI notes app for Linux (and probably macOS) ((and maybe Windows Subsystem for Linux)) written in Ruby
|
3
3
|
|
4
|
-
CNote is my personal system for managing notes. I wanted something snappy and lightweight that would let me search, tag and edit a folder full of markdown files using just my keyboard and some `vim
|
4
|
+
CNote is my personal system for managing notes. I wanted something snappy and lightweight that would let me search, tag and edit a folder full of markdown files using just my keyboard and some `vim`-ish single-letter commands.
|
5
5
|
|
6
6
|
## Installation
|
7
7
|
|
@@ -11,7 +11,7 @@ First of all, make sure you have a recent version of Ruby installed (including R
|
|
11
11
|
|
12
12
|
## Usage
|
13
13
|
|
14
|
-
CNote will be installed as a command on your machine. To get started, run `cnote`. The first time you run `cnote`, you'll be walked through the basic setup process which will produce a `.cnote.yaml` file within your `$HOME` directory. To skip this, just create the file yourself. Valid options for this file are covered [here](#).
|
14
|
+
CNote will be installed as a command on your machine. To get started, run `cnote`. The first time you run `cnote`, you'll be walked through the basic setup process which will produce a `.cnote.yaml` file within your `$HOME` directory. To skip this, just create the file yourself. Valid options for this file are covered [here](#configuration).
|
15
15
|
|
16
16
|
```
|
17
17
|
$ cnote
|
data/cnote.gemspec
CHANGED
data/lib/cnote/note.rb
CHANGED
@@ -19,7 +19,9 @@ class Note
|
|
19
19
|
@filename = File.basename(path)
|
20
20
|
@path = path
|
21
21
|
|
22
|
-
|
22
|
+
File.open(@path, "r") do |file|
|
23
|
+
refresh(file.read)
|
24
|
+
end
|
23
25
|
|
24
26
|
@modified = File.mtime(@path) if !@modified
|
25
27
|
@created = @modified if !@created
|
@@ -27,19 +29,20 @@ class Note
|
|
27
29
|
@title = "Untitled" if !@title
|
28
30
|
end
|
29
31
|
|
30
|
-
def refresh
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
@content << line + "\n"
|
32
|
+
def refresh(contents)
|
33
|
+
@title = nil
|
34
|
+
@content = ''
|
35
|
+
|
36
|
+
contents.each_line do |line|
|
37
|
+
line = line.strip
|
38
|
+
if @meta_regex =~ line
|
39
|
+
parse_meta($~[1])
|
40
|
+
elsif !@title
|
41
|
+
if line != ""
|
42
|
+
@title = line.gsub(/#|[^a-z0-9\s\.\-]/i, "").strip
|
42
43
|
end
|
44
|
+
else
|
45
|
+
@content << line + "\n"
|
43
46
|
end
|
44
47
|
end
|
45
48
|
end
|
@@ -102,7 +105,7 @@ class Note
|
|
102
105
|
# Leave two empty lines before metadata.
|
103
106
|
contents = contents.lines.slice(0, contents.lines.length - trailing_empty).join("")
|
104
107
|
|
105
|
-
contents += "\n
|
108
|
+
contents += "\n"
|
106
109
|
contents += "<!--- created: #{@created} -->\n"
|
107
110
|
contents += "<!--- modified: #{@modified} -->\n"
|
108
111
|
contents += "<!--- tags: #{@tags.join(", ")} -->\n"
|
@@ -110,6 +113,8 @@ class Note
|
|
110
113
|
File.open(@path, "w") do |file|
|
111
114
|
file.write(contents)
|
112
115
|
end
|
116
|
+
|
117
|
+
refresh(contents)
|
113
118
|
end
|
114
119
|
end
|
115
120
|
end
|
data/lib/cnote/notes.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require "ap"
|
2
1
|
require "colorize"
|
3
2
|
require "fileutils"
|
4
3
|
require "time"
|
@@ -7,11 +6,7 @@ require "cnote/note"
|
|
7
6
|
class Notes
|
8
7
|
def initialize(config)
|
9
8
|
@config = config
|
10
|
-
@notes = Dir[File.join(@config.note_path, "
|
11
|
-
File.extname(file) == ".md"
|
12
|
-
end.map do |file|
|
13
|
-
Note.new(file)
|
14
|
-
end
|
9
|
+
@notes = Dir[File.join(@config.note_path, "**/*.md")].map { |f| Note.new(f) }
|
15
10
|
@filtered = @notes
|
16
11
|
end
|
17
12
|
|
@@ -162,8 +157,8 @@ class Notes
|
|
162
157
|
num = params.first.to_i
|
163
158
|
note = @filtered[num - 1]
|
164
159
|
|
165
|
-
if note
|
166
|
-
if confirm("You're #{
|
160
|
+
if note and File.exists? note.path
|
161
|
+
if confirm("You're #{'sure'.italic} you want to delete note #{num.to_s.bold.white} with title #{note.title.bold.white}?")
|
167
162
|
FileUtils.rm(note.path)
|
168
163
|
@notes.delete(note)
|
169
164
|
@filtered.delete(note)
|
@@ -179,12 +174,15 @@ class Notes
|
|
179
174
|
def peek(params)
|
180
175
|
note = @filtered[params.first.to_i - 1]
|
181
176
|
if note
|
177
|
+
lines = note.content.lines
|
182
178
|
puts
|
183
179
|
puts "-" * 40
|
184
180
|
puts note.title.bold.white
|
185
|
-
puts
|
186
|
-
|
187
|
-
|
181
|
+
puts lines.slice(0, 15)
|
182
|
+
if lines.length > 15
|
183
|
+
puts
|
184
|
+
puts "(#{lines.length - 15} more line#{'s' if lines.length != 16}...)".italic
|
185
|
+
end
|
188
186
|
puts "-" * 40
|
189
187
|
puts
|
190
188
|
else
|
@@ -281,7 +279,7 @@ class Notes
|
|
281
279
|
tags = note.tags.map { |tag| tag.yellow }
|
282
280
|
puts " tags: " + "[#{tags.join('] [')}]"
|
283
281
|
else
|
284
|
-
puts " <no tags>"
|
282
|
+
puts " <no tags>"
|
285
283
|
end
|
286
284
|
puts " modified: " + note.modified.strftime("%a, %b %e %Y, %l:%M%P").italic
|
287
285
|
puts " created: " + note.created.strftime("%a, %b %e %Y, %l:%M%P").italic
|
data/lib/cnote/version.rb
CHANGED
data/lib/cnote.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cnote
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony McCoy
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: awesome_print
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '1.8'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '1.8'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: colorize
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -102,8 +88,6 @@ files:
|
|
102
88
|
- classes/notes.rb
|
103
89
|
- cnote.gemspec
|
104
90
|
- exe/cnote
|
105
|
-
- gems.locked
|
106
|
-
- gems.rb
|
107
91
|
- lib/cnote.rb
|
108
92
|
- lib/cnote/config.rb
|
109
93
|
- lib/cnote/note.rb
|
data/gems.locked
DELETED