commit 85558d58b28e64ad261092eef7160ba0b1d9f761
parent 83a8c9d9190ff889732856cb1e76f97eb2daf288
Author: Daniel Moch <daniel@danielmoch.com>
Date: Fri, 27 Jul 2018 13:34:12 -0400
Fix crashes and remove markdown options
Notes assumes all notes are markdown
Diffstat:
7 files changed, 6 insertions(+), 86 deletions(-)
diff --git a/README.md b/README.md
@@ -54,7 +54,6 @@ Check your OS distribution for installation packages.
- edit note tags
- trash/untrash notes
- pin/unpin notes
- - flag notes as markdown or not
- vi-like keybinds (fully configurable)
- Colors! (fully configurable)
* Command Line (scripting)
@@ -69,7 +68,6 @@ Check your OS distribution for installation packages.
- edit a note (via editor)
- trash/untrash a note
- pin/unpin a note
- - flag note as markdown or not
- view and edit note tags
### HowTo
@@ -95,8 +93,6 @@ Check your OS distribution for installation packages.
- dump a note (specified by <key>) edit - edit a
note (specified by <key>) < trash | untrash > - trash/untrash
a note (specified by <key>) < pin | unpin > - pin/unpin a
- note (specified by <key>) < markdown | unmarkdown > -
- markdown/unmarkdown a note (specified by <key>) tag get
- retrieve the tags from a note (specified by <key>) tag set <tags>
- set the tags for a note (specified by <key>) tag add <tags>
- add tags to a note (specified by <key>) tag rm <tags>
@@ -162,7 +158,7 @@ formatting tags supports a width specifier (decimal) and a left
justification (-) like that supported by printf:
``` %F - flags (fixed 5 char width) X - needs sync T - trashed
- * - pinned S - published/shared m - markdown %T - tags %D - date
+ * - pinned S - published/shared m - tags %D - date
%N - title ```
The default note title format pushes the note tags to the far right of
diff --git a/nnotes_cli/config.py b/nnotes_cli/config.py
@@ -114,7 +114,6 @@ def __init__(self, custom_file=None):
'kb_sort_tags' : 'ctrl t',
'kb_note_trash' : 'T',
'kb_note_pin' : 'p',
- 'kb_note_markdown' : 'm',
'kb_note_tags' : 't',
'kb_copy_note_text' : 'y',
@@ -255,7 +254,6 @@ def __init__(self, custom_file=None):
self.keybinds['sort_tags'] = [ cp.get(cfg_sec, 'kb_sort_tags'), [ 'titles' ], 'Sort notes by tags' ]
self.keybinds['note_trash'] = [ cp.get(cfg_sec, 'kb_note_trash'), [ 'titles', 'notes' ], 'Trash a note' ]
self.keybinds['note_pin'] = [ cp.get(cfg_sec, 'kb_note_pin'), [ 'titles', 'notes' ], 'Pin note' ]
- self.keybinds['note_markdown'] = [ cp.get(cfg_sec, 'kb_note_markdown'), [ 'titles', 'notes' ], 'Flag note as markdown' ]
self.keybinds['note_tags'] = [ cp.get(cfg_sec, 'kb_note_tags'), [ 'titles', 'notes' ], 'Edit note tags' ]
self.keybinds['copy_note_text'] = [ cp.get(cfg_sec, 'kb_copy_note_text'), [ 'notes' ], 'Copy line (xsel/pbcopy)' ]
diff --git a/nnotes_cli/nncli.py b/nnotes_cli/nncli.py
@@ -790,30 +790,6 @@ def gui_frame_keypress(self, size, key):
self.ndb.sync_worker_go()
- elif key == self.config.get_keybind('note_markdown'):
- if self.gui_body_get().__class__ != view_titles.ViewTitles and \
- self.gui_body_get().__class__ != view_note.ViewNote:
- return key
-
- if self.gui_body_get().__class__ == view_titles.ViewTitles:
- if len(lb.body.positions()) <= 0:
- return None
- note = lb.note_list[lb.focus_position].note
- else: # self.gui_body_get().__class__ == view_note.ViewNote:
- note = lb.note
-
- md = 1
- if 'systemtags' in note:
- if 'markdown' in note['systemtags']: md = 0
- else: md = 1
-
- self.ndb.set_note_markdown(note['localkey'], md)
-
- if self.gui_body_get().__class__ == view_titles.ViewTitles:
- lb.update_note_title()
-
- self.ndb.sync_worker_go()
-
elif key == self.config.get_keybind('note_tags'):
if self.gui_body_get().__class__ != view_titles.ViewTitles and \
self.gui_body_get().__class__ != view_note.ViewNote:
@@ -1224,16 +1200,6 @@ def cli_note_pin(self, key, pin):
self.ndb.set_note_pinned(key, pin)
self.sync_notes()
- def cli_note_markdown(self, key, markdown):
-
- note = self.ndb.get_note(key)
- if not note:
- self.log('ERROR: Key does not exist')
- return
-
- self.ndb.set_note_markdown(key, markdown)
- self.sync_notes()
-
def cli_note_tags_get(self, key):
note = self.ndb.get_note(key)
@@ -1328,7 +1294,6 @@ def usage():
edit - edit a note (specified by <key>)
< trash | untrash > - trash/untrash a note (specified by <key>)
< pin | unpin > - pin/unpin a note (specified by <key>)
- < markdown | unmarkdown > - markdown/unmarkdown a note (specified by <key>)
tag get - retrieve the tags from a note (specified by <key>)
tag set <tags> - set the tags for a note (specified by <key>)
tag add <tags> - add tags to a note (specified by <key>)
@@ -1450,14 +1415,6 @@ def nncli_start(sync=sync, verbose=verbose, config=config):
sn = nncli_start()
sn.cli_note_pin(key, 1 if args[0] == 'pin' else 0)
- elif args[0] == 'markdown' or args[0] == 'unmarkdown':
-
- if not key:
- usage()
-
- sn = nncli_start()
- sn.cli_note_markdown(key, 1 if args[0] == 'markdown' else 0)
-
# Tag API
elif args[0] == 'tag':
diff --git a/nnotes_cli/notes_db.py b/nnotes_cli/notes_db.py
@@ -433,21 +433,6 @@ def set_note_pinned(self, key, pinned):
self.flag_what_changed(n, 'systemtags')
self.log('Note {0} (key={1})'.format('pinned' if pinned else 'unpinned', key))
- def set_note_markdown(self, key, markdown):
- n = self.notes[key]
- old_markdown = utils.note_markdown(n)
- if markdown != old_markdown:
- if 'systemtags' not in n:
- n['systemtags'] = []
- systemtags = n['systemtags']
- if markdown:
- systemtags.append('markdown')
- else:
- systemtags.remove('markdown')
- n['modified'] = time.time()
- self.flag_what_changed(n, 'systemtags')
- self.log('Note markdown {0} (key={1})'.format('flagged' if markdown else 'unflagged', key))
-
def helper_key_to_fname(self, k):
return os.path.join(self.config.get_config('db_path'), str(k)) + '.json'
@@ -577,7 +562,7 @@ def sync_notes(self, server_sync=True, full_sync=True):
skip_remote_syncing = True
# 3. for each remote note
- # if remote syncnum > local syncnum ||
+ # if remote modified > local modified ||
# a new note and key is not in local store
# retrieve note, update note with response
if not skip_remote_syncing:
@@ -590,7 +575,7 @@ def sync_notes(self, server_sync=True, full_sync=True):
if k in self.notes:
# we already have this note
# if the server note has a newer syncnum we need to get it
- if int(n.get('syncnum')) > int(self.notes[k].get('syncnum', -1)):
+ if int(n.get('modified')) > int(self.notes[k].get('modified')):
gret = self.note.get_note(k)
if gret[1] == 0:
self.notes[k].update(gret[0])
diff --git a/nnotes_cli/temp.py b/nnotes_cli/temp.py
@@ -13,11 +13,7 @@ def tempfile_create(note, raw=False, tempdir=None):
tf.write(contents.encode('utf-8'))
tf.flush()
else:
- ext = '.txt'
- if note and \
- 'systemtags' in note and \
- 'markdown' in note['systemtags']:
- ext = '.mkd'
+ ext = '.mkd'
tf = tempfile.NamedTemporaryFile(suffix=ext, delete=False, dir=tempdir)
if note:
contents = note['content']
diff --git a/nnotes_cli/utils.py b/nnotes_cli/utils.py
@@ -56,7 +56,6 @@ def get_note_tags(note):
# 'T' - trashed
# '*' - pinned
# 'S' - published/shared
-# 'm' - markdown
def get_note_flags(note):
flags = ''
flags += 'X' if float(note['modified']) > float(note['syncdate']) else ' '
@@ -64,7 +63,6 @@ def get_note_flags(note):
if 'systemtags' in note:
flags += '*' if 'pinned' in note['systemtags'] else ' '
flags += 'S' if 'published' in note['systemtags'] else ' '
- flags += 'm' if 'markdown' in note['systemtags'] else ' '
else:
flags += ' '
return flags
@@ -90,11 +88,7 @@ def get_note_title_file(note):
else:
fn = str(fn)
- if note_markdown(note):
- fn += '.mkdn'
- else:
- fn += '.txt'
-
+ fn += '.mkdn'
return fn
else:
return ''
@@ -139,12 +133,6 @@ def note_pinned(n):
return 0
return 1 if 'pinned' in asystags else 0
-def note_markdown(n):
- asystags = n.get('systemtags', 0)
- if not asystags:
- return 0
- return 1 if 'markdown' in asystags else 0
-
# TODO: NextCloud notes doesn't have a concept of tags, but it does
# allow assignment of notes to a single category. Refactor to take this
# into account
diff --git a/nnotes_cli/view_note.py b/nnotes_cli/view_note.py
@@ -152,7 +152,7 @@ def get_status_bar(self):
status_key_index = \
('pack', urwid.AttrMap(urwid.Text(' [' +
- self.key +
+ str(self.key) +
'] ' +
str(cur + 1) +
'/' +