nncli

NextCloud Notes Command Line Interface
git clone git://git.danielmoch.com/nncli.git
Log | Files | Refs | LICENSE

commit 9936dd7a2397df1df67da8444d6e7f2e151675db
parent 364da5b17c4d5b9eecdc6200a613b65018d583f9
Author: Eric Davis <edavis@insanum.com>
Date:   Mon, 14 Jul 2014 00:52:54 -0700

show url for notes that are published

Diffstat:
Msncli.py | 18+++++++++++-------
Mutils.py | 25+++++++++++--------------
Mview_note.py | 16+++++++++++++---
3 files changed, 35 insertions(+), 24 deletions(-)

diff --git a/sncli.py b/sncli.py @@ -761,7 +761,7 @@ def cli_note_dump(self, key): self.log(u'ERROR: Key does not exist') return - w = 50 + w = 60 sep = u'+' + u'-'*(w+2) + u'+' t = time.localtime(float(note['modifydate'])) mod_time = time.strftime('%a, %d %b %Y %H:%M:%S', t) @@ -770,12 +770,16 @@ def cli_note_dump(self, key): tags = utils.get_note_tags(note) print sep - print (u'| {:<' + str(w) + u'} |').format((u' Title: ' + title)[:w]) - print (u'| {:<' + str(w) + u'} |').format((u' Key: ' + note['key'])[:w]) - print (u'| {:<' + str(w) + u'} |').format((u' Date: ' + mod_time)[:w]) - print (u'| {:<' + str(w) + u'} |').format((u' Tags: ' + tags)[:w]) - print (u'| {:<' + str(w) + u'} |').format((u'Version: v' + str(note['version']))[:w]) - print (u'| {:<' + str(w) + u'} |').format((u' Flags: [' + flags + u']')[:w]) + print (u'| {:<' + str(w) + u'} |').format((u' Title: ' + title)[:w]) + print (u'| {:<' + str(w) + u'} |').format((u' Key: ' + note['key'])[:w]) + print (u'| {:<' + str(w) + u'} |').format((u' Date: ' + mod_time)[:w]) + print (u'| {:<' + str(w) + u'} |').format((u' Tags: ' + tags)[:w]) + print (u'| {:<' + str(w) + u'} |').format((u' Version: v' + str(note['version']))[:w]) + print (u'| {:<' + str(w) + u'} |').format((u' Flags: [' + flags + u']')[:w]) + if utils.note_published(note) and 'publishkey' in note: + print (u'| {:<' + str(w) + u'} |').format((u'Published: http://simp.ly/publish/' + note['publishkey'])[:w]) + else: + print (u'| {:<' + str(w) + u'} |').format((u'Published: n/a')[:w]) print sep print note['content'] diff --git a/utils.py b/utils.py @@ -25,10 +25,11 @@ def get_note_flags(note): flags = '' flags += u'T' if note['deleted'] else u' ' if 'systemtags' in note: - flags += u'*' if 'pinned' in note['systemtags'] else u' ' - flags += u'm' if 'markdown' in note['systemtags'] else u' ' + flags += u'*' if 'pinned' in note['systemtags'] else u' ' + flags += u'S' if 'published' in note['systemtags'] else u' ' + flags += u'm' if 'markdown' in note['systemtags'] else u' ' else: - flags += ' ' + flags += ' ' return flags def get_note_title(note): @@ -89,27 +90,23 @@ def human_date(timestamp): # not today or this year, so we do "Dec 11, 2011" return '%s %d, %d' % (dt.strftime('%b'), dt.day, dt.year) -def note_pinned(n): +def note_published(n): asystags = n.get('systemtags', 0) - # no systemtag at all if not asystags: return 0 + return 1 if 'published' in asystags else 0 - if 'pinned' in asystags: - return 1 - else: +def note_pinned(n): + asystags = n.get('systemtags', 0) + if not asystags: return 0 + return 1 if 'pinned' in asystags else 0 def note_markdown(n): asystags = n.get('systemtags', 0) - # no systemtag at all if not asystags: return 0 - - if 'markdown' in asystags: - return 1 - else: - return 0 + return 1 if 'markdown' in asystags else 0 tags_illegal_chars = re.compile(r'[\s]') def sanitise_tags(tags): diff --git a/view_note.py b/view_note.py @@ -78,9 +78,19 @@ def get_status_bar(self): 'status_bar')) pile_top = urwid.Columns([ status_title, status_key_index ]) pile_bottom = urwid.Columns([ status_date, status_tags_flags ]) - return \ - urwid.AttrMap(urwid.Pile([ pile_top, pile_bottom ]), - 'status_bar') + + if utils.note_published(self.note) and 'publishkey' in self.note: + pile_publish = \ + urwid.AttrMap(urwid.Text(u'Published: http://simp.ly/publish/' + + self.note['publishkey']), + 'status_bar') + return \ + urwid.AttrMap(urwid.Pile([ pile_top, pile_bottom, pile_publish ]), + 'status_bar') + else: + return \ + urwid.AttrMap(urwid.Pile([ pile_top, pile_bottom ]), + 'status_bar') def keypress(self, size, key): if key == self.config.get_keybind('tabstop2'):