Merge branch 'develop' into master

This commit is contained in:
Jonathan Wren 2020-02-08 11:33:09 -08:00 committed by GitHub
commit fa971b0f2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 96 additions and 30 deletions

View file

@ -7,6 +7,7 @@ cache:
git: git:
depth: false depth: false
autocrlf: false
before_install: before_install:
- date - date

View file

@ -16,12 +16,15 @@
- Updating/clarifying template explanation [\#829](https://github.com/jrnl-org/jrnl/pull/829) ([heymajor](https://github.com/heymajor)) - Updating/clarifying template explanation [\#829](https://github.com/jrnl-org/jrnl/pull/829) ([heymajor](https://github.com/heymajor))
## [v2.2](https://pypi.org/project/jrnl/v2.2/) (2020-02-01) ## [v2.2](https://pypi.org/project/jrnl/v2.2/) (2020-02-01)
[Full Changelog](https://github.com/jrnl-org/jrnl/compare/v2.2-beta2...v2.2) [Full Changelog](https://github.com/jrnl-org/jrnl/compare/v2.2-beta2...v2.2)
**Implemented enhancements:** **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)) - 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)) - 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)) - Refactor password logic to prevent accidental password leakage [\#708](https://github.com/jrnl-org/jrnl/pull/708) ([pspeter](https://github.com/pspeter))
@ -36,6 +39,7 @@
- Fix issue where jrnl would always out 'source' for version, fix Poetry config to build and publish properly [\#820](https://github.com/jrnl-org/jrnl/pull/820) ([wren](https://github.com/wren)) - Fix issue where jrnl would always out 'source' for version, fix Poetry config to build and publish properly [\#820](https://github.com/jrnl-org/jrnl/pull/820) ([wren](https://github.com/wren))
- Unpin poetry [\#808](https://github.com/jrnl-org/jrnl/pull/808) ([wren](https://github.com/wren)) - Unpin poetry [\#808](https://github.com/jrnl-org/jrnl/pull/808) ([wren](https://github.com/wren))
- 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)) - 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)) - 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)) - 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))

View file

@ -70,17 +70,59 @@ jrnlimport () {
### Using templates ### Using templates
Say you always want to use the same template for creating new entries. !!! note
If you have an [external editor](../advanced) set up, you can use this: 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 ```sh
jrnl < my_template.txt My Personal Journal
jrnl -1 --edit Title:
Body:
``` ```
Another nice solution that allows you to define individual prompts comes The `template.txt` file could be used to create a new entry with these
from [Jacobo de command line arguements:
Vera](https://github.com/maebert/jrnl/issues/194#issuecomment-47402869):
```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
...
template: "/path/to/template.txt"
...
```
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 ```sh
function log_question() function log_question()
@ -93,6 +135,11 @@ log_question 'What did I achieve today?'
log_question 'What did I make progress with?' 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 ### Display random entry
You can use this to select one title at random and then display the whole You can use this to select one title at random and then display the whole
@ -107,10 +154,11 @@ jrnl -on "$(jrnl --short | shuf -n 1 | cut -d' ' -f1,2)"
## External editors ## External editors
To use external editors for writing and editing journal entries, set Configure your preferred external editor by updating the `editor` option
them up in your `jrnl.yaml` (see `advanced usage <advanced>` for in your `jrnl.yaml` file. (See [advanced usage](../advanced) for details).
details). Generally, after writing an entry, you will have to save and
close the file to save the changes to jrnl. !!! note
To save and log any entry edits, save and close the file.
### Sublime Text ### Sublime Text

View file

@ -24,7 +24,6 @@ Feature: Zapped Dayone bugs stay dead!
| I'm feeling sore because I forgot to stretch. | 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 Scenario: Opening an folder that's not a DayOne folder gives a nice error message
Given we use the config "empty_folder.yaml" Given we use the config "empty_folder.yaml"
When we run "jrnl Herro" When we run "jrnl Herro"

View file

@ -12,7 +12,6 @@
Then we should see the message "Journal decrypted" Then we should see the message "Journal decrypted"
And the journal should have 2 entries And the journal should have 2 entries
@skip_win
Scenario: Encrypting a journal Scenario: Encrypting a journal
Given we use the config "basic.yaml" Given we use the config "basic.yaml"
When we run "jrnl --encrypt" and enter When we run "jrnl --encrypt" and enter
@ -27,7 +26,6 @@
Then the output should contain "Password" Then the output should contain "Password"
And the output should contain "2013-06-10 15:40 Life is good" And the output should contain "2013-06-10 15:40 Life is good"
@skip_win
Scenario: Mistyping your password Scenario: Mistyping your password
Given we use the config "basic.yaml" Given we use the config "basic.yaml"
When we run "jrnl --encrypt" and enter When we run "jrnl --encrypt" and enter
@ -45,7 +43,6 @@
Then the output should contain "Password" Then the output should contain "Password"
And the output should contain "2013-06-10 15:40 Life is good" And the output should contain "2013-06-10 15:40 Life is good"
@skip_win
Scenario: Storing a password in Keychain Scenario: Storing a password in Keychain
Given we use the config "multiple.yaml" Given we use the config "multiple.yaml"
When we run "jrnl simple --encrypt" and enter When we run "jrnl simple --encrypt" and enter

View file

@ -1,6 +1,5 @@
Feature: Upgrading Journals from 1.x.x to 2.x.x Feature: Upgrading Journals from 1.x.x to 2.x.x
@skip_win
Scenario: Upgrade and parse journals with square brackets Scenario: Upgrade and parse journals with square brackets
Given we use the config "upgrade_from_195.json" Given we use the config "upgrade_from_195.json"
When we run "jrnl -9" and enter "Y" 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 Then the journal should have 2 entries
@skip_win
Scenario: Upgrading a journal encrypted with jrnl 1.x Scenario: Upgrading a journal encrypted with jrnl 1.x
Given we use the config "encrypted_old.json" Given we use the config "encrypted_old.json"
When we run "jrnl -n 1" and enter 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" Then the output should contain "Password"
and the output should contain "2013-06-10 15:40 Life is good" 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 Scenario: Upgrade and parse journals with little endian date format
Given we use the config "upgrade_from_195_little_endian_dates.json" Given we use the config "upgrade_from_195_little_endian_dates.json"
When we run "jrnl -9" and enter "Y" When we run "jrnl -9" and enter "Y"

View file

@ -19,11 +19,10 @@ class YAMLExporter(TextExporter):
"""Returns a markdown representation of a single entry, with YAML front matter.""" """Returns a markdown representation of a single entry, with YAML front matter."""
if to_multifile is False: if to_multifile is False:
print( print(
"{}ERROR{}: YAML export must be to individual files. " "{}ERROR{}: YAML export must be to individual files. Please \
"Please specify a directory to export to.".format( specify a directory to export to.".format(
"\033[31m", "\033[0m" ERROR_COLOR, RESET_COLOR, file=sys.stderr
), )
file=sys.stderr,
) )
return return
@ -33,16 +32,14 @@ class YAMLExporter(TextExporter):
tagsymbols = entry.journal.config["tagsymbols"] tagsymbols = entry.journal.config["tagsymbols"]
# see also Entry.Entry.rag_regex # see also Entry.Entry.rag_regex
multi_tag_regex = re.compile( multi_tag_regex = re.compile(fr"(?u)^\s*([{tagsymbols}][-+*#/\w]+\s*)+$")
r"(?u)^\s*([{tags}][-+*#/\w]+\s*)+$".format(tags=tagsymbols)
)
"""Increase heading levels in body text""" """Increase heading levels in body text"""
newbody = "" newbody = ""
heading = "#" heading = "#"
previous_line = "" previous_line = ""
warn_on_heading_level = False warn_on_heading_level = False
for line in entry.body.splitlines(True): for line in body.splitlines(True):
if re.match(r"^#+ ", line): if re.match(r"^#+ ", line):
"""ATX style headings""" """ATX style headings"""
newbody = newbody + previous_line + heading + line newbody = newbody + previous_line + heading + line
@ -80,9 +77,32 @@ class YAMLExporter(TextExporter):
dayone_attributes = "" dayone_attributes = ""
if hasattr(entry, "uuid"): if hasattr(entry, "uuid"):
dayone_attributes += "uuid: " + entry.uuid + "\n" dayone_attributes += "uuid: " + entry.uuid + "\n"
# TODO: copy over pictures, if present if (
# source directory is entry.journal.config['journal'] hasattr(entry, "creator_device_agent")
# output directory is...? 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( return "title: {title}\ndate: {date}\nstared: {stared}\ntags: {tags}\n{dayone} {body} {space}".format(
date=date_str, date=date_str,