Merge branch 'develop' into pytest-bdd-6-1685

Conflicts:
poetry.lock
This commit is contained in:
Jonathan Wren 2023-02-25 14:59:56 -08:00
commit c6cef96c9d
No known key found for this signature in database
15 changed files with 1887 additions and 1486 deletions

View file

@ -15,7 +15,11 @@
**Fixed bugs:** **Fixed bugs:**
- Templated entries should not be saved if the raw text is identical to the original template [\#1652](https://github.com/jrnl-org/jrnl/issues/1652)
- jrnl does not update version key in config file [\#1638](https://github.com/jrnl-org/jrnl/issues/1638) - jrnl does not update version key in config file [\#1638](https://github.com/jrnl-org/jrnl/issues/1638)
- jrnl should not create 0-length "encrypted" file on startup [\#1493](https://github.com/jrnl-org/jrnl/issues/1493)
- Save empty journal on install instead of just creating a zero-length file [\#1690](https://github.com/jrnl-org/jrnl/pull/1690) ([micahellison](https://github.com/micahellison))
- Don't save templated journal entries if the received raw text is the same as the template itself [\#1653](https://github.com/jrnl-org/jrnl/pull/1653) ([Briscoooe](https://github.com/Briscoooe))
- Add tag to XML file when edited DayOne entry and is searchable afterward [\#1648](https://github.com/jrnl-org/jrnl/pull/1648) ([jonakeys](https://github.com/jonakeys)) - Add tag to XML file when edited DayOne entry and is searchable afterward [\#1648](https://github.com/jrnl-org/jrnl/pull/1648) ([jonakeys](https://github.com/jonakeys))
- Update version key in config file after version changes [\#1646](https://github.com/jrnl-org/jrnl/pull/1646) ([jonakeys](https://github.com/jonakeys)) - Update version key in config file after version changes [\#1646](https://github.com/jrnl-org/jrnl/pull/1646) ([jonakeys](https://github.com/jonakeys))
@ -32,7 +36,13 @@
**Documentation:** **Documentation:**
- Document template extension behavior [\#1677](https://github.com/jrnl-org/jrnl/issues/1677)
- Visual Studio Code may store unencrypted temporary files [\#1675](https://github.com/jrnl-org/jrnl/issues/1675)
- Documentation Change [\#1651](https://github.com/jrnl-org/jrnl/issues/1651) - Documentation Change [\#1651](https://github.com/jrnl-org/jrnl/issues/1651)
- Support mkdocs 1.4.2 and fix its missing breadcrumb [\#1691](https://github.com/jrnl-org/jrnl/pull/1691) ([micahellison](https://github.com/micahellison))
- Document temporary file extension behavior when using template [\#1686](https://github.com/jrnl-org/jrnl/pull/1686) ([micahellison](https://github.com/micahellison))
- Update documentation about privacy and security in VSCode [\#1680](https://github.com/jrnl-org/jrnl/pull/1680) ([giuseppedandrea](https://github.com/giuseppedandrea))
- Update documentation on temporary files naming [\#1673](https://github.com/jrnl-org/jrnl/pull/1673) ([giuseppedandrea](https://github.com/giuseppedandrea))
- Update docs to include time and title in arguments with `--edit` [\#1657](https://github.com/jrnl-org/jrnl/pull/1657) ([pconrad-fb](https://github.com/pconrad-fb)) - Update docs to include time and title in arguments with `--edit` [\#1657](https://github.com/jrnl-org/jrnl/pull/1657) ([pconrad-fb](https://github.com/pconrad-fb))
- Fix markup in "Advanced Usage" doc [\#1655](https://github.com/jrnl-org/jrnl/pull/1655) ([multani](https://github.com/multani)) - Fix markup in "Advanced Usage" doc [\#1655](https://github.com/jrnl-org/jrnl/pull/1655) ([multani](https://github.com/multani))
- Remove Windows 7 known issue since Windows 7 is no longer supported [\#1636](https://github.com/jrnl-org/jrnl/pull/1636) ([micahellison](https://github.com/micahellison)) - Remove Windows 7 known issue since Windows 7 is no longer supported [\#1636](https://github.com/jrnl-org/jrnl/pull/1636) ([micahellison](https://github.com/micahellison))

View file

@ -37,6 +37,9 @@ jrnl yesterday: All my troubles seemed so far away. --edit
All editors must be [blocking processes](https://en.wikipedia.org/wiki/Blocking_(computing)) to work with jrnl. Some editors, such as [micro](https://micro-editor.github.io/), are blocking by default, though others can be made to block with additional arguments, such as many of those documented below. If jrnl opens your editor but finishes running immediately, then your editor is not a blocking process, and you may be able to correct that with one of the suggestions below. All editors must be [blocking processes](https://en.wikipedia.org/wiki/Blocking_(computing)) to work with jrnl. Some editors, such as [micro](https://micro-editor.github.io/), are blocking by default, though others can be made to block with additional arguments, such as many of those documented below. If jrnl opens your editor but finishes running immediately, then your editor is not a blocking process, and you may be able to correct that with one of the suggestions below.
Please see [this section](./privacy-and-security.md#editor-history) about how
your editor might leak sensitive information and how to mitigate that risk.
## Sublime Text ## Sublime Text
To use [Sublime Text](https://www.sublimetext.com/), install the command line To use [Sublime Text](https://www.sublimetext.com/), install the command line
@ -71,6 +74,17 @@ back to journal. In the case of MacVim, this is `-f`:
editor: "mvim -f" editor: "mvim -f"
``` ```
## Vim/Neovim
To use any of the Vim derivatives as editor in Linux, simply set the `editor`
to the executable:
```yaml
editor: "vim"
# or
editor: "nvim"
```
## iA Writer ## iA Writer
On OS X, you can use the fabulous [iA On OS X, you can use the fabulous [iA

View file

@ -78,8 +78,125 @@ unencrypted temporary remains on your disk. If your computer were to shut off
during this time, or the `jrnl` process were killed unexpectedly, then the during this time, or the `jrnl` process were killed unexpectedly, then the
unencrypted temporary file will remain on your disk. You can mitigate this unencrypted temporary file will remain on your disk. You can mitigate this
issue by only saving with your editor right before closing it. You can also issue by only saving with your editor right before closing it. You can also
manually delete these files (i.e. files named `jrnl_*.txt`) from your temporary manually delete these files from your temporary folder. By default, they
folder. are named `jrnl*.jrnl`, but if you use a
[template](reference-config-file.md#template), they will have the same
extension as the template.
## Editor history
Some editors keep usage history stored on disk for future use. This can be a
security risk in the sense that sensitive information can leak via recent
search patterns or editor commands.
### Visual Studio Code
Visual Studio Code stores the contents of saved files to allow you to restore or
review the contents later. You can disable this feature for all files by unchecking
the `workbench.localHistory.enabled` setting in the
[Settings editor](https://code.visualstudio.com/docs/getstarted/settings#_settings-editor).
Alternatively, you can disable this feature for specific files by configuring a
[pattern](https://code.visualstudio.com/docs/editor/codebasics#_advanced-search-options)
in the `workbench.localHistory.exclude` setting. To exclude unencrypted temporary files generated
by `jrnl`, you can set the `**/jrnl*.jrnl` (unless you are using a
[template](reference-config-file.md#template)) pattern for the `workbench.localHistory.exclude` setting
in the [Settings editor](https://code.visualstudio.com/docs/getstarted/settings#_settings-editor).
!!! note
On Windows, the history location is typically found at
`%APPDATA%\Code\User\History`.
Visual Studio Code also creates a copy of all unsaved files that are open.
It stores these copies in a backup location that's automatically cleaned when
you save the file. However, if your computer shuts off before you save the file,
or the Visual Studio Code process stops unexpectedly, then an unencrypted
temporary file may remain on your disk. You can manually delete these files
from the backup location.
!!! note
On Windows, the backup location is typically found at
`%APPDATA%\Code\Backups`.
### Vim
Vim stores progress data in a so called Viminfo file located at `~/.viminfo`
which contains all sorts of user data including command line history, search
string history, search/substitute patterns, contents of register etc. Also to
be able to recover opened files after an unexpected application close Vim uses
swap files.
These options as well as other leaky features can be disabled by setting the
`editor` key in the Jrnl settings like this:
``` yaml
editor: "vim -c 'set viminfo= noswapfile noundofile nobackup nowritebackup noshelltemp history=0 nomodeline secure'"
```
To disable all plugins and custom configurations and start Vim with the default
configuration `-u NONE` can be passed on the command line as well. This will
ensure that any rogue plugins or other difficult to catch information leaks are
eliminated. The downside to this is that the editor experience will decrease
quite a bit.
To instead let Vim automatically detect when a Jrnl file is being edited an
autocommand can be used. Place this in your `~/.vimrc`:
``` vim
autocmd BufNewFile,BufReadPre *.jrnl setlocal viminfo= noswapfile noundofile nobackup nowritebackup noshelltemp history=0 nomodeline secure
```
!!! note
If you're using a [template](reference-config-file.md#template), you will
have to use the template's file extension instead of `.jrnl`.
See `:h <option>` in Vim for more information about the options mentioned.
### Neovim
Neovim strives to be mostly compatible with Vim and has therefore similar
functionality as Vim. One difference in Neovim is that the Viminfo file is
instead called the ShaDa ("shared data") file which resides in
`~/.local/state/nvim` (`~/.local/share/nvim` pre Neovim v0.8.0). The ShaDa file
can be disabled in the same way as for Vim.
``` yaml
editor: "nvim -c 'set shada= noswapfile noundofile nobackup nowritebackup noshelltemp history=0 nomodeline secure'"
```
`-u NONE` can be passed here as well to start a session with the default configs.
As for Vim above we can create an autocommand in Vimscript:
``` vim
autocmd BufNewFile,BufReadPre *.jrnl setlocal shada= noswapfile noundofile nobackup nowritebackup noshelltemp history=0 nomodeline secure
```
or the same but in Lua:
``` lua
vim.api.nvim_create_autocmd( {"BufNewFile","BufReadPre" }, {
group = vim.api.nvim_create_augroup("PrivateJrnl", {}),
pattern = "*.jrnl",
callback = function()
vim.o.shada = ""
vim.o.swapfile = false
vim.o.undofile = false
vim.o.backup = false
vim.o.writebackup = false
vim.o.shelltemp = false
vim.o.history = 0
vim.o.modeline = false
vim.o.secure = true
end,
})
```
!!! note
If you're using a [template](reference-config-file.md#template), you will
have to use the template's file extension instead of `.jrnl`.
Please see `:h <option>` in Neovim for more information about the options mentioned.
## Plausible deniability ## Plausible deniability
@ -100,7 +217,6 @@ In Windows, the keychain is the Windows Credential Manager (WCM), which can't be
and can be accessed by any other application running under your username. If this is and can be accessed by any other application running under your username. If this is
a concern for you, you may not want to store your password. a concern for you, you may not want to store your password.
## Notice any other risks? ## Notice any other risks?
Please let the maintainers know by [filing an issue on GitHub](https://github.com/jrnl-org/jrnl/issues). Please let the maintainers know by [filing an issue on GitHub](https://github.com/jrnl-org/jrnl/issues).

View file

@ -59,7 +59,9 @@ value for journals that already have data in them.
### template ### template
The path to a text file to use as a template for new entries. Only works when you The path to a text file to use as a template for new entries. Only works when you
have the `editor` field configured. have the `editor` field configured. If you use a template, the editor's
[temporary files](privacy-and-security.md#files-in-transit-from-editor-to-jrnl)
will have the same extension as the template.
### tagsymbols ### tagsymbols
Symbols to be interpreted as tags. Symbols to be interpreted as tags.

View file

@ -118,7 +118,7 @@ div.rst-content {
background-size: 100%; background-size: 100%;
} }
a.icon-home:before { .wy-side-nav-search a.icon-home:before {
display: block; display: block;
width: 84px; width: 84px;
height: 70px; height: 70px;

View file

@ -0,0 +1,49 @@
<!--
Copied from https://github.com/mkdocs/mkdocs/blob/master/mkdocs/themes/readthedocs/breadcrumbs.html
Then lightly modified for accessibility
-->
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="{{ nav.homepage.url|url }}" class="icon icon-home" aria-label="{% trans %}Docs{% endtrans %}"></a> &raquo;</li>
{%- if page %}
{%- for doc in page.ancestors[::-1] %}
{%- if doc.link %}
<li><a href="{{ doc.link|e }}">{{ doc.title }}</a> &raquo;</li>
{%- else %}
<li>{{ doc.title }} &raquo;</li>
{%- endif %}
{%- endfor %}
<li>{{ page.title }}</li>
{%- endif %}
<li class="wy-breadcrumbs-aside">
{%- block repo %}
{%- if page and page.edit_url %}
{%- if config.repo_name|lower == 'github' %}
<a href="{{ page.edit_url }}" class="icon icon-github"> {% trans repo_name=config.repo_name %}Edit on {{ repo_name }}{% endtrans %}</a>
{%- elif config.repo_name|lower == 'bitbucket' %}
<a href="{{ page.edit_url }}" class="icon icon-bitbucket"> {% trans repo_name=config.repo_name %}Edit on {{ repo_name }}{% endtrans %}</a>
{%- elif config.repo_name|lower == 'gitlab' %}
<a href="{{ page.edit_url }}" class="icon icon-gitlab"> {% trans repo_name=config.repo_name %}Edit on {{ repo_name }}{% endtrans %}</a>
{%- elif config.repo_name %}
<a href="{{ page.edit_url }}">{% trans repo_name=config.repo_name %}Edit on {{ repo_name }}{% endtrans %}</a>
{%- else %}
<a href="{{ page.edit_url }}">{% trans %}Edit{% endtrans %}</a>
{%- endif %}
{%- endif %}
{%- endblock %}
</li>
</ul>
{%- if config.theme.prev_next_buttons_location|lower in ['top', 'both']
and page and (page.next_page or page.previous_page) %}
<div class="rst-breadcrumbs-buttons" role="navigation" aria-label="{% trans %}Breadcrumb Navigation{% endtrans %}">
{%- if page.previous_page %}
<a href="{{ page.previous_page.url|url }}" class="btn btn-neutral float-left" title="{{ page.previous_page.title }}"><span class="icon icon-circle-arrow-left" aria-hidden="true"></span> {% trans %}Previous{% endtrans %}</a>
{%- endif %}
{%- if page.next_page %}
<a href="{{ page.next_page.url|url }}" class="btn btn-neutral float-right" title="{{ page.next_page.title }}">{% trans %}Next{% endtrans %} <span class="icon icon-circle-arrow-right" aria-hidden="true"></span></a>
{%- endif %}
</div>
{%- endif %}
<hr/>
</div>

View file

@ -1,2 +1,2 @@
mkdocs==1.2.4 mkdocs>=1.4
jinja2==3.1.2 jinja2==3.1.2

View file

@ -150,6 +150,9 @@ def write_mode(args: "Namespace", config: dict, journal: Journal, **kwargs) -> N
if not raw or raw.isspace(): if not raw or raw.isspace():
logging.error("Write mode: couldn't get raw text or entry was empty") logging.error("Write mode: couldn't get raw text or entry was empty")
raise JrnlException(Message(MsgText.NoTextReceived, MsgStyle.NORMAL)) raise JrnlException(Message(MsgText.NoTextReceived, MsgStyle.NORMAL))
if config["template"] and raw == _get_editor_template(config):
logging.error("Write mode: raw text was the same as the template")
raise JrnlException(Message(MsgText.NoChangesToTemplate, MsgStyle.NORMAL))
logging.debug( logging.debug(
'Write mode: appending raw text to journal "%s": %s', args.journal_name, raw 'Write mode: appending raw text to journal "%s": %s', args.journal_name, raw

View file

@ -123,6 +123,7 @@ class Journal:
}, },
) )
) )
self.write()
text = self._load(filename) text = self._load(filename)
text = self._decrypt(text) text = self._decrypt(text)

View file

@ -156,7 +156,9 @@ class MsgText(Enum):
NoTextReceived = """ NoTextReceived = """
No entry to save, because no text was received No entry to save, because no text was received
""" """
NoChangesToTemplate = """
No entry to save, because the template was not changed
"""
# --- Upgrade --- # # --- Upgrade --- #
JournalFailedUpgrade = """ JournalFailedUpgrade = """
The following journal{s} failed to upgrade: The following journal{s} failed to upgrade:

View file

@ -5,6 +5,9 @@ theme:
custom_dir: docs_theme custom_dir: docs_theme
static_templates: static_templates:
- index.html - index.html
watch:
- docs
- docs_theme
extra_css: extra_css:
- https://fonts.googleapis.com/css?family=Open+Sans:300,600 - https://fonts.googleapis.com/css?family=Open+Sans:300,600
- assets/colors.css - assets/colors.css

3125
poetry.lock generated

File diff suppressed because it is too large Load diff

View file

@ -51,7 +51,7 @@ flake8-type-checking = ">=2.2.0"
flake8-simplify = ">=0.19" flake8-simplify = ">=0.19"
ipdb = "*" ipdb = "*"
isort = ">=5.10" isort = ">=5.10"
mkdocs = ">=1.0,<1.3" mkdocs = ">=1.4"
poethepoet = "*" poethepoet = "*"
pytest = ">=6.2" pytest = ">=6.2"
pytest-bdd = ">=6.0" pytest-bdd = ">=6.0"

View file

@ -43,3 +43,18 @@ Feature: Installing jrnl
When we run "jrnl" When we run "jrnl"
Then we should be prompted for a password Then we should be prompted for a password
Scenario: Install jrnl with encrypted default journal with no entries
Given we use no config
And we use the password "test" if prompted
When we run "jrnl -1" and enter
encrypted.txt
y
n
Then the error output should contain "Journal will be encrypted"
And the default journal "encrypted.txt" should be in the "." directory
And the config should contain "encrypt: true"
And the version in the config file should be up-to-date
When we run "jrnl -1"
Then we should be prompted for a password
And the error output should contain "no entries found"
And the error output should not contain "Wrong password, try again"

View file

@ -6,9 +6,12 @@ Feature: Using templates
Scenario Outline: Template contents should be used in new entry Scenario Outline: Template contents should be used in new entry
Given we use the config "<config_file>" Given we use the config "<config_file>"
And we use the password "test" if prompted And we use the password "test" if prompted
And we append to the editor if opened
This is an addition to a templated entry
When we run "jrnl --config-override template features/templates/basic.template" When we run "jrnl --config-override template features/templates/basic.template"
And we run "jrnl -1" And we run "jrnl -1"
Then the output should contain "This text is in the basic template" Then the output should contain "This text is in the basic template"
Then the output should contain "This is an addition to a templated entry"
Examples: configs Examples: configs
| config_file | | config_file |
@ -17,3 +20,15 @@ Feature: Using templates
| basic_folder.yaml | | basic_folder.yaml |
| basic_dayone.yaml | | basic_dayone.yaml |
Scenario Outline: Templated entry should not be saved if template is unchanged
Given we use the config "<config_file>"
And we use the password "test" if prompted
When we run "jrnl --config-override template features/templates/basic.template"
Then the output should contain "No entry to save, because the template was not changed"
Examples: configs
| config_file |
| basic_onefile.yaml |
| basic_encrypted.yaml |
| basic_folder.yaml |
| basic_dayone.yaml |