From 9f615191b4374eb8c850dca8dee1de6c4f903db2 Mon Sep 17 00:00:00 2001 From: Micah Ellison <4383304+micahellison@users.noreply.github.com> Date: Sat, 25 Jan 2020 15:39:05 -0800 Subject: [PATCH 1/9] Prevent Travis from turning LF to CRLF in Windows --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 37dab626..8219d49a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ cache: git: depth: false + autocrlf: false before_install: - date From 25a7577f0b5d46acc57a32b2234ddab1ac733118 Mon Sep 17 00:00:00 2001 From: Micah Ellison <4383304+micahellison@users.noreply.github.com> Date: Sat, 25 Jan 2020 15:40:05 -0800 Subject: [PATCH 2/9] Remove all skip_win directives now that Travis is not mangling newlines on Windows --- features/core.feature | 1 - features/dayone_regressions.feature | 1 - features/encryption.feature | 3 --- features/upgrade.feature | 3 --- 4 files changed, 8 deletions(-) diff --git a/features/core.feature b/features/core.feature index c023cd4c..94da701a 100644 --- a/features/core.feature +++ b/features/core.feature @@ -20,7 +20,6 @@ Feature: Basic reading and writing to a journal When we run "jrnl -n 1" Then the output should contain "2013-07-23 09:00 A cold and stormy day." - @skip_win Scenario: Writing an empty entry from the editor Given we use the config "editor.yaml" When we open the editor and enter "" diff --git a/features/dayone_regressions.feature b/features/dayone_regressions.feature index f6098ba6..62c8cc24 100644 --- a/features/dayone_regressions.feature +++ b/features/dayone_regressions.feature @@ -24,7 +24,6 @@ Feature: Zapped Dayone bugs stay dead! | I'm feeling sore because I forgot to stretch. """ - @skip_win Scenario: Opening an folder that's not a DayOne folder gives a nice error message Given we use the config "empty_folder.yaml" When we run "jrnl Herro" diff --git a/features/encryption.feature b/features/encryption.feature index 081a208f..787fa850 100644 --- a/features/encryption.feature +++ b/features/encryption.feature @@ -12,7 +12,6 @@ Then we should see the message "Journal decrypted" And the journal should have 2 entries - @skip_win Scenario: Encrypting a journal Given we use the config "basic.yaml" When we run "jrnl --encrypt" and enter @@ -27,7 +26,6 @@ Then the output should contain "Password" And the output should contain "2013-06-10 15:40 Life is good" - @skip_win Scenario: Mistyping your password Given we use the config "basic.yaml" When we run "jrnl --encrypt" and enter @@ -45,7 +43,6 @@ Then the output should contain "Password" And the output should contain "2013-06-10 15:40 Life is good" - @skip_win Scenario: Storing a password in Keychain Given we use the config "multiple.yaml" When we run "jrnl simple --encrypt" and enter diff --git a/features/upgrade.feature b/features/upgrade.feature index b2c569c7..ef597d4f 100644 --- a/features/upgrade.feature +++ b/features/upgrade.feature @@ -1,6 +1,5 @@ Feature: Upgrading Journals from 1.x.x to 2.x.x - @skip_win Scenario: Upgrade and parse journals with square brackets Given we use the config "upgrade_from_195.json" When we run "jrnl -9" and enter "Y" @@ -12,7 +11,6 @@ Feature: Upgrading Journals from 1.x.x to 2.x.x """ Then the journal should have 2 entries - @skip_win Scenario: Upgrading a journal encrypted with jrnl 1.x Given we use the config "encrypted_old.json" When we run "jrnl -n 1" and enter @@ -24,7 +22,6 @@ Feature: Upgrading Journals from 1.x.x to 2.x.x Then the output should contain "Password" and the output should contain "2013-06-10 15:40 Life is good" - @skip_win Scenario: Upgrade and parse journals with little endian date format Given we use the config "upgrade_from_195_little_endian_dates.json" When we run "jrnl -9" and enter "Y" From 9cc8539ff94ea18b9d6249b554aedf6de695bdae Mon Sep 17 00:00:00 2001 From: Micah Ellison <4383304+micahellison@users.noreply.github.com> Date: Sat, 25 Jan 2020 15:57:58 -0800 Subject: [PATCH 3/9] Keep skip_win directive for empty entry test that still stalls on Travis --- features/core.feature | 1 + 1 file changed, 1 insertion(+) diff --git a/features/core.feature b/features/core.feature index 94da701a..c023cd4c 100644 --- a/features/core.feature +++ b/features/core.feature @@ -20,6 +20,7 @@ Feature: Basic reading and writing to a journal When we run "jrnl -n 1" Then the output should contain "2013-07-23 09:00 A cold and stormy day." + @skip_win Scenario: Writing an empty entry from the editor Given we use the config "editor.yaml" When we open the editor and enter "" From e54da410008d2c8786b8e4006be300b66fb49ab0 Mon Sep 17 00:00:00 2001 From: MinchinWeb Date: Sat, 25 Jan 2020 18:01:55 -0700 Subject: [PATCH 4/9] [DayOne] YAML export improvements (#773) * [YAML Export] code style improvements * [Dayone] Brings back extended Dayone attributes to YAML export c.f. 7d3afd811ba2c32463391b709331019e3cbfc40f reverse fd46ffea23eb1cb98121bde3a3993a4fa56e1afb * [YAML Exporter] switch to f-strings * [Black] apply black formatter to YAML Exporter * Code fixes as per review --- jrnl/plugins/yaml_exporter.py | 44 +++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/jrnl/plugins/yaml_exporter.py b/jrnl/plugins/yaml_exporter.py index b0177b39..430b68f7 100644 --- a/jrnl/plugins/yaml_exporter.py +++ b/jrnl/plugins/yaml_exporter.py @@ -19,11 +19,10 @@ class YAMLExporter(TextExporter): """Returns a markdown representation of a single entry, with YAML front matter.""" if to_multifile is False: print( - "{}ERROR{}: YAML export must be to individual files. " - "Please specify a directory to export to.".format( - "\033[31m", "\033[0m" - ), - file=sys.stderr, + "{}ERROR{}: YAML export must be to individual files. Please \ + specify a directory to export to.".format( + ERROR_COLOR, RESET_COLOR, file=sys.stderr + ) ) return @@ -33,16 +32,14 @@ class YAMLExporter(TextExporter): tagsymbols = entry.journal.config["tagsymbols"] # see also Entry.Entry.rag_regex - multi_tag_regex = re.compile( - r"(?u)^\s*([{tags}][-+*#/\w]+\s*)+$".format(tags=tagsymbols) - ) + multi_tag_regex = re.compile(fr"(?u)^\s*([{tagsymbols}][-+*#/\w]+\s*)+$") """Increase heading levels in body text""" newbody = "" heading = "#" previous_line = "" warn_on_heading_level = False - for line in entry.body.splitlines(True): + for line in body.splitlines(True): if re.match(r"^#+ ", line): """ATX style headings""" newbody = newbody + previous_line + heading + line @@ -80,9 +77,32 @@ class YAMLExporter(TextExporter): dayone_attributes = "" if hasattr(entry, "uuid"): dayone_attributes += "uuid: " + entry.uuid + "\n" - # TODO: copy over pictures, if present - # source directory is entry.journal.config['journal'] - # output directory is...? + if ( + hasattr(entry, "creator_device_agent") + or hasattr(entry, "creator_generation_date") + or hasattr(entry, "creator_host_name") + or hasattr(entry, "creator_os_agent") + or hasattr(entry, "creator_software_agent") + ): + dayone_attributes += "creator:\n" + if hasattr(entry, "creator_device_agent"): + dayone_attributes += f" device agent: {entry.creator_device_agent}\n" + if hasattr(entry, "creator_generation_date"): + dayone_attributes += " generation date: {}\n".format( + str(entry.creator_generation_date) + ) + if hasattr(entry, "creator_host_name"): + dayone_attributes += f" host name: {entry.creator_host_name}\n" + if hasattr(entry, "creator_os_agent"): + dayone_attributes += f" os agent: {entry.creator_os_agent}\n" + if hasattr(entry, "creator_software_agent"): + dayone_attributes += ( + f" software agent: {entry.creator_software_agent}\n" + ) + + # TODO: copy over pictures, if present + # source directory is entry.journal.config['journal'] + # output directory is...? return "title: {title}\ndate: {date}\nstared: {stared}\ntags: {tags}\n{dayone} {body} {space}".format( date=date_str, From ace4f576b2db471d718044e25f5c60ce6274051e Mon Sep 17 00:00:00 2001 From: Jrnl Bot Date: Sun, 26 Jan 2020 01:13:04 +0000 Subject: [PATCH 5/9] Updating changelog [ci skip] --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index de50e8c7..3969df3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ **Implemented enhancements:** +- Update YAML exporter to handle Dayone format [\#773](https://github.com/jrnl-org/jrnl/pull/773) ([MinchinWeb](https://github.com/MinchinWeb)) - Full text search \(case insensitive\) with "-contains" [\#740](https://github.com/jrnl-org/jrnl/pull/740) ([empireshades](https://github.com/empireshades)) - Reduce startup time by 55% [\#719](https://github.com/jrnl-org/jrnl/pull/719) ([maebert](https://github.com/maebert)) - Refactor password logic to prevent accidental password leakage [\#708](https://github.com/jrnl-org/jrnl/pull/708) ([pspeter](https://github.com/pspeter)) From 5033bb3e30eeba896de22e1fd6ce6a67db75e389 Mon Sep 17 00:00:00 2001 From: Jrnl Bot Date: Sun, 26 Jan 2020 01:35:23 +0000 Subject: [PATCH 6/9] Updating changelog [ci skip] --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3969df3d..e4dbdba8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ **Build:** +- Fix all skipped tests on Travis Windows builds by preserving newlines [\#823](https://github.com/jrnl-org/jrnl/pull/823) ([micahellison](https://github.com/micahellison)) - Change PyPI auth method in build pipeline [\#807](https://github.com/jrnl-org/jrnl/pull/807) ([wren](https://github.com/wren)) - Automagically update the changelog you see before your very eyes! [\#806](https://github.com/jrnl-org/jrnl/pull/806) ([wren](https://github.com/wren)) - Update Black version and lock file to fix builds on develop branch [\#784](https://github.com/jrnl-org/jrnl/pull/784) ([wren](https://github.com/wren)) From ba3f688e8fd56bc1e0d1f3c73a2d16f926204b04 Mon Sep 17 00:00:00 2001 From: heymajor <13547412+heymajor@users.noreply.github.com> Date: Sat, 1 Feb 2020 16:12:30 -0500 Subject: [PATCH 7/9] Updating/expanding template explanation --- docs/recipes.md | 74 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 62 insertions(+), 12 deletions(-) diff --git a/docs/recipes.md b/docs/recipes.md index 08e51711..b9335419 100644 --- a/docs/recipes.md +++ b/docs/recipes.md @@ -13,7 +13,7 @@ jrnl @alberto --tags | grep @melo And will get something like `@melo: 9`, meaning there are 9 entries where both `@alberto` and `@melo` are tagged. How does this work? First, -`jrnl @alberto` will filter the journal to only entries containing the +`jrnl @alberto` will filter the journal to only entries containing **the** tag `@alberto`, and then the `--tags` option will print out how often each tag occurred in this filtered journal. Finally, we pipe this to `grep` which will only display the line containing `@melo`. @@ -70,17 +70,61 @@ jrnlimport () { ### Using templates -Say you always want to use the same template for creating new entries. -If you have an [external editor](../advanced) set up, you can use this: +!!! note + Templates require an [external editor](../advanced) be configured. + +A template is a code snippet that makes it easier to enter use repeated text +each time a new journal entry is started. There are two ways you can utilize +templates in your entries. + +#### 1. Command line arguments + +If you had a `template.txt` file with the following contents: ```sh -jrnl < my_template.txt -jrnl -1 --edit +My Personal Journal +Title: + +Body: ``` -Another nice solution that allows you to define individual prompts comes -from [Jacobo de -Vera](https://github.com/maebert/jrnl/issues/194#issuecomment-47402869): +The `template.txt` file could be used to create a new entry with these +command line arguements: + +```sh +jrnl < template.txt # Imports template.txt as the most recent entry +jrnl -1 --edit # Opens the most recent entry in the editor +``` + +#### 2. Include the template file in `jrnl.yaml` + +A more efficient way to work with a template file is to declare the file +in your config file by changing the `template` setting from `false` to the +template file's path in double quotes: + +```sh +... +tagsymbols: "@" +template: "/path/to/template.txt" +timeformat: '%Y-%m-%d %H:%M' +version: "2.1.1" +``` + +Changes can be saved as you continue writing the journal entry and will be +logged as a new entry in the journal you specified in the original argument. + +!!! tip +To read your journal entry or to verify the entry saved, you can use this +command: `jrnl -n 1' (Check out [Import and Export](../export/#export-to-files) for more export options). + +```sh +jrnl -n 1 +``` + +### Prompts on shell reload + +If you'd like to be prompted each time you refresh your shell, you can include +this in your `.bash_profile`: ```sh function log_question() @@ -93,6 +137,11 @@ log_question 'What did I achieve today?' log_question 'What did I make progress with?' ``` +Whenever your shell is reloaded, you will be prompted to answer each of the +questions in the example above. Each answer will be logged as a separate +journal entry at the `default_hour` and `default_minute` listed in your +`jrnl.yaml` [config file](../advanced/#configuration-file). + ### Display random entry You can use this to select one title at random and then display the whole @@ -107,10 +156,11 @@ jrnl -on "$(jrnl --short | shuf -n 1 | cut -d' ' -f1,2)" ## External editors -To use external editors for writing and editing journal entries, set -them up in your `jrnl.yaml` (see `advanced usage ` for -details). Generally, after writing an entry, you will have to save and -close the file to save the changes to jrnl. +Configure your preferred external editor by updating the `editor` option +in your `jrnl.yaml` file. (See [advanced usage](../advanced) for details). + +!!! note + To save and log any entry edits, save and close the file. ### Sublime Text From 436370b53818b7a6a3746ed681b0e28f451a7ad2 Mon Sep 17 00:00:00 2001 From: heymajor <13547412+heymajor@users.noreply.github.com> Date: Sat, 1 Feb 2020 17:52:33 -0500 Subject: [PATCH 8/9] Smoothing out formatting issues --- docs/recipes.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/recipes.md b/docs/recipes.md index b9335419..d688b429 100644 --- a/docs/recipes.md +++ b/docs/recipes.md @@ -13,7 +13,7 @@ jrnl @alberto --tags | grep @melo And will get something like `@melo: 9`, meaning there are 9 entries where both `@alberto` and `@melo` are tagged. How does this work? First, -`jrnl @alberto` will filter the journal to only entries containing **the** +`jrnl @alberto` will filter the journal to only entries containing the tag `@alberto`, and then the `--tags` option will print out how often each tag occurred in this filtered journal. Finally, we pipe this to `grep` which will only display the line containing `@melo`. @@ -104,18 +104,16 @@ template file's path in double quotes: ```sh ... -tagsymbols: "@" template: "/path/to/template.txt" -timeformat: '%Y-%m-%d %H:%M' -version: "2.1.1" +... ``` Changes can be saved as you continue writing the journal entry and will be logged as a new entry in the journal you specified in the original argument. !!! tip -To read your journal entry or to verify the entry saved, you can use this -command: `jrnl -n 1' (Check out [Import and Export](../export/#export-to-files) for more export options). + To read your journal entry or to verify the entry saved, you can use this + command: `jrnl -n 1` (Check out [Import and Export](../export/#export-to-files) for more export options). ```sh jrnl -n 1 From 6bf0ccfb2bbdafe3b3709d9976e42af2f18b53ff Mon Sep 17 00:00:00 2001 From: Jrnl Bot Date: Wed, 5 Feb 2020 20:34:10 +0000 Subject: [PATCH 9/9] Updating changelog [ci skip] --- CHANGELOG.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4dbdba8..1c635848 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,24 @@ ## [Unreleased](https://github.com/jrnl-org/jrnl/) +[Full Changelog](https://github.com/jrnl-org/jrnl/compare/v2.2...HEAD) + +**Implemented enhancements:** + +- Update YAML exporter to handle Dayone format [\#773](https://github.com/jrnl-org/jrnl/pull/773) ([MinchinWeb](https://github.com/MinchinWeb)) + +**Build:** + +- Fix all skipped tests on Travis Windows builds by preserving newlines [\#823](https://github.com/jrnl-org/jrnl/pull/823) ([micahellison](https://github.com/micahellison)) + +**Updated documentation:** + +- Updating/clarifying template explanation [\#829](https://github.com/jrnl-org/jrnl/pull/829) ([heymajor](https://github.com/heymajor)) + +# Changelog + +## [Unreleased](https://github.com/jrnl-org/jrnl/) + [Full Changelog](https://github.com/jrnl-org/jrnl/compare/v2.1.1...HEAD) **Implemented enhancements:**