From 1c5d0a57ccc56677274d2257b3cc6d9e494a807e Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Mon, 11 Jun 2012 15:39:45 +0200 Subject: [PATCH 1/6] Adds feedback on updating jrnl_conf --- jrnl/jrnl.py | 1 + 1 file changed, 1 insertion(+) diff --git a/jrnl/jrnl.py b/jrnl/jrnl.py index 811cd222..40019f3a 100755 --- a/jrnl/jrnl.py +++ b/jrnl/jrnl.py @@ -36,6 +36,7 @@ def update_config(config): config[key] = default_config[key] with open(CONFIG_PATH, 'w') as f: json.dump(config, f, indent=2) + print("[.jrnl_conf updated to newest version]") def parse_args(): parser = argparse.ArgumentParser() From 5c86f0b18b179f16207df929d87b13bc905afafa Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Mon, 11 Jun 2012 15:58:25 +0200 Subject: [PATCH 2/6] Adds support for multiple journals --- jrnl/install.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/jrnl/install.py b/jrnl/install.py index 49f58e31..5098fd51 100644 --- a/jrnl/install.py +++ b/jrnl/install.py @@ -17,7 +17,9 @@ def module_exists(module_name): return True default_config = { - 'journal': os.path.expanduser("~/journal.txt"), + 'journals': { + "default": os.path.expanduser("~/journal.txt") + }, 'editor': "", 'encrypt': False, 'password': "", @@ -61,7 +63,7 @@ def install_jrnl(config_path='~/.jrnl_config'): print("clint not found. To turn on highlighting, install clint and set highlight to true in your .jrnl_conf.") default_config['highlight'] = False - open(default_config['journal'], 'a').close() # Touch to make sure it's there + open(default_config['journals']['default'], 'a').close() # Touch to make sure it's there # Write config to ~/.jrnl_conf with open(config_path, 'w') as f: From 35ea3aab931e5ac53bf098eba0b7df9d667aac0f Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Mon, 11 Jun 2012 16:02:21 +0200 Subject: [PATCH 3/6] Adds support for multiple journals --- jrnl/jrnl.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/jrnl/jrnl.py b/jrnl/jrnl.py index 40019f3a..0e2d7af1 100755 --- a/jrnl/jrnl.py +++ b/jrnl/jrnl.py @@ -129,6 +129,14 @@ def print_tags(journal): for n, tag in sorted(tag_counts, reverse=True): print("{:20} : {}".format(tag, n)) + +def touch_journal(filename): + """If filename does not exist, touch the file""" + if not os.path.exists(filename): + print("[Journal created at {}".format(filename)) + open(filename, 'a').close() + + def cli(): if not os.path.exists(CONFIG_PATH): config = install_jrnl(CONFIG_PATH) @@ -142,7 +150,17 @@ def cli(): print("According to your jrnl_conf, your journal is encrypted, however PyCrypto was not found. To open your journal, install the PyCrypto package from http://www.pycrypto.org.") sys.exit(-1) - args = parse_args() + args = parse_args() + + # If the first textual argument points to a journal file, + # use this! + if args.text and args.text[0] in config['journals']: + config['journal'] = config['journals'].get(args.text[0]) + args.text = args.text[1:] + else: + config['journal'] = config['journals'].get('default') + + touch_journal(config['journal']) mode_compose, mode_export = guess_mode(args, config) # open journal file From b00e8944faed99caf11b01a684bff81bb6311638 Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Mon, 11 Jun 2012 16:08:38 +0200 Subject: [PATCH 4/6] Installation modifies journals.default, not journal --- jrnl/install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jrnl/install.py b/jrnl/install.py index 5098fd51..7341f8bb 100644 --- a/jrnl/install.py +++ b/jrnl/install.py @@ -45,7 +45,7 @@ def install_jrnl(config_path='~/.jrnl_config'): # Where to create the journal? path_query = 'Path to your journal file (leave blank for ~/journal.txt): ' journal_path = raw_input(path_query).strip() or os.path.expanduser('~/journal.txt') - default_config['journal'] = os.path.expanduser(journal_path) + default_config['journals']['default'] = os.path.expanduser(journal_path) # Encrypt it? if module_exists("Crypto"): From 61865a88b9859dd53c35e61ca75ef824c1cb372c Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Mon, 11 Jun 2012 16:16:26 +0200 Subject: [PATCH 5/6] Help on multiple journals. --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0515f4ab..115fef5d 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ The first time launched, _jrnl_ will create a file called `.jrnl_config` in your The configuration file is a simple JSON file with the following options. - - `journal`: path to your journal file + - `journals`: path to your journal files - `editor`: if set, executes this command to launch an external editor for writing your entries, e.g. `vim` or `subl -w` (note the `-w` flag to make sure _jrnl_ waits for Sublime Text to close the file before writing into the journal). - `encrypt`: if `true`, encrypts your journal using AES. - `password`: you may store the password you used to encrypt your journal in plaintext here. This is useful if your journal file lives in an unsecure space (ie. your Dropbox), but the config file itself is more or less safe. @@ -117,6 +117,17 @@ The configuration file is a simple JSON file with the following options. > > Or use the built-in prompt or an external editor to compose your entries. +### Multiple journal files + +You can configure _jrnl_ to use with multiple journals (eg. `private` and `work`) by defining more journals in your `.jrnl_config`, for example: + + "journals": { + "default": "~/journal.txt", + "work": "~/work.txt" + }, + +The `default` journal gets created the first time you start _jrnl_. Now you can access the `work` journal by using `jrnl work` instead of `jrnl`, eg. `jrnl work at 10am: Meeting with @Steve" or `jrnl work -n 3` will use `~/work.txt`, while `jrnl -n 3` will display the last three entries from `~/journal.txt` (and so does `jrnl default -n 3`). + ### JSON export Can do: From 955efe5096400ac189591782d23897ebdb8849a8 Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Mon, 11 Jun 2012 16:17:25 +0200 Subject: [PATCH 6/6] [Improved] Supports multiple journal files. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10e77795..101dbc11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Changelog * [Improved] Supports deleting of last entry. * [Fixed] Fixes a bug where --encrypt or --decrypt without a target file would not work. * [Improved] Supports a config option for setting word wrap. +* [Improved] Supports multiple journal files. ### 0.3.0 (May 24, 2012)