aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--default.nix37
-rw-r--r--patches/terminal_velocity_fix_build.patch15
-rw-r--r--patches/terminal_velocity_sort_found_notes.patch67
3 files changed, 119 insertions, 0 deletions
diff --git a/default.nix b/default.nix
index 4592eef..c2fe492 100644
--- a/default.nix
+++ b/default.nix
@@ -86,6 +86,42 @@ let
86 }; 86 };
87 }; 87 };
88 88
89 buildPerlPackage = callPackage <nixpkgs/pkgs/development/perl-modules/generic> { };
90 note = buildPerlPackage rec {
91 name = "note-1.3.26";
92 src = fetchurl {
93 url = "mirror://cpan/authors/id/T/TL/TLINDEN/${name}.tar.gz";
94 sha256 = "1h645rnb5vpms48fcyzvp7cwwcbf9k5xq49w2bpniyzzgk2brjrq";
95 };
96 outputs = ["out" "man"];
97 buildInputs = [ perlPackages.YAML ];
98 meta = with stdenv.lib; {
99 description = "A perl script for maintaining notes";
100 homepage = http://www.daemon.de/NOTE;
101 license = licenses.gpl3;
102 maintainers = with maintainers; [ { name = "T.v.Dein"; email = "tlinden@cpan.org"; } ];
103 platforms = platforms.unix;
104 };
105 };
106
107 terminal_velocity = with python2Packages; buildPythonApplication rec {
108 pname = "terminal-velocity-git";
109 version = "0.2.0";
110
111 patches = [
112 # FIXME: update this patch when version changes
113 ./patches/terminal_velocity_fix_build.patch
114 ./patches/terminal_velocity_sort_found_notes.patch
115 ];
116
117 propagatedBuildInputs = [ chardet urwid sh pyyaml ];
118 buildInputs = [ m2r restructuredtext_lint pygments ];
119
120 src = fetchPypi {
121 inherit pname version;
122 sha256 = "13yrkcmvh5h5fwnai61sbmqkrjyisz08n62pq0ada2lyyqf7g6b9";
123 };
124 };
89in 125in
90 { 126 {
91 inherit nix-prefetch-scripts; 127 inherit nix-prefetch-scripts;
@@ -109,5 +145,6 @@ in
109 inherit ranger; 145 inherit ranger;
110 inherit profanity; 146 inherit profanity;
111 inherit weechat; 147 inherit weechat;
148 inherit note terminal_velocity;
112 #inherit nixos; 149 #inherit nixos;
113 } 150 }
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 @@
1diff --git a/setup.py b/setup.py
2index 84a99e9..a783dff 100644
3--- a/setup.py
4+++ b/setup.py
5@@ -1,7 +1,9 @@
6 from setuptools import setup
7 from m2r import parse_from_file
8 import restructuredtext_lint
9-from mister_bump import bump
10+
11+def bump():
12+ return "0.2.0"
13
14 # Parser README.md into reStructuredText format
15 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 @@
1diff --git a/terminal_velocity/terminal_velocity.py b/terminal_velocity/terminal_velocity.py
2index db2eb05..bb77dc6 100755
3--- a/terminal_velocity/terminal_velocity.py
4+++ b/terminal_velocity/terminal_velocity.py
5@@ -75,6 +75,10 @@ the default default will be used"""
6 default=defaults.get("log_file", "~/.tvlog"),
7 help="the file to log to (default: %(default)s)")
8
9+ parser.add_argument("-s", "--sort", dest="sort", action="store",
10+ default=defaults.get("sort", "date"),
11+ help="the note sorting rules. Possible values: date, title (default: %(default)s)")
12+
13 parser.add_argument("-p", "--print-config", dest="print_config",
14 action="store_true", default=False,
15 help="print your configuration settings then exit")
16@@ -120,7 +124,7 @@ the default default will be used"""
17 try:
18 urwid_ui.launch(notes_dir=args.notes_dir, editor=args.editor,
19 extension=args.extension, extensions=args.extensions,
20- exclude=args.exclude)
21+ exclude=args.exclude, sort=args.sort)
22 except KeyboardInterrupt:
23 # Silence KeyboardInterrupt tracebacks on ctrl-c.
24 sys.exit()
25diff --git a/terminal_velocity/urwid_ui.py b/terminal_velocity/urwid_ui.py
26index 34cf4f6..caebcb9 100644
27--- a/terminal_velocity/urwid_ui.py
28+++ b/terminal_velocity/urwid_ui.py
29@@ -237,11 +237,12 @@ class NoteFilterListBox(urwid.ListBox):
30 class MainFrame(urwid.Frame):
31 """The topmost urwid widget."""
32
33- def __init__(self, notes_dir, editor, extension, extensions, exclude=None):
34+ def __init__(self, notes_dir, editor, extension, extensions, exclude=None, sort="date"):
35
36 self.editor = editor
37 self.notebook = notebook.PlainTextNoteBook(notes_dir, extension,
38 extensions, exclude=exclude)
39+ self.sort = sort
40
41 # Don't filter the note list when the text in the search box changes.
42 self.suppress_filter = False
43@@ -408,7 +409,10 @@ class MainFrame(urwid.Frame):
44
45 # Sort the notes.
46 # TODO: Support different sort orderings.
47- matching_notes.sort(key=lambda x: x.mtime, reverse=True)
48+ if self.sort == "title":
49+ matching_notes.sort(key=lambda x: x.title)
50+ else:
51+ matching_notes.sort(key=lambda x: x.mtime, reverse=True)
52
53 # Tell the list box to show only the matching notes.
54 self.list_box.filter(matching_notes)
55@@ -433,10 +437,10 @@ class MainFrame(urwid.Frame):
56 self.selected_note = note
57
58
59-def launch(notes_dir, editor, extension, extensions, exclude=None):
60+def launch(notes_dir, editor, extension, extensions, exclude=None, sort="date"):
61 """Launch the user interface."""
62
63- frame = MainFrame(notes_dir, editor, extension, extensions, exclude=exclude)
64+ frame = MainFrame(notes_dir, editor, extension, extensions, exclude=exclude, sort=sort)
65 loop = urwid.MainLoop(frame, palette)
66 frame.loop = loop
67 loop.run()