Compare commits

..

410 commits

Author SHA1 Message Date
Jrnl Bot
7923e815f7 Update changelog [ci skip] 2025-04-29 03:08:35 +00:00
Micah Jerome Ellison
72d4968471
Rename Poetry dev dependency group in pyproject.toml (#1995)
* Rename pyproject group to comply with poetry

* Run poetry lock
2025-04-28 20:06:32 -07:00
Jrnl Bot
c286012bef Update changelog [ci skip] 2025-04-29 02:36:25 +00:00
Micah Jerome Ellison
c415c68443
Remove publish-to-homebrew step (#1994) 2025-04-28 19:34:45 -07:00
Jrnl Bot
e5fc8be2a8 Update changelog [ci skip] 2025-04-04 02:17:55 +00:00
renovate[bot]
20a087f64c
Update dependency rich to v14 (#1989)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-03 19:16:22 -07:00
Jrnl Bot
a2eb68963b Update changelog [ci skip] 2025-04-04 02:14:52 +00:00
renovate[bot]
89be61ccf8
Update dependency tox to v4.25.0 (#1986)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-03 19:13:03 -07:00
renovate[bot]
98d0bcac20
Update dependency poethepoet to v0.33.1 (#1982)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-03 19:12:40 -07:00
renovate[bot]
a282440118
Update dependency tzlocal to v5.3.1 (#1984)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-03 19:11:56 -07:00
renovate[bot]
7e72386da1
Update dependency cryptography to v44.0.2 (#1980)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-03 19:11:15 -07:00
renovate[bot]
6f1e8e5853
Update dependency jinja2 to v3.1.6 (#1983)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-03 19:10:43 -07:00
renovate[bot]
906a3fed78
Update dependency pytest to v8.3.5 (#1981)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-03 19:10:15 -07:00
Edoardo Baldi
8329cf5537
Add user-friendly message when missing importer (#1959) 2025-04-03 18:48:04 -07:00
Jrnl Bot
1dd2d48068 Update changelog [ci skip] 2025-04-04 01:35:11 +00:00
renovate[bot]
43310f399d
Update dependency ruff to v0.11.3 (#1978)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-03 18:33:25 -07:00
renovate[bot]
591f2457c3
Update dependency python to 3.13 (#1988)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-03 18:32:32 -07:00
Jrnl Bot
8be5b722aa Update changelog [ci skip] 2025-02-25 05:03:32 +00:00
Jrnl Bot
7249adb232 Increment version to v4.2.1 2025-02-25 05:02:27 +00:00
Jrnl Bot
fbd1b9e78b Update changelog [ci skip] 2025-02-25 05:00:06 +00:00
renovate[bot]
2581c43ae7
Update dependency pytest-bdd to v8.1.0 (#1952)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-24 20:58:12 -08:00
renovate[bot]
2035619587
Update dependency poethepoet to v0.32.2 (#1951)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-24 20:58:01 -08:00
renovate[bot]
37f634ac80
Update dependency tzlocal to v5.3 (#1972)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-24 20:57:21 -08:00
Jrnl Bot
d1e3e546f2 Update changelog [ci skip] 2025-02-25 04:57:00 +00:00
renovate[bot]
f8d80b2877
Update dependency jinja2 to v3.1.5 (#1966)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-24 20:55:10 -08:00
Jrnl Bot
8589b2ed65 Update changelog [ci skip] 2025-02-25 04:52:30 +00:00
renovate[bot]
6645b1e36f
Update dependency ruamel.yaml to v0.18.10 (#1967)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-24 20:51:02 -08:00
Jrnl Bot
316b9761d5 Update changelog [ci skip] 2025-02-25 04:49:07 +00:00
Jonathan Wren
e2a62e99a0
Update dependency pytest to >=8.1.1 (#1974)
* update pytest in deps

* update lock file

* update lock file
2025-02-24 20:47:32 -08:00
Jrnl Bot
692d0cb132 Update changelog [ci skip] 2025-02-25 04:39:11 +00:00
renovate[bot]
573e34fb48
Update dependency tox to v4.24.1 (#1945)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-24 20:36:33 -08:00
renovate[bot]
f2bb5eb501
Update dependency black to v25 (#1973)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-24 20:35:42 -08:00
Jrnl Bot
7ad6fca011 Update changelog [ci skip] 2025-02-25 04:32:45 +00:00
renovate[bot]
640150bcbe
Update dependency cryptography to v44 (#1962)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-24 20:30:38 -08:00
renovate[bot]
75c98a408c
Update dependency rich to v13.9.4 (#1946)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-24 20:30:03 -08:00
renovate[bot]
b8a8de98c3
Update dependency keyring to v25.6.0 (#1948)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-24 20:29:02 -08:00
Jrnl Bot
85eb730186 Update changelog [ci skip] 2025-02-25 04:28:43 +00:00
renovate[bot]
024ea00a95
Update dependency ruff to v0.9.7 (#1947)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-24 20:27:11 -08:00
Carl Smedstad
1530ad39a1
Update pytest-bdd to v8.0 (#1955)
* Encapsulate all multiline strings in triple-quotes in Gherkin files

Since pytest-bdd v8.0.0 uses the official Gherkin parser, multiline
strings must now be encapsulated by triple-quotes.

See:
- https://pytest-bdd.readthedocs.io/en/stable/#id2
- https://pytest-bdd.readthedocs.io/en/stable/#docstrings

* Remove comments in Gherkin files causing test breakage

These comments break the step matching.

* Fix compatibility of step-functions matching on multiple lines

In pytest-bdd v8.0.0 it is no longer possible to match based on multiple
lines, which breaks essentially all steps that support docstrings. Solve
this by adding a wrapper-function for each of these instances, that
matches the docstring step, and calls the original function.

So, what used to be:

    @then(parse("the output should match\n{regex}"))
    @then(parse('the output should match "{regex}"'))
    def output_should_match(regex, cli_run):
        ...

Is now:

    @then(parse("the output should match"))
    def output_should_match_docstring(cli_run, docstring):
        output_should_match(docstring, cli_run)

    @then(parse('the output should match "{regex}"'))
    def output_should_match(regex, cli_run):
        ...

There is possibly a way around this that is much better than what I've
done here, but this is a start at least.

* Update version requirement of pytest-bdd to >=8.0

* Update tox config to match poetry config

---------

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2025-02-24 20:16:54 -08:00
Jrnl Bot
505a9b6846 Update changelog [ci skip] 2025-02-25 03:26:36 +00:00
David Sosa
30c341ef8b
fix typed.js URL (#1970) 2025-02-24 19:25:01 -08:00
Jrnl Bot
ccb64b1721 Update changelog [ci skip] 2025-02-25 03:15:37 +00:00
Jonathan Wren
a1b3a612a5
Remove deprecated command in Poetry >2.0 causing error in CI (#1971)
* remove deprecated flag from install command
* Change poetry install to poetry sync
* Change other poetry install to poetry sync

---------

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2025-02-24 19:14:00 -08:00
Micah Jerome Ellison
247129c760
Fix 4.2 changelog by reverting to cleaned beta changelog (#1960) 2024-11-17 16:12:03 -08:00
Jrnl Bot
bb71dff815 Update changelog [ci skip] 2024-11-17 23:54:47 +00:00
Jrnl Bot
ba18bed4d7 Increment version to v4.2 2024-11-17 23:53:30 +00:00
Jrnl Bot
eb5fe6fef1 Update changelog [ci skip] 2024-10-19 22:06:23 +00:00
Jrnl Bot
16a0f043b1 Increment version to v4.2-beta 2024-10-19 22:04:52 +00:00
Micah Jerome Ellison
b760759906
Changelog cleanup (#1944)
* Sort packages and and remove extraneous entries

* Move docs accessibility issues to docs section
2024-10-19 14:54:41 -07:00
Jrnl Bot
2ce567e495 Update changelog [ci skip] 2024-10-19 21:30:10 +00:00
Micah Jerome Ellison
1143fba023
Force brighter color with XML syntax highlighting (#1943) 2024-10-19 14:28:21 -07:00
renovate[bot]
41279ae943
Update peter-evans/create-pull-request action to v7 (#1929)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-19 14:27:25 -07:00
Jrnl Bot
985187f866 Update changelog [ci skip] 2024-10-19 21:24:20 +00:00
renovate[bot]
53fef9021d
Update dependency typed.js to v2.1.0 (#1861)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-19 14:22:53 -07:00
Jrnl Bot
df4a5a5867 Update changelog [ci skip] 2024-10-19 21:20:37 +00:00
renovate[bot]
3f3bf3e77e
Update dependency xmltodict to v0.14.2 (#1940)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-19 14:19:03 -07:00
Jrnl Bot
1b79f0b340 Update changelog [ci skip] 2024-10-19 21:18:52 +00:00
renovate[bot]
428549778c
Update dependency parse-type to v0.6.4 (#1936)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-19 14:17:03 -07:00
Jrnl Bot
d9dae7af04 Update changelog [ci skip] 2024-10-19 21:15:48 +00:00
renovate[bot]
5f6be07fbd
Update dependency ruff to v0.7.0 (#1938)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-19 14:14:22 -07:00
renovate[bot]
a94f7c6161
Update dependency rich to v13.9.2 (#1937)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-19 14:13:55 -07:00
Jrnl Bot
086c34a6a7 Update changelog [ci skip] 2024-10-19 21:08:27 +00:00
renovate[bot]
0044b2dee8
Update dependency tox to v4.23.0 (#1935)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-19 14:06:09 -07:00
renovate[bot]
0cc4acd494
Update dependency black to v24.10.0 (#1939)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-19 14:05:26 -07:00
renovate[bot]
0d5bf1e467
Update dependency cryptography to v43.0.3 (#1942)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-19 14:05:04 -07:00
Jrnl Bot
85a98afcd9 Update changelog [ci skip] 2024-10-02 03:30:57 +00:00
Micah Jerome Ellison
96d89ca9d5
Add Python 3.13 support (#1930)
* Allow Python 3.13 in pyproject

* Add Python 3.13 to GitHub actions

* Run `poetry update`

* fix failing test

* update poetry.lock

* update poetry.lock again

---------

Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
2024-10-01 20:29:06 -07:00
Jonathan Wren
de79733957
Add config to pa11y to workaround github actions issue (#1933)
fixes #1932
2024-10-01 20:28:11 -07:00
Jrnl Bot
af1b9f128e Update changelog [ci skip] 2024-10-02 02:17:11 +00:00
renovate[bot]
5145190584
Update dependency tox to v4.21.0 (#1927)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-01 19:15:05 -07:00
renovate[bot]
314576ae13
Update dependency rich to v13.9.1 (#1931)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-01 19:14:38 -07:00
renovate[bot]
87c022780d
Update dependency cryptography to v43 (#1928)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-01 19:14:14 -07:00
Aaron Lichtman
a8bd0bcd44
Add calendar heatmap display format (#1759)
* Add calendar heatmap exporter

Fix #743

* Lint fixes

* More lint fixes

* Surface total number of entries per month in heatmap

* Refactoring

* More refactoring

* Resolve last lint error

* Unbump version

* Add calendar export test scaffolding

* WIP: Test debugging + scaffolding

* Remove broken tests

* Remove args from .vscode/launch.json

* Discard changes to tests/bdd/features/format.feature

* Remove extraneous vscode files

* move NestedDict to utils file

* run formatter

* fix import error

* Address lints

---------

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
2024-10-01 18:59:26 -07:00
Jrnl Bot
2f0c5d2eb9 Update changelog [ci skip] 2024-10-01 01:25:58 +00:00
renovate[bot]
ae32ca6917
Update dependency rich to v13.8.1 (#1926)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-30 18:24:00 -07:00
renovate[bot]
5856517b0f
Update dependency poethepoet to v0.29.0 (#1925)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-30 18:23:21 -07:00
renovate[bot]
1586cc2b49
Update dependency pytest-xdist to v3.6.1 (#1897)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-30 18:22:27 -07:00
renovate[bot]
bcf41ddd17
Update dependency parse-type to v0.6.3 (#1922)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-30 18:21:23 -07:00
renovate[bot]
4017c4acb5
Update dependency keyring to v25.4.1 (#1924)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-30 18:20:46 -07:00
renovate[bot]
a646801c15
Update dependency black to v24.8.0 (#1923)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-30 18:19:54 -07:00
renovate[bot]
cb504c4bfb
Update dependency pytest-bdd to v7.3.0 (#1896)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-30 18:19:06 -07:00
Jrnl Bot
21e4552360 Update changelog [ci skip] 2024-10-01 01:18:27 +00:00
renovate[bot]
cdb9a220bd
Update dependency python-dateutil to v2.9.0 (#1898)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-30 18:16:48 -07:00
renovate[bot]
2d3809e6f7
Update dependency jinja2 to v3.1.4 (#1892)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-30 18:15:58 -07:00
renovate[bot]
0ff69bd24c
Update dependency mkdocs to v1.6.1 (#1895)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-30 18:15:15 -07:00
renovate[bot]
dec4855816
Update dependency requests to v2.32.3 (#1899)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-30 18:14:37 -07:00
renovate[bot]
89eaf3440a
Update dependency cryptography to v42.0.8 (#1904)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-30 18:13:58 -07:00
Jrnl Bot
7953309c78 Update changelog [ci skip] 2024-10-01 01:12:25 +00:00
renovate[bot]
17e1ba60e5
Update dependency ruff to v0.6.8 (#1900)
* Update dependency ruff to v0.6.8

* Run `ruff check .` instead of `ruff .` due to ruff error

* Preface ruff lint keys with .lint to address ruff deprecation warning

* Changes to appease ruff linter

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2024-09-30 18:10:49 -07:00
Jrnl Bot
4d84c491f1 Update changelog [ci skip] 2024-06-14 02:36:04 +00:00
Micah Jerome Ellison
79cf67eca6
Recommend pipx as easiest installation method for all OSes and remove warning about apt (#1889)
* Remove warning against installing pipx through apt (1886)
* Remove brew recommendation and consolidate pipx instructions (1888)
2024-06-13 19:34:31 -07:00
Jrnl Bot
c8c49b1ba2 Update changelog [ci skip] 2024-05-22 14:36:04 +00:00
renovate[bot]
8f2cb9c355
Update dependency poethepoet to v0.26.1 (#1862)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-22 07:34:33 -07:00
Jrnl Bot
9ac27704fb Update changelog [ci skip] 2024-05-22 14:32:05 +00:00
renovate[bot]
97b39dfd76
Update dependency tox to v4.15.0 (#1860)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-22 07:30:06 -07:00
Jrnl Bot
8fc158e35b Update changelog [ci skip] 2024-05-22 14:04:55 +00:00
renovate[bot]
83d4878044
Update dependency rich to v13.7.1 (#1864)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-22 07:03:04 -07:00
renovate[bot]
c9c71b40ef
Update dependency ruff to v0.4.4 (#1854)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-22 07:02:38 -07:00
Jrnl Bot
8cd4ac24a8 Update changelog [ci skip] 2024-05-22 14:00:33 +00:00
renovate[bot]
ca6b4a08a7
Update dependency cryptography to v42.0.7 (#1857)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-22 06:58:50 -07:00
Jrnl Bot
be9dbf52e0 Update changelog [ci skip] 2024-05-22 13:58:32 +00:00
renovate[bot]
4c4e36a534
Update dependency ruamel.yaml to v0.18.6 (#1855)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-22 06:55:55 -07:00
Jrnl Bot
7c4e3ad76e Update changelog [ci skip] 2024-05-22 13:55:04 +00:00
renovate[bot]
0c2c40d494
Update dependency keyring to v24.3.1 (#1863)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-22 06:53:26 -07:00
Jrnl Bot
ecf5f07dbb Update changelog [ci skip] 2024-05-21 04:18:03 +00:00
Ricardo Ruiz
8957ceb74d
Fix -contains to allow multiple terms with "OR" logic unless -and is added (#1890)
* Store multiple -contains arguments (OR default).

Allow multiple occurrences of the -contains argument
to be stored in a list. Previously, only the last occurrence was
considered. Additionally, the behavior has been modified to default to
OR logic, meaning that if multiple -contains arguments are provided,
entries matching any of them will be included in the results.

* Solved issue #1877 "-and" flag with multiple instances of the -contains option.

* Run poe format

* Fix unit test for contains to allow list instead of single value

* Add BDD tests for multiple contains with and without -and

* Black version updated.

* Revert pyproject.toml to appease poetry

---------

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2024-05-20 21:16:33 -07:00
Jrnl Bot
0deadc03c8 Update changelog [ci skip] 2024-05-20 15:08:46 +00:00
renovate[bot]
d5a5401db9
Update dependency black to v24.4.2 (#1856)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-20 08:07:06 -07:00
Manu Ebert
0aefdb3f21
Begrudgingly, change Twitter references to X (#1884)
Small fix: Change the twitter icon on the Docs landing page to X, and change the verbiage accordingly
2024-04-23 18:27:39 -07:00
Jrnl Bot
9ad1c9f26b Update changelog [ci skip] 2024-03-28 15:10:04 +00:00
Ben Beasley
48b61f6953
Support pytest_bdd 7.1.2 and later (#1878)
* Support pytest_bdd 7.1.2 and later

Fix #1875.

* Prevent use of pytest 8.1 for now due to unrelated error

* poetry lock --no-update

---------

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2024-03-28 08:08:00 -07:00
Jrnl Bot
2af05e4008 Update changelog [ci skip] 2024-02-02 04:07:22 +00:00
renovate[bot]
a13abe446b
Update dependency black to v24 (#1849)
* Update dependency black to v24

* update file to match new formatting from black

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
2024-02-01 20:05:39 -08:00
renovate[bot]
5ce9d47126
Update dependency poethepoet to v0.24.4 (#1825)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-01 20:05:03 -08:00
Jrnl Bot
581af57bfd Update changelog [ci skip] 2024-02-02 03:49:26 +00:00
renovate[bot]
60abba3bfe
Update dependency ruamel.yaml to v0.18.5 (#1822)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-01 19:47:52 -08:00
Jrnl Bot
5323ca64fa Update changelog [ci skip] 2024-02-02 03:47:22 +00:00
renovate[bot]
1b2fa594e8
Update dependency ruff to v0.2.0 (#1824)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-01 19:45:51 -08:00
Jrnl Bot
36677fdccd Update changelog [ci skip] 2024-02-02 03:45:21 +00:00
renovate[bot]
896be7fb5f
Update dependency pytest-xdist to v3.5.0 (#1829)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-01 19:43:59 -08:00
Jrnl Bot
a2a6618959 Update changelog [ci skip] 2024-02-02 03:43:47 +00:00
renovate[bot]
39291bf1ce
Update dependency keyring to v24.3.0 (#1830)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-01 19:42:19 -08:00
Jrnl Bot
fbd468e03e Update changelog [ci skip] 2024-02-02 03:42:04 +00:00
renovate[bot]
d91c857fdc
Update dependency cryptography to v42 (#1850)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-01 19:40:28 -08:00
renovate[bot]
8eb124b54c
Update peter-evans/create-pull-request action to v6 (#1852)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-01 19:40:02 -08:00
Jrnl Bot
f3624a3fa2 Update changelog [ci skip] 2024-02-02 03:38:48 +00:00
renovate[bot]
de4cf5219e
Update nick-invision/retry action to v3 (#1851)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-01 19:37:06 -08:00
renovate[bot]
7fdc43b69d
Update dependency pa11y-ci to v3.1.0 (#1831)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-01 19:36:08 -08:00
renovate[bot]
df37641fa8
Update actions/setup-python action to v5 (#1848)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-01 19:35:05 -08:00
renovate[bot]
8edc14cfe7
Update actions/cache action to v4 (#1847)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-01 19:33:29 -08:00
renovate[bot]
8f2ac67659
Update dependency rich to v13.7.0 (#1833)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-01 19:32:36 -08:00
renovate[bot]
c5ba4cb198
Update dependency pytest-bdd to v7.0.1 (#1846)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-01 19:31:06 -08:00
renovate[bot]
d44515f764
Update dependency pytest to v7.4.4 (#1845)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-01 19:30:13 -08:00
Jrnl Bot
ccd68f1e78 Update changelog [ci skip] 2024-02-02 03:23:58 +00:00
renovate[bot]
fc16c6c3e8
Update dependency cryptography to v41.0.7 (#1837)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-01 19:22:31 -08:00
Jrnl Bot
b4e8bb0e12 Update changelog [ci skip] 2024-02-02 03:16:52 +00:00
renovate[bot]
5ca5ee6723
Update dependency jinja2 to v3.1.3 (#1844)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-01 19:15:11 -08:00
Jrnl Bot
ce50158167 Update changelog [ci skip] 2024-02-02 03:05:47 +00:00
renovate[bot]
d5f7182cf4
Update dependency tox to v4.12.1 (#1838)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-01 19:04:01 -08:00
Jrnl Bot
9d97df04a7 Update changelog [ci skip] 2024-02-02 02:54:59 +00:00
Micah Jerome Ellison
bf32d59844
Update release process to use Python 3.12 (#1820) 2024-02-01 18:53:27 -08:00
Jrnl Bot
caf3cdea3d Update changelog [ci skip] 2023-11-27 02:14:16 +00:00
utopiatopia
434c32003f
Document security risks of eavesdropping (#1834)
* Add security risks of eavesdropping
* Remove "Limitations" heading and dedent subheadings
* Move Plausible Deniability/Spying/Saved Passwords up above the long Shell History section

---------

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2023-11-26 18:12:26 -08:00
Micah Jerome Ellison
48a31e8154
v4.1 changelog cleanup (#1826)
* Sort packaging deps alphabetically

* De-dupe packaging deps. Only the latest one matters for the changelog

* Add missing PRs and a special thanks note

* Add missing linebreak
2023-11-04 12:58:52 -07:00
Jrnl Bot
3fe3eda27b Update changelog [ci skip] 2023-11-04 19:37:42 +00:00
Jrnl Bot
65070cb675 Increment version to v4.1 2023-11-04 19:35:55 +00:00
Jrnl Bot
311d0b51b6 Update changelog [ci skip] 2023-10-31 01:55:19 +00:00
Jrnl Bot
aca0a185b7 Increment version to v4.1-beta2 2023-10-31 01:53:15 +00:00
Jrnl Bot
14bf9ac55f Update changelog [ci skip] 2023-10-31 01:28:20 +00:00
Micah Jerome Ellison
cf145123f5
Force rich to use color codes when pretty printing (#1821) 2023-10-30 18:25:49 -07:00
Jrnl Bot
c2a97f3100 Update changelog [ci skip] 2023-10-29 20:36:06 +00:00
Jrnl Bot
296c459252 Increment version to v4.1-beta 2023-10-29 20:34:08 +00:00
Jrnl Bot
a176913bda Update changelog [ci skip] 2023-10-29 20:29:54 +00:00
Micah Jerome Ellison
721167a079
Resolve parsedatetime "flag style" DeprecationWarning (#1818)
* Stop ignoring parsedatetime warning flag style warning
* Use new VERSION_CONTEXT_STYLE to bypass parsedatetime flag style warning
* Replace "flag" and its magic numbers with contextual booleans
2023-10-29 13:27:53 -07:00
Jrnl Bot
7e94208574 Update changelog [ci skip] 2023-10-29 16:25:51 +00:00
renovate[bot]
ef016cfb76
Update dependency pytest to v7.4.3 (#1816)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-29 09:22:41 -07:00
renovate[bot]
c2cbf36a87
Update dependency poethepoet to v0.24.1 (#1806)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-29 09:22:21 -07:00
renovate[bot]
6379533065
Update dependency black to v23.10.1 (#1811)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-29 09:22:01 -07:00
renovate[bot]
eec83daaf5
Update dependency ruff to v0.1.3 (#1810)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-29 09:21:45 -07:00
Jrnl Bot
00a6724900 Update changelog [ci skip] 2023-10-29 16:15:25 +00:00
renovate[bot]
69e098d6e5
Update dependency pytest-bdd to v7 (#1807)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-29 09:13:09 -07:00
renovate[bot]
5bf24d6eac
Update dependency tzlocal to v5.2 (#1814)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-29 09:12:29 -07:00
Jrnl Bot
b6f1e76ae4 Update changelog [ci skip] 2023-10-29 16:10:57 +00:00
renovate[bot]
1fdb76008e
Update dependency ruamel.yaml to v0.18.3 (#1813)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-29 09:08:31 -07:00
Jrnl Bot
681b477543 Update changelog [ci skip] 2023-10-29 16:02:23 +00:00
renovate[bot]
c2fa27329c
Update dependency cryptography to v41.0.5 (#1815)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-29 08:59:51 -07:00
Jrnl Bot
299bf090fc Update changelog [ci skip] 2023-10-29 15:45:47 +00:00
Micah Jerome Ellison
a8f5f54a62
Add Python 3.12 support (#1761)
* Add python 3.12 beta to PR tests and testing schedule

* Remove -dev suffix from 3.12 version in test runner and allow pre-releases
Reference: https://github.com/actions/setup-python/releases/tag/v4.6.0

* Run poetry lock to get sub-dependencies to update
2023-10-29 08:43:43 -07:00
Jrnl Bot
75f97ce32f Update changelog [ci skip] 2023-10-17 15:36:22 +00:00
Micah Jerome Ellison
09a96e6db9
Set new required build fields in the ReadTheDocs config file (#1803)
* Set the OS in the ReadTheDocs build process

* Add required tools.python to ReadTheDocs config file

* Change Python version from number to a string
2023-10-17 08:33:58 -07:00
Jrnl Bot
f9558f960a Update changelog [ci skip] 2023-10-06 19:39:42 +00:00
renovate[bot]
1de94ca929
Update dependency ruff to v0.0.292 (#1797)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-06 12:37:35 -07:00
renovate[bot]
b639915fd4
Update dependency poethepoet to v0.24.0 (#1798)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-06 12:36:28 -07:00
renovate[bot]
12525e21ec
Update dependency tzlocal to v5.1 (#1804)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-06 12:35:42 -07:00
Jrnl Bot
3177578c64 Update changelog [ci skip] 2023-10-06 19:22:19 +00:00
renovate[bot]
4ea2fa8c31
Update dependency mkdocs to v1.5.3 (#1795)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-06 12:19:58 -07:00
Jrnl Bot
a1c24359d2 Update changelog [ci skip] 2023-10-06 18:53:56 +00:00
renovate[bot]
6529fbf211
Update dependency rich to v13.6.0 (#1794)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-06 11:51:52 -07:00
renovate[bot]
d881880c38
Update dependency ruamel.yaml to v0.17.35 (#1802)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-06 11:49:55 -07:00
Jrnl Bot
0a01420e9d Update changelog [ci skip] 2023-09-23 17:59:07 +00:00
renovate[bot]
c6f22a2753
Update dependency cryptography to v41.0.4 (#1796)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-23 10:56:52 -07:00
Jrnl Bot
c7b204022a Update changelog [ci skip] 2023-09-16 21:17:56 +00:00
renovate[bot]
1c7ad4d5bb
Update dependency ruff to v0.0.290 (#1792)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-16 14:15:36 -07:00
renovate[bot]
be4cc1abe8
Update dependency black to v23.9.1 (#1791)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-16 14:14:31 -07:00
Jrnl Bot
4969d28988 Update changelog [ci skip] 2023-09-09 22:46:45 +00:00
renovate[bot]
6962c399ea
Update dependency ruff to v0.0.287 (#1778)
* Update dependency ruff to v0.0.287

* add ruff target version to tailor linting to our required python versions

* fix linting issues

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
2023-09-09 15:44:46 -07:00
Jrnl Bot
9533b55d8f Update changelog [ci skip] 2023-09-09 21:10:43 +00:00
renovate[bot]
c4d7f37cc2
Update dependency rich to v13.5.2 (#1776)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-09 14:08:20 -07:00
Micah Jerome Ellison
5c4724d524
Rename readthedocs.yml to .readthedocs.yaml as per current RTD spec (#1781) 2023-09-09 13:55:44 -07:00
Jrnl Bot
dfdd9b69cb Update changelog [ci skip] 2023-09-09 20:45:34 +00:00
renovate[bot]
475923d6d5
Update dependency poethepoet to v0.22.1 (#1785)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-09 13:43:25 -07:00
Jrnl Bot
2674639383 Update changelog [ci skip] 2023-09-09 20:42:04 +00:00
renovate[bot]
d2fc602618
Update dependency pytest to v7.4.2 (#1787)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-09 13:40:07 -07:00
renovate[bot]
85bd7d40a5
Update actions/checkout action to v4 (#1788)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-09 13:39:13 -07:00
Jrnl Bot
303ca98d0b Update changelog [ci skip] 2023-09-09 20:27:19 +00:00
renovate[bot]
c63367b067
Update dependency black to v23.9.0 (#1790)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-09 13:25:11 -07:00
Jrnl Bot
42ac0d33cc Update changelog [ci skip] 2023-09-09 20:17:25 +00:00
renovate[bot]
2a59c708b2
Update dependency tox to v4.11.3 (#1782)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-09 13:15:30 -07:00
Jrnl Bot
75b703d39f Update changelog [ci skip] 2023-08-03 19:18:09 +00:00
renovate[bot]
0f4fdf89b2
Update dependency cryptography to v41.0.3 (#1779)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-08-03 12:15:51 -07:00
Jrnl Bot
d2756db940 Update changelog [ci skip] 2023-08-03 19:12:35 +00:00
renovate[bot]
cfcbd8e6b7
Update dependency mkdocs to v1.5.2 (#1780)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-08-03 12:10:30 -07:00
Micah Jerome Ellison
cb69bb474c
Use rich instead of ansiwrap to wrap text (#1693) 2023-07-29 14:36:43 -07:00
Jrnl Bot
525cce3e92 Update changelog [ci skip] 2023-07-29 19:06:39 +00:00
renovate[bot]
cf6aef7ae0
Update dependency parse-type to v0.6.2 (#1762)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-07-29 12:04:26 -07:00
Jrnl Bot
b77ea37b2c Update changelog [ci skip] 2023-07-29 19:02:25 +00:00
renovate[bot]
488998cd33
Update dependency cryptography to v41.0.2 (#1770)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-07-29 12:00:16 -07:00
renovate[bot]
f5378dea74
Update dependency mkdocs to v1.5.1 (#1774)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-07-29 11:59:31 -07:00
Jrnl Bot
23b169708c Update changelog [ci skip] 2023-07-29 18:58:59 +00:00
renovate[bot]
b899130009
Update dependency rich to v13.5.0 (#1775)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-07-29 11:56:42 -07:00
Jrnl Bot
bb838ed83a Update changelog [ci skip] 2023-07-29 18:10:56 +00:00
renovate[bot]
4c53cd8830
Update dependency poethepoet to v0.21.1 (#1767)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-07-29 11:08:59 -07:00
renovate[bot]
1aa1ac0976
Update dependency black to v23.7.0 (#1769)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-07-29 11:08:10 -07:00
Jrnl Bot
f4db877ddd Update changelog [ci skip] 2023-07-29 17:58:19 +00:00
renovate[bot]
0da41a1328
Update dependency ruff to v0.0.280 (#1773)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-07-29 10:56:20 -07:00
Jrnl Bot
9970873ff5 Update changelog [ci skip] 2023-07-29 17:45:48 +00:00
renovate[bot]
129428ef80
Update dependency tox to v4.6.4 (#1765)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-07-29 10:43:36 -07:00
Jrnl Bot
e1501fd4d1 Update changelog [ci skip] 2023-07-15 19:37:08 +00:00
Micah Jerome Ellison
34c7903300
Replace flake8 and isort with ruff linter and add black --check to linting step (#1763)
* Add ruff

* Add ruff config

* Add ruff rules that look useful and are already passing

* Add more ruff rules after talking with Jonathan

* Add line length exception for acceptably long indented line

* Resolve ruff line length 88 rule in args. Changing small lines but adding a noqa ignore directive to longer lines that look best as they are. Their dedented length is still less than 88

* poe format

* Resolve all remaining ruff line length errors

* Replace flake* and isort with ruff calls

* Add black --check as final lint step. ruff catches most but not all black formatting issues

* Remove unneeded flakeheaven setting

* Remove flake* and isort now that ruff is handling all their business

* Update pyproject, lockfile with latest version of ruff

* Document each ruff rule with comment

* Add black --version call before black --check

* Remove extraneous period
2023-07-15 12:35:10 -07:00
Jrnl Bot
dd09ece4e7 Update changelog [ci skip] 2023-07-15 19:11:58 +00:00
Micah Jerome Ellison
c6b9114c42
Add note about messages going to stderr and the implication for piping (#1768)
* Add note about messages going to STDERR and the implication for piping

* Minor wording change

* Wording and capitalization changes
2023-07-15 12:09:18 -07:00
Jrnl Bot
7a9bc929a5 Update changelog [ci skip] 2023-06-24 18:31:50 +00:00
renovate[bot]
235ba679e3
Update dependency keyring to v24.2.0 (#1760)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-24 11:29:56 -07:00
Jrnl Bot
32f7b9de62 Update changelog [ci skip] 2023-06-24 18:28:06 +00:00
renovate[bot]
9735a60883
Update dependency cryptography to v41 (#1753)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-24 11:25:40 -07:00
renovate[bot]
b4088bf8b8
Update dependency tox to v4.6.3 (#1751)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-24 11:24:15 -07:00
renovate[bot]
a1de9589b5
Update dependency ruamel.yaml to v0.17.32 (#1752)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-24 11:23:01 -07:00
renovate[bot]
875b6d2b35
Update dependency rich to v13.4.2 (#1754)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-24 11:21:28 -07:00
renovate[bot]
12355e087c
Update dependency pytest to v7.4.0 (#1757)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-24 11:21:09 -07:00
renovate[bot]
6e8d6e9aee
Update dependency keyring to v24 (#1758)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-24 11:19:31 -07:00
Jrnl Bot
2a05aad0e9
Update changelog [ci skip] 2023-06-20 16:53:52 -07:00
Jrnl Bot
4f1a21819d Increment version to v4.0.1 2023-06-20 23:39:40 +00:00
Jrnl Bot
12e663ee93 Update changelog [ci skip] 2023-05-27 20:02:06 +00:00
renovate[bot]
9edc7c5cc0
Update dependency ruamel.yaml to v0.17.28 (#1749)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-05-27 12:59:47 -07:00
Jrnl Bot
793a5e22c5 Update changelog [ci skip] 2023-05-22 20:16:54 +00:00
renovate[bot]
10cf68161e
Update dependency requests to v2.31.0 (#1748)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-05-22 13:14:18 -07:00
Jrnl Bot
21c4aa0b3a Update changelog [ci skip] 2023-05-20 23:37:04 +00:00
Jrnl Bot
649254d0ac Increment version to v4.0.1-beta 2023-05-20 23:34:50 +00:00
Jrnl Bot
f5dc5fbae0 Update changelog [ci skip] 2023-05-20 23:31:48 +00:00
renovate[bot]
5124a805c8
Update dependency ruamel.yaml to v0.17.26 (#1746)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-05-20 16:20:47 -07:00
Jrnl Bot
982e597742 Update changelog [ci skip] 2023-05-20 23:15:49 +00:00
Micah Jerome Ellison
4a7057c038
Refactor --template code (#1711)
* Move path concerns to path.py and template concerns to editor.py -- BDD tests are failing
* Move path-related constants from config.py to path.py
* Mock get_templates_path in its new calling file
* Mediate template arg vs. config in controller then read template text in editor and unify those two use cases.
Some tests still failing
* Fix test whose message had changed
* poe format
* Refactor for easier unit testing and add unit tests
* Use path strings instead of Path objects in return values to prevent side effects that caused unit tests to fail on some platforms
* poe format
* Attempt to bypass getcwd errors in CI with patch
* Consistently use strings for paths instead of some strings and some pathlib.Path
* Keep pathlib within a function for readability
* fix for ruamel.yaml versions >=0.17.22
* Run poe format

---------

Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
2023-05-20 16:13:24 -07:00
renovate[bot]
78d11d74bd
Update dependency flake8-simplify to v0.20.0 (#1716)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-05-20 16:12:26 -07:00
Jrnl Bot
b1843ab14b Update changelog [ci skip] 2023-05-20 23:05:54 +00:00
Jonathan Wren
4cb5d1e436
fix some linting issues for failing PR (#1745) 2023-05-20 16:03:46 -07:00
renovate[bot]
959e18ad91
Update peter-evans/create-pull-request action to v5 (#1719)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-05-20 16:02:35 -07:00
Jrnl Bot
4292d85a22 Update changelog [ci skip] 2023-05-20 22:57:33 +00:00
Jonathan Wren
9f4ca2683f
run pipeline tests weekly (#1744) 2023-05-20 15:55:25 -07:00
Jrnl Bot
3e44027ab5 Update changelog [ci skip] 2023-05-20 22:46:18 +00:00
Jonathan Wren
98d2a3b3ec
fix linting issue from shellcheck (#1743) 2023-05-20 15:43:52 -07:00
Jrnl Bot
0d8fc9028c Update changelog [ci skip] 2023-05-20 22:25:05 +00:00
renovate[bot]
f5e5d817be
Update dependency requests to v2.30.0 (#1728)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-05-20 15:22:31 -07:00
renovate[bot]
d5f00edb9d
Update dependency rich to v13.3.5 (#1729)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-05-20 15:20:51 -07:00
renovate[bot]
6e9fade8dd
Update dependency tox to v4.5.1 (#1727)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-05-20 15:19:30 -07:00
Jrnl Bot
7045e97a24 Update changelog [ci skip] 2023-05-20 22:17:51 +00:00
renovate[bot]
fdc87ff8c4
Update dependency mkdocs to v1.4.3 (#1733)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-05-20 15:15:42 -07:00
Jrnl Bot
81313c2445 Update changelog [ci skip] 2023-05-20 22:12:36 +00:00
renovate[bot]
0b8b4244bd
Update dependency poethepoet to v0.20.0 (#1735)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-05-20 15:10:16 -07:00
Jrnl Bot
7a8b86aadb Update changelog [ci skip] 2023-05-20 22:10:01 +00:00
renovate[bot]
1f59c15f5e
Update dependency pytest-xdist to v3.3.1 (#1740)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-05-20 15:07:47 -07:00
renovate[bot]
da0c49da83
Update dependency tzlocal to v5 (#1741)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-05-20 15:07:06 -07:00
Micah Jerome Ellison
8f2eb27793
Add flakeheaven_cache/ to gitignore and fix typo in comment (#1731) 2023-05-20 14:57:24 -07:00
Jonathan Wren
a1a68f7eea
clean up changelog a bit 2023-05-20 14:50:41 -07:00
Jrnl Bot
cd850c068d Update changelog [ci skip] 2023-05-20 20:37:30 +00:00
Jrnl Bot
e987e34c78 Increment version to v4.0 2023-05-20 20:35:57 +00:00
Jrnl Bot
53342c944e Update changelog [ci skip] 2023-05-07 00:04:57 +00:00
Jonathan Wren
0b55c477e1
Lock ruamel.yaml version until bug is fixed (#1738) 2023-05-06 17:02:55 -07:00
Jrnl Bot
7e09c4eb66 Update changelog [ci skip] 2023-04-29 22:53:16 +00:00
Jrnl Bot
adeb1acced Increment version to v4.0-beta3 2023-04-29 22:51:01 +00:00
Micah Jerome Ellison
95836a7dd1
Only read text files that look like entries when opening folder journal (#1697)
* Add text file that should be ignored to basic test folder journal. Makes tons of tests fail
* Add additional files that should be ignored by FolderJournal
* Ignore all files in folder journal except year/month/day.txt
* Completely remake get_files in FolderJournal:
- move get_files into FolderJournal class and add underscore prefix
- create iterables to get for year/month folders and day files
- make year/month/day file reading strict: only exact expected months and days out of all possible months and days
* Restore accidentally-deleted self.sort() line
* Use match instead of string comparison to be os-agnostic
* Explicitly declare static methods
* Filter with glob first for max performance
* Explicitly check for valid dates in FolderJournal and add unit test
* Remove unneeded jrnl import
* Clean up method comment and add type hints
* Add is_valid_date unit test
* Elucidate comment

Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
2023-04-29 15:49:41 -07:00
Jrnl Bot
88aa2491b0 Update changelog [ci skip] 2023-04-29 18:59:52 +00:00
CoffeeOrDeath
73aa146f8a
Update contributing.md links in documentation (#1726)
* Chore: Update README.md to contribution

Update the contribution link to go directly to the current contribution guide and documentation.

* Update PULL_REQUEST_TEMPLATE.md
2023-04-29 11:57:57 -07:00
Jrnl Bot
7d237c887f Update changelog [ci skip] 2023-04-22 20:49:03 +00:00
Jrnl Bot
8d95e0bfe9 Increment version to v4.0-beta2 2023-04-22 20:46:35 +00:00
Jrnl Bot
bd147fa285 Update changelog [ci skip] 2023-04-22 20:40:18 +00:00
renovate[bot]
ab9128ffb6
Update dependency tox to v4.4.12 (#1712)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-04-22 13:38:15 -07:00
Jrnl Bot
d2c92511ff Update changelog [ci skip] 2023-04-22 20:37:56 +00:00
renovate[bot]
9bd16473c9
Update dependency rich to v13.3.4 (#1713)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-04-22 13:35:27 -07:00
renovate[bot]
ad3b8396be
Update dependency flake8-type-checking to v2.4.0 (#1714)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-04-22 13:34:15 -07:00
Jrnl Bot
8a22f9db56 Update changelog [ci skip] 2023-04-22 20:33:52 +00:00
renovate[bot]
b00f5f1531
Update dependency black to v23.3.0 (#1715)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-04-22 13:31:16 -07:00
Jrnl Bot
fc83bee80b Update changelog [ci skip] 2023-04-22 20:21:49 +00:00
Zhizhen He
0b64d50f4b
fix typo (#1718) 2023-04-22 13:19:15 -07:00
Jrnl Bot
ea6a5da3eb Update changelog [ci skip] 2023-04-22 19:41:20 +00:00
renovate[bot]
5bcdcdd5c6
Update dependency pytest to v7.3.1 (#1720)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-04-22 12:39:25 -07:00
renovate[bot]
9581b1b81a
Update dependency flakeheaven to v3.3.0 (#1722)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-04-22 12:37:48 -07:00
Jrnl Bot
10216988d4 Update changelog [ci skip] 2023-04-22 19:32:57 +00:00
renovate[bot]
745373df6a
Update dependency cryptography to v40.0.2 (#1723)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-04-22 12:30:17 -07:00
Jrnl Bot
23551a379b Update changelog [ci skip] 2023-03-25 23:06:24 +00:00
Jrnl Bot
deef870213 Increment version to v4.0-beta 2023-03-25 23:04:23 +00:00
Jrnl Bot
37b731ff14 Update changelog [ci skip] 2023-03-25 19:34:32 +00:00
Jonathan Wren
3c923ae943
Allow combinations of --change-time, --delete, and --edit while correctly counting the number of entries affected (#1669)
* Remove search mode conditional that added explicit tag search behavior
* Fix failing change-time test by using same method signature as base journal class
* Fix user input mock - was not appropriately checking return value
* Clean up controller
  - streamline `run` function in `controller.py`
  - add debug logging
  - fix unnecessary import of Journal class (only needed for typing)
  - standardize summary display across different actions
* Add currently-failing test conditions for count messages when changing time and deleting
* Don't show summary if no entries found and prevent extra line break when no entries found by short-circuiting display method
* Track found entry count and remove incorrect modified stat logic
* Track journal entry deletion consistently
* Remove unneeded exception when editor is empty and fix test that was testing incorrect message
* Correct entry edit modified count test
* Track modification of entries with --change-time
* Preserve existing behavior when editor is empty but make the message more clear
* Reconcile tests with new error message when clearing editor in edit mode
* Add found/modified counts to edit tests
* Add tests for found count with -n equivalent argument
* Test combinations of found/deleted messages when using --delete
* Add tests for counting combinations of action arguments (change-time, edit, delete) and for change-time counts. Some are failing and should be investigated
* Remove extraneous comment in test
* Track added/deleted counts in a register in the Journal class instead of attempting to infer it via controller counting
* Add encrypted to more tests
* Fix merge conflict typo
* Change 'write mode' -> 'append mode' in more places

---------

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2023-03-25 12:32:25 -07:00
Jrnl Bot
b3c6f90a35 Update changelog [ci skip] 2023-03-25 18:49:16 +00:00
Aaron Lichtman
a2b217fdfc
Add ability to use template with --template (#1667)
* Add ability to pass template path with --template

Update jrnl/args.py

* Fix tests
2023-03-25 11:47:00 -07:00
Jrnl Bot
0725ea6b87 Update changelog [ci skip] 2023-03-25 18:18:19 +00:00
renovate[bot]
dad2744e71
Update dependency cryptography to v40 (#1710)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-25 11:15:48 -07:00
Jrnl Bot
94f079293b Update changelog [ci skip] 2023-03-25 17:55:18 +00:00
renovate[bot]
55f7328b3e
Update dependency poethepoet to v0.19.0 (#1709)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-25 10:53:19 -07:00
Jrnl Bot
5a74b0e722 Update changelog [ci skip] 2023-03-18 20:00:55 +00:00
renovate[bot]
3764946dfe
Update dependency pytest-xdist to v3.2.1 (#1705)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-18 12:58:47 -07:00
renovate[bot]
1b7afe588b
Update dependency ipdb to v0.13.13 (#1703)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-18 12:57:47 -07:00
renovate[bot]
f7e2a59332
Update dependency flake8-type-checking to v2.3.1 (#1702)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-18 12:56:38 -07:00
renovate[bot]
fc9def0879
Update dependency pytest to v7.2.2 (#1704)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-18 12:56:10 -07:00
renovate[bot]
7cd301fcbf
Update dependency rich to v13.3.2 (#1706)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-18 12:55:42 -07:00
renovate[bot]
16fec7c87f
Update dependency tox to v4.4.7 (#1707)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-18 12:53:56 -07:00
Jrnl Bot
a7021b03e7 Update changelog [ci skip] 2023-03-18 19:47:29 +00:00
renovate[bot]
d24a73e349
Update dependency cryptography to v39.0.2 (#1701)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-18 12:45:21 -07:00
Jrnl Bot
d67310ec90 Update changelog [ci skip] 2023-03-18 19:39:00 +00:00
renovate[bot]
0f203fb198
Update dependency tzlocal to v4.3 (#1708)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-18 12:36:58 -07:00
Jrnl Bot
aa8433f881 Update changelog [ci skip] 2023-03-04 20:53:29 +00:00
Micah Jerome Ellison
e54908be0d
Document -tagged, -not -tagged, and -not -starred in command line reference (#1684) 2023-03-04 12:51:12 -08:00
Jrnl Bot
22bf6595da Update changelog [ci skip] 2023-03-04 20:47:31 +00:00
Micah Jerome Ellison
427485a1d7
Add message with config location and docs location when installation is complete (#1695) 2023-03-04 12:45:37 -08:00
Jrnl Bot
23150ddb31 Update changelog [ci skip] 2023-03-04 20:39:09 +00:00
Micah Jerome Ellison
1a67fd5dec
Use pytest-bdd 6 (#1685)
* update pytest-bdd to 6.0
* update lock file
* fix first test (inject command fixture to request)
* fix some more tests
* fix cli_run fixture
* fix password fixture
* Remove unused import
* Fix greedy should_or_should_not parsing problems while also consolidating its parse/transformation-to-bool code
* Prevent greedy matching in "we run" by using regular expression lookahead
* Add missing "Outline" in scenario outlines with examples
* Split "we use the config" and "we use no config" so pytest won't try to consume config_file as a fixture
* Fix missing ShouldOrShouldNot
* Formatting
* fix get_fixture function
* change output of failing test to be a little more useful
* update lock file
* update type builder to for should/should not to be in it's own file, rename some vars for readability
* add parse-type new dev/testing dependency
* update lock file

---------

Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
2023-03-04 12:37:06 -08:00
Micah Jerome Ellison
2d0b15ea7b
Update documentation front page text (#1698)
* Update front page console examples and feature text with more present-day style, brand-agnostic examples, and hopefully a more inclusive tone

* Updating feature blurb text

* Blurb edit

* Update index.html

* Update index.html

* Update index.html

📓🖉 👍

---------

Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
2023-03-04 12:20:20 -08:00
Jrnl Bot
611f3af772 Update changelog [ci skip] 2023-02-25 23:32:54 +00:00
Micah Jerome Ellison
e6804f1627
Prompt to include colors in config when first running jrnl (#1687)
* Add prompt to ask user if entries should be formatted with colors when installing jrnl
* Use magenta instead of black for default date color
* Use other default colors and alphabetize color list
* Update tests
* Delete test file
* update lock file
* fix failing test after merge conflict

---------

Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
2023-02-25 15:30:25 -08:00
Jrnl Bot
fecd696b2a Update changelog [ci skip] 2023-02-25 20:31:52 +00:00
Micah Jerome Ellison
3c87111710
Save empty journal on install instead of just creating a zero-length file (#1690)
* Add failing test for issue #1493
* Write journal upon creation instead of just creating 0-length file
* Fix test to accommodate current password mocking form
2023-02-25 12:29:43 -08:00
Jrnl Bot
592e7bcf27 Update changelog [ci skip] 2023-02-25 20:18:29 +00:00
Micah Jerome Ellison
d81b5ad955
Support mkdocs 1.4.2 and fix its missing breadcrumb (#1691)
* Use latest mkdocs version 1.4.2
* Add docs_theme to mkdocs watch so it automatically reloads localhost when modifying theme
* Bring in ReadTheDocs breadcrumb theme and fix display issues around "Docs" root breadcrumb
* The problem is CSS, not the breadcrumbs template. Tightly scope offending CSS and remove breadcrumbs template override
* Bring mkdocs ReadTheDocs breadcrumbs theme back in
* Fix pa11y validation issue by replacing breadcrumb a alt attribute with aria-label
* Attribute source of new breadcrumbs file
* Use mkdocs 1.4 or greater with no upper bound
2023-02-25 12:16:33 -08:00
Micah Jerome Ellison
fcac94a30e
Document temporary file extension behavior when using template (#1686)
* Document jrnl's temp file behavior when using templates
* Move up "Files in transit from editor to jrnl" section and add notes about template extension behavior in solutions that reference .jrnl extension
* Update privacy-and-security.md
2023-02-25 12:15:52 -08:00
Giuseppe D'Andrea
18397b13eb
Update documentation about privacy and security in VSCode (#1680)
* docs: vscode file history

* docs: vscode unsaved files

* Edited for tone

---------

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2023-02-21 08:45:53 -08:00
Jrnl Bot
b4da3a51f7 Update changelog [ci skip] 2023-02-11 20:40:50 +00:00
Briscoooe
b41a988d6f
Don't save templated journal entries if the received raw text is the same as the template itself (#1653) 2023-02-11 12:38:21 -08:00
David Isaksson
6c6937c507
Add documentation about information leaks in Vim/Neovim (#1674)
* Add documentation about using Vim/Neovim as editor
* Add documentation about information leaks in editors
* Spelling fix

---------

Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
2023-02-11 12:16:31 -08:00
Jrnl Bot
6b179e673b Update changelog [ci skip] 2023-02-11 20:12:27 +00:00
Giuseppe D'Andrea
2d1a52afe5
Update documentation on temporary files naming (#1673) 2023-02-11 12:10:18 -08:00
Jrnl Bot
d4ce2a84cf Update changelog [ci skip] 2023-01-28 19:47:17 +00:00
Ciaran Concannon
7bd15d12ad
Search for entries with no tags or stars with -not -starred and -not -tagged (#1663)
* Allow for `-not -starred` to search for unstarred entries

* Add `-tagged` and `-not -tagged` functionality
2023-01-28 11:45:01 -08:00
Jrnl Bot
17c987c605 Update changelog [ci skip] 2023-01-14 22:44:27 +00:00
Jonathan Wren
fff05eb646
Refactor flow for easier access to some files (avoid things like jrnl.Journal.Journal and jrnl.jrnl co-existing) (#1662)
* run format

* rename cli.py to main.py

* rename jrnl.py to controller.py

* move journal class files into journals dir

* rename start -> run in controller.py
2023-01-14 14:42:29 -08:00
Jrnl Bot
7be67accc1 Update changelog [ci skip] 2023-01-14 21:24:31 +00:00
outa
a13726d4c5
Add more type hints (#1642) 2023-01-14 13:22:31 -08:00
Peter Conrad
9547411390
Update docs to include time and title in arguments with --edit (#1657) 2023-01-07 14:04:33 -08:00
Jrnl Bot
120c54a29e Update changelog [ci skip] 2023-01-07 22:01:41 +00:00
renovate[bot]
a6f2d34b7e
Update dependency rich to v13 (#1654)
* Update dependency rich to v13

* Update pyproject.toml

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
2023-01-07 13:59:40 -08:00
Jonathan Ballet
458faff8a8
Fix markup in "Advanced Usage" doc (#1655)
* Fix YAML indentiation in a configuration example
* Improve Markdown markup
2023-01-07 13:58:49 -08:00
Jrnl Bot
2cec8bdc5b Update changelog [ci skip] 2023-01-07 21:41:17 +00:00
Jonathan Wren
8da6029624
Update copyright notices for 2023 (#1660)
* update copyright notice for 2023

* standardize whitespace after copyright notice
2023-01-07 13:39:07 -08:00
Micah Jerome Ellison
9274ab16ed
Add basic template test (#1659)
* Add very basic test template
* Ensure that templates are copied to temporary test workspace
* Add basic template test
* Update copyright for this new file
2023-01-07 13:37:43 -08:00
Jrnl Bot
d5d39971b4 Update changelog [ci skip] 2023-01-07 20:53:14 +00:00
Jonathan van der Steege
907566b39f
Add tag to XML file when edited DayOne entry and is searchable afterward (#1648)
* Add tag to XML file when edited DayOne entry
* Remove forbidden change
* undo edits
* Tags working for DayOne journal
* Correction doentries to prevent time-error
* Add sorting to tags
* Delete test statements
* Revert time changes
2023-01-07 12:51:07 -08:00
Jrnl Bot
7229d77bda Update changelog [ci skip] 2023-01-07 19:48:26 +00:00
Jonathan van der Steege
d94325127f
Update version key in config file after version changes (#1646) 2023-01-07 11:46:12 -08:00
Jrnl Bot
fe08cfd3ab Update changelog [ci skip] 2022-11-19 21:41:41 +00:00
Jonathan Wren
fcc8d8e3fa
Rework Encryption to enable future support of other encryption methods (#1602)
- initial pass through to rework encryption into separate module
- little more cleanup
- rename function, fix some linting issues
- more cleaning
- fix password bug in encryption
- fix linting issue
- more cleanup
- move prompt into prompt.py
- more cleanup
- update the upgrade process for new encryption classes
- general cleanup
- turn into enum instead of strings
- store status code so tests don't fail
- standardize the load and store methods in journals
- get rid of old PlainJournal class
- typing cleanup
- more cleanup
- format
- fix linting issue
- Fix obscure Windows line ending issue with decode
  See https://bugs.python.org/issue40863
- fix for python 3.11
- add more typing
- don't use class variables because that's not what we want
- fix more type hints
- jrnlv1 encryption doesn't support encryption anymore (it's deprecated)
- keep logic for password attemps inside the class that uses it
- take out old line of code
- add some more logging
- update logging statements
- clean up logging statements
- run linters
- fix typo
- Fix for new test from develop branch
  There was a new test added for re-encrypting a journal. This updates the
  refactor to match the old (previously untested) behavior of jrnl.

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2022-11-19 13:39:39 -08:00
Jrnl Bot
e6e08e5d3e Update changelog [ci skip] 2022-11-05 23:07:28 +00:00
Micah Jerome Ellison
92a8ec4f68
Remove Windows 7 known issue since jrnl no longer supports (#1636) 2022-11-05 16:05:36 -07:00
Jrnl Bot
b7a3110e7e Update changelog [ci skip] 2022-11-05 22:58:54 +00:00
Jonathan Wren
b508ed6c9a
Add simplify plugin to linting checks (#1630)
* add simplify plugin for flakeheaven

* update lock file

* fix linting issues in current codebase
2022-11-05 15:56:46 -07:00
Jrnl Bot
1e69495728 Update changelog [ci skip] 2022-11-05 22:31:41 +00:00
outa
30b41fdb88
Add type hints (#1614)
* Add type hints

* Fix linters

* Add remaining type hints

* Fix type-checking linter

* Update jrnl/DayOneJournal.py

Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
2022-11-05 15:29:50 -07:00
Jonathan Wren
c1eb0c54a3
Add type-checking plugin to linting checks (#1629)
* add type-checking plugin for flakeheaven

* update lock file

* fix type-checking issues in current codebase

* run linters
2022-11-03 07:18:35 -07:00
Jrnl Bot
cb7e0ed289 Update changelog [ci skip] 2022-11-03 02:55:34 +00:00
Micah Jerome Ellison
e6130dbf4a
Resolve failing GitHub Actions linting by replacing deprecated set-output command (#1632)
* Replace deprecated set-output command
* Resolve SC2086 - double quote to prevent globbing and word splitting
* fix quotes in output command

Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
2022-11-02 19:53:32 -07:00
Jrnl Bot
8e482321f2 Update changelog [ci skip] 2022-11-01 23:52:21 +00:00
Jonathan Wren
8ad9e2bdd6
Fix bug where changelog is always slightly out of date on release tags (#1631)
* fix issue where changelog is always slightly out of date on release tags

* fix tag step running all the time per CR

* update tag name to use more clear variable name
2022-11-01 16:50:25 -07:00
Jonathan Wren
51e9ce5638
Move existing linting into flakeheaven (#1628)
* add black and isort to flakeheaven

* update lock file

* clean up poe config

* run formta on python blocks in markdown file

* disable code for black being confused about markdown

* add cache timeout for flakeheaven

See: https://github.com/flakeheaven/flakeheaven/issues/71
2022-10-31 09:31:17 -07:00
Jrnl Bot
9150f07984 Update changelog [ci skip] 2022-10-31 15:58:15 +00:00
Jonathan Wren
cd47070894
Add rich handler for better-formatted debug logging (#1627) 2022-10-31 08:55:23 -07:00
Micah Jerome Ellison
44e2ace833
Add double encryption test (#1626) 2022-10-30 13:06:54 -07:00
Jrnl Bot
5cf9311502 Update changelog [ci skip] 2022-10-29 21:39:27 +00:00
Micah Jerome Ellison
74b7ac834e
Drop Python 3.9 and use Python 3.11 official release (#1611)
* Drop Python 3.9 and use Python 3.11 release instead of pre-release
* Run poetry lock
* Fix need for quoted 3.10 string
* Use 3.11.0-rc.2 for Python 3.11 for now
* Update minimum Python version in installation docs
* Change Python 3.11 RC version to 3.11
* Run docs and release workflows on Python 3.11
* Including Python 3.12 in allowable versions
* Restore poetry.lock from develop
* Run poetry lock --no-update
* Retrieve poetry.lock from develop and lock with --no-update
* poetry lock --no-update
2022-10-29 14:36:50 -07:00
Jonathan Wren
a77a3d5a56
Replace flake8 with flakeheaven in linting steps (#1625)
* replace flake8 with flakeheaven

* update pyproject.toml for new flake tool

* update lock file

* change flake8 to flakeheaven in tests

* undo fix for poetry

* remove unused plugin marker for flakeheaven

* remove unused import in markdown file

* Attempt to exclude .venv from flakeheaven runs in CI

* Exclude more dirs from flakeheaven

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2022-10-29 14:21:11 -07:00
Jonathan Wren
847dadac5d
Manual change to changelog [ci skip]
- Document that v3.0 had breaking changes with emoji for emphasis
2022-10-29 12:40:31 -07:00
Jrnl Bot
60590e0c49 Update changelog [ci skip] 2022-10-29 19:27:02 +00:00
Jrnl Bot
415fc336ec Increment version to v3.3 2022-10-29 19:19:53 +00:00
Jrnl Bot
81771eff4f Update changelog [ci skip] 2022-10-29 19:16:11 +00:00
Micah Jerome Ellison
6f9a3eb536
Document that editors must be blocking processes (#1624)
* Describe blocking processes in External Editors page
* Add documentation about how the editor must be a blocking process
* Add contextual link to external editor site
* Point to micro editor as an example since it's likely less intimidating than vim
2022-10-29 12:14:28 -07:00
Micah Jerome Ellison
c6479c70c1 Add contextual link to external editors page from overview 2022-10-29 11:51:41 -07:00
Jrnl Bot
6cd8c35598 Update changelog [ci skip] 2022-10-22 22:40:26 +00:00
Jrnl Bot
ffdd4f923d Increment version to v3.3-beta2 2022-10-22 22:38:31 +00:00
Jrnl Bot
c32acd0123 Update changelog [ci skip] 2022-10-22 22:36:58 +00:00
Jonathan Wren
63850a33c1
Fix bug for new --list --format options when no default journal is specified (#1621)
* rename test config

* Change journal name validation

Journal name validation used to happen before postconfig commands could
have a chance to run, so now each command is responsible for its own
error-checking of the journal name.

Added a new decorator and function that makes this error-checking easier.

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>

* fix wrapper function call to be more like original

* change arg names to show which aren't used

* add type hints

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2022-10-22 15:35:16 -07:00
Jrnl Bot
619de775fd Update changelog [ci skip] 2022-10-22 21:30:18 +00:00
DSiekmeier
48c528d76a
Remove wrong option in configuration file reference (#1618) 2022-10-22 14:28:34 -07:00
Jrnl Bot
52f82fc855 Update changelog [ci skip] 2022-10-08 20:51:42 +00:00
Jrnl Bot
41e5d5ffff Increment version to v3.3-beta 2022-10-08 20:49:59 +00:00
outa
d7242d81a4
Don't create empty file when attempting a YAML export to a non-existing folder (#1600)
* Call `export_journal` before opening file handle
* Use correct exporter class
* Fix unit test
2022-10-08 13:48:29 -07:00
Jrnl Bot
a925c81ba8 Update changelog [ci skip] 2022-10-08 20:43:20 +00:00
Micah Jerome Ellison
ceff398a01
Change default config to use journal key instead of journal name as key for file path (#1594) 2022-10-08 13:41:22 -07:00
Jrnl Bot
dd7f59cef7 Update changelog [ci skip] 2022-10-08 19:42:07 +00:00
Jonathan Wren
ff24ee604d
Update .gitignore (#1604)
* add ignore for directories used by this project

* update name of asdf version file (had a typo)
2022-10-08 12:40:27 -07:00
Jrnl Bot
560d076a5f Update changelog [ci skip] 2022-09-24 19:48:37 +00:00
Kevin
2df7acf488
Add machine readable --list output (#1592)
* Add machine readable --list output

* Refactor list_journals()

Create three new methods for each journal list format.
- JSON, YAML, STDOUT

* Added journal list export test

* Update test regex to handle windows filepaths
2022-09-24 12:46:49 -07:00
dependabot[bot]
057f31407a
Bump mako from 1.2.1 to 1.2.2 (#1598)
Bumps [mako](https://github.com/sqlalchemy/mako) from 1.2.1 to 1.2.2.
- [Release notes](https://github.com/sqlalchemy/mako/releases)
- [Changelog](https://github.com/sqlalchemy/mako/blob/main/CHANGES)
- [Commits](https://github.com/sqlalchemy/mako/commits)

---
updated-dependencies:
- dependency-name: mako
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-17 12:04:36 -07:00
Jonathan Wren
e9be61cae2
Change default timestamp to %F %r (#1595)
Fixes #1100
2022-09-17 12:02:52 -07:00
Jrnl Bot
66d26cfed6 Update changelog [ci skip] 2022-09-10 18:50:10 +00:00
Kevin
b5a22379b8
Update YAML export description in docs (#1591) 2022-09-10 11:48:20 -07:00
Jrnl Bot
405e0c2199 Update changelog [ci skip] 2022-09-03 21:23:14 +00:00
Jonathan Wren
bd02c52d5a
Fix Docs Accessibility Testing (#1588)
* update run_shell task to use newer python

* add shell arg back

* make tests run when certain files change
2022-09-03 14:21:27 -07:00
Jrnl Bot
8032aa9f2f Update changelog [ci skip] 2022-09-03 20:25:31 +00:00
renovate[bot]
a95cd333d5
Update dependency typed.js to v2.0.12 (#1578)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-09-03 13:23:37 -07:00
renovate[bot]
0618ff57e4
Update dependency jinja2 to v3.1.2 (#1579)
* Update dependency jinja2 to v3.1.2

* Remove old unneeded comment from requirements.txt

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
2022-09-03 13:22:46 -07:00
Jrnl Bot
a3ce9bdb55 Update changelog [ci skip] 2022-09-03 20:18:05 +00:00
renovate[bot]
43d7dc026c
Pin dependencies (#1577)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-09-03 13:16:28 -07:00
renovate[bot]
0d7acafc44
Update actions/checkout action to v3 (#1582)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-09-03 13:16:18 -07:00
Jrnl Bot
080fcde440 Update changelog [ci skip] 2022-09-03 20:13:58 +00:00
renovate[bot]
adc505cef9
Update peter-evans/create-pull-request action to v4 (#1585)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-09-03 13:12:12 -07:00
renovate[bot]
cc703ae3c6
Update actions/cache action to v3 (#1581)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-09-03 13:11:08 -07:00
Jrnl Bot
7b2e2de3df Update changelog [ci skip] 2022-09-03 20:04:21 +00:00
renovate[bot]
06a5dab129
Update actions/setup-python action to v4 (#1583)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-09-03 13:02:37 -07:00
Jrnl Bot
4d4f328527 Update changelog [ci skip] 2022-09-03 19:51:36 +00:00
Jonathan Wren
49fc1e4e40
Update to use renamed flag for brew bump-formula-pr 2022-09-03 12:49:43 -07:00
Paul Jimenez
b2f53d48f7
Add hint for how to get vi to go to end-of-file (#1563) 2022-09-03 12:48:37 -07:00
Jrnl Bot
75008dcb1a Update changelog [ci skip] 2022-09-03 19:23:33 +00:00
renovate[bot]
37af7b8db6
Replace Dependabot with Renovate (#1575)
* Add renovate.json

* move renovate config file into .github dir

* update config to match dependabot

* remove old dependabot config

* update prhourlylimit setting for renovate

* fix typo

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
2022-09-03 12:21:52 -07:00
Jrnl Bot
8a7225a249 Update changelog [ci skip] 2022-09-03 19:09:06 +00:00
140 changed files with 5173 additions and 2542 deletions

View file

@ -12,7 +12,7 @@ Here are some key points to include in your description:
### Checklist ### Checklist
- [ ] I have read the [contributing doc](https://github.com/jrnl-org/jrnl/blob/develop/CONTRIBUTING.md). - [ ] I have read the [contributing doc](https://github.com/jrnl-org/jrnl/blob/develop/docs/contributing.md).
- [ ] I have included a link to the relevant issue number. - [ ] I have included a link to the relevant issue number.
- [ ] I have checked to ensure there aren't other open [pull requests](../pulls) - [ ] I have checked to ensure there aren't other open [pull requests](../pulls)
for the same issue. for the same issue.

View file

@ -11,16 +11,17 @@ runs:
shell: bash shell: bash
- name: Set up Python ${{ matrix.python-version }} - name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2 uses: actions/setup-python@v5
with: with:
python-version: ${{ matrix.python-version }} python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Capture full Python version in env - name: Capture full Python version in env
run: echo "PYTHON_FULL_VERSION=$(python --version)" >> $GITHUB_ENV run: echo "PYTHON_FULL_VERSION=$(python --version)" >> $GITHUB_ENV
shell: bash shell: bash
- name: poetry cache # Change CACHE_STRING secret to bust the cache - name: poetry cache # Change CACHE_STRING secret to bust the cache
uses: actions/cache@v2 uses: actions/cache@v4
with: with:
path: .venv path: .venv
key: ${{ runner.os }}-${{ hashFiles('poetry.lock') }}-${{ env.PYTHON_FULL_VERSION }}-${{ inputs.cache-string }} key: ${{ runner.os }}-${{ hashFiles('poetry.lock') }}-${{ env.PYTHON_FULL_VERSION }}-${{ inputs.cache-string }}
@ -33,7 +34,7 @@ runs:
echo '::endgroup::' echo '::endgroup::'
echo '::group::Other dependencies' echo '::group::Other dependencies'
poetry install --remove-untracked poetry sync
echo '::endgroup::' echo '::endgroup::'
echo 'DEPS_INSTALLED=true' >> $GITHUB_ENV echo 'DEPS_INSTALLED=true' >> $GITHUB_ENV

View file

@ -1,12 +0,0 @@
version: 2
updates:
- package-ecosystem: pip
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
reviewers:
- wren
- micahellison
labels:
- packaging

14
.github/renovate.json vendored Normal file
View file

@ -0,0 +1,14 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base"
],
"schedule": [ "at any time" ],
"prConcurrentLimit": 10,
"prHourlyLimit": 10,
"reviewers": [
"wren",
"micahellison"
],
"labels": [ "packaging" ]
}

View file

@ -1,4 +1,4 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
name: Changelog name: Changelog
@ -21,7 +21,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v4
with: with:
token: ${{ secrets.JRNL_BOT_TOKEN }} token: ${{ secrets.JRNL_BOT_TOKEN }}
@ -59,7 +59,7 @@ jobs:
if [[ "$(git rev-parse "origin/$BRANCH")" != "$GITHUB_SHA" ]]; then if [[ "$(git rev-parse "origin/$BRANCH")" != "$GITHUB_SHA" ]]; then
# Normal build on a branch (no tag) # Normal build on a branch (no tag)
echo "::debug::BRANCH: $BRANCH $(git rev-parse origin/$BRANCH)" echo "::debug::BRANCH: $BRANCH $(git rev-parse "origin/$BRANCH")"
echo "::debug::GITHUB_SHA: $GITHUB_SHA" echo "::debug::GITHUB_SHA: $GITHUB_SHA"
echo "::error::$BRANCH has been updated since build started. Aborting changelog." echo "::error::$BRANCH has been updated since build started. Aborting changelog."
exit 1 exit 1
@ -152,6 +152,14 @@ jobs:
git commit -m "Update changelog [ci skip]" git commit -m "Update changelog [ci skip]"
git push origin "$BRANCH" git push origin "$BRANCH"
- name: Update tag to include changelog
if: startsWith(env.GITHUB_REF, 'refs/tags/')
run: |
# This is a tag build (releases and prereleases)
# update the tag to include the changelog
git tag -fam "$GITHUB_REF_NAME" "$GITHUB_REF_NAME"
git push --tags --force
- name: Merge to Release branch - name: Merge to Release branch
if: env.FULL_RELEASE == 'true' if: env.FULL_RELEASE == 'true'
run: | run: |

View file

@ -1,4 +1,4 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
name: Docs name: Docs
@ -12,6 +12,8 @@ on:
- 'mkdocs.yml' - 'mkdocs.yml'
- 'readthedocs.yml' - 'readthedocs.yml'
- '.github/workflows/docs.yaml' - '.github/workflows/docs.yaml'
- 'tasks.py'
- 'pyproject.toml'
pull_request: pull_request:
branches: [ develop ] branches: [ develop ]
paths: paths:
@ -20,6 +22,8 @@ on:
- 'mkdocs.yml' - 'mkdocs.yml'
- 'readthedocs.yml' - 'readthedocs.yml'
- '.github/workflows/docs.yaml' - '.github/workflows/docs.yaml'
- 'tasks.py'
- 'pyproject.toml'
jobs: jobs:
accessibility: accessibility:
@ -28,14 +32,14 @@ jobs:
strategy: strategy:
fail-fast: true fail-fast: true
matrix: matrix:
python-version: [ 3.9 ] python-version: [ '3.11' ]
os: [ ubuntu-latest ] os: [ ubuntu-latest ]
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v4
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v2 uses: actions/setup-python@v5
with: with:
python-version: ${{ matrix.python-version }} python-version: ${{ matrix.python-version }}
@ -46,13 +50,13 @@ jobs:
run: echo "PYTHON_FULL_VERSION=$(python --version)" >> "$GITHUB_ENV" run: echo "PYTHON_FULL_VERSION=$(python --version)" >> "$GITHUB_ENV"
- name: poetry cache - name: poetry cache
uses: actions/cache@v2 uses: actions/cache@v4
with: with:
path: .venv path: .venv
key: ${{ runner.os }}-${{ hashFiles('poetry.lock') }}-${{ env.PYTHON_FULL_VERSION }}-${{ secrets.CACHE_STRING }} key: ${{ runner.os }}-${{ hashFiles('poetry.lock') }}-${{ env.PYTHON_FULL_VERSION }}-${{ secrets.CACHE_STRING }}
- name: npm cache - name: npm cache
uses: actions/cache@v2 uses: actions/cache@v4
with: with:
path: node_modules path: node_modules
key: ${{ runner.os }}-pa11y-v3 key: ${{ runner.os }}-pa11y-v3
@ -61,7 +65,7 @@ jobs:
run: | run: |
pip install poetry pip install poetry
poetry config --local virtualenvs.in-project true poetry config --local virtualenvs.in-project true
poetry install --no-root --remove-untracked poetry sync --no-root
npm install npm install
echo "node_modules/.bin" >> "$GITHUB_PATH" echo "node_modules/.bin" >> "$GITHUB_PATH"

View file

@ -1,4 +1,4 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
name: Release name: Release
@ -19,11 +19,6 @@ on:
type: boolean type: boolean
required: true required: true
default: true default: true
include_brew:
description: 'Publish to Homebrew?'
type: boolean
required: true
default: true
jobs: jobs:
validate: validate:
@ -66,12 +61,12 @@ jobs:
echo "JRNL_VERSION=$JRNL_VERSION" >> "$GITHUB_ENV" echo "JRNL_VERSION=$JRNL_VERSION" >> "$GITHUB_ENV"
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v2 uses: actions/setup-python@v5
with: with:
python-version: 3.9 python-version: '3.13'
- name: Checkout repo - name: Checkout repo
uses: actions/checkout@v2 uses: actions/checkout@v4
with: with:
token: ${{ secrets.JRNL_BOT_TOKEN }} token: ${{ secrets.JRNL_BOT_TOKEN }}
@ -111,112 +106,4 @@ jobs:
id: pypi-version-getter id: pypi-version-getter
run: | run: |
pypi_version="$(find dist/jrnl-*.tar.gz | sed -r 's!dist/jrnl-(.*)\.tar\.gz!\1!')" pypi_version="$(find dist/jrnl-*.tar.gz | sed -r 's!dist/jrnl-(.*)\.tar\.gz!\1!')"
echo "::set-output name=pypi_version::$pypi_version" echo "pypi_version=$pypi_version" >> "$GITHUB_OUTPUT"
release_homebrew:
if: ${{ github.event.inputs.include_brew == 'true' }}
needs: release_pypi
name: "Release to Homebrew"
runs-on: macos-latest
env:
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
HOME_REPO: ${{ secrets.HOME_REPO }}
steps:
- name: Get version
run: |
JRNL_VERSION="${{ github.event.inputs.version }}"
PYPI_VERSION="${{ needs.release_pypi.outputs.pypi_version }}"
echo "::debug::jrnl version: $JRNL_VERSION"
echo "::debug::pypi version: $PYPI_VERSION"
echo "JRNL_VERSION=$JRNL_VERSION" >> "$GITHUB_ENV"
echo "PYPI_VERSION=$PYPI_VERSION" >> "$GITHUB_ENV"
- name: Set env variables
env:
REPO_OWNER: ${{ github.repository_owner }}
run: |
if [[ $JRNL_VERSION =~ (alpha|beta) ]]; then
echo '::debug::Prerelease (not a full release)'
{
echo "RELEASE_TYPE=pre"
echo "FORMULA_REPO=${REPO_OWNER}/homebrew-prerelease"
echo "BOT_REPO=jrnl-bot/homebrew-prerelease"
echo "FORMULA_NAME=jrnl-beta"
} >> "$GITHUB_ENV"
else
echo '::debug::Full release (not a prerelease)'
if [[ "${{ github.repository }}" == "${HOME_REPO}" ]]; then
REPO_OWNER="homebrew"
fi
{
echo "RELEASE_TYPE=full"
echo "FORMULA_REPO=${REPO_OWNER}/homebrew-core"
echo "BOT_REPO=jrnl-bot/homebrew-core"
echo "FORMULA_NAME=jrnl"
} >> "$GITHUB_ENV"
fi
- name: Tap formula
run: |
brew tap "${FORMULA_REPO}"
echo '::debug::Set tap directory'
echo "BREW_TAP_DIRECTORY=$(brew --repo "${FORMULA_REPO}")" >> "$GITHUB_ENV"
- name: Install dependencies
run: brew install pipgrip
- name: Query PyPI API
uses: nick-invision/retry@v2
with:
timeout_seconds: 10
max_attempts: 30
retry_wait_seconds: 10
command: |
curl -Ls https://pypi.org/pypi/jrnl/json > api_response.json
# if query doesn't have our version yet, give it some time before trying again
if [[ "null" == "$(jq ".releases[\"${PYPI_VERSION}\"][1].url" -r api_response.json)" ]]; then
echo "::debug::PYPI_VERSION: $PYPI_VERSION"
echo "::debug::JQ VALUE: $(jq ".releases[\"${PYPI_VERSION}\"][1].url" -r api_response.json)"
echo "::group::cat api_response.json"
cat api_response.json
echo "::endgroup::"
exit 1
fi
- name: Update Homebrew Formula
uses: nick-invision/retry@v2
with:
timeout_minutes: 8
max_attempts: 6
retry_wait_seconds: 30
command: >
brew bump-formula-pr "${FORMULA_NAME}"
--url $(jq ".releases[\"${PYPI_VERSION}\"][1].url" -r api_response.json)
--sha256 $(jq ".releases[\"${PYPI_VERSION}\"][1].digests.sha256" -r api_response.json)
--no-audit
--write
--force
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
path: ${{ env.BREW_TAP_DIRECTORY }}
token: ${{ secrets.JRNL_BOT_TOKEN }}
push-to-fork: ${{ env.BOT_REPO }}
committer: ${{ secrets.JRNL_BOT_NAME }} <${{ secrets.JRNL_BOT_EMAIL }}>
author: ${{ secrets.JRNL_BOT_NAME }} <${{ secrets.JRNL_BOT_EMAIL }}>
title: jrnl ${{ env.JRNL_VERSION }}
body: Created with `brew bump-formula-pr`
branch: jrnl-${{ env.JRNL_VERSION }}--
branch-suffix: random
commit-message: |
jrnl ${{ env.JRNL_VERSION }}
Update jrnl to ${{ env.JRNL_VERSION }}
${{ secrets.RELEASE_COAUTHORS }}

View file

@ -1,4 +1,4 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
name: Testing Pipeline Files name: Testing Pipeline Files
@ -14,6 +14,8 @@ on:
paths: paths:
- '.github/workflows/**' - '.github/workflows/**'
- '.github/actions/**' - '.github/actions/**'
schedule:
- cron: '0 0 * * SAT'
jobs: jobs:
test: test:
@ -26,7 +28,7 @@ jobs:
os: [ ubuntu-latest ] os: [ ubuntu-latest ]
steps: steps:
- run: git config --global core.autocrlf false - run: git config --global core.autocrlf false
- uses: actions/checkout@v2 - uses: actions/checkout@v4
- name: Check workflow files - name: Check workflow files
uses: docker://rhysd/actionlint:latest uses: docker://rhysd/actionlint:latest
with: with:

View file

@ -1,4 +1,4 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
name: Testing name: Testing
@ -13,6 +13,7 @@ on:
- 'poetry.lock' - 'poetry.lock'
- 'pyproject.toml' - 'pyproject.toml'
- '.github/workflows/testing_prs.yaml' - '.github/workflows/testing_prs.yaml'
- 'tasks.py'
pull_request: pull_request:
branches: [ develop ] branches: [ develop ]
paths: paths:
@ -22,6 +23,7 @@ on:
- 'poetry.lock' - 'poetry.lock'
- 'pyproject.toml' - 'pyproject.toml'
- '.github/workflows/testing_prs.yaml' - '.github/workflows/testing_prs.yaml'
- 'tasks.py'
defaults: defaults:
run: run:
@ -35,11 +37,11 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
python-version: [ 3.9, '3.10', 3.11-dev ] python-version: [ '3.10', '3.11', '3.12', '3.13' ]
os: [ ubuntu-latest, macos-latest, windows-latest ] os: [ ubuntu-latest, macos-latest, windows-latest ]
steps: steps:
- run: git config --global core.autocrlf false - run: git config --global core.autocrlf false
- uses: actions/checkout@v2 - uses: actions/checkout@v4
- name: Run tests - name: Run tests
uses: ./.github/actions/run_tests uses: ./.github/actions/run_tests
with: with:

View file

@ -1,4 +1,4 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
name: Testing name: Testing
@ -17,11 +17,11 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
python-version: [ 3.9, '3.10', 3.11-dev ] python-version: [ '3.10', '3.11', '3.12', '3.13' ]
os: [ ubuntu-latest, macos-latest, windows-latest ] os: [ ubuntu-latest, macos-latest, windows-latest ]
steps: steps:
- run: git config --global core.autocrlf false - run: git config --global core.autocrlf false
- uses: actions/checkout@v2 - uses: actions/checkout@v4
- name: Run tests - name: Run tests
uses: ./.github/actions/run_tests uses: ./.github/actions/run_tests
with: with:

7
.gitignore vendored
View file

@ -17,10 +17,13 @@ sdist/
.tox/ .tox/
var/ var/
node_modules/ node_modules/
__pycache__/
.pytest_cache/
.flakeheaven_cache/
# Versioning # Versioning
.python-version .python-version
.tool-version .tool-versions
# Installer logs # Installer logs
.DS_Store .DS_Store
@ -37,7 +40,7 @@ exp/
objects.inv objects.inv
searchindex.js searchindex.js
# virtaulenv # virtualenv
.venv*/ .venv*/
env/ env/
env*/ env*/

View file

@ -5,6 +5,13 @@
# Required # Required
version: 2 version: 2
# Set the OS
build:
os: ubuntu-22.04
tools:
python: "3"
# Build documentation in the docs/ directory # Build documentation in the docs/ directory
mkdocs: mkdocs:
configuration: mkdocs.yml configuration: mkdocs.yml

View file

@ -2,24 +2,280 @@
## [Unreleased](https://github.com/jrnl-org/jrnl/) ## [Unreleased](https://github.com/jrnl-org/jrnl/)
[Full Changelog](https://github.com/jrnl-org/jrnl/compare/v3.2-beta...HEAD) [Full Changelog](https://github.com/jrnl-org/jrnl/compare/v4.2.1...HEAD)
**Fixed bugs:**
- poetry warning - "poetry.dev-dependencies" section is deprecated [\#1975](https://github.com/jrnl-org/jrnl/issues/1975)
- Homebrew autobump error on jrnl release [\#1961](https://github.com/jrnl-org/jrnl/issues/1961)
**Build:**
- Remove release step to publish to Homebrew [\#1994](https://github.com/jrnl-org/jrnl/pull/1994) ([micahellison](https://github.com/micahellison))
**Packaging:**
- Update dependency rich to v14 [\#1989](https://github.com/jrnl-org/jrnl/pull/1989) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency python to 3.13 [\#1988](https://github.com/jrnl-org/jrnl/pull/1988) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency tox to v4.25.0 [\#1986](https://github.com/jrnl-org/jrnl/pull/1986) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency tzlocal to v5.3.1 [\#1984](https://github.com/jrnl-org/jrnl/pull/1984) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency jinja2 to v3.1.6 [\#1983](https://github.com/jrnl-org/jrnl/pull/1983) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency poethepoet to v0.33.1 [\#1982](https://github.com/jrnl-org/jrnl/pull/1982) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency pytest to v8.3.5 [\#1981](https://github.com/jrnl-org/jrnl/pull/1981) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency cryptography to v44.0.2 [\#1980](https://github.com/jrnl-org/jrnl/pull/1980) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency ruff to v0.11.3 [\#1978](https://github.com/jrnl-org/jrnl/pull/1978) ([renovate[bot]](https://github.com/apps/renovate))
## [v4.2.1](https://pypi.org/project/jrnl/v4.2.1/) (2025-02-25)
[Full Changelog](https://github.com/jrnl-org/jrnl/compare/v4.2...v4.2.1)
**Documentation:**
- Typing animation in landing page is broken [\#1969](https://github.com/jrnl-org/jrnl/issues/1969)
**Packaging:**
- Update dependency pytest to \>=8.1.1 [\#1974](https://github.com/jrnl-org/jrnl/pull/1974) ([wren](https://github.com/wren))
- Update dependency black to v25 [\#1973](https://github.com/jrnl-org/jrnl/pull/1973) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency tzlocal to v5.3 [\#1972](https://github.com/jrnl-org/jrnl/pull/1972) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency ruamel.yaml to v0.18.10 [\#1967](https://github.com/jrnl-org/jrnl/pull/1967) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency jinja2 to v3.1.5 [\#1966](https://github.com/jrnl-org/jrnl/pull/1966) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency cryptography to v44 [\#1962](https://github.com/jrnl-org/jrnl/pull/1962) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency pytest-bdd to v8.1.0 [\#1952](https://github.com/jrnl-org/jrnl/pull/1952) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency poethepoet to v0.32.2 [\#1951](https://github.com/jrnl-org/jrnl/pull/1951) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency keyring to v25.6.0 [\#1948](https://github.com/jrnl-org/jrnl/pull/1948) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency ruff to v0.9.7 [\#1947](https://github.com/jrnl-org/jrnl/pull/1947) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency rich to v13.9.4 [\#1946](https://github.com/jrnl-org/jrnl/pull/1946) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency tox to v4.24.1 [\#1945](https://github.com/jrnl-org/jrnl/pull/1945) ([renovate[bot]](https://github.com/apps/renovate))
## [v4.2](https://pypi.org/project/jrnl/v4.2/) (2024-11-17)
[Full Changelog](https://github.com/jrnl-org/jrnl/compare/v4.2-beta...v4.2)
**Implemented enhancements:**
- Add Python 3.13 support [\#1893](https://github.com/jrnl-org/jrnl/issues/1893)
- Add calendar heatmap display format [\#1759](https://github.com/jrnl-org/jrnl/pull/1759) ([alichtman](https://github.com/alichtman))
**Fixed bugs:**
- -contains doesn't accept multiple search terms, doesn't work with -and [\#1877](https://github.com/jrnl-org/jrnl/issues/1877)
- Tests failing on develop branch starting with pytest-bdd 7.1.2 [\#1875](https://github.com/jrnl-org/jrnl/issues/1875)
- Ignore color when used in a pipeline [\#1839](https://github.com/jrnl-org/jrnl/issues/1839)
- Fix -contains to allow multiple terms with "OR" logic unless -and is added [\#1890](https://github.com/jrnl-org/jrnl/pull/1890) ([eigenric](https://github.com/eigenric))
**Documentation:**
- Recommend pipx as default installation method [\#1888](https://github.com/jrnl-org/jrnl/issues/1888)
- Remove documentation recommendation to install pipx through brew or pip [\#1886](https://github.com/jrnl-org/jrnl/issues/1886)
- Document security risks of using a computer that someone else has admin access to [\#1793](https://github.com/jrnl-org/jrnl/issues/1793)
- Recommend pipx as easiest installation method for all OSes and remove warning about apt [\#1889](https://github.com/jrnl-org/jrnl/pull/1889) ([micahellison](https://github.com/micahellison))
- Docs accessibility checker failure - contrast ratio [\#1934](https://github.com/jrnl-org/jrnl/issues/1934)
- Docs accessibility test runner failing [\#1932](https://github.com/jrnl-org/jrnl/issues/1932)
**Packaging:**
- Update actions/cache action to v4 [\#1847](https://github.com/jrnl-org/jrnl/pull/1847) ([renovate[bot]](https://github.com/apps/renovate))
- Update actions/setup-python action to v5 [\#1848](https://github.com/jrnl-org/jrnl/pull/1848) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency black to v24.8.0 [\#1923](https://github.com/jrnl-org/jrnl/pull/1923) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency cryptography to v43.0.3 [\#1942](https://github.com/jrnl-org/jrnl/pull/1942) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency jinja2 to v3.1.4 [\#1892](https://github.com/jrnl-org/jrnl/pull/1892) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency keyring to v25.4.1 [\#1924](https://github.com/jrnl-org/jrnl/pull/1924) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency mkdocs to v1.6.1 [\#1895](https://github.com/jrnl-org/jrnl/pull/1895) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency pa11y-ci to v3.1.0 [\#1831](https://github.com/jrnl-org/jrnl/pull/1831) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency parse-type to v0.6.4 [\#1936](https://github.com/jrnl-org/jrnl/pull/1936) ([renovate[bot]](https://github.com/apps/renovate))
- Update peter-evans/create-pull-request action to v7 [\#1929](https://github.com/jrnl-org/jrnl/pull/1929) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency poethepoet to v0.29.0 [\#1925](https://github.com/jrnl-org/jrnl/pull/1925) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency pytest to v7.4.4 [\#1845](https://github.com/jrnl-org/jrnl/pull/1845) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency pytest-bdd to v7.3.0 [\#1896](https://github.com/jrnl-org/jrnl/pull/1896) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency pytest-xdist to v3.6.1 [\#1897](https://github.com/jrnl-org/jrnl/pull/1897) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency python-dateutil to v2.9.0 [\#1898](https://github.com/jrnl-org/jrnl/pull/1898) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency requests to v2.32.3 [\#1899](https://github.com/jrnl-org/jrnl/pull/1899) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency rich to v13.9.2 [\#1937](https://github.com/jrnl-org/jrnl/pull/1937) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency ruamel.yaml to v0.18.6 [\#1855](https://github.com/jrnl-org/jrnl/pull/1855) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency ruff to v0.7.0 [\#1938](https://github.com/jrnl-org/jrnl/pull/1938) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency tox to v4.23.0 [\#1935](https://github.com/jrnl-org/jrnl/pull/1935) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency typed.js to v2.1.0 [\#1861](https://github.com/jrnl-org/jrnl/pull/1861) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency xmltodict to v0.14.2 [\#1940](https://github.com/jrnl-org/jrnl/pull/1940) ([renovate[bot]](https://github.com/apps/renovate))
- Update nick-invision/retry action to v3 [\#1851](https://github.com/jrnl-org/jrnl/pull/1851) ([renovate[bot]](https://github.com/apps/renovate))
- Update peter-evans/create-pull-request action to v6 [\#1852](https://github.com/jrnl-org/jrnl/pull/1852) ([renovate[bot]](https://github.com/apps/renovate))
## [v4.1](https://pypi.org/project/jrnl/v4.1/) (2023-11-04)
[Full Changelog](https://github.com/jrnl-org/jrnl/compare/v4.1-beta2...v4.1)
**Build:**
- Add Python 3.12 support [\#1761](https://github.com/jrnl-org/jrnl/pull/1761) ([micahellison](https://github.com/micahellison))
- Set new required build fields in the ReadTheDocs config file [\#1803](https://github.com/jrnl-org/jrnl/pull/1803) ([micahellison](https://github.com/micahellison))
- Replace flake8 and isort with ruff linter and add `black --check` to linting step [\#1763](https://github.com/jrnl-org/jrnl/pull/1763) ([micahellison](https://github.com/micahellison))
**Documentation:**
- Add note about messages going to `stderr` and the implication for piping [\#1768](https://github.com/jrnl-org/jrnl/pull/1768) ([micahellison](https://github.com/micahellison))
**Packaging:**
- Drop/replace ansiwrap dependency [\#1191](https://github.com/jrnl-org/jrnl/issues/1191)
- Use rich instead of ansiwrap to wrap text [\#1693](https://github.com/jrnl-org/jrnl/pull/1693) ([micahellison](https://github.com/micahellison))
- Update actions/checkout action to v4 [\#1788](https://github.com/jrnl-org/jrnl/pull/1788) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency black to v23.10.1 [\#1811](https://github.com/jrnl-org/jrnl/pull/1811) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency cryptography to v41.0.5 [\#1815](https://github.com/jrnl-org/jrnl/pull/1815) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency keyring to v24.2.0 [\#1760](https://github.com/jrnl-org/jrnl/pull/1760) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency mkdocs to v1.5.3 [\#1795](https://github.com/jrnl-org/jrnl/pull/1795) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency parse-type to v0.6.2 [\#1762](https://github.com/jrnl-org/jrnl/pull/1762) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency poethepoet to v0.24.1 [\#1806](https://github.com/jrnl-org/jrnl/pull/1806) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency pytest to v7.4.3 [\#1816](https://github.com/jrnl-org/jrnl/pull/1816) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency pytest-bdd to v7 [\#1807](https://github.com/jrnl-org/jrnl/pull/1807) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency rich to v13.6.0 [\#1794](https://github.com/jrnl-org/jrnl/pull/1794) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency ruamel.yaml to v0.18.3 [\#1813](https://github.com/jrnl-org/jrnl/pull/1813) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency ruff to v0.1.3 [\#1810](https://github.com/jrnl-org/jrnl/pull/1810) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency tox to v4.11.3 [\#1782](https://github.com/jrnl-org/jrnl/pull/1782) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency tzlocal to v5.2 [\#1814](https://github.com/jrnl-org/jrnl/pull/1814) ([renovate[bot]](https://github.com/apps/renovate))
**Special thanks:**
- jrnl uses UTC instead of local time for entries in WSL/Ubuntu [\#1607](https://github.com/jrnl-org/jrnl/issues/1607) investigated and reported upstream by [giuseppedandrea](https://github.com/giuseppedandrea)
## [v4.0.1](https://pypi.org/project/jrnl/v4.0.1/) (2023-06-20)
[Full Changelog](https://github.com/jrnl-org/jrnl/compare/v4.0.1-beta...v4.0.1)
**Fixed bugs:**
- jrnl crashes when running `jrnl --list --format json` and `jrnl --list --format yaml` [\#1737](https://github.com/jrnl-org/jrnl/issues/1737)
- Refactor --template code [\#1711](https://github.com/jrnl-org/jrnl/pull/1711) ([micahellison](https://github.com/micahellison))
**Build:**
- Fix linting issue in CI pipeline [\#1743](https://github.com/jrnl-org/jrnl/pull/1743) ([wren](https://github.com/wren))
**Packaging:**
- Update dependency ruamel.yaml to v0.17.28 [\#1749](https://github.com/jrnl-org/jrnl/pull/1749) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency requests to v2.31.0 [\#1748](https://github.com/jrnl-org/jrnl/pull/1748) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency ruamel.yaml to v0.17.26 [\#1746](https://github.com/jrnl-org/jrnl/pull/1746) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency tzlocal to v5 [\#1741](https://github.com/jrnl-org/jrnl/pull/1741) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency pytest-xdist to v3.3.1 [\#1740](https://github.com/jrnl-org/jrnl/pull/1740) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency poethepoet to v0.20.0 [\#1735](https://github.com/jrnl-org/jrnl/pull/1735) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency mkdocs to v1.4.3 [\#1733](https://github.com/jrnl-org/jrnl/pull/1733) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency rich to v13.3.5 [\#1729](https://github.com/jrnl-org/jrnl/pull/1729) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency requests to v2.30.0 [\#1728](https://github.com/jrnl-org/jrnl/pull/1728) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency tox to v4.5.1 [\#1727](https://github.com/jrnl-org/jrnl/pull/1727) ([renovate[bot]](https://github.com/apps/renovate))
- Update peter-evans/create-pull-request action to v5 [\#1719](https://github.com/jrnl-org/jrnl/pull/1719) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency flake8-simplify to v0.20.0 [\#1716](https://github.com/jrnl-org/jrnl/pull/1716) ([renovate[bot]](https://github.com/apps/renovate))
## [v4.0](https://pypi.org/project/jrnl/v4.0/) (2023-05-20)
[Full Changelog](https://github.com/jrnl-org/jrnl/compare/v4.0-beta3...v4.0)
🚨 **BREAKING CHANGES** 🚨
**Deprecated:**
- Drop Python 3.9 and use Python 3.11 official release [\#1611](https://github.com/jrnl-org/jrnl/pull/1611) ([micahellison](https://github.com/micahellison))
**Implemented enhancements:**
- Add message with config location and docs location when installation is complete [\#1695](https://github.com/jrnl-org/jrnl/pull/1695) ([micahellison](https://github.com/micahellison))
- Prompt to include colors in config when first running jrnl [\#1687](https://github.com/jrnl-org/jrnl/pull/1687) ([micahellison](https://github.com/micahellison))
- Add ability to use template with `--template` [\#1667](https://github.com/jrnl-org/jrnl/pull/1667) ([alichtman](https://github.com/alichtman))
- Search for entries with no tags or stars with `-not -starred` and `-not -tagged` [\#1663](https://github.com/jrnl-org/jrnl/pull/1663) ([cjcon90](https://github.com/cjcon90))
- Refactor flow for easier access to some files \(avoid things like `jrnl.Journal.Journal` and `jrnl.jrnl` co-existing\) [\#1662](https://github.com/jrnl-org/jrnl/pull/1662) ([wren](https://github.com/wren))
- Add more type hints [\#1642](https://github.com/jrnl-org/jrnl/pull/1642) ([outa](https://github.com/outa))
- Add `rich` handler to debug logging [\#1627](https://github.com/jrnl-org/jrnl/pull/1627) ([wren](https://github.com/wren))
- Rework Encryption to enable future support of other encryption methods [\#1602](https://github.com/jrnl-org/jrnl/pull/1602) ([wren](https://github.com/wren))
**Fixed bugs:**
- Only read text files that look like entries when opening folder journal [\#1697](https://github.com/jrnl-org/jrnl/pull/1697) ([micahellison](https://github.com/micahellison))
- 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))
- Allow combinations of `--change-time`, `--delete`, and `--edit` while correctly counting the number of entries affected [\#1669](https://github.com/jrnl-org/jrnl/pull/1669) ([wren](https://github.com/wren))
- 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))
- Update version key in config file after version changes [\#1646](https://github.com/jrnl-org/jrnl/pull/1646) ([jonakeys](https://github.com/jonakeys))
**Build:**
- Update copyright notices for 2023 [\#1660](https://github.com/jrnl-org/jrnl/pull/1660) ([wren](https://github.com/wren))
- Fix bug where changelog is always slightly out of date on release tags [\#1631](https://github.com/jrnl-org/jrnl/pull/1631) ([wren](https://github.com/wren))
- Add `simplify` plugin to linting checks [\#1630](https://github.com/jrnl-org/jrnl/pull/1630) ([wren](https://github.com/wren))
- Add type hints [\#1614](https://github.com/jrnl-org/jrnl/pull/1614) ([outa](https://github.com/outa))
**Documentation:**
- Update contributing.md links in documentation [\#1726](https://github.com/jrnl-org/jrnl/pull/1726) ([ahosking](https://github.com/ahosking))
- Fix various typos [\#1718](https://github.com/jrnl-org/jrnl/pull/1718) ([hezhizhen](https://github.com/hezhizhen))
- Update documentation front page text [\#1698](https://github.com/jrnl-org/jrnl/pull/1698) ([micahellison](https://github.com/micahellison))
- 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))
- Document `-tagged`, `-not -tagged`, and `-not -starred` [\#1684](https://github.com/jrnl-org/jrnl/pull/1684) ([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))
- 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))
**Packaging:**
- Lock ruamel.yaml version to v0.17.21 until bug is fixed [\#1738](https://github.com/jrnl-org/jrnl/pull/1738) ([wren](https://github.com/wren))
- Update dependency black to v23.3.0 [\#1715](https://github.com/jrnl-org/jrnl/pull/1715) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency cryptography to v40.0.2 [\#1723](https://github.com/jrnl-org/jrnl/pull/1723) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency flake8-type-checking to v2.4.0 [\#1714](https://github.com/jrnl-org/jrnl/pull/1714) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency flakeheaven to v3.3.0 [\#1722](https://github.com/jrnl-org/jrnl/pull/1722) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency ipdb to v0.13.13 [\#1703](https://github.com/jrnl-org/jrnl/pull/1703) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency poethepoet to v0.19.0 [\#1709](https://github.com/jrnl-org/jrnl/pull/1709) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency pytest to v7.3.1 [\#1720](https://github.com/jrnl-org/jrnl/pull/1720) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency pytest-xdist to v3.2.1 [\#1705](https://github.com/jrnl-org/jrnl/pull/1705) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency rich to v13.3.4 [\#1713](https://github.com/jrnl-org/jrnl/pull/1713) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency tox to v4.4.7 [\#1707](https://github.com/jrnl-org/jrnl/pull/1707) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency tzlocal to v4.3 [\#1708](https://github.com/jrnl-org/jrnl/pull/1708) ([renovate[bot]](https://github.com/apps/renovate))
## [v3.3](https://pypi.org/project/jrnl/v3.3/) (2022-10-29)
[Full Changelog](https://github.com/jrnl-org/jrnl/compare/v3.3-beta2...v3.3)
**Implemented enhancements:**
- Change default config to use journal key [\#1594](https://github.com/jrnl-org/jrnl/pull/1594) ([micahellison](https://github.com/micahellison))
- Add machine readable --list output [\#1592](https://github.com/jrnl-org/jrnl/pull/1592) ([apainintheneck](https://github.com/apainintheneck))
**Fixed bugs:**
- Fix bug for new `--list --format` options when no default journal is specified [\#1621](https://github.com/jrnl-org/jrnl/pull/1621) ([wren](https://github.com/wren))
- Don't create empty file when attempting a YAML export to a non-existing folder [\#1600](https://github.com/jrnl-org/jrnl/pull/1600) ([outa](https://github.com/outa))
**Build:**
- Update `.gitignore` [\#1604](https://github.com/jrnl-org/jrnl/pull/1604) ([wren](https://github.com/wren))
- Fix Docs Accessibility Testing [\#1588](https://github.com/jrnl-org/jrnl/pull/1588) ([wren](https://github.com/wren))
- Update to use renamed flag for `brew bump-formula-pr` [\#1587](https://github.com/jrnl-org/jrnl/pull/1587) ([wren](https://github.com/wren))
- Update peter-evans/create-pull-request action to v4 [\#1585](https://github.com/jrnl-org/jrnl/pull/1585) ([renovate[bot]](https://github.com/apps/renovate))
- Update actions/setup-python action to v4 [\#1583](https://github.com/jrnl-org/jrnl/pull/1583) ([renovate[bot]](https://github.com/apps/renovate))
- Update actions/checkout action to v3 [\#1582](https://github.com/jrnl-org/jrnl/pull/1582) ([renovate[bot]](https://github.com/apps/renovate))
- Update actions/cache action to v3 [\#1581](https://github.com/jrnl-org/jrnl/pull/1581) ([renovate[bot]](https://github.com/apps/renovate))
- Replace Dependabot with Renovate [\#1575](https://github.com/jrnl-org/jrnl/pull/1575) ([renovate[bot]](https://github.com/apps/renovate))
**Documentation:**
- Add documentation about how the editor must be a blocking process [\#1456](https://github.com/jrnl-org/jrnl/issues/1456)
- Document that editors must be blocking processes [\#1624](https://github.com/jrnl-org/jrnl/pull/1624) ([micahellison](https://github.com/micahellison))
- Remove wrong option in configuration file reference [\#1618](https://github.com/jrnl-org/jrnl/pull/1618) ([DSiekmeier](https://github.com/DSiekmeier))
- Update YAML export description in docs [\#1591](https://github.com/jrnl-org/jrnl/pull/1591) ([apainintheneck](https://github.com/apainintheneck))
- Update dependency jinja2 to v3.1.2 [\#1579](https://github.com/jrnl-org/jrnl/pull/1579) ([renovate[bot]](https://github.com/apps/renovate))
- Update dependency typed.js to v2.0.12 [\#1578](https://github.com/jrnl-org/jrnl/pull/1578) ([renovate[bot]](https://github.com/apps/renovate))
- Add hint for how to get vi to go to end-of-file [\#1563](https://github.com/jrnl-org/jrnl/pull/1563) ([pjz](https://github.com/pjz))
**Packaging:**
- Pin dependencies [\#1577](https://github.com/jrnl-org/jrnl/pull/1577) ([renovate[bot]](https://github.com/apps/renovate))
## [v3.2](https://pypi.org/project/jrnl/v3.2/) (2022-09-03)
[Full Changelog](https://github.com/jrnl-org/jrnl/compare/v3.2-beta...v3.2)
**Implemented enhancements:** **Implemented enhancements:**
- Update issue & PR templates to use forms [\#1559](https://github.com/jrnl-org/jrnl/issues/1559) - Update issue & PR templates to use forms [\#1559](https://github.com/jrnl-org/jrnl/issues/1559)
**Documentation:**
- Remove note in contributing docs about gh-pages branch that we no longer use [\#1566](https://github.com/jrnl-org/jrnl/pull/1566) ([micahellison](https://github.com/micahellison))
## [v3.2-beta](https://pypi.org/project/jrnl/v3.2-beta/) (2022-08-27)
[Full Changelog](https://github.com/jrnl-org/jrnl/compare/v3.1...v3.2-beta)
**Implemented enhancements:**
- Supress output if action is successful [\#1543](https://github.com/jrnl-org/jrnl/issues/1543)
- Report number of entries found in a search [\#1454](https://github.com/jrnl-org/jrnl/issues/1454)
- Suppress "Entry added" message if using default journal [\#1561](https://github.com/jrnl-org/jrnl/pull/1561) ([micahellison](https://github.com/micahellison)) - Suppress "Entry added" message if using default journal [\#1561](https://github.com/jrnl-org/jrnl/pull/1561) ([micahellison](https://github.com/micahellison))
- Add message showing the number of search results [\#1524](https://github.com/jrnl-org/jrnl/pull/1524) ([apainintheneck](https://github.com/apainintheneck)) - Add message showing the number of search results [\#1524](https://github.com/jrnl-org/jrnl/pull/1524) ([apainintheneck](https://github.com/apainintheneck))
@ -27,6 +283,10 @@
- Quick fix follow up for actionlint [\#1565](https://github.com/jrnl-org/jrnl/pull/1565) ([wren](https://github.com/wren)) - Quick fix follow up for actionlint [\#1565](https://github.com/jrnl-org/jrnl/pull/1565) ([wren](https://github.com/wren))
**Documentation:**
- Remove note in contributing docs about gh-pages branch that we no longer use [\#1566](https://github.com/jrnl-org/jrnl/pull/1566) ([micahellison](https://github.com/micahellison))
## [v3.1](https://pypi.org/project/jrnl/v3.1/) (2022-08-21) ## [v3.1](https://pypi.org/project/jrnl/v3.1/) (2022-08-21)
[Full Changelog](https://github.com/jrnl-org/jrnl/compare/v3.1-beta2...v3.1) [Full Changelog](https://github.com/jrnl-org/jrnl/compare/v3.1-beta2...v3.1)
@ -65,6 +325,12 @@
[Full Changelog](https://github.com/jrnl-org/jrnl/compare/v3.0-beta2...v3.0) [Full Changelog](https://github.com/jrnl-org/jrnl/compare/v3.0-beta2...v3.0)
🚨 **BREAKING CHANGES** 🚨
**Deprecated:**
- Drop support for Python 3.7 and 3.8 [\#1412](https://github.com/jrnl-org/jrnl/pull/1412) ([micahellison](https://github.com/micahellison))
**Implemented enhancements:** **Implemented enhancements:**
- Show name of journal when creating a password/encrypting [\#1478](https://github.com/jrnl-org/jrnl/pull/1478) ([jonakeys](https://github.com/jonakeys)) - Show name of journal when creating a password/encrypting [\#1478](https://github.com/jrnl-org/jrnl/pull/1478) ([jonakeys](https://github.com/jonakeys))
@ -87,10 +353,6 @@
- Display "No entry to save, because no text was received" after empty entry on cmdline [\#1459](https://github.com/jrnl-org/jrnl/pull/1459) ([apainintheneck](https://github.com/apainintheneck)) - Display "No entry to save, because no text was received" after empty entry on cmdline [\#1459](https://github.com/jrnl-org/jrnl/pull/1459) ([apainintheneck](https://github.com/apainintheneck))
- Yaml export errors now don't show stack trace [\#1449](https://github.com/jrnl-org/jrnl/pull/1449) ([apainintheneck](https://github.com/apainintheneck)) - Yaml export errors now don't show stack trace [\#1449](https://github.com/jrnl-org/jrnl/pull/1449) ([apainintheneck](https://github.com/apainintheneck))
**Deprecated:**
- Drop support for Python 3.7 and 3.8 [\#1412](https://github.com/jrnl-org/jrnl/pull/1412) ([micahellison](https://github.com/micahellison))
**Build:** **Build:**
- Pin `pytest-bdd` to \<6.0 to temporarily avoid breaking changes [\#1536](https://github.com/jrnl-org/jrnl/pull/1536) ([wren](https://github.com/wren)) - Pin `pytest-bdd` to \<6.0 to temporarily avoid breaking changes [\#1536](https://github.com/jrnl-org/jrnl/pull/1536) ([wren](https://github.com/wren))

View file

@ -1,5 +1,5 @@
<!-- <!--
Copyright © 2012-2022 jrnl contributors Copyright © 2012-2023 jrnl contributors
License: https://www.gnu.org/licenses/gpl-3.0.html License: https://www.gnu.org/licenses/gpl-3.0.html
--> -->

View file

@ -1,5 +1,5 @@
<!-- <!--
Copyright © 2012-2022 jrnl contributors Copyright © 2012-2023 jrnl contributors
License: https://www.gnu.org/licenses/gpl-3.0.html License: https://www.gnu.org/licenses/gpl-3.0.html
--> -->
@ -19,7 +19,7 @@ jrnl
==== ====
_To get help, [submit an issue](https://github.com/jrnl-org/jrnl/issues/new/choose) on _To get help, [submit an issue](https://github.com/jrnl-org/jrnl/issues/new/choose) on
Github._ GitHub._
`jrnl` is a simple journal application for the command line. `jrnl` is a simple journal application for the command line.
@ -70,7 +70,7 @@ src="https://opencollective.com/jrnl/contributors.svg?width=890&button=false"
/></a> /></a>
If you'd also like to help make `jrnl` better, please see our [contributing If you'd also like to help make `jrnl` better, please see our [contributing
documentation](CONTRIBUTING.md). documentation](docs/contributing.md).
### Financial Backers ### Financial Backers

View file

@ -1,5 +1,5 @@
<!-- <!--
Copyright © 2012-2022 jrnl contributors Copyright © 2012-2023 jrnl contributors
License: https://www.gnu.org/licenses/gpl-3.0.html License: https://www.gnu.org/licenses/gpl-3.0.html
--> -->
@ -20,8 +20,8 @@ for example:
``` yaml ``` yaml
journals: journals:
default: ~\journal.txt default: ~/journal.txt
work: ~\work.txt work: ~/work.txt
``` ```
The `default` journal gets created the first time you start `jrnl` The `default` journal gets created the first time you start `jrnl`
@ -42,11 +42,11 @@ If your `jrnl.yaml` looks like this:
``` yaml ``` yaml
encrypt: false encrypt: false
journals: journals:
default: ~/journal.txt default: ~/journal.txt
work: work:
journal: ~/work.txt journal: ~/work.txt
encrypt: true encrypt: true
food: ~/my_recipes.txt food: ~/my_recipes.txt
``` ```
Your `default` and your `food` journals won't be encrypted, however your Your `default` and your `food` journals won't be encrypted, however your
@ -59,7 +59,7 @@ that journal.
Consider the following example configuration Consider the following example configuration
```yaml ``` yaml
editor: vi -c startinsert editor: vi -c startinsert
journals: journals:
default: ~/journal.txt default: ~/journal.txt
@ -80,22 +80,22 @@ The `work` journal is encrypted, prints to `json` by default, and is edited usin
You can override a configuration field for the current instance of `jrnl` using `--config-override CONFIG_KEY CONFIG_VALUE` where `CONFIG_KEY` is a valid configuration field, specified in dot notation and `CONFIG_VALUE` is the (valid) desired override value. The dot notation can be used to change config keys within other keys, such as `colors.title` for the `title` key within the `colors` key. You can override a configuration field for the current instance of `jrnl` using `--config-override CONFIG_KEY CONFIG_VALUE` where `CONFIG_KEY` is a valid configuration field, specified in dot notation and `CONFIG_VALUE` is the (valid) desired override value. The dot notation can be used to change config keys within other keys, such as `colors.title` for the `title` key within the `colors` key.
You can specify multiple overrides as multiple calls to `--config-override`. You can specify multiple overrides as multiple calls to `--config-override`.
!!! note !!! note
These overrides allow you to modify ***any*** field of your jrnl configuration. We trust that you know what you are doing. These overrides allow you to modify ***any*** field of your jrnl configuration. We trust that you know what you are doing.
#### Examples: #### Examples:
``` sh ``` sh
#Create an entry using the `stdin` prompt, for rapid logging # Create an entry using the `stdin` prompt, for rapid logging
jrnl --config-override editor "" jrnl --config-override editor ""
#Populate a project's log # Populate a project's log
jrnl --config-override journals.todo "$(git rev-parse --show-toplevel)/todo.txt" todo find my towel jrnl --config-override journals.todo "$(git rev-parse --show-toplevel)/todo.txt" todo find my towel
#Pass multiple overrides # Pass multiple overrides
jrnl --config-override display_format fancy --config-override linewrap 20 \ jrnl --config-override display_format fancy --config-override linewrap 20 \
--config-override colors.title green --config-override colors.title green
``` ```
### Using an alternate config ### Using an alternate config
@ -105,7 +105,7 @@ You can specify an alternate configuration file for the current instance of `jrn
#### Examples: #### Examples:
``` ``` sh
# Use personalised configuration file for personal journal entries # Use personalised configuration file for personal journal entries
jrnl --config-file ~/foo/jrnl/personal-config.yaml jrnl --config-file ~/foo/jrnl/personal-config.yaml
@ -115,12 +115,3 @@ jrnl --config-file ~/foo/jrnl/work-config.yaml
# Use default configuration file (created on first run) # Use default configuration file (created on first run)
jrnl jrnl
``` ```
## Known Issues
### Unicode on Windows
The Windows shell prior to Windows 7 has issues with unicode encoding.
To use non-ascii characters, first tweak Python to recognize the encoding by adding `'cp65001': 'utf_8'`, to `Lib/encoding/aliases.py`. Then, change the codepage with `chcp 1252` before using `jrnl`.
(Related issue: [#486](https://github.com/jrnl-org/jrnl/issues/486))

View file

@ -1,5 +1,5 @@
<!-- <!--
Copyright © 2012-2022 jrnl contributors Copyright © 2012-2023 jrnl contributors
License: https://www.gnu.org/licenses/gpl-3.0.html License: https://www.gnu.org/licenses/gpl-3.0.html
--> -->

View file

@ -1,5 +1,5 @@
<!-- <!--
Copyright © 2012-2022 jrnl contributors Copyright © 2012-2023 jrnl contributors
License: https://www.gnu.org/licenses/gpl-3.0.html License: https://www.gnu.org/licenses/gpl-3.0.html
--> -->
@ -100,16 +100,16 @@ something like `pip3 install crytography`)
import base64 import base64
import getpass import getpass
from pathlib import Path from pathlib import Path
from cryptography.fernet import Fernet from cryptography.fernet import Fernet
from cryptography.hazmat.backends import default_backend from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
filepath = input("journal file path: ") filepath = input("journal file path: ")
password = getpass.getpass("Password: ") password = getpass.getpass("Password: ")
with open(Path(filepath),"rb") as f: with open(Path(filepath), "rb") as f:
ciphertext = f.read() ciphertext = f.read()
password = password.encode("utf-8") password = password.encode("utf-8")
@ -123,7 +123,7 @@ kdf = PBKDF2HMAC(
key = base64.urlsafe_b64encode(kdf.derive(password)) key = base64.urlsafe_b64encode(kdf.derive(password))
print(Fernet(key).decrypt(ciphertext).decode('utf-8')) print(Fernet(key).decrypt(ciphertext).decode("utf-8"))
``` ```
**Example for jrnl v1 files**: **Example for jrnl v1 files**:
@ -137,19 +137,19 @@ like `pip3 install pycrypto`)
""" """
import argparse import argparse
from Crypto.Cipher import AES
import getpass import getpass
import hashlib import hashlib
import sys
from Crypto.Cipher import AES
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("filepath", help="journal file to decrypt") parser.add_argument("filepath", help="journal file to decrypt")
args = parser.parse_args() args = parser.parse_args()
pwd = getpass.getpass() pwd = getpass.getpass()
key = hashlib.sha256(pwd.encode('utf-8')).digest() key = hashlib.sha256(pwd.encode("utf-8")).digest()
with open(args.filepath, 'rb') as f: with open(args.filepath, "rb") as f:
ciphertext = f.read() ciphertext = f.read()
crypto = AES.new(key, AES.MODE_CBC, ciphertext[:16]) crypto = AES.new(key, AES.MODE_CBC, ciphertext[:16])

View file

@ -1,18 +1,44 @@
<!-- <!--
Copyright © 2012-2022 jrnl contributors Copyright © 2012-2023 jrnl contributors
License: https://www.gnu.org/licenses/gpl-3.0.html License: https://www.gnu.org/licenses/gpl-3.0.html
--> -->
# External editors # External editors
Configure your preferred external editor by updating the `editor` option Configure your preferred external editor by updating the `editor` option
in your [configuration file](./reference-config-file.md#editor) in your [configuration file](./reference-config-file.md#editor). If your editor is not
in your operating system's `PATH` environment variable, then you will have to
enter the full path of your editor.
Once it's configured, you can create an entry as a new document in your editor using the `jrnl`
command by itself:
``` text
jrnl
```
You can specify the time and title of the entry as usual on the first line of the document.
If you want, you can skip the editor by including a quick entry with the `jrnl` command:
``` text
jrnl yesterday: All my troubles seemed so far away.
```
If you want to start the entry on the command line and continue writing in your chosen editor,
use the `--edit` flag. For example:
``` text
jrnl yesterday: All my troubles seemed so far away. --edit
```
!!! note !!! note
To save and log any entry edits, save and close the file. To save and log any entry edits, save and close the file.
If your editor is not in your operating system's `PATH` environment variable, 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.
then you will have to enter in the full path of your editor.
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
@ -48,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
@ -97,4 +134,4 @@ When you're done editing the message, save and `C-x #` to close the buffer and s
## Other editors ## Other editors
If you're using another editor and would like to share, feel free to [contribute documentation](./contributing.md#editing-documentation) on it. If you're using another editor and would like to share, feel free to [contribute documentation](./contributing.md#editing-documentation) on it.

View file

@ -1,5 +1,5 @@
<!-- <!--
Copyright © 2012-2022 jrnl contributors Copyright © 2012-2023 jrnl contributors
License: https://www.gnu.org/licenses/gpl-3.0.html License: https://www.gnu.org/licenses/gpl-3.0.html
--> -->
@ -117,6 +117,11 @@ These formats are mainly intended for piping or exporting your journal to other
programs. Even so, they can still be used in the same way as any other format (like programs. Even so, they can still be used in the same way as any other format (like
written to a file, or displayed in your terminal, if you want). written to a file, or displayed in your terminal, if you want).
!!! note
You may see boxed messages like "2 entries found" when using these formats, but
those messages are written to `stderr` instead of `stdout`, and won't be piped when
using the `|` operator.
### JSON ### JSON
``` sh ``` sh
@ -271,13 +276,14 @@ supported by many programs and programming languages.
### YAML ### YAML
``` sh ``` sh
jrnl --format yaml jrnl --format yaml --file 'my_directory/'
``` ```
This outputs your journal into YAML format. YAML is a commonly used data format and is This outputs your journal into YAML format. YAML is a commonly used data format and is
supported by many programs and programming languages. supported by many programs and programming languages. [Exporting to directories](#exporting-to-directories) is the
only supported YAML export option and each entry will be written to a separate file.
**Example output**: **Example file**:
``` yaml ``` yaml
title: This is the second sample entry title: This is the second sample entry
date: 2020-07-01 20:00 date: 2020-07-01 20:00
@ -335,14 +341,14 @@ jrnl --format json > myjournal.json
If the `--file` argument is a directory, jrnl will export each entry into an individual file: If the `--file` argument is a directory, jrnl will export each entry into an individual file:
``` sh ``` sh
jrnl --format json --file my_entries/ jrnl --format yaml --file my_entries/
``` ```
The contents of `my_entries/` will then look like this: The contents of `my_entries/` will then look like this:
``` output ``` output
my_entries/ my_entries/
|- 2013_06_03_a-beautiful-day.json |- 2013_06_03_a-beautiful-day.yaml
|- 2013_06_07_dinner-with-gabriel.json |- 2013_06_07_dinner-with-gabriel.yaml
|- ... |- ...
``` ```

View file

@ -1,5 +1,5 @@
<!-- <!--
Copyright © 2012-2022 jrnl contributors Copyright © 2012-2023 jrnl contributors
License: https://www.gnu.org/licenses/gpl-3.0.html License: https://www.gnu.org/licenses/gpl-3.0.html
--> -->
@ -7,24 +7,14 @@ License: https://www.gnu.org/licenses/gpl-3.0.html
## Installation ## Installation
On Mac and Linux, the easiest way to install `jrnl` is using The easiest way to install `jrnl` is using
[Homebrew](http://brew.sh/): [pipx](https://pipx.pypa.io/stable/installation/)
with [Python](https://www.python.org/) 3.10+:
``` sh
brew install jrnl
```
On other platforms, install `jrnl` using [Python](https://www.python.org/) 3.6+ and [pipx](https://pipxproject.github.io/pipx/):
``` sh ``` sh
pipx install jrnl pipx install jrnl
``` ```
!!! note
`pipx` should be installed through either `brew` or `pip`. Missing dependencies and other issues
may occur when installing `pipx` through `apt` or another package manager. Further installation
instructions can be found in [pipx's documentation](https://pipxproject.github.io/pipx/installation/).
!!! tip !!! tip
Do not use `sudo` while installing `jrnl`. This may lead to path issues. Do not use `sudo` while installing `jrnl`. This may lead to path issues.

View file

@ -1,5 +1,5 @@
<!-- <!--
Copyright © 2012-2022 jrnl contributors Copyright © 2012-2023 jrnl contributors
License: https://www.gnu.org/licenses/gpl-3.0.html License: https://www.gnu.org/licenses/gpl-3.0.html
--> -->

View file

@ -1,5 +1,5 @@
<!-- <!--
Copyright © 2012-2022 jrnl contributors Copyright © 2012-2023 jrnl contributors
License: https://www.gnu.org/licenses/gpl-3.0.html License: https://www.gnu.org/licenses/gpl-3.0.html
--> -->
@ -39,7 +39,7 @@ read them or edit them.
`jrnl` plays nicely with your favorite text editor. You may prefer to write `jrnl` plays nicely with your favorite text editor. You may prefer to write
journal entries in an editor. Or you may want to make changes that require a journal entries in an editor. Or you may want to make changes that require a
more comprehensive application. `jrnl` can filter specific entries and pass them more comprehensive application. `jrnl` can filter specific entries and pass them
to the external editor of your choice. to the [external editor](./external-editors.md) of your choice.
## Encryption ## Encryption

View file

@ -1,5 +1,5 @@
<!-- <!--
Copyright © 2012-2022 jrnl contributors Copyright © 2012-2023 jrnl contributors
License: https://www.gnu.org/licenses/gpl-3.0.html License: https://www.gnu.org/licenses/gpl-3.0.html
--> -->
@ -14,6 +14,35 @@ program there are some limitations to be aware of.
passwords can be easily circumvented by someone with basic security skills passwords can be easily circumvented by someone with basic security skills
to access to your encrypted `jrnl` file. to access to your encrypted `jrnl` file.
## Plausible deniability
You may be able to hide the contents of your journal behind a layer of encryption,
but if someone has access to your configuration file, then they can figure out that
you have a journal, where that journal file is, and when you last edited it.
With a sufficient power imbalance, someone may be able to force you to unencrypt
it through non-technical means.
## Spying
While `jrnl` can protect against unauthorized access to your journal entries while
it isn't open, it cannot protect you against an unsafe computer/location.
For example:
- Someone installs a keylogger, tracking what you type into your journal.
- Someone watches your screen while you write your entry.
- Someone installs a backdoor into `jrnl` or poisons your journal into revealing your entries.
## Saved Passwords
When creating an encrypted journal, you'll be prompted as to whether or not you
want to "store the password in your keychain." This keychain is accessed using
the [Python keyring library](https://pypi.org/project/keyring/), which has different
behavior depending on your operating system.
In Windows, the keychain is the Windows Credential Manager (WCM), which can't be locked
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.
## Shell history ## Shell history
Since you can enter entries from the command line, any tool that logs command Since you can enter entries from the command line, any tool that logs command
@ -78,28 +107,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.
## Plausible deniability ## Editor history
You may be able to hide the contents of your journal behind a layer of encryption, Some editors keep usage history stored on disk for future use. This can be a
but if someone has access to your configuration file, then they can figure out that security risk in the sense that sensitive information can leak via recent
you have a journal, where that journal file is, and when you last edited it. search patterns or editor commands.
With a sufficient power imbalance, someone may be able to force you to unencrypt
it through non-technical means.
## Saved Passwords ### Visual Studio Code
When creating an encrypted journal, you'll be prompted as to whether or not you Visual Studio Code stores the contents of saved files to allow you to restore or
want to "store the password in your keychain." This keychain is accessed using review the contents later. You can disable this feature for all files by unchecking
the [Python keyring library](https://pypi.org/project/keyring/), which has different the `workbench.localHistory.enabled` setting in the
behavior depending on your operating system. [Settings editor](https://code.visualstudio.com/docs/getstarted/settings#_settings-editor).
In Windows, the keychain is the Windows Credential Manager (WCM), which can't be locked Alternatively, you can disable this feature for specific files by configuring a
and can be accessed by any other application running under your username. If this is [pattern](https://code.visualstudio.com/docs/editor/codebasics#_advanced-search-options)
a concern for you, you may not want to store your password. 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.
## Notice any other risks? ## Notice any other risks?

View file

@ -1,5 +1,5 @@
<!-- <!--
Copyright © 2012-2022 jrnl contributors Copyright © 2012-2023 jrnl contributors
License: https://www.gnu.org/licenses/gpl-3.0.html License: https://www.gnu.org/licenses/gpl-3.0.html
--> -->
@ -76,8 +76,11 @@ entries, such as `yesterday`, `today`, `Tuesday`, or `2021-08-01`.
| -contains TEXT | Show entries containing specific text (put quotes around text with spaces) | | -contains TEXT | Show entries containing specific text (put quotes around text with spaces) |
| -and | Show only entries that match all conditions, like saying "x AND y" (default: OR) | | -and | Show only entries that match all conditions, like saying "x AND y" (default: OR) |
| -starred | Show only starred entries (marked with *) | | -starred | Show only starred entries (marked with *) |
| -tagged | Show only tagged entries (marked with the [configured tagsymbols](reference-config-file.md#tagsymbols)) |
| -n [NUMBER] | Show a maximum of NUMBER entries (note: '-n 3' and '-3' have the same effect) | | -n [NUMBER] | Show a maximum of NUMBER entries (note: '-n 3' and '-3' have the same effect) |
| -not [TAG] | Exclude entries with this tag | | -not [TAG] | Exclude entries with this tag |
| -not -starred | Exclude entries that are starred |
| -not -tagged | Exclude entries that are tagged |
## Searching Options ## Searching Options
These help you do various tasks with the selected entries from your search. These help you do various tasks with the selected entries from your search.

View file

@ -1,5 +1,5 @@
<!-- <!--
Copyright © 2012-2022 jrnl contributors Copyright © 2012-2023 jrnl contributors
License: https://www.gnu.org/licenses/gpl-3.0.html License: https://www.gnu.org/licenses/gpl-3.0.html
--> -->
@ -47,10 +47,11 @@ key will be used instead.
If set, executes this command to launch an external editor for If set, executes this command to launch an external editor for
writing and editing your entries. The path to a temporary file writing and editing your entries. The path to a temporary file
is passed after it, and `jrnl` processes the file once is passed after it, and `jrnl` processes the file once
the editor is closed. the editor returns control to `jrnl`.
Some editors require special options to work properly. See Some editors require special options to work properly, since they must be
[External Editors](external-editors.md) for details. blocking processes to work with `jrnl`. See [External Editors](external-editors.md)
for details.
### encrypt ### encrypt
If `true`, encrypts your journal using AES. Do not change this If `true`, encrypts your journal using AES. Do not change this
@ -58,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.
@ -90,9 +93,6 @@ See the [python docs](http://docs.python.org/library/time.html#time.strftime) fo
Do not change this for an existing journal, since that might lead Do not change this for an existing journal, since that might lead
to data loss. to data loss.
If you would just like to change how `jrnl` displays dates,
use display_format instead.
!!! note !!! note
`jrnl` doesn't support the `%z` or `%Z` time zone identifiers. `jrnl` doesn't support the `%z` or `%Z` time zone identifiers.

View file

@ -1,5 +1,5 @@
<!-- <!--
Copyright © 2012-2022 jrnl contributors Copyright © 2012-2023 jrnl contributors
License: https://www.gnu.org/licenses/gpl-3.0.html License: https://www.gnu.org/licenses/gpl-3.0.html
--> -->
@ -74,39 +74,45 @@ jrnlimport () {
} }
``` ```
## Using templates ## Using Templates
!!! note !!! note
Templates require an [external editor](./advanced.md) be configured. Templates require an [external editor](./advanced.md) be configured.
A template is a code snippet that makes it easier to use repeated text Templates are text files that are used for creating structured journals.
each time a new journal entry is started. There are two ways you can utilize There are three ways you can use templates:
templates in your entries.
### 1. Command line arguments ### 1. Use the `--template` command line argument and the default $XDG_DATA_HOME/jrnl/templates directory
If you had a `template.txt` file with the following contents: `$XDG_DATA_HOME/jrnl/templates` is created by default to store your templates! Create a template (like `default.md`) in this directory and pass `--template FILE_IN_DIR`.
```sh ```sh
jrnl --template default.md
```
### 2. Use the `--template` command line argument with a local / absolute path
You can create a template file with any text. Here is an example:
```sh
# /tmp/template.txt
My Personal Journal My Personal Journal
Title: Title:
Body: Body:
``` ```
The `template.txt` file could be used to create a new entry with these Then, pass the absolute or relative path to the template file as an argument, and your external
command line arguments: editor will open and have your template pre-populated.
```sh ```sh
jrnl < template.txt # Imports template.txt as the most recent entry jrnl --template /tmp/template.md
jrnl -1 --edit # Opens the most recent entry in the editor
``` ```
### 2. Include the template file in `jrnl.yaml` ### 3. Set a default template file in `jrnl.yaml`
A more efficient way to work with a template file is to declare the file If you want a template by default, change the value of `template` in the [config file](./reference-config-file.md)
in your [config file](./reference-config-file.md) by changing the `template` from `false` to the template file's path, wrapped in double quotes:
setting from `false` to the template file's path in double quotes:
```sh ```sh
... ...
@ -114,9 +120,6 @@ 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 !!! tip
To read your journal entry or to verify the entry saved, you can use this To read your journal entry or to verify the entry saved, you can use this
command: `jrnl -n 1` (Check out [Formats](./formats.md) for more options). command: `jrnl -n 1` (Check out [Formats](./formats.md) for more options).
@ -211,3 +214,11 @@ display_format: markdown
For more information on how `jrnl` outputs your entries in Markdown, please visit the [Formats](./formats.md) section. For more information on how `jrnl` outputs your entries in Markdown, please visit the [Formats](./formats.md) section.
## Jump to end of buffer (with vi)
To cause vi to jump to the end of the last line of the entry you edit, in your config file set:
```yaml
editor: vi + -c "call cursor('.',strwidth(getline('.')))"
```

View file

@ -1,5 +1,5 @@
<!-- <!--
Copyright © 2012-2022 jrnl contributors Copyright © 2012-2023 jrnl contributors
License: https://www.gnu.org/licenses/gpl-3.0.html License: https://www.gnu.org/licenses/gpl-3.0.html
--> -->

View file

@ -1,5 +1,5 @@
/* /*
Copyright © 2012-2022 jrnl contributors Copyright © 2012-2023 jrnl contributors
License: https://www.gnu.org/licenses/gpl-3.0.html License: https://www.gnu.org/licenses/gpl-3.0.html
*/ */

View file

@ -1,5 +1,5 @@
/* /*
Copyright © 2012-2022 jrnl contributors Copyright © 2012-2023 jrnl contributors
License: https://www.gnu.org/licenses/gpl-3.0.html License: https://www.gnu.org/licenses/gpl-3.0.html
Atom One Dark With support for ReasonML by Gidi Morris, based off work by Atom One Dark With support for ReasonML by Gidi Morris, based off work by
@ -139,3 +139,9 @@ Original One Dark Syntax theme from https://github.com/atom/one-dark-syntax
.rst-content .tip .admonition { .rst-content .tip .admonition {
background: var(--light-blue); background: var(--light-blue);
} }
/* hack to bypass a11y issue with conflicting highlight.css files */
code.language-xml span.hljs-meta span.hljs-string {
color: var(--green) !important;
}

View file

@ -1,5 +1,5 @@
/* /*
Copyright © 2012-2022 jrnl contributors Copyright © 2012-2023 jrnl contributors
License: https://www.gnu.org/licenses/gpl-3.0.html License: https://www.gnu.org/licenses/gpl-3.0.html
*/ */

View file

@ -1,5 +1,5 @@
/* /*
Copyright © 2012-2022 jrnl contributors Copyright © 2012-2023 jrnl contributors
License: https://www.gnu.org/licenses/gpl-3.0.html License: https://www.gnu.org/licenses/gpl-3.0.html
*/ */
@ -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>

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View file

@ -1,5 +1,5 @@
<!-- <!--
Copyright © 2012-2022 jrnl contributors Copyright © 2012-2023 jrnl contributors
License: https://www.gnu.org/licenses/gpl-3.0.html License: https://www.gnu.org/licenses/gpl-3.0.html
--> -->
@ -65,7 +65,7 @@ License: https://www.gnu.org/licenses/gpl-3.0.html
<a href="overview">Documentation</a> <a href="overview">Documentation</a>
<a href="installation" class="cta">Get Started</a> <a href="installation" class="cta">Get Started</a>
<a href="http://github.com/jrnl-org/jrnl" title="View on Github">Fork on GitHub</a> <a href="http://github.com/jrnl-org/jrnl" title="View on Github">Fork on GitHub</a>
<a id="twitter-nav" href="https://twitter.com/intent/tweet?text=Collect+your+thoughts+and+notes+without+leaving+the+command+line.+https%3A%2F%2Fjrnl.sh+via+@JrnlSh"><i class="icon twitter"></i>Tell your friends on Twitter</a> <a id="twitter-nav" href="https://twitter.com/intent/tweet?text=Collect+your+thoughts+and+notes+without+leaving+the+command+line.+https%3A%2F%2Fjrnl.sh+via+@JrnlSh">Tell your friends on X</a>
</nav> </nav>
<div class="flex"> <div class="flex">
<section> <section>
@ -76,22 +76,22 @@ License: https://www.gnu.org/licenses/gpl-3.0.html
<section> <section>
<i class="icon future"></i> <i class="icon future"></i>
<h3>Future-proof.</h3> <h3>Future-proof.</h3>
<p>Your journals are stored in plain-text files that will still be readable in 50 years when all your fancy iPad apps will have gone the way of the Dodo.</p> <p>Your journals are stored in plain-text files that will still be readable in 50 years when your fancy proprietary apps will have gone the way of the dodo.</p>
</section> </section>
<section> <section>
<i class="icon secure"></i> <i class="icon secure"></i>
<h3>Secure.</h3> <h3>Secure.</h3>
<p>Encrypt your journals with industry-strength AES encryption. The NSA won't be able to read your dirty secrets.</p> <p>Encrypt your journals with industry-strength AES encryption. Nobody will be able to read your dirty secrets&mdash;not even you, if you lose your password!</p>
</section> </section>
<section> <section>
<i class="icon sync"></i> <i class="icon sync"></i>
<h3>Accessible anywhere.</h3> <h3>Accessible anywhere.</h3>
<p>Sync your journals with Dropbox and capture your thoughts where ever you are.</p> <p>Sync your journal files with other tools like Dropbox to capture your thoughts wherever you are.</p>
</section> </section>
<section> <section>
<i class="icon github"></i> <i class="icon github"></i>
<h3>Free &amp; Open Source.</h3> <h3>Free &amp; Open Source.</h3>
<p>jrnl is made by a bunch of really friendly and remarkably attractive people. Maybe even <a href="https://www.github.com/jrnl-org/jrnl" title="Fork jrnl on GitHub">you</a>?</p> <p>jrnl is made by a bunch of really friendly and remarkably amazing people. Maybe even <a href="https://www.github.com/jrnl-org/jrnl" title="Fork jrnl on GitHub">you</a>?</p>
</section> </section>
<section> <section>
<i class="icon folders"></i> <i class="icon folders"></i>
@ -103,21 +103,21 @@ License: https://www.gnu.org/licenses/gpl-3.0.html
<footer> <footer>
jrnl is made with love by <a href="https://github.com/jrnl-org/jrnl/graphs/contributors" title="Contributors">many fabulous people</a>. If you need help, <a href="https://github.com/jrnl-org/jrnl/issues/new/choose" title="Open a new issue on Github">submit an issue</a> on Github. jrnl is made with love by <a href="https://github.com/jrnl-org/jrnl/graphs/contributors" title="Contributors">many fabulous people</a>. If you need help, <a href="https://github.com/jrnl-org/jrnl/issues/new/choose" title="Open a new issue on Github">submit an issue</a> on Github.
</footer> </footer>
<script src="//cdnjs.cloudflare.com/ajax/libs/typed.js/2.0.10/typed.min.js"></script> <script src="https://unpkg.com/typed.js@2.1.0/dist/typed.umd.js"></script>
<script> <script>
new Typed("#typed", { new Typed("#typed", {
strings: [ strings: [
"jrnl today: Started writing my memoirs. On the command line. Like a boss.", "jrnl Started writing my memoirs on the command line. 🎉🔥💻🔥🎉",
"jrnl yesterday 2pm: used jrnl to keep track of accomplished tasks. The done.txt for my todo.txt", "jrnl yesterday 2pm: used jrnl to keep track of accomplished tasks. The done.txt for my todo.txt",
"jrnl <b>-from</b> 2009 <b>-until</b> may<br /><i>`(Displays all entries from January 2009 to last may)`</i>", "jrnl <b>-from</b> 2019 <b>-until</b> may<br /><i>`(displays all entries from January 2019 to last May)`</i>",
"jrnl A day on the beach with @beth and @frank. Taggidy-tag-tag.", "jrnl A day on the beach with @beth and @frank. Tagging them so I can easily look this up later.",
"jrnl <b>--tags</b><br /><i>`@idea 7<br />@beth 5</i>`", "jrnl <b>--tags</b><br /><i>`@frank 7<br />@beth 5</i>`",
"jrnl <b>--format</b> json<br /><i>`(Outputs your entire journal as json)</i>`", "jrnl <b>--format</b> json<br /><i>`(Outputs your entire journal as json)</i>`",
"jrnl <b>--encrypt</b><br /><i>`(AES encryption. Crack this, NSA)</i>`" "jrnl <b>--encrypt</b><br /><i>`(AES encryption. Don't lose your password!)</i>`"
], ],
typeSpeed: 35, typeSpeed: 20, // less is faster
backSpeed: 15, backSpeed: 10,
backDelay: 2000, backDelay: 2500,
loop: true, loop: true,
showCursor: false showCursor: false
}); });

View file

@ -1,5 +1,5 @@
<!-- <!--
Copyright © 2012-2022 jrnl contributors Copyright © 2012-2023 jrnl contributors
License: https://www.gnu.org/licenses/gpl-3.0.html License: https://www.gnu.org/licenses/gpl-3.0.html
--> -->

View file

@ -1,2 +1,2 @@
mkdocs>=1.0,<1.3 mkdocs>=1.4
jinja2==3.0.3 # https://github.com/readthedocs/readthedocs.org/issues/9037 jinja2==3.1.6

View file

@ -1,5 +1,5 @@
<!-- <!--
Copyright © 2012-2022 jrnl contributors Copyright © 2012-2023 jrnl contributors
License: https://www.gnu.org/licenses/gpl-3.0.html License: https://www.gnu.org/licenses/gpl-3.0.html
--> -->

View file

@ -1,217 +0,0 @@
# Copyright © 2012-2022 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html
import base64
import hashlib
import logging
import os
from typing import Callable
from typing import Optional
from cryptography.fernet import Fernet
from cryptography.fernet import InvalidToken
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives import padding
from cryptography.hazmat.primitives.ciphers import Cipher
from cryptography.hazmat.primitives.ciphers import algorithms
from cryptography.hazmat.primitives.ciphers import modes
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
from jrnl.exception import JrnlException
from jrnl.Journal import Journal
from jrnl.Journal import LegacyJournal
from jrnl.messages import Message
from jrnl.messages import MsgStyle
from jrnl.messages import MsgText
from jrnl.output import print_msg
from jrnl.prompt import create_password
def make_key(password):
password = password.encode("utf-8")
kdf = PBKDF2HMAC(
algorithm=hashes.SHA256(),
length=32,
# Salt is hard-coded
salt=b"\xf2\xd5q\x0e\xc1\x8d.\xde\xdc\x8e6t\x89\x04\xce\xf8",
iterations=100_000,
backend=default_backend(),
)
key = kdf.derive(password)
return base64.urlsafe_b64encode(key)
def decrypt_content(
decrypt_func: Callable[[str], Optional[str]],
keychain: str = None,
max_attempts: int = 3,
) -> str:
def get_pw():
return print_msg(
Message(MsgText.Password, MsgStyle.PROMPT), get_input=True, hide_input=True
)
pwd_from_keychain = keychain and get_keychain(keychain)
password = pwd_from_keychain or get_pw()
result = decrypt_func(password)
# Password is bad:
if result is None and pwd_from_keychain:
set_keychain(keychain, None)
attempt = 1
while result is None and attempt < max_attempts:
print_msg(Message(MsgText.WrongPasswordTryAgain, MsgStyle.WARNING))
password = get_pw()
result = decrypt_func(password)
attempt += 1
if result is None:
raise JrnlException(Message(MsgText.PasswordMaxTriesExceeded, MsgStyle.ERROR))
return result
class EncryptedJournal(Journal):
def __init__(self, name="default", **kwargs):
super().__init__(name, **kwargs)
self.config["encrypt"] = True
self.password = None
def open(self, filename=None):
"""Opens the journal file defined in the config and parses it into a list of Entries.
Entries have the form (date, title, body)."""
filename = filename or self.config["journal"]
dirname = os.path.dirname(filename)
if not os.path.exists(filename):
if not os.path.isdir(dirname):
os.makedirs(dirname)
print_msg(
Message(
MsgText.DirectoryCreated,
MsgStyle.NORMAL,
{"directory_name": dirname},
)
)
self.create_file(filename)
self.password = create_password(self.name)
print_msg(
Message(
MsgText.JournalCreated,
MsgStyle.NORMAL,
{"journal_name": self.name, "filename": filename},
)
)
text = self._load(filename)
self.entries = self._parse(text)
self.sort()
logging.debug("opened %s with %d entries", self.__class__.__name__, len(self))
return self
def _load(self, filename):
"""Loads an encrypted journal from a file and tries to decrypt it.
If password is not provided, will look for password in the keychain
and otherwise ask the user to enter a password up to three times.
If the password is provided but wrong (or corrupt), this will simply
return None."""
with open(filename, "rb") as f:
journal_encrypted = f.read()
def decrypt_journal(password):
key = make_key(password)
try:
plain = Fernet(key).decrypt(journal_encrypted).decode("utf-8")
self.password = password
return plain
except (InvalidToken, IndexError):
return None
if self.password:
return decrypt_journal(self.password)
return decrypt_content(keychain=self.name, decrypt_func=decrypt_journal)
def _store(self, filename, text):
key = make_key(self.password)
journal = Fernet(key).encrypt(text.encode("utf-8"))
with open(filename, "wb") as f:
f.write(journal)
@classmethod
def from_journal(cls, other: Journal):
new_journal = super().from_journal(other)
new_journal.password = (
other.password
if hasattr(other, "password")
else create_password(other.name)
)
return new_journal
class LegacyEncryptedJournal(LegacyJournal):
"""Legacy class to support opening journals encrypted with the jrnl 1.x
standard. You'll not be able to save these journals anymore."""
def __init__(self, name="default", **kwargs):
super().__init__(name, **kwargs)
self.config["encrypt"] = True
self.password = None
def _load(self, filename):
with open(filename, "rb") as f:
journal_encrypted = f.read()
iv, cipher = journal_encrypted[:16], journal_encrypted[16:]
def decrypt_journal(password):
decryption_key = hashlib.sha256(password.encode("utf-8")).digest()
decryptor = Cipher(
algorithms.AES(decryption_key), modes.CBC(iv), default_backend()
).decryptor()
try:
plain_padded = decryptor.update(cipher) + decryptor.finalize()
self.password = password
if plain_padded[-1] in (" ", 32):
# Ancient versions of jrnl. Do not judge me.
return plain_padded.decode("utf-8").rstrip(" ")
else:
unpadder = padding.PKCS7(algorithms.AES.block_size).unpadder()
plain = unpadder.update(plain_padded) + unpadder.finalize()
return plain.decode("utf-8")
except ValueError:
return None
if self.password:
return decrypt_journal(self.password)
return decrypt_content(keychain=self.name, decrypt_func=decrypt_journal)
def get_keychain(journal_name):
import keyring
try:
return keyring.get_password("jrnl", journal_name)
except keyring.errors.KeyringError as e:
if not isinstance(e, keyring.errors.NoKeyringError):
print_msg(Message(MsgText.KeyringRetrievalFailure, MsgStyle.ERROR))
return ""
def set_keychain(journal_name, password):
import keyring
if password is None:
try:
keyring.delete_password("jrnl", journal_name)
except keyring.errors.KeyringError:
pass
else:
try:
keyring.set_password("jrnl", journal_name, password)
except keyring.errors.KeyringError as e:
if isinstance(e, keyring.errors.NoKeyringError):
msg = Message(MsgText.KeyringBackendNotFound, MsgStyle.WARNING)
else:
msg = Message(MsgText.KeyringRetrievalFailure, MsgStyle.ERROR)
print_msg(msg)

View file

@ -1,4 +1,4 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
try: try:

View file

@ -1,9 +1,9 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
import sys import sys
from jrnl.cli import cli from jrnl.main import run
if __name__ == "__main__": if __name__ == "__main__":
sys.exit(cli()) sys.exit(run())

View file

@ -1 +1 @@
__version__ = "v3.2" __version__ = "v4.2.1"

View file

@ -1,4 +1,4 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
import argparse import argparse
@ -20,7 +20,7 @@ from jrnl.plugins import util
class WrappingFormatter(argparse.RawTextHelpFormatter): class WrappingFormatter(argparse.RawTextHelpFormatter):
"""Used in help screen""" """Used in help screen"""
def _split_lines(self, text, width): def _split_lines(self, text: str, width: int) -> list[str]:
text = text.split("\n\n") text = text.split("\n\n")
text = map(lambda t: self._whitespace_matcher.sub(" ", t).strip(), text) text = map(lambda t: self._whitespace_matcher.sub(" ", t).strip(), text)
text = map(lambda t: textwrap.wrap(t, width=56), text) text = map(lambda t: textwrap.wrap(t, width=56), text)
@ -28,7 +28,44 @@ class WrappingFormatter(argparse.RawTextHelpFormatter):
return text return text
def parse_args(args=[]): class IgnoreNoneAppendAction(argparse._AppendAction):
"""
Pass -not without a following string and avoid appending
a None value to the excluded list
"""
def __call__(self, parser, namespace, values, option_string=None):
if values is not None:
super().__call__(parser, namespace, values, option_string)
def parse_not_arg(
args: list[str], parsed_args: argparse.Namespace, parser: argparse.ArgumentParser
) -> argparse.Namespace:
"""
It's possible to use -not as a precursor to -starred and -tagged
to reverse their behaviour, however this requires some extra logic
to parse, and to ensure we still do not allow passing an empty -not
"""
parsed_args.exclude_starred = False
parsed_args.exclude_tagged = False
if "-not-starred" in "".join(args):
parsed_args.starred = False
parsed_args.exclude_starred = True
if "-not-tagged" in "".join(args):
parsed_args.tagged = False
parsed_args.exclude_tagged = True
if "-not" in args and not any(
[parsed_args.exclude_starred, parsed_args.exclude_tagged, parsed_args.excluded]
):
parser.error("argument -not: expected 1 argument")
return parsed_args
def parse_args(args: list[str] = []) -> argparse.Namespace:
""" """
Argument parsing that is doable before the config is available. Argument parsing that is doable before the config is available.
Everything else goes into "text" for later parsing. Everything else goes into "text" for later parsing.
@ -41,7 +78,7 @@ def parse_args(args=[]):
""" """
We gratefully thank all contributors! We gratefully thank all contributors!
Come see the whole list of code and financial contributors at https://github.com/jrnl-org/jrnl Come see the whole list of code and financial contributors at https://github.com/jrnl-org/jrnl
And special thanks to Bad Lip Reading for the Yoda joke in the Writing section above :)""" And special thanks to Bad Lip Reading for the Yoda joke in the Writing section above :)""" # noqa: E501
), ),
) )
@ -85,7 +122,13 @@ def parse_args(args=[]):
action="store_const", action="store_const",
const=postconfig_list, const=postconfig_list,
dest="postconfig_cmd", dest="postconfig_cmd",
help="List all configured journals", help="""
List all configured journals.
Optional parameters:
--format [json or yaml]
""",
) )
standalone.add_argument( standalone.add_argument(
"--ls", "--ls",
@ -168,6 +211,12 @@ def parse_args(args=[]):
"Writing", textwrap.dedent(compose_msg).strip() "Writing", textwrap.dedent(compose_msg).strip()
) )
composing.add_argument("text", metavar="", nargs="*") composing.add_argument("text", metavar="", nargs="*")
composing.add_argument(
"--template",
dest="template",
help="Path to template file. Can be a local path, absolute path, or a path "
"relative to $XDG_DATA_HOME/jrnl/templates/",
)
read_msg = ( read_msg = (
"To find entries from your journal, use any combination of the below filters." "To find entries from your journal, use any combination of the below filters."
@ -216,14 +265,17 @@ def parse_args(args=[]):
reading.add_argument( reading.add_argument(
"-contains", "-contains",
dest="contains", dest="contains",
action="append",
metavar="TEXT", metavar="TEXT",
help="Show entries containing specific text (put quotes around text with spaces)", help="Show entries containing specific text (put quotes around text with "
"spaces)",
) )
reading.add_argument( reading.add_argument(
"-and", "-and",
dest="strict", dest="strict",
action="store_true", action="store_true",
help='Show only entries that match all conditions, like saying "x AND y" (default: OR)', help='Show only entries that match all conditions, like saying "x AND y" '
"(default: OR)",
) )
reading.add_argument( reading.add_argument(
"-starred", "-starred",
@ -231,27 +283,42 @@ def parse_args(args=[]):
action="store_true", action="store_true",
help="Show only starred entries (marked with *)", help="Show only starred entries (marked with *)",
) )
reading.add_argument(
"-tagged",
dest="tagged",
action="store_true",
help="Show only entries that have at least one tag",
)
reading.add_argument( reading.add_argument(
"-n", "-n",
dest="limit", dest="limit",
default=None, default=None,
metavar="NUMBER", metavar="NUMBER",
help="Show a maximum of NUMBER entries (note: '-n 3' and '-3' have the same effect)", help="Show a maximum of NUMBER entries (note: '-n 3' and '-3' have the same "
"effect)",
nargs="?", nargs="?",
type=int, type=int,
) )
reading.add_argument( reading.add_argument(
"-not", "-not",
dest="excluded", dest="excluded",
nargs=1, nargs="?",
default=[], default=[],
metavar="TAG", metavar="TAG/FLAG",
action="extend", action=IgnoreNoneAppendAction,
help="Exclude entries with this tag", help=(
"If passed a string, will exclude entries with that tag. "
"Can be also used before -starred or -tagged flags, to exclude "
"starred or tagged entries respectively."
),
) )
search_options_msg = """ These help you do various tasks with the selected entries from your search. search_options_msg = (
If used on their own (with no search), they will act on your entire journal""" " " # Preserves indentation
"""
These help you do various tasks with the selected entries from your search.
If used on their own (with no search), they will act on your entire journal"""
)
exporting = parser.add_argument_group( exporting = parser.add_argument_group(
"Searching Options", textwrap.dedent(search_options_msg) "Searching Options", textwrap.dedent(search_options_msg)
) )
@ -273,7 +340,7 @@ def parse_args(args=[]):
nargs="?", nargs="?",
metavar="DATE", metavar="DATE",
const="now", const="now",
help="Change timestamp for seleted entries (default: now)", help="Change timestamp for selected entries (default: now)",
) )
exporting.add_argument( exporting.add_argument(
"--format", "--format",
@ -302,7 +369,8 @@ def parse_args(args=[]):
"--tags", "--tags",
dest="tags", dest="tags",
action="store_true", action="store_true",
help="Alias for '--format tags'. Returns a list of all tags and number of occurences", help="Alias for '--format tags'. Returns a list of all tags and number of "
"occurrences",
) )
exporting.add_argument( exporting.add_argument(
"--short", "--short",
@ -342,7 +410,7 @@ def parse_args(args=[]):
\t jrnl --config-override editor "nano" \n \t jrnl --config-override editor "nano" \n
\t - Override color selections\n \t - Override color selections\n
\t jrnl --config-override colors.body blue --config-override colors.title green \t jrnl --config-override colors.body blue --config-override colors.title green
""", """, # noqa: E501
) )
config_overrides.add_argument( config_overrides.add_argument(
"--co", "--co",
@ -366,13 +434,13 @@ def parse_args(args=[]):
default="", default="",
help=""" help="""
Overrides default (created when first installed) config file for this command only. Overrides default (created when first installed) config file for this command only.
Examples: \n Examples: \n
\t - Use a work config file for this jrnl entry, call: \n \t - Use a work config file for this jrnl entry, call: \n
\t jrnl --config-file /home/user1/work_config.yaml \t jrnl --config-file /home/user1/work_config.yaml
\t - Use a personal config file stored on a thumb drive: \n \t - Use a personal config file stored on a thumb drive: \n
\t jrnl --config-file /media/user1/my-thumb-drive/personal_config.yaml \t jrnl --config-file /media/user1/my-thumb-drive/personal_config.yaml
""", """, # noqa: E501
) )
alternate_config.add_argument( alternate_config.add_argument(
@ -382,5 +450,7 @@ def parse_args(args=[]):
# Handle '-123' as a shortcut for '-n 123' # Handle '-123' as a shortcut for '-n 123'
num = re.compile(r"^-(\d+)$") num = re.compile(r"^-(\d+)$")
args = [num.sub(r"-n \1", arg) for arg in args] args = [num.sub(r"-n \1", arg) for arg in args]
parsed_args = parser.parse_intermixed_args(args)
parsed_args = parse_not_arg(args, parsed_args, parser)
return parser.parse_intermixed_args(args) return parsed_args

View file

@ -1,19 +1,23 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
import re import re
from string import punctuation from string import punctuation
from string import whitespace from string import whitespace
from typing import TYPE_CHECKING
import colorama import colorama
from jrnl.os_compat import on_windows from jrnl.os_compat import on_windows
if TYPE_CHECKING:
from jrnl.journals import Entry
if on_windows(): if on_windows():
colorama.init() colorama.init()
def colorize(string, color, bold=False): def colorize(string: str, color: str, bold: bool = False) -> str:
"""Returns the string colored with colorama.Fore.color. If the color set by """Returns the string colored with colorama.Fore.color. If the color set by
the user is "NONE" or the color doesn't exist in the colorama.Fore attributes, the user is "NONE" or the color doesn't exist in the colorama.Fore attributes,
it returns the string without any modification.""" it returns the string without any modification."""
@ -26,7 +30,9 @@ def colorize(string, color, bold=False):
return colorama.Style.BRIGHT + color_escape + string + colorama.Style.RESET_ALL return colorama.Style.BRIGHT + color_escape + string + colorama.Style.RESET_ALL
def highlight_tags_with_background_color(entry, text, color, is_title=False): def highlight_tags_with_background_color(
entry: "Entry", text: str, color: str, is_title: bool = False
) -> str:
""" """
Takes a string and colorizes the tags in it based upon the config value for Takes a string and colorizes the tags in it based upon the config value for
color.tags, while colorizing the rest of the text based on `color`. color.tags, while colorizing the rest of the text based on `color`.
@ -45,9 +51,9 @@ def highlight_tags_with_background_color(entry, text, color, is_title=False):
:returns [(colorized_str, original_str)]""" :returns [(colorized_str, original_str)]"""
for part in fragments: for part in fragments:
if part and part[0] not in config["tagsymbols"]: if part and part[0] not in config["tagsymbols"]:
yield (colorize(part, color, bold=is_title), part) yield colorize(part, color, bold=is_title), part
elif part: elif part:
yield (colorize(part, config["colors"]["tags"], bold=True), part) yield colorize(part, config["colors"]["tags"], bold=True), part
config = entry.journal.config config = entry.journal.config
if config["highlight"]: # highlight tags if config["highlight"]: # highlight tags

View file

@ -1,4 +1,4 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
""" """
@ -14,18 +14,21 @@ run.
Also, please note that all (non-builtin) imports should be scoped to each function to Also, please note that all (non-builtin) imports should be scoped to each function to
avoid any possible overhead for these standalone commands. avoid any possible overhead for these standalone commands.
""" """
import argparse
import logging
import platform import platform
import sys import sys
from jrnl.config import cmd_requires_valid_journal_name
from jrnl.exception import JrnlException from jrnl.exception import JrnlException
from jrnl.messages import Message from jrnl.messages import Message
from jrnl.messages import MsgStyle from jrnl.messages import MsgStyle
from jrnl.messages import MsgText from jrnl.messages import MsgText
from jrnl.output import print_msg from jrnl.output import print_msg
from jrnl.prompt import create_password
def preconfig_diagnostic(_): def preconfig_diagnostic(_) -> None:
from jrnl import __title__ from jrnl import __title__
from jrnl import __version__ from jrnl import __version__
@ -36,7 +39,7 @@ def preconfig_diagnostic(_):
) )
def preconfig_version(_): def preconfig_version(_) -> None:
import textwrap import textwrap
from jrnl import __title__ from jrnl import __title__
@ -45,7 +48,7 @@ def preconfig_version(_):
output = f""" output = f"""
{__title__} {__version__} {__title__} {__version__}
Copyright © 2012-2022 jrnl contributors Copyright © 2012-2023 jrnl contributors
This is free software, and you are welcome to redistribute it under certain This is free software, and you are welcome to redistribute it under certain
conditions; for details, see: https://www.gnu.org/licenses/gpl-3.0.html conditions; for details, see: https://www.gnu.org/licenses/gpl-3.0.html
@ -56,31 +59,48 @@ def preconfig_version(_):
print(output) print(output)
def postconfig_list(config, **kwargs): def postconfig_list(args: argparse.Namespace, config: dict, **_) -> int:
from jrnl.output import list_journals from jrnl.output import list_journals
print(list_journals(config)) print(list_journals(config, args.export))
return 0
def postconfig_import(args, config, **kwargs): @cmd_requires_valid_journal_name
from jrnl.Journal import open_journal def postconfig_import(args: argparse.Namespace, config: dict, **_) -> int:
from jrnl.journals import open_journal
from jrnl.plugins import get_importer from jrnl.plugins import get_importer
# Requires opening the journal # Requires opening the journal
journal = open_journal(args.journal_name, config) journal = open_journal(args.journal_name, config)
format = args.export if args.export else "jrnl" format = args.export if args.export else "jrnl"
get_importer(format).import_(journal, args.filename)
if (importer := get_importer(format)) is None:
raise JrnlException(
Message(
MsgText.ImporterNotFound,
MsgStyle.ERROR,
{"format": format},
)
)
importer.import_(journal, args.filename)
return 0
def postconfig_encrypt(args, config, original_config, **kwargs): @cmd_requires_valid_journal_name
def postconfig_encrypt(
args: argparse.Namespace, config: dict, original_config: dict
) -> int:
""" """
Encrypt a journal in place, or optionally to a new file Encrypt a journal in place, or optionally to a new file
""" """
from jrnl.config import update_config from jrnl.config import update_config
from jrnl.EncryptedJournal import EncryptedJournal
from jrnl.install import save_config from jrnl.install import save_config
from jrnl.Journal import open_journal from jrnl.journals import open_journal
# Open the journal # Open the journal
journal = open_journal(args.journal_name, config) journal = open_journal(args.journal_name, config)
@ -97,21 +117,24 @@ def postconfig_encrypt(args, config, original_config, **kwargs):
) )
) )
new_journal = EncryptedJournal.from_journal(journal)
# If journal is encrypted, create new password # If journal is encrypted, create new password
if journal.config["encrypt"] is True: logging.debug("Clearing encryption method...")
print(f"Journal {journal.name} is already encrypted. Create a new password.")
new_journal.password = create_password(new_journal.name)
journal.config["encrypt"] = True if journal.config["encrypt"] is True:
new_journal.write(args.filename) logging.debug("Journal already encrypted. Re-encrypting...")
print(f"Journal {journal.name} is already encrypted. Create a new password.")
journal.encryption_method.clear()
else:
journal.config["encrypt"] = True
journal.encryption_method = None
journal.write(args.filename)
print_msg( print_msg(
Message( Message(
MsgText.JournalEncryptedTo, MsgText.JournalEncryptedTo,
MsgStyle.NORMAL, MsgStyle.NORMAL,
{"path": args.filename or new_journal.config["journal"]}, {"path": args.filename or journal.config["journal"]},
) )
) )
@ -122,24 +145,30 @@ def postconfig_encrypt(args, config, original_config, **kwargs):
) )
save_config(original_config) save_config(original_config)
return 0
def postconfig_decrypt(args, config, original_config, **kwargs):
"""Decrypts into new file. If filename is not set, we encrypt the journal file itself.""" @cmd_requires_valid_journal_name
def postconfig_decrypt(
args: argparse.Namespace, config: dict, original_config: dict
) -> int:
"""Decrypts to file. If filename is not set, we encrypt the journal file itself."""
from jrnl.config import update_config from jrnl.config import update_config
from jrnl.install import save_config from jrnl.install import save_config
from jrnl.Journal import PlainJournal from jrnl.journals import open_journal
from jrnl.Journal import open_journal
journal = open_journal(args.journal_name, config) journal = open_journal(args.journal_name, config)
journal.config["encrypt"] = False
new_journal = PlainJournal.from_journal(journal) logging.debug("Clearing encryption method...")
new_journal.write(args.filename) journal.config["encrypt"] = False
journal.encryption_method = None
journal.write(args.filename)
print_msg( print_msg(
Message( Message(
MsgText.JournalDecryptedTo, MsgText.JournalDecryptedTo,
MsgStyle.NORMAL, MsgStyle.NORMAL,
{"path": args.filename or new_journal.config["journal"]}, {"path": args.filename or journal.config["journal"]},
) )
) )
@ -149,3 +178,5 @@ def postconfig_decrypt(args, config, original_config, **kwargs):
original_config, {"encrypt": False}, args.journal_name, force_local=True original_config, {"encrypt": False}, args.journal_name, force_local=True
) )
save_config(original_config) save_config(original_config)
return 0

View file

@ -1,11 +1,14 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
import argparse
import logging import logging
import os import os
from typing import Any
from typing import Callable
import colorama import colorama
import xdg.BaseDirectory from rich.pretty import pretty_repr
from ruamel.yaml import YAML from ruamel.yaml import YAML
from ruamel.yaml import constructor from ruamel.yaml import constructor
@ -16,13 +19,10 @@ from jrnl.messages import MsgStyle
from jrnl.messages import MsgText from jrnl.messages import MsgText
from jrnl.output import list_journals from jrnl.output import list_journals
from jrnl.output import print_msg from jrnl.output import print_msg
from jrnl.path import home_dir from jrnl.path import get_config_path
from jrnl.path import get_default_journal_path
# Constants # Constants
DEFAULT_CONFIG_NAME = "jrnl.yaml"
XDG_RESOURCE = "jrnl"
DEFAULT_JOURNAL_NAME = "journal.txt"
DEFAULT_JOURNAL_KEY = "default" DEFAULT_JOURNAL_KEY = "default"
YAML_SEPARATOR = ": " YAML_SEPARATOR = ": "
@ -30,7 +30,6 @@ YAML_FILE_ENCODING = "utf-8"
def make_yaml_valid_dict(input: list) -> dict: def make_yaml_valid_dict(input: list) -> dict:
""" """
Convert a two-element list of configuration key-value pair into a flat dict. Convert a two-element list of configuration key-value pair into a flat dict.
@ -38,9 +37,10 @@ def make_yaml_valid_dict(input: list) -> dict:
The dict is created through the yaml loader, with the assumption that The dict is created through the yaml loader, with the assumption that
"input[0]: input[1]" is valid yaml. "input[0]: input[1]" is valid yaml.
:param input: list of configuration keys in dot-notation and their respective values. :param input: list of configuration keys in dot-notation and their respective values
:type input: list :type input: list
:return: A single level dict of the configuration keys in dot-notation and their respective desired values :return: A single level dict of the configuration keys in dot-notation and their
respective desired values
:rtype: dict :rtype: dict
""" """
@ -54,7 +54,7 @@ def make_yaml_valid_dict(input: list) -> dict:
return runtime_modifications return runtime_modifications
def save_config(config, alt_config_path=None): def save_config(config: dict, alt_config_path: str | None = None) -> None:
"""Supply alt_config_path if using an alternate config through --config-file.""" """Supply alt_config_path if using an alternate config through --config-file."""
config["version"] = __version__ config["version"] = __version__
@ -69,71 +69,59 @@ def save_config(config, alt_config_path=None):
yaml.dump(config, f) yaml.dump(config, f)
def get_config_path(): def get_default_config() -> dict[str, Any]:
try:
config_directory_path = xdg.BaseDirectory.save_config_path(XDG_RESOURCE)
except FileExistsError:
raise JrnlException(
Message(
MsgText.ConfigDirectoryIsFile,
MsgStyle.ERROR,
{
"config_directory_path": os.path.join(
xdg.BaseDirectory.xdg_config_home, XDG_RESOURCE
)
},
),
)
return os.path.join(config_directory_path or home_dir(), DEFAULT_CONFIG_NAME)
def get_default_config():
return { return {
"version": __version__, "version": __version__,
"journals": {"default": get_default_journal_path()}, "journals": {"default": {"journal": get_default_journal_path()}},
"editor": os.getenv("VISUAL") or os.getenv("EDITOR") or "", "editor": os.getenv("VISUAL") or os.getenv("EDITOR") or "",
"encrypt": False, "encrypt": False,
"template": False, "template": False,
"default_hour": 9, "default_hour": 9,
"default_minute": 0, "default_minute": 0,
"timeformat": "%Y-%m-%d %H:%M", "timeformat": "%F %r",
"tagsymbols": "#@", "tagsymbols": "#@",
"highlight": True, "highlight": True,
"linewrap": 79, "linewrap": 79,
"indent_character": "|", "indent_character": "|",
"colors": { "colors": {
"date": "none",
"title": "none",
"body": "none", "body": "none",
"date": "none",
"tags": "none", "tags": "none",
"title": "none",
}, },
} }
def get_default_journal_path(): def get_default_colors() -> dict[str, Any]:
journal_data_path = xdg.BaseDirectory.save_data_path(XDG_RESOURCE) or home_dir() return {
return os.path.join(journal_data_path, DEFAULT_JOURNAL_NAME) "body": "none",
"date": "black",
"tags": "yellow",
"title": "cyan",
}
def scope_config(config, journal_name): def scope_config(config: dict, journal_name: str) -> dict:
if journal_name not in config["journals"]: if journal_name not in config["journals"]:
return config return config
config = config.copy() config = config.copy()
journal_conf = config["journals"].get(journal_name) journal_conf = config["journals"].get(journal_name)
if type(journal_conf) is dict: if isinstance(journal_conf, dict):
# We can override the default config on a by-journal basis # We can override the default config on a by-journal basis
logging.debug( logging.debug(
"Updating configuration with specific journal overrides %s", journal_conf "Updating configuration with specific journal overrides:\n%s",
pretty_repr(journal_conf),
) )
config.update(journal_conf) config.update(journal_conf)
else: else:
# But also just give them a string to point to the journal file # But also just give them a string to point to the journal file
config["journal"] = journal_conf config["journal"] = journal_conf
logging.debug("Scoped config:\n%s", pretty_repr(config))
return config return config
def verify_config_colors(config): def verify_config_colors(config: dict) -> bool:
""" """
Ensures the keys set for colors are valid colorama.Fore attributes, or "None" Ensures the keys set for colors are valid colorama.Fore attributes, or "None"
:return: True if all keys are set correctly, False otherwise :return: True if all keys are set correctly, False otherwise
@ -158,7 +146,7 @@ def verify_config_colors(config):
return all_valid_colors return all_valid_colors
def load_config(config_path): def load_config(config_path: str) -> dict:
"""Tries to load a config file from YAML.""" """Tries to load a config file from YAML."""
try: try:
with open(config_path, encoding=YAML_FILE_ENCODING) as f: with open(config_path, encoding=YAML_FILE_ENCODING) as f:
@ -181,17 +169,19 @@ def load_config(config_path):
return yaml.load(f) return yaml.load(f)
def is_config_json(config_path): def is_config_json(config_path: str) -> bool:
with open(config_path, "r", encoding="utf-8") as f: with open(config_path, "r", encoding="utf-8") as f:
config_file = f.read() config_file = f.read()
return config_file.strip().startswith("{") return config_file.strip().startswith("{")
def update_config(config, new_config, scope, force_local=False): def update_config(
config: dict, new_config: dict, scope: str | None, force_local: bool = False
) -> None:
"""Updates a config dict with new values - either global if scope is None """Updates a config dict with new values - either global if scope is None
or config['journals'][scope] is just a string pointing to a journal file, or config['journals'][scope] is just a string pointing to a journal file,
or within the scope""" or within the scope"""
if scope and type(config["journals"][scope]) is dict: # Update to journal specific if scope and isinstance(config["journals"][scope], dict):
config["journals"][scope].update(new_config) config["journals"][scope].update(new_config)
elif scope and force_local: # Convert to dict elif scope and force_local: # Convert to dict
config["journals"][scope] = {"journal": config["journals"][scope]} config["journals"][scope] = {"journal": config["journals"][scope]}
@ -200,7 +190,7 @@ def update_config(config, new_config, scope, force_local=False):
config.update(new_config) config.update(new_config)
def get_journal_name(args, config): def get_journal_name(args: argparse.Namespace, config: dict) -> argparse.Namespace:
args.journal_name = DEFAULT_JOURNAL_KEY args.journal_name = DEFAULT_JOURNAL_KEY
# The first arg might be a journal name # The first arg might be a journal name
@ -213,14 +203,27 @@ def get_journal_name(args, config):
args.journal_name = potential_journal_name args.journal_name = potential_journal_name
args.text = args.text[1:] args.text = args.text[1:]
if args.journal_name not in config["journals"]:
raise JrnlException(
Message(
MsgText.NoDefaultJournal,
MsgStyle.ERROR,
{"journals": list_journals(config)},
),
)
logging.debug("Using journal name: %s", args.journal_name) logging.debug("Using journal name: %s", args.journal_name)
return args return args
def cmd_requires_valid_journal_name(func: Callable) -> Callable:
def wrapper(args: argparse.Namespace, config: dict, original_config: dict):
validate_journal_name(args.journal_name, config)
func(args=args, config=config, original_config=original_config)
return wrapper
def validate_journal_name(journal_name: str, config: dict) -> None:
if journal_name not in config["journals"]:
raise JrnlException(
Message(
MsgText.NoNamedJournal,
MsgStyle.ERROR,
{
"journal_name": journal_name,
"journals": list_journals(config),
},
),
)

View file

@ -1,8 +1,9 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
import logging import logging
import sys import sys
from typing import TYPE_CHECKING
from jrnl import install from jrnl import install
from jrnl import plugins from jrnl import plugins
@ -13,26 +14,33 @@ from jrnl.config import get_journal_name
from jrnl.config import scope_config from jrnl.config import scope_config
from jrnl.editor import get_text_from_editor from jrnl.editor import get_text_from_editor
from jrnl.editor import get_text_from_stdin from jrnl.editor import get_text_from_stdin
from jrnl.editor import read_template_file
from jrnl.exception import JrnlException from jrnl.exception import JrnlException
from jrnl.Journal import open_journal from jrnl.journals import open_journal
from jrnl.messages import Message from jrnl.messages import Message
from jrnl.messages import MsgStyle from jrnl.messages import MsgStyle
from jrnl.messages import MsgText from jrnl.messages import MsgText
from jrnl.output import print_msg from jrnl.output import print_msg
from jrnl.output import print_msgs from jrnl.output import print_msgs
from jrnl.override import apply_overrides from jrnl.override import apply_overrides
from jrnl.path import expand_path
if TYPE_CHECKING:
from argparse import Namespace
from jrnl.journals import Entry
from jrnl.journals import Journal
def run(args): def run(args: "Namespace"):
""" """
Flow: Flow:
1. Run standalone command if it doesn't require config (help, version, etc), then exit 1. Run standalone command if it doesn't need config (help, version, etc), then exit
2. Load config 2. Load config
3. Run standalone command if it does require config (encrypt, decrypt, etc), then exit 3. Run standalone command if it does need config (encrypt, decrypt, etc), then exit
4. Load specified journal 4. Load specified journal
5. Start write mode, or search mode 5. Start append mode, or search mode
6. Profit 6. Perform actions with results from search mode (if needed)
7. Profit
""" """
# Run command if possible before config is available # Run command if possible before config is available
@ -64,87 +72,98 @@ def run(args):
"args": args, "args": args,
"config": config, "config": config,
"journal": journal, "journal": journal,
"old_entries": journal.entries,
} }
if _is_write_mode(**kwargs): if _is_append_mode(**kwargs):
write_mode(**kwargs) append_mode(**kwargs)
return
# If not append mode, then we're in search mode (only 2 modes exist)
search_mode(**kwargs)
entries_found_count = len(journal)
_print_entries_found_count(entries_found_count, args)
# Actions
_perform_actions_on_search_results(**kwargs)
if entries_found_count != 0 and _has_action_args(args):
_print_changed_counts(journal)
else: else:
search_mode(**kwargs) # display only occurs if no other action occurs
_display_search_results(**kwargs)
def _is_write_mode(args, config, **kwargs): def _perform_actions_on_search_results(**kwargs):
"""Determines if we are in write mode (as opposed to search mode)""" args = kwargs["args"]
write_mode = True
# Perform actions (if needed)
if args.change_time:
_change_time_search_results(**kwargs)
if args.delete:
_delete_search_results(**kwargs)
# open results in editor (if `--edit` was used)
if args.edit:
_edit_search_results(**kwargs)
def _is_append_mode(args: "Namespace", config: dict, **kwargs) -> bool:
"""Determines if we are in append mode (as opposed to search mode)"""
# Are any search filters present? If so, then search mode. # Are any search filters present? If so, then search mode.
write_mode = not any( append_mode = (
( not _has_search_args(args)
args.contains, and not _has_action_args(args)
args.delete, and not _has_display_args(args)
args.edit,
args.change_time,
args.excluded,
args.export,
args.end_date,
args.today_in_history,
args.month,
args.day,
args.year,
args.limit,
args.on_date,
args.short,
args.starred,
args.start_date,
args.strict,
args.tags,
)
) )
# Might be writing and want to move to editor part of the way through # Might be writing and want to move to editor part of the way through
if args.edit and args.text: if args.edit and args.text:
write_mode = True append_mode = True
# If the text is entirely tags, then we are also searching (not writing) # If the text is entirely tags, then we are also searching (not writing)
if ( if append_mode and args.text and _has_only_tags(config["tagsymbols"], args.text):
write_mode append_mode = False
and args.text
and all(word[0] in config["tagsymbols"] for word in " ".join(args.text).split())
):
write_mode = False
return write_mode return append_mode
def write_mode(args, config, journal, **kwargs): def append_mode(args: "Namespace", config: dict, journal: "Journal", **kwargs) -> None:
""" """
Gets input from the user to write to the journal Gets input from the user to write to the journal
0. Check for a template passed as an argument, or in the global config
1. Check for input from cli 1. Check for input from cli
2. Check input being piped in 2. Check input being piped in
3. Open editor if configured (prepopulated with template if available) 3. Open editor if configured (prepopulated with template if available)
4. Use stdin.read as last resort 4. Use stdin.read as last resort
6. Write any found text to journal, or exit 6. Write any found text to journal, or exit
""" """
logging.debug("Write mode: starting") logging.debug("Append mode: starting")
template_text = _get_template(args, config)
if args.text: if args.text:
logging.debug("Write mode: cli text detected: %s", args.text) logging.debug(f"Append mode: cli text detected: {args.text}")
raw = " ".join(args.text).strip() raw = " ".join(args.text).strip()
if args.edit: if args.edit:
raw = _write_in_editor(config, raw) raw = _write_in_editor(config, raw)
elif not sys.stdin.isatty(): elif not sys.stdin.isatty():
logging.debug("Write mode: receiving piped text") logging.debug("Append mode: receiving piped text")
raw = sys.stdin.read() raw = sys.stdin.read()
else: else:
raw = _write_in_editor(config) raw = _write_in_editor(config, template_text)
if template_text is not None and raw == template_text:
logging.error("Append mode: raw text was the same as the template")
raise JrnlException(Message(MsgText.NoChangesToTemplate, MsgStyle.NORMAL))
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("Append mode: couldn't get raw text or entry was empty")
raise JrnlException(Message(MsgText.NoTextReceived, MsgStyle.NORMAL)) raise JrnlException(Message(MsgText.NoTextReceived, MsgStyle.NORMAL))
logging.debug( logging.debug(
'Write mode: appending raw text to journal "%s": %s', args.journal_name, raw f"Append mode: appending raw text to journal '{args.journal_name}': {raw}"
) )
journal.new_entry(raw) journal.new_entry(raw)
if args.journal_name != DEFAULT_JOURNAL_KEY: if args.journal_name != DEFAULT_JOURNAL_KEY:
@ -156,122 +175,53 @@ def write_mode(args, config, journal, **kwargs):
) )
) )
journal.write() journal.write()
logging.debug("Write mode: completed journal.write()") logging.debug("Append mode: completed journal.write()")
def search_mode(args, journal, **kwargs): def _get_template(args, config) -> str:
# Read template file and pass as raw text into the composer
logging.debug(
"Get template:\n"
f"--template: {args.template}\n"
f"from config: {config.get('template')}"
)
template_path = args.template or config.get("template")
template_text = None
if template_path:
template_text = read_template_file(template_path)
return template_text
def search_mode(args: "Namespace", journal: "Journal", **kwargs) -> None:
""" """
Search for entries in a journal, then either: Search for entries in a journal, and return the
1. Send them to configured editor for user manipulation (and also results. If no search args, then return all results
change their timestamps if requested)
2. Change their timestamps
2. Delete them (with confirmation for each entry)
3. Display them (with formatting options)
""" """
kwargs = { logging.debug("Search mode: starting")
**kwargs,
"args": args,
"journal": journal,
"old_entries": journal.entries,
}
if _has_search_args(args): # If no search args, then return all results (don't filter anything)
_filter_journal_entries(**kwargs) if not _has_search_args(args) and not _has_display_args(args) and not args.text:
_print_entries_found_count(len(journal), args) logging.debug("Search mode: has no search args")
# Where do the search results go?
if args.edit:
# If we want to both edit and change time in one action
if args.change_time:
# Generate a new list instead of assigning so it won't be
# modified by _change_time_search_results
selected_entries = [e for e in journal.entries]
no_change_time_prompt = len(journal.entries) == 1
_change_time_search_results(no_prompt=no_change_time_prompt, **kwargs)
# Re-filter the journal enties (_change_time_search_results
# puts the filtered entries back); use selected_entries
# instead of running _search_journal again, because times
# have changed since the original search
kwargs["old_entries"] = journal.entries
journal.entries = selected_entries
_edit_search_results(**kwargs)
elif not journal:
# Bail out if there are no entries and we're not editing
return return
elif args.change_time: logging.debug("Search mode: has search args")
_change_time_search_results(**kwargs) _filter_journal_entries(args, journal)
elif args.delete:
_delete_search_results(**kwargs)
else:
_display_search_results(**kwargs)
def _write_in_editor(config, template=None): def _write_in_editor(config: dict, prepopulated_text: str | None = None) -> str:
if config["editor"]: if config["editor"]:
logging.debug("Write mode: opening editor") logging.debug("Append mode: opening editor")
if not template: raw = get_text_from_editor(config, prepopulated_text)
template = _get_editor_template(config)
raw = get_text_from_editor(config, template)
else: else:
raw = get_text_from_stdin() raw = get_text_from_stdin()
return raw return raw
def _get_editor_template(config, **kwargs): def _filter_journal_entries(args: "Namespace", journal: "Journal", **kwargs) -> None:
logging.debug("Write mode: loading template for entry")
if not config["template"]:
logging.debug("Write mode: no template configured")
return ""
template_path = expand_path(config["template"])
try:
template = open(template_path).read()
logging.debug("Write mode: template loaded: %s", template)
except OSError:
logging.error("Write mode: template not loaded")
raise JrnlException(
Message(
MsgText.CantReadTemplate,
MsgStyle.ERROR,
{"template": template_path},
)
)
return template
def _has_search_args(args):
return any(
(
args.on_date,
args.today_in_history,
args.text,
args.month,
args.day,
args.year,
args.start_date,
args.end_date,
args.strict,
args.starred,
args.excluded,
args.contains,
args.limit,
)
)
def _filter_journal_entries(args, journal, **kwargs):
"""Filter journal entries in-place based upon search args""" """Filter journal entries in-place based upon search args"""
if args.on_date: if args.on_date:
args.start_date = args.end_date = args.on_date args.start_date = args.end_date = args.on_date
@ -290,13 +240,17 @@ def _filter_journal_entries(args, journal, **kwargs):
end_date=args.end_date, end_date=args.end_date,
strict=args.strict, strict=args.strict,
starred=args.starred, starred=args.starred,
tagged=args.tagged,
exclude=args.excluded, exclude=args.excluded,
exclude_starred=args.exclude_starred,
exclude_tagged=args.exclude_tagged,
contains=args.contains, contains=args.contains,
) )
journal.limit(args.limit) journal.limit(args.limit)
def _print_entries_found_count(count, args): def _print_entries_found_count(count: int, args: "Namespace") -> None:
logging.debug(f"count: {count}")
if count == 0: if count == 0:
if args.edit or args.change_time: if args.edit or args.change_time:
print_msg(Message(MsgText.NothingToModify, MsgStyle.WARNING)) print_msg(Message(MsgText.NothingToModify, MsgStyle.WARNING))
@ -304,25 +258,27 @@ def _print_entries_found_count(count, args):
print_msg(Message(MsgText.NothingToDelete, MsgStyle.WARNING)) print_msg(Message(MsgText.NothingToDelete, MsgStyle.WARNING))
else: else:
print_msg(Message(MsgText.NoEntriesFound, MsgStyle.NORMAL)) print_msg(Message(MsgText.NoEntriesFound, MsgStyle.NORMAL))
elif args.limit:
# Don't show count if the user expects a limited number of results
return return
elif args.edit or not (args.change_time or args.delete): elif args.limit and args.limit == count:
# Don't show count if we are ONLY changing the time or deleting entries # Don't show count if the user expects a limited number of results
my_msg = ( logging.debug("args.limit is true-ish")
MsgText.EntryFoundCountSingular return
if count == 1
else MsgText.EntryFoundCountPlural logging.debug("Printing general summary")
) my_msg = (
print_msg(Message(my_msg, MsgStyle.NORMAL, {"num": count})) MsgText.EntryFoundCountSingular if count == 1 else MsgText.EntryFoundCountPlural
)
print_msg(Message(my_msg, MsgStyle.NORMAL, {"num": count}))
def _other_entries(journal, entries): def _other_entries(journal: "Journal", entries: list["Entry"]) -> list["Entry"]:
"""Find entries that are not in journal""" """Find entries that are not in journal"""
return [e for e in entries if e not in journal.entries] return [e for e in entries if e not in journal.entries]
def _edit_search_results(config, journal, old_entries, **kwargs): def _edit_search_results(
config: dict, journal: "Journal", old_entries: list["Entry"], **kwargs
) -> None:
""" """
1. Send the given journal entries to the user-configured editor 1. Send the given journal entries to the user-configured editor
2. Print out stats on any modifications to journal 2. Print out stats on any modifications to journal
@ -340,15 +296,18 @@ def _edit_search_results(config, journal, old_entries, **kwargs):
# separate entries we are not editing # separate entries we are not editing
other_entries = _other_entries(journal, old_entries) other_entries = _other_entries(journal, old_entries)
# Get stats now for summary later
old_stats = _get_predit_stats(journal)
# Send user to the editor # Send user to the editor
edited = get_text_from_editor(config, journal.editable_str()) try:
journal.parse_editable_str(edited) edited = get_text_from_editor(config, journal.editable_str())
except JrnlException as e:
if e.has_message_text(MsgText.NoTextReceived):
raise JrnlException(
Message(MsgText.NoEditsReceivedJournalNotDeleted, MsgStyle.WARNING)
)
else:
raise e
# Print summary if available journal.parse_editable_str(edited)
_print_edited_summary(journal, old_stats)
# Put back entries we separated earlier, sort, and write the journal # Put back entries we separated earlier, sort, and write the journal
journal.entries += other_entries journal.entries += other_entries
@ -356,13 +315,8 @@ def _edit_search_results(config, journal, old_entries, **kwargs):
journal.write() journal.write()
def _print_edited_summary(journal, old_stats, **kwargs): def _print_changed_counts(journal: "Journal", **kwargs) -> None:
stats = { stats = journal.get_change_counts()
"added": len(journal) - old_stats["count"],
"deleted": old_stats["count"] - len(journal),
"modified": len([e for e in journal.entries if e.modified]),
}
stats["modified"] -= stats["added"]
msgs = [] msgs = []
if stats["added"] > 0: if stats["added"] > 0:
@ -395,44 +349,46 @@ def _print_edited_summary(journal, old_stats, **kwargs):
print_msgs(msgs) print_msgs(msgs)
def _get_predit_stats(journal): def _get_predit_stats(journal: "Journal") -> dict[str, int]:
return {"count": len(journal)} return {"count": len(journal)}
def _delete_search_results(journal, old_entries, **kwargs): def _delete_search_results(
journal: "Journal", old_entries: list["Entry"], **kwargs
) -> None:
entries_to_delete = journal.prompt_action_entries(MsgText.DeleteEntryQuestion) entries_to_delete = journal.prompt_action_entries(MsgText.DeleteEntryQuestion)
journal.entries = old_entries
if entries_to_delete: if entries_to_delete:
journal.entries = old_entries
journal.delete_entries(entries_to_delete) journal.delete_entries(entries_to_delete)
journal.write() journal.write()
def _change_time_search_results(args, journal, old_entries, no_prompt=False, **kwargs): def _change_time_search_results(
args: "Namespace",
journal: "Journal",
old_entries: list["Entry"],
no_prompt: bool = False,
**kwargs,
) -> None:
# separate entries we are not editing # separate entries we are not editing
other_entries = _other_entries(journal, old_entries) # @todo if there's only 1, don't prompt
entries_to_change = journal.prompt_action_entries(MsgText.ChangeTimeEntryQuestion)
if no_prompt:
entries_to_change = journal.entries
else:
entries_to_change = journal.prompt_action_entries(
MsgText.ChangeTimeEntryQuestion
)
if entries_to_change: if entries_to_change:
other_entries += [e for e in journal.entries if e not in entries_to_change]
journal.entries = entries_to_change
date = time.parse(args.change_time) date = time.parse(args.change_time)
journal.change_date_entries(date) journal.entries = old_entries
journal.change_date_entries(date, entries_to_change)
journal.entries += other_entries
journal.sort()
journal.write() journal.write()
def _display_search_results(args, journal, **kwargs): def _display_search_results(args: "Namespace", journal: "Journal", **kwargs) -> None:
if len(journal) == 0:
return
# Get export format from config file if not provided at the command line # Get export format from config file if not provided at the command line
args.export = args.export or kwargs["config"].get("display_format") args.export = args.export or kwargs["config"].get("display_format")
@ -450,3 +406,50 @@ def _display_search_results(args, journal, **kwargs):
print(exporter.export(journal, args.filename)) print(exporter.export(journal, args.filename))
else: else:
print(journal.pprint()) print(journal.pprint())
def _has_search_args(args: "Namespace") -> bool:
"""Looking for arguments that filter a journal"""
return any(
(
args.contains,
args.tagged,
args.excluded,
args.exclude_starred,
args.exclude_tagged,
args.end_date,
args.today_in_history,
args.month,
args.day,
args.year,
args.limit,
args.on_date,
args.starred,
args.start_date,
args.strict, # -and
)
)
def _has_action_args(args: "Namespace") -> bool:
return any(
(
args.change_time,
args.delete,
args.edit,
)
)
def _has_display_args(args: "Namespace") -> bool:
return any(
(
args.tags,
args.short,
args.export, # --format
)
)
def _has_only_tags(tag_symbols: str, args_text: str) -> bool:
return all(word[0] in tag_symbols for word in " ".join(args_text).split())

View file

@ -1,4 +1,4 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
import logging import logging
@ -15,9 +15,11 @@ from jrnl.messages import MsgText
from jrnl.os_compat import on_windows from jrnl.os_compat import on_windows
from jrnl.os_compat import split_args from jrnl.os_compat import split_args
from jrnl.output import print_msg from jrnl.output import print_msg
from jrnl.path import absolute_path
from jrnl.path import get_templates_path
def get_text_from_editor(config, template=""): def get_text_from_editor(config: dict, template: str = "") -> str:
suffix = ".jrnl" suffix = ".jrnl"
if config["template"]: if config["template"]:
template_filename = Path(config["template"]).name template_filename = Path(config["template"]).name
@ -50,15 +52,15 @@ def get_text_from_editor(config, template=""):
return raw return raw
def get_text_from_stdin(): def get_text_from_stdin() -> str:
print_msg( print_msg(
Message( Message(
MsgText.WritingEntryStart, MsgText.WritingEntryStart,
MsgStyle.TITLE, MsgStyle.TITLE,
{ {
"how_to_quit": MsgText.HowToQuitWindows "how_to_quit": (
if on_windows() MsgText.HowToQuitWindows if on_windows() else MsgText.HowToQuitLinux
else MsgText.HowToQuitLinux )
}, },
) )
) )
@ -66,10 +68,54 @@ def get_text_from_stdin():
try: try:
raw = sys.stdin.read() raw = sys.stdin.read()
except KeyboardInterrupt: except KeyboardInterrupt:
logging.error("Write mode: keyboard interrupt") logging.error("Append mode: keyboard interrupt")
raise JrnlException( raise JrnlException(
Message(MsgText.KeyboardInterruptMsg, MsgStyle.ERROR_ON_NEW_LINE), Message(MsgText.KeyboardInterruptMsg, MsgStyle.ERROR_ON_NEW_LINE),
Message(MsgText.JournalNotSaved, MsgStyle.WARNING), Message(MsgText.JournalNotSaved, MsgStyle.WARNING),
) )
return raw return raw
def get_template_path(template_path: str, jrnl_template_dir: str) -> str:
actual_template_path = os.path.join(jrnl_template_dir, template_path)
if not os.path.exists(actual_template_path):
logging.debug(
f"Couldn't open {actual_template_path}. "
"Treating template path like a local / abs path."
)
actual_template_path = absolute_path(template_path)
return actual_template_path
def read_template_file(template_path: str) -> str:
"""
Reads the template file given a template path in this order:
* Check $XDG_DATA_HOME/jrnl/templates/template_path.
* Check template_arg as an absolute / relative path.
If a file is found, its contents are returned as a string.
If not, a JrnlException is raised.
"""
jrnl_template_dir = get_templates_path()
actual_template_path = get_template_path(template_path, jrnl_template_dir)
try:
with open(actual_template_path, encoding="utf-8") as f:
template_data = f.read()
return template_data
except FileNotFoundError:
raise JrnlException(
Message(
MsgText.CantReadTemplate,
MsgStyle.ERROR,
{
"template_path": template_path,
"actual_template_path": actual_template_path,
"jrnl_template_dir": str(jrnl_template_dir) + os.sep,
},
)
)

View file

@ -0,0 +1,53 @@
# Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html
import logging
from abc import ABC
from abc import abstractmethod
from jrnl.exception import JrnlException
from jrnl.messages import Message
from jrnl.messages import MsgStyle
from jrnl.messages import MsgText
class BaseEncryption(ABC):
def __init__(self, journal_name: str, config: dict):
logging.debug("start")
self._encoding: str = "utf-8"
self._journal_name: str = journal_name
self._config: dict = config
def clear(self) -> None:
pass
def encrypt(self, text: str) -> bytes:
logging.debug("encrypting")
return self._encrypt(text)
def decrypt(self, text: bytes) -> str:
logging.debug("decrypting")
if (result := self._decrypt(text)) is None:
raise JrnlException(
Message(MsgText.DecryptionFailedGeneric, MsgStyle.ERROR)
)
return result
@abstractmethod
def _encrypt(self, text: str) -> bytes:
"""
This is needed because self.decrypt might need
to perform actions (e.g. prompt for password)
before actually encrypting.
"""
pass
@abstractmethod
def _decrypt(self, text: bytes) -> str | None:
"""
This is needed because self.decrypt might need
to perform actions (e.g. prompt for password)
before actually decrypting.
"""
pass

View file

@ -0,0 +1,8 @@
# Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html
from .BaseEncryption import BaseEncryption
class BaseKeyEncryption(BaseEncryption):
pass

View file

@ -0,0 +1,82 @@
# Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html
import logging
from jrnl.encryption.BaseEncryption import BaseEncryption
from jrnl.exception import JrnlException
from jrnl.keyring import get_keyring_password
from jrnl.messages import Message
from jrnl.messages import MsgStyle
from jrnl.messages import MsgText
from jrnl.prompt import create_password
from jrnl.prompt import prompt_password
class BasePasswordEncryption(BaseEncryption):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
logging.debug("start")
self._attempts: int = 0
self._max_attempts: int = 3
self._password: str = ""
self._check_keyring: bool = True
@property
def check_keyring(self) -> bool:
return self._check_keyring
@check_keyring.setter
def check_keyring(self, value: bool) -> None:
self._check_keyring = value
@property
def password(self) -> str | None:
return self._password
@password.setter
def password(self, value: str) -> None:
self._password = value
def clear(self):
self.password = None
self.check_keyring = False
def encrypt(self, text: str) -> bytes:
logging.debug("encrypting")
if not self.password:
if self.check_keyring and (
keyring_pw := get_keyring_password(self._journal_name)
):
self.password = keyring_pw
if not self.password:
self.password = create_password(self._journal_name)
return self._encrypt(text)
def decrypt(self, text: bytes) -> str:
logging.debug("decrypting")
if not self.password:
if self.check_keyring and (
keyring_pw := get_keyring_password(self._journal_name)
):
self.password = keyring_pw
if not self.password:
self._prompt_password()
while (result := self._decrypt(text)) is None:
self._prompt_password()
return result
def _prompt_password(self) -> None:
if self._attempts >= self._max_attempts:
raise JrnlException(
Message(MsgText.PasswordMaxTriesExceeded, MsgStyle.ERROR)
)
first_try = self._attempts == 0
self.password = prompt_password(first_try=first_try)
self._attempts += 1

View file

@ -0,0 +1,42 @@
# Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html
import hashlib
import logging
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import padding
from cryptography.hazmat.primitives.ciphers import Cipher
from cryptography.hazmat.primitives.ciphers import algorithms
from cryptography.hazmat.primitives.ciphers import modes
from jrnl.encryption.BasePasswordEncryption import BasePasswordEncryption
class Jrnlv1Encryption(BasePasswordEncryption):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
logging.debug("start")
def _encrypt(self, _: str) -> bytes:
raise NotImplementedError
def _decrypt(self, text: bytes) -> str | None:
logging.debug("decrypting")
iv, cipher = text[:16], text[16:]
password = self._password or ""
decryption_key = hashlib.sha256(password.encode(self._encoding)).digest()
decryptor = Cipher(
algorithms.AES(decryption_key), modes.CBC(iv), default_backend()
).decryptor()
try:
plain_padded = decryptor.update(cipher) + decryptor.finalize()
if plain_padded[-1] in (" ", 32):
# Ancient versions of jrnl. Do not judge me.
return plain_padded.decode(self._encoding).rstrip(" ")
else:
unpadder = padding.PKCS7(algorithms.AES.block_size).unpadder()
plain = unpadder.update(plain_padded) + unpadder.finalize()
return plain.decode(self._encoding)
except ValueError:
return None

View file

@ -0,0 +1,59 @@
# Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html
import base64
import logging
from cryptography.fernet import Fernet
from cryptography.fernet import InvalidToken
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
from .BasePasswordEncryption import BasePasswordEncryption
class Jrnlv2Encryption(BasePasswordEncryption):
def __init__(self, *args, **kwargs) -> None:
# Salt is hard-coded
self._salt: bytes = b"\xf2\xd5q\x0e\xc1\x8d.\xde\xdc\x8e6t\x89\x04\xce\xf8"
self._key: bytes = b""
super().__init__(*args, **kwargs)
logging.debug("start")
@property
def password(self):
return self._password
@password.setter
def password(self, value: str | None):
self._password = value
self._make_key()
def _make_key(self) -> None:
if self._password is None:
# Password was removed after being set
self._key = None
return
password = self.password.encode(self._encoding)
kdf = PBKDF2HMAC(
algorithm=hashes.SHA256(),
length=32,
salt=self._salt,
iterations=100_000,
backend=default_backend(),
)
key = kdf.derive(password)
self._key = base64.urlsafe_b64encode(key)
def _encrypt(self, text: str) -> bytes:
logging.debug("encrypting")
return Fernet(self._key).encrypt(text.encode(self._encoding))
def _decrypt(self, text: bytes) -> str | None:
logging.debug("decrypting")
try:
return Fernet(self._key).decrypt(text).decode(self._encoding)
except (InvalidToken, IndexError):
return None

View file

@ -0,0 +1,20 @@
# Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html
import logging
from jrnl.encryption.BaseEncryption import BaseEncryption
class NoEncryption(BaseEncryption):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
logging.debug("start")
def _encrypt(self, text: str) -> bytes:
logging.debug("encrypting")
return text.encode(self._encoding)
def _decrypt(self, text: bytes) -> str:
logging.debug("decrypting")
return text.decode(self._encoding)

View file

@ -0,0 +1,36 @@
# Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html
from enum import Enum
from importlib import import_module
from typing import TYPE_CHECKING
from typing import Type
if TYPE_CHECKING:
from .BaseEncryption import BaseEncryption
class EncryptionMethods(str, Enum):
def __str__(self) -> str:
return self.value
NONE = "NoEncryption"
JRNLV1 = "Jrnlv1Encryption"
JRNLV2 = "Jrnlv2Encryption"
def determine_encryption_method(config: str | bool) -> Type["BaseEncryption"]:
ENCRYPTION_METHODS = {
True: EncryptionMethods.JRNLV2, # the default
False: EncryptionMethods.NONE,
"jrnlv1": EncryptionMethods.JRNLV1,
"jrnlv2": EncryptionMethods.JRNLV2,
}
key = config
if isinstance(config, str):
key = config.lower()
my_class = ENCRYPTION_METHODS[key]
return getattr(import_module(f"jrnl.encryption.{my_class}"), my_class)

View file

@ -1,16 +1,24 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
from jrnl.messages import Message from typing import TYPE_CHECKING
from jrnl.output import print_msg from jrnl.output import print_msg
if TYPE_CHECKING:
from jrnl.messages import Message
from jrnl.messages import MsgText
class JrnlException(Exception): class JrnlException(Exception):
"""Common exceptions raised by jrnl.""" """Common exceptions raised by jrnl."""
def __init__(self, *messages: Message): def __init__(self, *messages: "Message"):
self.messages = messages self.messages = messages
def print(self) -> None: def print(self) -> None:
for msg in self.messages: for msg in self.messages:
print_msg(msg) print_msg(msg)
def has_message_text(self, message_text: "MsgText"):
return any([m.text == message_text for m in self.messages])

View file

@ -1,13 +1,18 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
import contextlib
import glob import glob
import logging import logging
import os import os
import sys import sys
from rich.pretty import pretty_repr
from jrnl import __version__
from jrnl.config import DEFAULT_JOURNAL_KEY from jrnl.config import DEFAULT_JOURNAL_KEY
from jrnl.config import get_config_path from jrnl.config import get_config_path
from jrnl.config import get_default_colors
from jrnl.config import get_default_config from jrnl.config import get_default_config
from jrnl.config import get_default_journal_path from jrnl.config import get_default_journal_path
from jrnl.config import load_config from jrnl.config import load_config
@ -25,16 +30,24 @@ from jrnl.prompt import yesno
from jrnl.upgrade import is_old_version from jrnl.upgrade import is_old_version
def upgrade_config(config_data, alt_config_path=None): def upgrade_config(config_data: dict, alt_config_path: str | None = None) -> None:
"""Checks if there are keys missing in a given config dict, and if so, updates the config file accordingly. """Checks if there are keys missing in a given config dict, and if so, updates the
This essentially automatically ports jrnl installations if new config parameters are introduced in later config file accordingly. This essentially automatically ports jrnl installations
versions. if new config parameters are introduced in later versions. Also checks for
existence of and difference in version number between config dict
and current jrnl version, and if so, update the config file accordingly.
Supply alt_config_path if using an alternate config through --config-file.""" Supply alt_config_path if using an alternate config through --config-file."""
default_config = get_default_config() default_config = get_default_config()
missing_keys = set(default_config).difference(config_data) missing_keys = set(default_config).difference(config_data)
if missing_keys: if missing_keys:
for key in missing_keys: for key in missing_keys:
config_data[key] = default_config[key] config_data[key] = default_config[key]
different_version = config_data["version"] != __version__
if different_version:
config_data["version"] = __version__
if missing_keys or different_version:
save_config(config_data, alt_config_path) save_config(config_data, alt_config_path)
config_path = alt_config_path if alt_config_path else get_config_path() config_path = alt_config_path if alt_config_path else get_config_path()
print_msg( print_msg(
@ -44,7 +57,7 @@ def upgrade_config(config_data, alt_config_path=None):
) )
def find_default_config(): def find_default_config() -> str:
config_path = ( config_path = (
get_config_path() get_config_path()
if os.path.exists(get_config_path()) if os.path.exists(get_config_path())
@ -53,7 +66,7 @@ def find_default_config():
return config_path return config_path
def find_alt_config(alt_config): def find_alt_config(alt_config: str) -> str:
if not os.path.exists(alt_config): if not os.path.exists(alt_config):
raise JrnlException( raise JrnlException(
Message( Message(
@ -64,7 +77,7 @@ def find_alt_config(alt_config):
return alt_config return alt_config
def load_or_install_jrnl(alt_config_path): def load_or_install_jrnl(alt_config_path: str) -> dict:
""" """
If jrnl is already installed, loads and returns a default config object. If jrnl is already installed, loads and returns a default config object.
If alternate config is specified via --config-file flag, it will be used. If alternate config is specified via --config-file flag, it will be used.
@ -101,11 +114,11 @@ def load_or_install_jrnl(alt_config_path):
logging.debug("Configuration file not found, installing jrnl...") logging.debug("Configuration file not found, installing jrnl...")
config = install() config = install()
logging.debug('Using configuration "%s"', config) logging.debug('Using configuration:\n"%s"', pretty_repr(config))
return config return config
def install(): def install() -> dict:
_initialize_autocomplete() _initialize_autocomplete()
# Where to create the journal? # Where to create the journal?
@ -122,14 +135,12 @@ def install():
) )
journal_path = absolute_path(user_given_path or default_journal_path) journal_path = absolute_path(user_given_path or default_journal_path)
default_config = get_default_config() default_config = get_default_config()
default_config["journals"][DEFAULT_JOURNAL_KEY] = journal_path default_config["journals"][DEFAULT_JOURNAL_KEY]["journal"] = journal_path
# If the folder doesn't exist, create it # If the folder doesn't exist, create it
path = os.path.split(default_config["journals"][DEFAULT_JOURNAL_KEY])[0] path = os.path.split(journal_path)[0]
try: with contextlib.suppress(OSError):
os.makedirs(path) os.makedirs(path)
except OSError:
pass
# Encrypt it? # Encrypt it?
encrypt = yesno(Message(MsgText.EncryptJournalQuestion), default=False) encrypt = yesno(Message(MsgText.EncryptJournalQuestion), default=False)
@ -137,12 +148,26 @@ def install():
default_config["encrypt"] = True default_config["encrypt"] = True
print_msg(Message(MsgText.JournalEncrypted, MsgStyle.NORMAL)) print_msg(Message(MsgText.JournalEncrypted, MsgStyle.NORMAL))
# Use colors?
use_colors = yesno(Message(MsgText.UseColorsQuestion), default=True)
if use_colors:
default_config["colors"] = get_default_colors()
save_config(default_config) save_config(default_config)
print_msg(
Message(
MsgText.InstallComplete,
MsgStyle.NORMAL,
params={"config_path": get_config_path()},
)
)
return default_config return default_config
def _initialize_autocomplete(): def _initialize_autocomplete() -> None:
# readline is not included in Windows Active Python and perhaps some other distributions # readline is not included in Windows Active Python and perhaps some other distss
if sys.modules.get("readline"): if sys.modules.get("readline"):
import readline import readline
@ -151,7 +176,7 @@ def _initialize_autocomplete():
readline.set_completer(_autocomplete_path) readline.set_completer(_autocomplete_path)
def _autocomplete_path(text, state): def _autocomplete_path(text: str, state: int) -> list[str | None]:
expansions = glob.glob(expand_path(text) + "*") expansions = glob.glob(expand_path(text) + "*")
expansions = [e + "/" if os.path.isdir(e) else e for e in expansions] expansions = [e + "/" if os.path.isdir(e) else e for e in expansions]
expansions.append(None) expansions.append(None)

View file

@ -1,6 +1,7 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
import contextlib
import datetime import datetime
import fnmatch import fnmatch
import os import os
@ -16,13 +17,14 @@ from xml.parsers.expat import ExpatError
import tzlocal import tzlocal
from jrnl import Entry
from jrnl import Journal
from jrnl import __title__ from jrnl import __title__
from jrnl import __version__ from jrnl import __version__
from .Entry import Entry
from .Journal import Journal
class DayOne(Journal.Journal):
class DayOne(Journal):
"""A special Journal handling DayOne files""" """A special Journal handling DayOne files"""
# InvalidFileException was added to plistlib in Python3.4 # InvalidFileException was added to plistlib in Python3.4
@ -38,7 +40,7 @@ class DayOne(Journal.Journal):
self.can_be_encrypted = False self.can_be_encrypted = False
super().__init__(**kwargs) super().__init__(**kwargs)
def open(self): def open(self) -> "DayOne":
filenames = [] filenames = []
for root, dirnames, f in os.walk(self.config["journal"]): for root, dirnames, f in os.walk(self.config["journal"]):
for filename in fnmatch.filter(f, "*.doentry"): for filename in fnmatch.filter(f, "*.doentry"):
@ -62,7 +64,7 @@ class DayOne(Journal.Journal):
if timezone.key != "UTC": if timezone.key != "UTC":
date = date.replace(fold=1) + timezone.utcoffset(date) date = date.replace(fold=1) + timezone.utcoffset(date)
entry = Entry.Entry( entry = Entry(
self, self,
date, date,
text=dict_entry["Entry Text"], text=dict_entry["Entry Text"],
@ -73,47 +75,32 @@ class DayOne(Journal.Journal):
self.config["tagsymbols"][0] + tag.lower() self.config["tagsymbols"][0] + tag.lower()
for tag in dict_entry.get("Tags", []) for tag in dict_entry.get("Tags", [])
] ]
if entry._tags:
entry._tags.sort()
"""Extended DayOne attributes""" """Extended DayOne attributes"""
try: # just ignore it if the keys don't exist
with contextlib.suppress(KeyError):
entry.creator_device_agent = dict_entry["Creator"][ entry.creator_device_agent = dict_entry["Creator"][
"Device Agent" "Device Agent"
] ]
except: # noqa: E722
pass
try:
entry.creator_generation_date = dict_entry["Creator"][
"Generation Date"
]
except: # noqa: E722
entry.creator_generation_date = date
try:
entry.creator_host_name = dict_entry["Creator"]["Host Name"] entry.creator_host_name = dict_entry["Creator"]["Host Name"]
except: # noqa: E722
pass
try:
entry.creator_os_agent = dict_entry["Creator"]["OS Agent"] entry.creator_os_agent = dict_entry["Creator"]["OS Agent"]
except: # noqa: E722
pass
try:
entry.creator_software_agent = dict_entry["Creator"][ entry.creator_software_agent = dict_entry["Creator"][
"Software Agent" "Software Agent"
] ]
except: # noqa: E722
pass
try:
entry.location = dict_entry["Location"] entry.location = dict_entry["Location"]
except: # noqa: E722
pass
try:
entry.weather = dict_entry["Weather"] entry.weather = dict_entry["Weather"]
except: # noqa: E722
pass entry.creator_generation_date = dict_entry.get("Creator", {}).get(
"Generation Date", date
)
self.entries.append(entry) self.entries.append(entry)
self.sort() self.sort()
return self return self
def write(self): def write(self) -> None:
"""Writes only the entries that have been modified into plist files.""" """Writes only the entries that have been modified into plist files."""
for entry in self.entries: for entry in self.entries:
if entry.modified: if entry.modified:
@ -177,20 +164,20 @@ class DayOne(Journal.Journal):
) )
os.remove(filename) os.remove(filename)
def editable_str(self): def editable_str(self) -> str:
"""Turns the journal into a string of entries that can be edited """Turns the journal into a string of entries that can be edited
manually and later be parsed with eslf.parse_editable_str.""" manually and later be parsed with eslf.parse_editable_str."""
return "\n".join([f"{str(e)}\n# {e.uuid}\n" for e in self.entries]) return "\n".join([f"{str(e)}\n# {e.uuid}\n" for e in self.entries])
def _update_old_entry(self, entry, new_entry): def _update_old_entry(self, entry: Entry, new_entry: Entry) -> None:
for attr in ("title", "body", "date"): for attr in ("title", "body", "date", "tags"):
old_attr = getattr(entry, attr) old_attr = getattr(entry, attr)
new_attr = getattr(new_entry, attr) new_attr = getattr(new_entry, attr)
if old_attr != new_attr: if old_attr != new_attr:
entry.modified = True entry.modified = True
setattr(entry, attr, new_attr) setattr(entry, attr, new_attr)
def _get_and_remove_uuid_from_entry(self, entry): def _get_and_remove_uuid_from_entry(self, entry: Entry) -> Entry:
uuid_regex = "^ *?# ([a-zA-Z0-9]+) *?$" uuid_regex = "^ *?# ([a-zA-Z0-9]+) *?$"
m = re.search(uuid_regex, entry.body, re.MULTILINE) m = re.search(uuid_regex, entry.body, re.MULTILINE)
entry.uuid = m.group(1) if m else None entry.uuid = m.group(1) if m else None
@ -201,7 +188,7 @@ class DayOne(Journal.Journal):
return entry return entry
def parse_editable_str(self, edited): def parse_editable_str(self, edited: str) -> None:
"""Parses the output of self.editable_str and updates its entries.""" """Parses the output of self.editable_str and updates its entries."""
# Method: create a new list of entries from the edited text, then match # Method: create a new list of entries from the edited text, then match
# UUIDs of the new entries against self.entries, updating the entries # UUIDs of the new entries against self.entries, updating the entries
@ -211,6 +198,8 @@ class DayOne(Journal.Journal):
for entry in entries_from_editor: for entry in entries_from_editor:
entry = self._get_and_remove_uuid_from_entry(entry) entry = self._get_and_remove_uuid_from_entry(entry)
if entry._tags:
entry._tags.sort()
# Remove deleted entries # Remove deleted entries
edited_uuids = [e.uuid for e in entries_from_editor] edited_uuids = [e.uuid for e in entries_from_editor]
@ -220,5 +209,11 @@ class DayOne(Journal.Journal):
for entry in entries_from_editor: for entry in entries_from_editor:
for old_entry in self.entries: for old_entry in self.entries:
if entry.uuid == old_entry.uuid: if entry.uuid == old_entry.uuid:
if old_entry._tags:
tags_not_in_body = [
tag for tag in old_entry._tags if (tag not in entry._body)
]
if tags_not_in_body:
entry._tags.extend(tags_not_in_body.sort())
self._update_old_entry(old_entry, entry) self._update_old_entry(old_entry, entry)
break break

View file

@ -1,19 +1,28 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
import datetime import datetime
import logging import logging
import os import os
import re import re
from typing import TYPE_CHECKING
import ansiwrap from jrnl.color import colorize
from jrnl.color import highlight_tags_with_background_color
from jrnl.output import wrap_with_ansi_colors
from .color import colorize if TYPE_CHECKING:
from .color import highlight_tags_with_background_color from .Journal import Journal
class Entry: class Entry:
def __init__(self, journal, date=None, text="", starred=False): def __init__(
self,
journal: "Journal",
date: datetime.datetime | None = None,
text: str = "",
starred: bool = False,
):
self.journal = journal # Reference to journal mainly to access its config self.journal = journal # Reference to journal mainly to access its config
self.date = date or datetime.datetime.now() self.date = date or datetime.datetime.now()
self.text = text self.text = text
@ -24,7 +33,7 @@ class Entry:
self.modified = False self.modified = False
@property @property
def fulltext(self): def fulltext(self) -> str:
return self.title + " " + self.body return self.title + " " + self.body
def _parse_text(self): def _parse_text(self):
@ -38,48 +47,48 @@ class Entry:
self._tags = list(self._parse_tags()) self._tags = list(self._parse_tags())
@property @property
def title(self): def title(self) -> str:
if self._title is None: if self._title is None:
self._parse_text() self._parse_text()
return self._title return self._title
@title.setter @title.setter
def title(self, x): def title(self, x: str):
self._title = x self._title = x
@property @property
def body(self): def body(self) -> str:
if self._body is None: if self._body is None:
self._parse_text() self._parse_text()
return self._body return self._body
@body.setter @body.setter
def body(self, x): def body(self, x: str):
self._body = x self._body = x
@property @property
def tags(self): def tags(self) -> list[str]:
if self._tags is None: if self._tags is None:
self._parse_text() self._parse_text()
return self._tags return self._tags
@tags.setter @tags.setter
def tags(self, x): def tags(self, x: list[str]):
self._tags = x self._tags = x
@staticmethod @staticmethod
def tag_regex(tagsymbols): def tag_regex(tagsymbols: str) -> re.Pattern:
pattern = rf"(?<!\S)([{tagsymbols}][-+*#/\w]+)" pattern = rf"(?<!\S)([{tagsymbols}][-+*#/\w]+)"
return re.compile(pattern) return re.compile(pattern)
def _parse_tags(self): def _parse_tags(self) -> set[str]:
tagsymbols = self.journal.config["tagsymbols"] tagsymbols = self.journal.config["tagsymbols"]
return { return {
tag.lower() for tag in re.findall(Entry.tag_regex(tagsymbols), self.text) tag.lower() for tag in re.findall(Entry.tag_regex(tagsymbols), self.text)
} }
def __str__(self): def __str__(self):
"""Returns a string representation of the entry to be written into a journal file.""" """Returns string representation of the entry to be written to journal file."""
date_str = self.date.strftime(self.journal.config["timeformat"]) date_str = self.date.strftime(self.journal.config["timeformat"])
title = "[{}] {}".format(date_str, self.title.rstrip("\n ")) title = "[{}] {}".format(date_str, self.title.rstrip("\n "))
if self.starred: if self.starred:
@ -90,7 +99,7 @@ class Entry:
body=self.body.rstrip("\n "), body=self.body.rstrip("\n "),
) )
def pprint(self, short=False): def pprint(self, short: bool = False) -> str:
"""Returns a pretty-printed version of the entry. """Returns a pretty-printed version of the entry.
If short is true, only print the title.""" If short is true, only print the title."""
# Handle indentation # Handle indentation
@ -119,7 +128,7 @@ class Entry:
columns = 79 columns = 79
# Color date / title and bold title # Color date / title and bold title
title = ansiwrap.fill( title = wrap_with_ansi_colors(
date_str date_str
+ " " + " "
+ highlight_tags_with_background_color( + highlight_tags_with_background_color(
@ -133,35 +142,17 @@ class Entry:
body = highlight_tags_with_background_color( body = highlight_tags_with_background_color(
self, self.body.rstrip(" \n"), self.journal.config["colors"]["body"] self, self.body.rstrip(" \n"), self.journal.config["colors"]["body"]
) )
body_text = [
colorize(
ansiwrap.fill(
line,
columns,
initial_indent=indent,
subsequent_indent=indent,
drop_whitespace=True,
),
self.journal.config["colors"]["body"],
)
or indent
for line in body.rstrip(" \n").splitlines()
]
# ansiwrap doesn't handle lines with only the "\n" character and some body = wrap_with_ansi_colors(body, columns - len(indent))
# ANSI escapes properly, so we have this hack here to make sure the if indent:
# beginning of each line has the indent character and it's colored # Without explicitly colorizing the indent character, it will lose its
# properly. textwrap doesn't have this issue, however, it doesn't wrap # color after a tag appears.
# the strings properly as it counts ANSI escapes as literal characters. body = "\n".join(
# TL;DR: I'm sorry.
body = "\n".join(
[
colorize(indent, self.journal.config["colors"]["body"]) + line colorize(indent, self.journal.config["colors"]["body"]) + line
if not ansiwrap.strip_color(line).startswith(indent) for line in body.splitlines()
else line )
for line in body_text
] body = colorize(body, self.journal.config["colors"]["body"])
)
else: else:
title = ( title = (
date_str date_str
@ -197,7 +188,7 @@ class Entry:
def __hash__(self): def __hash__(self):
return hash(self.__repr__()) return hash(self.__repr__())
def __eq__(self, other): def __eq__(self, other: "Entry"):
if ( if (
not isinstance(other, Entry) not isinstance(other, Entry)
or self.title.strip() != other.title.strip() or self.title.strip() != other.title.strip()
@ -208,7 +199,7 @@ class Entry:
return False return False
return True return True
def __ne__(self, other): def __ne__(self, other: "Entry"):
return not self.__eq__(other) return not self.__eq__(other)
@ -223,14 +214,14 @@ SENTENCE_SPLITTER = re.compile(
\s+ # AND a sequence of required spaces. \s+ # AND a sequence of required spaces.
) )
|[\uFF01\uFF0E\uFF1F\uFF61\u3002] # CJK full/half width terminals usually do not have following spaces. |[\uFF01\uFF0E\uFF1F\uFF61\u3002] # CJK full/half width terminals usually do not have following spaces.
""", """, # noqa: E501
re.VERBOSE, re.VERBOSE,
) )
SENTENCE_SPLITTER_ONLY_NEWLINE = re.compile("\n") SENTENCE_SPLITTER_ONLY_NEWLINE = re.compile("\n")
def split_title(text): def split_title(text: str) -> tuple[str, str]:
"""Splits the first sentence off from a text.""" """Splits the first sentence off from a text."""
sep = SENTENCE_SPLITTER_ONLY_NEWLINE.search(text.lstrip()) sep = SENTENCE_SPLITTER_ONLY_NEWLINE.search(text.lstrip())
if not sep: if not sep:

View file

@ -1,44 +1,49 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
import codecs import codecs
import fnmatch
import os import os
import pathlib
from typing import TYPE_CHECKING
from jrnl import Journal
from jrnl import time from jrnl import time
from .Journal import Journal
def get_files(journal_config): if TYPE_CHECKING:
"""Searches through sub directories starting with journal_config and find all text files""" from jrnl.journals import Entry
filenames = []
for root, dirnames, f in os.walk(journal_config): # glob search patterns for folder/file structure
for filename in fnmatch.filter(f, "*.txt"): DIGIT_PATTERN = "[0123456789]"
filenames.append(os.path.join(root, filename)) YEAR_PATTERN = DIGIT_PATTERN * 4
return filenames MONTH_PATTERN = "[01]" + DIGIT_PATTERN
DAY_PATTERN = "[0123]" + DIGIT_PATTERN + ".txt"
class Folder(Journal.Journal): class Folder(Journal):
"""A Journal handling multiple files in a folder""" """A Journal handling multiple files in a folder"""
def __init__(self, name="default", **kwargs): def __init__(self, name: str = "default", **kwargs):
self.entries = [] self.entries = []
self._diff_entry_dates = [] self._diff_entry_dates = []
self.can_be_encrypted = False self.can_be_encrypted = False
super().__init__(name, **kwargs) super().__init__(name, **kwargs)
def open(self): def open(self) -> "Folder":
filenames = [] filenames = []
self.entries = [] self.entries = []
filenames = get_files(self.config["journal"])
for filename in filenames: if os.path.exists(self.config["journal"]):
with codecs.open(filename, "r", "utf-8") as f: filenames = Folder._get_files(self.config["journal"])
journal = f.read() for filename in filenames:
self.entries.extend(self._parse(journal)) with codecs.open(filename, "r", "utf-8") as f:
self.sort() journal = f.read()
self.entries.extend(self._parse(journal))
self.sort()
return self return self
def write(self): def write(self) -> None:
"""Writes only the entries that have been modified into proper files.""" """Writes only the entries that have been modified into proper files."""
# Create a list of dates of modified entries. Start with diff_entry_dates # Create a list of dates of modified entries. Start with diff_entry_dates
modified_dates = self._diff_entry_dates modified_dates = self._diff_entry_dates
@ -76,29 +81,31 @@ class Folder(Journal.Journal):
journal_file.write(journal) journal_file.write(journal)
# look for and delete empty files # look for and delete empty files
filenames = [] filenames = []
filenames = get_files(self.config["journal"]) filenames = Folder._get_files(self.config["journal"])
for filename in filenames: for filename in filenames:
if os.stat(filename).st_size <= 0: if os.stat(filename).st_size <= 0:
os.remove(filename) os.remove(filename)
def delete_entries(self, entries_to_delete): def delete_entries(self, entries_to_delete: list["Entry"]) -> None:
"""Deletes specific entries from a journal.""" """Deletes specific entries from a journal."""
for entry in entries_to_delete: for entry in entries_to_delete:
self.entries.remove(entry) self.entries.remove(entry)
self._diff_entry_dates.append(entry.date) self._diff_entry_dates.append(entry.date)
self.deleted_entry_count += 1
def change_date_entries(self, date): def change_date_entries(self, date: str, entries_to_change: list["Entry"]) -> None:
"""Changes entry dates to given date.""" """Changes entry dates to given date."""
date = time.parse(date) date = time.parse(date)
self._diff_entry_dates.append(date) self._diff_entry_dates.append(date)
for entry in self.entries: for entry in entries_to_change:
self._diff_entry_dates.append(entry.date) self._diff_entry_dates.append(entry.date)
entry.date = date entry.date = date
entry.modified = True
def parse_editable_str(self, edited): def parse_editable_str(self, edited: str) -> None:
"""Parses the output of self.editable_str and updates its entries.""" """Parses the output of self.editable_str and updates its entries."""
mod_entries = self._parse(edited) mod_entries = self._parse(edited)
diff_entries = set(self.entries) - set(mod_entries) diff_entries = set(self.entries) - set(mod_entries)
@ -109,4 +116,43 @@ class Folder(Journal.Journal):
# modified and how many got deleted later. # modified and how many got deleted later.
for entry in mod_entries: for entry in mod_entries:
entry.modified = not any(entry == old_entry for old_entry in self.entries) entry.modified = not any(entry == old_entry for old_entry in self.entries)
self.increment_change_counts_by_edit(mod_entries)
self.entries = mod_entries self.entries = mod_entries
@staticmethod
def _get_files(journal_path: str) -> list[str]:
"""Searches through sub directories starting with journal_path and find all text
files that look like entries"""
for year_folder in Folder._get_year_folders(pathlib.Path(journal_path)):
for month_folder in Folder._get_month_folders(year_folder):
yield from Folder._get_day_files(month_folder)
@staticmethod
def _get_year_folders(path: pathlib.Path) -> list[pathlib.Path]:
for child in path.glob(YEAR_PATTERN):
if child.is_dir():
yield child
return
@staticmethod
def _get_month_folders(path: pathlib.Path) -> list[pathlib.Path]:
for child in path.glob(MONTH_PATTERN):
if int(child.name) > 0 and int(child.name) <= 12 and path.is_dir():
yield child
return
@staticmethod
def _get_day_files(path: pathlib.Path) -> list[str]:
for child in path.glob(DAY_PATTERN):
if (
int(child.stem) > 0
and int(child.stem) <= 31
and time.is_valid_date(
year=int(path.parent.name),
month=int(path.name),
day=int(child.stem),
)
and child.is_file()
):
yield str(child)

View file

@ -1,4 +1,4 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
import datetime import datetime
@ -6,8 +6,9 @@ import logging
import os import os
import re import re
from jrnl import Entry
from jrnl import time from jrnl import time
from jrnl.config import validate_journal_name
from jrnl.encryption import determine_encryption_method
from jrnl.messages import Message from jrnl.messages import Message
from jrnl.messages import MsgStyle from jrnl.messages import MsgStyle
from jrnl.messages import MsgText from jrnl.messages import MsgText
@ -15,6 +16,8 @@ from jrnl.output import print_msg
from jrnl.path import expand_path from jrnl.path import expand_path
from jrnl.prompt import yesno from jrnl.prompt import yesno
from .Entry import Entry
class Tag: class Tag:
def __init__(self, name, count=0): def __init__(self, name, count=0):
@ -46,6 +49,11 @@ class Journal:
self.search_tags = None # Store tags we're highlighting self.search_tags = None # Store tags we're highlighting
self.name = name self.name = name
self.entries = [] self.entries = []
self.encryption_method = None
# Track changes to journal in session. Modified is tracked in Entry
self.added_entry_count = 0
self.deleted_entry_count = 0
def __len__(self): def __len__(self):
"""Returns the number of entries""" """Returns the number of entries"""
@ -56,7 +64,7 @@ class Journal:
return (entry for entry in self.entries) return (entry for entry in self.entries)
@classmethod @classmethod
def from_journal(cls, other): def from_journal(cls, other: "Journal") -> "Journal":
"""Creates a new journal by copying configuration and entries from """Creates a new journal by copying configuration and entries from
another journal object""" another journal object"""
new_journal = cls(other.name, **other.config) new_journal = cls(other.name, **other.config)
@ -69,7 +77,7 @@ class Journal:
) )
return new_journal return new_journal
def import_(self, other_journal_txt): def import_(self, other_journal_txt: str) -> None:
imported_entries = self._parse(other_journal_txt) imported_entries = self._parse(other_journal_txt)
for entry in imported_entries: for entry in imported_entries:
entry.modified = True entry.modified = True
@ -77,8 +85,24 @@ class Journal:
self.entries = list(frozenset(self.entries) | frozenset(imported_entries)) self.entries = list(frozenset(self.entries) | frozenset(imported_entries))
self.sort() self.sort()
def open(self, filename=None): def _get_encryption_method(self) -> None:
"""Opens the journal file defined in the config and parses it into a list of Entries. encryption_method = determine_encryption_method(self.config["encrypt"])
self.encryption_method = encryption_method(self.name, self.config)
def _decrypt(self, text: bytes) -> str:
if self.encryption_method is None:
self._get_encryption_method()
return self.encryption_method.decrypt(text)
def _encrypt(self, text: str) -> bytes:
if self.encryption_method is None:
self._get_encryption_method()
return self.encryption_method.encrypt(text)
def open(self, filename: str | None = None) -> "Journal":
"""Opens the journal file and parses it into a list of Entries
Entries have the form (date, title, body).""" Entries have the form (date, title, body)."""
filename = filename or self.config["journal"] filename = filename or self.config["journal"]
dirname = os.path.dirname(filename) dirname = os.path.dirname(filename)
@ -103,43 +127,44 @@ class Journal:
}, },
) )
) )
self.write()
text = self._load(filename) text = self._load(filename)
text = self._decrypt(text)
self.entries = self._parse(text) self.entries = self._parse(text)
self.sort() self.sort()
logging.debug("opened %s with %d entries", self.__class__.__name__, len(self)) logging.debug("opened %s with %d entries", self.__class__.__name__, len(self))
return self return self
def write(self, filename=None): def write(self, filename: str | None = None) -> None:
"""Dumps the journal into the config file, overwriting it""" """Dumps the journal into the config file, overwriting it"""
filename = filename or self.config["journal"] filename = filename or self.config["journal"]
text = self._to_text() text = self._to_text()
text = self._encrypt(text)
self._store(filename, text) self._store(filename, text)
def validate_parsing(self): def validate_parsing(self) -> bool:
"""Confirms that the jrnl is still parsed correctly after being dumped to text.""" """Confirms that the jrnl is still parsed correctly after conversion to text."""
new_entries = self._parse(self._to_text()) new_entries = self._parse(self._to_text())
for i, entry in enumerate(self.entries): return all(entry == new_entries[i] for i, entry in enumerate(self.entries))
if entry != new_entries[i]:
return False
return True
@staticmethod @staticmethod
def create_file(filename): def create_file(filename: str) -> None:
with open(filename, "w"): with open(filename, "w"):
pass pass
def _to_text(self): def _to_text(self) -> str:
return "\n".join([str(e) for e in self.entries]) return "\n".join([str(e) for e in self.entries])
def _load(self, filename): def _load(self, filename: str) -> bytes:
raise NotImplementedError with open(filename, "rb") as f:
return f.read()
@classmethod def _store(self, filename: str, text: bytes) -> None:
def _store(filename, text): with open(filename, "wb") as f:
raise NotImplementedError f.write(text)
def _parse(self, journal_txt): def _parse(self, journal_txt: str) -> list[Entry]:
"""Parses a journal that's stored in a string and returns a list of entries""" """Parses a journal that's stored in a string and returns a list of entries"""
# Return empty array if the journal is blank # Return empty array if the journal is blank
@ -165,11 +190,11 @@ class Journal:
if entries: if entries:
entries[-1].text = journal_txt[last_entry_pos : match.start()] entries[-1].text = journal_txt[last_entry_pos : match.start()]
last_entry_pos = match.end() last_entry_pos = match.end()
entries.append(Entry.Entry(self, date=new_date)) entries.append(Entry(self, date=new_date))
# If no entries were found, treat all the existing text as an entry made now # If no entries were found, treat all the existing text as an entry made now
if not entries: if not entries:
entries.append(Entry.Entry(self, date=time.parse("now"))) entries.append(Entry(self, date=time.parse("now")))
# Fill in the text of the last entry # Fill in the text of the last entry
entries[-1].text = journal_txt[last_entry_pos:] entries[-1].text = journal_txt[last_entry_pos:]
@ -178,7 +203,7 @@ class Journal:
entry._parse_text() entry._parse_text()
return entries return entries
def pprint(self, short=False): def pprint(self, short: bool = False) -> str:
"""Prettyprints the journal's entries""" """Prettyprints the journal's entries"""
return "\n".join([e.pprint(short=short) for e in self.entries]) return "\n".join([e.pprint(short=short) for e in self.entries])
@ -188,20 +213,21 @@ class Journal:
def __repr__(self): def __repr__(self):
return f"<Journal with {len(self.entries)} entries>" return f"<Journal with {len(self.entries)} entries>"
def sort(self): def sort(self) -> None:
"""Sorts the Journal's entries by date""" """Sorts the Journal's entries by date"""
self.entries = sorted(self.entries, key=lambda entry: entry.date) self.entries = sorted(self.entries, key=lambda entry: entry.date)
def limit(self, n=None): def limit(self, n: int | None = None) -> None:
"""Removes all but the last n entries""" """Removes all but the last n entries"""
if n: if n:
self.entries = self.entries[-n:] self.entries = self.entries[-n:]
@property @property
def tags(self): def tags(self) -> list[Tag]:
"""Returns a set of tuples (count, tag) for all tags present in the journal.""" """Returns a set of tuples (count, tag) for all tags present in the journal."""
# Astute reader: should the following line leave you as puzzled as me the first time # Astute reader: should the following line leave you as puzzled as me the first
# I came across this construction, worry not and embrace the ensuing moment of enlightment. # time I came across this construction, worry not and embrace the ensuing moment
# of enlightment.
tags = [tag for entry in self.entries for tag in set(entry.tags)] tags = [tag for entry in self.entries for tag in set(entry.tags)]
# To be read: [for entry in journal.entries: for tag in set(entry.tags): tag] # To be read: [for entry in journal.entries: for tag in set(entry.tags): tag]
tag_counts = {(tags.count(tag), tag) for tag in tags} tag_counts = {(tags.count(tag), tag) for tag in tags}
@ -216,8 +242,11 @@ class Journal:
start_date=None, start_date=None,
end_date=None, end_date=None,
starred=False, starred=False,
tagged=False,
exclude_starred=False,
exclude_tagged=False,
strict=False, strict=False,
contains=None, contains=[],
exclude=[], exclude=[],
): ):
"""Removes all entries from the journal that don't match the filter. """Removes all entries from the journal that don't match the filter.
@ -239,13 +268,15 @@ class Journal:
start_date = time.parse(start_date) start_date = time.parse(start_date)
# If strict mode is on, all tags have to be present in entry # If strict mode is on, all tags have to be present in entry
tagged = self.search_tags.issubset if strict else self.search_tags.intersection has_tags = (
self.search_tags.issubset if strict else self.search_tags.intersection
)
def excluded(tags): def excluded(tags):
return 0 < len([tag for tag in tags if tag in excluded_tags]) return 0 < len([tag for tag in tags if tag in excluded_tags])
if contains: if contains:
contains_lower = contains.casefold() contains_lower = [substring.casefold() for substring in contains]
# Create datetime object for comparison below # Create datetime object for comparison below
# this approach allows various formats # this approach allows various formats
@ -255,8 +286,9 @@ class Journal:
result = [ result = [
entry entry
for entry in self.entries for entry in self.entries
if (not tags or tagged(entry.tags)) if (not tags or has_tags(entry.tags))
and (not starred or entry.starred) and (not (starred or exclude_starred) or entry.starred == starred)
and (not (tagged or exclude_tagged) or bool(entry.tags) == tagged)
and (not month or entry.date.month == compare_d.month) and (not month or entry.date.month == compare_d.month)
and (not day or entry.date.day == compare_d.day) and (not day or entry.date.day == compare_d.day)
and (not year or entry.date.year == compare_d.year) and (not year or entry.date.year == compare_d.year)
@ -266,27 +298,43 @@ class Journal:
and ( and (
not contains not contains
or ( or (
contains_lower in entry.title.casefold() strict
or contains_lower in entry.body.casefold() and all(
substring in entry.title.casefold()
or substring in entry.body.casefold()
for substring in contains_lower
)
)
or (
not strict
and any(
substring in entry.title.casefold()
or substring in entry.body.casefold()
for substring in contains_lower
)
) )
) )
] ]
self.entries = result self.entries = result
def delete_entries(self, entries_to_delete): def delete_entries(self, entries_to_delete: list[Entry]) -> None:
"""Deletes specific entries from a journal.""" """Deletes specific entries from a journal."""
for entry in entries_to_delete: for entry in entries_to_delete:
self.entries.remove(entry) self.entries.remove(entry)
self.deleted_entry_count += 1
def change_date_entries(self, date): def change_date_entries(
self, date: datetime.datetime, entries_to_change: list[Entry]
) -> None:
"""Changes entry dates to given date.""" """Changes entry dates to given date."""
date = time.parse(date) date = time.parse(date)
for entry in self.entries: for entry in entries_to_change:
entry.date = date entry.date = date
entry.modified = True
def prompt_action_entries(self, msg: MsgText): def prompt_action_entries(self, msg: MsgText) -> list[Entry]:
"""Prompts for action for each entry in a journal, using given message. """Prompts for action for each entry in a journal, using given message.
Returns the entries the user wishes to apply the action on.""" Returns the entries the user wishes to apply the action on."""
to_act = [] to_act = []
@ -306,9 +354,11 @@ class Journal:
return to_act return to_act
def new_entry(self, raw, date=None, sort=True): def new_entry(self, raw: str, date=None, sort: bool = True) -> Entry:
"""Constructs a new entry from some raw text input. """Constructs a new entry from some raw text input.
If a date is given, it will parse and use this, otherwise scan for a date in the input first.""" If a date is given, it will parse and use this, otherwise scan for a date in
the input first.
"""
raw = raw.replace("\\n ", "\n").replace("\\n", "\n") raw = raw.replace("\\n ", "\n").replace("\\n", "\n")
# Split raw text into title and body # Split raw text into title and body
@ -335,19 +385,19 @@ class Journal:
) )
if not date: # Still nothing? Meh, just live in the moment. if not date: # Still nothing? Meh, just live in the moment.
date = time.parse("now") date = time.parse("now")
entry = Entry.Entry(self, date, raw, starred=starred) entry = Entry(self, date, raw, starred=starred)
entry.modified = True entry.modified = True
self.entries.append(entry) self.entries.append(entry)
if sort: if sort:
self.sort() self.sort()
return entry return entry
def editable_str(self): def editable_str(self) -> str:
"""Turns the journal into a string of entries that can be edited """Turns the journal into a string of entries that can be edited
manually and later be parsed with eslf.parse_editable_str.""" manually and later be parsed with self.parse_editable_str."""
return "\n".join([str(e) for e in self.entries]) return "\n".join([str(e) for e in self.entries])
def parse_editable_str(self, edited): def parse_editable_str(self, edited: str) -> None:
"""Parses the output of self.editable_str and updates it's entries.""" """Parses the output of self.editable_str and updates it's entries."""
mod_entries = self._parse(edited) mod_entries = self._parse(edited)
# Match those entries that can be found in self.entries and set # Match those entries that can be found in self.entries and set
@ -355,17 +405,23 @@ class Journal:
# modified and how many got deleted later. # modified and how many got deleted later.
for entry in mod_entries: for entry in mod_entries:
entry.modified = not any(entry == old_entry for old_entry in self.entries) entry.modified = not any(entry == old_entry for old_entry in self.entries)
self.increment_change_counts_by_edit(mod_entries)
self.entries = mod_entries self.entries = mod_entries
def increment_change_counts_by_edit(self, mod_entries: Entry) -> None:
if len(mod_entries) > len(self.entries):
self.added_entry_count += len(mod_entries) - len(self.entries)
else:
self.deleted_entry_count += len(self.entries) - len(mod_entries)
class PlainJournal(Journal): def get_change_counts(self) -> dict:
def _load(self, filename): return {
with open(filename, "r", encoding="utf-8") as f: "added": self.added_entry_count,
return f.read() "deleted": self.deleted_entry_count,
"modified": len([e for e in self.entries if e.modified]),
def _store(self, filename, text): }
with open(filename, "w", encoding="utf-8") as f:
f.write(text)
class LegacyJournal(Journal): class LegacyJournal(Journal):
@ -373,11 +429,7 @@ class LegacyJournal(Journal):
standard. Main difference here is that in 1.x, timestamps were not cuddled standard. Main difference here is that in 1.x, timestamps were not cuddled
by square brackets. You'll not be able to save these journals anymore.""" by square brackets. You'll not be able to save these journals anymore."""
def _load(self, filename): def _parse(self, journal_txt: str) -> list[Entry]:
with open(filename, "r", encoding="utf-8") as f:
return f.read()
def _parse(self, journal_txt):
"""Parses a journal that's stored in a string and returns a list of entries""" """Parses a journal that's stored in a string and returns a list of entries"""
# Entries start with a line that looks like 'date title' - let's figure out how # Entries start with a line that looks like 'date title' - let's figure out how
# long the date will be by constructing one # long the date will be by constructing one
@ -405,7 +457,7 @@ class LegacyJournal(Journal):
else: else:
starred = False starred = False
current_entry = Entry.Entry( current_entry = Entry(
self, date=new_date, text=line[date_length + 1 :], starred=starred self, date=new_date, text=line[date_length + 1 :], starred=starred
) )
except ValueError: except ValueError:
@ -424,12 +476,14 @@ class LegacyJournal(Journal):
return entries return entries
def open_journal(journal_name, config, legacy=False): def open_journal(journal_name: str, config: dict, legacy: bool = False) -> Journal:
""" """
Creates a normal, encrypted or DayOne journal based on the passed config. Creates a normal, encrypted or DayOne journal based on the passed config.
If legacy is True, it will open Journals with legacy classes build for If legacy is True, it will open Journals with legacy classes build for
backwards compatibility with jrnl 1.x backwards compatibility with jrnl 1.x
""" """
logging.debug(f"open_journal '{journal_name}'")
validate_journal_name(journal_name, config)
config = config.copy() config = config.copy()
config["journal"] = expand_path(config["journal"]) config["journal"] = expand_path(config["journal"])
@ -448,25 +502,24 @@ def open_journal(journal_name, config, legacy=False):
if config["journal"].strip("/").endswith(".dayone") or "entries" in os.listdir( if config["journal"].strip("/").endswith(".dayone") or "entries" in os.listdir(
config["journal"] config["journal"]
): ):
from jrnl import DayOneJournal from jrnl.journals import DayOne
return DayOneJournal.DayOne(**config).open() return DayOne(**config).open()
else: else:
from jrnl import FolderJournal from jrnl.journals import Folder
return FolderJournal.Folder(journal_name, **config).open() return Folder(journal_name, **config).open()
if not config["encrypt"]: if not config["encrypt"]:
if legacy: if legacy:
return LegacyJournal(journal_name, **config).open() return LegacyJournal(journal_name, **config).open()
if config["journal"].endswith(os.sep): if config["journal"].endswith(os.sep):
from jrnl import FolderJournal from jrnl.journals import Folder
return FolderJournal.Folder(journal_name, **config).open() return Folder(journal_name, **config).open()
return PlainJournal(journal_name, **config).open() return Journal(journal_name, **config).open()
from jrnl import EncryptedJournal
if legacy: if legacy:
return EncryptedJournal.LegacyEncryptedJournal(journal_name, **config).open() config["encrypt"] = "jrnlv1"
return EncryptedJournal.EncryptedJournal(journal_name, **config).open() return LegacyJournal(journal_name, **config).open()
return Journal(journal_name, **config).open()

View file

@ -0,0 +1,5 @@
from .DayOneJournal import DayOne
from .Entry import Entry
from .FolderJournal import Folder
from .Journal import Journal
from .Journal import open_journal

29
jrnl/keyring.py Normal file
View file

@ -0,0 +1,29 @@
# Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html
import keyring
from jrnl.messages import Message
from jrnl.messages import MsgStyle
from jrnl.messages import MsgText
from jrnl.output import print_msg
def get_keyring_password(journal_name: str = "default") -> str | None:
try:
return keyring.get_password("jrnl", journal_name)
except keyring.errors.KeyringError as e:
if not isinstance(e, keyring.errors.NoKeyringError):
print_msg(Message(MsgText.KeyringRetrievalFailure, MsgStyle.ERROR))
return None
def set_keyring_password(password: str, journal_name: str = "default") -> None:
try:
return keyring.set_password("jrnl", journal_name, password)
except keyring.errors.KeyringError as e:
if isinstance(e, keyring.errors.NoKeyringError):
msg = Message(MsgText.KeyringBackendNotFound, MsgStyle.WARNING)
else:
msg = Message(MsgText.KeyringRetrievalFailure, MsgStyle.ERROR)
print_msg(msg)

View file

@ -1,42 +1,47 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
import logging import logging
import sys import sys
import traceback import traceback
from rich.logging import RichHandler
from jrnl import controller
from jrnl.args import parse_args from jrnl.args import parse_args
from jrnl.exception import JrnlException from jrnl.exception import JrnlException
from jrnl.jrnl import run
from jrnl.messages import Message from jrnl.messages import Message
from jrnl.messages import MsgStyle from jrnl.messages import MsgStyle
from jrnl.messages import MsgText from jrnl.messages import MsgText
from jrnl.output import print_msg from jrnl.output import print_msg
def configure_logger(debug=False): def configure_logger(debug: bool = False) -> None:
if not debug: if not debug:
logging.disable() logging.disable()
return return
logging.basicConfig( logging.basicConfig(
level=logging.DEBUG, level=logging.DEBUG,
format="%(levelname)-8s %(name)-12s %(message)s", datefmt="[%X]",
format="%(message)s",
handlers=[RichHandler()],
) )
logging.getLogger("parsedatetime").setLevel(logging.INFO) logging.getLogger("parsedatetime").setLevel(logging.INFO)
logging.getLogger("keyring.backend").setLevel(logging.ERROR) logging.getLogger("keyring.backend").setLevel(logging.ERROR)
logging.debug("Logging start")
def cli(manual_args=None): def run(manual_args: list[str] | None = None) -> int:
try: try:
if manual_args is None: if manual_args is None:
manual_args = sys.argv[1:] manual_args = sys.argv[1:]
args = parse_args(manual_args) args = parse_args(manual_args)
configure_logger(args.debug) configure_logger(args.debug)
logging.debug("Parsed args: %s", args) logging.debug("Parsed args:\n%s", args)
status_code = run(args) status_code = controller.run(args)
except JrnlException as e: except JrnlException as e:
status_code = 1 status_code = 1

View file

@ -1,14 +1,17 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
from typing import TYPE_CHECKING
from typing import Mapping from typing import Mapping
from typing import NamedTuple from typing import NamedTuple
from jrnl.messages.MsgStyle import MsgStyle from jrnl.messages.MsgStyle import MsgStyle
from jrnl.messages.MsgText import MsgText
if TYPE_CHECKING:
from jrnl.messages.MsgText import MsgText
class Message(NamedTuple): class Message(NamedTuple):
text: MsgText text: "MsgText"
style: MsgStyle = MsgStyle.NORMAL style: MsgStyle = MsgStyle.NORMAL
params: Mapping = {} params: Mapping = {}

View file

@ -1,4 +1,4 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
from enum import Enum from enum import Enum
@ -90,4 +90,4 @@ class MsgStyle(Enum):
@property @property
def box_title(self) -> MsgText: def box_title(self) -> MsgText:
return self.value.get("box_title", None) return self.value.get("box_title")

View file

@ -1,4 +1,4 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
from enum import Enum from enum import Enum
@ -28,6 +28,11 @@ class MsgText(Enum):
AllDoneUpgrade = "We're all done here and you can start enjoying jrnl 2" AllDoneUpgrade = "We're all done here and you can start enjoying jrnl 2"
InstallComplete = """
jrnl configuration created at {config_path}
For advanced features, read the docs at https://jrnl.sh
"""
# --- Prompts --- # # --- Prompts --- #
InstallJournalPathQuestion = """ InstallJournalPathQuestion = """
Path to your journal file (leave blank for {default_journal_path}): Path to your journal file (leave blank for {default_journal_path}):
@ -37,6 +42,9 @@ class MsgText(Enum):
EncryptJournalQuestion = """ EncryptJournalQuestion = """
Do you want to encrypt your journal? (You can always change this later) Do you want to encrypt your journal? (You can always change this later)
""" """
UseColorsQuestion = """
Do you want jrnl to use colors to display entries? (You can always change this later)
""" # noqa: E501 - the line is still under 88 when dedented
YesOrNoPromptDefaultYes = "[Y/n]" YesOrNoPromptDefaultYes = "[Y/n]"
YesOrNoPromptDefaultNo = "[y/N]" YesOrNoPromptDefaultNo = "[y/N]"
ContinueUpgrade = "Continue upgrading jrnl?" ContinueUpgrade = "Continue upgrading jrnl?"
@ -93,15 +101,19 @@ class MsgText(Enum):
of journal can't be encrypted. Please fix your config file. of journal can't be encrypted. Please fix your config file.
""" """
DecryptionFailedGeneric = "The decryption of journal data failed."
KeyboardInterruptMsg = "Aborted by user" KeyboardInterruptMsg = "Aborted by user"
CantReadTemplate = """ CantReadTemplate = """
Unreadable template Unable to find a template file {template_path}.
Could not read template file at:
{template} The following paths were checked:
* {jrnl_template_dir}{template_path}
* {actual_template_path}
""" """
NoDefaultJournal = "No default journal configured\n{journals}" NoNamedJournal = "No '{journal_name}' journal configured\n{journals}"
DoesNotExist = "{name} does not exist" DoesNotExist = "{name} does not exist"
@ -149,12 +161,22 @@ class MsgText(Enum):
https://jrnl.sh/en/stable/external-editors/ https://jrnl.sh/en/stable/external-editors/
""" """
NoEditsReceivedJournalNotDeleted = """
No text received from editor. Were you trying to delete all the entries?
This seems a bit drastic, so the operation was cancelled.
To delete all entries, use the --delete option.
"""
NoEditsReceived = "No edits to save, because nothing was changed" NoEditsReceived = "No edits to save, because nothing was changed"
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:
@ -244,6 +266,11 @@ class MsgText(Enum):
{count} imported to {journal_name} journal {count} imported to {journal_name} journal
""" """
ImporterNotFound = """
No importer found for file type '{format}'.
'{format}' is likely to be an export-only format.
"""
# --- Color --- # # --- Color --- #
InvalidColor = "{key} set to invalid color: {color}" InvalidColor = "{key} set to invalid color: {color}"

View file

@ -1,10 +1,10 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
from jrnl.messages.Message import Message from jrnl.messages import Message
from jrnl.messages.MsgStyle import MsgStyle from jrnl.messages import MsgStyle
from jrnl.messages.MsgText import MsgText from jrnl.messages import MsgText
Message = Message Message = Message.Message
MsgStyle = MsgStyle MsgStyle = MsgStyle.MsgStyle
MsgText = MsgText MsgText = MsgText.MsgText

View file

@ -1,18 +1,18 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
import shlex import shlex
from sys import platform from sys import platform
def on_windows(): def on_windows() -> bool:
return "win32" in platform return "win32" in platform
def on_posix(): def on_posix() -> bool:
return not on_windows() return not on_windows()
def split_args(args): def split_args(args: str) -> list[str]:
"""Split arguments and add escape characters as appropriate for the OS""" """Split arguments and add escape characters as appropriate for the OS"""
return shlex.split(args, posix=on_posix()) return shlex.split(args, posix=on_posix())

View file

@ -1,8 +1,8 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
import textwrap import textwrap
from typing import Union from typing import Callable
from rich.console import Console from rich.console import Console
from rich.text import Text from rich.text import Text
@ -12,7 +12,9 @@ from jrnl.messages import MsgStyle
from jrnl.messages import MsgText from jrnl.messages import MsgText
def deprecated_cmd(old_cmd, new_cmd, callback=None, **kwargs): def deprecated_cmd(
old_cmd: str, new_cmd: str, callback: Callable | None = None, **kwargs
) -> None:
print_msg( print_msg(
Message( Message(
MsgText.DeprecatedCommand, MsgText.DeprecatedCommand,
@ -25,20 +27,54 @@ def deprecated_cmd(old_cmd, new_cmd, callback=None, **kwargs):
callback(**kwargs) callback(**kwargs)
def list_journals(configuration): def journal_list_to_json(journal_list: dict) -> str:
from jrnl import config import json
"""List the journals specified in the configuration file""" return json.dumps(journal_list)
result = f"Journals defined in config ({config.get_config_path()})\n"
ml = min(max(len(k) for k in configuration["journals"]), 20)
for journal, cfg in configuration["journals"].items(): def journal_list_to_yaml(journal_list: dict) -> str:
from io import StringIO
from ruamel.yaml import YAML
output = StringIO()
dumper = YAML()
dumper.width = 1000
dumper.dump(journal_list, output)
return output.getvalue()
def journal_list_to_stdout(journal_list: dict) -> str:
result = f"Journals defined in config ({journal_list['config_path']})\n"
ml = min(max(len(k) for k in journal_list["journals"]), 20)
for journal, cfg in journal_list["journals"].items():
result += " * {:{}} -> {}\n".format( result += " * {:{}} -> {}\n".format(
journal, ml, cfg["journal"] if isinstance(cfg, dict) else cfg journal, ml, cfg["journal"] if isinstance(cfg, dict) else cfg
) )
return result return result
def print_msg(msg: Message, **kwargs) -> Union[None, str]: def list_journals(configuration: dict, format: str | None = None) -> str:
from jrnl import config
"""List the journals specified in the configuration file"""
journal_list = {
"config_path": config.get_config_path(),
"journals": configuration["journals"],
}
if format == "json":
return journal_list_to_json(journal_list)
elif format == "yaml":
return journal_list_to_yaml(journal_list)
else:
return journal_list_to_stdout(journal_list)
def print_msg(msg: Message, **kwargs) -> str | None:
"""Helper function to print a single message""" """Helper function to print a single message"""
kwargs["style"] = msg.style kwargs["style"] = msg.style
return print_msgs([msg], **kwargs) return print_msgs([msg], **kwargs)
@ -50,7 +86,7 @@ def print_msgs(
style: MsgStyle = MsgStyle.NORMAL, style: MsgStyle = MsgStyle.NORMAL,
get_input: bool = False, get_input: bool = False,
hide_input: bool = False, hide_input: bool = False,
) -> Union[None, str]: ) -> str | None:
# Same as print_msg, but for a list # Same as print_msg, but for a list
text = Text("", end="") text = Text("", end="")
kwargs = style.decoration.args kwargs = style.decoration.args
@ -82,7 +118,7 @@ def _get_console(stderr: bool = True) -> Console:
return Console(stderr=stderr) return Console(stderr=stderr)
def _add_extra_style_args_if_needed(args, msg): def _add_extra_style_args_if_needed(args: dict, msg: Message):
args["border_style"] = msg.style.color args["border_style"] = msg.style.color
args["title"] = msg.style.box_title args["title"] = msg.style.box_title
return args return args
@ -95,3 +131,12 @@ def format_msg_text(msg: Message) -> Text:
text = textwrap.dedent(text) text = textwrap.dedent(text)
text = text.strip() text = text.strip()
return Text(text) return Text(text)
def wrap_with_ansi_colors(text: str, width: int) -> str:
richtext = Text.from_ansi(text, no_wrap=False, tab_size=None)
console = Console(width=width, force_terminal=True)
with console.capture() as capture:
console.print(richtext, sep="", end="")
return capture.get()

View file

@ -1,14 +1,17 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
from argparse import Namespace from typing import TYPE_CHECKING
from jrnl.config import make_yaml_valid_dict from jrnl.config import make_yaml_valid_dict
from jrnl.config import update_config from jrnl.config import update_config
if TYPE_CHECKING:
from argparse import Namespace
# import logging # import logging
def apply_overrides(args: Namespace, base_config: dict) -> dict: def apply_overrides(args: "Namespace", base_config: dict) -> dict:
"""Unpack CLI provided overrides into the configuration tree. """Unpack CLI provided overrides into the configuration tree.
:param overrides: List of configuration key-value pairs collected from the CLI :param overrides: List of configuration key-value pairs collected from the CLI
@ -18,13 +21,12 @@ def apply_overrides(args: Namespace, base_config: dict) -> dict:
:return: Configuration to be used during runtime with the overrides applied :return: Configuration to be used during runtime with the overrides applied
:rtype: dict :rtype: dict
""" """
overrides = vars(args).get("config_override", None) overrides = vars(args).get("config_override")
if not overrides: if not overrides:
return base_config return base_config
cfg_with_overrides = base_config.copy() cfg_with_overrides = base_config.copy()
for pairs in overrides: for pairs in overrides:
pairs = make_yaml_valid_dict(pairs) pairs = make_yaml_valid_dict(pairs)
key_as_dots, override_value = _get_key_and_value_from_pair(pairs) key_as_dots, override_value = _get_key_and_value_from_pair(pairs)
keys = _convert_dots_to_list(key_as_dots) keys = _convert_dots_to_list(key_as_dots)
@ -36,12 +38,12 @@ def apply_overrides(args: Namespace, base_config: dict) -> dict:
return base_config return base_config
def _get_key_and_value_from_pair(pairs): def _get_key_and_value_from_pair(pairs: dict) -> tuple:
key_as_dots, override_value = list(pairs.items())[0] key_as_dots, override_value = list(pairs.items())[0]
return key_as_dots, override_value return key_as_dots, override_value
def _convert_dots_to_list(key_as_dots): def _convert_dots_to_list(key_as_dots: str) -> list[str]:
keys = key_as_dots.split(".") keys = key_as_dots.split(".")
keys = [k for k in keys if k != ""] # remove empty elements keys = [k for k in keys if k != ""] # remove empty elements
return keys return keys
@ -54,7 +56,8 @@ def _recursively_apply(tree: dict, nodes: list, override_value) -> dict:
Args: Args:
config (dict): Configuration to modify config (dict): Configuration to modify
nodes (list): Vector of override keys; the length of the vector indicates tree depth nodes (list): Vector of override keys; the length of the vector indicates tree
depth
override_value (str): Runtime override passed from the command-line override_value (str): Runtime override passed from the command-line
""" """
key = nodes[0] key = nodes[0]

View file

@ -1,16 +1,72 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
import os.path import os.path
from pathlib import Path
import xdg.BaseDirectory
from jrnl.exception import JrnlException
from jrnl.messages import Message
from jrnl.messages import MsgStyle
from jrnl.messages import MsgText
# Constants
XDG_RESOURCE = "jrnl"
DEFAULT_CONFIG_NAME = "jrnl.yaml"
DEFAULT_JOURNAL_NAME = "journal.txt"
def home_dir(): def home_dir() -> str:
return os.path.expanduser("~") return os.path.expanduser("~")
def expand_path(path): def expand_path(path: str) -> str:
return os.path.expanduser(os.path.expandvars(path)) return os.path.expanduser(os.path.expandvars(path))
def absolute_path(path): def absolute_path(path: str) -> str:
return os.path.abspath(expand_path(path)) return os.path.abspath(expand_path(path))
def get_default_journal_path() -> str:
journal_data_path = xdg.BaseDirectory.save_data_path(XDG_RESOURCE) or home_dir()
return os.path.join(journal_data_path, DEFAULT_JOURNAL_NAME)
def get_templates_path() -> str:
"""
Get the path to the XDG templates directory. Creates the directory if it
doesn't exist.
"""
# jrnl_xdg_resource_path is created by save_data_path if it does not exist
jrnl_xdg_resource_path = Path(xdg.BaseDirectory.save_data_path(XDG_RESOURCE))
jrnl_templates_path = jrnl_xdg_resource_path / "templates"
# Create the directory if needed.
jrnl_templates_path.mkdir(exist_ok=True)
return str(jrnl_templates_path)
def get_config_directory() -> str:
try:
return xdg.BaseDirectory.save_config_path(XDG_RESOURCE)
except FileExistsError:
raise JrnlException(
Message(
MsgText.ConfigDirectoryIsFile,
MsgStyle.ERROR,
{
"config_directory_path": os.path.join(
xdg.BaseDirectory.xdg_config_home, XDG_RESOURCE
)
},
),
)
def get_config_path() -> str:
try:
config_directory_path = get_config_directory()
except JrnlException:
return os.path.join(home_dir(), DEFAULT_CONFIG_NAME)
return os.path.join(config_directory_path, DEFAULT_CONFIG_NAME)

View file

@ -1,6 +1,9 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
from typing import Type
from jrnl.plugins.calendar_heatmap_exporter import CalendarHeatmapExporter
from jrnl.plugins.dates_exporter import DatesExporter from jrnl.plugins.dates_exporter import DatesExporter
from jrnl.plugins.fancy_exporter import FancyExporter from jrnl.plugins.fancy_exporter import FancyExporter
from jrnl.plugins.jrnl_importer import JRNLImporter from jrnl.plugins.jrnl_importer import JRNLImporter
@ -12,14 +15,15 @@ from jrnl.plugins.xml_exporter import XMLExporter
from jrnl.plugins.yaml_exporter import YAMLExporter from jrnl.plugins.yaml_exporter import YAMLExporter
__exporters = [ __exporters = [
CalendarHeatmapExporter,
DatesExporter,
FancyExporter,
JSONExporter, JSONExporter,
MarkdownExporter, MarkdownExporter,
TagExporter, TagExporter,
DatesExporter,
TextExporter, TextExporter,
XMLExporter, XMLExporter,
YAMLExporter, YAMLExporter,
FancyExporter,
] ]
__importers = [JRNLImporter] __importers = [JRNLImporter]
@ -32,14 +36,14 @@ EXPORT_FORMATS = sorted(__exporter_types.keys())
IMPORT_FORMATS = sorted(__importer_types.keys()) IMPORT_FORMATS = sorted(__importer_types.keys())
def get_exporter(format): def get_exporter(format: str) -> Type[TextExporter] | None:
for exporter in __exporters: for exporter in __exporters:
if hasattr(exporter, "names") and format in exporter.names: if hasattr(exporter, "names") and format in exporter.names:
return exporter return exporter
return None return None
def get_importer(format): def get_importer(format: str) -> Type[JRNLImporter] | None:
for importer in __importers: for importer in __importers:
if hasattr(importer, "names") and format in importer.names: if hasattr(importer, "names") and format in importer.names:
return importer return importer

View file

@ -0,0 +1,117 @@
# Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html
import calendar
from datetime import datetime
from typing import TYPE_CHECKING
from rich import box
from rich.align import Align
from rich.columns import Columns
from rich.console import Console
from rich.table import Table
from rich.text import Text
from jrnl.plugins.text_exporter import TextExporter
from jrnl.plugins.util import get_journal_frequency_nested
if TYPE_CHECKING:
from jrnl.journals import Entry
from jrnl.journals import Journal
from jrnl.plugins.util import NestedDict
class CalendarHeatmapExporter(TextExporter):
"""This Exporter displays a calendar heatmap of the journaling frequency."""
names = ["calendar", "heatmap"]
extension = "cal"
@classmethod
def export_entry(cls, entry: "Entry"):
raise NotImplementedError
@classmethod
def print_calendar_heatmap(cls, journal_frequency: "NestedDict") -> str:
"""Returns a string representation of the calendar heatmap."""
console = Console()
cal = calendar.Calendar()
curr_year = datetime.now().year
curr_month = datetime.now().month
curr_day = datetime.now().day
hit_first_entry = False
with console.capture() as capture:
for year, month_journaling_freq in journal_frequency.items():
year_calendar = []
for month in range(1, 13):
if month > curr_month and year == curr_year:
break
entries_this_month = sum(month_journaling_freq[month].values())
if not hit_first_entry and entries_this_month > 0:
hit_first_entry = True
if entries_this_month == 0 and not hit_first_entry:
continue
elif entries_this_month == 0:
entry_msg = "No entries"
elif entries_this_month == 1:
entry_msg = "1 entry"
else:
entry_msg = f"{entries_this_month} entries"
table = Table(
title=f"{calendar.month_name[month]} {year} ({entry_msg})",
title_style="bold green",
box=box.SIMPLE_HEAVY,
padding=0,
)
for week_day in cal.iterweekdays():
table.add_column(
"{:.3}".format(calendar.day_name[week_day]), justify="right"
)
month_days = cal.monthdayscalendar(year, month)
for weekdays in month_days:
days = []
for _, day in enumerate(weekdays):
if day == 0: # Not a part of this month, just filler.
day_label = Text(str(day or ""), style="white")
elif (
day > curr_day
and month == curr_month
and year == curr_year
):
break
else:
journal_frequency_for_day = (
month_journaling_freq[month][day] or 0
)
day = str(day)
# TODO: Make colors configurable?
if journal_frequency_for_day == 0:
day_label = Text(day, style="red on black")
elif journal_frequency_for_day == 1:
day_label = Text(day, style="black on yellow")
elif journal_frequency_for_day == 2:
day_label = Text(day, style="black on green")
else:
day_label = Text(day, style="black on white")
days.append(day_label)
table.add_row(*days)
year_calendar.append(Align.center(table))
# Print year header line
console.rule(str(year))
console.print()
# Print calendar
console.print(Columns(year_calendar, padding=1, expand=True))
return capture.get()
@classmethod
def export_journal(cls, journal: "Journal"):
"""Returns dates and their frequencies for an entire journal."""
journal_entry_date_frequency = get_journal_frequency_nested(journal)
return cls.print_calendar_heatmap(journal_entry_date_frequency)

View file

@ -1,9 +1,14 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
from collections import Counter from typing import TYPE_CHECKING
from jrnl.plugins.text_exporter import TextExporter from jrnl.plugins.text_exporter import TextExporter
from jrnl.plugins.util import get_journal_frequency_one_level
if TYPE_CHECKING:
from jrnl.journals import Entry
from jrnl.journals import Journal
class DatesExporter(TextExporter): class DatesExporter(TextExporter):
@ -13,16 +18,12 @@ class DatesExporter(TextExporter):
extension = "dates" extension = "dates"
@classmethod @classmethod
def export_entry(cls, entry): def export_entry(cls, entry: "Entry"):
raise NotImplementedError raise NotImplementedError
@classmethod @classmethod
def export_journal(cls, journal): def export_journal(cls, journal: "Journal") -> str:
"""Returns dates and their frequencies for an entire journal.""" """Returns dates and their frequencies for an entire journal."""
date_counts = Counter() date_counts = get_journal_frequency_one_level(journal)
for entry in journal.entries:
# entry.date.date() gets date without time
date = str(entry.date.date())
date_counts[date] += 1
result = "\n".join(f"{date}, {count}" for date, count in date_counts.items()) result = "\n".join(f"{date}, {count}" for date, count in date_counts.items())
return result return result

View file

@ -1,9 +1,10 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
import logging import logging
import os import os
from textwrap import TextWrapper from textwrap import TextWrapper
from typing import TYPE_CHECKING
from jrnl.exception import JrnlException from jrnl.exception import JrnlException
from jrnl.messages import Message from jrnl.messages import Message
@ -11,9 +12,13 @@ from jrnl.messages import MsgStyle
from jrnl.messages import MsgText from jrnl.messages import MsgText
from jrnl.plugins.text_exporter import TextExporter from jrnl.plugins.text_exporter import TextExporter
if TYPE_CHECKING:
from jrnl.journals import Entry
from jrnl.journals import Journal
class FancyExporter(TextExporter): class FancyExporter(TextExporter):
"""This Exporter can convert entries and journals into text with unicode box drawing characters.""" """This Exporter converts entries and journals into text with unicode boxes."""
names = ["fancy", "boxed"] names = ["fancy", "boxed"]
extension = "txt" extension = "txt"
@ -35,7 +40,7 @@ class FancyExporter(TextExporter):
border_m = "" border_m = ""
@classmethod @classmethod
def export_entry(cls, entry): def export_entry(cls, entry: "Entry") -> str:
"""Returns a fancy unicode representation of a single entry.""" """Returns a fancy unicode representation of a single entry."""
date_str = entry.date.strftime(entry.journal.config["timeformat"]) date_str = entry.date.strftime(entry.journal.config["timeformat"])
@ -95,12 +100,14 @@ class FancyExporter(TextExporter):
return "\n".join(card) return "\n".join(card)
@classmethod @classmethod
def export_journal(cls, journal): def export_journal(cls, journal) -> str:
"""Returns a unicode representation of an entire journal.""" """Returns a unicode representation of an entire journal."""
return "\n".join(cls.export_entry(entry) for entry in journal) return "\n".join(cls.export_entry(entry) for entry in journal)
def check_provided_linewrap_viability(linewrap, card, journal): def check_provided_linewrap_viability(
linewrap: int, card: list[str], journal: "Journal"
):
if len(card[0]) > linewrap: if len(card[0]) > linewrap:
width_violation = len(card[0]) - linewrap width_violation = len(card[0]) - linewrap
raise JrnlException( raise JrnlException(

View file

@ -1,7 +1,8 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
import sys import sys
from typing import TYPE_CHECKING
from jrnl.exception import JrnlException from jrnl.exception import JrnlException
from jrnl.messages import Message from jrnl.messages import Message
@ -9,6 +10,9 @@ from jrnl.messages import MsgStyle
from jrnl.messages import MsgText from jrnl.messages import MsgText
from jrnl.output import print_msg from jrnl.output import print_msg
if TYPE_CHECKING:
from jrnl.journals import Journal
class JRNLImporter: class JRNLImporter:
"""This plugin imports entries from other jrnl files.""" """This plugin imports entries from other jrnl files."""
@ -16,7 +20,7 @@ class JRNLImporter:
names = ["jrnl"] names = ["jrnl"]
@staticmethod @staticmethod
def import_(journal, input=None): def import_(journal: "Journal", input: str | None = None) -> None:
"""Imports from an existing file if input is specified, and """Imports from an existing file if input is specified, and
standard input otherwise.""" standard input otherwise."""
old_cnt = len(journal.entries) old_cnt = len(journal.entries)

View file

@ -1,11 +1,16 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
import json import json
from typing import TYPE_CHECKING
from jrnl.plugins.text_exporter import TextExporter from jrnl.plugins.text_exporter import TextExporter
from jrnl.plugins.util import get_tags_count from jrnl.plugins.util import get_tags_count
if TYPE_CHECKING:
from jrnl.journals import Entry
from jrnl.journals import Journal
class JSONExporter(TextExporter): class JSONExporter(TextExporter):
"""This Exporter can convert entries and journals into json.""" """This Exporter can convert entries and journals into json."""
@ -14,7 +19,7 @@ class JSONExporter(TextExporter):
extension = "json" extension = "json"
@classmethod @classmethod
def entry_to_dict(cls, entry): def entry_to_dict(cls, entry: "Entry") -> dict:
entry_dict = { entry_dict = {
"title": entry.title, "title": entry.title,
"body": entry.body, "body": entry.body,
@ -49,12 +54,12 @@ class JSONExporter(TextExporter):
return entry_dict return entry_dict
@classmethod @classmethod
def export_entry(cls, entry): def export_entry(cls, entry: "Entry") -> str:
"""Returns a json representation of a single entry.""" """Returns a json representation of a single entry."""
return json.dumps(cls.entry_to_dict(entry), indent=2) + "\n" return json.dumps(cls.entry_to_dict(entry), indent=2) + "\n"
@classmethod @classmethod
def export_journal(cls, journal): def export_journal(cls, journal: "Journal") -> str:
"""Returns a json representation of an entire journal.""" """Returns a json representation of an entire journal."""
tags = get_tags_count(journal) tags = get_tags_count(journal)
result = { result = {

View file

@ -1,8 +1,9 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
import os import os
import re import re
from typing import TYPE_CHECKING
from jrnl.messages import Message from jrnl.messages import Message
from jrnl.messages import MsgStyle from jrnl.messages import MsgStyle
@ -10,6 +11,10 @@ from jrnl.messages import MsgText
from jrnl.output import print_msg from jrnl.output import print_msg
from jrnl.plugins.text_exporter import TextExporter from jrnl.plugins.text_exporter import TextExporter
if TYPE_CHECKING:
from jrnl.journals import Entry
from jrnl.journals import Journal
class MarkdownExporter(TextExporter): class MarkdownExporter(TextExporter):
"""This Exporter can convert entries and journals into Markdown.""" """This Exporter can convert entries and journals into Markdown."""
@ -18,7 +23,7 @@ class MarkdownExporter(TextExporter):
extension = "md" extension = "md"
@classmethod @classmethod
def export_entry(cls, entry, to_multifile=True): def export_entry(cls, entry: "Entry", to_multifile: bool = True) -> str:
"""Returns a markdown representation of a single entry.""" """Returns a markdown representation of a single entry."""
date_str = entry.date.strftime(entry.journal.config["timeformat"]) date_str = entry.date.strftime(entry.journal.config["timeformat"])
body_wrapper = "\n" if entry.body else "" body_wrapper = "\n" if entry.body else ""
@ -73,16 +78,16 @@ class MarkdownExporter(TextExporter):
return f"{heading} {date_str} {entry.title}\n{newbody} " return f"{heading} {date_str} {entry.title}\n{newbody} "
@classmethod @classmethod
def export_journal(cls, journal): def export_journal(cls, journal: "Journal") -> str:
"""Returns a Markdown representation of an entire journal.""" """Returns a Markdown representation of an entire journal."""
out = [] out = []
year, month = -1, -1 year, month = -1, -1
for e in journal.entries: for e in journal.entries:
if not e.date.year == year: if e.date.year != year:
year = e.date.year year = e.date.year
out.append("# " + str(year)) out.append("# " + str(year))
out.append("") out.append("")
if not e.date.month == month: if e.date.month != month:
month = e.date.month month = e.date.month
out.append("## " + e.date.strftime("%B")) out.append("## " + e.date.strftime("%B"))
out.append("") out.append("")

View file

@ -1,23 +1,29 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
from typing import TYPE_CHECKING
from jrnl.plugins.text_exporter import TextExporter from jrnl.plugins.text_exporter import TextExporter
from jrnl.plugins.util import get_tags_count from jrnl.plugins.util import get_tags_count
if TYPE_CHECKING:
from jrnl.journals import Entry
from jrnl.journals import Journal
class TagExporter(TextExporter): class TagExporter(TextExporter):
"""This Exporter can lists the tags for entries and journals, exported as a plain text file.""" """This Exporter lists the tags for entries and journals."""
names = ["tags"] names = ["tags"]
extension = "tags" extension = "tags"
@classmethod @classmethod
def export_entry(cls, entry): def export_entry(cls, entry: "Entry") -> str:
"""Returns a list of tags for a single entry.""" """Returns a list of tags for a single entry."""
return ", ".join(entry.tags) return ", ".join(entry.tags)
@classmethod @classmethod
def export_journal(cls, journal): def export_journal(cls, journal: "Journal") -> str:
"""Returns a list of tags and their frequency for an entire journal.""" """Returns a list of tags and their frequency for an entire journal."""
tag_counts = get_tags_count(journal) tag_counts = get_tags_count(journal)
result = "" result = ""

View file

@ -1,16 +1,21 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
import errno import errno
import os import os
import re import re
import unicodedata import unicodedata
from typing import TYPE_CHECKING
from jrnl.messages import Message from jrnl.messages import Message
from jrnl.messages import MsgStyle from jrnl.messages import MsgStyle
from jrnl.messages import MsgText from jrnl.messages import MsgText
from jrnl.output import print_msg from jrnl.output import print_msg
if TYPE_CHECKING:
from jrnl.journals import Entry
from jrnl.journals import Journal
class TextExporter: class TextExporter:
"""This Exporter can convert entries and journals into text files.""" """This Exporter can convert entries and journals into text files."""
@ -19,39 +24,40 @@ class TextExporter:
extension = "txt" extension = "txt"
@classmethod @classmethod
def export_entry(cls, entry): def export_entry(cls, entry: "Entry") -> str:
"""Returns a string representation of a single entry.""" """Returns a string representation of a single entry."""
return str(entry) return str(entry)
@classmethod @classmethod
def export_journal(cls, journal): def export_journal(cls, journal: "Journal") -> str:
"""Returns a string representation of an entire journal.""" """Returns a string representation of an entire journal."""
return "\n".join(cls.export_entry(entry) for entry in journal) return "\n".join(cls.export_entry(entry) for entry in journal)
@classmethod @classmethod
def write_file(cls, journal, path): def write_file(cls, journal: "Journal", path: str) -> str:
"""Exports a journal into a single file.""" """Exports a journal into a single file."""
export_str = cls.export_journal(journal)
with open(path, "w", encoding="utf-8") as f: with open(path, "w", encoding="utf-8") as f:
f.write(cls.export_journal(journal)) f.write(export_str)
print_msg( print_msg(
Message( Message(
MsgText.JournalExportedTo, MsgText.JournalExportedTo,
MsgStyle.NORMAL, MsgStyle.NORMAL,
{ {
"path": path, "path": path,
}, },
)
) )
return "" )
return ""
@classmethod @classmethod
def make_filename(cls, entry): def make_filename(cls, entry: "Entry") -> str:
return entry.date.strftime("%Y-%m-%d") + "_{}.{}".format( return entry.date.strftime("%Y-%m-%d") + "_{}.{}".format(
cls._slugify(str(entry.title)), cls.extension cls._slugify(str(entry.title)), cls.extension
) )
@classmethod @classmethod
def write_files(cls, journal, path): def write_files(cls, journal: "Journal", path: str) -> str:
"""Exports a journal into individual files for each entry.""" """Exports a journal into individual files for each entry."""
for entry in journal.entries: for entry in journal.entries:
entry_is_written = False entry_is_written = False
@ -81,7 +87,7 @@ class TextExporter:
) )
return "" return ""
def _slugify(string): def _slugify(string: str) -> str:
"""Slugifies a string. """Slugifies a string.
Based on public domain code from https://github.com/zacharyvoase/slugify Based on public domain code from https://github.com/zacharyvoase/slugify
""" """
@ -91,7 +97,7 @@ class TextExporter:
return slug return slug
@classmethod @classmethod
def export(cls, journal, output=None): def export(cls, journal: "Journal", output: str | None = None) -> str:
"""Exports to individual files if output is an existing path, or into """Exports to individual files if output is an existing path, or into
a single file if output is a file name, or returns the exporter's a single file if output is a file name, or returns the exporter's
representation as string if output is None.""" representation as string if output is None."""

View file

@ -1,18 +1,33 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
from collections import Counter
from typing import TYPE_CHECKING
def get_tags_count(journal): if TYPE_CHECKING:
from jrnl.journals import Journal
class NestedDict(dict):
"""https://stackoverflow.com/a/74873621/8740440"""
def __missing__(self, x):
self[x] = NestedDict()
return self[x]
def get_tags_count(journal: "Journal") -> set[tuple[int, str]]:
"""Returns a set of tuples (count, tag) for all tags present in the journal.""" """Returns a set of tuples (count, tag) for all tags present in the journal."""
# Astute reader: should the following line leave you as puzzled as me the first time # Astute reader: should the following line leave you as puzzled as me the first time
# I came across this construction, worry not and embrace the ensuing moment of enlightment. # I came across this construction, worry not and embrace the ensuing moment of
# enlightment.
tags = [tag for entry in journal.entries for tag in set(entry.tags)] tags = [tag for entry in journal.entries for tag in set(entry.tags)]
# To be read: [for entry in journal.entries: for tag in set(entry.tags): tag] # To be read: [for entry in journal.entries: for tag in set(entry.tags): tag]
tag_counts = {(tags.count(tag), tag) for tag in tags} tag_counts = {(tags.count(tag), tag) for tag in tags}
return tag_counts return tag_counts
def oxford_list(lst): def oxford_list(lst: list) -> str:
"""Return Human-readable list of things obeying the object comma)""" """Return Human-readable list of things obeying the object comma)"""
lst = sorted(lst) lst = sorted(lst)
if not lst: if not lst:
@ -23,3 +38,26 @@ def oxford_list(lst):
return lst[0] + " or " + lst[1] return lst[0] + " or " + lst[1]
else: else:
return ", ".join(lst[:-1]) + ", or " + lst[-1] return ", ".join(lst[:-1]) + ", or " + lst[-1]
def get_journal_frequency_nested(journal: "Journal") -> NestedDict:
"""Returns a NestedDict of the form {year: {month: {day: count}}}"""
journal_frequency = NestedDict()
for entry in journal.entries:
date = entry.date.date()
if date.day in journal_frequency[date.year][date.month]:
journal_frequency[date.year][date.month][date.day] += 1
else:
journal_frequency[date.year][date.month][date.day] = 1
return journal_frequency
def get_journal_frequency_one_level(journal: "Journal") -> Counter:
"""Returns a Counter of the form {date (YYYY-MM-DD): count}"""
date_counts = Counter()
for entry in journal.entries:
# entry.date.date() gets date without time
date = str(entry.date.date())
date_counts[date] += 1
return date_counts

View file

@ -1,11 +1,16 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
from typing import TYPE_CHECKING
from xml.dom import minidom from xml.dom import minidom
from jrnl.plugins.json_exporter import JSONExporter from jrnl.plugins.json_exporter import JSONExporter
from jrnl.plugins.util import get_tags_count from jrnl.plugins.util import get_tags_count
if TYPE_CHECKING:
from jrnl.journals import Entry
from jrnl.journals import Journal
class XMLExporter(JSONExporter): class XMLExporter(JSONExporter):
"""This Exporter can convert entries and journals into XML.""" """This Exporter can convert entries and journals into XML."""
@ -14,7 +19,9 @@ class XMLExporter(JSONExporter):
extension = "xml" extension = "xml"
@classmethod @classmethod
def export_entry(cls, entry, doc=None): def export_entry(
cls, entry: "Entry", doc: minidom.Document | None = None
) -> minidom.Element | str:
"""Returns an XML representation of a single entry.""" """Returns an XML representation of a single entry."""
doc_el = doc or minidom.Document() doc_el = doc or minidom.Document()
entry_el = doc_el.createElement("entry") entry_el = doc_el.createElement("entry")
@ -29,7 +36,7 @@ class XMLExporter(JSONExporter):
return entry_el return entry_el
@classmethod @classmethod
def entry_to_xml(cls, entry, doc): def entry_to_xml(cls, entry: "Entry", doc: minidom.Document) -> minidom.Element:
entry_el = doc.createElement("entry") entry_el = doc.createElement("entry")
entry_el.setAttribute("date", entry.date.isoformat()) entry_el.setAttribute("date", entry.date.isoformat())
if hasattr(entry, "uuid"): if hasattr(entry, "uuid"):
@ -44,7 +51,7 @@ class XMLExporter(JSONExporter):
return entry_el return entry_el
@classmethod @classmethod
def export_journal(cls, journal): def export_journal(cls, journal: "Journal") -> str:
"""Returns an XML representation of an entire journal.""" """Returns an XML representation of an entire journal."""
tags = get_tags_count(journal) tags = get_tags_count(journal)
doc = minidom.Document() doc = minidom.Document()

View file

@ -1,8 +1,9 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
import os import os
import re import re
from typing import TYPE_CHECKING
from jrnl.exception import JrnlException from jrnl.exception import JrnlException
from jrnl.messages import Message from jrnl.messages import Message
@ -11,16 +12,21 @@ from jrnl.messages import MsgText
from jrnl.output import print_msg from jrnl.output import print_msg
from jrnl.plugins.text_exporter import TextExporter from jrnl.plugins.text_exporter import TextExporter
if TYPE_CHECKING:
from jrnl.journals import Entry
from jrnl.journals import Journal
class YAMLExporter(TextExporter): class YAMLExporter(TextExporter):
"""This Exporter can convert entries and journals into Markdown formatted text with YAML front matter.""" """This Exporter converts entries and journals into Markdown formatted text with
YAML front matter."""
names = ["yaml"] names = ["yaml"]
extension = "md" extension = "md"
@classmethod @classmethod
def export_entry(cls, entry, to_multifile=True): def export_entry(cls, entry: "Entry", to_multifile: bool = True) -> str:
"""Returns a markdown representation of a single entry, with YAML front matter.""" """Returns a markdown representation of an entry, with YAML front matter."""
if to_multifile is False: if to_multifile is False:
raise JrnlException(Message(MsgText.YamlMustBeDirectory, MsgStyle.ERROR)) raise JrnlException(Message(MsgText.YamlMustBeDirectory, MsgStyle.ERROR))
@ -29,7 +35,7 @@ class YAMLExporter(TextExporter):
body = body_wrapper + entry.body body = body_wrapper + entry.body
tagsymbols = entry.journal.config["tagsymbols"] tagsymbols = entry.journal.config["tagsymbols"]
# see also Entry.Entry.rag_regex # see also Entry.rag_regex
multi_tag_regex = re.compile(rf"(?u)^\s*([{tagsymbols}][-+*#/\w]+\s*)+$") multi_tag_regex = re.compile(rf"(?u)^\s*([{tagsymbols}][-+*#/\w]+\s*)+$")
"""Increase heading levels in body text""" """Increase heading levels in body text"""
@ -112,7 +118,14 @@ class YAMLExporter(TextExporter):
# source directory is entry.journal.config['journal'] # source directory is entry.journal.config['journal']
# output directory is...? # output directory is...?
return "{start}\ntitle: {title}\ndate: {date}\nstarred: {starred}\ntags: {tags}\n{dayone}body: |{body}{end}".format( return (
"{start}\n"
"title: {title}\n"
"date: {date}\n"
"starred: {starred}\n"
"tags: {tags}\n"
"{dayone}body: |{body}{end}"
).format(
start="---", start="---",
date=date_str, date=date_str,
title=entry.title, title=entry.title,
@ -124,6 +137,6 @@ class YAMLExporter(TextExporter):
) )
@classmethod @classmethod
def export_journal(cls, journal): def export_journal(cls, journal: "Journal"):
"""Returns an error, as YAML export requires a directory as a target.""" """Returns an error, as YAML export requires a directory as a target."""
raise JrnlException(Message(MsgText.YamlMustBeDirectory, MsgStyle.ERROR)) raise JrnlException(Message(MsgText.YamlMustBeDirectory, MsgStyle.ERROR))

View file

@ -1,4 +1,4 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
from jrnl.messages import Message from jrnl.messages import Message
@ -35,14 +35,28 @@ def create_password(journal_name: str) -> str:
print_msg(Message(MsgText.PasswordDidNotMatch, MsgStyle.ERROR)) print_msg(Message(MsgText.PasswordDidNotMatch, MsgStyle.ERROR))
if yesno(Message(MsgText.PasswordStoreInKeychain), default=True): if yesno(Message(MsgText.PasswordStoreInKeychain), default=True):
from jrnl.EncryptedJournal import set_keychain from jrnl.keyring import set_keyring_password
set_keychain(journal_name, pw) set_keyring_password(pw, journal_name)
return pw return pw
def yesno(prompt: Message, default: bool = True) -> bool: def prompt_password(first_try: bool = True) -> str:
if not first_try:
print_msg(Message(MsgText.WrongPasswordTryAgain, MsgStyle.WARNING))
return (
print_msg(
Message(MsgText.Password, MsgStyle.PROMPT),
get_input=True,
hide_input=True,
)
or ""
)
def yesno(prompt: Message | str, default: bool = True) -> bool:
response = print_msgs( response = print_msgs(
[ [
prompt, prompt,

View file

@ -1,4 +1,4 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
import datetime import datetime
@ -9,35 +9,40 @@ DEFAULT_PAST = datetime.datetime(FAKE_YEAR, 1, 1, 0, 0)
def __get_pdt_calendar(): def __get_pdt_calendar():
try: import parsedatetime as pdt
import parsedatetime.parsedatetime_consts as pdt
except ImportError:
import parsedatetime as pdt
consts = pdt.Constants(usePyICU=False) consts = pdt.Constants(usePyICU=False)
consts.DOWParseStyle = -1 # "Monday" will be either today or the last Monday consts.DOWParseStyle = -1 # "Monday" will be either today or the last Monday
calendar = pdt.Calendar(consts) calendar = pdt.Calendar(consts, version=pdt.VERSION_CONTEXT_STYLE)
return calendar return calendar
def parse( def parse(
date_str, inclusive=False, default_hour=None, default_minute=None, bracketed=False date_str: str | datetime.datetime,
): inclusive: bool = False,
default_hour: int | None = None,
default_minute: int | None = None,
bracketed: bool = False,
) -> datetime.datetime | None:
"""Parses a string containing a fuzzy date and returns a datetime.datetime object""" """Parses a string containing a fuzzy date and returns a datetime.datetime object"""
if not date_str: if not date_str:
return None return None
elif isinstance(date_str, datetime.datetime): elif isinstance(date_str, datetime.datetime):
return date_str return date_str
# Don't try to parse anything with 6 or less characters and was parsed from the existing journal. # Don't try to parse anything with 6 or fewer characters and was parsed from the
# It's probably a markdown footnote # existing journal. It's probably a markdown footnote
if len(date_str) <= 6 and bracketed: if len(date_str) <= 6 and bracketed:
return None return None
default_date = DEFAULT_FUTURE if inclusive else DEFAULT_PAST default_date = DEFAULT_FUTURE if inclusive else DEFAULT_PAST
date = None date = None
year_present = False year_present = False
hasTime = False
hasDate = False
while not date: while not date:
try: try:
from dateutil.parser import parse as dateparse from dateutil.parser import parse as dateparse
@ -49,7 +54,8 @@ def parse(
) )
else: else:
year_present = True year_present = True
flag = 1 if date.hour == date.minute == 0 else 2 hasTime = not (date.hour == date.minute == 0)
hasDate = True
date = date.timetuple() date = date.timetuple()
except Exception as e: except Exception as e:
if e.args[0] == "day is out of range for month": if e.args[0] == "day is out of range for month":
@ -57,9 +63,11 @@ def parse(
default_date = datetime.datetime(y, m, d - 1, H, M, S) default_date = datetime.datetime(y, m, d - 1, H, M, S)
else: else:
calendar = __get_pdt_calendar() calendar = __get_pdt_calendar()
date, flag = calendar.parse(date_str) date, parse_context = calendar.parse(date_str)
hasTime = parse_context.hasTime
hasDate = parse_context.hasDate
if not flag: # Oops, unparsable. if not hasDate and not hasTime:
try: # Try and parse this as a single year try: # Try and parse this as a single year
year = int(date_str) year = int(date_str)
return datetime.datetime(year, 1, 1) return datetime.datetime(year, 1, 1)
@ -68,8 +76,8 @@ def parse(
except TypeError: except TypeError:
return None return None
if flag == 1: # Date found, but no time. Use the default time. if hasDate and not hasTime:
date = datetime.datetime( date = datetime.datetime( # Use the default time
*date[:3], *date[:3],
hour=23 if inclusive else default_hour or 0, hour=23 if inclusive else default_hour or 0,
minute=59 if inclusive else default_minute or 0, minute=59 if inclusive else default_minute or 0,
@ -78,10 +86,18 @@ def parse(
else: else:
date = datetime.datetime(*date[:6]) date = datetime.datetime(*date[:6])
# Ugly heuristic: if the date is more than 4 weeks in the future, we got the year wrong. # Ugly heuristic: if the date is more than 4 weeks in the future, we got the year
# Rather then this, we would like to see parsedatetime patched so we can tell it to prefer # wrong. Rather than this, we would like to see parsedatetime patched so we can
# past dates # tell it to prefer past dates
dt = datetime.datetime.now() - date dt = datetime.datetime.now() - date
if dt.days < -28 and not year_present: if dt.days < -28 and not year_present:
date = date.replace(date.year - 1) date = date.replace(date.year - 1)
return date return date
def is_valid_date(year: int, month: int, day: int) -> bool:
try:
datetime.datetime(year, month, day)
return True
except ValueError:
return False

View file

@ -1,15 +1,16 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
import logging
import os import os
from jrnl import Journal
from jrnl import __version__ from jrnl import __version__
from jrnl.config import is_config_json from jrnl.config import is_config_json
from jrnl.config import load_config from jrnl.config import load_config
from jrnl.config import scope_config from jrnl.config import scope_config
from jrnl.EncryptedJournal import EncryptedJournal
from jrnl.exception import JrnlException from jrnl.exception import JrnlException
from jrnl.journals import Journal
from jrnl.journals import open_journal
from jrnl.messages import Message from jrnl.messages import Message
from jrnl.messages import MsgStyle from jrnl.messages import MsgStyle
from jrnl.messages import MsgText from jrnl.messages import MsgText
@ -19,7 +20,7 @@ from jrnl.path import expand_path
from jrnl.prompt import yesno from jrnl.prompt import yesno
def backup(filename, binary=False): def backup(filename: str, binary: bool = False):
filename = expand_path(filename) filename = expand_path(filename)
try: try:
@ -42,14 +43,14 @@ def backup(filename, binary=False):
raise JrnlException(Message(MsgText.UpgradeAborted, MsgStyle.WARNING)) raise JrnlException(Message(MsgText.UpgradeAborted, MsgStyle.WARNING))
def check_exists(path): def check_exists(path: str) -> bool:
""" """
Checks if a given path exists. Checks if a given path exists.
""" """
return os.path.exists(path) return os.path.exists(path)
def upgrade_jrnl(config_path): def upgrade_jrnl(config_path: str) -> None:
config = load_config(config_path) config = load_config(config_path)
print_msg(Message(MsgText.WelcomeToJrnl, MsgStyle.NORMAL, {"version": __version__})) print_msg(Message(MsgText.WelcomeToJrnl, MsgStyle.NORMAL, {"version": __version__}))
@ -115,7 +116,7 @@ def upgrade_jrnl(config_path):
cont = yesno(Message(MsgText.ContinueUpgrade), default=False) cont = yesno(Message(MsgText.ContinueUpgrade), default=False)
if not cont: if not cont:
raise JrnlException(Message(MsgText.UpgradeAborted), MsgStyle.WARNING) raise JrnlException(Message(MsgText.UpgradeAborted, MsgStyle.WARNING))
for journal_name, path in encrypted_journals.items(): for journal_name, path in encrypted_journals.items():
print_msg( print_msg(
@ -129,10 +130,20 @@ def upgrade_jrnl(config_path):
) )
backup(path, binary=True) backup(path, binary=True)
old_journal = Journal.open_journal( old_journal = open_journal(
journal_name, scope_config(config, journal_name), legacy=True journal_name, scope_config(config, journal_name), legacy=True
) )
all_journals.append(EncryptedJournal.from_journal(old_journal))
logging.debug(f"Clearing encryption method for '{journal_name}' journal")
# Update the encryption method
new_journal = Journal.from_journal(old_journal)
new_journal.config["encrypt"] = "jrnlv2"
new_journal._get_encryption_method()
# Copy over password (jrnlv1 only supported password-based encryption)
new_journal.encryption_method.password = old_journal.encryption_method.password
all_journals.append(new_journal)
for journal_name, path in plain_journals.items(): for journal_name, path in plain_journals.items():
print_msg( print_msg(
@ -146,10 +157,10 @@ def upgrade_jrnl(config_path):
) )
backup(path) backup(path)
old_journal = Journal.open_journal( old_journal = open_journal(
journal_name, scope_config(config, journal_name), legacy=True journal_name, scope_config(config, journal_name), legacy=True
) )
all_journals.append(Journal.PlainJournal.from_journal(old_journal)) all_journals.append(Journal.from_journal(old_journal))
# loop through lists to validate # loop through lists to validate
failed_journals = [j for j in all_journals if not j.validate_parsing()] failed_journals = [j for j in all_journals if not j.validate_parsing()]
@ -178,7 +189,7 @@ def upgrade_jrnl(config_path):
print_msg(Message(MsgText.AllDoneUpgrade, MsgStyle.NORMAL)) print_msg(Message(MsgText.AllDoneUpgrade, MsgStyle.NORMAL))
def is_old_version(config_path): def is_old_version(config_path: str) -> bool:
return is_config_json(config_path) return is_config_json(config_path)

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

150
package-lock.json generated
View file

@ -5,7 +5,7 @@
"packages": { "packages": {
"": { "": {
"devDependencies": { "devDependencies": {
"pa11y-ci": ">=3.0.1" "pa11y-ci": "3.1.0"
} }
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
@ -25,12 +25,6 @@
"@types/node": "*" "@types/node": "*"
} }
}, },
"node_modules/abbrev": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
"integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
"dev": true
},
"node_modules/agent-base": { "node_modules/agent-base": {
"version": "6.0.2", "version": "6.0.2",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
@ -74,9 +68,9 @@
} }
}, },
"node_modules/axe-core": { "node_modules/axe-core": {
"version": "4.4.3", "version": "4.2.4",
"resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.4.3.tgz", "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.2.4.tgz",
"integrity": "sha512-32+ub6kkdhhWick/UjvEwRchgoetXqTK14INLqbGm5U2TzBkBNF3nQtLYm8ovxSkQWArjEQvftCKryjZaATu3w==", "integrity": "sha512-9AiDKFKUCWEQm1Kj4lcq7KFavLqSXdf2m/zJo+NVh4VXlW5iwXRJ6alkKmipCyYorsRnqsICH9XLubP1jBF+Og==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">=4" "node": ">=4"
@ -525,19 +519,6 @@
"node": ">= 0.4.0" "node": ">= 0.4.0"
} }
}, },
"node_modules/hogan.js": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/hogan.js/-/hogan.js-3.0.2.tgz",
"integrity": "sha512-RqGs4wavGYJWE07t35JQccByczmNUXQT0E12ZYV1VKYu5UiAU9lsos/yBAcf840+zrUQQxgVduCR5/B8nNtibg==",
"dev": true,
"dependencies": {
"mkdirp": "0.3.0",
"nopt": "1.0.10"
},
"bin": {
"hulk": "bin/hulk"
}
},
"node_modules/hoopy": { "node_modules/hoopy": {
"version": "0.1.4", "version": "0.1.4",
"resolved": "https://registry.npmjs.org/hoopy/-/hoopy-0.1.4.tgz", "resolved": "https://registry.npmjs.org/hoopy/-/hoopy-0.1.4.tgz",
@ -684,16 +665,6 @@
"node": "*" "node": "*"
} }
}, },
"node_modules/mkdirp": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz",
"integrity": "sha512-OHsdUcVAQ6pOtg5JYWpCBo9W/GySVuwvP9hueRMW7UqshC0tbfzLv8wjySTPm3tfUZ/21CE9E1pJagOA91Pxew==",
"deprecated": "Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)",
"dev": true,
"engines": {
"node": "*"
}
},
"node_modules/mkdirp-classic": { "node_modules/mkdirp-classic": {
"version": "0.5.3", "version": "0.5.3",
"resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz",
@ -706,6 +677,15 @@
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"dev": true "dev": true
}, },
"node_modules/mustache": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz",
"integrity": "sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==",
"dev": true,
"bin": {
"mustache": "bin/mustache"
}
},
"node_modules/node-fetch": { "node_modules/node-fetch": {
"version": "2.6.7", "version": "2.6.7",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
@ -739,21 +719,6 @@
"node": ">=0.4.0" "node": ">=0.4.0"
} }
}, },
"node_modules/nopt": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz",
"integrity": "sha512-NWmpvLSqUrgrAC9HCuxEvb+PSloHpqVu+FqcO4eeF2h5qYRhA7ev6KvelyQAKtegUbC6RypJnlEOhd8vloNKYg==",
"dev": true,
"dependencies": {
"abbrev": "1"
},
"bin": {
"nopt": "bin/nopt.js"
},
"engines": {
"node": "*"
}
},
"node_modules/nth-check": { "node_modules/nth-check": {
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz", "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz",
@ -830,18 +795,18 @@
} }
}, },
"node_modules/pa11y": { "node_modules/pa11y": {
"version": "6.1.1", "version": "6.2.3",
"resolved": "https://registry.npmjs.org/pa11y/-/pa11y-6.1.1.tgz", "resolved": "https://registry.npmjs.org/pa11y/-/pa11y-6.2.3.tgz",
"integrity": "sha512-2NzqA3D9CUlDWj8WuOI4fM2P0qM1d/IUxsRRpzCOfDT5eMR1oEgmUwW2TAk+f90ff/GVck0BewdYT4et4BANew==", "integrity": "sha512-69JoUlfW2QVmrgQAm+17XBxIvmd1u0ImFBYIHPyjC61CzAkmxO3kkbqDVxIcl0OKLvAMYSMbvfCH8kMFE9xsbg==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"axe-core": "^4.0.2", "axe-core": "~4.2.1",
"bfj": "~7.0.2", "bfj": "~7.0.2",
"commander": "~8.0.0", "commander": "~8.0.0",
"envinfo": "~7.8.1", "envinfo": "~7.8.1",
"hogan.js": "^3.0.2", "html_codesniffer": "~2.5.1",
"html_codesniffer": "^2.5.1",
"kleur": "~4.1.4", "kleur": "~4.1.4",
"mustache": "~4.2.0",
"node.extend": "~2.0.2", "node.extend": "~2.0.2",
"p-timeout": "~4.1.0", "p-timeout": "~4.1.0",
"puppeteer": "~9.1.1", "puppeteer": "~9.1.1",
@ -855,19 +820,19 @@
} }
}, },
"node_modules/pa11y-ci": { "node_modules/pa11y-ci": {
"version": "3.0.1", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/pa11y-ci/-/pa11y-ci-3.0.1.tgz", "resolved": "https://registry.npmjs.org/pa11y-ci/-/pa11y-ci-3.1.0.tgz",
"integrity": "sha512-DUtEIhEG3Ofds7qRuplq0DdCb9doILRlzcRctFNzo4QUNmVy4iZfM3u51A9cqoPo2irCJZoo5BzfiFrcriY2IQ==", "integrity": "sha512-1WBGBMq0dYtZ+N/SH/AcnFSsT6sZ2w27d8Z/5XHJWSELeX8Qhh4yX5f0drb7crwjt7ugKSo4A7eEF9RbMB0LYg==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"async": "~2.6.3", "async": "~2.6.4",
"cheerio": "~1.0.0-rc.10", "cheerio": "~1.0.0-rc.10",
"commander": "~6.2.1", "commander": "~6.2.1",
"globby": "~6.1.0", "globby": "~6.1.0",
"kleur": "~4.1.4", "kleur": "~4.1.4",
"lodash": "~4.17.21", "lodash": "~4.17.21",
"node-fetch": "~2.6.1", "node-fetch": "~2.6.1",
"pa11y": "~6.1.0", "pa11y": "^6.2.3",
"protocolify": "~3.0.0", "protocolify": "~3.0.0",
"puppeteer": "~9.1.1", "puppeteer": "~9.1.1",
"wordwrap": "~1.0.0" "wordwrap": "~1.0.0"
@ -876,7 +841,7 @@
"pa11y-ci": "bin/pa11y-ci.js" "pa11y-ci": "bin/pa11y-ci.js"
}, },
"engines": { "engines": {
"node": ">=12" "node": ">= 12"
} }
}, },
"node_modules/pa11y/node_modules/commander": { "node_modules/pa11y/node_modules/commander": {
@ -1270,12 +1235,6 @@
"@types/node": "*" "@types/node": "*"
} }
}, },
"abbrev": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
"integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
"dev": true
},
"agent-base": { "agent-base": {
"version": "6.0.2", "version": "6.0.2",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
@ -1310,9 +1269,9 @@
} }
}, },
"axe-core": { "axe-core": {
"version": "4.4.3", "version": "4.2.4",
"resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.4.3.tgz", "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.2.4.tgz",
"integrity": "sha512-32+ub6kkdhhWick/UjvEwRchgoetXqTK14INLqbGm5U2TzBkBNF3nQtLYm8ovxSkQWArjEQvftCKryjZaATu3w==", "integrity": "sha512-9AiDKFKUCWEQm1Kj4lcq7KFavLqSXdf2m/zJo+NVh4VXlW5iwXRJ6alkKmipCyYorsRnqsICH9XLubP1jBF+Og==",
"dev": true "dev": true
}, },
"balanced-match": { "balanced-match": {
@ -1633,16 +1592,6 @@
"function-bind": "^1.1.1" "function-bind": "^1.1.1"
} }
}, },
"hogan.js": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/hogan.js/-/hogan.js-3.0.2.tgz",
"integrity": "sha512-RqGs4wavGYJWE07t35JQccByczmNUXQT0E12ZYV1VKYu5UiAU9lsos/yBAcf840+zrUQQxgVduCR5/B8nNtibg==",
"dev": true,
"requires": {
"mkdirp": "0.3.0",
"nopt": "1.0.10"
}
},
"hoopy": { "hoopy": {
"version": "0.1.4", "version": "0.1.4",
"resolved": "https://registry.npmjs.org/hoopy/-/hoopy-0.1.4.tgz", "resolved": "https://registry.npmjs.org/hoopy/-/hoopy-0.1.4.tgz",
@ -1744,12 +1693,6 @@
"brace-expansion": "^1.1.7" "brace-expansion": "^1.1.7"
} }
}, },
"mkdirp": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz",
"integrity": "sha512-OHsdUcVAQ6pOtg5JYWpCBo9W/GySVuwvP9hueRMW7UqshC0tbfzLv8wjySTPm3tfUZ/21CE9E1pJagOA91Pxew==",
"dev": true
},
"mkdirp-classic": { "mkdirp-classic": {
"version": "0.5.3", "version": "0.5.3",
"resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz",
@ -1762,6 +1705,12 @@
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"dev": true "dev": true
}, },
"mustache": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz",
"integrity": "sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==",
"dev": true
},
"node-fetch": { "node-fetch": {
"version": "2.6.7", "version": "2.6.7",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
@ -1781,15 +1730,6 @@
"is": "^3.2.1" "is": "^3.2.1"
} }
}, },
"nopt": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz",
"integrity": "sha512-NWmpvLSqUrgrAC9HCuxEvb+PSloHpqVu+FqcO4eeF2h5qYRhA7ev6KvelyQAKtegUbC6RypJnlEOhd8vloNKYg==",
"dev": true,
"requires": {
"abbrev": "1"
}
},
"nth-check": { "nth-check": {
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz", "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz",
@ -1845,18 +1785,18 @@
"dev": true "dev": true
}, },
"pa11y": { "pa11y": {
"version": "6.1.1", "version": "6.2.3",
"resolved": "https://registry.npmjs.org/pa11y/-/pa11y-6.1.1.tgz", "resolved": "https://registry.npmjs.org/pa11y/-/pa11y-6.2.3.tgz",
"integrity": "sha512-2NzqA3D9CUlDWj8WuOI4fM2P0qM1d/IUxsRRpzCOfDT5eMR1oEgmUwW2TAk+f90ff/GVck0BewdYT4et4BANew==", "integrity": "sha512-69JoUlfW2QVmrgQAm+17XBxIvmd1u0ImFBYIHPyjC61CzAkmxO3kkbqDVxIcl0OKLvAMYSMbvfCH8kMFE9xsbg==",
"dev": true, "dev": true,
"requires": { "requires": {
"axe-core": "^4.0.2", "axe-core": "~4.2.1",
"bfj": "~7.0.2", "bfj": "~7.0.2",
"commander": "~8.0.0", "commander": "~8.0.0",
"envinfo": "~7.8.1", "envinfo": "~7.8.1",
"hogan.js": "^3.0.2", "html_codesniffer": "~2.5.1",
"html_codesniffer": "^2.5.1",
"kleur": "~4.1.4", "kleur": "~4.1.4",
"mustache": "~4.2.0",
"node.extend": "~2.0.2", "node.extend": "~2.0.2",
"p-timeout": "~4.1.0", "p-timeout": "~4.1.0",
"puppeteer": "~9.1.1", "puppeteer": "~9.1.1",
@ -1872,19 +1812,19 @@
} }
}, },
"pa11y-ci": { "pa11y-ci": {
"version": "3.0.1", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/pa11y-ci/-/pa11y-ci-3.0.1.tgz", "resolved": "https://registry.npmjs.org/pa11y-ci/-/pa11y-ci-3.1.0.tgz",
"integrity": "sha512-DUtEIhEG3Ofds7qRuplq0DdCb9doILRlzcRctFNzo4QUNmVy4iZfM3u51A9cqoPo2irCJZoo5BzfiFrcriY2IQ==", "integrity": "sha512-1WBGBMq0dYtZ+N/SH/AcnFSsT6sZ2w27d8Z/5XHJWSELeX8Qhh4yX5f0drb7crwjt7ugKSo4A7eEF9RbMB0LYg==",
"dev": true, "dev": true,
"requires": { "requires": {
"async": "~2.6.3", "async": "~2.6.4",
"cheerio": "~1.0.0-rc.10", "cheerio": "~1.0.0-rc.10",
"commander": "~6.2.1", "commander": "~6.2.1",
"globby": "~6.1.0", "globby": "~6.1.0",
"kleur": "~4.1.4", "kleur": "~4.1.4",
"lodash": "~4.17.21", "lodash": "~4.17.21",
"node-fetch": "~2.6.1", "node-fetch": "~2.6.1",
"pa11y": "~6.1.0", "pa11y": "^6.2.3",
"protocolify": "~3.0.0", "protocolify": "~3.0.0",
"puppeteer": "~9.1.1", "puppeteer": "~9.1.1",
"wordwrap": "~1.0.0" "wordwrap": "~1.0.0"

View file

@ -1,5 +1,5 @@
{ {
"devDependencies": { "devDependencies": {
"pa11y-ci": ">=3.0.1" "pa11y-ci": "3.1.0"
} }
} }

2181
poetry.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "jrnl" name = "jrnl"
version = "v3.2" version = "v4.2.1"
description = "Collect your thoughts and notes without leaving the command line." description = "Collect your thoughts and notes without leaving the command line."
authors = [ authors = [
"jrnl contributors <maintainers@jrnl.sh>", "jrnl contributors <maintainers@jrnl.sh>",
@ -27,60 +27,40 @@ classifiers = [
"Funding" = "https://opencollective.com/jrnl" "Funding" = "https://opencollective.com/jrnl"
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = ">=3.9.0, <3.12" python = ">=3.10.0, <3.14"
ansiwrap = "^0.8.4"
colorama = ">=0.4" # https://github.com/tartley/colorama/blob/master/CHANGELOG.rst colorama = ">=0.4" # https://github.com/tartley/colorama/blob/master/CHANGELOG.rst
cryptography = ">=3.0" # https://cryptography.io/en/latest/api-stability.html cryptography = ">=3.0" # https://cryptography.io/en/latest/api-stability.html
keyring = ">=21.0" # https://github.com/jaraco/keyring#integration keyring = ">=21.0" # https://github.com/jaraco/keyring#integration
parsedatetime = ">=2.6" parsedatetime = ">=2.6"
python-dateutil = "^2.8" # https://github.com/dateutil/dateutil/blob/master/RELEASING python-dateutil = "^2.8" # https://github.com/dateutil/dateutil/blob/master/RELEASING
pyxdg = ">=0.27.0" pyxdg = ">=0.27.0"
"ruamel.yaml" = "^0.17.21" "ruamel.yaml" = ">=0.17.22"
rich = "^12.2.0" rich = ">=14.0.0, <14.1.0"
# dayone-only deps # dayone-only deps
tzlocal = ">=4.0" # https://github.com/regebro/tzlocal/blob/master/CHANGES.txt tzlocal = ">=4.0" # https://github.com/regebro/tzlocal/blob/master/CHANGES.txt
[tool.poetry.dev-dependencies] [tool.poetry.group.dev.dependencies]
black = { version = ">=21.5b2", allow-prereleases = true } black = { version = ">=21.5b2", allow-prereleases = true }
ipdb = "*" ipdb = "*"
isort = ">=5.10" mkdocs = ">=1.4"
mkdocs = ">=1.0,<1.3" parse-type = ">=0.6.0"
poethepoet = "*" poethepoet = "*"
pyproject-flake8 = "*" pytest = ">=8.1"
pytest = ">=6.2" pytest-bdd = ">=8.0"
pytest-bdd = ">=4.0.1,<6.0"
pytest-clarity = "*" pytest-clarity = "*"
pytest-xdist = ">=2.5.0" pytest-xdist = ">=2.5.0"
requests = "*" requests = "*"
ruff = ">=0.0.276"
toml = ">=0.10" toml = ">=0.10"
tox = "*" tox = "*"
xmltodict = "*" xmltodict = "*"
[tool.poetry.scripts] [tool.poetry.scripts]
jrnl = 'jrnl.cli:cli' jrnl = 'jrnl.main:run'
[tool.poe.tasks] [tool.poe.tasks]
format-run = [
{cmd = "black ."},
]
format-check = [
{cmd = "black --version"},
{cmd = "black --check --diff ."},
]
style-check = [
{cmd = "pflake8 --version"},
{cmd = "pflake8 jrnl tests tasks.py"},
]
sort-run = [
{cmd = "isort ."},
]
sort-check = [
{cmd = "isort --version"},
{cmd = "isort --check ."},
]
docs-check.default_item_type = "script" docs-check.default_item_type = "script"
docs-check.sequence = [ docs-check.sequence = [
"tasks:delete_files(['sitemap.xml', 'config.json'])", "tasks:delete_files(['sitemap.xml', 'config.json'])",
@ -99,32 +79,28 @@ test-run = [
{cmd = "tox -q -e py --"}, {cmd = "tox -q -e py --"},
] ]
installer-check = [ # Groups of tasks
{cmd = "poetry --version"}, format.default_item_type = "cmd"
{cmd = "poetry check"}, format.sequence = [
"ruff check . --select I --fix", # equivalent to "isort ."
"black .",
] ]
# Groups of tasks lint.default_item_type = "cmd"
format = [ lint.sequence = [
"format-run", "poetry --version",
"sort-run", "poetry check",
] "ruff --version",
lint = [ "ruff check .",
"installer-check", "black --version",
"style-check", "black --check ."
"sort-check",
"format-check",
] ]
test = [ test = [
"lint", "lint",
"test-run", "test-run",
] ]
[tool.isort]
profile = "black"
force_single_line = true
known_first_party = ["jrnl", "tests"]
[tool.pytest.ini_options] [tool.pytest.ini_options]
minversion = "6.0" minversion = "6.0"
required_plugins = [ required_plugins = [
@ -145,14 +121,40 @@ addopts = [
filterwarnings = [ filterwarnings = [
"ignore::DeprecationWarning", "ignore::DeprecationWarning",
"ignore:Flag style will be deprecated in.*",
"ignore:[WinError 32].*", "ignore:[WinError 32].*",
"ignore:[WinError 5].*" "ignore:[WinError 5].*"
] ]
[tool.flake8] [tool.ruff]
# ignore formatting warnings and errors because we use Black to autoformat line-length = 88
extend-ignore = "E101,E111,E114,E115,E116,E117,E12,E13,E2,E3,E401,E5,E70,W1,W2,W3,W5" target-version = "py310"
# https://beta.ruff.rs/docs/rules/
lint.select = [
'F', # Pyflakes
'E', # pycodestyle errors
'W', # pycodestyle warnings
'I', # isort
'ASYNC', # flake8-async
'S110', # try-except-pass
'S112', # try-except-continue
'EM', # flake8-errmsg
'ISC', # flake8-implicit-str-concat
'Q', # flake8-quotes
'RSE', # flake8-raise
'TID', # flake8-tidy-imports
'TCH', # flake8-type-checking
'T100', # debugger, don't allow break points
'ICN' # flake8-import-conventions
]
exclude = [".git", ".tox", ".venv", "node_modules"]
[tool.ruff.lint.isort]
force-single-line = true
known-first-party = ["jrnl", "tests"]
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"] # unused imports
[build-system] [build-system]
requires = ["poetry-core>=1.0.0"] requires = ["poetry-core>=1.0.0"]
@ -167,9 +169,10 @@ isolated_build = True
[testenv] [testenv]
deps = deps =
pytest >= 6.2 pytest >=8.1
pytest-bdd >=4.0.1,<6.0 pytest-bdd >=8.0
pytest-xdist >=2.5.0 pytest-xdist >=2.5.0
parse-type >=0.6.0
toml >=0.10 toml >=0.10
commands = pytest {posargs} commands = pytest {posargs}

View file

@ -1,4 +1,4 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
import json import json
@ -21,7 +21,7 @@ def delete_files(files):
def run_shell(command): def run_shell(command):
# Required to run NPM commands in Windows and *nix # Required to run NPM commands in Windows and *nix
subprocess.call(command, shell=True) subprocess.run(command, check=True, shell=True)
def generate_sitemap(): def generate_sitemap():
@ -41,7 +41,14 @@ def generate_pa11y_config_from_sitemap():
urls += [url["loc"] for url in xml_sitemap["urlset"]["url"]] urls += [url["loc"] for url in xml_sitemap["urlset"]["url"]]
with open(CONFIG_FILENAME, "w") as f: with open(CONFIG_FILENAME, "w") as f:
f.write(json.dumps({"urls": urls})) f.write(
json.dumps(
{
"defaults": {"chromeLaunchConfig": {"args": ["--no-sandbox"]}},
"urls": urls,
}
)
)
def output_file(file): def output_file(file):

View file

@ -0,0 +1,128 @@
# Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html
Feature: Test combinations of edit, change-time, and delete
Scenario Outline: --change-time with --edit modifies selected entries
Given we use the config "<config_file>"
And we write nothing to the editor if opened
And we use the password "test" if prompted
When we run "jrnl --change-time '2022-04-23 10:30' --edit" and enter
"""
Y
N
Y
"""
Then the error output should contain "No text received from editor. Were you trying to delete all the entries?"
And the editor should have been called
When we run "jrnl -99 --short"
Then the output should be
"""
2020-08-31 14:32 A second entry in what I hope to be a long series.
2022-04-23 10:30 Entry the first.
2022-04-23 10:30 The third entry finally after weeks without writing.
"""
Examples: Configs
| config_file |
| basic_onefile.yaml |
| basic_folder.yaml |
| basic_encrypted.yaml |
# | basic_dayone.yaml | @todo
Scenario Outline: --delete with --edit deletes selected entries
Given we use the config "<config_file>"
And we append to the editor if opened
"""
[2023-02-21 10:32] Here is a new entry
"""
And we use the password "test" if prompted
When we run "jrnl --delete --edit" and enter
"""
Y
N
Y
"""
Then the editor should have been called
And the error output should contain "3 entries found"
And the error output should contain "2 entries deleted"
And the error output should contain "1 entry added"
When we run "jrnl -99 --short"
Then the error output should contain "2 entries found"
And the output should be
"""
2020-08-31 14:32 A second entry in what I hope to be a long series.
2023-02-21 10:32 Here is a new entry
"""
Examples: Configs
| config_file |
| basic_onefile.yaml |
| basic_folder.yaml |
| basic_encrypted.yaml |
# | basic_dayone.yaml | @todo
Scenario Outline: --change-time with --delete affects appropriate entries
Given we use the config "<config_file>"
And we use the password "test" if prompted
# --change-time is asked first, then --delete
When we run "jrnl --change-time '2022-04-23 10:30' --delete" and enter
"""
N
N
Y
Y
N
N
"""
Then the error output should contain "3 entries found"
And the error output should contain "1 entry deleted"
And the error output should contain "1 entry modified"
When we run "jrnl -99 --short"
Then the output should be
"""
2020-08-31 14:32 A second entry in what I hope to be a long series.
2022-04-23 10:30 The third entry finally after weeks without writing.
"""
Examples: Configs
| config_file |
| basic_onefile.yaml |
| basic_folder.yaml |
| basic_encrypted.yaml |
# | basic_dayone.yaml | @todo
Scenario Outline: Combining --change-time and --delete and --edit affects appropriate entries
Given we use the config "<config_file>"
And we append to the editor if opened
"""
[2023-02-21 10:32] Here is a new entry
"""
And we use the password "test" if prompted
# --change-time is asked first, then --delete, then --edit
When we run "jrnl --change-time '2022-04-23 10:30' --delete --edit" and enter
"""
N
Y
Y
Y
Y
N
"""
Then the error output should contain "3 entries found"
And the error output should contain "2 entries deleted"
And the error output should contain "1 entry modified"
And the error output should contain "1 entry added"
When we run "jrnl -99 --short"
Then the output should be
"""
2022-04-23 10:30 The third entry finally after weeks without writing.
2023-02-21 10:32 Here is a new entry
"""
Examples: Configs
| config_file |
| basic_onefile.yaml |
| basic_folder.yaml |
| basic_encrypted.yaml |
# | basic_dayone.yaml | @todo

View file

@ -1,4 +1,4 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
Feature: Build process Feature: Build process

View file

@ -1,4 +1,4 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
Feature: Change entry times in journal Feature: Change entry times in journal
@ -8,12 +8,18 @@ Feature: Change entry times in journal
When we run "jrnl -1" When we run "jrnl -1"
Then the output should contain "2020-09-24 09:14 The third entry finally" Then the output should contain "2020-09-24 09:14 The third entry finally"
When we run "jrnl -1 --change-time '2022-04-23 10:30'" and enter When we run "jrnl -1 --change-time '2022-04-23 10:30'" and enter
"""
Y Y
"""
Then the error output should contain "1 entry modified"
And the error output should not contain "deleted"
When we run "jrnl -99 --short" When we run "jrnl -99 --short"
Then the output should be Then the output should be
"""
2020-08-29 11:11 Entry the first. 2020-08-29 11:11 Entry the first.
2020-08-31 14:32 A second entry in what I hope to be a long series. 2020-08-31 14:32 A second entry in what I hope to be a long series.
2022-04-23 10:30 The third entry finally after weeks without writing. 2022-04-23 10:30 The third entry finally after weeks without writing.
"""
Examples: Configs Examples: Configs
| config_file | | config_file |
@ -25,17 +31,28 @@ Feature: Change entry times in journal
Scenario Outline: Change flag changes prompted entries Scenario Outline: Change flag changes prompted entries
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
When we run "jrnl -1" When we run "jrnl --short"
Then the output should contain "2020-09-24 09:14 The third entry finally" Then the output should be
"""
2020-08-29 11:11 Entry the first.
2020-08-31 14:32 A second entry in what I hope to be a long series.
2020-09-24 09:14 The third entry finally after weeks without writing.
"""
When we run "jrnl --change-time '2022-04-23 10:30'" and enter When we run "jrnl --change-time '2022-04-23 10:30'" and enter
"""
Y Y
N N
Y Y
When we run "jrnl -99 --short" """
Then the error output should contain "3 entries found"
And the error output should contain "2 entries modified"
When we run "jrnl --short"
Then the output should be Then the output should be
"""
2020-08-31 14:32 A second entry in what I hope to be a long series. 2020-08-31 14:32 A second entry in what I hope to be a long series.
2022-04-23 10:30 Entry the first. 2022-04-23 10:30 Entry the first.
2022-04-23 10:30 The third entry finally after weeks without writing. 2022-04-23 10:30 The third entry finally after weeks without writing.
"""
Examples: Configs Examples: Configs
| config_file | | config_file |
@ -45,199 +62,264 @@ Feature: Change entry times in journal
# | basic_dayone.yaml | @todo # | basic_dayone.yaml | @todo
Scenario Outline: Change time flag with nonsense input changes nothing Scenario Outline: Answering "N" to change-time prompt deletes no entries
Given we use the config "<config_file>" Given we use the config "<config_file>"
When we run "jrnl --change-time now asdfasdf" And we use the password "test" if prompted
Then the output should contain "No entries to modify" When we run "jrnl -1"
Then the output should contain "2020-09-24 09:14 The third entry finally"
When we run "jrnl -1 --change-time '2023-02-21 10:30'" and enter
"""
N
"""
Then the error output should not contain "modified"
And the error output should not contain "deleted"
When we run "jrnl -99 --short" When we run "jrnl -99 --short"
Then the output should be Then the output should be
"""
2020-08-29 11:11 Entry the first. 2020-08-29 11:11 Entry the first.
2020-08-31 14:32 A second entry in what I hope to be a long series. 2020-08-31 14:32 A second entry in what I hope to be a long series.
2020-09-24 09:14 The third entry finally after weeks without writing. 2020-09-24 09:14 The third entry finally after weeks without writing.
"""
Examples: Configs Examples: Configs
| config_file | | config_file |
| basic_onefile.yaml | | basic_onefile.yaml |
| basic_folder.yaml | | basic_encrypted.yaml |
| basic_dayone.yaml | | basic_folder.yaml |
# | basic_dayone.yaml | @todo
Scenario Outline: Change time flag with nonsense input changes nothing
Given we use the config "<config_file>"
And we use the password "test" if prompted
When we run "jrnl --change-time now asdfasdf"
Then the output should contain "No entries to modify"
And the error output should not contain "entries modified"
And the error output should not contain "entries deleted"
When we run "jrnl -99 --short"
Then the output should be
"""
2020-08-29 11:11 Entry the first.
2020-08-31 14:32 A second entry in what I hope to be a long series.
2020-09-24 09:14 The third entry finally after weeks without writing.
"""
Examples: Configs
| config_file |
| basic_onefile.yaml |
| basic_folder.yaml |
| basic_encrypted.yaml |
| basic_dayone.yaml |
Scenario Outline: Change time flag with tag only changes tagged entries Scenario Outline: Change time flag with tag only changes tagged entries
Given we use the config "<config_file>" Given we use the config "<config_file>"
And we use the password "test" if prompted
When we run "jrnl --change-time '2022-04-23 10:30' @ipsum" and enter When we run "jrnl --change-time '2022-04-23 10:30' @ipsum" and enter
"""
Y Y
"""
Then the error output should contain "1 entry found"
And the error output should contain "1 entry modified"
When we run "jrnl -99 --short" When we run "jrnl -99 --short"
Then the output should be Then the output should be
"""
2020-08-31 14:32 A second entry in what I hope to be a long series. 2020-08-31 14:32 A second entry in what I hope to be a long series.
2020-09-24 09:14 The third entry finally after weeks without writing. 2020-09-24 09:14 The third entry finally after weeks without writing.
2022-04-23 10:30 Entry the first. 2022-04-23 10:30 Entry the first.
"""
Examples: Configs Examples: Configs
| config_file | | config_file |
| basic_onefile.yaml | | basic_onefile.yaml |
| basic_folder.yaml | | basic_folder.yaml |
| basic_encrypted.yaml |
# | basic_dayone.yaml | @todo # | basic_dayone.yaml | @todo
Scenario Outline: Change time flag with multiple tags changes all entries matching any of the tags Scenario Outline: Change time flag with multiple tags changes all entries matching any of the tags
Given we use the config "<config_file>" Given we use the config "<config_file>"
And we use the password "test" if prompted
When we run "jrnl --change-time '2022-04-23 10:30' @ipsum @tagthree" and enter When we run "jrnl --change-time '2022-04-23 10:30' @ipsum @tagthree" and enter
"""
Y Y
Y Y
"""
When we run "jrnl -99 --short" When we run "jrnl -99 --short"
Then the output should be Then the output should be
"""
2020-08-31 14:32 A second entry in what I hope to be a long series. 2020-08-31 14:32 A second entry in what I hope to be a long series.
2022-04-23 10:30 Entry the first. 2022-04-23 10:30 Entry the first.
2022-04-23 10:30 The third entry finally after weeks without writing. 2022-04-23 10:30 The third entry finally after weeks without writing.
"""
Examples: Configs Examples: Configs
| config_file | | config_file |
| basic_onefile.yaml | | basic_onefile.yaml |
| basic_folder.yaml | | basic_folder.yaml |
| basic_encrypted.yaml |
# | basic_dayone.yaml | @todo # | basic_dayone.yaml | @todo
Scenario Outline: Change time flag with -and changes boolean AND of tagged entries Scenario Outline: Change time flag with -and changes boolean AND of tagged entries
Given we use the config "<config_file>" Given we use the config "<config_file>"
And we use the password "test" if prompted
When we run "jrnl --change-time '2022-04-23 10:30' -and @tagone @tagtwo" and enter When we run "jrnl --change-time '2022-04-23 10:30' -and @tagone @tagtwo" and enter
"""
Y Y
"""
When we run "jrnl -99 --short" When we run "jrnl -99 --short"
Then the output should be Then the output should be
"""
2020-08-31 14:32 A second entry in what I hope to be a long series. 2020-08-31 14:32 A second entry in what I hope to be a long series.
2020-09-24 09:14 The third entry finally after weeks without writing. 2020-09-24 09:14 The third entry finally after weeks without writing.
2022-04-23 10:30 Entry the first. 2022-04-23 10:30 Entry the first.
"""
Examples: Configs Examples: Configs
| config_file | | config_file |
| basic_onefile.yaml | | basic_onefile.yaml |
| basic_folder.yaml | | basic_folder.yaml |
| basic_encrypted.yaml |
# | basic_dayone.yaml | @todo # | basic_dayone.yaml | @todo
Scenario Outline: Change time flag with -not does not change entries from given tag Scenario Outline: Change time flag with -not does not change entries from given tag
Given we use the config "<config_file>" Given we use the config "<config_file>"
And we use the password "test" if prompted
When we run "jrnl --change-time '2022-04-23 10:30' @tagone -not @ipsum" and enter When we run "jrnl --change-time '2022-04-23 10:30' @tagone -not @ipsum" and enter
"""
Y Y
"""
When we run "jrnl -99 --short" When we run "jrnl -99 --short"
Then the output should be Then the output should be
"""
2020-08-29 11:11 Entry the first. 2020-08-29 11:11 Entry the first.
2020-08-31 14:32 A second entry in what I hope to be a long series. 2020-08-31 14:32 A second entry in what I hope to be a long series.
2022-04-23 10:30 The third entry finally after weeks without writing. 2022-04-23 10:30 The third entry finally after weeks without writing.
"""
Examples: Configs Examples: Configs
| config_file | | config_file |
| basic_onefile.yaml | | basic_onefile.yaml |
| basic_folder.yaml | | basic_folder.yaml |
| basic_encrypted.yaml |
# | basic_dayone.yaml | @todo # | basic_dayone.yaml | @todo
Scenario Outline: Change time flag with -from search operator only changes entries since that date Scenario Outline: Change time flag with -from search operator only changes entries since that date
Given we use the config "<config_file>" Given we use the config "<config_file>"
And we use the password "test" if prompted
When we run "jrnl --change-time '2022-04-23 10:30' -from 2020-09-01" and enter When we run "jrnl --change-time '2022-04-23 10:30' -from 2020-09-01" and enter
"""
Y Y
"""
When we run "jrnl -99 --short" When we run "jrnl -99 --short"
Then the output should be Then the output should be
"""
2020-08-29 11:11 Entry the first. 2020-08-29 11:11 Entry the first.
2020-08-31 14:32 A second entry in what I hope to be a long series. 2020-08-31 14:32 A second entry in what I hope to be a long series.
2022-04-23 10:30 The third entry finally after weeks without writing. 2022-04-23 10:30 The third entry finally after weeks without writing.
"""
Examples: Configs Examples: Configs
| config_file | | config_file |
| basic_onefile.yaml | | basic_onefile.yaml |
| basic_folder.yaml | | basic_folder.yaml |
| basic_encrypted.yaml |
# | basic_dayone.yaml | @todo # | basic_dayone.yaml | @todo
Scenario Outline: Change time flag with -to only changes entries up to specified date Scenario Outline: Change time flag with -to only changes entries up to specified date
Given we use the config "<config_file>" Given we use the config "<config_file>"
And we use the password "test" if prompted
When we run "jrnl --change-time '2022-04-23 10:30' -to 2020-08-31" and enter When we run "jrnl --change-time '2022-04-23 10:30' -to 2020-08-31" and enter
"""
Y Y
Y Y
"""
When we run "jrnl -99 --short" When we run "jrnl -99 --short"
Then the output should be Then the output should be
"""
2020-09-24 09:14 The third entry finally after weeks without writing. 2020-09-24 09:14 The third entry finally after weeks without writing.
2022-04-23 10:30 Entry the first. 2022-04-23 10:30 Entry the first.
2022-04-23 10:30 A second entry in what I hope to be a long series. 2022-04-23 10:30 A second entry in what I hope to be a long series.
"""
Examples: Configs Examples: Configs
| config_file | | config_file |
| basic_onefile.yaml | | basic_onefile.yaml |
| basic_folder.yaml | | basic_folder.yaml |
| basic_encrypted.yaml |
# | basic_dayone.yaml | @todo # | basic_dayone.yaml | @todo
Scenario Outline: Change time flag with -starred only changes starred entries Scenario Outline: Change time flag with -starred only changes starred entries
Given we use the config "<config_file>" Given we use the config "<config_file>"
And we use the password "test" if prompted
When we run "jrnl --change-time '2022-04-23 10:30' -starred" and enter When we run "jrnl --change-time '2022-04-23 10:30' -starred" and enter
"""
Y Y
"""
When we run "jrnl -99 --short" When we run "jrnl -99 --short"
Then the output should be Then the output should be
"""
2020-08-29 11:11 Entry the first. 2020-08-29 11:11 Entry the first.
2020-09-24 09:14 The third entry finally after weeks without writing. 2020-09-24 09:14 The third entry finally after weeks without writing.
2022-04-23 10:30 A second entry in what I hope to be a long series. 2022-04-23 10:30 A second entry in what I hope to be a long series.
"""
Examples: Configs Examples: Configs
| config_file | | config_file |
| basic_onefile.yaml | | basic_onefile.yaml |
| basic_folder.yaml | | basic_folder.yaml |
| basic_encrypted.yaml |
# | basic_dayone.yaml | @todo # | basic_dayone.yaml | @todo
Scenario Outline: Change time flag with -contains only changes entries containing expression Scenario Outline: Change time flag with -contains only changes entries containing expression
Given we use the config "<config_file>" Given we use the config "<config_file>"
And we use the password "test" if prompted
When we run "jrnl --change-time '2022-04-23 10:30' -contains dignissim" and enter When we run "jrnl --change-time '2022-04-23 10:30' -contains dignissim" and enter
"""
Y Y
"""
Then the error output should contain "1 entry modified"
When we run "jrnl -99 --short" When we run "jrnl -99 --short"
Then the output should be Then the output should be
"""
2020-08-31 14:32 A second entry in what I hope to be a long series. 2020-08-31 14:32 A second entry in what I hope to be a long series.
2020-09-24 09:14 The third entry finally after weeks without writing. 2020-09-24 09:14 The third entry finally after weeks without writing.
2022-04-23 10:30 Entry the first. 2022-04-23 10:30 Entry the first.
"""
Examples: Configs Examples: Configs
| config_file | | config_file |
| basic_onefile.yaml | | basic_onefile.yaml |
| basic_folder.yaml | | basic_folder.yaml |
| basic_encrypted.yaml |
# | basic_dayone.yaml | @todo # | basic_dayone.yaml | @todo
Scenario Outline: Change time flag with no enties specified changes nothing Scenario Outline: Change time flag with no entries specified changes nothing
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
When we run "jrnl --change-time" and enter When we run "jrnl --change-time" and enter
"""
N N
N N
N N
"""
When we run "jrnl -99 --short" When we run "jrnl -99 --short"
Then the output should be Then the output should be
"""
2020-08-29 11:11 Entry the first. 2020-08-29 11:11 Entry the first.
2020-08-31 14:32 A second entry in what I hope to be a long series. 2020-08-31 14:32 A second entry in what I hope to be a long series.
2020-09-24 09:14 The third entry finally after weeks without writing. 2020-09-24 09:14 The third entry finally after weeks without writing.
"""
Examples: Configs Examples: Configs
| config_file | | config_file |
| basic_onefile.yaml | | basic_onefile.yaml |
| basic_folder.yaml | | basic_folder.yaml |
| basic_dayone.yaml | | basic_encrypted.yaml |
| basic_dayone.yaml |
Scenario Outline: --change-time with --edit modifies selected entries
Given we use the config "<config_file>"
And we write nothing to the editor if opened
And we use the password "test" if prompted
When we run "jrnl --change-time '2022-04-23 10:30' --edit" and enter
Y
N
Y
Then the error output should contain "No entry to save"
And the editor should have been called
When we run "jrnl -99 --short"
Then the output should be
2020-08-31 14:32 A second entry in what I hope to be a long series.
2022-04-23 10:30 Entry the first.
2022-04-23 10:30 The third entry finally after weeks without writing.
Examples: Configs
| config_file |
| basic_onefile.yaml |
| basic_folder.yaml |
# | basic_dayone.yaml | @todo

View file

@ -1,4 +1,4 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
Feature: Multiple journals Feature: Multiple journals
@ -7,8 +7,8 @@ Feature: Multiple journals
Given the config "basic_onefile.yaml" exists Given the config "basic_onefile.yaml" exists
And we use the config "multiple.yaml" And we use the config "multiple.yaml"
When we run "jrnl --cf basic_onefile.yaml -999" When we run "jrnl --cf basic_onefile.yaml -999"
Then the output should not contain "My first entry" # from multiple.yaml Then the output should not contain "My first entry"
And the output should contain "Lorem ipsum" # from basic_onefile.yaml And the output should contain "Lorem ipsum"
Scenario: Write to default journal by default using an alternate config Scenario: Write to default journal by default using an alternate config
Given the config "multiple.yaml" exists Given the config "multiple.yaml" exists
@ -64,27 +64,31 @@ Feature: Multiple journals
Then the output should contain "sell my junk on ebay and make lots of money" Then the output should contain "sell my junk on ebay and make lots of money"
Scenario: Don't crash if no default journal is specified using an alternate config Scenario: Don't crash if no default journal is specified using an alternate config
Given the config "bug343.yaml" exists Given the config "no_default_journal.yaml" exists
And we use the config "basic_onefile.yaml" And we use the config "basic_onefile.yaml"
When we run "jrnl --cf bug343.yaml a long day in the office" When we run "jrnl --cf no_default_journal.yaml a long day in the office"
Then the output should contain "No default journal configured" Then the output should contain "No 'default' journal configured"
Scenario: Don't crash if no file exists for a configured encrypted journal using an alternate config Scenario: Don't crash if no file exists for a configured encrypted journal using an alternate config
Given the config "multiple.yaml" exists Given the config "multiple.yaml" exists
And we use the config "basic_onefile.yaml" And we use the config "basic_onefile.yaml"
When we run "jrnl new_encrypted --cf multiple.yaml Adding first entry" and enter When we run "jrnl new_encrypted --cf multiple.yaml Adding first entry" and enter
"""
these three eyes these three eyes
these three eyes these three eyes
n n
"""
Then the output should contain "Journal 'new_encrypted' created at " Then the output should contain "Journal 'new_encrypted' created at "
Scenario: Don't overwrite main config when encrypting a journal in an alternate config Scenario: Don't overwrite main config when encrypting a journal in an alternate config
Given the config "basic_onefile.yaml" exists Given the config "basic_onefile.yaml" exists
And we use the config "multiple.yaml" And we use the config "multiple.yaml"
When we run "jrnl --cf basic_onefile.yaml --encrypt" and enter When we run "jrnl --cf basic_onefile.yaml --encrypt" and enter
"""
these three eyes these three eyes
these three eyes these three eyes
n n
"""
Then the output should contain "Journal encrypted to features/journals/basic_onefile.journal" Then the output should contain "Journal encrypted to features/journals/basic_onefile.journal"
And the config should contain "encrypt: false" And the config should contain "encrypt: false"
@ -122,7 +126,7 @@ Feature: Multiple journals
And we use the config "duplicate_keys.yaml" And we use the config "duplicate_keys.yaml"
When we run "jrnl -1" When we run "jrnl -1"
Then the output should contain "There is at least one duplicate key in your configuration file" Then the output should contain "There is at least one duplicate key in your configuration file"
Scenario: Show a warning message when using --config-file with duplicate keys Scenario: Show a warning message when using --config-file with duplicate keys
Given the config "duplicate_keys.yaml" exists Given the config "duplicate_keys.yaml" exists
And we use the config "multiple.yaml" And we use the config "multiple.yaml"
@ -133,3 +137,9 @@ Feature: Multiple journals
Given we use the config "multiple.yaml" Given we use the config "multiple.yaml"
When we run "jrnl --config-override highlight false" When we run "jrnl --config-override highlight false"
Then the output should not contain "There is at least one duplicate key in your configuration file" Then the output should not contain "There is at least one duplicate key in your configuration file"
Scenario: Update version number in config file when running newer version
Given we use the config "format_md.yaml"
When we run "jrnl -1"
Then the output should contain "Configuration updated to newest version at"
And the version in the config file should be up-to-date

View file

@ -1,4 +1,4 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
Feature: Functionality of jrnl outside of actually handling journals Feature: Functionality of jrnl outside of actually handling journals

View file

@ -1,4 +1,4 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
Feature: Reading and writing to journal with custom date formats Feature: Reading and writing to journal with custom date formats
@ -27,11 +27,13 @@ Feature: Reading and writing to journal with custom date formats
Then we should get no error Then we should get no error
When we run "jrnl -n 999" When we run "jrnl -n 999"
Then the output should be Then the output should be
"""
09.06.2013 15:39 My first entry. 09.06.2013 15:39 My first entry.
| Everything is alright | Everything is alright
10.07.2013 15:40 Life is good. 10.07.2013 15:40 Life is good.
| But I'm better. | But I'm better.
"""
Scenario Outline: Writing an entry from command line with custom date Scenario Outline: Writing an entry from command line with custom date
@ -142,9 +144,11 @@ Feature: Reading and writing to journal with custom date formats
Given we use the config "mostlyreadabledates.yaml" Given we use the config "mostlyreadabledates.yaml"
When we run "jrnl --short" When we run "jrnl --short"
Then the output should be Then the output should be
"""
2019-07-01 14:23 The third entry 2019-07-01 14:23 The third entry
2019-07-18 14:23 The first entry 2019-07-18 14:23 The first entry
2019-07-19 14:23 The second entry 2019-07-19 14:23 The second entry
"""
Scenario: Update near-valid dates after journal is edited Scenario: Update near-valid dates after journal is edited
@ -175,7 +179,9 @@ Feature: Reading and writing to journal with custom date formats
When we run "jrnl -1" When we run "jrnl -1"
Then we should get no error Then we should get no error
And the output should be And the output should be
"""
2013-10-27 04:27 Some text. 2013-10-27 04:27 Some text.
"""
@skip #1422 @skip #1422

View file

@ -1,4 +1,4 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2023 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
Feature: Delete entries from journal Feature: Delete entries from journal
@ -8,13 +8,19 @@ Feature: Delete entries from journal
When we run "jrnl -1" When we run "jrnl -1"
Then the output should contain "2020-09-24 09:14 The third entry finally" Then the output should contain "2020-09-24 09:14 The third entry finally"
When we run "jrnl --delete" and enter When we run "jrnl --delete" and enter
"""
N N
N N
Y Y
"""
Then the error output should contain "3 entries found"
And the error output should contain "1 entry deleted"
When we run "jrnl -99 --short" When we run "jrnl -99 --short"
Then the output should be Then the output should be
"""
2020-08-29 11:11 Entry the first. 2020-08-29 11:11 Entry the first.
2020-08-31 14:32 A second entry in what I hope to be a long series. 2020-08-31 14:32 A second entry in what I hope to be a long series.
"""
Examples: Configs Examples: Configs
| config_file | | config_file |
@ -27,12 +33,17 @@ Feature: Delete entries from journal
Scenario Outline: Backing out of interactive delete does not change journal Scenario Outline: Backing out of interactive delete does not change journal
Given we use the config "<config_file>" Given we use the config "<config_file>"
When we run "jrnl --delete -n 1" and enter When we run "jrnl --delete -n 1" and enter
"""
N N
"""
Then the error output should not contain "deleted"
When we run "jrnl -99 --short" When we run "jrnl -99 --short"
Then the output should be Then the output should be
"""
2020-08-29 11:11 Entry the first. 2020-08-29 11:11 Entry the first.
2020-08-31 14:32 A second entry in what I hope to be a long series. 2020-08-31 14:32 A second entry in what I hope to be a long series.
2020-09-24 09:14 The third entry finally after weeks without writing. 2020-09-24 09:14 The third entry finally after weeks without writing.
"""
Examples: Configs Examples: Configs
| config_file | | config_file |
@ -44,12 +55,14 @@ Feature: Delete entries from journal
Scenario Outline: Delete flag with nonsense input deletes nothing (issue #932) Scenario Outline: Delete flag with nonsense input deletes nothing (issue #932)
Given we use the config "<config_file>" Given we use the config "<config_file>"
When we run "jrnl --delete asdfasdf" When we run "jrnl --delete asdfasdf"
Then the output should contain "No entries to delete" Then the error output should contain "No entries to delete"
When we run "jrnl -99 --short" When we run "jrnl -99 --short"
Then the output should be Then the output should be
"""
2020-08-29 11:11 Entry the first. 2020-08-29 11:11 Entry the first.
2020-08-31 14:32 A second entry in what I hope to be a long series. 2020-08-31 14:32 A second entry in what I hope to be a long series.
2020-09-24 09:14 The third entry finally after weeks without writing. 2020-09-24 09:14 The third entry finally after weeks without writing.
"""
Examples: Configs Examples: Configs
| config_file | | config_file |
@ -61,11 +74,17 @@ Feature: Delete entries from journal
Scenario Outline: Delete flag with tag only deletes tagged entries Scenario Outline: Delete flag with tag only deletes tagged entries
Given we use the config "<config_file>" Given we use the config "<config_file>"
When we run "jrnl --delete @ipsum" and enter When we run "jrnl --delete @ipsum" and enter
"""
Y Y
"""
Then the error output should contain "1 entry found"
Then the error output should contain "1 entry deleted"
When we run "jrnl -99 --short" When we run "jrnl -99 --short"
Then the output should be Then the output should be
"""
2020-08-31 14:32 A second entry in what I hope to be a long series. 2020-08-31 14:32 A second entry in what I hope to be a long series.
2020-09-24 09:14 The third entry finally after weeks without writing. 2020-09-24 09:14 The third entry finally after weeks without writing.
"""
Examples: Configs Examples: Configs
| config_file | | config_file |
@ -77,11 +96,17 @@ Feature: Delete entries from journal
Scenario Outline: Delete flag with multiple tags deletes all entries matching any of the tags Scenario Outline: Delete flag with multiple tags deletes all entries matching any of the tags
Given we use the config "<config_file>" Given we use the config "<config_file>"
When we run "jrnl --delete @ipsum @tagthree" and enter When we run "jrnl --delete @ipsum @tagthree" and enter
"""
Y Y
Y Y
"""
Then the error output should contain "2 entries found"
And the error output should contain "2 entries deleted"
When we run "jrnl -99 --short" When we run "jrnl -99 --short"
Then the output should be Then the output should be
"""
2020-08-31 14:32 A second entry in what I hope to be a long series. 2020-08-31 14:32 A second entry in what I hope to be a long series.
"""
Examples: Configs Examples: Configs
| config_file | | config_file |
@ -93,11 +118,17 @@ Feature: Delete entries from journal
Scenario Outline: Delete flag with -and deletes boolean AND of tagged entries Scenario Outline: Delete flag with -and deletes boolean AND of tagged entries
Given we use the config "<config_file>" Given we use the config "<config_file>"
When we run "jrnl --delete -and @tagone @tagtwo" and enter When we run "jrnl --delete -and @tagone @tagtwo" and enter
"""
Y Y
"""
Then the error output should contain "1 entry found"
And the error output should contain "1 entry deleted"
When we run "jrnl -99 --short" When we run "jrnl -99 --short"
Then the output should be Then the output should be
"""
2020-08-31 14:32 A second entry in what I hope to be a long series. 2020-08-31 14:32 A second entry in what I hope to be a long series.
2020-09-24 09:14 The third entry finally after weeks without writing. 2020-09-24 09:14 The third entry finally after weeks without writing.
"""
Examples: Configs Examples: Configs
| config_file | | config_file |
@ -109,11 +140,17 @@ Feature: Delete entries from journal
Scenario Outline: Delete flag with -not does not delete entries from given tag Scenario Outline: Delete flag with -not does not delete entries from given tag
Given we use the config "<config_file>" Given we use the config "<config_file>"
When we run "jrnl --delete @tagone -not @ipsum" and enter When we run "jrnl --delete @tagone -not @ipsum" and enter
"""
Y Y
"""
Then the error output should contain "1 entry found"
And the error output should contain "1 entry deleted"
When we run "jrnl -99 --short" When we run "jrnl -99 --short"
Then the output should be Then the output should be
"""
2020-08-29 11:11 Entry the first. 2020-08-29 11:11 Entry the first.
2020-08-31 14:32 A second entry in what I hope to be a long series. 2020-08-31 14:32 A second entry in what I hope to be a long series.
"""
Examples: Configs Examples: Configs
| config_file | | config_file |
@ -125,11 +162,17 @@ Feature: Delete entries from journal
Scenario Outline: Delete flag with -from search operator only deletes entries since that date Scenario Outline: Delete flag with -from search operator only deletes entries since that date
Given we use the config "<config_file>" Given we use the config "<config_file>"
When we run "jrnl --delete -from 2020-09-01" and enter When we run "jrnl --delete -from 2020-09-01" and enter
"""
Y Y
"""
Then the error output should contain "1 entry found"
And the error output should contain "1 entry deleted"
When we run "jrnl -99 --short" When we run "jrnl -99 --short"
Then the output should be Then the output should be
"""
2020-08-29 11:11 Entry the first. 2020-08-29 11:11 Entry the first.
2020-08-31 14:32 A second entry in what I hope to be a long series. 2020-08-31 14:32 A second entry in what I hope to be a long series.
"""
Examples: Configs Examples: Configs
| config_file | | config_file |
@ -141,11 +184,17 @@ Feature: Delete entries from journal
Scenario Outline: Delete flag with -to only deletes entries up to specified date Scenario Outline: Delete flag with -to only deletes entries up to specified date
Given we use the config "<config_file>" Given we use the config "<config_file>"
When we run "jrnl --delete -to 2020-08-31" and enter When we run "jrnl --delete -to 2020-08-31" and enter
"""
Y Y
Y Y
"""
Then the error output should contain "2 entries found"
And the error output should contain "2 entries deleted"
When we run "jrnl -99 --short" When we run "jrnl -99 --short"
Then the output should be Then the output should be
"""
2020-09-24 09:14 The third entry finally after weeks without writing. 2020-09-24 09:14 The third entry finally after weeks without writing.
"""
Examples: Configs Examples: Configs
| config_file | | config_file |
@ -157,11 +206,16 @@ Feature: Delete entries from journal
Scenario Outline: Delete flag with -starred only deletes starred entries Scenario Outline: Delete flag with -starred only deletes starred entries
Given we use the config "<config_file>" Given we use the config "<config_file>"
When we run "jrnl --delete -starred" and enter When we run "jrnl --delete -starred" and enter
"""
Y Y
"""
Then the error output should contain "1 entry deleted"
When we run "jrnl -99 --short" When we run "jrnl -99 --short"
Then the output should be Then the output should be
"""
2020-08-29 11:11 Entry the first. 2020-08-29 11:11 Entry the first.
2020-09-24 09:14 The third entry finally after weeks without writing. 2020-09-24 09:14 The third entry finally after weeks without writing.
"""
Examples: Configs Examples: Configs
| config_file | | config_file |
@ -173,11 +227,17 @@ Feature: Delete entries from journal
Scenario Outline: Delete flag with -contains only entries containing expression Scenario Outline: Delete flag with -contains only entries containing expression
Given we use the config "<config_file>" Given we use the config "<config_file>"
When we run "jrnl --delete -contains dignissim" and enter When we run "jrnl --delete -contains dignissim" and enter
"""
Y Y
"""
Then the error output should contain "1 entry found"
And the error output should contain "1 entry deleted"
When we run "jrnl -99 --short" When we run "jrnl -99 --short"
Then the output should be Then the output should be
"""
2020-08-31 14:32 A second entry in what I hope to be a long series. 2020-08-31 14:32 A second entry in what I hope to be a long series.
2020-09-24 09:14 The third entry finally after weeks without writing. 2020-09-24 09:14 The third entry finally after weeks without writing.
"""
Examples: Configs Examples: Configs
| config_file | | config_file |

Some files were not shown because too many files have changed in this diff Show more