From d0f8088176b96b41bb7fe5911b9a224883b4b9f1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Isma=C3=ABl=20Bouya?= Date: Thu, 20 Dec 2018 00:09:58 +0100 Subject: [PATCH] Add note taking applications --- default.nix | 37 ++++++++++ patches/terminal_velocity_fix_build.patch | 15 +++++ .../terminal_velocity_sort_found_notes.patch | 67 +++++++++++++++++++ 3 files changed, 119 insertions(+) create mode 100644 patches/terminal_velocity_fix_build.patch create mode 100644 patches/terminal_velocity_sort_found_notes.patch diff --git a/default.nix b/default.nix index 4592eef..c2fe492 100644 --- a/default.nix +++ b/default.nix @@ -86,6 +86,42 @@ let }; }; + buildPerlPackage = callPackage { }; + note = buildPerlPackage rec { + name = "note-1.3.26"; + src = fetchurl { + url = "mirror://cpan/authors/id/T/TL/TLINDEN/${name}.tar.gz"; + sha256 = "1h645rnb5vpms48fcyzvp7cwwcbf9k5xq49w2bpniyzzgk2brjrq"; + }; + outputs = ["out" "man"]; + buildInputs = [ perlPackages.YAML ]; + meta = with stdenv.lib; { + description = "A perl script for maintaining notes"; + homepage = http://www.daemon.de/NOTE; + license = licenses.gpl3; + maintainers = with maintainers; [ { name = "T.v.Dein"; email = "tlinden@cpan.org"; } ]; + platforms = platforms.unix; + }; + }; + + terminal_velocity = with python2Packages; buildPythonApplication rec { + pname = "terminal-velocity-git"; + version = "0.2.0"; + + patches = [ + # FIXME: update this patch when version changes + ./patches/terminal_velocity_fix_build.patch + ./patches/terminal_velocity_sort_found_notes.patch + ]; + + propagatedBuildInputs = [ chardet urwid sh pyyaml ]; + buildInputs = [ m2r restructuredtext_lint pygments ]; + + src = fetchPypi { + inherit pname version; + sha256 = "13yrkcmvh5h5fwnai61sbmqkrjyisz08n62pq0ada2lyyqf7g6b9"; + }; + }; in { inherit nix-prefetch-scripts; @@ -109,5 +145,6 @@ in inherit ranger; inherit profanity; inherit weechat; + inherit note terminal_velocity; #inherit nixos; } diff --git a/patches/terminal_velocity_fix_build.patch b/patches/terminal_velocity_fix_build.patch new file mode 100644 index 0000000..5c7f716 --- /dev/null +++ b/patches/terminal_velocity_fix_build.patch @@ -0,0 +1,15 @@ +diff --git a/setup.py b/setup.py +index 84a99e9..a783dff 100644 +--- a/setup.py ++++ b/setup.py +@@ -1,7 +1,9 @@ + from setuptools import setup + from m2r import parse_from_file + import restructuredtext_lint +-from mister_bump import bump ++ ++def bump(): ++ return "0.2.0" + + # Parser README.md into reStructuredText format + rst_readme = parse_from_file('README.md') diff --git a/patches/terminal_velocity_sort_found_notes.patch b/patches/terminal_velocity_sort_found_notes.patch new file mode 100644 index 0000000..8296d54 --- /dev/null +++ b/patches/terminal_velocity_sort_found_notes.patch @@ -0,0 +1,67 @@ +diff --git a/terminal_velocity/terminal_velocity.py b/terminal_velocity/terminal_velocity.py +index db2eb05..bb77dc6 100755 +--- a/terminal_velocity/terminal_velocity.py ++++ b/terminal_velocity/terminal_velocity.py +@@ -75,6 +75,10 @@ the default default will be used""" + default=defaults.get("log_file", "~/.tvlog"), + help="the file to log to (default: %(default)s)") + ++ parser.add_argument("-s", "--sort", dest="sort", action="store", ++ default=defaults.get("sort", "date"), ++ help="the note sorting rules. Possible values: date, title (default: %(default)s)") ++ + parser.add_argument("-p", "--print-config", dest="print_config", + action="store_true", default=False, + help="print your configuration settings then exit") +@@ -120,7 +124,7 @@ the default default will be used""" + try: + urwid_ui.launch(notes_dir=args.notes_dir, editor=args.editor, + extension=args.extension, extensions=args.extensions, +- exclude=args.exclude) ++ exclude=args.exclude, sort=args.sort) + except KeyboardInterrupt: + # Silence KeyboardInterrupt tracebacks on ctrl-c. + sys.exit() +diff --git a/terminal_velocity/urwid_ui.py b/terminal_velocity/urwid_ui.py +index 34cf4f6..caebcb9 100644 +--- a/terminal_velocity/urwid_ui.py ++++ b/terminal_velocity/urwid_ui.py +@@ -237,11 +237,12 @@ class NoteFilterListBox(urwid.ListBox): + class MainFrame(urwid.Frame): + """The topmost urwid widget.""" + +- def __init__(self, notes_dir, editor, extension, extensions, exclude=None): ++ def __init__(self, notes_dir, editor, extension, extensions, exclude=None, sort="date"): + + self.editor = editor + self.notebook = notebook.PlainTextNoteBook(notes_dir, extension, + extensions, exclude=exclude) ++ self.sort = sort + + # Don't filter the note list when the text in the search box changes. + self.suppress_filter = False +@@ -408,7 +409,10 @@ class MainFrame(urwid.Frame): + + # Sort the notes. + # TODO: Support different sort orderings. +- matching_notes.sort(key=lambda x: x.mtime, reverse=True) ++ if self.sort == "title": ++ matching_notes.sort(key=lambda x: x.title) ++ else: ++ matching_notes.sort(key=lambda x: x.mtime, reverse=True) + + # Tell the list box to show only the matching notes. + self.list_box.filter(matching_notes) +@@ -433,10 +437,10 @@ class MainFrame(urwid.Frame): + self.selected_note = note + + +-def launch(notes_dir, editor, extension, extensions, exclude=None): ++def launch(notes_dir, editor, extension, extensions, exclude=None, sort="date"): + """Launch the user interface.""" + +- frame = MainFrame(notes_dir, editor, extension, extensions, exclude=exclude) ++ frame = MainFrame(notes_dir, editor, extension, extensions, exclude=exclude, sort=sort) + loop = urwid.MainLoop(frame, palette) + frame.loop = loop + loop.run() -- 2.41.0