Compare commits
No commits in common. "develop" and "v0.3" have entirely different histories.
|
@ -1,8 +0,0 @@
|
|||
import toml
|
||||
|
||||
pyproject = toml.load("pyproject.toml")
|
||||
|
||||
pyproject["tool"]["poetry"]["dependencies"]["python"] = "*"
|
||||
|
||||
with open("pyproject.toml", "w") as toml_file:
|
||||
toml.dump(pyproject, toml_file)
|
4
.gitattributes
vendored
|
@ -1,4 +0,0 @@
|
|||
*.journal text eol=lf
|
||||
*.feature text eol=lf
|
||||
poetry.lock text eol=lf
|
||||
pyrpoject.toml text eol=lf
|
12
.github/FUNDING.yml
vendored
|
@ -1,12 +0,0 @@
|
|||
# These are supported funding model platforms
|
||||
|
||||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: jrnl
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
74
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
|
@ -1,74 +0,0 @@
|
|||
name: Bug Report
|
||||
description: Create a report to help us improve
|
||||
title: "Bug Report"
|
||||
labels: [ ":new:", "bug" ]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
# Bug Report
|
||||
Hello, and thank you for reporting an issue!
|
||||
|
||||
Please fill out the points below, as it will make our process much easier.
|
||||
|
||||
- type: textarea
|
||||
id: diagnostic
|
||||
attributes:
|
||||
label: Diagnostic output
|
||||
description: Run `jrnl --diagnostic` and paste the output below
|
||||
placeholder: Paste output here
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: current-behavior
|
||||
attributes:
|
||||
label: Current Behavior
|
||||
description: Please put a short description of what is currently happening.
|
||||
placeholder: Tell us what is happening
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: expected-behavior
|
||||
attributes:
|
||||
label: Expected Behavior
|
||||
description: Please write a short description of what you would expect to happen
|
||||
placeholder: Tell us what should be happening
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: repro-steps
|
||||
attributes:
|
||||
label: Repro Steps
|
||||
description: |
|
||||
Provide the steps to reproduce the problem.
|
||||
|
||||
Please be as precise as possible, since more info will let us help you faster.
|
||||
placeholder: Repro steps
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: debug-output
|
||||
attributes:
|
||||
label: Debug output
|
||||
description: |
|
||||
Please provide the output of your command with the `--debug` flag on.
|
||||
placeholder: "example: `jrnl --debug lorem ipsum`"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: other-info
|
||||
attributes:
|
||||
label: Other Information
|
||||
description: >
|
||||
Is there anything else we should know?
|
||||
|
||||
(e.g. more detailed explanation, stacktraces, related
|
||||
issues, suggestions how to fix, links for us to have context, eg.
|
||||
stackoverflow, gitter, etc)
|
||||
validations:
|
||||
required: false
|
1
.github/ISSUE_TEMPLATE/config.yml
vendored
|
@ -1 +0,0 @@
|
|||
blank_issues_enabled: false
|
41
.github/ISSUE_TEMPLATE/documentation.yaml
vendored
|
@ -1,41 +0,0 @@
|
|||
name: Documentation Change
|
||||
description: Request or report any updates to our documentation (https://jrnl.sh)
|
||||
title: Documentation Change
|
||||
labels: [ ":new:", "documentation" ]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
# Documentation Change
|
||||
Hello, and thank you for reporting an issue!
|
||||
|
||||
Please fill out the points below, as it will make our process much easier.
|
||||
|
||||
- type: textarea
|
||||
id: affected-pages
|
||||
attributes:
|
||||
label: Affected Page(s)
|
||||
description: >
|
||||
Please tell us which page, or pages, from the documentation site
|
||||
(https://jrnl.sh) are affected in this issue
|
||||
placeholder: "example: https://jrnl.sh/en/stable/overview"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: what-could-be-better
|
||||
attributes:
|
||||
label: What Could Be Better?
|
||||
description: >
|
||||
Please write a short description of what you hope can be clarified or
|
||||
further explained.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: other-info
|
||||
attributes:
|
||||
label: Other Information
|
||||
description: Is there anything else we should know that might be helpful?
|
||||
validations:
|
||||
required: false
|
43
.github/ISSUE_TEMPLATE/feature_request.yaml
vendored
|
@ -1,43 +0,0 @@
|
|||
name: Feature Request
|
||||
description: Suggest an idea for jrnl
|
||||
title: "Feature Report"
|
||||
labels: [ ":new:", "enhancement" ]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
# Feature Request
|
||||
Hello, and thank you for reporting an issue!
|
||||
|
||||
Please fill out the points below, as it will make our process much easier.
|
||||
|
||||
- type: textarea
|
||||
id: user-case
|
||||
attributes:
|
||||
label: Use Case/Motivation
|
||||
description: What is the motivation / use case for changing the behavior?
|
||||
placeholder: Tell us about your idea
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: example-usage
|
||||
attributes:
|
||||
label: Example Usage
|
||||
description: Please provide examples of the usage you would like to see.
|
||||
placeholder: e.g `jrnl --new-flag="super cool new feature"`
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: other-info
|
||||
attributes:
|
||||
label: Other Information
|
||||
description: >
|
||||
Is there anything else we should know?
|
||||
|
||||
(e.g. more detailed explanation, stacktraces, related
|
||||
issues, suggestions how to fix, links for us to have context, eg.
|
||||
stackoverflow, gitter, etc)
|
||||
validations:
|
||||
required: false
|
54
.github/ISSUE_TEMPLATE/support_request.yaml
vendored
|
@ -1,54 +0,0 @@
|
|||
name: Support Request
|
||||
description: Get help with jrnl
|
||||
title: Support Request
|
||||
labels: [ ":new:", "support" ]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
# Support Request
|
||||
Hello, and thank you for reporting an issue!
|
||||
|
||||
Please fill out the points below, as it will make our process much easier.
|
||||
|
||||
- type: textarea
|
||||
id: diagnostic
|
||||
attributes:
|
||||
label: Diagnostic output
|
||||
description: Run `jrnl --diagnostic` and paste the output below
|
||||
placeholder: Paste output here
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: current-behavior
|
||||
attributes:
|
||||
label: What are you trying to do?
|
||||
description: Please put a short description of what is happening.
|
||||
placeholder: Tell us what is happening
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: tried
|
||||
attributes:
|
||||
label: What have you tried?
|
||||
description: >
|
||||
Have you tried anything to fix the problem? This can help give us more
|
||||
information to help you with.
|
||||
placeholder: Tell us what should be happening
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: other-info
|
||||
attributes:
|
||||
label: Other Information
|
||||
description: >
|
||||
Is there anything else we should know?
|
||||
|
||||
(e.g. more detailed explanation, stacktraces, related
|
||||
issues, suggestions how to fix, links for us to have context, eg.
|
||||
stackoverflow, gitter, etc)
|
||||
validations:
|
||||
required: false
|
24
.github/PULL_REQUEST_TEMPLATE.md
vendored
|
@ -1,24 +0,0 @@
|
|||
<!--
|
||||
Thank you for wanting to contribute!
|
||||
|
||||
Please fill out this description, and the checklist below.
|
||||
|
||||
Here are some key points to include in your description:
|
||||
- What is this new code intended to do?
|
||||
- Are there any related issues?
|
||||
- What is the motivation for this change?
|
||||
- What is an example of usage, or changes to config files? (if applicable)
|
||||
-->
|
||||
|
||||
### Checklist
|
||||
|
||||
- [ ] 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 checked to ensure there aren't other open [pull requests](../pulls)
|
||||
for the same issue.
|
||||
- [ ] I have written new tests for these changes, as needed.
|
||||
<!--
|
||||
NOTE: Your PR may not be reviewed if there are any failing tests. You can run
|
||||
tests locally with `poe test` (see the contributing doc if you need help with
|
||||
`poe`), or use our automated tests after you submit your PR.
|
||||
-->
|
17
.github/actionlint-matcher.json
vendored
|
@ -1,17 +0,0 @@
|
|||
{
|
||||
"problemMatcher": [
|
||||
{
|
||||
"owner": "actionlint",
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "^(?:\\x1b\\[\\d+m)?(.+?)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*: (?:\\x1b\\[\\d+m)*(.+?)(?:\\x1b\\[\\d+m)* \\[(.+?)\\]$",
|
||||
"file": 1,
|
||||
"line": 2,
|
||||
"column": 3,
|
||||
"message": 4,
|
||||
"code": 5
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
46
.github/actions/run_tests/action.yaml
vendored
|
@ -1,46 +0,0 @@
|
|||
name: run jrnl tests
|
||||
description: Runs all jrnl tests on multiple platforms
|
||||
inputs:
|
||||
cache-string:
|
||||
description: 'Cache string secret. Change to bust the cache'
|
||||
required: true
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- run: git config --global core.autocrlf false
|
||||
shell: bash
|
||||
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
allow-prereleases: true
|
||||
|
||||
- name: Capture full Python version in env
|
||||
run: echo "PYTHON_FULL_VERSION=$(python --version)" >> $GITHUB_ENV
|
||||
shell: bash
|
||||
|
||||
- name: poetry cache # Change CACHE_STRING secret to bust the cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: .venv
|
||||
key: ${{ runner.os }}-${{ hashFiles('poetry.lock') }}-${{ env.PYTHON_FULL_VERSION }}-${{ inputs.cache-string }}
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
echo '::group::poetry'
|
||||
pip --disable-pip-version-check install poetry
|
||||
poetry config --local virtualenvs.in-project true
|
||||
echo '::endgroup::'
|
||||
|
||||
echo '::group::Other dependencies'
|
||||
poetry sync
|
||||
echo '::endgroup::'
|
||||
|
||||
echo 'DEPS_INSTALLED=true' >> $GITHUB_ENV
|
||||
shell: bash
|
||||
|
||||
- name: Linting & Testing
|
||||
if: ${{ env.DEPS_INSTALLED == 'true' }}
|
||||
run: poetry run poe test
|
||||
shell: bash
|
39
.github/lock.yml
vendored
|
@ -1,39 +0,0 @@
|
|||
# Configuration for Lock Threads - https://github.com/dessant/lock-threads-app
|
||||
|
||||
# Number of days of inactivity before a closed issue or pull request is locked
|
||||
daysUntilLock: 90
|
||||
|
||||
# Skip issues and pull requests created before a given timestamp. Timestamp must
|
||||
# follow ISO 8601 (`YYYY-MM-DD`). Set to `false` to disable
|
||||
skipCreatedBefore: false
|
||||
|
||||
# Issues and pull requests with these labels will be ignored. Set to `[]` to disable
|
||||
exemptLabels: []
|
||||
|
||||
# Label to add before locking, such as `outdated`. Set to `false` to disable
|
||||
lockLabel: ':lock:'
|
||||
|
||||
# Comment to post before locking. Set to `false` to disable
|
||||
lockComment: >
|
||||
This thread has been automatically locked since there has not been
|
||||
any recent activity after it was closed. Please open a new issue for
|
||||
related bugs. You can link back here from your new issue to continue
|
||||
the conversation.
|
||||
|
||||
# Assign `resolved` as the reason for locking. Set to `false` to disable
|
||||
setLockReason: true
|
||||
|
||||
# Limit to only `issues` or `pulls`
|
||||
# only: issues
|
||||
|
||||
# Optionally, specify configuration settings just for `issues` or `pulls`
|
||||
# issues:
|
||||
# exemptLabels:
|
||||
# - help-wanted
|
||||
# lockLabel: outdated
|
||||
|
||||
# pulls:
|
||||
# daysUntilLock: 30
|
||||
|
||||
# Repository to extend settings from
|
||||
# _extends: repo
|
14
.github/renovate.json
vendored
|
@ -1,14 +0,0 @@
|
|||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"config:base"
|
||||
],
|
||||
"schedule": [ "at any time" ],
|
||||
"prConcurrentLimit": 10,
|
||||
"prHourlyLimit": 10,
|
||||
"reviewers": [
|
||||
"wren",
|
||||
"micahellison"
|
||||
],
|
||||
"labels": [ "packaging" ]
|
||||
}
|
17
.github/stale.yml
vendored
|
@ -1,17 +0,0 @@
|
|||
# Number of days of inactivity before an issue becomes stale
|
||||
daysUntilStale: 60
|
||||
# Number of days of inactivity before a stale issue is closed
|
||||
daysUntilClose: 7
|
||||
# Issues with these labels will never be considered stale
|
||||
exemptLabels:
|
||||
- ':pushpin:'
|
||||
- critical
|
||||
# Label to use when marking an issue as stale
|
||||
staleLabel: stale
|
||||
# Comment to post when marking an issue as stale. Set to `false` to disable
|
||||
markComment: >
|
||||
This issue has been automatically marked as stale because it has not had
|
||||
recent activity. It will be closed if no further activity occurs. Thank you
|
||||
for your contributions.
|
||||
# Comment to post when closing a stale issue. Set to `false` to disable
|
||||
closeComment: false
|
170
.github/workflows/changelog.yaml
vendored
|
@ -1,170 +0,0 @@
|
|||
# Copyright © 2012-2023 jrnl contributors
|
||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
name: Changelog
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- develop
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
generate:
|
||||
if: >
|
||||
! contains(github.event.head_commit.message, '[ci skip]') &&
|
||||
! (
|
||||
startsWith(github.event.head_commit.message, 'Increment version to v') &&
|
||||
startsWith(github.ref, 'refs/heads/')
|
||||
)
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ secrets.JRNL_BOT_TOKEN }}
|
||||
|
||||
- name: Check branch for new commits, and env vars
|
||||
run: |
|
||||
echo "::group::git fetch origin --tags --force"
|
||||
git fetch origin --tags --force
|
||||
echo "::endgroup::"
|
||||
|
||||
TAG_REGEX='include-all'
|
||||
echo "::debug::GITHUB_REF: $GITHUB_REF"
|
||||
BRANCH="${GITHUB_REF##*/}"
|
||||
|
||||
if [[ $GITHUB_REF =~ ^refs/tags/ ]]; then
|
||||
# This is a tag build (i.e. a release)
|
||||
echo '::debug::Release build'
|
||||
if [[ ! $BRANCH =~ ^v[0-9]+(\.[0-9]+){1,2}(-(alpha|beta)([0-9]+)?)?$ ]]; then
|
||||
echo "::error::Invalid tag format: ${BRANCH}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
RELEASE=1
|
||||
BRANCH=develop
|
||||
git checkout $BRANCH
|
||||
|
||||
# if actual release (not pre), then changelog should exclude prereleases on update
|
||||
prerelease_regex='(alpha|beta)'
|
||||
if [[ ! ${GITHUB_REF##*/} =~ $prerelease_regex ]]; then
|
||||
echo '::debug::Actual release (not a prerelease)'
|
||||
TAG_REGEX="$prerelease_regex"
|
||||
echo "FULL_RELEASE=true" >> "$GITHUB_ENV"
|
||||
fi
|
||||
fi
|
||||
echo "::debug::TAG_REGEX: $TAG_REGEX"
|
||||
|
||||
if [[ "$(git rev-parse "origin/$BRANCH")" != "$GITHUB_SHA" ]]; then
|
||||
# Normal build on a branch (no tag)
|
||||
echo "::debug::BRANCH: $BRANCH $(git rev-parse "origin/$BRANCH")"
|
||||
echo "::debug::GITHUB_SHA: $GITHUB_SHA"
|
||||
echo "::error::$BRANCH has been updated since build started. Aborting changelog."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SINCE_TAG=$(git tag --sort=-creatordate | grep -Ev "$TAG_REGEX" | awk "NR==$(( 1 + ${RELEASE:-0} ))")
|
||||
|
||||
echo "::debug::BRANCH: $BRANCH"
|
||||
echo "::debug::TAG_REGEX: $TAG_REGEX"
|
||||
echo "::debug::FILENAME: CHANGELOG.md"
|
||||
echo "::debug::SINCE_TAG: $SINCE_TAG"
|
||||
|
||||
{
|
||||
echo "BRANCH=$BRANCH"
|
||||
echo "TAG_REGEX=$TAG_REGEX"
|
||||
echo "FILENAME=CHANGELOG.md"
|
||||
echo "SINCE_TAG=$SINCE_TAG"
|
||||
} >> "$GITHUB_ENV"
|
||||
|
||||
- name: Prep changelog file (clear out old lines)
|
||||
run: |
|
||||
# delete the top of the changelog up to the correct tag
|
||||
tagline=$(grep -n "^## \[${SINCE_TAG}\]" "$FILENAME" | awk '{print $1}' FS=':' | head -1)
|
||||
echo "tagline: ${tagline}"
|
||||
|
||||
if [[ -z $tagline ]]; then
|
||||
echo "::error::Something is wrong. ${SINCE_TAG} isn't in the changelog."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $tagline == 1 ]]; then
|
||||
echo "::error::Something is wrong."
|
||||
echo "::error::The latest release ${SINCE_TAG} is the first line in the changelog,"
|
||||
echo "::error::but the h1 '# Changelog' should always be the first line."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sed -i "1,$(( tagline - 1 ))d" "$FILENAME"
|
||||
# delete generated line (or it will be added multiple times)
|
||||
sed -i '/This Changelog was automatically generated by/d' "$FILENAME"
|
||||
# delete trailing empty lines
|
||||
sed -i -e :a -e '/^\n*$/{$d;N;};/\n$/ba' "$FILENAME"
|
||||
|
||||
- name: Generate changelog
|
||||
uses: heinrichreimer/action-github-changelog-generator@v2.1.1
|
||||
with:
|
||||
# see: https://github.com/heinrichreimer/action-github-changelog-generator
|
||||
repo: jrnl-org/jrnl
|
||||
token: ${{ secrets.JRNL_BOT_TOKEN }}
|
||||
base: CHANGELOG.md
|
||||
addSections: '{"build":{"prefix":"**Build:**","labels":["build"]},"docs":{"prefix":"**Documentation:**","labels":["documentation"]},"packaging":{"prefix":"**Packaging:**","labels":["packaging"]}}'
|
||||
issues: true
|
||||
pullRequests: true
|
||||
issuesWoLabels: false
|
||||
unreleased: true
|
||||
compareLink: true
|
||||
includeLabels: bug,enhancement,documentation,build,packaging,deprecated
|
||||
excludeLabels: stale,wontfix
|
||||
excludeTagsRegex: ${{ env.TAG_REGEX }}
|
||||
sinceTag: ${{ env.SINCE_TAG }}
|
||||
maxIssues: 150
|
||||
releaseUrl: https://pypi.org/project/jrnl/%s/
|
||||
releaseBranch: develop
|
||||
verbose: false
|
||||
author: true
|
||||
|
||||
- name: Small fixes
|
||||
run: |
|
||||
# Change unreleased link to correct url
|
||||
sed -i 's!https://pypi.org/project/jrnl/HEAD/!https://github.com/jrnl-org/jrnl/!' "$FILENAME"
|
||||
|
||||
- name: Diff and consistency check
|
||||
run: |
|
||||
git diff
|
||||
if [[ $(grep -c '^# Changelog$' "$FILENAME") != 1 ]]; then
|
||||
echo '::error::Something is wrong with the changelog.'
|
||||
exit 1
|
||||
fi
|
||||
SOMETHING_CHANGED=false
|
||||
git diff --exit-code || SOMETHING_CHANGED=true
|
||||
echo "::debug::SOMETHING_CHANGED: $SOMETHING_CHANGED"
|
||||
echo "SOMETHING_CHANGED=$SOMETHING_CHANGED" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Commit
|
||||
if: env.SOMETHING_CHANGED == 'true'
|
||||
run: |
|
||||
git config --global user.name "${{ secrets.JRNL_BOT_NAME }}"
|
||||
git config --global user.email "${{ secrets.JRNL_BOT_EMAIL }}"
|
||||
git add "$FILENAME"
|
||||
git commit -m "Update changelog [ci skip]"
|
||||
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
|
||||
if: env.FULL_RELEASE == 'true'
|
||||
run: |
|
||||
git fetch --unshallow origin
|
||||
git checkout release
|
||||
git merge --ff-only "$BRANCH"
|
||||
git push origin release
|
||||
|
76
.github/workflows/docs.yaml
vendored
|
@ -1,76 +0,0 @@
|
|||
# Copyright © 2012-2023 jrnl contributors
|
||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
name: Docs
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ develop, release ]
|
||||
paths:
|
||||
- 'docs/**'
|
||||
- 'docs_theme/**'
|
||||
- 'mkdocs.yml'
|
||||
- 'readthedocs.yml'
|
||||
- '.github/workflows/docs.yaml'
|
||||
- 'tasks.py'
|
||||
- 'pyproject.toml'
|
||||
pull_request:
|
||||
branches: [ develop ]
|
||||
paths:
|
||||
- 'docs/**'
|
||||
- 'docs_theme/**'
|
||||
- 'mkdocs.yml'
|
||||
- 'readthedocs.yml'
|
||||
- '.github/workflows/docs.yaml'
|
||||
- 'tasks.py'
|
||||
- 'pyproject.toml'
|
||||
|
||||
jobs:
|
||||
accessibility:
|
||||
if: contains(toJson(github.event.commits), '[ci skip]') == false
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
python-version: [ '3.11' ]
|
||||
os: [ ubuntu-latest ]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- name: Setup Node.js environment
|
||||
uses: actions/setup-node@main
|
||||
|
||||
- name: Capture full Python version in env
|
||||
run: echo "PYTHON_FULL_VERSION=$(python --version)" >> "$GITHUB_ENV"
|
||||
|
||||
- name: poetry cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: .venv
|
||||
key: ${{ runner.os }}-${{ hashFiles('poetry.lock') }}-${{ env.PYTHON_FULL_VERSION }}-${{ secrets.CACHE_STRING }}
|
||||
|
||||
- name: npm cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: node_modules
|
||||
key: ${{ runner.os }}-pa11y-v3
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
pip install poetry
|
||||
poetry config --local virtualenvs.in-project true
|
||||
poetry sync --no-root
|
||||
npm install
|
||||
echo "node_modules/.bin" >> "$GITHUB_PATH"
|
||||
|
||||
- name: Start docs server
|
||||
run: poetry run poe docs-run &
|
||||
|
||||
- name: Accessibility testing (Pa11y)
|
||||
run: poetry run poe docs-check
|
109
.github/workflows/release.yaml
vendored
|
@ -1,109 +0,0 @@
|
|||
# Copyright © 2012-2023 jrnl contributors
|
||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
name: Release
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: 'Version (e.g. v2.5, v2.5.1-beta, v2.6-beta2)'
|
||||
type: string
|
||||
required: true
|
||||
include_repo_version:
|
||||
description: 'Update version in repo?'
|
||||
type: boolean
|
||||
required: true
|
||||
default: true
|
||||
include_pypi:
|
||||
description: 'Publish to PyPI?'
|
||||
type: boolean
|
||||
required: true
|
||||
default: true
|
||||
|
||||
jobs:
|
||||
validate:
|
||||
name: "Validate version string"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Validate version
|
||||
run: |
|
||||
JRNL_VERSION="${{ github.event.inputs.version }}"
|
||||
echo "::debug::version: $JRNL_VERSION"
|
||||
if [[ ! $JRNL_VERSION =~ ^v[0-9]+(\.[0-9]+){1,2}(-(alpha|beta)([0-9]+)?)?$ ]]; then
|
||||
echo
|
||||
echo "::error::Bad version"
|
||||
echo
|
||||
echo "Version string should match pattern above."
|
||||
echo "Here are some examples of valid version numbers:"
|
||||
echo
|
||||
echo " v2.5"
|
||||
echo " v2.5-alpha"
|
||||
echo " v2.5-beta"
|
||||
echo " v2.5.1"
|
||||
echo " v2.5.1-alpha"
|
||||
echo " v2.5.1-beta"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
release_pypi:
|
||||
needs: validate
|
||||
name: "Release to PyPI"
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
pypi_version: ${{ steps.pypi-version-getter.outputs.pypi_version }}
|
||||
env:
|
||||
HOME_REPO: ${{ secrets.HOME_REPO }}
|
||||
steps:
|
||||
- name: Get version
|
||||
run: |
|
||||
JRNL_VERSION="${{ github.event.inputs.version }}"
|
||||
echo "::debug::version: $JRNL_VERSION"
|
||||
echo "JRNL_VERSION=$JRNL_VERSION" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.13'
|
||||
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ secrets.JRNL_BOT_TOKEN }}
|
||||
|
||||
- name: Config git user
|
||||
run: |
|
||||
git config --global user.name "${{ secrets.JRNL_BOT_NAME }}"
|
||||
git config --global user.email "${{ secrets.JRNL_BOT_EMAIL }}"
|
||||
|
||||
- name: Install dependencies
|
||||
run: pip install poetry
|
||||
|
||||
- name: Update version in files
|
||||
if: ${{ github.event.inputs.include_repo_version == 'true' }}
|
||||
run: |
|
||||
poetry version "$JRNL_VERSION"
|
||||
echo "__version__ = \"$JRNL_VERSION\"" > jrnl/__version__.py
|
||||
|
||||
- name: Commit updated files
|
||||
if: ${{ github.event.inputs.include_repo_version == 'true' && github.repository == env.HOME_REPO }}
|
||||
run: |
|
||||
git add pyproject.toml jrnl/__version__.py
|
||||
git commit -m "Increment version to ${JRNL_VERSION}"
|
||||
git tag -a -m "$JRNL_VERSION" "$JRNL_VERSION"
|
||||
git push
|
||||
git push --tags
|
||||
|
||||
- name: Build
|
||||
run: poetry build
|
||||
|
||||
- name: Deploy to PyPI
|
||||
if: ${{ github.event.inputs.include_pypi == 'true' && github.repository == env.HOME_REPO }}
|
||||
env:
|
||||
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
|
||||
run: poetry publish
|
||||
|
||||
- name: Get PyPI version
|
||||
id: pypi-version-getter
|
||||
run: |
|
||||
pypi_version="$(find dist/jrnl-*.tar.gz | sed -r 's!dist/jrnl-(.*)\.tar\.gz!\1!')"
|
||||
echo "pypi_version=$pypi_version" >> "$GITHUB_OUTPUT"
|
35
.github/workflows/testing_pipelines.yaml
vendored
|
@ -1,35 +0,0 @@
|
|||
# Copyright © 2012-2023 jrnl contributors
|
||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
name: Testing Pipeline Files
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ develop, release ]
|
||||
paths:
|
||||
- '.github/workflows/**'
|
||||
- '.github/actions/**'
|
||||
pull_request:
|
||||
branches: [ develop ]
|
||||
paths:
|
||||
- '.github/workflows/**'
|
||||
- '.github/actions/**'
|
||||
schedule:
|
||||
- cron: '0 0 * * SAT'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
if: >
|
||||
! contains(github.event.head_commit.message, '[ci skip]')
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ ubuntu-latest ]
|
||||
steps:
|
||||
- run: git config --global core.autocrlf false
|
||||
- uses: actions/checkout@v4
|
||||
- name: Check workflow files
|
||||
uses: docker://rhysd/actionlint:latest
|
||||
with:
|
||||
args: -color
|
48
.github/workflows/testing_prs.yaml
vendored
|
@ -1,48 +0,0 @@
|
|||
# Copyright © 2012-2023 jrnl contributors
|
||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
name: Testing
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ develop, release ]
|
||||
paths:
|
||||
- 'jrnl/**'
|
||||
- 'features/**'
|
||||
- 'tests/**'
|
||||
- 'poetry.lock'
|
||||
- 'pyproject.toml'
|
||||
- '.github/workflows/testing_prs.yaml'
|
||||
- 'tasks.py'
|
||||
pull_request:
|
||||
branches: [ develop ]
|
||||
paths:
|
||||
- 'jrnl/**'
|
||||
- 'features/**'
|
||||
- 'tests/**'
|
||||
- 'poetry.lock'
|
||||
- 'pyproject.toml'
|
||||
- '.github/workflows/testing_prs.yaml'
|
||||
- 'tasks.py'
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash # needed to prevent Windows from using PowerShell
|
||||
|
||||
jobs:
|
||||
test:
|
||||
if: >
|
||||
! contains(github.event.head_commit.message, '[ci skip]')
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
python-version: [ '3.10', '3.11', '3.12', '3.13' ]
|
||||
os: [ ubuntu-latest, macos-latest, windows-latest ]
|
||||
steps:
|
||||
- run: git config --global core.autocrlf false
|
||||
- uses: actions/checkout@v4
|
||||
- name: Run tests
|
||||
uses: ./.github/actions/run_tests
|
||||
with:
|
||||
cache-string: ${{ secrets.CACHE_STRING }}
|
28
.github/workflows/testing_schedule.yaml
vendored
|
@ -1,28 +0,0 @@
|
|||
# Copyright © 2012-2023 jrnl contributors
|
||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
name: Testing
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 0 * * SAT'
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash # needed to prevent Windows from using PowerShell
|
||||
|
||||
jobs:
|
||||
test_all:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
python-version: [ '3.10', '3.11', '3.12', '3.13' ]
|
||||
os: [ ubuntu-latest, macos-latest, windows-latest ]
|
||||
steps:
|
||||
- run: git config --global core.autocrlf false
|
||||
- uses: actions/checkout@v4
|
||||
- name: Run tests
|
||||
uses: ./.github/actions/run_tests
|
||||
with:
|
||||
cache-string: ${{ secrets.CACHE_STRING }}
|
67
.gitignore
vendored
|
@ -1,63 +1,22 @@
|
|||
# Byte-compiled DLL and Shared Library files
|
||||
*.py[cod]
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Packages
|
||||
*.egg
|
||||
*.egg-info/
|
||||
*.egg-info
|
||||
dist
|
||||
build
|
||||
eggs
|
||||
parts
|
||||
bin
|
||||
var
|
||||
sdist
|
||||
develop-eggs
|
||||
.installed.cfg
|
||||
bin/
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
eggs/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
.tox/
|
||||
var/
|
||||
node_modules/
|
||||
__pycache__/
|
||||
.pytest_cache/
|
||||
.flakeheaven_cache/
|
||||
|
||||
# Versioning
|
||||
.python-version
|
||||
.tool-versions
|
||||
lib
|
||||
lib64
|
||||
|
||||
# Installer logs
|
||||
.DS_Store
|
||||
.travis-solo
|
||||
Icon
|
||||
pip-log.txt
|
||||
|
||||
# Documentation
|
||||
_build
|
||||
_sources
|
||||
_static
|
||||
coverage.xml
|
||||
exp/
|
||||
objects.inv
|
||||
searchindex.js
|
||||
|
||||
# virtualenv
|
||||
.venv*/
|
||||
env/
|
||||
env*/
|
||||
venv*/
|
||||
|
||||
# Editor and IDE specific files
|
||||
# Since contributors may want to user a variety of development tools it is
|
||||
# recommended that editor specific file types be ignored globally by each
|
||||
# contributor via a global gitignore. Instructions for setting up a global
|
||||
# ignore file can be found here:
|
||||
# https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files
|
||||
# (Configuring ignored files for all repositories on your computer)
|
||||
# Examples of such files are:
|
||||
# MS Visual Studio (PyTools)
|
||||
# obj
|
||||
# *.suo
|
||||
# PyCharm
|
||||
# .idea/
|
||||
# VS Code
|
||||
# .vscode/settings.json
|
|
@ -1,28 +0,0 @@
|
|||
# readthedocs.yml
|
||||
# Read the Docs configuration file
|
||||
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
|
||||
|
||||
# Required
|
||||
version: 2
|
||||
|
||||
# Set the OS
|
||||
build:
|
||||
os: ubuntu-22.04
|
||||
tools:
|
||||
python: "3"
|
||||
|
||||
|
||||
# Build documentation in the docs/ directory
|
||||
mkdocs:
|
||||
configuration: mkdocs.yml
|
||||
fail_on_warning: false
|
||||
|
||||
# Optionally build your docs in additional formats such as PDF
|
||||
formats:
|
||||
- pdf
|
||||
- epub
|
||||
|
||||
# Optionally set the version of Python and requirements required to build your docs
|
||||
python:
|
||||
install:
|
||||
- requirements: docs_theme/requirements.txt
|
1144
CHANGELOG.md
|
@ -1,127 +0,0 @@
|
|||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
We as members, contributors, and leaders pledge to make participation in our
|
||||
community a harassment-free experience for everyone, regardless of age, body
|
||||
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||
identity and expression, level of experience, education, socio-economic status,
|
||||
nationality, personal appearance, race, religion, or sexual identity
|
||||
and orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||
diverse, inclusive, and healthy community.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to a positive environment for our
|
||||
community include:
|
||||
|
||||
* Demonstrating empathy and kindness toward other people
|
||||
* Being respectful of differing opinions, viewpoints, and experiences
|
||||
* Giving and gracefully accepting constructive feedback
|
||||
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||
and learning from the experience
|
||||
* Focusing on what is best not just for us as individuals, but for the
|
||||
overall community
|
||||
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
* The use of sexualized language or imagery, and sexual attention or
|
||||
advances of any kind
|
||||
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or email
|
||||
address, without their explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Enforcement Responsibilities
|
||||
|
||||
Community leaders are responsible for clarifying and enforcing our standards of
|
||||
acceptable behavior and will take appropriate and fair corrective action in
|
||||
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||
or harmful.
|
||||
|
||||
Community leaders have the right and responsibility to remove, edit, or reject
|
||||
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||
decisions when appropriate.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies within all community spaces, and also applies when
|
||||
an individual is officially representing the community in public spaces.
|
||||
Examples of representing our community include using an official e-mail address,
|
||||
posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by [emailing the maintainers](mailto:maintainers@jrnl.sh).
|
||||
All complaints will be reviewed and investigated promptly and fairly.
|
||||
|
||||
All community leaders are obligated to respect the privacy and security of the
|
||||
reporter of any incident.
|
||||
|
||||
## Enforcement Guidelines
|
||||
|
||||
Community leaders will follow these Community Impact Guidelines in determining
|
||||
the consequences for any action they deem in violation of this Code of Conduct:
|
||||
|
||||
### 1. Correction
|
||||
|
||||
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||
unprofessional or unwelcome in the community.
|
||||
|
||||
**Consequence**: A private, written warning from community leaders, providing
|
||||
clarity around the nature of the violation and an explanation of why the
|
||||
behavior was inappropriate. A public apology may be requested.
|
||||
|
||||
### 2. Warning
|
||||
|
||||
**Community Impact**: A violation through a single incident or series
|
||||
of actions.
|
||||
|
||||
**Consequence**: A warning with consequences for continued behavior. No
|
||||
interaction with the people involved, including unsolicited interaction with
|
||||
those enforcing the Code of Conduct, for a specified period of time. This
|
||||
includes avoiding interactions in community spaces as well as external channels
|
||||
like social media. Violating these terms may lead to a temporary or
|
||||
permanent ban.
|
||||
|
||||
### 3. Temporary Ban
|
||||
|
||||
**Community Impact**: A serious violation of community standards, including
|
||||
sustained inappropriate behavior.
|
||||
|
||||
**Consequence**: A temporary ban from any sort of interaction or public
|
||||
communication with the community for a specified period of time. No public or
|
||||
private interaction with the people involved, including unsolicited interaction
|
||||
with those enforcing the Code of Conduct, is allowed during this period.
|
||||
Violating these terms may lead to a permanent ban.
|
||||
|
||||
### 4. Permanent Ban
|
||||
|
||||
**Community Impact**: Demonstrating a pattern of violation of community
|
||||
standards, including sustained inappropriate behavior, harassment of an
|
||||
individual, or aggression toward or disparagement of classes of individuals.
|
||||
|
||||
**Consequence**: A permanent ban from any sort of public interaction within
|
||||
the community.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 2.0, available at
|
||||
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
||||
|
||||
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
||||
enforcement ladder](https://github.com/mozilla/diversity).
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see the FAQ at
|
||||
https://www.contributor-covenant.org/faq. Translations are available at
|
||||
https://www.contributor-covenant.org/translations.
|
|
@ -1,8 +0,0 @@
|
|||
<!--
|
||||
Copyright © 2012-2023 jrnl contributors
|
||||
License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
-->
|
||||
|
||||
# Contributing
|
||||
|
||||
See "[Contributing](docs/contributing.md)" in the `docs` directory.
|
7
LICENSE
Normal file
|
@ -0,0 +1,7 @@
|
|||
Copyright (c) 2012 Manuel Ebert
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
675
LICENSE.md
|
@ -1,675 +0,0 @@
|
|||
### GNU GENERAL PUBLIC LICENSE
|
||||
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
<https://fsf.org/>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this
|
||||
license document, but changing it is not allowed.
|
||||
|
||||
### Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom
|
||||
to share and change all versions of a program--to make sure it remains
|
||||
free software for all its users. We, the Free Software Foundation, use
|
||||
the GNU General Public License for most of our software; it applies
|
||||
also to any other work released this way by its authors. You can apply
|
||||
it to your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you
|
||||
have certain responsibilities if you distribute copies of the
|
||||
software, or if you modify it: responsibilities to respect the freedom
|
||||
of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the
|
||||
manufacturer can do so. This is fundamentally incompatible with the
|
||||
aim of protecting users' freedom to change the software. The
|
||||
systematic pattern of such abuse occurs in the area of products for
|
||||
individuals to use, which is precisely where it is most unacceptable.
|
||||
Therefore, we have designed this version of the GPL to prohibit the
|
||||
practice for those products. If such problems arise substantially in
|
||||
other domains, we stand ready to extend this provision to those
|
||||
domains in future versions of the GPL, as needed to protect the
|
||||
freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish
|
||||
to avoid the special danger that patents applied to a free program
|
||||
could make it effectively proprietary. To prevent this, the GPL
|
||||
assures that patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
### TERMS AND CONDITIONS
|
||||
|
||||
#### 0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds
|
||||
of works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of
|
||||
an exact copy. The resulting work is called a "modified version" of
|
||||
the earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user
|
||||
through a computer network, with no transfer of a copy, is not
|
||||
conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices" to
|
||||
the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
#### 1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work for
|
||||
making modifications to it. "Object code" means any non-source form of
|
||||
a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users can
|
||||
regenerate automatically from other parts of the Corresponding Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that same
|
||||
work.
|
||||
|
||||
#### 2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not convey,
|
||||
without conditions so long as your license otherwise remains in force.
|
||||
You may convey covered works to others for the sole purpose of having
|
||||
them make modifications exclusively for you, or provide you with
|
||||
facilities for running those works, provided that you comply with the
|
||||
terms of this License in conveying all material for which you do not
|
||||
control copyright. Those thus making or running the covered works for
|
||||
you must do so exclusively on your behalf, under your direction and
|
||||
control, on terms that prohibit them from making any copies of your
|
||||
copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under the
|
||||
conditions stated below. Sublicensing is not allowed; section 10 makes
|
||||
it unnecessary.
|
||||
|
||||
#### 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such
|
||||
circumvention is effected by exercising rights under this License with
|
||||
respect to the covered work, and you disclaim any intention to limit
|
||||
operation or modification of the work as a means of enforcing, against
|
||||
the work's users, your or third parties' legal rights to forbid
|
||||
circumvention of technological measures.
|
||||
|
||||
#### 4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
#### 5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these
|
||||
conditions:
|
||||
|
||||
- a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
- b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under
|
||||
section 7. This requirement modifies the requirement in section 4
|
||||
to "keep intact all notices".
|
||||
- c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
- d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
#### 6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms of
|
||||
sections 4 and 5, provided that you also convey the machine-readable
|
||||
Corresponding Source under the terms of this License, in one of these
|
||||
ways:
|
||||
|
||||
- a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
- b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the Corresponding
|
||||
Source from a network server at no charge.
|
||||
- c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
- d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
- e) Convey the object code using peer-to-peer transmission,
|
||||
provided you inform other peers where the object code and
|
||||
Corresponding Source of the work are being offered to the general
|
||||
public at no charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal,
|
||||
family, or household purposes, or (2) anything designed or sold for
|
||||
incorporation into a dwelling. In determining whether a product is a
|
||||
consumer product, doubtful cases shall be resolved in favor of
|
||||
coverage. For a particular product received by a particular user,
|
||||
"normally used" refers to a typical or common use of that class of
|
||||
product, regardless of the status of the particular user or of the way
|
||||
in which the particular user actually uses, or expects or is expected
|
||||
to use, the product. A product is a consumer product regardless of
|
||||
whether the product has substantial commercial, industrial or
|
||||
non-consumer uses, unless such uses represent the only significant
|
||||
mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to
|
||||
install and execute modified versions of a covered work in that User
|
||||
Product from a modified version of its Corresponding Source. The
|
||||
information must suffice to ensure that the continued functioning of
|
||||
the modified object code is in no case prevented or interfered with
|
||||
solely because modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or
|
||||
updates for a work that has been modified or installed by the
|
||||
recipient, or for the User Product in which it has been modified or
|
||||
installed. Access to a network may be denied when the modification
|
||||
itself materially and adversely affects the operation of the network
|
||||
or violates the rules and protocols for communication across the
|
||||
network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
#### 7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders
|
||||
of that material) supplement the terms of this License with terms:
|
||||
|
||||
- a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
- b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
- c) Prohibiting misrepresentation of the origin of that material,
|
||||
or requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
- d) Limiting the use for publicity purposes of names of licensors
|
||||
or authors of the material; or
|
||||
- e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
- f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions
|
||||
of it) with contractual assumptions of liability to the recipient,
|
||||
for any liability that these contractual assumptions directly
|
||||
impose on those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions; the
|
||||
above requirements apply either way.
|
||||
|
||||
#### 8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your license
|
||||
from a particular copyright holder is reinstated (a) provisionally,
|
||||
unless and until the copyright holder explicitly and finally
|
||||
terminates your license, and (b) permanently, if the copyright holder
|
||||
fails to notify you of the violation by some reasonable means prior to
|
||||
60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
#### 9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or run
|
||||
a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
#### 10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
#### 11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims owned
|
||||
or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within the
|
||||
scope of its coverage, prohibits the exercise of, or is conditioned on
|
||||
the non-exercise of one or more of the rights that are specifically
|
||||
granted under this License. You may not convey a covered work if you
|
||||
are a party to an arrangement with a third party that is in the
|
||||
business of distributing software, under which you make payment to the
|
||||
third party based on the extent of your activity of conveying the
|
||||
work, and under which the third party grants, to any of the parties
|
||||
who would receive the covered work from you, a discriminatory patent
|
||||
license (a) in connection with copies of the covered work conveyed by
|
||||
you (or copies made from those copies), or (b) primarily for and in
|
||||
connection with specific products or compilations that contain the
|
||||
covered work, unless you entered into that arrangement, or that patent
|
||||
license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
#### 12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under
|
||||
this License and any other pertinent obligations, then as a
|
||||
consequence you may not convey it at all. For example, if you agree to
|
||||
terms that obligate you to collect a royalty for further conveying
|
||||
from those to whom you convey the Program, the only way you could
|
||||
satisfy both those terms and this License would be to refrain entirely
|
||||
from conveying the Program.
|
||||
|
||||
#### 13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
#### 14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in
|
||||
detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies that a certain numbered version of the GNU General Public
|
||||
License "or any later version" applies to it, you have the option of
|
||||
following the terms and conditions either of that numbered version or
|
||||
of any later version published by the Free Software Foundation. If the
|
||||
Program does not specify a version number of the GNU General Public
|
||||
License, you may choose any version ever published by the Free
|
||||
Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future versions
|
||||
of the GNU General Public License can be used, that proxy's public
|
||||
statement of acceptance of a version permanently authorizes you to
|
||||
choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
#### 15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
|
||||
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
|
||||
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
|
||||
DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
|
||||
CORRECTION.
|
||||
|
||||
#### 16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR
|
||||
CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
|
||||
ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
|
||||
NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
|
||||
LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
|
||||
TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
|
||||
PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
#### 17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
### How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these
|
||||
terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest to
|
||||
attach them to the start of each source file to most effectively state
|
||||
the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper
|
||||
mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands \`show w' and \`show c' should show the
|
||||
appropriate parts of the General Public License. Of course, your
|
||||
program's commands might be different; for a GUI interface, you would
|
||||
use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. For more information on this, and how to apply and follow
|
||||
the GNU GPL, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your
|
||||
program into proprietary programs. If your program is a subroutine
|
||||
library, you may consider it more useful to permit linking proprietary
|
||||
applications with the library. If this is what you want to do, use the
|
||||
GNU Lesser General Public License instead of this License. But first,
|
||||
please read <https://www.gnu.org/licenses/why-not-lgpl.html>.
|
207
README.md
|
@ -1,85 +1,172 @@
|
|||
<!--
|
||||
Copyright © 2012-2023 jrnl contributors
|
||||
License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
-->
|
||||
|
||||
<p align="center">
|
||||
<a href="https://jrnl.sh">
|
||||
<img align="center" src="https://raw.githubusercontent.com/jrnl-org/jrnl/develop/docs_theme/assets/readme-header.png"/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
jrnl
|
||||
[](https://github.com/jrnl-org/jrnl/actions?query=workflow%3ATesting)
|
||||
[](https://pepy.tech/project/jrnl)
|
||||
[](https://pypi.python.org/pypi/jrnl/)
|
||||
[](https://formulae.brew.sh/formula/jrnl)
|
||||
[](https://gitter.im/jrnl-org/jrnl)
|
||||
[](https://github.com/jrnl-org/jrnl/blob/develop/CHANGELOG.md)
|
||||
====
|
||||
|
||||
_To get help, [submit an issue](https://github.com/jrnl-org/jrnl/issues/new/choose) on
|
||||
GitHub._
|
||||
*jrnl* is a simple journal application for your command line. Journals are stored as human readable plain text files - you can put them into a Dropbox folder for instant syncinc and you can be assured that your journal will still be readable in 2050, when all your fancy iPad journal applications will long be forgotten.
|
||||
|
||||
`jrnl` is a simple journal application for the command line.
|
||||
Optionally, your journal can be encrypted using the [256-bit AES](http://en.wikipedia.org/wiki/Advanced_Encryption_Standard).
|
||||
|
||||
You can use it to easily create, search, and view journal entries. Journals are
|
||||
stored as human-readable plain text, and can also be encrypted using [AES
|
||||
encryption](http://en.wikipedia.org/wiki/Advanced_Encryption_Standard).
|
||||
### Why keep a journal?
|
||||
|
||||
## In a Nutshell
|
||||
Journals aren't only for 13-year old girls and people who have too much time on their summer vacation. A journal helps you to keep track of the things you get done and how you did them. Your imagination may be limitless, but your memory isn't. For personal use, make it a good habit to write at least 20 words a day. Just to reflect what made this day special, why you haven't wasted it. For professional use, consider a text-based journal to be the perfect complement to your GTD todo list - a documentation of what and how you've done it.
|
||||
|
||||
To make a new entry, just enter
|
||||
In a Nutshell
|
||||
-------------
|
||||
|
||||
``` sh
|
||||
jrnl yesterday: Called in sick. Used the time to clean the house and write my
|
||||
book.
|
||||
```
|
||||
to make a new entry, just type
|
||||
|
||||
`yesterday:` is interpreted by `jrnl` as a timestamp. Everything until the
|
||||
first sentence ending (either `.`, `?`, or `!`) is interpreted as the title, and
|
||||
the rest as the body. In your journal file, the result will look like this:
|
||||
jrnl yesterday: Called in sick. Used the time to clean the house and spent 4h on writing my book.
|
||||
|
||||
[2012-03-29 09:00] Called in sick.
|
||||
Used the time to clean the house and write my book.
|
||||
and hit return. `yesterday:` will be interpreted as a timestamp. Everything until the first sentence mark (`.?!`) will be interpreted as the title, the rest as the body. In your journal file, the result will look like this:
|
||||
|
||||
If you just call `jrnl`, you will be prompted to compose your entry - but you
|
||||
can also configure _jrnl_ to use your external editor.
|
||||
2012-03-29 09:00 Called in sick.
|
||||
Used the time to clean the house and spent 4h on writing my book.
|
||||
|
||||
For more information, please read the
|
||||
[documentation](https://jrnl.sh).
|
||||
If you just call `jrnl`, you will be prompted to compose your entry - but you can also configure _jrnl_ to use your external editor.
|
||||
|
||||
## Contributors
|
||||
Usage
|
||||
-----
|
||||
|
||||
### Maintainers
|
||||
_jrnl_ has to modes: __composing__ and __viewing__.
|
||||
|
||||
Our maintainers help keep the lights on for the project:
|
||||
### Viewing:
|
||||
|
||||
* Jonathan Wren ([wren](https://github.com/wren))
|
||||
* Micah Ellison ([micahellison](https://github.com/micahellison))
|
||||
jrnl -n 10
|
||||
|
||||
Please thank them if you like `jrnl`!
|
||||
will list you the ten latest entries,
|
||||
|
||||
### Code Contributors
|
||||
jrnl -from "last year" -to march
|
||||
|
||||
This project is made with love by the many fabulous people who have contributed.
|
||||
`jrnl` couldn't exist without each and every one of you!
|
||||
everything that happened from the start of last year to the start of last march. If you only want to see the titles of your entries, use
|
||||
|
||||
<a href="https://github.com/jrnl-org/jrnl/graphs/contributors"><img
|
||||
src="https://opencollective.com/jrnl/contributors.svg?width=890&button=false"
|
||||
/></a>
|
||||
jrnl -short
|
||||
|
||||
If you'd also like to help make `jrnl` better, please see our [contributing
|
||||
documentation](docs/contributing.md).
|
||||
### Using Tags:
|
||||
|
||||
### Financial Backers
|
||||
Keep track of people, projects or locations, by tagging them with an `@` in your entries:
|
||||
|
||||
Another way show support is through direct financial contributions. These funds
|
||||
go to covering our costs, and are a quick way to show your appreciation for
|
||||
`jrnl`.
|
||||
jrnl Had a wonderful day on the #beach with @Tom and @Anna.
|
||||
|
||||
[Become a financial contributor](https://opencollective.com/jrnl/contribute)
|
||||
and help us sustain our community.
|
||||
You can filter your journal entries just like this:
|
||||
|
||||
<a href="https://opencollective.com/jrnl"><img
|
||||
src="https://opencollective.com/jrnl/individuals.svg?width=890"></a>
|
||||
jrnl @pinkie @WorldDomination
|
||||
|
||||
Will print all entries in which either `@pinkie` or `@WorldDomination` occurred.
|
||||
|
||||
jrnl -n 5 -and @pineapple @lubricant
|
||||
|
||||
the last five entries containing both `@pineapple` __and__ `@lubricant`. You can change which symbols you'd like to use for tagging in the configuration.
|
||||
|
||||
> __Note:__ `jrnl @pinkie @WorldDomination` will switch to viewing mode because although now command line arguments are given, all the input strings look like tags - _jrnl_ will assume you want to filter by tag.
|
||||
|
||||
### Smart timestamps:
|
||||
|
||||
Timestamps that work:
|
||||
|
||||
* at 6am
|
||||
* yesterday
|
||||
* last monday
|
||||
* sunday at noon
|
||||
* 2 march 2012
|
||||
* 7 apr
|
||||
* 5/20/1998 at 23:42
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
Install _jrnl_ using pip:
|
||||
|
||||
pip install jrnl
|
||||
|
||||
Alternatively, install manually by cloning the repository:
|
||||
|
||||
git clone git://github.com/maebert/jrnl.git
|
||||
cd jrnl
|
||||
python setup.py install
|
||||
|
||||
### Known Issues
|
||||
|
||||
- The Windows shell prior to Windows 7 has issues with unicode encoding. If you want to use non-ascii characters, change the codepage with `chcp 1252` before using `jrnl` (Thanks to Yves Pouplard for solving this!)
|
||||
- _jrnl_ relies on the `Crypto` package to encrypt journals, which has some known problems with installing within virtual environments.
|
||||
|
||||
Advanced usage
|
||||
--------------
|
||||
|
||||
The first time launched, _jrnl_ will create a file called `.jrnl_config` in your home directory.
|
||||
|
||||
### .jrnl_config
|
||||
|
||||
It's just a regular `json` file:
|
||||
|
||||
{
|
||||
journal: "~/journal.txt",
|
||||
editor: "",
|
||||
encrypt: false,
|
||||
password: ""
|
||||
tagsymbols: '@'
|
||||
default_hour: 9,
|
||||
default_minute: 0,
|
||||
timeformat: "%Y-%m-%d %H:%M",
|
||||
highlight: true
|
||||
}
|
||||
|
||||
- `journal`: path to your journal file
|
||||
- `editor`: if set, executes this command to launch an external editor for writing your entries, e.g. `vim` or `subl -w` (note the `-w` flag to make sure _jrnl_ waits for Sublime Text to close the file before writing into the journal).
|
||||
- `encrypt`: if `true`, encrypts your journal using AES.
|
||||
- `password`: you may store the password you used to encrypt your journal in plaintext here. This is useful if your journal file lives in an unsecure space (ie. your Dropbox), but the config file itself is more or less safe.
|
||||
- `tagsymbols`: Symbols to be interpreted as tags. (__See note below__)
|
||||
- `default_hour` and `default_minute`: if you supply a date, such as `last thursday`, but no specific time, the entry will be created at this time
|
||||
- `timeformat`: how to format the timestamps in your journal, see the [python docs](http://docs.python.org/library/time.html#time.strftime) for reference
|
||||
- `highlight`: if `true` and you have [clint](http://www.nicosphere.net/clint-command-line-library-for-python/) installed, tags will be highlighted in cyan.
|
||||
|
||||
> __Note on `tagsymbols`:__ Although it seems intuitive to use the `#` character for tags, there's a drawback: on most shells, this is interpreted as a meta-character starting a comment. This means that if you type
|
||||
>
|
||||
> jrnl Implemented endless scrolling on the #frontend of our website.
|
||||
>
|
||||
> your bash will chop off everything after the `#` before passing it to _jrnl_). To avoid this, wrap your input into quotation marks like this:
|
||||
>
|
||||
> jrnl "Implemented endless scrolling on the #frontend of our website."
|
||||
>
|
||||
> Or use the built-in prompt or an external editor to compose your entries.
|
||||
|
||||
### JSON export
|
||||
|
||||
Can do:
|
||||
|
||||
jrnl --json
|
||||
|
||||
Why not create a beautiful [timeline](http://timeline.verite.co/) of your journal?
|
||||
|
||||
### Tag export
|
||||
|
||||
With
|
||||
|
||||
jrnl --tags
|
||||
|
||||
you'll get a list of all tags you used in your journal, sorted by most frequent. Tags occuring several times in the same entry are only counted as one.
|
||||
|
||||
### Markdown export
|
||||
|
||||
jrnl --markdown
|
||||
|
||||
Markdown is a simple markup language that is human readable and can be used to be rendered to other formats (html, pdf). This README for example is formatted in markdown and github makes it look nice.
|
||||
|
||||
### Encryption
|
||||
|
||||
You can encrypt your existing journal file or change its password using
|
||||
|
||||
jrnl --encrypt
|
||||
|
||||
If it is already encrypted, you will first be asked for the current password. You can then enter a new password and your plain journal will replaced by the encrypted file. Conversely,
|
||||
|
||||
jrnl --decrypt
|
||||
|
||||
will replace your encrypted journal file by a Journal in plain text.
|
||||
|
||||
Should you ever want to decrypt your journal manually, you can do so with any program that supports the AES algorithm. The key used for encryption is the SHA-256-hash of your password, and the IV (initialisation vector) is stored in the first 16 bytes of the encrypted file. So, to decrypt a journal file in python, run
|
||||
|
||||
import hashlib, Crypto.Cipher
|
||||
key = hashlib.sha256(my_password).digest()
|
||||
with open("my_journal.txt") as f:
|
||||
cipher = f.read()
|
||||
crypto = AES.new(key, AES.MODE_CBC, iv = cipher[:16])
|
||||
plain = crypto.decrypt(cipher[16:])
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
# Security
|
||||
|
||||
If you've discovered a potential security issue in jrnl, please contact the maintainers at [maintainers@jrnl.sh](mailto:maintainers@jrnl.sh).
|
||||
|
||||
You can also feel free to [open an issue](https://github.com/jrnl-org/jrnl/issues/new/choose) (but please don't disclose the vulnerability) in case the email goes to spam.
|
||||
|
||||
You can find [known privacy and security issues in our documentation](https://jrnl.sh/en/stable/privacy-and-security/).
|
117
docs/advanced.md
|
@ -1,117 +0,0 @@
|
|||
<!--
|
||||
Copyright © 2012-2023 jrnl contributors
|
||||
License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
-->
|
||||
|
||||
# Advanced Usage
|
||||
|
||||
## Configuration File
|
||||
|
||||
`jrnl` has a wide variety of options that can be customized through the config file,
|
||||
including templates, formats, multiple journals, and more. See
|
||||
the [configuration file reference](./reference-config-file.md) for details
|
||||
or read on for some common use cases.
|
||||
|
||||
### Multiple journal files
|
||||
|
||||
You can configure `jrnl`to use with multiple journals (eg.
|
||||
`private` and `work`) by defining more journals in your [config file](./reference-config-file.md),
|
||||
for example:
|
||||
|
||||
``` yaml
|
||||
journals:
|
||||
default: ~/journal.txt
|
||||
work: ~/work.txt
|
||||
```
|
||||
|
||||
The `default` journal gets created the first time you start `jrnl`
|
||||
Now you can access the `work` journal by using `jrnl work` instead of
|
||||
`jrnl`, eg.
|
||||
|
||||
``` sh
|
||||
jrnl work at 10am: Meeting with @Steve
|
||||
jrnl work -n 3
|
||||
```
|
||||
|
||||
will both use `~/work.txt`, while `jrnl -n 3` will display the last
|
||||
three entries from `~/journal.txt` (and so does `jrnl default -n 3`).
|
||||
|
||||
You can also override the default options for each individual journal.
|
||||
If your `jrnl.yaml` looks like this:
|
||||
|
||||
``` yaml
|
||||
encrypt: false
|
||||
journals:
|
||||
default: ~/journal.txt
|
||||
work:
|
||||
journal: ~/work.txt
|
||||
encrypt: true
|
||||
food: ~/my_recipes.txt
|
||||
```
|
||||
|
||||
Your `default` and your `food` journals won't be encrypted, however your
|
||||
`work` journal will!
|
||||
|
||||
You can override all options that are present at
|
||||
the top level of `jrnl.yaml`, just make sure that at the very least
|
||||
you specify a `journal: ...` key that points to the journal file of
|
||||
that journal.
|
||||
|
||||
Consider the following example configuration
|
||||
|
||||
``` yaml
|
||||
editor: vi -c startinsert
|
||||
journals:
|
||||
default: ~/journal.txt
|
||||
work:
|
||||
journal: ~/work.txt
|
||||
encrypt: true
|
||||
display_format: json
|
||||
editor: code -rw
|
||||
food:
|
||||
display_format: markdown
|
||||
journal: ~/recipes.txt
|
||||
```
|
||||
|
||||
The `work` journal is encrypted, prints to `json` by default, and is edited using an existing window of VSCode. Similarly, the `food` journal prints to markdown by default, but uses all the other defaults.
|
||||
|
||||
### Modifying Configurations from the Command line
|
||||
|
||||
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`.
|
||||
|
||||
!!! note
|
||||
These overrides allow you to modify ***any*** field of your jrnl configuration. We trust that you know what you are doing.
|
||||
|
||||
#### Examples:
|
||||
|
||||
``` sh
|
||||
# Create an entry using the `stdin` prompt, for rapid logging
|
||||
jrnl --config-override editor ""
|
||||
|
||||
# Populate a project's log
|
||||
jrnl --config-override journals.todo "$(git rev-parse --show-toplevel)/todo.txt" todo find my towel
|
||||
|
||||
# Pass multiple overrides
|
||||
jrnl --config-override display_format fancy --config-override linewrap 20 \
|
||||
--config-override colors.title green
|
||||
```
|
||||
|
||||
### Using an alternate config
|
||||
|
||||
You can specify an alternate configuration file for the current instance of `jrnl` using `--config-file CONFIG_FILE_PATH` where
|
||||
`CONFIG_FILE_PATH` is a path to an alternate `jrnl` configuration file.
|
||||
|
||||
#### Examples:
|
||||
|
||||
``` sh
|
||||
# Use personalised configuration file for personal journal entries
|
||||
jrnl --config-file ~/foo/jrnl/personal-config.yaml
|
||||
|
||||
# Use alternate configuration file for work-related entries
|
||||
jrnl --config-file ~/foo/jrnl/work-config.yaml
|
||||
|
||||
# Use default configuration file (created on first run)
|
||||
jrnl
|
||||
```
|
|
@ -1,132 +0,0 @@
|
|||
<!--
|
||||
Copyright © 2012-2023 jrnl contributors
|
||||
License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
-->
|
||||
|
||||
# Contributing to jrnl
|
||||
|
||||
We welcome contributions to jrnl, whether it's through reporting bugs, improving the documentation, testing releases, engaging in discussion on features and bugs, or writing code.
|
||||
|
||||
## Table of Contents
|
||||
* [Code of Conduct](#code-of-conduct)
|
||||
* [Reporting Bugs](#reporting-bugs)
|
||||
* [Editing Documentation](#editing-documentation)
|
||||
* [Testing](#testing)
|
||||
* [Submitting feature requests and ideas](#submitting-feature-requests-and-ideas)
|
||||
* [Developing jrnl](#developing)
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
Before starting, please read the [Code of Conduct](https://github.com/jrnl-org/jrnl/blob/develop/CODE_OF_CONDUCT.md).
|
||||
|
||||
## Reporting Bugs
|
||||
|
||||
Please report bugs by [opening a new issue](https://github.com/jrnl-org/jrnl/issues/new/choose) and describing it as well as possible. Many bugs are specific to a particular operating system and Python version, so please include that information!
|
||||
|
||||
## Editing Documentation
|
||||
|
||||
If you find a typo or a mistake in the docs, please fix it right away and send a pull request. If you're unsure what to change but still see a problem, you can [open a new issue](https://github.com/jrnl-org/jrnl/issues/new/choose) with the "Documentation change" type.
|
||||
|
||||
To edit the documentation, edit the `docs/*.md` files on the **develop** branch. You can see the result by running `poe docs-run` inside the project's root directory, then navigating your browser to [localhost:8000](http://localhost:8000).
|
||||
|
||||
### External editors and tips and tricks
|
||||
|
||||
If you'd like to share a jrnl command line trick that you find useful, you may find it worthwhile to add it to the ["Tips and Tricks" section](tips-and-tricks.md). For advice on how to integrate a particular external editor, you can add to the ["External Editors" section](external-editors.md).
|
||||
|
||||
## Testing
|
||||
|
||||
Much of the work of maintaining jrnl involves testing rather than coding.
|
||||
|
||||
The nature of jrnl means we deal with extremely sensitive data, and can't risk data loss. While jrnl does have a comprehensive automated testing suite, user testing is crucial to mitigating this risk.
|
||||
|
||||
### Prereleases
|
||||
|
||||
[Prereleases are deployed through PyPi much like normal releases](https://pypi.org/project/jrnl/#history). You can use [pipx](https://pypi.org/project/pipx/) to fetch them and test them. See the [changelog](https://github.com/jrnl-org/jrnl/blob/develop/CHANGELOG.md) for information on what has changed with each release.
|
||||
|
||||
### Pull requests
|
||||
|
||||
If you are comfortable enough with git, feel free to fetch particular [pull requests](https://github.com/jrnl-org/jrnl/pulls), test them yourself, and report back your findings. Bonus points if you can add a screencast of how the new feature works.
|
||||
|
||||
### Confirm bug reports
|
||||
|
||||
There are always [open bugs among our GitHub issues](https://github.com/jrnl-org/jrnl/issues?q=is%3Aissue+is%3Aopen+label%3Abug) and many are specific to a particular OS, Python version, or jrnl version. A simple comment like "Confirmed on jrnl v2.2, MacOS 10.15, Python 3.8.1" would be extremely helpful in tracking down bugs.
|
||||
|
||||
### Automate tests
|
||||
|
||||
See the develop section below for information on how to contribute new automated tests.
|
||||
|
||||
## Submitting feature requests and ideas
|
||||
|
||||
If you have a feature request or idea for jrnl, please [open a new issue](https://github.com/jrnl-org/jrnl/issues/new/choose) and describe the goal of the feature, and any relevant use cases. We'll discuss the issue with you, and decide if it's a good fit for the project.
|
||||
|
||||
When discussing new features, please keep in mind our design goals. jrnl strives to
|
||||
[do one thing well](https://en.wikipedia.org/wiki/Unix_philosophy). To us, that means:
|
||||
|
||||
* being _nimble_
|
||||
* having a simple interface
|
||||
* avoiding duplicating functionality
|
||||
|
||||
## Developing
|
||||
|
||||
### Getting your environment set up
|
||||
|
||||
You will need to install [poetry](https://python-poetry.org/) to develop jrnl. It will take care of all of the project's other dependencies.
|
||||
|
||||
### Understanding the branches
|
||||
|
||||
jrnl uses two primary branches:
|
||||
|
||||
* `develop` - for ongoing development
|
||||
* `release` - for releases
|
||||
|
||||
In general, pull requests should be made on the `develop` branch.
|
||||
|
||||
### Common development commands
|
||||
|
||||
You can find an inventory of commands in the `pyproject.toml`. Users can run the commands by typing `poe` followed by the name of the command ([Poe the Poet](https://github.com/nat-n/poethepoet) can be installed on its own, or as part of `poetry install`).
|
||||
|
||||
A typical development workflow includes:
|
||||
|
||||
* Installing dependencies:
|
||||
* `poetry install`
|
||||
* Activate virtual environment:
|
||||
* `poetry shell`
|
||||
* Running the source in a virtual environment:
|
||||
* `jrnl` (with or without arguments as necessary)
|
||||
* Running tests:
|
||||
* `poe test`
|
||||
* Formatting the code to standardize its style:
|
||||
* `poe format`
|
||||
|
||||
### Updating automated tests
|
||||
|
||||
When resolving bugs or adding new functionality, please add tests to prevent that functionality from breaking in the future. If you notice any functionality that isn't covered in the tests, feel free to submit a test-only pull request as well.
|
||||
|
||||
For testing, jrnl uses [pytest](https://docs.pytest.org) for unit tests, and [pytest-bdd](https://pytest-bdd.readthedocs.io/) for integration testing. All tests are in the `tests` folder.
|
||||
|
||||
Many tests can be created by only editing `*.feature` files with the same format as other tests. For more complicated functionality, you may need to implement steps in `tests/lib/` which are then executed by your tests in the `feature` files.
|
||||
|
||||
### Submitting pull requests
|
||||
|
||||
When you're ready, feel free to submit a pull request (PR). The jrnl maintainers generally review the pull requests every two weeks, but the continuous integration pipeline will run on automated tests on it within a matter of minutes and will report back any issues it has found with your code across a variety of environments.
|
||||
|
||||
The pull request template contains a checklist full of housekeeping items. Please fill them out as necessary when you submit.
|
||||
|
||||
If a pull request contains failing tests, it probably will not be reviewed, and it definitely will not be approved. However, if you need help resolving a failing test, please mention that in your PR.
|
||||
|
||||
### Finding things to work on
|
||||
|
||||
You can search the [jrnl GitHub issues](https://github.com/jrnl-org/jrnl/issues) by [label](https://github.com/jrnl-org/jrnl/labels) for things to work on. Here are some labels worth searching:
|
||||
|
||||
* [critical](https://github.com/jrnl-org/jrnl/labels/critical)
|
||||
* [help wanted](https://github.com/jrnl-org/jrnl/labels/help%20wanted)
|
||||
* [bug](https://github.com/jrnl-org/jrnl/labels/bug)
|
||||
* [enhancement](https://github.com/jrnl-org/jrnl/labels/enhancement)
|
||||
|
||||
You can also get a feel for the project's priorities by reviewing the [milestones](https://github.com/jrnl-org/jrnl/milestones).
|
||||
|
||||
### A note for new programmers and programmers new to python
|
||||
|
||||
Although jrnl has grown quite a bit since its inception, the overall complexity (for an end-user program) is fairly low, and we hope you'll find the code easy enough to understand.
|
||||
|
||||
If you have a question, please don't hesitate to ask! Python is known for its welcoming community and openness to novice programmers, so feel free to fork the code and play around with it! If you create something you want to share with us, please create a pull request. We never expect pull requests to be perfect, idiomatic, instantly mergeable code. We can work through it together!
|
|
@ -1,160 +0,0 @@
|
|||
<!--
|
||||
Copyright © 2012-2023 jrnl contributors
|
||||
License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
-->
|
||||
|
||||
# Encryption
|
||||
|
||||
## A Note on Security
|
||||
|
||||
While `jrnl` follows best practices, total security is never possible in the
|
||||
real world. There are a number of ways that people can at least partially
|
||||
compromise your `jrnl` data. See the [Privacy and Security](./privacy-and-security.md) page
|
||||
for more information.
|
||||
|
||||
## Encrypting and Decrypting
|
||||
|
||||
Existing plain text journal files can be encrypted using the `--encrypt`
|
||||
command:
|
||||
|
||||
``` sh
|
||||
jrnl --encrypt [FILENAME]
|
||||
```
|
||||
|
||||
You can then enter a new password, and the unencrypted file will replaced with
|
||||
the new encrypted file.
|
||||
|
||||
This command also works to change the password for a journal file that is
|
||||
already encrypted. `jrnl` will prompt you for the current password and then new
|
||||
password.
|
||||
|
||||
Conversely,
|
||||
|
||||
``` sh
|
||||
jrnl --decrypt [FILENAME]
|
||||
```
|
||||
|
||||
replaces the encrypted journal file with a plain text file. You can also specify
|
||||
a filename, e.g., `jrnl --decrypt plain_text_copy.txt`, to leave the original
|
||||
encrypted file untouched and create a new plain text file next to it.
|
||||
|
||||
!!! note
|
||||
Changing `encrypt` in your [config file](./reference-config-file.md) to
|
||||
a different value will not encrypt or decrypt your
|
||||
journal file. It merely says whether or not your journal
|
||||
is encrypted. Hence manually changing
|
||||
this option will most likely result in your journal file being
|
||||
impossible to load. This is why the above commands are necessary.
|
||||
|
||||
## Storing Passwords in Your Keychain
|
||||
|
||||
Nobody can recover or reset your `jrnl` password. If you lose it,
|
||||
your data will be inaccessible forever.
|
||||
|
||||
For this reason, when encrypting a journal, `jrnl` asks whether you would like
|
||||
to store the password in your system's keychain. An added benefit is that you
|
||||
will not need to enter the password when interacting with the journal file.
|
||||
|
||||
If you don't initially store the password in your keychain but decide to do so
|
||||
later---or if you want to store it in one computer's keychain but not in another
|
||||
computer's---you can run `jrnl --encrypt` on an encrypted journal and use the
|
||||
same password again. This will trigger the keychain storage prompt.
|
||||
|
||||
## Manual Decryption
|
||||
|
||||
The easiest way to decrypt your journal is with `jrnl --decrypt`, but you could
|
||||
also decrypt your journal manually if needed. To do this, you can use any
|
||||
program that supports the AES algorithm (specifically AES-CBC), and you'll need
|
||||
the following relevant information for decryption:
|
||||
|
||||
- **Key:** The key used for encryption is the
|
||||
[SHA-256](https://en.wikipedia.org/wiki/SHA-2) hash of your password.
|
||||
- **Initialization vector (IV):** The IV is stored in the first 16 bytes of
|
||||
your encrypted journal file.
|
||||
- **The actual text of the journal** (everything after the first 16 bytes in
|
||||
the encrypted journal file) is encoded in
|
||||
[UTF-8](https://en.wikipedia.org/wiki/UTF-8) and padded according to
|
||||
[PKCS\#7](https://en.wikipedia.org/wiki/PKCS_7) before being encrypted.
|
||||
|
||||
If you'd like an example of what this might look like in script form, please
|
||||
see below for some examples of Python scripts that you could use to manually
|
||||
decrypt your journal.
|
||||
|
||||
|
||||
|
||||
!!! note
|
||||
These are only examples, and are only here to illustrate that your journal files
|
||||
will still be recoverable even if `jrnl` isn't around anymore. Please use
|
||||
`jrnl --decrypt` if available.
|
||||
|
||||
**Example for jrnl v2 files**:
|
||||
``` python
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Decrypt a jrnl v2 encrypted journal.
|
||||
|
||||
Note: the `cryptography` module must be installed (you can do this with
|
||||
something like `pip3 install crytography`)
|
||||
"""
|
||||
|
||||
import base64
|
||||
import getpass
|
||||
from pathlib import Path
|
||||
|
||||
from cryptography.fernet import Fernet
|
||||
from cryptography.hazmat.backends import default_backend
|
||||
from cryptography.hazmat.primitives import hashes
|
||||
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
|
||||
|
||||
filepath = input("journal file path: ")
|
||||
password = getpass.getpass("Password: ")
|
||||
|
||||
with open(Path(filepath), "rb") as f:
|
||||
ciphertext = f.read()
|
||||
|
||||
password = password.encode("utf-8")
|
||||
kdf = PBKDF2HMAC(
|
||||
algorithm=hashes.SHA256(),
|
||||
length=32,
|
||||
salt=b"\xf2\xd5q\x0e\xc1\x8d.\xde\xdc\x8e6t\x89\x04\xce\xf8",
|
||||
iterations=100_000,
|
||||
backend=default_backend(),
|
||||
)
|
||||
|
||||
key = base64.urlsafe_b64encode(kdf.derive(password))
|
||||
|
||||
print(Fernet(key).decrypt(ciphertext).decode("utf-8"))
|
||||
```
|
||||
|
||||
**Example for jrnl v1 files**:
|
||||
``` python
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Decrypt a jrnl v1 encrypted journal.
|
||||
|
||||
Note: the `pycrypto` module must be installed (you can do this with something
|
||||
like `pip3 install pycrypto`)
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import getpass
|
||||
import hashlib
|
||||
|
||||
from Crypto.Cipher import AES
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("filepath", help="journal file to decrypt")
|
||||
args = parser.parse_args()
|
||||
|
||||
pwd = getpass.getpass()
|
||||
key = hashlib.sha256(pwd.encode("utf-8")).digest()
|
||||
|
||||
with open(args.filepath, "rb") as f:
|
||||
ciphertext = f.read()
|
||||
|
||||
crypto = AES.new(key, AES.MODE_CBC, ciphertext[:16])
|
||||
plain = crypto.decrypt(ciphertext[16:])
|
||||
plain = plain.strip(plain[-1:])
|
||||
plain = plain.decode("utf-8")
|
||||
print(plain)
|
||||
```
|
|
@ -1,137 +0,0 @@
|
|||
<!--
|
||||
Copyright © 2012-2023 jrnl contributors
|
||||
License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
-->
|
||||
|
||||
# External editors
|
||||
|
||||
Configure your preferred external editor by updating the `editor` option
|
||||
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
|
||||
To save and log any entry edits, save and close the file.
|
||||
|
||||
All editors must be [blocking processes](https://en.wikipedia.org/wiki/Blocking_(computing)) to work with jrnl. Some editors, such as [micro](https://micro-editor.github.io/), are blocking by default, though others can be made to block with additional arguments, such as many of those documented below. If jrnl opens your editor but finishes running immediately, then your editor is not a blocking process, and you may be able to correct that with one of the suggestions below.
|
||||
|
||||
Please see [this section](./privacy-and-security.md#editor-history) about how
|
||||
your editor might leak sensitive information and how to mitigate that risk.
|
||||
|
||||
## Sublime Text
|
||||
|
||||
To use [Sublime Text](https://www.sublimetext.com/), install the command line
|
||||
tools for Sublime Text and configure your `jrnl.yaml` like this:
|
||||
|
||||
```yaml
|
||||
editor: "subl -w"
|
||||
```
|
||||
|
||||
Note the `-w` flag to make sure `jrnl` waits for Sublime Text to close the
|
||||
file before writing into the journal.
|
||||
|
||||
## Visual Studio Code
|
||||
|
||||
[Visual Studio Code](https://code.visualstudio.com) also requires a flag
|
||||
that tells the process to wait until the file is closed before exiting:
|
||||
|
||||
```yaml
|
||||
editor: "code --wait"
|
||||
```
|
||||
|
||||
On Windows, `code` is not added to the path by default, so you'll need to
|
||||
enter the full path to your `code.exe` file, or add it to the `PATH` variable.
|
||||
|
||||
## MacVim
|
||||
|
||||
Also similar to Sublime Text, MacVim must be started with a flag that tells
|
||||
the the process to wait until the file is closed before passing control
|
||||
back to journal. In the case of MacVim, this is `-f`:
|
||||
|
||||
```yaml
|
||||
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
|
||||
|
||||
On OS X, you can use the fabulous [iA
|
||||
Writer](http://www.iawriter.com/mac) to write entries. Configure your
|
||||
`jrnl.yaml` like this:
|
||||
|
||||
```yaml
|
||||
editor: "open -b pro.writer.mac -Wn"
|
||||
```
|
||||
|
||||
What does this do? `open -b ...` opens a file using the application
|
||||
identified by the bundle identifier (a unique string for every app out
|
||||
there). `-Wn` tells the application to wait until it's closed before
|
||||
passing back control, and to use a new instance of the application.
|
||||
|
||||
If the `pro.writer.mac` bundle identifier is not found on your system,
|
||||
you can find the right string to use by inspecting iA Writer's
|
||||
`Info.plist` file in your shell:
|
||||
|
||||
```sh
|
||||
grep -A 1 CFBundleIdentifier /Applications/iA\ Writer.app/Contents/Info.plist
|
||||
```
|
||||
|
||||
## Notepad++ on Windows
|
||||
|
||||
To set [Notepad++](http://notepad-plus-plus.org/) as your editor, edit
|
||||
the `jrnl` config file (`jrnl.yaml`) like this:
|
||||
|
||||
```yaml
|
||||
editor: "C:\\Program Files (x86)\\Notepad++\\notepad++.exe -multiInst -nosession"
|
||||
```
|
||||
|
||||
The double backslashes are needed so `jrnl` can read the file path
|
||||
correctly. The `-multiInst -nosession` options will cause `jrnl` to open
|
||||
its own Notepad++ window.
|
||||
|
||||
|
||||
## emacs
|
||||
|
||||
To use `emacs` as your editor, edit the `jrnl` config file (`jrnl.yaml`) like this:
|
||||
|
||||
```yaml
|
||||
editor: emacsclient -a "" -c
|
||||
```
|
||||
|
||||
When you're done editing the message, save and `C-x #` to close the buffer and stop the emacsclient process.
|
||||
|
||||
## Other editors
|
||||
|
||||
If you're using another editor and would like to share, feel free to [contribute documentation](./contributing.md#editing-documentation) on it.
|
354
docs/formats.md
|
@ -1,354 +0,0 @@
|
|||
<!--
|
||||
Copyright © 2012-2023 jrnl contributors
|
||||
License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
-->
|
||||
|
||||
# Formats
|
||||
|
||||
`jrnl` supports a variety of alternate formats. These can be used to display your
|
||||
journal in a different manner than the `jrnl` default, and can even be used to pipe data
|
||||
from your journal for use in another program to create reports, or do whatever you want
|
||||
with your `jrnl` data.
|
||||
|
||||
Any of these formats can be used with a search (e.g. `jrnl -contains "lorem ipsum"
|
||||
--format json`) to display the results of that search in the given format, or can be
|
||||
used alone (e.g. `jrnl --format json`) to display all entries from the selected journal.
|
||||
|
||||
This page shows examples of all the built-in formats, but since `jrnl` supports adding
|
||||
more formats through plugins, you may have more available on your system. Please see
|
||||
`jrnl --help` for a list of which formats are available on your system.
|
||||
|
||||
Any of these formats can be used interchangeably, and are only grouped into "display",
|
||||
"data", and "report" formats below for convenience.
|
||||
|
||||
## Display Formats
|
||||
These formats are mainly intended for displaying your journal in the terminal. Even so,
|
||||
they can still be used in the same way as any other format (like written to a file, if
|
||||
you choose).
|
||||
|
||||
### Pretty
|
||||
``` sh
|
||||
jrnl --format pretty
|
||||
# or
|
||||
jrnl -1 # any search
|
||||
```
|
||||
|
||||
This is the default format in `jrnl`. If no `--format` is given, `pretty` will be used.
|
||||
|
||||
It displays the timestamp of each entry formatted to by the user config followed by the
|
||||
title on the same line. Then the body of the entry is shown below.
|
||||
|
||||
This format is configurable through these values from your config file (see
|
||||
[Advanced Usage](./advanced.md) for more details):
|
||||
|
||||
- `colors`
|
||||
- `body`
|
||||
- `date`
|
||||
- `tags`
|
||||
- `title`
|
||||
- `indent_character`
|
||||
- `linewrap`
|
||||
- `timeformat`
|
||||
|
||||
**Example output**:
|
||||
``` sh
|
||||
2020-06-28 18:22 This is the first sample entry
|
||||
| This is the sample body text of the first sample entry.
|
||||
|
||||
2020-07-01 20:00 This is the second sample entry
|
||||
| This is the sample body text of the second sample entry, but
|
||||
| this one has a @tag.
|
||||
|
||||
2020-07-02 09:00 This is the third sample entry
|
||||
| This is the sample body text of the third sample entry.
|
||||
```
|
||||
|
||||
### Short
|
||||
|
||||
``` sh
|
||||
jrnl --format short
|
||||
# or
|
||||
jrnl --short
|
||||
```
|
||||
|
||||
This will shorten entries to display only the date and title. It is essentially the
|
||||
`pretty` format but without the body of each entry. This can be useful if you have long
|
||||
journal entries and only want to see a list of entries that match your search.
|
||||
|
||||
**Example output**:
|
||||
``` sh
|
||||
2020-06-28 18:22 This is the first sample entry
|
||||
2020-07-01 20:00 This is the second sample entry
|
||||
2020-07-02 09:00 This is the third sample entry
|
||||
```
|
||||
|
||||
### Fancy (or Boxed)
|
||||
``` sh
|
||||
jrnl --format fancy
|
||||
# or
|
||||
jrnl --format boxed
|
||||
```
|
||||
|
||||
This format outlines each entry with a border. This makes it much easier to tell where
|
||||
each entry starts and ends. It's an example of how free-form the formats can be, and also
|
||||
just looks kinda ~*~fancy~*~, if you're into that kind of thing.
|
||||
|
||||
**Example output**:
|
||||
``` sh
|
||||
┎──────────────────────────────────────────────────────────────────────╮2020-06-28 18:22
|
||||
┃ This is the first sample entry ╘═══════════════╕
|
||||
┠╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
|
||||
┃ This is the sample body text of the first sample entry. │
|
||||
┖──────────────────────────────────────────────────────────────────────────────────────┘
|
||||
┎──────────────────────────────────────────────────────────────────────╮2020-07-01 20:00
|
||||
┃ This is the second sample entry ╘═══════════════╕
|
||||
┠╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
|
||||
┃ This is the sample body text of the second sample entry, but this one has a @tag. │
|
||||
┖──────────────────────────────────────────────────────────────────────────────────────┘
|
||||
┎──────────────────────────────────────────────────────────────────────╮2020-07-02 09:00
|
||||
┃ This is the third sample entry ╘═══════════════╕
|
||||
┠╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
|
||||
┃ This is the sample body text of the third sample entry. │
|
||||
┖──────────────────────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
## Data Formats
|
||||
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
|
||||
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
|
||||
|
||||
``` sh
|
||||
jrnl --format json
|
||||
```
|
||||
|
||||
JSON is a very handy format used by many programs and has support in nearly every
|
||||
programming language. There are many things you could do with JSON data. Maybe you could
|
||||
use `jq` ([project page](https://github.com/stedolan/jq)) to filter through the fields in your journal.
|
||||
Like this:
|
||||
|
||||
``` sh
|
||||
$ j -3 --format json | jq '.entries[].date' jrnl-GFqVlfgP-py3.8
|
||||
"2020-06-28"
|
||||
"2020-07-01"
|
||||
"2020-07-02"
|
||||
```
|
||||
|
||||
Or why not create a [beautiful timeline](http://timeline.knightlab.com/) of your journal?
|
||||
|
||||
**Example output**:
|
||||
``` json
|
||||
{
|
||||
"tags": {
|
||||
"@tag": 1
|
||||
},
|
||||
"entries": [
|
||||
{
|
||||
"title": "This is the first sample entry",
|
||||
"body": "This is the sample body text of the first sample entry.",
|
||||
"date": "2020-06-28",
|
||||
"time": "18:22",
|
||||
"tags": [],
|
||||
"starred": false
|
||||
},
|
||||
{
|
||||
"title": "This is the second sample entry",
|
||||
"body": "This is the sample body text of the second sample entry, but this one has a @tag.",
|
||||
"date": "2020-07-01",
|
||||
"time": "20:00",
|
||||
"tags": [
|
||||
"@tag"
|
||||
],
|
||||
"starred": false
|
||||
},
|
||||
{
|
||||
"title": "This is the third sample entry",
|
||||
"body": "This is the sample body text of the third sample entry.",
|
||||
"date": "2020-07-02",
|
||||
"time": "09:00",
|
||||
"tags": [],
|
||||
"starred": false
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Markdown
|
||||
|
||||
``` sh
|
||||
jrnl --format markdown
|
||||
# or
|
||||
jrnl --format md
|
||||
```
|
||||
|
||||
Markdown is a simple markup language that is human readable and can be used to be
|
||||
rendered to other formats (html, pdf). `jrnl`'s
|
||||
[README](https://github.com/jrnl-org/jrnl/blob/develop/README.md) for example is
|
||||
formatted in markdown, then Github adds some formatting to make it look nice.
|
||||
|
||||
The markdown format groups entries by date (first by year, then by month), and adds
|
||||
header markings as needed (e.g. `#`, `##`, etc). If you already have markdown header
|
||||
markings in your journal, they will be incremented as necessary to make them fit under
|
||||
these new headers (i.e. `#` will become `##`).
|
||||
|
||||
This format can be very useful, for example, to export a journal to a program that
|
||||
converts markdown to html to make a website or a blog from your journal.
|
||||
|
||||
**Example output**:
|
||||
``` markdown
|
||||
# 2020
|
||||
|
||||
## June
|
||||
|
||||
### 2020-06-28 18:22 This is the first sample entry
|
||||
|
||||
This is the sample body text of the first sample entry.
|
||||
|
||||
## July
|
||||
|
||||
### 2020-07-01 20:00 This is the second sample entry
|
||||
|
||||
This is the sample body text of the second sample entry, but this one has a @tag.
|
||||
|
||||
### 2020-07-02 09:00 This is the third sample entry
|
||||
|
||||
This is the sample body text of the third sample entry.
|
||||
```
|
||||
|
||||
### Plain Text
|
||||
|
||||
``` sh
|
||||
jrnl --format text
|
||||
# or
|
||||
jrnl --format txt
|
||||
```
|
||||
|
||||
This outputs your journal in the same plain-text format that `jrnl` uses to store your
|
||||
journal on disk. This format is particularly useful for importing and exporting journals
|
||||
within `jrnl`.
|
||||
|
||||
You can use it, for example, to move entries from one journal to another, or to create a
|
||||
new journal with search results from another journal.
|
||||
|
||||
**Example output**:
|
||||
``` sh
|
||||
[2020-06-28 18:22] This is the first sample entry
|
||||
This is the sample body text of the first sample entry.
|
||||
|
||||
[2020-07-01 20:00] This is the second sample entry
|
||||
This is the sample body text of the second sample entry, but this one has a @tag.
|
||||
|
||||
[2020-07-02 09:00] This is the third sample entry
|
||||
This is the sample body text of the third sample entry.
|
||||
```
|
||||
|
||||
### XML
|
||||
``` sh
|
||||
jrnl --format xml
|
||||
```
|
||||
|
||||
This outputs your journal into XML format. XML is a commonly used data format and is
|
||||
supported by many programs and programming languages.
|
||||
|
||||
**Example output**:
|
||||
``` xml
|
||||
<?xml version="1.0" ?>
|
||||
<journal>
|
||||
<entries>
|
||||
<entry date="2020-06-28T18:22:00" starred="">This is the first sample entry This is the sample body text of the first sample entry.</entry>
|
||||
<entry date="2020-07-01T20:00:00" starred="">
|
||||
<tag name="@tag"/>
|
||||
This is the second sample entry This is the sample body text of the second sample entry, but this one has a @tag.
|
||||
</entry>
|
||||
<entry date="2020-07-02T09:00:00" starred="">*This is the third sample entry, and is starred This is the sample body text of the third sample entry.</entry>
|
||||
</entries>
|
||||
<tags>
|
||||
<tag name="@tag">1</tag>
|
||||
</tags>
|
||||
</journal>
|
||||
```
|
||||
|
||||
### YAML
|
||||
``` sh
|
||||
jrnl --format yaml --file 'my_directory/'
|
||||
```
|
||||
|
||||
This outputs your journal into YAML format. YAML is a commonly used data format and is
|
||||
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 file**:
|
||||
``` yaml
|
||||
title: This is the second sample entry
|
||||
date: 2020-07-01 20:00
|
||||
starred: False
|
||||
tags: tag
|
||||
|
||||
This is the sample body text of the second sample entry, but this one has a @tag.
|
||||
```
|
||||
|
||||
## Report formats
|
||||
Since formats use your journal data and display it in different ways, they can also be
|
||||
used to create reports.
|
||||
|
||||
### Tags
|
||||
|
||||
``` sh
|
||||
jrnl --format tags
|
||||
# or
|
||||
jrnl --tags
|
||||
```
|
||||
|
||||
This format is a simple example of how formats can be used to create reports. It
|
||||
displays each tag, and a count of how many entries in which tag appears in your journal
|
||||
(or in the search results), sorted by most frequent.
|
||||
|
||||
Example output:
|
||||
``` sh
|
||||
@one : 32
|
||||
@two : 17
|
||||
@three : 4
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
### Exporting with `--file`
|
||||
|
||||
Example: `jrnl --format json --file /some/path/to/a/file.txt`
|
||||
|
||||
By default, `jrnl` will output entries to your terminal. But if you provide `--file`
|
||||
along with a filename, the same output that would have been to your terminal will be
|
||||
written to the file instead. This is the same as piping the output to a file.
|
||||
|
||||
So, in bash for example, the following two statements are equivalent:
|
||||
|
||||
``` sh
|
||||
jrnl --format json --file myjournal.json
|
||||
```
|
||||
|
||||
``` sh
|
||||
jrnl --format json > myjournal.json
|
||||
```
|
||||
|
||||
#### Exporting to directories
|
||||
|
||||
If the `--file` argument is a directory, jrnl will export each entry into an individual file:
|
||||
|
||||
``` sh
|
||||
jrnl --format yaml --file my_entries/
|
||||
```
|
||||
|
||||
The contents of `my_entries/` will then look like this:
|
||||
|
||||
``` output
|
||||
my_entries/
|
||||
|- 2013_06_03_a-beautiful-day.yaml
|
||||
|- 2013_06_07_dinner-with-gabriel.yaml
|
||||
|- ...
|
||||
```
|
|
@ -1,43 +0,0 @@
|
|||
<!--
|
||||
Copyright © 2012-2023 jrnl contributors
|
||||
License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
-->
|
||||
|
||||
# Getting started
|
||||
|
||||
## Installation
|
||||
|
||||
The easiest way to install `jrnl` is using
|
||||
[pipx](https://pipx.pypa.io/stable/installation/)
|
||||
with [Python](https://www.python.org/) 3.10+:
|
||||
|
||||
``` sh
|
||||
pipx install jrnl
|
||||
```
|
||||
|
||||
!!! tip
|
||||
Do not use `sudo` while installing `jrnl`. This may lead to path issues.
|
||||
|
||||
The first time you run `jrnl` you will be asked where your journal file
|
||||
should be created and whether you wish to encrypt it.
|
||||
|
||||
## Quickstart
|
||||
|
||||
To make a new entry, just type
|
||||
|
||||
``` text
|
||||
jrnl yesterday: Called in sick. Used the time to clean, and spent 4h on writing my book.
|
||||
```
|
||||
|
||||
and hit return. `yesterday:` will be interpreted as a time stamp.
|
||||
Everything until the first sentence mark (`.?!:`) will be interpreted as
|
||||
the title, the rest as the body. In your journal file, the result will
|
||||
look like this:
|
||||
|
||||
``` output
|
||||
2012-03-29 09:00 Called in sick.
|
||||
Used the time to clean the house and spent 4h on writing my book.
|
||||
```
|
||||
|
||||
If you just call `jrnl`, you will be prompted to compose your entry -
|
||||
but you can also [configure](advanced.md) *jrnl* to use your external editor.
|
|
@ -1,65 +0,0 @@
|
|||
<!--
|
||||
Copyright © 2012-2023 jrnl contributors
|
||||
License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
-->
|
||||
|
||||
# Journal Types
|
||||
`jrnl` can store your journal in a few different ways:
|
||||
|
||||
- a single text file (encrypted or otherwise)
|
||||
- a folder structure organized by date containing unencrypted text files
|
||||
- the DayOne Classic format
|
||||
|
||||
There is no need to specify what type of journal you'd like to use. Instead,
|
||||
`jrnl` will automatically detect the journal type based on whether you're
|
||||
referencing a file or a folder in your [config file](advanced.md),
|
||||
and if it's a folder, whether or not DayOne Classic content exists in it.
|
||||
|
||||
## Single File
|
||||
The single file format is the most flexible, as it can be [encrypted](encryption.md).
|
||||
To use it, enter any path that is a file or does not already exist. You can
|
||||
use any extension. `jrnl` will automatically create the file when you save
|
||||
your first entry.
|
||||
|
||||
## Folder
|
||||
The folder journal format organizes your entries into subfolders for the year
|
||||
and month and `.txt` files for each day. If there are multiple entries in a day,
|
||||
they all appear in the same `.txt` file.
|
||||
|
||||
The directory tree structure is in this format: `YYYY/MM/DD.txt`. For instance, if
|
||||
you have an entry on May 5th, 2021 in a folder journal at `~/folderjournal`, it will
|
||||
be located in: `~/folderjournal/2021/05/05.txt`
|
||||
|
||||
!!! note
|
||||
Creating a new folder journal can be done in two ways:
|
||||
|
||||
* Create a folder with the name of the journal before running `jrnl`. Otherwise, when you run `jrnl` for the first time, it will assume that you are creating a single file journal instead, and it will create a file at that path.
|
||||
* Create a new journal in your [config_file](advanced.md) and end the path with a ``/`` (on a POSIX system like Linux or MacOSX) or a ``\`` (on a Windows system). The folder will be created automatically if it doesn't exist.
|
||||
|
||||
!!! note
|
||||
Folder journals can't be encrypted.
|
||||
|
||||
## Day One Classic
|
||||
`jrnl` supports the original data format used by DayOne. It's similar to the folder
|
||||
journal format, except it's identified by either of these characteristics:
|
||||
|
||||
* the folder has a `.dayone` extension
|
||||
* the folder has a subfolder named `entries`
|
||||
|
||||
This is not to be confused with the DayOne 2.0 format, [which is very different](https://help.dayoneapp.com/en/articles/1187337-day-one-classic-is-retired).
|
||||
|
||||
!!! note
|
||||
DayOne Classic journals can't be encrypted.
|
||||
|
||||
## Changing your journal type
|
||||
You can't simply modify a journal's configuration to change its type. Instead,
|
||||
define a new journal as the type you'd like, and use
|
||||
[piping](https://en.wikipedia.org/wiki/Redirection_(computing)#Piping)
|
||||
to export your old journal as `txt` to an import command on your new journal.
|
||||
|
||||
For instance, if you have a `projects` journal you would like to import into
|
||||
a `new` journal, you would run the following after setting up the configuration
|
||||
for your `new` journal:
|
||||
```
|
||||
jrnl projects --format txt | jrnl new --import
|
||||
```
|
|
@ -1,64 +0,0 @@
|
|||
<!--
|
||||
Copyright © 2012-2023 jrnl contributors
|
||||
License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
-->
|
||||
|
||||
# Overview
|
||||
|
||||
`jrnl` is a simple journal application for the command line.
|
||||
|
||||
You can use it to easily create, search, and view journal entries. Journals are
|
||||
stored as human-readable plain text, and can also be encrypted using [AES
|
||||
encryption](http://en.wikipedia.org/wiki/Advanced_Encryption_Standard).
|
||||
|
||||
`jrnl` has most of the features you need, and few of the ones you don't.
|
||||
|
||||
## Plain Text
|
||||
|
||||
`jrnl` stores each journal in plain text. You can store `jrnl` files anywhere,
|
||||
including in shared folders to keep them synchronized between devices. Journal
|
||||
files are compact (thousands of entries take up less than 1 MiB) and can be read
|
||||
by almost any electronic device, now and for the foreseeable future.
|
||||
|
||||
## Tags
|
||||
|
||||
To make it easier to find entries later, `jrnl` includes support for inline tags
|
||||
(the default tag symbol is `@`). You can find and filter entries by using tags
|
||||
along with other search criteria.
|
||||
|
||||
## Support for Multiple Journals
|
||||
|
||||
`jrnl` includes support for the creation of multiple journals, each of which
|
||||
can be stored as a single file or as a set of files. Entries are automatically
|
||||
timestamped in a human-readable format that makes it easy to view multiple
|
||||
entries at a time. `jrnl` can easily find the entries you want so that you can
|
||||
read them or edit them.
|
||||
|
||||
## Support for External Editors
|
||||
|
||||
`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
|
||||
more comprehensive application. `jrnl` can filter specific entries and pass them
|
||||
to the [external editor](./external-editors.md) of your choice.
|
||||
|
||||
## Encryption
|
||||
|
||||
`jrnl` includes support for [AES
|
||||
encryption](http://en.wikipedia.org/wiki/Advanced_Encryption_Standard). See the
|
||||
[encryption page](./encryption.md) for more information.
|
||||
|
||||
## Import and Export
|
||||
|
||||
`jrnl` makes it easy to import entries from other sources. Existing entries can
|
||||
be exported in a variety of [formats](./formats.md).
|
||||
|
||||
## Multi-Platform Support
|
||||
|
||||
`jrnl` is compatible with most operating systems. You can [download](./installation.md) it using one
|
||||
of a variety of package managers, or you can build from source.
|
||||
|
||||
## Open-Source
|
||||
|
||||
`jrnl` is written in [Python](https://www.python.org) and maintained by a
|
||||
[friendly community](https://github.com/jrnl-org/jrnl) of open-source software
|
||||
enthusiasts.
|
|
@ -1,232 +0,0 @@
|
|||
<!--
|
||||
Copyright © 2012-2023 jrnl contributors
|
||||
License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
-->
|
||||
|
||||
# Privacy and Security
|
||||
|
||||
`jrnl` is designed with privacy and security in mind, but like any other
|
||||
program there are some limitations to be aware of.
|
||||
|
||||
## Password strength
|
||||
|
||||
`jrnl` doesn't enforce password strength requirements. Short or commonly-used
|
||||
passwords can be easily circumvented by someone with basic security skills
|
||||
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
|
||||
|
||||
Since you can enter entries from the command line, any tool that logs command
|
||||
line actions is a potential security risk. See below for how to deal with this
|
||||
problem in various shells.
|
||||
|
||||
### bash
|
||||
|
||||
You can disable history logging for jrnl by adding this line into your
|
||||
`~/.bashrc` file:
|
||||
|
||||
``` sh
|
||||
HISTIGNORE="$HISTIGNORE:jrnl *"
|
||||
```
|
||||
|
||||
To delete existing `jrnl` commands from `bash` history, simply delete them from
|
||||
your bash history file. The default location of this file is `~/.bash_history`,
|
||||
but you can run `echo "$HISTFILE"` to find it if needed. Also, you can run
|
||||
`history -c` to delete all commands from your history.
|
||||
|
||||
### zsh
|
||||
|
||||
You can disable history logging for jrnl by adding this to your `~/.zshrc`
|
||||
file:
|
||||
|
||||
``` sh
|
||||
setopt HIST_IGNORE_SPACE
|
||||
alias jrnl=" jrnl"
|
||||
```
|
||||
|
||||
To delete existing `jrnl` commands from `zsh` history, simply remove them from
|
||||
your zsh history file. The default location of this file is `~/.zsh_history`,
|
||||
but you can run `echo "$HISTFILE"` to find it if needed. Also, you can run
|
||||
`history -c` to delete all commands from your history.
|
||||
|
||||
### fish
|
||||
|
||||
By default `fish` will not log any command that starts with a space. If you
|
||||
want to always run jrnl with a space before it, then you can add this to your
|
||||
`~/.config/fish/config.fish` file:
|
||||
|
||||
``` sh
|
||||
abbr --add jrnl " jrnl"
|
||||
```
|
||||
|
||||
To delete existing jrnl commands from `fish` history, run `history delete --prefix 'jrnl '`.
|
||||
|
||||
### Windows Command Prompt
|
||||
|
||||
Windows doesn't log history to disk, but it does keep it in your command prompt
|
||||
session. Close the command prompt or press `Alt`+`F7` to clear your history
|
||||
after journaling.
|
||||
|
||||
## Files in transit from editor to jrnl
|
||||
|
||||
When creating or editing an entry, `jrnl` uses a unencrypted temporary file on
|
||||
disk in order to give your editor access to your journal. After you close your
|
||||
editor, `jrnl` then deletes this temporary file.
|
||||
|
||||
So, if you have saved a journal entry but haven't closed your editor yet, the
|
||||
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
|
||||
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
|
||||
manually delete these files from your temporary folder. By default, they
|
||||
are named `jrnl*.jrnl`, but if you use a
|
||||
[template](reference-config-file.md#template), they will have the same
|
||||
extension as the template.
|
||||
|
||||
## Editor history
|
||||
|
||||
Some editors keep usage history stored on disk for future use. This can be a
|
||||
security risk in the sense that sensitive information can leak via recent
|
||||
search patterns or editor commands.
|
||||
|
||||
### Visual Studio Code
|
||||
|
||||
Visual Studio Code stores the contents of saved files to allow you to restore or
|
||||
review the contents later. You can disable this feature for all files by unchecking
|
||||
the `workbench.localHistory.enabled` setting in the
|
||||
[Settings editor](https://code.visualstudio.com/docs/getstarted/settings#_settings-editor).
|
||||
|
||||
Alternatively, you can disable this feature for specific files by configuring a
|
||||
[pattern](https://code.visualstudio.com/docs/editor/codebasics#_advanced-search-options)
|
||||
in the `workbench.localHistory.exclude` setting. To exclude unencrypted temporary files generated
|
||||
by `jrnl`, you can set the `**/jrnl*.jrnl` (unless you are using a
|
||||
[template](reference-config-file.md#template)) pattern for the `workbench.localHistory.exclude` setting
|
||||
in the [Settings editor](https://code.visualstudio.com/docs/getstarted/settings#_settings-editor).
|
||||
|
||||
!!! note
|
||||
On Windows, the history location is typically found at
|
||||
`%APPDATA%\Code\User\History`.
|
||||
|
||||
Visual Studio Code also creates a copy of all unsaved files that are open.
|
||||
It stores these copies in a backup location that's automatically cleaned when
|
||||
you save the file. However, if your computer shuts off before you save the file,
|
||||
or the Visual Studio Code process stops unexpectedly, then an unencrypted
|
||||
temporary file may remain on your disk. You can manually delete these files
|
||||
from the backup location.
|
||||
|
||||
!!! note
|
||||
On Windows, the backup location is typically found at
|
||||
`%APPDATA%\Code\Backups`.
|
||||
|
||||
### Vim
|
||||
|
||||
Vim stores progress data in a so called Viminfo file located at `~/.viminfo`
|
||||
which contains all sorts of user data including command line history, search
|
||||
string history, search/substitute patterns, contents of register etc. Also to
|
||||
be able to recover opened files after an unexpected application close Vim uses
|
||||
swap files.
|
||||
|
||||
These options as well as other leaky features can be disabled by setting the
|
||||
`editor` key in the Jrnl settings like this:
|
||||
|
||||
``` yaml
|
||||
editor: "vim -c 'set viminfo= noswapfile noundofile nobackup nowritebackup noshelltemp history=0 nomodeline secure'"
|
||||
```
|
||||
|
||||
To disable all plugins and custom configurations and start Vim with the default
|
||||
configuration `-u NONE` can be passed on the command line as well. This will
|
||||
ensure that any rogue plugins or other difficult to catch information leaks are
|
||||
eliminated. The downside to this is that the editor experience will decrease
|
||||
quite a bit.
|
||||
|
||||
To instead let Vim automatically detect when a Jrnl file is being edited an
|
||||
autocommand can be used. Place this in your `~/.vimrc`:
|
||||
|
||||
``` vim
|
||||
autocmd BufNewFile,BufReadPre *.jrnl setlocal viminfo= noswapfile noundofile nobackup nowritebackup noshelltemp history=0 nomodeline secure
|
||||
```
|
||||
|
||||
!!! note
|
||||
If you're using a [template](reference-config-file.md#template), you will
|
||||
have to use the template's file extension instead of `.jrnl`.
|
||||
|
||||
See `:h <option>` in Vim for more information about the options mentioned.
|
||||
|
||||
### Neovim
|
||||
|
||||
Neovim strives to be mostly compatible with Vim and has therefore similar
|
||||
functionality as Vim. One difference in Neovim is that the Viminfo file is
|
||||
instead called the ShaDa ("shared data") file which resides in
|
||||
`~/.local/state/nvim` (`~/.local/share/nvim` pre Neovim v0.8.0). The ShaDa file
|
||||
can be disabled in the same way as for Vim.
|
||||
|
||||
``` yaml
|
||||
editor: "nvim -c 'set shada= noswapfile noundofile nobackup nowritebackup noshelltemp history=0 nomodeline secure'"
|
||||
```
|
||||
|
||||
`-u NONE` can be passed here as well to start a session with the default configs.
|
||||
|
||||
As for Vim above we can create an autocommand in Vimscript:
|
||||
|
||||
``` vim
|
||||
autocmd BufNewFile,BufReadPre *.jrnl setlocal shada= noswapfile noundofile nobackup nowritebackup noshelltemp history=0 nomodeline secure
|
||||
```
|
||||
|
||||
or the same but in Lua:
|
||||
|
||||
``` lua
|
||||
vim.api.nvim_create_autocmd( {"BufNewFile","BufReadPre" }, {
|
||||
group = vim.api.nvim_create_augroup("PrivateJrnl", {}),
|
||||
pattern = "*.jrnl",
|
||||
callback = function()
|
||||
vim.o.shada = ""
|
||||
vim.o.swapfile = false
|
||||
vim.o.undofile = false
|
||||
vim.o.backup = false
|
||||
vim.o.writebackup = false
|
||||
vim.o.shelltemp = false
|
||||
vim.o.history = 0
|
||||
vim.o.modeline = false
|
||||
vim.o.secure = true
|
||||
end,
|
||||
})
|
||||
```
|
||||
|
||||
!!! note
|
||||
If you're using a [template](reference-config-file.md#template), you will
|
||||
have to use the template's file extension instead of `.jrnl`.
|
||||
|
||||
Please see `:h <option>` in Neovim for more information about the options mentioned.
|
||||
|
||||
## Notice any other risks?
|
||||
|
||||
Please let the maintainers know by [filing an issue on GitHub](https://github.com/jrnl-org/jrnl/issues).
|
|
@ -1,141 +0,0 @@
|
|||
<!--
|
||||
Copyright © 2012-2023 jrnl contributors
|
||||
License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
-->
|
||||
|
||||
# Command Line Reference
|
||||
|
||||
## Synopsis
|
||||
```
|
||||
usage: jrnl [--debug] [--help] [--version] [--list] [--encrypt] [--decrypt]
|
||||
[--import] [-on DATE] [-today-in-history] [-month DATE]
|
||||
[-day DATE] [-year DATE] [-from DATE] [-to DATE] [-contains TEXT]
|
||||
[-and] [-starred] [-n [NUMBER]] [-not [TAG]] [--edit] [--delete]
|
||||
[--format TYPE] [--tags] [--short]
|
||||
[--config-override CONFIG_KEY CONFIG_VALUE]
|
||||
[--config-file CONFIG_FILE_PATH]
|
||||
[[...]]
|
||||
```
|
||||
|
||||
## Standalone Commands
|
||||
|
||||
These commands will exit after they complete. You may only run one at a time.
|
||||
|
||||
### --help
|
||||
Show a help message.
|
||||
|
||||
### --version
|
||||
Print version and license information.
|
||||
|
||||
### --list
|
||||
List the config file location, all configured journals, and their locations.
|
||||
|
||||
### ---encrypt
|
||||
Encrypt a journal. See [encryption](encryption.md) for more information.
|
||||
|
||||
### --decrypt
|
||||
Decrypt a journal. See [encryption](encryption.md) for more information.
|
||||
|
||||
|
||||
### --import
|
||||
Import entries from another journal. If any entries have the exact same content
|
||||
and timestamp, they will be deduplicated.
|
||||
|
||||
Optional parameters:
|
||||
```sh
|
||||
--file FILENAME
|
||||
```
|
||||
Specify a file to import. If not provided, `jrnl` will use STDIN as the data source.
|
||||
|
||||
```sh
|
||||
--format TYPE
|
||||
```
|
||||
Specify the format of the file that is being imported. Defaults to the same data
|
||||
storage method that jrnl uses. See [formats](formats.md) for more information.
|
||||
|
||||
## Writing new entries
|
||||
See [Basic Usage](usage.md).
|
||||
|
||||
## Searching
|
||||
|
||||
To find entries from your journal, use any combination of the below filters.
|
||||
Only entries that match all the filters will be displayed.
|
||||
|
||||
When specifying dates, you can use the same kinds of dates you use for new
|
||||
entries, such as `yesterday`, `today`, `Tuesday`, or `2021-08-01`.
|
||||
|
||||
| Search Argument | Description |
|
||||
| --- | --- |
|
||||
| -on DATE | Show entries on this date |
|
||||
| -today-in-history | Show entries of today over the years |
|
||||
| -month DATE | Show entries on this month of any year |
|
||||
| -day DATE | Show entries on this day of any month |
|
||||
| -year DATE | Show entries of a specific year |
|
||||
| -from DATE | Show entries after, or on, this date |
|
||||
| -to DATE | Show entries before, or on, this date (alias: -until) |
|
||||
| -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) |
|
||||
| -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) |
|
||||
| -not [TAG] | Exclude entries with this tag |
|
||||
| -not -starred | Exclude entries that are starred |
|
||||
| -not -tagged | Exclude entries that are tagged |
|
||||
|
||||
## Searching Options
|
||||
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.
|
||||
|
||||
### --edit
|
||||
Opens the selected entries in your configured editor. It will fail if the
|
||||
`editor` key is not set in your config file.
|
||||
|
||||
Once you begin editing, you can add multiple entries and delete entries
|
||||
by modifying the text in your editor. When your editor closes, jrnl reads
|
||||
the temporary file you were editing and makes the changes to your journal.
|
||||
|
||||
### --delete
|
||||
Interactively deletes selected entries. You'll be asked to confirm deletion of
|
||||
each entry.
|
||||
|
||||
### --change-time DATE
|
||||
Interactively changes the time of the selected entries to the date specified,
|
||||
or to right now if no date is specified. You'll be asked to confirm each entry,
|
||||
unless you are using this with `--edit` on a single entry.
|
||||
|
||||
### --format TYPE
|
||||
Display selected entries in an alternate format. See [formats](formats.md).
|
||||
|
||||
#### Optional parameters
|
||||
```sh
|
||||
--file FILENAME
|
||||
```
|
||||
Write output to file instead of STDOUT. In most shells, the
|
||||
same effect can be achieved using `>`.
|
||||
|
||||
### --tags
|
||||
|
||||
Alias for '--format tags'. Returns a list of all tags and the number of times
|
||||
they occur within the searched entries. If there are no tags found, `jrnl` will output a message saying so.
|
||||
|
||||
### --short
|
||||
Only shows the date and titles of the searched entries.
|
||||
|
||||
## Configuration arguments
|
||||
|
||||
### --config-override CONFIG_KEY CONFIG_VALUE
|
||||
|
||||
Override configured key-value pair with CONFIG_KV_PAIR for this command invocation only. To access config keys that aren't at the top level, separate the keys with a dot, such as `colors.title` to access the `title` key within the `colors` key. Read [advanced usage](./advanced.md) for examples.
|
||||
|
||||
### --config-file CONFIG_FILE_PATH
|
||||
|
||||
Use the config file at CONFIG_FILE_PATH for this command invocation only.
|
||||
Read [advanced usage](./advanced.md) for examples.
|
||||
|
||||
## Other Arguments
|
||||
|
||||
### --debug
|
||||
Prints information useful for troubleshooting while `jrnl` executes.
|
||||
|
||||
### --diagnostic
|
||||
Prints diagnostic information useful for [reporting issues](https://github.com/jrnl-org/jrnl/issues).
|
|
@ -1,123 +0,0 @@
|
|||
<!--
|
||||
Copyright © 2012-2023 jrnl contributors
|
||||
License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
-->
|
||||
|
||||
# Configuration File Reference
|
||||
|
||||
`jrnl` stores its information in a YAML configuration file.
|
||||
|
||||
!!! note
|
||||
Backup your journal and config file before editing. Changes to the config file
|
||||
can have destructive effects on your journal!
|
||||
|
||||
## Config location
|
||||
You can find your configuration file location by running:
|
||||
`jrnl --list`
|
||||
|
||||
By default, the configuration file is `~/.config/jrnl/jrnl.yaml`.
|
||||
If you have the `XDG_CONFIG_HOME` variable set, the configuration
|
||||
file will be saved as `$XDG_CONFIG_HOME/jrnl/jrnl.yaml`.
|
||||
|
||||
!!! note
|
||||
On Windows, the configuration file is typically found at
|
||||
`%USERPROFILE%\.config\jrnl\jrnl.yaml`.
|
||||
|
||||
|
||||
## Config format
|
||||
The configuration file is a [YAML](https://yaml.org/) file and can be edited with
|
||||
a text editor.
|
||||
|
||||
## Config keys
|
||||
|
||||
### journals
|
||||
|
||||
Describes each journal used by `jrnl`. Each indented key after this key is
|
||||
the name of a journal.
|
||||
|
||||
If a journal key has a value, that value will be interpreted as the path
|
||||
to the journal. Otherwise, the journal needs the additional indented key
|
||||
`journal` to specify its path.
|
||||
|
||||
All keys below can be specified for each journal at the same level as the
|
||||
`journal` key. If a key conflicts with a top-level key, the journal-specific
|
||||
key will be used instead.
|
||||
|
||||
### editor
|
||||
If set, executes this command to launch an external editor for
|
||||
writing and editing your entries. The path to a temporary file
|
||||
is passed after it, and `jrnl` processes the file once
|
||||
the editor returns control to `jrnl`.
|
||||
|
||||
Some editors require special options to work properly, since they must be
|
||||
blocking processes to work with `jrnl`. See [External Editors](external-editors.md)
|
||||
for details.
|
||||
|
||||
### encrypt
|
||||
If `true`, encrypts your journal using AES. Do not change this
|
||||
value for journals that already have data in them.
|
||||
|
||||
### template
|
||||
The path to a text file to use as a template for new entries. Only works when you
|
||||
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
|
||||
Symbols to be interpreted as tags.
|
||||
|
||||
!!! note
|
||||
Although it seems intuitive to use the `#`
|
||||
character for tags, there's a drawback: on most shells, this is
|
||||
interpreted as a meta-character starting a comment. This means that if
|
||||
you type
|
||||
|
||||
> `jrnl Implemented endless scrolling on the #frontend of our website.`
|
||||
|
||||
your bash will chop off everything after the `#` before passing it to
|
||||
`jrnl`. To avoid this, wrap your input into quotation marks like
|
||||
this:
|
||||
|
||||
> `jrnl "Implemented endless scrolling on the #frontend of our website."`
|
||||
|
||||
Or use the built-in prompt or an external editor to compose your
|
||||
entries.
|
||||
|
||||
### default_hour and default_minute
|
||||
Entries will be created at this time if you supply a date but no specific time (for example, `last thursday`).
|
||||
|
||||
### timeformat
|
||||
Defines how to format the timestamps as they are stored in your journal.
|
||||
See the [python docs](http://docs.python.org/library/time.html#time.strftime) for reference.
|
||||
|
||||
Do not change this for an existing journal, since that might lead
|
||||
to data loss.
|
||||
|
||||
!!! note
|
||||
`jrnl` doesn't support the `%z` or `%Z` time zone identifiers.
|
||||
|
||||
### highlight
|
||||
If `true`, tags will be highlighted in cyan.
|
||||
|
||||
### linewrap
|
||||
Controls the width of the output. Set to `false` if you don't want to
|
||||
wrap long lines. Set to `auto` to let `jrnl` automatically determine
|
||||
the terminal width.
|
||||
|
||||
### colors
|
||||
A dictionary that controls the colors used to display journal entries.
|
||||
It has four subkeys, which are: `body`, `date`, `tags`, and `title`.
|
||||
|
||||
Current valid values are: `BLACK`, `RED`, `GREEN`, `YELLOW`, `BLUE`,
|
||||
`MAGENTA`, `CYAN`, `WHITE`, and `NONE`.
|
||||
|
||||
`colorama.Fore` is used for colorization, and you can find the [docs here](https://github.com/tartley/colorama#colored-output).
|
||||
|
||||
To disable colored output, set the value to `NONE`.
|
||||
|
||||
### display_format
|
||||
Specifies formatter to use by default. See [formats](formats.md).
|
||||
|
||||
### version
|
||||
`jrnl` automatically updates this field to the version that it is running.
|
||||
There is no need to change this field manually.
|
|
@ -1,224 +0,0 @@
|
|||
<!--
|
||||
Copyright © 2012-2023 jrnl contributors
|
||||
License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
-->
|
||||
|
||||
# Tips and Tricks
|
||||
|
||||
This page contains tips and tricks for using `jrnl`, often in conjunction
|
||||
with other tools, including external editors.
|
||||
|
||||
## Co-occurrence of tags
|
||||
|
||||
If I want to find out how often I mentioned my flatmates Alberto and
|
||||
Melo in the same entry, I run
|
||||
|
||||
```sh
|
||||
jrnl @alberto --tags | grep @melo
|
||||
```
|
||||
|
||||
And will get something like `@melo: 9`, meaning there are 9 entries
|
||||
where both `@alberto` and `@melo` are tagged. How does this work? First,
|
||||
`jrnl @alberto` will filter the journal to only entries containing the
|
||||
tag `@alberto`, and then the `--tags` option will print out how often
|
||||
each tag occurred in this filtered journal. Finally, we pipe this to
|
||||
`grep` which will only display the line containing `@melo`.
|
||||
|
||||
## Combining filters
|
||||
|
||||
You can do things like
|
||||
|
||||
```sh
|
||||
jrnl @fixed -starred -n 10 -to "jan 2013" --short
|
||||
```
|
||||
|
||||
To get a short summary of the 10 most recent, favourite entries before
|
||||
January 1, 2013 that are tagged with `@fixed`.
|
||||
|
||||
## Statistics
|
||||
|
||||
How much did I write last year?
|
||||
|
||||
```sh
|
||||
jrnl -from "jan 1 2013" -to "dec 31 2013" | wc -w
|
||||
```
|
||||
|
||||
Will give you the number of words you wrote in 2013. How long is my
|
||||
average entry?
|
||||
|
||||
```sh
|
||||
expr $(jrnl --export text | wc -w) / $(jrnl --short | wc -l)
|
||||
```
|
||||
|
||||
This will first get the total number of words in the journal and divide
|
||||
it by the number of entries (this works because `jrnl --short` will
|
||||
print exactly one line per entry).
|
||||
|
||||
## Importing older files
|
||||
|
||||
If you want to import a file as an entry to `jrnl`, you can just do `jrnl < entry.ext`. But what if you want the modification date of the file to
|
||||
be the date of the entry in `jrnl`? Try this
|
||||
|
||||
```sh
|
||||
echo `stat -f %Sm -t '%d %b %Y at %H:%M: ' entry.txt` `cat entry.txt` | jrnl
|
||||
```
|
||||
|
||||
The first part will format the modification date of `entry.txt`, and
|
||||
then combine it with the contents of the file before piping it to jrnl.
|
||||
If you do that often, consider creating a function in your `.bashrc` or
|
||||
`.bash_profile`
|
||||
|
||||
```sh
|
||||
jrnlimport () {
|
||||
echo `stat -f %Sm -t '%d %b %Y at %H:%M: ' $1` `cat $1` | jrnl
|
||||
}
|
||||
```
|
||||
|
||||
## Using Templates
|
||||
|
||||
!!! note
|
||||
Templates require an [external editor](./advanced.md) be configured.
|
||||
|
||||
Templates are text files that are used for creating structured journals.
|
||||
There are three ways you can use templates:
|
||||
|
||||
### 1. Use the `--template` command line argument and the default $XDG_DATA_HOME/jrnl/templates directory
|
||||
|
||||
`$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
|
||||
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
|
||||
Title:
|
||||
|
||||
Body:
|
||||
```
|
||||
|
||||
Then, pass the absolute or relative path to the template file as an argument, and your external
|
||||
editor will open and have your template pre-populated.
|
||||
|
||||
```sh
|
||||
jrnl --template /tmp/template.md
|
||||
```
|
||||
|
||||
### 3. Set a default template file in `jrnl.yaml`
|
||||
|
||||
If you want a template by default, change the value of `template` in the [config file](./reference-config-file.md)
|
||||
from `false` to the template file's path, wrapped in double quotes:
|
||||
|
||||
```sh
|
||||
...
|
||||
template: "/path/to/template.txt"
|
||||
...
|
||||
```
|
||||
|
||||
!!! tip
|
||||
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).
|
||||
|
||||
```sh
|
||||
jrnl -n 1
|
||||
```
|
||||
|
||||
## Prompts on shell reload
|
||||
|
||||
If you'd like to be prompted each time you refresh your shell, you can include
|
||||
this in your `.bash_profile`:
|
||||
|
||||
```sh
|
||||
function log_question()
|
||||
{
|
||||
echo $1
|
||||
read
|
||||
jrnl today: ${1}. $REPLY
|
||||
}
|
||||
log_question 'What did I achieve today?'
|
||||
log_question 'What did I make progress with?'
|
||||
```
|
||||
|
||||
Whenever your shell is reloaded, you will be prompted to answer each of the
|
||||
questions in the example above. Each answer will be logged as a separate
|
||||
journal entry at the `default_hour` and `default_minute` listed in your
|
||||
`jrnl.yaml` [config file](../advanced/#configuration-file).
|
||||
|
||||
## Display random entry
|
||||
|
||||
You can use this to select one title at random and then display the whole
|
||||
entry. The invocation of `cut` needs to match the format of the timestamp.
|
||||
For timestamps that have a space between data and time components, select
|
||||
fields 1 and 2 as shown. For timestamps that have no whitespace, select
|
||||
only field 1.
|
||||
|
||||
```sh
|
||||
jrnl -on "$(jrnl --short | shuf -n 1 | cut -d' ' -f1,2)"
|
||||
```
|
||||
|
||||
|
||||
## Launch a terminal for rapid logging
|
||||
You can use this to launch a terminal that is the `jrnl` stdin prompt so you can start typing away immediately.
|
||||
|
||||
```bash
|
||||
jrnl --config-override editor ""
|
||||
```
|
||||
|
||||
Bind this to a keyboard shortcut.
|
||||
|
||||
Map `Super+Alt+J` to launch the terminal with `jrnl` prompt
|
||||
|
||||
- **xbindkeys**
|
||||
In your `.xbindkeysrc`
|
||||
|
||||
```ini
|
||||
Mod4+Mod1+j
|
||||
alacritty -t floating-jrnl -e jrnl --config-override editor "",
|
||||
```
|
||||
|
||||
- **I3 WM** Launch a floating terminal with the `jrnl` prompt
|
||||
|
||||
```ini
|
||||
bindsym Mod4+Mod1+j exec --no-startup-id alacritty -t floating-jrnl -e jrnl --config-override editor ""
|
||||
for_window[title="floating *"] floating enable
|
||||
```
|
||||
## Visualize Formatted Markdown in the CLI
|
||||
|
||||
Out of the box, `jrnl` can output journal entries in Markdown. To visualize it, you can pipe to [mdless](https://github.com/ttscoff/mdless), which is a [less](https://en.wikipedia.org/wiki/Less_(Unix))-like tool that allows you to visualize your Markdown text with formatting and syntax highlighting from the CLI. You can use this in any shell that supports piping.
|
||||
|
||||
The simplest way to visualize your Markdown output with `mdless` is as follows:
|
||||
```sh
|
||||
jrnl --export md | mdless
|
||||
```
|
||||
|
||||
This will render your Markdown output in the whole screen.
|
||||
|
||||
Fortunately, `mdless` has an option that allows you to adjust the screen width by using the `-w` option as follows:
|
||||
|
||||
```sh
|
||||
jrnl --export md | mdless -w 70
|
||||
```
|
||||
|
||||
If you want Markdown to be your default display format, you can define this in your config file as follows:
|
||||
|
||||
```yaml
|
||||
display_format: md
|
||||
# or
|
||||
display_format: markdown
|
||||
```
|
||||
|
||||
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('.')))"
|
||||
```
|
256
docs/usage.md
|
@ -1,256 +0,0 @@
|
|||
<!--
|
||||
Copyright © 2012-2023 jrnl contributors
|
||||
License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
-->
|
||||
|
||||
# Basic Usage #
|
||||
|
||||
`jrnl` has two modes: **composing** and **viewing**. Whenever you don't enter
|
||||
any arguments that start with a dash (`-`) or double-dash (`--`), you're in
|
||||
composing mode, meaning that you can write your entry on the command line.
|
||||
|
||||
We intentionally break a convention on command line arguments: all arguments
|
||||
starting with a _single dash_ (`-`) will _filter_ your journal before viewing
|
||||
it. Filter arguments can be combined arbitrarily. Arguments with a _double dash_
|
||||
(`--`) will _control_ how your journal is displayed or exported. Control
|
||||
arguments are mutually exclusive (i.e., you can only specify one way to display
|
||||
or export your journal at a time).
|
||||
|
||||
For a list of commands, enter `jrnl --help`.
|
||||
|
||||
## Composing Entries ##
|
||||
|
||||
Composing mode is entered by either starting `jrnl` without any arguments --
|
||||
which will launch an external editor -- or by just writing an entry on the
|
||||
command line:
|
||||
|
||||
```text
|
||||
jrnl today at 3am: I just met Steve Buscemi in a bar! What a nice guy.
|
||||
```
|
||||
|
||||
!!! note
|
||||
Most shells contain a certain number of reserved characters, such as `#` and
|
||||
`*`. These characters, as well as unbalanced single or double quotation
|
||||
marks, parentheses, and others, likely will cause problems. Although
|
||||
reserved characters can be escaped using `\`, this is not ideal for
|
||||
long-form writing. The solution: first enter `jrnl` and hit `return`. You
|
||||
can then enter the text of your journal entry. Alternatively, you can [use
|
||||
an external editor](./advanced.md).
|
||||
|
||||
You can also import an entry directly from a file:
|
||||
|
||||
```sh
|
||||
jrnl < my_entry.txt
|
||||
```
|
||||
|
||||
### Specifying Date and Time ###
|
||||
|
||||
If you don't specify a date and time (e.g., `jrnl finished writing letter to brother`), `jrnl` will create an entry using the current date and time. For retrospective entries, you can use a timestamp to tell `jrnl` where to put the entry. Timestamps can be entered using a variety of formats. Here are some that work:
|
||||
|
||||
- at 6am
|
||||
- yesterday
|
||||
- last monday
|
||||
- sunday at noon
|
||||
- 2 march 2012
|
||||
- 7 apr
|
||||
- 5/20/1998 at 23:42
|
||||
- 2020-05-22T15:55-04:00
|
||||
|
||||
If you don't use a timestamp, `jrnl` will create an entry using the current
|
||||
time. If you use a date only (no time), `jrnl` will use the default time
|
||||
specified in your [configuration file](./reference-config-file.md#default_hour-and-default_minute).
|
||||
Behind the scenes, `jrnl` reorganizes entries in chronological order.
|
||||
|
||||
### Using Tags ###
|
||||
|
||||
`jrnl` supports tags. The default tag symbol is `@` (largely because `#` is a
|
||||
reserved character). You can specify your own tag symbol in the
|
||||
[configuration file](./reference-config-file.md#tagsymbols). To use tags, preface the
|
||||
desired tag with the symbol:
|
||||
|
||||
```sh
|
||||
jrnl Had a wonderful day at the @beach with @Tom and @Anna.
|
||||
```
|
||||
|
||||
Although you can use capitals while tagging an entry, searches by tag are
|
||||
case-insensitive.
|
||||
|
||||
There is no limit to how many tags you can use in an entry.
|
||||
|
||||
### Starring Entries ###
|
||||
|
||||
To mark an entry as a favorite, simply "star" it using an asterisk (`*`):
|
||||
|
||||
```sh
|
||||
jrnl last sunday *: Best day of my life.
|
||||
```
|
||||
|
||||
If you don't want to add a date (i.e., you want the date to be entered as
|
||||
_now_), the following options are equivalent:
|
||||
|
||||
- `jrnl *: Best day of my life.`
|
||||
- `jrnl *Best day of my life.`
|
||||
- `jrnl Best day of my life.*`
|
||||
|
||||
!!! note
|
||||
Make sure that the asterisk (`*`) is **not** surrounded by whitespaces.
|
||||
`jrnl Best day of my life! *` will not work because the `*` character has a
|
||||
special meaning in most shells.
|
||||
|
||||
## Viewing and Searching Entries ##
|
||||
|
||||
`jrnl` can display entries in a variety of ways.
|
||||
|
||||
To view all entries, enter:
|
||||
```sh
|
||||
jrnl -to today
|
||||
```
|
||||
|
||||
`jrnl` provides several filtering commands, prefaced by a single dash (`-`), that
|
||||
allow you to find a more specific range of entries. For example,
|
||||
|
||||
```sh
|
||||
jrnl -n 10
|
||||
```
|
||||
|
||||
lists the ten most recent entries. `jrnl -10` is even more concise and works the
|
||||
same way. If you want to see all of the entries you wrote from the beginning of
|
||||
last year until the end of this past March, you would enter
|
||||
|
||||
```sh
|
||||
jrnl -from "last year" -to march
|
||||
```
|
||||
|
||||
Filter criteria that use more than one word require surrounding quotes (`""`).
|
||||
|
||||
To see entries on a particular date, use `-on`:
|
||||
```sh
|
||||
jrnl -on yesterday
|
||||
```
|
||||
|
||||
### Text Search ###
|
||||
|
||||
The `-contains` command displays all entries containing the text you enter after it.
|
||||
This may be helpful when you're searching for entries and you can't remember if you
|
||||
tagged any words when you wrote them.
|
||||
|
||||
You may realize that you use a word a lot and want to turn it into a tag in all
|
||||
of your previous entries.
|
||||
|
||||
```sh
|
||||
jrnl -contains "dogs" --edit
|
||||
```
|
||||
|
||||
opens your external editor so that you can add a tag symbol (`@` by default) to
|
||||
all instances of the word "dogs."
|
||||
|
||||
### Filtering by Tag ###
|
||||
|
||||
You can filter your journal entries by tag. For example,
|
||||
|
||||
```sh
|
||||
jrnl @pinkie @WorldDomination
|
||||
```
|
||||
|
||||
displays all entries in which either `@pinkie` or `@WorldDomination`
|
||||
occurred. Tag filters can be combined with other filters:
|
||||
|
||||
```sh
|
||||
jrnl -n 5 @pinkie -and @WorldDomination
|
||||
```
|
||||
|
||||
displays the last five entries containing _both_ `@pinkie` _and_
|
||||
`@worldDomination`. You can change which symbols you'd like to use for tagging
|
||||
in the [configuration file](./reference-config-file.md#tagsymbols).
|
||||
|
||||
!!! note
|
||||
Entering `jrnl @pinkie @WorldDomination` will display entries in which both
|
||||
tags are present because, although no command line arguments are given, all
|
||||
of the input strings look like tags. `jrnl` will assume you want to filter
|
||||
by tag, rather than create a new entry that consists only of tags.
|
||||
|
||||
To view a list of all tags in the journal, enter:
|
||||
|
||||
```sh
|
||||
jrnl --tags
|
||||
```
|
||||
|
||||
### Viewing Starred Entries ###
|
||||
|
||||
To display only your favorite (starred) entries, enter
|
||||
|
||||
```sh
|
||||
jrnl -starred
|
||||
```
|
||||
|
||||
## Editing Entries ##
|
||||
|
||||
You can edit entries after writing them. This is particularly useful when your
|
||||
journal file is encrypted. To use this feature, you need to have an external
|
||||
editor configured in your [configuration file](./reference-config-file.md#editor). You
|
||||
can also edit only the entries that match specific search criteria. For example,
|
||||
|
||||
```sh
|
||||
jrnl -to 1950 @texas -and @history --edit
|
||||
```
|
||||
|
||||
opens your external editor displaying all entries tagged with `@texas` and
|
||||
`@history` that were written before 1950. After making changes, save and close
|
||||
the file, and only those entries will be modified (and encrypted, if
|
||||
applicable).
|
||||
|
||||
If you are using multiple journals, it's easy to edit specific entries from
|
||||
specific journals. Simply prefix the filter string with the name of the journal.
|
||||
For example,
|
||||
|
||||
```sh
|
||||
jrnl work -n 1 --edit
|
||||
```
|
||||
|
||||
opens the most recent entry in the 'work' journal in your external editor.
|
||||
|
||||
## Deleting Entries ##
|
||||
|
||||
The `--delete` command opens an interactive interface for deleting entries. The
|
||||
date and title of each entry in the journal are presented one at a time, and you
|
||||
can choose whether to keep or delete each entry.
|
||||
|
||||
If no filters are specified, `jrnl` will ask you to keep or delete each entry in
|
||||
the entire journal, one by one. If there are a lot of entries in the journal, it
|
||||
may be more efficient to filter entries before passing the `--delete` command.
|
||||
|
||||
Here's an example. Say you have a journal into which you've imported the last 12
|
||||
years of blog posts. You use the `@book` tag a lot, and for some reason you want
|
||||
to delete some, but not all, of the entries in which you used that tag, but only
|
||||
the ones you wrote at some point in 2004 or earlier. You're not sure which
|
||||
entries you want to keep, and you want to look through them before deciding.
|
||||
This is what you might enter:
|
||||
|
||||
```sh
|
||||
jrnl -to 2004 @book --delete
|
||||
```
|
||||
|
||||
`jrnl` will show you only the relevant entries, and you can choose the ones you
|
||||
want to delete.
|
||||
|
||||
You may want to delete _all_ of the entries containing `@book` that you wrote in
|
||||
2004 or earlier. If there are dozens or hundreds, the easiest way would be to
|
||||
use an external editor. Open an editor with the entries you want to delete...
|
||||
|
||||
```sh
|
||||
jrnl -to 2004 @book --edit
|
||||
```
|
||||
|
||||
...select everything, delete it, save and close, and all of those entries are
|
||||
removed from the journal.
|
||||
|
||||
## Listing Journals ##
|
||||
|
||||
To list all of your journals:
|
||||
|
||||
```sh
|
||||
jrnl --list
|
||||
```
|
||||
|
||||
The journals displayed correspond to those specified in the `jrnl`
|
||||
[configuration file](./reference-config-file.md#journals).
|
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
Copyright © 2012-2023 jrnl contributors
|
||||
License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
:root {
|
||||
/* For dark bg */
|
||||
--white: #fcfcfc;
|
||||
--off-white: #f4f0ff;
|
||||
--purple: #7e57c2;
|
||||
--light-purple: #cf93e6;
|
||||
--blue: #61aeee;
|
||||
--green: #a6e22e;
|
||||
--orange: #fd971f;
|
||||
--red: #eb5567;
|
||||
--pink: #d57699;
|
||||
--yellow: #e2b93d;
|
||||
|
||||
/* For light bg */
|
||||
--black: #404040;
|
||||
--teal: #2a8068;
|
||||
--dark-blue: #356eb7;
|
||||
--mid-purple: #846392;
|
||||
--bright-purple: #af27ad;
|
||||
--dark-purple: #604385;
|
||||
--darkest-purple: #251A32;
|
||||
--grey: #3b3b4a;
|
||||
|
||||
--black-shadow: #0000001A;
|
||||
--blacker-shadow: #00000059;
|
||||
|
||||
/* Special cases */
|
||||
--terminal: #1b1c2e;
|
||||
}
|
|
@ -1,147 +0,0 @@
|
|||
/*
|
||||
Copyright © 2012-2023 jrnl contributors
|
||||
License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Atom One Dark With support for ReasonML by Gidi Morris, based off work by
|
||||
Daniel Gamage
|
||||
|
||||
Original One Dark Syntax theme from https://github.com/atom/one-dark-syntax
|
||||
*/
|
||||
|
||||
.hljs {
|
||||
display: block;
|
||||
overflow-x: auto;
|
||||
padding: 0.5em;
|
||||
line-height: 1.3em;
|
||||
color: var(--off-white);
|
||||
background: #383e49;
|
||||
border-radius: 5px;
|
||||
font-size: 0.9rem;
|
||||
line-height: 1.3rem;
|
||||
}
|
||||
.hljs-keyword,
|
||||
.hljs-operator {
|
||||
color: var(--pink);
|
||||
}
|
||||
.hljs-pattern-match {
|
||||
color: var(--pink);
|
||||
}
|
||||
.hljs-pattern-match .hljs-constructor {
|
||||
color: var(--blue);
|
||||
}
|
||||
.hljs-function {
|
||||
color: var(--blue);
|
||||
}
|
||||
.hljs-function .hljs-params {
|
||||
color: var(--green);
|
||||
}
|
||||
.hljs-function .hljs-params .hljs-typing {
|
||||
color: var(--orange);
|
||||
}
|
||||
.hljs-module-access .hljs-module {
|
||||
color: var(--purple);
|
||||
}
|
||||
.hljs-constructor {
|
||||
color: var(--yellow);
|
||||
}
|
||||
.hljs-constructor .hljs-string {
|
||||
color: var(--green);
|
||||
}
|
||||
.hljs-comment,
|
||||
.hljs-quote {
|
||||
color: var(--light-purple);
|
||||
font-style: italic;
|
||||
}
|
||||
.hljs-doctag,
|
||||
.hljs-formula {
|
||||
color: var(--purple);
|
||||
}
|
||||
.hljs-section,
|
||||
.hljs-name,
|
||||
.hljs-selector-tag,
|
||||
.hljs-deletion,
|
||||
.hljs-subst {
|
||||
color: var(--yellow);
|
||||
}
|
||||
.hljs-literal {
|
||||
color: var(--blue);
|
||||
}
|
||||
.hljs-string,
|
||||
.hljs-regexp,
|
||||
.hljs-addition,
|
||||
.hljs-attribute,
|
||||
.hljs-meta-string {
|
||||
color: var(--green);
|
||||
}
|
||||
.hljs-built_in,
|
||||
.hljs-class .hljs-title {
|
||||
color: var(--orange);
|
||||
}
|
||||
.hljs-attr,
|
||||
.hljs-variable,
|
||||
.hljs-template-variable,
|
||||
.hljs-type,
|
||||
.hljs-selector-class,
|
||||
.hljs-selector-attr,
|
||||
.hljs-selector-pseudo,
|
||||
.hljs-number {
|
||||
color: var(--orange);
|
||||
}
|
||||
|
||||
.rst-content a tt,
|
||||
.rst-content a tt,
|
||||
.rst-content a code {
|
||||
color: var(--blue);
|
||||
}
|
||||
|
||||
.hljs-number,
|
||||
.hljs-literal,
|
||||
.hljs-variable,
|
||||
.hljs-template-variable,
|
||||
.hljs-tag .hljs-attr {
|
||||
color: var(--blue);
|
||||
}
|
||||
|
||||
.hljs-tag {
|
||||
color: var(--pink)
|
||||
}
|
||||
|
||||
.hljs-symbol,
|
||||
.hljs-bullet,
|
||||
.hljs-link,
|
||||
.hljs-meta,
|
||||
.hljs-selector-id,
|
||||
.hljs-title {
|
||||
color: var(--blue);
|
||||
}
|
||||
.hljs-emphasis {
|
||||
font-style: italic;
|
||||
}
|
||||
.hljs-strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
.hljs-link {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.rst-content .note .admonition-title {
|
||||
background: var(--dark-blue);
|
||||
}
|
||||
|
||||
.rst-content .note.admonition {
|
||||
background: var(--light-blue);
|
||||
}
|
||||
|
||||
.rst-content .tip .admonition-title {
|
||||
background: var(--teal);
|
||||
}
|
||||
|
||||
.rst-content .tip .admonition {
|
||||
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;
|
||||
}
|
||||
|
|
@ -1,325 +0,0 @@
|
|||
/*
|
||||
Copyright © 2012-2023 jrnl contributors
|
||||
License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
/* reset */article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}audio,canvas,video{display:inline-block}audio:not([controls]){display:none;height:0}[hidden]{display:none}html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}a:focus{outline:thin dotted}a:active,a:hover{outline:0}h1{font-size:2em;margin:.67em 0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}dfn{font-style:italic}hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0}mark{background:#ff0;color:#000}code,kbd,pre,samp{font-family:monospace,serif;font-size:1em}pre{white-space:pre-wrap}q{quotes:"\201C" "\201D" "\2018" "\2019"}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:0}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{border:0;padding:0}button,input,select,textarea{font-family:inherit;font-size:100%;margin:0}button,input{line-height:normal}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}textarea{overflow:auto;vertical-align:top}table{border-collapse:collapse;border-spacing:0}
|
||||
|
||||
body {
|
||||
background-color: var(--white);
|
||||
font-family: "Open Sans", "Helvetica Neue", sans-serif;
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
.icon {
|
||||
background-image: url("../img/sprites.svg");
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
display: inline-block;
|
||||
font-size: 40px;
|
||||
background-size: 200px 80px;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.icon.secure {
|
||||
background-position: 0em 0em;
|
||||
}
|
||||
|
||||
.icon.future {
|
||||
background-position: -1em 0em;
|
||||
}
|
||||
|
||||
.icon.search {
|
||||
background-position: -2em 0em;
|
||||
}
|
||||
|
||||
.icon.nli {
|
||||
background-position: -3em 0em;
|
||||
}
|
||||
|
||||
.icon.share {
|
||||
background-position: 0em -1em;
|
||||
}
|
||||
|
||||
.icon.sync {
|
||||
background-position: 0 -1em;
|
||||
}
|
||||
|
||||
.icon.dayone {
|
||||
background-position: -1em -1em;
|
||||
}
|
||||
|
||||
.icon.github {
|
||||
background-position: -2em -1em;
|
||||
}
|
||||
|
||||
.icon.search {
|
||||
background-position: -2em 0;
|
||||
}
|
||||
|
||||
.icon.folders {
|
||||
background-position: -3em -1em;
|
||||
}
|
||||
|
||||
.icon.twitter {
|
||||
background-position: -4em -1em;
|
||||
}
|
||||
|
||||
header {
|
||||
background-color: var(--mid-purple);
|
||||
background-image: linear-gradient(211deg, var(--mid-purple) 0%, var(--dark-purple) 100%);
|
||||
color: var(--white);
|
||||
border: 0px solid transparent;
|
||||
display: relative;
|
||||
padding-top: 150px;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
#terminal {
|
||||
background: var(--terminal);
|
||||
max-width: 520px;
|
||||
box-shadow: 0 -2px 16px 0 var(--black-shadow);
|
||||
border-radius: 6px;
|
||||
min-height: 120px;
|
||||
margin: 0px auto;
|
||||
position: relative;
|
||||
transform: translateY(75px);
|
||||
color: var(--off-white);
|
||||
font-family: "Monaco", "Courier New";
|
||||
font-size: 18px;
|
||||
padding: 45px 20px 0px 20px;
|
||||
line-height: 165%;
|
||||
}
|
||||
|
||||
#terminal b {
|
||||
font-weight: normal;
|
||||
color: var(--off-white);
|
||||
}
|
||||
|
||||
#terminal i {
|
||||
font-style: normal;
|
||||
color: var(--light-purple);
|
||||
}
|
||||
|
||||
#terminal:before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 15px;
|
||||
left: 15px;
|
||||
display: inline-block;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
border-radius: 50%;
|
||||
background: var(--grey);
|
||||
box-shadow: 25px 0 0 var(--grey), 50px 0 0 var(--grey);
|
||||
}
|
||||
|
||||
#typed:before {
|
||||
content: "$ ";
|
||||
color: var(--mid-purple);
|
||||
}
|
||||
|
||||
#twitter {
|
||||
display: block;
|
||||
position: absolute;
|
||||
text-decoration: none;
|
||||
top: 20px;
|
||||
right: 20px;
|
||||
border: 1px solid var(--white);
|
||||
padding: 5px 10px;
|
||||
color: var(--white);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
#twitter .icon {
|
||||
transform: scale(0.5);
|
||||
vertical-align: -18%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#twitter:hover,
|
||||
#twitter:active {
|
||||
text-decoration: none;
|
||||
box-shadow: 0 2px 25px 0 var(--blacker-shadow);
|
||||
transition: all .5s ease;
|
||||
}
|
||||
|
||||
#title {
|
||||
max-width: 630px;
|
||||
margin: 0 auto;
|
||||
padding: 0px 20px;
|
||||
}
|
||||
|
||||
#prompt {
|
||||
max-width: 700px;
|
||||
margin: 25px auto 100px auto;
|
||||
padding: 0px 20px;
|
||||
}
|
||||
|
||||
header img {
|
||||
float: left;
|
||||
margin-right: 30px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: var(--white);
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
a,
|
||||
a:visited {
|
||||
color: var(--dark-purple);
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: var(--bright-purple);
|
||||
}
|
||||
|
||||
nav {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
nav a#twitter-nav {
|
||||
display: none;
|
||||
}
|
||||
|
||||
nav a, nav a:visited {
|
||||
color: var(--dark-purple);
|
||||
font-size: 20px;
|
||||
line-height: 2.5em;
|
||||
margin: 0 40px;
|
||||
font-weight: 400;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
nav a:hover,
|
||||
nav a:visited:hover {
|
||||
color: var(--bright-purple);
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
|
||||
nav a.cta {
|
||||
display: inline-block;
|
||||
color: var(--white);
|
||||
background-color: var(--mid-purple);
|
||||
background-image: linear-gradient(259deg, var(--mid-purple) 0%, var(--dark-purple) 100%);
|
||||
box-shadow: 0 2px 8px 0 var(--blacker-shadow);
|
||||
border-radius: 50px;
|
||||
padding: 0 2em;
|
||||
white-space: nowrap;
|
||||
transition: all 0.1s ease;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
nav a.cta:hover {
|
||||
text-decoration: none;
|
||||
background-color: var(--mid-purple);
|
||||
background-image: linear-gradient(259deg, var(--bright-purple) 0%, var(--dark-purple) 100%);
|
||||
box-shadow: 0 4px 16px 0 var(--black-shadow);
|
||||
color: var(--off-white);
|
||||
}
|
||||
|
||||
main {
|
||||
padding: 60px 0 0 0;
|
||||
}
|
||||
|
||||
.flex {
|
||||
display: flex;
|
||||
margin: 0 auto;
|
||||
max-width: 920px;
|
||||
flex-wrap: wrap;
|
||||
padding: 20px 20px;
|
||||
padding-top: 30px;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.flex section {
|
||||
/*margin: 20px;*/
|
||||
margin-top: 40px;
|
||||
width: 32%;
|
||||
}
|
||||
|
||||
.flex section:first-child {
|
||||
margin-left: 0px;
|
||||
}
|
||||
.flex section:last-child {
|
||||
margin-right: 0px;
|
||||
}
|
||||
|
||||
.flex section i {
|
||||
float: left;
|
||||
left: 0;
|
||||
display: block;
|
||||
margin: 0px auto 10px auto;
|
||||
}
|
||||
|
||||
.flex section h3 {
|
||||
margin-top: 0;
|
||||
font-size: 18px;
|
||||
color: var(--dark-purple);
|
||||
margin-bottom: 0.5em;
|
||||
font-weight: 300;
|
||||
margin-left: 40px;
|
||||
}
|
||||
|
||||
.flex section p {
|
||||
padding-left: 40px;
|
||||
color: var(--grey);
|
||||
font-size: 16px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
footer {
|
||||
color: var(--grey);
|
||||
max-width: 700px;
|
||||
margin: 70px auto 20px;
|
||||
padding: 0 20px 20px 20px;
|
||||
font-size: 16px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 680px) {
|
||||
.flex {
|
||||
display: block;
|
||||
padding: 0;
|
||||
}
|
||||
.flex section {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
main {
|
||||
padding: 20px;
|
||||
margin: 0;
|
||||
width: calc(100% - 40px);
|
||||
}
|
||||
|
||||
nav a,
|
||||
nav a#twitter-nav {
|
||||
display: inline-block;
|
||||
margin: 0px 10px;
|
||||
}
|
||||
|
||||
nav a.cta {
|
||||
display: block;
|
||||
margin: 20px;
|
||||
}
|
||||
|
||||
header #twitter {
|
||||
display: none;
|
||||
}
|
||||
|
||||
header #logo {
|
||||
display: block;
|
||||
float: none;
|
||||
margin: 0px auto;
|
||||
}
|
||||
|
||||
header #title br {
|
||||
display: none;
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 43 KiB |
|
@ -1,378 +0,0 @@
|
|||
/*
|
||||
Copyright © 2012-2023 jrnl contributors
|
||||
License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* Overrides for jrnl theme */
|
||||
/* ------------------------------------------------------------ */
|
||||
|
||||
body.wy-body-for-nav,
|
||||
section.wy-nav-content-wrap {
|
||||
background-color: var(--white);
|
||||
color: var(--black);
|
||||
}
|
||||
|
||||
.rst-content pre {
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
margin: 1em -1em;
|
||||
}
|
||||
|
||||
.rst-content code {
|
||||
color: var(--darkest-purple);
|
||||
background-color: var(--off-white);
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.rst-content pre code {
|
||||
color: var(--off-white);
|
||||
background: var(--darkest-purple);
|
||||
padding: 1em 1.5em;
|
||||
border-radius: 15px;
|
||||
border: none;
|
||||
font-size: 16px;
|
||||
line-height: 1.5em;
|
||||
font-weight: 200 !important;
|
||||
}
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6 {
|
||||
font-family: "Open Sans", "Helvetica Neue", Helvetica, sans-serif;
|
||||
font-weight: 600;
|
||||
margin-top: 2rem;
|
||||
margin-bottom: 0.2rem;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1.2em;
|
||||
margin-top: 40px;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 1.1em;
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
p,
|
||||
td,
|
||||
tr,
|
||||
div,
|
||||
li {
|
||||
font-family: "Open Sans", "Helvetica Neue", Helvetica, sans-serif;
|
||||
font-weight: 00;
|
||||
font-size: 18px;
|
||||
line-height: 1.5em;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 1em 0em;
|
||||
}
|
||||
|
||||
/* No-one likes lines that are 400 characters long. */
|
||||
div.rst-content {
|
||||
max-width: 54em;
|
||||
}
|
||||
|
||||
|
||||
.wy-side-nav-search,
|
||||
.wy-menu-vertical li.current,
|
||||
.wy-menu-vertical li.toctree-l1.current > a,
|
||||
.wy-menu-vertical li.toctree-l2.current > a,
|
||||
.wy-menu-vertical li.toctree-l3.current > a {
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.wy-menu-vertical li.toctree-l2.current li.toctree-l3,
|
||||
.wy-menu-vertical li.toctree-l2.current li.toctree-l3 > a {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.wy-menu-vertical li.toctree-l4,
|
||||
.wy-menu-vertical li.toctree-l5,
|
||||
.wy-menu-vertical li.toctree-l6,
|
||||
.wy-menu-vertical li.toctree-l7 {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.wy-nav-top {
|
||||
background-color: var(--mid-purple);
|
||||
background-image: linear-gradient(-211deg, var(--mid-purple) 0%, var(--dark-purple) 100%);
|
||||
}
|
||||
|
||||
.wy-nav-top .fa-bars {
|
||||
line-height: 50px;
|
||||
}
|
||||
|
||||
.wy-side-nav-search a.icon-home {
|
||||
width: 100%;
|
||||
max-width: 250px;
|
||||
background-size: 100%;
|
||||
}
|
||||
|
||||
.wy-side-nav-search a.icon-home:before {
|
||||
display: block;
|
||||
width: 84px;
|
||||
height: 70px;
|
||||
content: "";
|
||||
background: url(../img/logo_white.svg) center center no-repeat;
|
||||
margin: 10px auto;
|
||||
}
|
||||
|
||||
.wy-menu-vertical a,
|
||||
.wy-menu-vertical li ul li a {
|
||||
font-size: 16px;
|
||||
color: var(--white);
|
||||
line-height: 2em;
|
||||
}
|
||||
|
||||
.wy-menu-vertical a:hover,
|
||||
.wy-menu-vertical li.toctree-l2.current li.toctree-l3 > a:hover,
|
||||
.wy-menu-vertical li.current a:hover {
|
||||
background-color: var(--black-shadow);
|
||||
color: var(--white);
|
||||
}
|
||||
|
||||
.wy-menu-vertical li.on a {
|
||||
transition: all .25s ease;
|
||||
background: var(--dark-purple);
|
||||
color: var(--white);
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.wy-menu-vertical li.toctree-l1.current > a {
|
||||
background: var(--darkest-purple);
|
||||
border: none !important;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.wy-menu-vertical li.on a,
|
||||
.wy-menu-vertical li.current a {
|
||||
border-right: none;
|
||||
}
|
||||
|
||||
.wy-menu-vertical li.on a,
|
||||
.wy-menu-vertical li > a.current:after {
|
||||
position: absolute;
|
||||
right: 0em;
|
||||
z-index: 999;
|
||||
content: "";
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-top: 1em solid transparent;
|
||||
border-bottom: 1em solid transparent;
|
||||
border-right: 1em solid var(--white);
|
||||
}
|
||||
|
||||
.toctree-expand:before {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.rst-versions,
|
||||
.rst-versions .rst-current-version {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.wy-menu-vertical p.caption {
|
||||
margin-top: 2em;
|
||||
}
|
||||
|
||||
.wy-menu-vertical span {
|
||||
color: var(--white);
|
||||
font-size: 1.2em;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.wy-menu-vertical li a {
|
||||
color: var(--white) !important;
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
|
||||
.wy-nav-side {
|
||||
background-color: var(--mid-purple);
|
||||
font-weight: 300;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
|
||||
footer {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.wy-side-nav-search input[type=text],
|
||||
.mkdocs-search input[type=text],
|
||||
form .search-query {
|
||||
background-color: var(--off-white);
|
||||
border: none;
|
||||
margin-bottom: 1em;
|
||||
color: var(--black);
|
||||
font-weight: 500;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.wy-side-nav-search input[type=text]::placeholder,
|
||||
.mkdocs-search input[type=text]::placeholder,
|
||||
form .search-query::placeholder {
|
||||
color: var(--dark-purple);
|
||||
}
|
||||
|
||||
.wy-side-nav-search > a:hover {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.wy-menu-vertical li.current ul {
|
||||
background-color: var(--mid-purple);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* Logo: ; */
|
||||
/* ------------------------------------------------------------ */
|
||||
|
||||
.logo {
|
||||
width: 128px;
|
||||
height: 128px;
|
||||
vertical-align: middle;
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* Code blocks in callouts */
|
||||
/* ------------------------------------------------------------ */
|
||||
|
||||
div.admonition {
|
||||
border-radius: 5px;
|
||||
margin: 1em -1em;
|
||||
}
|
||||
|
||||
div.admonition p.admonition-title {
|
||||
border-top-left-radius: 5px;
|
||||
border-top-right-radius: 5px;
|
||||
}
|
||||
|
||||
div.admonition>p {
|
||||
padding: 0em .5em;
|
||||
}
|
||||
|
||||
|
||||
div.admonition div.highlight {
|
||||
background: none !important;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* Fancy ordered lists. */
|
||||
/* ------------------------------------------------------------ */
|
||||
|
||||
ol {
|
||||
counter-reset: li;
|
||||
margin-left: 0px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
ol li {
|
||||
list-style: none !important;
|
||||
margin-bottom: 1.5em;
|
||||
margin-left: 3em !important;
|
||||
}
|
||||
|
||||
ol>li:before {
|
||||
content: counter(li);
|
||||
counter-increment: li;
|
||||
background-color: var(--sidebar);
|
||||
border-radius: 50%;
|
||||
display: block;
|
||||
float: left;
|
||||
margin-left: -3em;
|
||||
margin-top: -.3em;
|
||||
width: 2em;
|
||||
height: 2em;
|
||||
color: var(--dark-purple);
|
||||
text-align: center;
|
||||
line-height: 2em;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* Accessibility-related changes */
|
||||
/* ------------------------------------------------------------ */
|
||||
.rst-content div[role="main"] a,
|
||||
.rst-content div[role="main"] a:visited {
|
||||
color: var(--mid-purple);
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.rst-content div[role="main"] a:hover {
|
||||
color: var(--bright-purple);
|
||||
}
|
||||
|
||||
.rst-content div[role="navigation"] a,
|
||||
.rst-content div[role="navigation"] a:visited {
|
||||
color: var(--mid-purple);
|
||||
}
|
||||
|
||||
.mkdocs-search {
|
||||
display: flex;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.wy-side-nav-search input[type="text"],
|
||||
.mkdocs-search input[type=text] {
|
||||
border-radius: 50px 0 0 50px;
|
||||
height: 32px;
|
||||
border-right: none;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.mkdocs-search button {
|
||||
background-color: var(--off-white);
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
color: var(--mid-purple);
|
||||
border-radius: 0 50px 50px 0;
|
||||
height: 32px;
|
||||
width: 2.5em;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.mkdocs-search {
|
||||
border-radius: 50px;
|
||||
}
|
||||
|
||||
.mkdocs-search:focus-within {
|
||||
box-shadow: 0 2px 25px 0 var(--blacker-shadow);
|
||||
transition: all .5s ease;
|
||||
}
|
||||
|
||||
.rst-content div[role="main"] .mkdocs-search input[type="text"] {
|
||||
border-right: none;
|
||||
font-size: 100%;
|
||||
height: 48px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.rst-content div[role="main"] .mkdocs-search button {
|
||||
border-left: none;
|
||||
font-size: 100%;
|
||||
height: 48px;
|
||||
}
|
||||
|
||||
.rst-content div[role="main"] .mkdocs-search button:before {
|
||||
font-size: 140%;
|
||||
position: relative;
|
||||
left: -7px;
|
||||
top: -1px;
|
||||
}
|
||||
|
||||
.search-results {
|
||||
margin-top: 0;
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
<!--
|
||||
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> »</li>
|
||||
{%- if page %}
|
||||
{%- for doc in page.ancestors[::-1] %}
|
||||
{%- if doc.link %}
|
||||
<li><a href="{{ doc.link|e }}">{{ doc.title }}</a> »</li>
|
||||
{%- else %}
|
||||
<li>{{ doc.title }} »</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>
|
Before Width: | Height: | Size: 224 KiB |
Before Width: | Height: | Size: 175 KiB |
Before Width: | Height: | Size: 17 KiB |
|
@ -1,15 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="64px" height="64px" viewBox="0 0 64 64" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 55 (78076) - https://sketchapp.com -->
|
||||
<title>favicon</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<defs>
|
||||
<linearGradient x1="50%" y1="0%" x2="50%" y2="100%" id="linearGradient-1">
|
||||
<stop stop-color="#986B9D" offset="0%"></stop>
|
||||
<stop stop-color="#664C8B" offset="100%"></stop>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<g id="favicon" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<path d="M47,9.75231557 L47,37 L42,32 L37,37 L37,7 L25,7 C17.8202983,7 12,12.8202983 12,20 L12,44 C12,51.1797017 17.8202983,57 25,57 L32,57 L32,7 L34,7 L34,57 L39,57 C46.1797017,57 52,51.1797017 52,44 L52,20 C52,15.8373552 50.0435392,12.1316662 47,9.75231557 Z M47.097641,7.37132944 C51.2495133,10.039075 54,14.6983322 54,20 L54,44 C54,49.3016678 51.2495133,53.960925 47.097641,56.6286706 C52.7817736,55.2392133 57,50.1122164 57,44 L57,20 C57,13.8877836 52.7817736,8.76078667 47.097641,7.37132944 Z M16.902359,56.6286706 C12.7504867,53.960925 10,49.3016678 10,44 L10,20 C10,14.6983322 12.7504867,10.039075 16.902359,7.37132944 C11.2182264,8.76078667 7,13.8877836 7,20 L7,44 C7,50.1122164 11.2182264,55.2392133 16.902359,56.6286706 Z M52.097641,7.37132944 C56.2495133,10.039075 59,14.6983322 59,20 L59,44 C59,49.3016678 56.2495133,53.960925 52.097641,56.6286706 C57.7817736,55.2392133 62,50.1122164 62,44 L62,20 C62,13.8877836 57.7817736,8.76078667 52.097641,7.37132944 Z M11.902359,56.6286706 C7.7504867,53.960925 5,49.3016678 5,44 L5,20 C5,14.6983322 7.7504867,10.039075 11.902359,7.37132944 C6.21822638,8.76078667 2,13.8877836 2,20 L2,44 C2,50.1122164 6.21822638,55.2392133 11.902359,56.6286706 Z M15,5 L49,5 C57.2842712,5 64,11.7157288 64,20 L64,44 C64,52.2842712 57.2842712,59 49,59 L15,59 C6.71572875,59 0,52.2842712 0,44 L0,20 C2.0539126e-15,11.7157288 6.71572875,5 15,5 Z" id="Combined-Shape" fill="url(#linearGradient-1)" fill-rule="nonzero"></path>
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 2.1 KiB |
|
@ -1,10 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="90px" height="98px" viewBox="0 0 90 98" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 55 (78076) - https://sketchapp.com -->
|
||||
<title>jrnl_white</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<g id="jrnl_white" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<path d="M63,5.34786368 L63,43 L58,38 L53,43 L53,5 L30,5 C22.8202983,5 17,10.8202983 17,18 L17,58 C17,65.1797017 22.8202983,71 30,71 L45,71 L45,5 L47,5 L47,71 L60,71 C67.1797017,71 73,65.1797017 73,58 L73,18 C73,11.8528367 68.7334,6.70219128 63,5.34786368 Z M67.6693542,5.10618565 C72.0593056,7.72299627 75,12.5180801 75,18 L75,58 C75,63.4819199 72.0593056,68.2770037 67.6693542,70.8938143 C74.060623,70.0745197 79,64.6140865 79,58 L79,18 C79,11.3859135 74.060623,5.92548026 67.6693542,5.10618565 Z M22.3306458,70.8938143 C17.9406944,68.2770037 15,63.4819199 15,58 L15,18 C15,12.5180801 17.9406944,7.72299627 22.3306458,5.10618565 C15.939377,5.92548026 11,11.3859135 11,18 L11,58 C11,64.6140865 15.939377,70.0745197 22.3306458,70.8938143 Z M73.6693542,5.10618565 C78.0593056,7.72299627 81,12.5180801 81,18 L81,58 C81,63.4819199 78.0593056,68.2770037 73.6693542,70.8938143 C80.060623,70.0745197 85,64.6140865 85,58 L85,18 C85,11.3859135 80.060623,5.92548026 73.6693542,5.10618565 Z M16.3306458,70.8938143 C11.9406944,68.2770037 9,63.4819199 9,58 L9,18 C9,12.5180801 11.9406944,7.72299627 16.3306458,5.10618565 C9.93937703,5.92548026 5,11.3859135 5,18 L5,58 C5,64.6140865 9.93937703,70.0745197 16.3306458,70.8938143 Z M18,3 L72,3 C80.2842712,3 87,9.71572875 87,18 L87,58 C87,66.2842712 80.2842712,73 72,73 L18,73 C9.71572875,73 3,66.2842712 3,58 L3,18 C3,9.71572875 9.71572875,3 18,3 Z" id="Combined-Shape" fill="#FFFFFF" fill-rule="nonzero"></path>
|
||||
<path d="M24.22,95.092 C24.0293324,95.092 23.7616684,95.0736668 23.417,95.037 C23.0723316,95.0003332 22.7680013,94.9306672 22.504,94.828 L22.856,92.65 C23.1786683,92.7526672 23.5673311,92.804 24.022,92.804 C24.6380031,92.804 25.0706654,92.6243351 25.32,92.265 C25.5693346,91.9056649 25.694,91.3666703 25.694,90.648 L25.694,82.642 L28.356,82.285 L28.356,90.692 C28.356,92.1880075 28.0003369,93.2953297 27.289,94.014 C26.5776631,94.7326703 25.5546733,95.092 24.22,95.092 Z M41.4,84.892 C41.1799989,84.8186663 40.8756686,84.7416671 40.487,84.661 C40.0983314,84.5803329 39.6473359,84.54 39.134,84.54 C38.8406652,84.54 38.5290017,84.569333 38.199,84.628 C37.8689984,84.686667 37.6380007,84.7379998 37.506,84.782 L37.506,94 L34.844,94 L34.844,83.044 C35.3573359,82.8533324 35.9989962,82.6736675 36.769,82.505 C37.5390039,82.3363325 38.3933286,82.252 39.332,82.252 C39.5080009,82.252 39.7133322,82.2629999 39.948,82.285 C40.1826678,82.3070001 40.4173322,82.3363332 40.652,82.373 C40.8866678,82.4096669 41.1139989,82.4536664 41.334,82.505 C41.5540011,82.5563336 41.7299993,82.6039998 41.862,82.648 L41.4,84.892 Z M46.81,82.868 C47.3233359,82.7213326 47.9906626,82.5820007 48.812,82.45 C49.6333374,82.3179993 50.5426617,82.252 51.54,82.252 C52.4786714,82.252 53.2633302,82.3803321 53.894,82.637 C54.5246698,82.893668 55.0269981,83.2529977 55.401,83.715 C55.7750019,84.1770023 56.0389992,84.7343301 56.193,85.387 C56.3470008,86.0396699 56.424,86.7546628 56.424,87.532 L56.424,94 L53.762,94 L53.762,87.95 C53.762,87.3339969 53.7216671,86.8096688 53.641,86.377 C53.5603329,85.9443312 53.4283342,85.5923347 53.245,85.321 C53.0616658,85.0496653 52.8123349,84.8516673 52.497,84.727 C52.1816651,84.6023327 51.7966689,84.54 51.342,84.54 C51.004665,84.54 50.6526685,84.5619998 50.286,84.606 C49.9193315,84.6500002 49.6480009,84.6866665 49.472,84.716 L49.472,94 L46.81,94 L46.81,82.868 Z M66.784,94.22 C65.991996,94.2053333 65.3356693,94.1173341 64.815,93.956 C64.2943307,93.7946659 63.8800015,93.5636682 63.572,93.263 C63.2639985,92.9623318 63.0476673,92.5883356 62.923,92.141 C62.7983327,91.6936644 62.736,91.1840029 62.736,90.612 L62.736,82.692 L65.398,82.252 L65.398,90.106 C65.398,90.4286683 65.4236664,90.6999989 65.475,90.92 C65.5263336,91.1400011 65.6179993,91.3269992 65.75,91.481 C65.8820007,91.6350008 66.0616655,91.7523329 66.289,91.833 C66.5163345,91.9136671 66.8059982,91.9759998 67.158,92.02 L66.784,94.22 Z" id="jrnl" fill="#FFFFFF" fill-rule="nonzero"></path>
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 4.2 KiB |
|
@ -1,16 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="90px" height="98px" viewBox="0 0 90 98" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 55 (78076) - https://sketchapp.com -->
|
||||
<title>logo</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<defs>
|
||||
<linearGradient x1="50%" y1="0%" x2="50%" y2="100%" id="linearGradient-1">
|
||||
<stop stop-color="#986B9D" offset="0%"></stop>
|
||||
<stop stop-color="#664C8B" offset="100%"></stop>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<g id="logo" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<path d="M63,5.34786368 L63,43 L58,38 L53,43 L53,5 L30,5 C22.8202983,5 17,10.8202983 17,18 L17,58 C17,65.1797017 22.8202983,71 30,71 L45,71 L45,5 L47,5 L47,71 L60,71 C67.1797017,71 73,65.1797017 73,58 L73,18 C73,11.8528367 68.7334,6.70219128 63,5.34786368 Z M67.6693542,5.10618565 C72.0593056,7.72299627 75,12.5180801 75,18 L75,58 C75,63.4819199 72.0593056,68.2770037 67.6693542,70.8938143 C74.060623,70.0745197 79,64.6140865 79,58 L79,18 C79,11.3859135 74.060623,5.92548026 67.6693542,5.10618565 Z M22.3306458,70.8938143 C17.9406944,68.2770037 15,63.4819199 15,58 L15,18 C15,12.5180801 17.9406944,7.72299627 22.3306458,5.10618565 C15.939377,5.92548026 11,11.3859135 11,18 L11,58 C11,64.6140865 15.939377,70.0745197 22.3306458,70.8938143 Z M73.6693542,5.10618565 C78.0593056,7.72299627 81,12.5180801 81,18 L81,58 C81,63.4819199 78.0593056,68.2770037 73.6693542,70.8938143 C80.060623,70.0745197 85,64.6140865 85,58 L85,18 C85,11.3859135 80.060623,5.92548026 73.6693542,5.10618565 Z M16.3306458,70.8938143 C11.9406944,68.2770037 9,63.4819199 9,58 L9,18 C9,12.5180801 11.9406944,7.72299627 16.3306458,5.10618565 C9.93937703,5.92548026 5,11.3859135 5,18 L5,58 C5,64.6140865 9.93937703,70.0745197 16.3306458,70.8938143 Z M18,3 L72,3 C80.2842712,3 87,9.71572875 87,18 L87,58 C87,66.2842712 80.2842712,73 72,73 L18,73 C9.71572875,73 3,66.2842712 3,58 L3,18 C3,9.71572875 9.71572875,3 18,3 Z" id="Combined-Shape" fill="url(#linearGradient-1)" fill-rule="nonzero"></path>
|
||||
<path d="M24.22,95.092 C24.0293324,95.092 23.7616684,95.0736668 23.417,95.037 C23.0723316,95.0003332 22.7680013,94.9306672 22.504,94.828 L22.856,92.65 C23.1786683,92.7526672 23.5673311,92.804 24.022,92.804 C24.6380031,92.804 25.0706654,92.6243351 25.32,92.265 C25.5693346,91.9056649 25.694,91.3666703 25.694,90.648 L25.694,82.642 L28.356,82.285 L28.356,90.692 C28.356,92.1880075 28.0003369,93.2953297 27.289,94.014 C26.5776631,94.7326703 25.5546733,95.092 24.22,95.092 Z M41.4,84.892 C41.1799989,84.8186663 40.8756686,84.7416671 40.487,84.661 C40.0983314,84.5803329 39.6473359,84.54 39.134,84.54 C38.8406652,84.54 38.5290017,84.569333 38.199,84.628 C37.8689984,84.686667 37.6380007,84.7379998 37.506,84.782 L37.506,94 L34.844,94 L34.844,83.044 C35.3573359,82.8533324 35.9989962,82.6736675 36.769,82.505 C37.5390039,82.3363325 38.3933286,82.252 39.332,82.252 C39.5080009,82.252 39.7133322,82.2629999 39.948,82.285 C40.1826678,82.3070001 40.4173322,82.3363332 40.652,82.373 C40.8866678,82.4096669 41.1139989,82.4536664 41.334,82.505 C41.5540011,82.5563336 41.7299993,82.6039998 41.862,82.648 L41.4,84.892 Z M46.81,82.868 C47.3233359,82.7213326 47.9906626,82.5820007 48.812,82.45 C49.6333374,82.3179993 50.5426617,82.252 51.54,82.252 C52.4786714,82.252 53.2633302,82.3803321 53.894,82.637 C54.5246698,82.893668 55.0269981,83.2529977 55.401,83.715 C55.7750019,84.1770023 56.0389992,84.7343301 56.193,85.387 C56.3470008,86.0396699 56.424,86.7546628 56.424,87.532 L56.424,94 L53.762,94 L53.762,87.95 C53.762,87.3339969 53.7216671,86.8096688 53.641,86.377 C53.5603329,85.9443312 53.4283342,85.5923347 53.245,85.321 C53.0616658,85.0496653 52.8123349,84.8516673 52.497,84.727 C52.1816651,84.6023327 51.7966689,84.54 51.342,84.54 C51.004665,84.54 50.6526685,84.5619998 50.286,84.606 C49.9193315,84.6500002 49.6480009,84.6866665 49.472,84.716 L49.472,94 L46.81,94 L46.81,82.868 Z M66.784,94.22 C65.991996,94.2053333 65.3356693,94.1173341 64.815,93.956 C64.2943307,93.7946659 63.8800015,93.5636682 63.572,93.263 C63.2639985,92.9623318 63.0476673,92.5883356 62.923,92.141 C62.7983327,91.6936644 62.736,91.1840029 62.736,90.612 L62.736,82.692 L65.398,82.252 L65.398,90.106 C65.398,90.4286683 65.4236664,90.6999989 65.475,90.92 C65.5263336,91.1400011 65.6179993,91.3269992 65.75,91.481 C65.8820007,91.6350008 66.0616655,91.7523329 66.289,91.833 C66.5163345,91.9136671 66.8059982,91.9759998 67.158,92.02 L66.784,94.22 Z" id="jrnl" fill="#674C8B" fill-rule="nonzero"></path>
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 4.5 KiB |
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="84px" height="70px" viewBox="0 0 84 70" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 55 (78076) - https://sketchapp.com -->
|
||||
<title>logo_white</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<g id="logo_white" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<path d="M60,2.34786368 L60,40 L55,35 L50,40 L50,2 L27,2 C19.8202983,2 14,7.82029825 14,15 L14,55 C14,62.1797017 19.8202983,68 27,68 L42,68 L42,2 L44,2 L44,68 L57,68 C64.1797017,68 70,62.1797017 70,55 L70,15 C70,8.85283673 65.7334,3.70219128 60,2.34786368 Z M64.6693542,2.10618565 C69.0593056,4.72299627 72,9.51808015 72,15 L72,55 C72,60.4819199 69.0593056,65.2770037 64.6693542,67.8938143 C71.060623,67.0745197 76,61.6140865 76,55 L76,15 C76,8.38591347 71.060623,2.92548026 64.6693542,2.10618565 Z M19.3306458,67.8938143 C14.9406944,65.2770037 12,60.4819199 12,55 L12,15 C12,9.51808015 14.9406944,4.72299627 19.3306458,2.10618565 C12.939377,2.92548026 8,8.38591347 8,15 L8,55 C8,61.6140865 12.939377,67.0745197 19.3306458,67.8938143 Z M70.6693542,2.10618565 C75.0593056,4.72299627 78,9.51808015 78,15 L78,55 C78,60.4819199 75.0593056,65.2770037 70.6693542,67.8938143 C77.060623,67.0745197 82,61.6140865 82,55 L82,15 C82,8.38591347 77.060623,2.92548026 70.6693542,2.10618565 Z M13.3306458,67.8938143 C8.94069436,65.2770037 6,60.4819199 6,55 L6,15 C6,9.51808015 8.94069436,4.72299627 13.3306458,2.10618565 C6.93937703,2.92548026 2,8.38591347 2,15 L2,55 C2,61.6140865 6.93937703,67.0745197 13.3306458,67.8938143 Z M15,0 L69,0 C77.2842712,-1.33226763e-15 84,6.71572875 84,15 L84,55 C84,63.2842712 77.2842712,70 69,70 L15,70 C6.71572875,70 2.66453526e-15,63.2842712 0,55 L0,15 C-8.8817842e-16,6.71572875 6.71572875,1.33226763e-15 15,0 Z" id="Combined-Shape" fill="#FFFFFF" fill-rule="nonzero"></path>
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 1.9 KiB |
|
@ -1,14 +0,0 @@
|
|||
<svg width="400" height="160" viewBox="0 0 400 160" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g id="sprites">
|
||||
<path id="path10" fill-rule="evenodd" clip-rule="evenodd" d="M176.001 24.001C176.001 10.7458 186.746 0 200.002 0C213.257 0 224.003 10.7471 224 24.001C224 37.2562 213.254 48.002 199.999 48.002C195.938 48.002 192.117 46.9846 188.765 45.2019L172.083 61.8826L172.087 61.8866C170.806 63.192 169.028 64.004 167.058 64.004C163.16 64.004 160 60.8452 160 56.9464C160 54.973 160.812 53.1969 162.117 51.9142L162.103 51.9022L178.791 35.2175C177.014 31.8667 176.001 28.0532 176.001 24.001ZM167.058 60.4732C168.054 60.4732 168.946 60.0545 169.59 59.3865L185.718 43.2605C183.82 41.8457 182.14 40.1657 180.73 38.2643L164.598 54.3969L164.615 54.4129C163.948 55.0596 163.528 55.949 163.528 56.945C163.528 58.8958 165.108 60.4732 167.058 60.4732ZM200.002 44.0045C188.957 44.0045 180.001 35.0455 180.001 24.0037C180.001 12.9592 188.957 4.00283 200.002 4.00283C211.043 4.00283 220.003 12.9592 220.003 24.0037C220.003 35.0468 211.045 44.0045 200.002 44.0045ZM201.002 11.0018C201.002 10.4498 200.551 10.0017 200.002 10.0017C192.268 10.0017 186.001 16.2687 186.001 24.0023C186.001 24.5544 186.449 25.0024 187.001 25.0024C187.553 25.0024 188.001 24.5544 188.001 24.0023C188.001 17.3754 193.373 12.0018 200.002 12.0018C200.551 12.0018 201.002 11.5525 201.002 11.0018Z" fill="#684688"/>
|
||||
<path id="path12" fill-rule="evenodd" clip-rule="evenodd" d="M42 26V18C42 8.05733 33.9427 0 24 0C14.0573 0 6 8.05733 6 18V26C2.68533 26 0 28.6853 0 32V38V40V44V46C0 55.9427 8.05733 64 18 64H30C39.9427 64 48 55.9427 48 46V44V40V38V32C48 28.684 45.312 26 42 26ZM10 18C10 10.268 16.268 4 24 4C31.732 4 38 10.268 38 18V26H34V18.004C34 12.48 29.524 8.004 24 8.004C18.476 8.004 14 12.48 14 18.004V26H10V18ZM32 18.0067V18C32 13.5827 28.4173 10 24 10C19.5813 10 16 13.5813 16 18V18.004V26H32V18.0067ZM44 38V40V44V46C44 53.7173 37.7173 60 30 60H18C10.2827 60 4 53.7173 4 46V44V40V38V32C4 30.896 4.896 30 6 30H10H38H42C43.1027 30 44 30.896 44 32V38ZM28 42C28 39.7907 26.208 38 24 38C21.792 38 20 39.7907 20 42C20 43.2133 20.6667 45.52 21.3333 47.344C21.8787 48.828 22.5627 49.996 24 49.996C25.564 49.996 26.1213 48.84 26.668 47.364C27.344 45.536 28 43.2173 28 42Z" fill="#684688"/>
|
||||
<path id="path6" fill-rule="evenodd" clip-rule="evenodd" d="M37.4495 102.225L56 110.175V88.9754L49.2056 93.8301C44.3508 88.4239 37.3366 85 29.5 85C17.0237 85 6.58791 93.6333 3.7737 105.244L8.72074 107.291C10.6738 97.6002 19.2306 90.2993 29.5 90.2993C35.5547 90.2993 41.001 92.8572 44.8646 96.9285L37.4495 102.225ZM29.5 132.701C23.4453 132.701 17.9966 130.143 14.1354 126.073L21.5505 120.773L3 112.824V134.025L9.79444 129.17C14.6467 134.576 21.6634 138 29.5 138C41.9945 138 52.4412 129.342 55.2397 117.709L50.2975 115.594C48.3894 125.344 39.8083 132.701 29.5 132.701Z" fill="#684688"/>
|
||||
<path id="Combined Shape" fill-rule="evenodd" clip-rule="evenodd" d="M124 84H130.667C138.03 84 144 89.9695 144 97.3333V126.667C144 134.03 138.03 140 130.667 140H124H100H93.3333C85.9695 140 80 134.03 80 126.667V97.3333C80 89.9695 85.9695 84 93.3333 84H100H124ZM110.667 88H100C94.8453 88 90.6667 92.1787 90.6667 97.3333V126.667C90.6667 131.821 94.8453 136 100 136H110.667V88ZM114.667 88V136H124C129.155 136 133.333 131.821 133.333 126.667V97.3333C133.333 94.1617 131.751 91.3595 129.333 89.6729V109.333L124 105.333L118.667 109.333V88H114.667ZM134.13 135.336C136.127 133.005 137.333 129.977 137.333 126.667V97.3333C137.333 94.0233 136.127 90.9949 134.13 88.6638C137.57 90.0393 140 93.4025 140 97.3333V126.667C140 130.597 137.57 133.961 134.13 135.336ZM89.8697 135.336C87.8729 133.005 86.6667 129.977 86.6667 126.667V97.3333C86.6667 94.0233 87.8728 90.9949 89.8697 88.6638C86.43 90.0393 84 93.4025 84 97.3333V126.667C84 130.597 86.43 133.961 89.8697 135.336Z" fill="#684688"/>
|
||||
<path id="path8" fill-rule="evenodd" clip-rule="evenodd" d="M363.625 13.625V2L384 16.5417L363.625 31.0833V22.375C335.716 22.375 332.168 42.2843 331.708 47.375C332.463 13.711 363.625 13.625 363.625 13.625ZM320 16.5417C320 12.1097 323.568 8.54167 328 8.54167H353.333L344 12.5417H328C325.784 12.5417 324 14.3257 324 16.5417V52.5417C324 54.7577 325.784 56.5417 328 56.5417H369.333C371.549 56.5417 373.333 54.7577 373.333 52.5417V32.5417L377.333 29.875V52.5417C377.333 56.9737 373.765 60.5417 369.333 60.5417H328C323.568 60.5417 320 56.9737 320 52.5417V16.5417Z" fill="#684688"/>
|
||||
<path id="path16" fill-rule="evenodd" clip-rule="evenodd" d="M272 3C254.327 3 240 13.7453 240 27C240 35.2547 245.557 42.532 254.016 46.852C254.016 46.878 254.012 46.8999 254.008 46.9224C254.004 46.9459 254 46.97 254 47C254 50.1096 251.986 53.4268 250.683 55.5737L250.683 55.5739C250.483 55.9023 250.3 56.2033 250.144 56.472H250.148C250.053 56.692 250 56.9333 250 57.188C250 58.188 250.809 59 251.812 59C251.902 59 252.025 58.9887 252.127 58.9792C252.239 58.9689 252.326 58.9609 252.321 58.972C258.572 57.948 264.46 52.2053 265.828 50.5427C267.827 50.836 269.887 51 272 51C289.671 51 304 40.2547 304 27C304 13.7453 289.672 3 272 3ZM272 13C272.552 13 273 13.448 273 14C273 14.552 272.549 15 272 15C261.345 15 252 20.608 252 27C252 27.552 251.552 28 251 28C250.448 28 250 27.552 250 27C250 19.412 260.075 13 272 13ZM266.408 46.5867C268.284 46.86 270.165 47 272 47C287.439 47 300 38.028 300 27C300 15.972 287.436 7 272 7C256.56 7 244 15.972 244 27C244 33.4147 248.424 39.504 255.836 43.2893C257.175 43.972 258.016 45.3467 258.016 46.8507C258.016 46.96 258.011 47.0907 257.999 47.2187C257.956 49.2867 257.347 51.292 256.567 53.0827C259.444 51.372 261.88 49.0467 262.736 48.004C263.503 47.072 264.64 46.544 265.828 46.544C266.02 46.544 266.213 46.5547 266.408 46.5867Z" fill="#684688"/>
|
||||
<path id="path22" fill-rule="evenodd" clip-rule="evenodd" d="M160 112C160 94.3267 174.327 80 192 80C209.673 80 224 94.3267 224 112C224 129.673 209.673 144 192 144C174.327 144 160 129.673 160 112ZM220 112C220 96.536 207.464 84 192 84C176.536 84 164 96.536 164 112C164 124.684 172.434 135.391 184 138.833V137.75V135.125V132.875C184 130.334 184.875 128.5 186.583 127.333C185.501 127.229 184.489 127.062 183.583 126.875C182.838 126.721 182.282 126.524 181.545 126.261C181.387 126.205 181.22 126.146 181.042 126.083C180.031 125.73 179.135 125.282 178.333 124.792C177.532 124.301 176.74 123.656 176 122.875C175.26 122.094 174.625 121.239 174.125 120.25C173.625 119.261 173.25 118.052 172.958 116.667C172.666 115.281 172.5 113.75 172.5 112.083C172.5 108.854 173.563 106.104 175.667 103.833C174.708 101.355 174.833 98.667 176 95.7083C176.012 95.7042 176.025 95.6992 176.039 95.6938C176.097 95.6718 176.175 95.6422 176.292 95.625C176.437 95.6037 176.781 95.6253 177.292 95.6667C177.802 95.708 178.365 95.8227 178.958 96C179.552 96.1773 180.344 96.5107 181.333 97C182.323 97.4907 183.354 98.0827 184.458 98.8333C186.896 98.1467 189.437 97.8333 192.125 97.8333C194.792 97.8333 197.396 98.1453 199.875 98.8333C201.626 97.6453 203.178 96.813 204.583 96.2917C205.989 95.7703 206.959 95.5207 207.5 95.5833L208.292 95.6667C209.458 98.604 209.584 101.333 208.625 103.833C210.729 106.105 211.75 108.854 211.75 112.083C211.75 113.75 211.625 115.281 211.333 116.667C211.041 118.052 210.625 119.261 210.125 120.25C209.625 121.239 209.03 122.094 208.292 122.875C207.553 123.656 206.761 124.302 205.958 124.792C205.156 125.281 204.261 125.73 203.25 126.083C202.239 126.437 201.28 126.688 200.375 126.875C199.47 127.062 198.459 127.188 197.375 127.292C199.104 128.48 200 130.354 200 132.875V135.375V137.667V138.833C211.566 135.391 220 124.684 220 112Z" fill="#684688"/>
|
||||
<path id="path3858" fill-rule="evenodd" clip-rule="evenodd" d="M100 0C99.0049 0 98.0752 0.350804 97.3333 0.958333C96.5914 1.56586 96 2.50111 96 3.625V5.33333H94.6667V6.66667H87.3333C87.264 6.66305 87.1944 6.66305 87.125 6.66667C86.1491 6.76895 85.3281 7.68544 85.3333 8.66667V9.33333H83.3333C82.2862 9.33344 81.3334 10.2862 81.3333 11.3333V12.125C80.563 12.3974 80.0044 13.1829 80 14V18C80.0001 19.0472 80.9528 19.9999 82 20H85.3333V53.3333L83.6667 54.9167C83.0569 55.2687 82.6604 55.9626 82.6667 56.6667V60.6667C82.6668 61.7138 83.6195 62.6666 84.6667 62.6667H95.2083H104.667H104.875H115.333C116.381 62.6666 117.333 61.7138 117.333 60.6667V56.6667C117.34 55.9626 116.943 55.2687 116.333 54.9167L114.667 53.3333V20H118C119.047 19.9999 120 19.0472 120 18V14C119.996 13.1829 119.437 12.3974 118.667 12.125V11.3333C118.667 10.2862 117.714 9.33344 116.667 9.33333H114.667V8.66667C114.667 7.6195 113.714 6.66677 112.667 6.66667H105.333V5.33333H104V3.625C104 2.50111 103.409 1.56586 102.667 0.958333C101.925 0.350804 100.995 0 100 0ZM100 2.66667C100.274 2.66667 100.684 2.81724 100.958 3.04167C101.232 3.26609 101.333 3.47936 101.333 3.625V5.33333H98.6667V3.625C98.6667 3.47936 98.7676 3.26609 99.0417 3.04167C99.3157 2.81724 99.7255 2.66667 100 2.66667ZM112 12V10.6667H88V12H85.3333C85.2542 12.8356 85.0919 13.6063 84 13.5417V17.3333H89.3333H110.667H116V13.4167C114.82 13.6844 114.596 12.9828 114.667 12H112ZM110.667 20V56L113.333 57.8333V58.6667H86.6667V57.8333L89.3333 56V20H110.667ZM92 28V22.6667H94.6667V28H92ZM96 22.6667V28H98.6667V22.6667H96ZM101.333 28V22.6667H104V28H101.333ZM105.333 22.6667V28H108V22.6667H105.333ZM92 34.6667V29.3333H94.6667V34.6667H92ZM96 29.3333V34.6667H98.6667V29.3333H96ZM101.333 34.6667V29.3333H104V34.6667H101.333ZM105.333 29.3333V34.6667H108V29.3333H105.333ZM101.333 42.6667C101.333 41.6527 102.153 40.8333 103.167 40.8333C104.181 40.8333 105 41.6527 105 42.6667C105 43.6806 104.181 44.5 103.167 44.5C102.153 44.5 101.333 43.6806 101.333 42.6667Z" fill="#684688"/>
|
||||
<path id="path20" fill-rule="evenodd" clip-rule="evenodd" d="M247.472 80L243.472 115.792L247.43 116.208L251.013 84H291.93L295.513 116.208L299.472 115.792L295.472 80H247.472ZM255.472 88V92H287.472V88H255.472ZM255.472 100V96H287.472V100H255.472ZM255.472 104V108H287.472V104H255.472ZM255.472 116V112H287.472V116H255.472ZM241.472 120C240.372 120 239.749 120.873 240.097 121.917L246.847 142.083C247.195 143.127 248.372 144 249.472 144H293.472C294.572 144 295.749 143.127 296.097 142.083L302.847 121.917C303.196 120.873 302.572 120 301.472 120H241.472ZM279.472 124H263.472V128H279.472V124Z" fill="#684688"/>
|
||||
<path id="Vector" d="M370.378 82H380.145L358.811 107.042L384 141H364.209L348.787 120.416L331.052 141H321.285L344.161 114.253L320 82H340.305L354.313 100.88L370.378 82ZM366.908 134.969H372.305L337.349 87.6378H331.438L366.908 134.969Z" fill="white"/>
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 10 KiB |
|
@ -1,127 +0,0 @@
|
|||
<!--
|
||||
Copyright © 2012-2023 jrnl contributors
|
||||
License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
-->
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>jrnl - The Command Line Journal</title>
|
||||
<meta name="description" content="Collect your thoughts and notes without leaving the command line.">
|
||||
<meta name="image" content="https://jrnl.sh/en/stable/img/banner_og.png">
|
||||
<meta itemprop="name" content="jrnl - The Command Line Journal">
|
||||
<meta itemprop="description" content="Collect your thoughts and notes without leaving the command line.">
|
||||
<meta itemprop="image" content="https://jrnl.sh/en/stable/img/banner_og.png">
|
||||
<meta name="twitter:card" content="summary">
|
||||
<meta name="twitter:title" content="jrnl - The Command Line Journal">
|
||||
<meta name="twitter:description" content="Collect your thoughts and notes without leaving the command line.">
|
||||
<meta name="twitter:creator" content="jrnl">
|
||||
<meta name="twitter:image:src" content="https://jrnl.sh/en/stable/img/banner_twitter.png">
|
||||
<meta name="og:title" content="jrnl - The Command Line Journal">
|
||||
<meta name="og:description" content="Collect your thoughts and notes without leaving the command line.">
|
||||
<meta name="og:image" content="https://jrnl.sh/en/stable/img/banner_og.png">
|
||||
<meta name="og:url" content="https://jrnl.sh">
|
||||
<meta name="og:site_name" content="jrnl - The Command Line Journal">
|
||||
<meta name="og:type" content="website">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<link href='http://fonts.googleapis.com/css?family=Open+Sans:300,400' rel='stylesheet' type='text/css'>
|
||||
<link rel="stylesheet" href="assets/colors.css">
|
||||
<link rel="stylesheet" href="assets/index.css">
|
||||
<link rel="shortcut icon" href="img/favicon.ico">
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "https://schema.org",
|
||||
"@type": "SoftwareApplication",
|
||||
"applicationCategory": "https://schema.org/LifestyleApplication",
|
||||
"name": "jrnl",
|
||||
"description": "Collect your thoughts and notes without leaving the command line.",
|
||||
"operatingSystem": ["macOS", "Windows", "Linux"],
|
||||
"thumbnailUrl": "https://jrnl.sh/en/stable/img/banner_og.png",
|
||||
"installUrl": "https://jrnl.sh/en/stable/installation",
|
||||
"softwareVersion": "2.5"
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header>
|
||||
<aside>
|
||||
<a id="twitter" 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</a>
|
||||
</aside>
|
||||
<div id="title">
|
||||
<img id="logo" src="img/jrnl_white.svg" width="90px" height="98px" title="jrnl" alt="jrnl logo" />
|
||||
<h1>Collect your thoughts and notes <br />without leaving the command line.</h1>
|
||||
</div>
|
||||
<div id="prompt">
|
||||
<div id="terminal">
|
||||
<div id="typed"></div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<main>
|
||||
<nav>
|
||||
<a href="overview">Documentation</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 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>
|
||||
<div class="flex">
|
||||
<section>
|
||||
<i class="icon nli"></i>
|
||||
<h3>Human friendly.</h3>
|
||||
<p>jrnl has a natural-language interface so you don't have to remember cryptic shortcuts when you're writing down your thoughts.</p>
|
||||
</section>
|
||||
<section>
|
||||
<i class="icon future"></i>
|
||||
<h3>Future-proof.</h3>
|
||||
<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>
|
||||
<i class="icon secure"></i>
|
||||
<h3>Secure.</h3>
|
||||
<p>Encrypt your journals with industry-strength AES encryption. Nobody will be able to read your dirty secrets—not even you, if you lose your password!</p>
|
||||
</section>
|
||||
<section>
|
||||
<i class="icon sync"></i>
|
||||
<h3>Accessible anywhere.</h3>
|
||||
<p>Sync your journal files with other tools like Dropbox to capture your thoughts wherever you are.</p>
|
||||
</section>
|
||||
<section>
|
||||
<i class="icon github"></i>
|
||||
<h3>Free & Open Source.</h3>
|
||||
<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>
|
||||
<i class="icon folders"></i>
|
||||
<h3>For work and play.</h3>
|
||||
<p>Effortlessly access several journals for all parts of your life.</p>
|
||||
</section>
|
||||
</div>
|
||||
</main>
|
||||
<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.
|
||||
</footer>
|
||||
<script src="https://unpkg.com/typed.js@2.1.0/dist/typed.umd.js"></script>
|
||||
<script>
|
||||
new Typed("#typed", {
|
||||
strings: [
|
||||
"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 <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. Tagging them so I can easily look this up later.",
|
||||
"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>--encrypt</b><br /><i>`(AES encryption. Don't lose your password!)</i>`"
|
||||
],
|
||||
typeSpeed: 20, // less is faster
|
||||
backSpeed: 10,
|
||||
backDelay: 2500,
|
||||
loop: true,
|
||||
showCursor: false
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -1 +0,0 @@
|
|||
var typed2 =
|
|
@ -1,17 +0,0 @@
|
|||
<!--
|
||||
Copyright © 2012-2023 jrnl contributors
|
||||
License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
-->
|
||||
|
||||
{% extends "base.html" %}
|
||||
|
||||
{%- block search_button %}
|
||||
{% if 'search' in config['plugins'] %}
|
||||
<div role="search">
|
||||
<form id ="rtd-search-form" class="wy-form mkdocs-search" action="{{ base_url }}/search.html" method="get">
|
||||
<input type="text" name="q" placeholder="Search docs" title="Type search term here" />
|
||||
<button class="icon icon-search" aria-label="submit"></button>
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
{%- endblock %}
|
|
@ -1,2 +0,0 @@
|
|||
mkdocs>=1.4
|
||||
jinja2==3.1.6
|
|
@ -1,34 +0,0 @@
|
|||
<!--
|
||||
Copyright © 2012-2023 jrnl contributors
|
||||
License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
-->
|
||||
|
||||
{% extends "main.html" %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div role="search">
|
||||
<form id ="content_search" class="wy-form mkdocs-search" action="{{ base_url }}/search.html" method="get">
|
||||
|
||||
<span role="status" aria-live="polite" class="ui-helper-hidden-accessible"></span>
|
||||
<input
|
||||
name="q"
|
||||
id="mkdocs-search-query"
|
||||
type="text"
|
||||
class="search_input search-query ui-autocomplete-input"
|
||||
placeholder="Search the Docs"
|
||||
autocomplete="off"
|
||||
autofocus
|
||||
title="Type search term here"
|
||||
>
|
||||
<button class="icon icon-search" aria-label="submit"></button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<h1 id="search">Results</h1>
|
||||
|
||||
<div id="mkdocs-search-results" class="search-results">
|
||||
Searching...
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
|
@ -1,8 +0,0 @@
|
|||
# Stop
|
||||
|
||||
Please don't file a blank issue.
|
||||
|
||||
Fill out one of the templates from the link below and we'll be better able to
|
||||
help you.
|
||||
|
||||
https://github.com/jrnl-org/jrnl/issues/new/choose
|
56
jrnl/Entry.py
Normal file
|
@ -0,0 +1,56 @@
|
|||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
import re
|
||||
|
||||
class Entry:
|
||||
def __init__(self, journal, date=None, title="", body=""):
|
||||
self.journal = journal # Reference to journal mainly to access it's config
|
||||
self.date = date
|
||||
self.title = title.strip()
|
||||
self.body = body.strip()
|
||||
self.tags = self.parse_tags()
|
||||
|
||||
def parse_tags(self):
|
||||
fulltext = " ".join([self.title, self.body]).lower()
|
||||
tags = re.findall(r"([%s]\w+)" % self.journal.config['tagsymbols'], fulltext)
|
||||
self.tags = set(tags)
|
||||
|
||||
def __str__(self):
|
||||
date_str = self.date.strftime(self.journal.config['timeformat'])
|
||||
body_wrapper = "\n" if self.body else ""
|
||||
body = body_wrapper + self.body.strip()
|
||||
space = "\n"
|
||||
|
||||
return "%(date)s %(title)s %(body)s %(space)s" % {
|
||||
'date': date_str,
|
||||
'title': self.title,
|
||||
'body': body,
|
||||
'space': space
|
||||
}
|
||||
|
||||
def __repr__(self):
|
||||
return str(self)
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
'title': self.title.strip(),
|
||||
'body': self.body.strip(),
|
||||
'date': self.date.strftime("%Y-%m-%d"),
|
||||
'time': self.date.strftime("%H:%M")
|
||||
}
|
||||
|
||||
def to_md(self):
|
||||
date_str = self.date.strftime(self.journal.config['timeformat'])
|
||||
body_wrapper = "\n\n" if self.body.strip() else ""
|
||||
body = body_wrapper + self.body.strip()
|
||||
space = "\n"
|
||||
md_head = "###"
|
||||
|
||||
return "%(md)s %(date)s, %(title)s %(body)s %(space)s" % {
|
||||
'md': md_head,
|
||||
'date': date_str,
|
||||
'title': self.title,
|
||||
'body': body,
|
||||
'space': space
|
||||
}
|
279
jrnl/Journal.py
Normal file
|
@ -0,0 +1,279 @@
|
|||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
from Entry import Entry
|
||||
import os
|
||||
import parsedatetime.parsedatetime as pdt
|
||||
import parsedatetime.parsedatetime_consts as pdc
|
||||
import re
|
||||
from datetime import datetime
|
||||
import time
|
||||
try: import simplejson as json
|
||||
except ImportError: import json
|
||||
import sys
|
||||
import readline, glob
|
||||
try:
|
||||
from Crypto.Cipher import AES
|
||||
from Crypto.Random import random, atfork
|
||||
except ImportError:
|
||||
pass
|
||||
import hashlib
|
||||
import getpass
|
||||
try:
|
||||
import clint
|
||||
except ImportError:
|
||||
clint = None
|
||||
|
||||
class Journal:
|
||||
def __init__(self, config, **kwargs):
|
||||
config.update(kwargs)
|
||||
self.config = config
|
||||
|
||||
# Set up date parser
|
||||
consts = pdc.Constants()
|
||||
consts.DOWParseStyle = -1 # "Monday" will be either today or the last Monday
|
||||
self.dateparse = pdt.Calendar(consts)
|
||||
self.key = None # used to decrypt and encrypt the journal
|
||||
|
||||
journal_txt = self.open()
|
||||
self.entries = self.parse(journal_txt)
|
||||
self.sort()
|
||||
|
||||
def _colorize(self, string, color='red'):
|
||||
if clint:
|
||||
return str(clint.textui.colored.ColoredString(color.upper(), string))
|
||||
else:
|
||||
return string
|
||||
|
||||
def _decrypt(self, cipher):
|
||||
"""Decrypts a cipher string using self.key as the key and the first 16 byte of the cipher as the IV"""
|
||||
if not cipher:
|
||||
return ""
|
||||
crypto = AES.new(self.key, AES.MODE_CBC, cipher[:16])
|
||||
try:
|
||||
plain = crypto.decrypt(cipher[16:])
|
||||
except ValueError:
|
||||
print("ERROR: Your journal file seems to be corrupted. You do have a backup, don't you?")
|
||||
sys.exit(-1)
|
||||
if plain[-1] != " ": # Journals are always padded
|
||||
return None
|
||||
else:
|
||||
return plain
|
||||
|
||||
def _encrypt(self, plain):
|
||||
"""Encrypt a plaintext string using self.key as the key"""
|
||||
atfork() # A seed for PyCrypto
|
||||
iv = ''.join(chr(random.randint(0, 0xFF)) for i in range(16))
|
||||
crypto = AES.new(self.key, AES.MODE_CBC, iv)
|
||||
if len(plain) % 16 != 0:
|
||||
plain += " " * (16 - len(plain) % 16)
|
||||
else: # Always pad so we can detect properly decrypted files :)
|
||||
plain += " " * 16
|
||||
return iv + crypto.encrypt(plain)
|
||||
|
||||
def make_key(self, prompt="Password: "):
|
||||
"""Creates an encryption key from the default password or prompts for a new password."""
|
||||
password = self.config['password'] or getpass.getpass(prompt)
|
||||
self.key = hashlib.sha256(password).digest()
|
||||
|
||||
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']
|
||||
journal = None
|
||||
with open(filename) as f:
|
||||
journal = f.read()
|
||||
if self.config['encrypt']:
|
||||
decrypted = None
|
||||
attempts = 0
|
||||
while decrypted is None:
|
||||
self.make_key()
|
||||
decrypted = self._decrypt(journal)
|
||||
if decrypted is None:
|
||||
attempts += 1
|
||||
self.config['password'] = None # This password doesn't work.
|
||||
if attempts < 3:
|
||||
print("Wrong password, try again.")
|
||||
else:
|
||||
print("Extremely wrong password.")
|
||||
sys.exit(-1)
|
||||
journal = decrypted
|
||||
return journal
|
||||
|
||||
def parse(self, journal):
|
||||
"""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
|
||||
# long the date will be by constructing one
|
||||
date_length = len(datetime.today().strftime(self.config['timeformat']))
|
||||
|
||||
# Initialise our current entry
|
||||
entries = []
|
||||
current_entry = None
|
||||
|
||||
for line in journal.splitlines():
|
||||
try:
|
||||
# try to parse line as date => new entry begins
|
||||
new_date = datetime.strptime(line[:date_length], self.config['timeformat'])
|
||||
|
||||
# parsing successfull => save old entry and create new one
|
||||
if new_date and current_entry:
|
||||
entries.append(current_entry)
|
||||
current_entry = Entry(self, date=new_date, title=line[date_length+1:])
|
||||
except ValueError:
|
||||
# Happens when we can't parse the start of the line as an date.
|
||||
# In this case, just append line to our body.
|
||||
current_entry.body += line + "\n"
|
||||
|
||||
# Append last entry
|
||||
if current_entry:
|
||||
entries.append(current_entry)
|
||||
for entry in entries:
|
||||
entry.parse_tags()
|
||||
return entries
|
||||
|
||||
def __str__(self):
|
||||
"""Prettyprints the journal's entries"""
|
||||
sep = "-"*60+"\n"
|
||||
pp = sep.join([str(e) for e in self.entries])
|
||||
if self.config['highlight']: # highlight tags
|
||||
if hasattr(self, 'search_tags'):
|
||||
for tag in self.search_tags:
|
||||
pp = pp.replace(tag, self._colorize(tag))
|
||||
else:
|
||||
pp = re.sub(r"([%s]\w+)" % self.config['tagsymbols'],
|
||||
lambda match: self._colorize(match.group(0), 'cyan'),
|
||||
pp)
|
||||
return pp
|
||||
|
||||
def to_json(self):
|
||||
"""Returns a JSON representation of the Journal."""
|
||||
return json.dumps([e.to_dict() for e in self.entries], indent=2)
|
||||
|
||||
def to_md(self):
|
||||
"""Returns a markdown representation of the Journal"""
|
||||
out = []
|
||||
year, month = -1, -1
|
||||
for e in self.entries:
|
||||
if not e.date.year == year:
|
||||
year = e.date.year
|
||||
out.append(str(year))
|
||||
out.append("=" * len(str(year)) + "\n")
|
||||
if not e.date.month == month:
|
||||
month = e.date.month
|
||||
out.append(e.date.strftime("%B"))
|
||||
out.append('-' * len(e.date.strftime("%B")) + "\n")
|
||||
out.append(e.to_md())
|
||||
return "\n".join(out)
|
||||
|
||||
def __repr__(self):
|
||||
return "<Journal with %d entries>" % len(self.entries)
|
||||
|
||||
def write(self, filename = None):
|
||||
"""Dumps the journal into the config file, overwriting it"""
|
||||
filename = filename or self.config['journal']
|
||||
journal = "\n".join([str(e) for e in self.entries])
|
||||
if self.config['encrypt']:
|
||||
journal = self._encrypt(journal)
|
||||
with open(filename, 'w') as journal_file:
|
||||
journal_file.write(journal)
|
||||
|
||||
def sort(self):
|
||||
"""Sorts the Journal's entries by date"""
|
||||
self.entries = sorted(self.entries, key=lambda entry: entry.date)
|
||||
|
||||
def limit(self, n=None):
|
||||
"""Removes all but the last n entries"""
|
||||
if n:
|
||||
self.entries = self.entries[-n:]
|
||||
|
||||
def filter(self, tags=[], start_date=None, end_date=None, strict=False, short=False):
|
||||
"""Removes all entries from the journal that don't match the filter.
|
||||
|
||||
tags is a list of tags, each being a string that starts with one of the
|
||||
tag symbols defined in the config, e.g. ["@John", "#WorldDomination"].
|
||||
|
||||
start_date and end_date define a timespan by which to filter.
|
||||
|
||||
If strict is True, all tags must be present in an entry. If false, the
|
||||
entry is kept if any tag is present."""
|
||||
self.search_tags = set([tag.lower() for tag in tags])
|
||||
end_date = self.parse_date(end_date)
|
||||
start_date = self.parse_date(start_date)
|
||||
# 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
|
||||
result = [
|
||||
entry for entry in self.entries
|
||||
if (not tags or tagged(entry.tags))
|
||||
and (not start_date or entry.date > start_date)
|
||||
and (not end_date or entry.date < end_date)
|
||||
]
|
||||
if short:
|
||||
if tags:
|
||||
for e in self.entries:
|
||||
res = []
|
||||
for tag in tags:
|
||||
matches = [m for m in re.finditer(tag, e.body)]
|
||||
for m in matches:
|
||||
date = e.date.strftime(self.config['timeformat'])
|
||||
excerpt = e.body[m.start():min(len(e.body), m.end()+60)]
|
||||
res.append('%s %s ..' % (date, excerpt))
|
||||
e.body = "\n".join(res)
|
||||
else:
|
||||
for e in self.entries:
|
||||
e.body = ''
|
||||
self.entries = result
|
||||
|
||||
def parse_date(self, date):
|
||||
"""Parses a string containing a fuzzy date and returns a datetime.datetime object"""
|
||||
if not date:
|
||||
return None
|
||||
elif type(date) is datetime:
|
||||
return date
|
||||
|
||||
date, flag = self.dateparse.parse(date)
|
||||
|
||||
if not flag: # Oops, unparsable.
|
||||
return None
|
||||
|
||||
if flag is 1: # Date found, but no time. Use the default time.
|
||||
date = datetime(*date[:3], hour=self.config['default_hour'], minute=self.config['default_minute'])
|
||||
else:
|
||||
date = datetime(*date[:6])
|
||||
|
||||
# Ugly heuristic: if the date is more than 4 weeks in the future, we got the year wrong.
|
||||
# Rather then this, we would like to see parsedatetime patched so we can tell it to prefer
|
||||
# past dates
|
||||
dt = datetime.now() - date
|
||||
if dt.days < -28:
|
||||
date = date.replace(date.year - 1)
|
||||
|
||||
return date
|
||||
|
||||
def new_entry(self, raw, date=None):
|
||||
"""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."""
|
||||
|
||||
# Split raw text into title and body
|
||||
title_end = len(raw)
|
||||
for separator in ".?!":
|
||||
sep_pos = raw.find(separator)
|
||||
if 1 < sep_pos < title_end:
|
||||
title_end = sep_pos
|
||||
title = raw[:title_end+1]
|
||||
body = raw[title_end+1:].strip()
|
||||
|
||||
if not date:
|
||||
if title.find(":") > 0:
|
||||
date = self.parse_date(title[:title.find(":")])
|
||||
if date: # Parsed successfully, strip that from the raw text
|
||||
title = title[title.find(":")+1:].strip()
|
||||
if not date: # Still nothing? Meh, just live in the moment.
|
||||
date = self.parse_date("now")
|
||||
|
||||
self.entries.append(Entry(self, date, title, body))
|
||||
self.sort()
|
||||
|
||||
def save_config(self, config_path):
|
||||
with open(config_path, 'w') as f:
|
||||
json.dump(self.config, f, indent=2)
|
|
@ -1,8 +1,5 @@
|
|||
# Copyright © 2012-2023 jrnl contributors
|
||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
try:
|
||||
from jrnl.__version__ import __version__
|
||||
except ImportError:
|
||||
__version__ = "source"
|
||||
__title__ = "jrnl"
|
||||
from Journal import Journal
|
||||
from jrnl import cli
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
# Copyright © 2012-2023 jrnl contributors
|
||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
import sys
|
||||
|
||||
from jrnl.main import run
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(run())
|
|
@ -1 +0,0 @@
|
|||
__version__ = "v4.2.1"
|
456
jrnl/args.py
|
@ -1,456 +0,0 @@
|
|||
# Copyright © 2012-2023 jrnl contributors
|
||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
import argparse
|
||||
import re
|
||||
import textwrap
|
||||
|
||||
from jrnl.commands import postconfig_decrypt
|
||||
from jrnl.commands import postconfig_encrypt
|
||||
from jrnl.commands import postconfig_import
|
||||
from jrnl.commands import postconfig_list
|
||||
from jrnl.commands import preconfig_diagnostic
|
||||
from jrnl.commands import preconfig_version
|
||||
from jrnl.output import deprecated_cmd
|
||||
from jrnl.plugins import EXPORT_FORMATS
|
||||
from jrnl.plugins import IMPORT_FORMATS
|
||||
from jrnl.plugins import util
|
||||
|
||||
|
||||
class WrappingFormatter(argparse.RawTextHelpFormatter):
|
||||
"""Used in help screen"""
|
||||
|
||||
def _split_lines(self, text: str, width: int) -> list[str]:
|
||||
text = text.split("\n\n")
|
||||
text = map(lambda t: self._whitespace_matcher.sub(" ", t).strip(), text)
|
||||
text = map(lambda t: textwrap.wrap(t, width=56), text)
|
||||
text = [item for sublist in text for item in sublist]
|
||||
return text
|
||||
|
||||
|
||||
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.
|
||||
Everything else goes into "text" for later parsing.
|
||||
"""
|
||||
parser = argparse.ArgumentParser(
|
||||
formatter_class=WrappingFormatter,
|
||||
add_help=False,
|
||||
description="Collect your thoughts and notes without leaving the command line",
|
||||
epilog=textwrap.dedent(
|
||||
"""
|
||||
We gratefully thank all contributors!
|
||||
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 :)""" # noqa: E501
|
||||
),
|
||||
)
|
||||
|
||||
optional = parser.add_argument_group("Optional Arguments")
|
||||
optional.add_argument(
|
||||
"--debug",
|
||||
dest="debug",
|
||||
action="store_true",
|
||||
help="Print information useful for troubleshooting",
|
||||
)
|
||||
|
||||
standalone = parser.add_argument_group(
|
||||
"Standalone Commands",
|
||||
"These commands will exit after they complete. You may only run one at a time.",
|
||||
)
|
||||
standalone.add_argument("--help", action="help", help="Show this help message")
|
||||
standalone.add_argument("-h", action="help", help=argparse.SUPPRESS)
|
||||
standalone.add_argument(
|
||||
"--version",
|
||||
action="store_const",
|
||||
const=preconfig_version,
|
||||
dest="preconfig_cmd",
|
||||
help="Print version information",
|
||||
)
|
||||
standalone.add_argument(
|
||||
"-v",
|
||||
action="store_const",
|
||||
const=preconfig_version,
|
||||
dest="preconfig_cmd",
|
||||
help=argparse.SUPPRESS,
|
||||
)
|
||||
standalone.add_argument(
|
||||
"--diagnostic",
|
||||
action="store_const",
|
||||
const=preconfig_diagnostic,
|
||||
dest="preconfig_cmd",
|
||||
help=argparse.SUPPRESS,
|
||||
)
|
||||
standalone.add_argument(
|
||||
"--list",
|
||||
action="store_const",
|
||||
const=postconfig_list,
|
||||
dest="postconfig_cmd",
|
||||
help="""
|
||||
List all configured journals.
|
||||
|
||||
Optional parameters:
|
||||
|
||||
--format [json or yaml]
|
||||
""",
|
||||
)
|
||||
standalone.add_argument(
|
||||
"--ls",
|
||||
action="store_const",
|
||||
const=postconfig_list,
|
||||
dest="postconfig_cmd",
|
||||
help=argparse.SUPPRESS,
|
||||
)
|
||||
standalone.add_argument(
|
||||
"-ls",
|
||||
action="store_const",
|
||||
const=lambda **kwargs: deprecated_cmd(
|
||||
"-ls", "--list or --ls", callback=postconfig_list, **kwargs
|
||||
),
|
||||
dest="postconfig_cmd",
|
||||
help=argparse.SUPPRESS,
|
||||
)
|
||||
standalone.add_argument(
|
||||
"--encrypt",
|
||||
help="Encrypt selected journal with a password",
|
||||
action="store_const",
|
||||
metavar="TYPE",
|
||||
const=postconfig_encrypt,
|
||||
dest="postconfig_cmd",
|
||||
)
|
||||
standalone.add_argument(
|
||||
"--decrypt",
|
||||
help="Decrypt selected journal and store it in plain text",
|
||||
action="store_const",
|
||||
metavar="TYPE",
|
||||
const=postconfig_decrypt,
|
||||
dest="postconfig_cmd",
|
||||
)
|
||||
standalone.add_argument(
|
||||
"--import",
|
||||
action="store_const",
|
||||
metavar="TYPE",
|
||||
const=postconfig_import,
|
||||
dest="postconfig_cmd",
|
||||
help=f"""
|
||||
Import entries from another journal.
|
||||
|
||||
Optional parameters:
|
||||
|
||||
--file FILENAME (default: uses stdin)
|
||||
|
||||
--format [{util.oxford_list(IMPORT_FORMATS)}] (default: jrnl)
|
||||
""",
|
||||
)
|
||||
standalone.add_argument(
|
||||
"--file",
|
||||
metavar="FILENAME",
|
||||
dest="filename",
|
||||
help=argparse.SUPPRESS,
|
||||
default=None,
|
||||
)
|
||||
standalone.add_argument("-i", dest="filename", help=argparse.SUPPRESS)
|
||||
|
||||
compose_msg = """
|
||||
To add a new entry into your journal, simply write it on the command line:
|
||||
|
||||
jrnl yesterday: I was walking and I found this big log.
|
||||
|
||||
The date and the following colon ("yesterday:") are optional. If you leave
|
||||
them out, "now" will be used:
|
||||
|
||||
jrnl Then I rolled the log over.
|
||||
|
||||
Also, you can mark extra special entries ("star" them) with an asterisk:
|
||||
|
||||
jrnl *And underneath was a tiny little stick.
|
||||
|
||||
Please note that asterisks might be a special character in your shell, so you
|
||||
might have to escape them. When in doubt about escaping, put quotes around
|
||||
your entire entry:
|
||||
|
||||
jrnl "saturday at 2am: *Then I was like 'That log had a child!'" """
|
||||
|
||||
composing = parser.add_argument_group(
|
||||
"Writing", textwrap.dedent(compose_msg).strip()
|
||||
)
|
||||
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 = (
|
||||
"To find entries from your journal, use any combination of the below filters."
|
||||
)
|
||||
reading = parser.add_argument_group("Searching", textwrap.dedent(read_msg))
|
||||
reading.add_argument(
|
||||
"-on", dest="on_date", metavar="DATE", help="Show entries on this date"
|
||||
)
|
||||
reading.add_argument(
|
||||
"-today-in-history",
|
||||
dest="today_in_history",
|
||||
action="store_true",
|
||||
help="Show entries of today over the years",
|
||||
)
|
||||
reading.add_argument(
|
||||
"-month",
|
||||
dest="month",
|
||||
metavar="DATE",
|
||||
help="Show entries on this month of any year",
|
||||
)
|
||||
reading.add_argument(
|
||||
"-day",
|
||||
dest="day",
|
||||
metavar="DATE",
|
||||
help="Show entries on this day of any month",
|
||||
)
|
||||
reading.add_argument(
|
||||
"-year",
|
||||
dest="year",
|
||||
metavar="DATE",
|
||||
help="Show entries of a specific year",
|
||||
)
|
||||
reading.add_argument(
|
||||
"-from",
|
||||
dest="start_date",
|
||||
metavar="DATE",
|
||||
help="Show entries after, or on, this date",
|
||||
)
|
||||
reading.add_argument(
|
||||
"-to",
|
||||
dest="end_date",
|
||||
metavar="DATE",
|
||||
help="Show entries before, or on, this date (alias: -until)",
|
||||
)
|
||||
reading.add_argument("-until", dest="end_date", help=argparse.SUPPRESS)
|
||||
reading.add_argument(
|
||||
"-contains",
|
||||
dest="contains",
|
||||
action="append",
|
||||
metavar="TEXT",
|
||||
help="Show entries containing specific text (put quotes around text with "
|
||||
"spaces)",
|
||||
)
|
||||
reading.add_argument(
|
||||
"-and",
|
||||
dest="strict",
|
||||
action="store_true",
|
||||
help='Show only entries that match all conditions, like saying "x AND y" '
|
||||
"(default: OR)",
|
||||
)
|
||||
reading.add_argument(
|
||||
"-starred",
|
||||
dest="starred",
|
||||
action="store_true",
|
||||
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(
|
||||
"-n",
|
||||
dest="limit",
|
||||
default=None,
|
||||
metavar="NUMBER",
|
||||
help="Show a maximum of NUMBER entries (note: '-n 3' and '-3' have the same "
|
||||
"effect)",
|
||||
nargs="?",
|
||||
type=int,
|
||||
)
|
||||
reading.add_argument(
|
||||
"-not",
|
||||
dest="excluded",
|
||||
nargs="?",
|
||||
default=[],
|
||||
metavar="TAG/FLAG",
|
||||
action=IgnoreNoneAppendAction,
|
||||
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 = (
|
||||
" " # 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(
|
||||
"Searching Options", textwrap.dedent(search_options_msg)
|
||||
)
|
||||
exporting.add_argument(
|
||||
"--edit",
|
||||
dest="edit",
|
||||
help="Opens the selected entries in your configured editor",
|
||||
action="store_true",
|
||||
)
|
||||
exporting.add_argument(
|
||||
"--delete",
|
||||
dest="delete",
|
||||
action="store_true",
|
||||
help="Interactively deletes selected entries",
|
||||
)
|
||||
exporting.add_argument(
|
||||
"--change-time",
|
||||
dest="change_time",
|
||||
nargs="?",
|
||||
metavar="DATE",
|
||||
const="now",
|
||||
help="Change timestamp for selected entries (default: now)",
|
||||
)
|
||||
exporting.add_argument(
|
||||
"--format",
|
||||
metavar="TYPE",
|
||||
dest="export",
|
||||
choices=EXPORT_FORMATS,
|
||||
help=f"""
|
||||
Display selected entries in an alternate format.
|
||||
|
||||
TYPE can be: {util.oxford_list(EXPORT_FORMATS)}.
|
||||
|
||||
Optional parameters:
|
||||
|
||||
--file FILENAME Write output to file instead of stdout
|
||||
""",
|
||||
default=False,
|
||||
)
|
||||
exporting.add_argument(
|
||||
"--export",
|
||||
metavar="TYPE",
|
||||
dest="export",
|
||||
choices=EXPORT_FORMATS,
|
||||
help=argparse.SUPPRESS,
|
||||
)
|
||||
exporting.add_argument(
|
||||
"--tags",
|
||||
dest="tags",
|
||||
action="store_true",
|
||||
help="Alias for '--format tags'. Returns a list of all tags and number of "
|
||||
"occurrences",
|
||||
)
|
||||
exporting.add_argument(
|
||||
"--short",
|
||||
dest="short",
|
||||
action="store_true",
|
||||
help="Show only titles or line containing the search tags",
|
||||
)
|
||||
exporting.add_argument(
|
||||
"-s",
|
||||
dest="short",
|
||||
action="store_true",
|
||||
help=argparse.SUPPRESS,
|
||||
)
|
||||
exporting.add_argument(
|
||||
"-o",
|
||||
dest="filename",
|
||||
help=argparse.SUPPRESS,
|
||||
)
|
||||
|
||||
config_overrides = parser.add_argument_group(
|
||||
"Config file override",
|
||||
textwrap.dedent("Apply a one-off override of the config file option"),
|
||||
)
|
||||
config_overrides.add_argument(
|
||||
"--config-override",
|
||||
dest="config_override",
|
||||
action="append",
|
||||
type=str,
|
||||
nargs=2,
|
||||
default=[],
|
||||
metavar="CONFIG_KV_PAIR",
|
||||
help="""
|
||||
Override configured key-value pair with CONFIG_KV_PAIR for this command invocation only.
|
||||
|
||||
Examples: \n
|
||||
\t - Use a different editor for this jrnl entry, call: \n
|
||||
\t jrnl --config-override editor "nano" \n
|
||||
\t - Override color selections\n
|
||||
\t jrnl --config-override colors.body blue --config-override colors.title green
|
||||
""", # noqa: E501
|
||||
)
|
||||
config_overrides.add_argument(
|
||||
"--co",
|
||||
dest="config_override",
|
||||
action="append",
|
||||
type=str,
|
||||
nargs=2,
|
||||
default=[],
|
||||
help=argparse.SUPPRESS,
|
||||
)
|
||||
|
||||
alternate_config = parser.add_argument_group(
|
||||
"Specifies alternate config to be used",
|
||||
textwrap.dedent("Applies alternate config for current session"),
|
||||
)
|
||||
|
||||
alternate_config.add_argument(
|
||||
"--config-file",
|
||||
dest="config_file_path",
|
||||
type=str,
|
||||
default="",
|
||||
help="""
|
||||
Overrides default (created when first installed) config file for this command only.
|
||||
|
||||
Examples: \n
|
||||
\t - Use a work config file for this jrnl entry, call: \n
|
||||
\t jrnl --config-file /home/user1/work_config.yaml
|
||||
\t - Use a personal config file stored on a thumb drive: \n
|
||||
\t jrnl --config-file /media/user1/my-thumb-drive/personal_config.yaml
|
||||
""", # noqa: E501
|
||||
)
|
||||
|
||||
alternate_config.add_argument(
|
||||
"--cf", dest="config_file_path", type=str, default="", help=argparse.SUPPRESS
|
||||
)
|
||||
|
||||
# Handle '-123' as a shortcut for '-n 123'
|
||||
num = re.compile(r"^-(\d+)$")
|
||||
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 parsed_args
|
|
@ -1,83 +0,0 @@
|
|||
# Copyright © 2012-2023 jrnl contributors
|
||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
import re
|
||||
from string import punctuation
|
||||
from string import whitespace
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import colorama
|
||||
|
||||
from jrnl.os_compat import on_windows
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from jrnl.journals import Entry
|
||||
|
||||
if on_windows():
|
||||
colorama.init()
|
||||
|
||||
|
||||
def colorize(string: str, color: str, bold: bool = False) -> str:
|
||||
"""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,
|
||||
it returns the string without any modification."""
|
||||
color_escape = getattr(colorama.Fore, color.upper(), None)
|
||||
if not color_escape:
|
||||
return string
|
||||
elif not bold:
|
||||
return color_escape + string + colorama.Fore.RESET
|
||||
else:
|
||||
return colorama.Style.BRIGHT + color_escape + string + colorama.Style.RESET_ALL
|
||||
|
||||
|
||||
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
|
||||
color.tags, while colorizing the rest of the text based on `color`.
|
||||
:param entry: Entry object, for access to journal config
|
||||
:param text: Text to be colorized
|
||||
:param color: Color for non-tag text, passed to colorize()
|
||||
:param is_title: Boolean flag indicating if the text is a title or not
|
||||
:return: Colorized str
|
||||
"""
|
||||
|
||||
def colorized_text_generator(fragments):
|
||||
"""Efficiently generate colorized tags / text from text fragments.
|
||||
Taken from @shobrook. Thanks, buddy :)
|
||||
:param fragments: List of strings representing parts of entry (tag or word).
|
||||
:rtype: List of tuples
|
||||
:returns [(colorized_str, original_str)]"""
|
||||
for part in fragments:
|
||||
if part and part[0] not in config["tagsymbols"]:
|
||||
yield colorize(part, color, bold=is_title), part
|
||||
elif part:
|
||||
yield colorize(part, config["colors"]["tags"], bold=True), part
|
||||
|
||||
config = entry.journal.config
|
||||
if config["highlight"]: # highlight tags
|
||||
text_fragments = re.split(entry.tag_regex(config["tagsymbols"]), text)
|
||||
|
||||
# Colorizing tags inside of other blocks of text
|
||||
final_text = ""
|
||||
previous_piece = ""
|
||||
for colorized_piece, piece in colorized_text_generator(text_fragments):
|
||||
# If this piece is entirely punctuation or whitespace or the start
|
||||
# of a line or the previous piece was a tag or this piece is a tag,
|
||||
# then add it to the final text without a leading space.
|
||||
if (
|
||||
all(char in punctuation + whitespace for char in piece)
|
||||
or previous_piece.endswith("\n")
|
||||
or (previous_piece and previous_piece[0] in config["tagsymbols"])
|
||||
or piece[0] in config["tagsymbols"]
|
||||
):
|
||||
final_text += colorized_piece
|
||||
else:
|
||||
# Otherwise add a leading space and then append the piece.
|
||||
final_text += " " + colorized_piece
|
||||
|
||||
previous_piece = piece
|
||||
return final_text.lstrip()
|
||||
else:
|
||||
return text
|
182
jrnl/commands.py
|
@ -1,182 +0,0 @@
|
|||
# Copyright © 2012-2023 jrnl contributors
|
||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
"""
|
||||
Functions in this file are standalone commands. All standalone commands are split into
|
||||
two categories depending on whether they require the config to be loaded to be able to
|
||||
run.
|
||||
|
||||
1. "preconfig" commands don't require the config at all, and can be run before the
|
||||
config has been loaded.
|
||||
2. "postconfig" commands require to config to have already been loaded, parsed, and
|
||||
scoped before they can be run.
|
||||
|
||||
Also, please note that all (non-builtin) imports should be scoped to each function to
|
||||
avoid any possible overhead for these standalone commands.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
import platform
|
||||
import sys
|
||||
|
||||
from jrnl.config import cmd_requires_valid_journal_name
|
||||
from jrnl.exception import JrnlException
|
||||
from jrnl.messages import Message
|
||||
from jrnl.messages import MsgStyle
|
||||
from jrnl.messages import MsgText
|
||||
from jrnl.output import print_msg
|
||||
|
||||
|
||||
def preconfig_diagnostic(_) -> None:
|
||||
from jrnl import __title__
|
||||
from jrnl import __version__
|
||||
|
||||
print(
|
||||
f"{__title__}: {__version__}\n"
|
||||
f"Python: {sys.version}\n"
|
||||
f"OS: {platform.system()} {platform.release()}"
|
||||
)
|
||||
|
||||
|
||||
def preconfig_version(_) -> None:
|
||||
import textwrap
|
||||
|
||||
from jrnl import __title__
|
||||
from jrnl import __version__
|
||||
|
||||
output = f"""
|
||||
{__title__} {__version__}
|
||||
|
||||
Copyright © 2012-2023 jrnl contributors
|
||||
|
||||
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
|
||||
"""
|
||||
|
||||
output = textwrap.dedent(output).strip()
|
||||
|
||||
print(output)
|
||||
|
||||
|
||||
def postconfig_list(args: argparse.Namespace, config: dict, **_) -> int:
|
||||
from jrnl.output import list_journals
|
||||
|
||||
print(list_journals(config, args.export))
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
@cmd_requires_valid_journal_name
|
||||
def postconfig_import(args: argparse.Namespace, config: dict, **_) -> int:
|
||||
from jrnl.journals import open_journal
|
||||
from jrnl.plugins import get_importer
|
||||
|
||||
# Requires opening the journal
|
||||
journal = open_journal(args.journal_name, config)
|
||||
|
||||
format = args.export if args.export else "jrnl"
|
||||
|
||||
if (importer := get_importer(format)) is None:
|
||||
raise JrnlException(
|
||||
Message(
|
||||
MsgText.ImporterNotFound,
|
||||
MsgStyle.ERROR,
|
||||
{"format": format},
|
||||
)
|
||||
)
|
||||
|
||||
importer.import_(journal, args.filename)
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
@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
|
||||
"""
|
||||
from jrnl.config import update_config
|
||||
from jrnl.install import save_config
|
||||
from jrnl.journals import open_journal
|
||||
|
||||
# Open the journal
|
||||
journal = open_journal(args.journal_name, config)
|
||||
|
||||
if hasattr(journal, "can_be_encrypted") and not journal.can_be_encrypted:
|
||||
raise JrnlException(
|
||||
Message(
|
||||
MsgText.CannotEncryptJournalType,
|
||||
MsgStyle.ERROR,
|
||||
{
|
||||
"journal_name": args.journal_name,
|
||||
"journal_type": journal.__class__.__name__,
|
||||
},
|
||||
)
|
||||
)
|
||||
|
||||
# If journal is encrypted, create new password
|
||||
logging.debug("Clearing encryption method...")
|
||||
|
||||
if journal.config["encrypt"] is True:
|
||||
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(
|
||||
Message(
|
||||
MsgText.JournalEncryptedTo,
|
||||
MsgStyle.NORMAL,
|
||||
{"path": args.filename or journal.config["journal"]},
|
||||
)
|
||||
)
|
||||
|
||||
# Update the config, if we encrypted in place
|
||||
if not args.filename:
|
||||
update_config(
|
||||
original_config, {"encrypt": True}, args.journal_name, force_local=True
|
||||
)
|
||||
save_config(original_config)
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
@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.install import save_config
|
||||
from jrnl.journals import open_journal
|
||||
|
||||
journal = open_journal(args.journal_name, config)
|
||||
|
||||
logging.debug("Clearing encryption method...")
|
||||
journal.config["encrypt"] = False
|
||||
journal.encryption_method = None
|
||||
|
||||
journal.write(args.filename)
|
||||
print_msg(
|
||||
Message(
|
||||
MsgText.JournalDecryptedTo,
|
||||
MsgStyle.NORMAL,
|
||||
{"path": args.filename or journal.config["journal"]},
|
||||
)
|
||||
)
|
||||
|
||||
# Update the config, if we decrypted in place
|
||||
if not args.filename:
|
||||
update_config(
|
||||
original_config, {"encrypt": False}, args.journal_name, force_local=True
|
||||
)
|
||||
save_config(original_config)
|
||||
|
||||
return 0
|
229
jrnl/config.py
|
@ -1,229 +0,0 @@
|
|||
# Copyright © 2012-2023 jrnl contributors
|
||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
import os
|
||||
from typing import Any
|
||||
from typing import Callable
|
||||
|
||||
import colorama
|
||||
from rich.pretty import pretty_repr
|
||||
from ruamel.yaml import YAML
|
||||
from ruamel.yaml import constructor
|
||||
|
||||
from jrnl import __version__
|
||||
from jrnl.exception import JrnlException
|
||||
from jrnl.messages import Message
|
||||
from jrnl.messages import MsgStyle
|
||||
from jrnl.messages import MsgText
|
||||
from jrnl.output import list_journals
|
||||
from jrnl.output import print_msg
|
||||
from jrnl.path import get_config_path
|
||||
from jrnl.path import get_default_journal_path
|
||||
|
||||
# Constants
|
||||
DEFAULT_JOURNAL_KEY = "default"
|
||||
|
||||
YAML_SEPARATOR = ": "
|
||||
YAML_FILE_ENCODING = "utf-8"
|
||||
|
||||
|
||||
def make_yaml_valid_dict(input: list) -> dict:
|
||||
"""
|
||||
|
||||
Convert a two-element list of configuration key-value pair into a flat dict.
|
||||
|
||||
The dict is created through the yaml loader, with the assumption that
|
||||
"input[0]: input[1]" is valid yaml.
|
||||
|
||||
:param input: list of configuration keys in dot-notation and their respective values
|
||||
:type input: list
|
||||
:return: A single level dict of the configuration keys in dot-notation and their
|
||||
respective desired values
|
||||
:rtype: dict
|
||||
"""
|
||||
|
||||
assert len(input) == 2
|
||||
|
||||
# yaml compatible strings are of the form Key:Value
|
||||
yamlstr = YAML_SEPARATOR.join(input)
|
||||
|
||||
runtime_modifications = YAML(typ="safe").load(yamlstr)
|
||||
|
||||
return runtime_modifications
|
||||
|
||||
|
||||
def save_config(config: dict, alt_config_path: str | None = None) -> None:
|
||||
"""Supply alt_config_path if using an alternate config through --config-file."""
|
||||
config["version"] = __version__
|
||||
|
||||
yaml = YAML(typ="safe")
|
||||
yaml.default_flow_style = False # prevents collapsing of tree structure
|
||||
|
||||
with open(
|
||||
alt_config_path if alt_config_path else get_config_path(),
|
||||
"w",
|
||||
encoding=YAML_FILE_ENCODING,
|
||||
) as f:
|
||||
yaml.dump(config, f)
|
||||
|
||||
|
||||
def get_default_config() -> dict[str, Any]:
|
||||
return {
|
||||
"version": __version__,
|
||||
"journals": {"default": {"journal": get_default_journal_path()}},
|
||||
"editor": os.getenv("VISUAL") or os.getenv("EDITOR") or "",
|
||||
"encrypt": False,
|
||||
"template": False,
|
||||
"default_hour": 9,
|
||||
"default_minute": 0,
|
||||
"timeformat": "%F %r",
|
||||
"tagsymbols": "#@",
|
||||
"highlight": True,
|
||||
"linewrap": 79,
|
||||
"indent_character": "|",
|
||||
"colors": {
|
||||
"body": "none",
|
||||
"date": "none",
|
||||
"tags": "none",
|
||||
"title": "none",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def get_default_colors() -> dict[str, Any]:
|
||||
return {
|
||||
"body": "none",
|
||||
"date": "black",
|
||||
"tags": "yellow",
|
||||
"title": "cyan",
|
||||
}
|
||||
|
||||
|
||||
def scope_config(config: dict, journal_name: str) -> dict:
|
||||
if journal_name not in config["journals"]:
|
||||
return config
|
||||
config = config.copy()
|
||||
journal_conf = config["journals"].get(journal_name)
|
||||
if isinstance(journal_conf, dict):
|
||||
# We can override the default config on a by-journal basis
|
||||
logging.debug(
|
||||
"Updating configuration with specific journal overrides:\n%s",
|
||||
pretty_repr(journal_conf),
|
||||
)
|
||||
config.update(journal_conf)
|
||||
else:
|
||||
# But also just give them a string to point to the journal file
|
||||
config["journal"] = journal_conf
|
||||
|
||||
logging.debug("Scoped config:\n%s", pretty_repr(config))
|
||||
return config
|
||||
|
||||
|
||||
def verify_config_colors(config: dict) -> bool:
|
||||
"""
|
||||
Ensures the keys set for colors are valid colorama.Fore attributes, or "None"
|
||||
:return: True if all keys are set correctly, False otherwise
|
||||
"""
|
||||
all_valid_colors = True
|
||||
for key, color in config["colors"].items():
|
||||
upper_color = color.upper()
|
||||
if upper_color == "NONE":
|
||||
continue
|
||||
if not getattr(colorama.Fore, upper_color, None):
|
||||
print_msg(
|
||||
Message(
|
||||
MsgText.InvalidColor,
|
||||
MsgStyle.NORMAL,
|
||||
{
|
||||
"key": key,
|
||||
"color": color,
|
||||
},
|
||||
)
|
||||
)
|
||||
all_valid_colors = False
|
||||
return all_valid_colors
|
||||
|
||||
|
||||
def load_config(config_path: str) -> dict:
|
||||
"""Tries to load a config file from YAML."""
|
||||
try:
|
||||
with open(config_path, encoding=YAML_FILE_ENCODING) as f:
|
||||
yaml = YAML(typ="safe")
|
||||
yaml.allow_duplicate_keys = False
|
||||
return yaml.load(f)
|
||||
except constructor.DuplicateKeyError as e:
|
||||
print_msg(
|
||||
Message(
|
||||
MsgText.ConfigDoubleKeys,
|
||||
MsgStyle.WARNING,
|
||||
{
|
||||
"error_message": e,
|
||||
},
|
||||
)
|
||||
)
|
||||
with open(config_path, encoding=YAML_FILE_ENCODING) as f:
|
||||
yaml = YAML(typ="safe")
|
||||
yaml.allow_duplicate_keys = True
|
||||
return yaml.load(f)
|
||||
|
||||
|
||||
def is_config_json(config_path: str) -> bool:
|
||||
with open(config_path, "r", encoding="utf-8") as f:
|
||||
config_file = f.read()
|
||||
return config_file.strip().startswith("{")
|
||||
|
||||
|
||||
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
|
||||
or config['journals'][scope] is just a string pointing to a journal file,
|
||||
or within the scope"""
|
||||
if scope and isinstance(config["journals"][scope], dict):
|
||||
config["journals"][scope].update(new_config)
|
||||
elif scope and force_local: # Convert to dict
|
||||
config["journals"][scope] = {"journal": config["journals"][scope]}
|
||||
config["journals"][scope].update(new_config)
|
||||
else:
|
||||
config.update(new_config)
|
||||
|
||||
|
||||
def get_journal_name(args: argparse.Namespace, config: dict) -> argparse.Namespace:
|
||||
args.journal_name = DEFAULT_JOURNAL_KEY
|
||||
|
||||
# The first arg might be a journal name
|
||||
if args.text:
|
||||
potential_journal_name = args.text[0]
|
||||
if potential_journal_name[-1] == ":":
|
||||
potential_journal_name = potential_journal_name[0:-1]
|
||||
|
||||
if potential_journal_name in config["journals"]:
|
||||
args.journal_name = potential_journal_name
|
||||
args.text = args.text[1:]
|
||||
|
||||
logging.debug("Using journal name: %s", args.journal_name)
|
||||
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),
|
||||
},
|
||||
),
|
||||
)
|
|
@ -1,455 +0,0 @@
|
|||
# Copyright © 2012-2023 jrnl contributors
|
||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
import logging
|
||||
import sys
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from jrnl import install
|
||||
from jrnl import plugins
|
||||
from jrnl import time
|
||||
from jrnl.config import DEFAULT_JOURNAL_KEY
|
||||
from jrnl.config import get_config_path
|
||||
from jrnl.config import get_journal_name
|
||||
from jrnl.config import scope_config
|
||||
from jrnl.editor import get_text_from_editor
|
||||
from jrnl.editor import get_text_from_stdin
|
||||
from jrnl.editor import read_template_file
|
||||
from jrnl.exception import JrnlException
|
||||
from jrnl.journals import open_journal
|
||||
from jrnl.messages import Message
|
||||
from jrnl.messages import MsgStyle
|
||||
from jrnl.messages import MsgText
|
||||
from jrnl.output import print_msg
|
||||
from jrnl.output import print_msgs
|
||||
from jrnl.override import apply_overrides
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from argparse import Namespace
|
||||
|
||||
from jrnl.journals import Entry
|
||||
from jrnl.journals import Journal
|
||||
|
||||
|
||||
def run(args: "Namespace"):
|
||||
"""
|
||||
Flow:
|
||||
1. Run standalone command if it doesn't need config (help, version, etc), then exit
|
||||
2. Load config
|
||||
3. Run standalone command if it does need config (encrypt, decrypt, etc), then exit
|
||||
4. Load specified journal
|
||||
5. Start append mode, or search mode
|
||||
6. Perform actions with results from search mode (if needed)
|
||||
7. Profit
|
||||
"""
|
||||
|
||||
# Run command if possible before config is available
|
||||
if callable(args.preconfig_cmd):
|
||||
return args.preconfig_cmd(args)
|
||||
|
||||
# Load the config, and extract journal name
|
||||
config = install.load_or_install_jrnl(args.config_file_path)
|
||||
original_config = config.copy()
|
||||
|
||||
# Apply config overrides
|
||||
config = apply_overrides(args, config)
|
||||
|
||||
args = get_journal_name(args, config)
|
||||
config = scope_config(config, args.journal_name)
|
||||
|
||||
# Run post-config command now that config is ready
|
||||
if callable(args.postconfig_cmd):
|
||||
return args.postconfig_cmd(
|
||||
args=args, config=config, original_config=original_config
|
||||
)
|
||||
|
||||
# --- All the standalone commands are now done --- #
|
||||
|
||||
# Get the journal we're going to be working with
|
||||
journal = open_journal(args.journal_name, config)
|
||||
|
||||
kwargs = {
|
||||
"args": args,
|
||||
"config": config,
|
||||
"journal": journal,
|
||||
"old_entries": journal.entries,
|
||||
}
|
||||
|
||||
if _is_append_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:
|
||||
# display only occurs if no other action occurs
|
||||
_display_search_results(**kwargs)
|
||||
|
||||
|
||||
def _perform_actions_on_search_results(**kwargs):
|
||||
args = kwargs["args"]
|
||||
|
||||
# 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.
|
||||
append_mode = (
|
||||
not _has_search_args(args)
|
||||
and not _has_action_args(args)
|
||||
and not _has_display_args(args)
|
||||
)
|
||||
|
||||
# Might be writing and want to move to editor part of the way through
|
||||
if args.edit and args.text:
|
||||
append_mode = True
|
||||
|
||||
# If the text is entirely tags, then we are also searching (not writing)
|
||||
if append_mode and args.text and _has_only_tags(config["tagsymbols"], args.text):
|
||||
append_mode = False
|
||||
|
||||
return append_mode
|
||||
|
||||
|
||||
def append_mode(args: "Namespace", config: dict, journal: "Journal", **kwargs) -> None:
|
||||
"""
|
||||
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
|
||||
2. Check input being piped in
|
||||
3. Open editor if configured (prepopulated with template if available)
|
||||
4. Use stdin.read as last resort
|
||||
6. Write any found text to journal, or exit
|
||||
"""
|
||||
logging.debug("Append mode: starting")
|
||||
|
||||
template_text = _get_template(args, config)
|
||||
|
||||
if args.text:
|
||||
logging.debug(f"Append mode: cli text detected: {args.text}")
|
||||
raw = " ".join(args.text).strip()
|
||||
if args.edit:
|
||||
raw = _write_in_editor(config, raw)
|
||||
elif not sys.stdin.isatty():
|
||||
logging.debug("Append mode: receiving piped text")
|
||||
raw = sys.stdin.read()
|
||||
else:
|
||||
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():
|
||||
logging.error("Append mode: couldn't get raw text or entry was empty")
|
||||
raise JrnlException(Message(MsgText.NoTextReceived, MsgStyle.NORMAL))
|
||||
|
||||
logging.debug(
|
||||
f"Append mode: appending raw text to journal '{args.journal_name}': {raw}"
|
||||
)
|
||||
journal.new_entry(raw)
|
||||
if args.journal_name != DEFAULT_JOURNAL_KEY:
|
||||
print_msg(
|
||||
Message(
|
||||
MsgText.JournalEntryAdded,
|
||||
MsgStyle.NORMAL,
|
||||
{"journal_name": args.journal_name},
|
||||
)
|
||||
)
|
||||
journal.write()
|
||||
logging.debug("Append mode: completed journal.write()")
|
||||
|
||||
|
||||
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, and return the
|
||||
results. If no search args, then return all results
|
||||
"""
|
||||
logging.debug("Search mode: starting")
|
||||
|
||||
# If no search args, then return all results (don't filter anything)
|
||||
if not _has_search_args(args) and not _has_display_args(args) and not args.text:
|
||||
logging.debug("Search mode: has no search args")
|
||||
return
|
||||
|
||||
logging.debug("Search mode: has search args")
|
||||
_filter_journal_entries(args, journal)
|
||||
|
||||
|
||||
def _write_in_editor(config: dict, prepopulated_text: str | None = None) -> str:
|
||||
if config["editor"]:
|
||||
logging.debug("Append mode: opening editor")
|
||||
raw = get_text_from_editor(config, prepopulated_text)
|
||||
else:
|
||||
raw = get_text_from_stdin()
|
||||
|
||||
return raw
|
||||
|
||||
|
||||
def _filter_journal_entries(args: "Namespace", journal: "Journal", **kwargs) -> None:
|
||||
"""Filter journal entries in-place based upon search args"""
|
||||
if args.on_date:
|
||||
args.start_date = args.end_date = args.on_date
|
||||
|
||||
if args.today_in_history:
|
||||
now = time.parse("now")
|
||||
args.day = now.day
|
||||
args.month = now.month
|
||||
|
||||
journal.filter(
|
||||
tags=args.text,
|
||||
month=args.month,
|
||||
day=args.day,
|
||||
year=args.year,
|
||||
start_date=args.start_date,
|
||||
end_date=args.end_date,
|
||||
strict=args.strict,
|
||||
starred=args.starred,
|
||||
tagged=args.tagged,
|
||||
exclude=args.excluded,
|
||||
exclude_starred=args.exclude_starred,
|
||||
exclude_tagged=args.exclude_tagged,
|
||||
contains=args.contains,
|
||||
)
|
||||
journal.limit(args.limit)
|
||||
|
||||
|
||||
def _print_entries_found_count(count: int, args: "Namespace") -> None:
|
||||
logging.debug(f"count: {count}")
|
||||
if count == 0:
|
||||
if args.edit or args.change_time:
|
||||
print_msg(Message(MsgText.NothingToModify, MsgStyle.WARNING))
|
||||
elif args.delete:
|
||||
print_msg(Message(MsgText.NothingToDelete, MsgStyle.WARNING))
|
||||
else:
|
||||
print_msg(Message(MsgText.NoEntriesFound, MsgStyle.NORMAL))
|
||||
return
|
||||
elif args.limit and args.limit == count:
|
||||
# Don't show count if the user expects a limited number of results
|
||||
logging.debug("args.limit is true-ish")
|
||||
return
|
||||
|
||||
logging.debug("Printing general summary")
|
||||
my_msg = (
|
||||
MsgText.EntryFoundCountSingular if count == 1 else MsgText.EntryFoundCountPlural
|
||||
)
|
||||
print_msg(Message(my_msg, MsgStyle.NORMAL, {"num": count}))
|
||||
|
||||
|
||||
def _other_entries(journal: "Journal", entries: list["Entry"]) -> list["Entry"]:
|
||||
"""Find entries that are not in journal"""
|
||||
return [e for e in entries if e not in journal.entries]
|
||||
|
||||
|
||||
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
|
||||
2. Print out stats on any modifications to journal
|
||||
3. Write modifications to journal
|
||||
"""
|
||||
if not config["editor"]:
|
||||
raise JrnlException(
|
||||
Message(
|
||||
MsgText.EditorNotConfigured,
|
||||
MsgStyle.ERROR,
|
||||
{"config_file": get_config_path()},
|
||||
)
|
||||
)
|
||||
|
||||
# separate entries we are not editing
|
||||
other_entries = _other_entries(journal, old_entries)
|
||||
|
||||
# Send user to the editor
|
||||
try:
|
||||
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
|
||||
|
||||
journal.parse_editable_str(edited)
|
||||
|
||||
# Put back entries we separated earlier, sort, and write the journal
|
||||
journal.entries += other_entries
|
||||
journal.sort()
|
||||
journal.write()
|
||||
|
||||
|
||||
def _print_changed_counts(journal: "Journal", **kwargs) -> None:
|
||||
stats = journal.get_change_counts()
|
||||
msgs = []
|
||||
|
||||
if stats["added"] > 0:
|
||||
my_msg = (
|
||||
MsgText.JournalCountAddedSingular
|
||||
if stats["added"] == 1
|
||||
else MsgText.JournalCountAddedPlural
|
||||
)
|
||||
msgs.append(Message(my_msg, MsgStyle.NORMAL, {"num": stats["added"]}))
|
||||
|
||||
if stats["deleted"] > 0:
|
||||
my_msg = (
|
||||
MsgText.JournalCountDeletedSingular
|
||||
if stats["deleted"] == 1
|
||||
else MsgText.JournalCountDeletedPlural
|
||||
)
|
||||
msgs.append(Message(my_msg, MsgStyle.NORMAL, {"num": stats["deleted"]}))
|
||||
|
||||
if stats["modified"] > 0:
|
||||
my_msg = (
|
||||
MsgText.JournalCountModifiedSingular
|
||||
if stats["modified"] == 1
|
||||
else MsgText.JournalCountModifiedPlural
|
||||
)
|
||||
msgs.append(Message(my_msg, MsgStyle.NORMAL, {"num": stats["modified"]}))
|
||||
|
||||
if not msgs:
|
||||
msgs.append(Message(MsgText.NoEditsReceived, MsgStyle.NORMAL))
|
||||
|
||||
print_msgs(msgs)
|
||||
|
||||
|
||||
def _get_predit_stats(journal: "Journal") -> dict[str, int]:
|
||||
return {"count": len(journal)}
|
||||
|
||||
|
||||
def _delete_search_results(
|
||||
journal: "Journal", old_entries: list["Entry"], **kwargs
|
||||
) -> None:
|
||||
entries_to_delete = journal.prompt_action_entries(MsgText.DeleteEntryQuestion)
|
||||
|
||||
journal.entries = old_entries
|
||||
|
||||
if entries_to_delete:
|
||||
journal.delete_entries(entries_to_delete)
|
||||
|
||||
journal.write()
|
||||
|
||||
|
||||
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
|
||||
# @todo if there's only 1, don't prompt
|
||||
entries_to_change = journal.prompt_action_entries(MsgText.ChangeTimeEntryQuestion)
|
||||
|
||||
if entries_to_change:
|
||||
date = time.parse(args.change_time)
|
||||
journal.entries = old_entries
|
||||
journal.change_date_entries(date, entries_to_change)
|
||||
|
||||
journal.write()
|
||||
|
||||
|
||||
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
|
||||
args.export = args.export or kwargs["config"].get("display_format")
|
||||
|
||||
if args.tags:
|
||||
print(plugins.get_exporter("tags").export(journal))
|
||||
|
||||
elif args.short or args.export == "short":
|
||||
print(journal.pprint(short=True))
|
||||
|
||||
elif args.export == "pretty":
|
||||
print(journal.pprint())
|
||||
|
||||
elif args.export:
|
||||
exporter = plugins.get_exporter(args.export)
|
||||
print(exporter.export(journal, args.filename))
|
||||
else:
|
||||
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())
|
121
jrnl/editor.py
|
@ -1,121 +0,0 @@
|
|||
# Copyright © 2012-2023 jrnl contributors
|
||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
import logging
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
from jrnl.exception import JrnlException
|
||||
from jrnl.messages import Message
|
||||
from jrnl.messages import MsgStyle
|
||||
from jrnl.messages import MsgText
|
||||
from jrnl.os_compat import on_windows
|
||||
from jrnl.os_compat import split_args
|
||||
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: dict, template: str = "") -> str:
|
||||
suffix = ".jrnl"
|
||||
if config["template"]:
|
||||
template_filename = Path(config["template"]).name
|
||||
suffix = "-" + template_filename
|
||||
filehandle, tmpfile = tempfile.mkstemp(prefix="jrnl", text=True, suffix=suffix)
|
||||
os.close(filehandle)
|
||||
|
||||
with open(tmpfile, "w", encoding="utf-8") as f:
|
||||
if template:
|
||||
f.write(template)
|
||||
|
||||
try:
|
||||
subprocess.call(split_args(config["editor"]) + [tmpfile])
|
||||
except FileNotFoundError:
|
||||
raise JrnlException(
|
||||
Message(
|
||||
MsgText.EditorMisconfigured,
|
||||
MsgStyle.ERROR,
|
||||
{"editor_key": config["editor"]},
|
||||
)
|
||||
)
|
||||
|
||||
with open(tmpfile, "r", encoding="utf-8") as f:
|
||||
raw = f.read()
|
||||
os.remove(tmpfile)
|
||||
|
||||
if not raw:
|
||||
raise JrnlException(Message(MsgText.NoTextReceived, MsgStyle.NORMAL))
|
||||
|
||||
return raw
|
||||
|
||||
|
||||
def get_text_from_stdin() -> str:
|
||||
print_msg(
|
||||
Message(
|
||||
MsgText.WritingEntryStart,
|
||||
MsgStyle.TITLE,
|
||||
{
|
||||
"how_to_quit": (
|
||||
MsgText.HowToQuitWindows if on_windows() else MsgText.HowToQuitLinux
|
||||
)
|
||||
},
|
||||
)
|
||||
)
|
||||
|
||||
try:
|
||||
raw = sys.stdin.read()
|
||||
except KeyboardInterrupt:
|
||||
logging.error("Append mode: keyboard interrupt")
|
||||
raise JrnlException(
|
||||
Message(MsgText.KeyboardInterruptMsg, MsgStyle.ERROR_ON_NEW_LINE),
|
||||
Message(MsgText.JournalNotSaved, MsgStyle.WARNING),
|
||||
)
|
||||
|
||||
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,
|
||||
},
|
||||
)
|
||||
)
|
|
@ -1,53 +0,0 @@
|
|||
# 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
|
|
@ -1,8 +0,0 @@
|
|||
# Copyright © 2012-2023 jrnl contributors
|
||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
from .BaseEncryption import BaseEncryption
|
||||
|
||||
|
||||
class BaseKeyEncryption(BaseEncryption):
|
||||
pass
|
|
@ -1,82 +0,0 @@
|
|||
# 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
|
|
@ -1,42 +0,0 @@
|
|||
# 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
|
|
@ -1,59 +0,0 @@
|
|||
# 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
|
|
@ -1,20 +0,0 @@
|
|||
# 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)
|
|
@ -1,36 +0,0 @@
|
|||
# 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)
|
|
@ -1,24 +0,0 @@
|
|||
# Copyright © 2012-2023 jrnl contributors
|
||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from jrnl.output import print_msg
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from jrnl.messages import Message
|
||||
from jrnl.messages import MsgText
|
||||
|
||||
|
||||
class JrnlException(Exception):
|
||||
"""Common exceptions raised by jrnl."""
|
||||
|
||||
def __init__(self, *messages: "Message"):
|
||||
self.messages = messages
|
||||
|
||||
def print(self) -> None:
|
||||
for msg in self.messages:
|
||||
print_msg(msg)
|
||||
|
||||
def has_message_text(self, message_text: "MsgText"):
|
||||
return any([m.text == message_text for m in self.messages])
|
226
jrnl/install.py
|
@ -1,183 +1,73 @@
|
|||
# Copyright © 2012-2023 jrnl contributors
|
||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
import contextlib
|
||||
import glob
|
||||
import logging
|
||||
import readline, glob
|
||||
import getpass
|
||||
try: import simplejson as json
|
||||
except ImportError: import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
from rich.pretty import pretty_repr
|
||||
|
||||
from jrnl import __version__
|
||||
from jrnl.config import DEFAULT_JOURNAL_KEY
|
||||
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_journal_path
|
||||
from jrnl.config import load_config
|
||||
from jrnl.config import save_config
|
||||
from jrnl.config import verify_config_colors
|
||||
from jrnl.exception import JrnlException
|
||||
from jrnl.messages import Message
|
||||
from jrnl.messages import MsgStyle
|
||||
from jrnl.messages import MsgText
|
||||
from jrnl.output import print_msg
|
||||
from jrnl.path import absolute_path
|
||||
from jrnl.path import expand_path
|
||||
from jrnl.path import home_dir
|
||||
from jrnl.prompt import yesno
|
||||
from jrnl.upgrade import is_old_version
|
||||
|
||||
|
||||
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. This essentially automatically ports jrnl installations
|
||||
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."""
|
||||
default_config = get_default_config()
|
||||
missing_keys = set(default_config).difference(config_data)
|
||||
if missing_keys:
|
||||
for key in missing_keys:
|
||||
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)
|
||||
config_path = alt_config_path if alt_config_path else get_config_path()
|
||||
print_msg(
|
||||
Message(
|
||||
MsgText.ConfigUpdated, MsgStyle.NORMAL, {"config_path": config_path}
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def find_default_config() -> str:
|
||||
config_path = (
|
||||
get_config_path()
|
||||
if os.path.exists(get_config_path())
|
||||
else os.path.join(home_dir(), ".jrnl_config")
|
||||
)
|
||||
return config_path
|
||||
|
||||
|
||||
def find_alt_config(alt_config: str) -> str:
|
||||
if not os.path.exists(alt_config):
|
||||
raise JrnlException(
|
||||
Message(
|
||||
MsgText.AltConfigNotFound, MsgStyle.ERROR, {"config_file": alt_config}
|
||||
)
|
||||
)
|
||||
|
||||
return alt_config
|
||||
|
||||
|
||||
def load_or_install_jrnl(alt_config_path: str) -> dict:
|
||||
"""
|
||||
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.
|
||||
Else, perform various prompts to install jrnl.
|
||||
"""
|
||||
config_path = (
|
||||
find_alt_config(alt_config_path) if alt_config_path else find_default_config()
|
||||
)
|
||||
|
||||
if os.path.exists(config_path):
|
||||
logging.debug("Reading configuration from file %s", config_path)
|
||||
config = load_config(config_path)
|
||||
|
||||
if config is None:
|
||||
raise JrnlException(
|
||||
Message(
|
||||
MsgText.CantParseConfigFile,
|
||||
MsgStyle.ERROR,
|
||||
{
|
||||
"config_path": config_path,
|
||||
},
|
||||
)
|
||||
)
|
||||
|
||||
if is_old_version(config_path):
|
||||
from jrnl import upgrade
|
||||
|
||||
upgrade.upgrade_jrnl(config_path)
|
||||
|
||||
upgrade_config(config, alt_config_path)
|
||||
verify_config_colors(config)
|
||||
|
||||
def module_exists(module_name):
|
||||
"""Checks if a module exists and can be imported"""
|
||||
try:
|
||||
__import__(module_name)
|
||||
except ImportError:
|
||||
return False
|
||||
else:
|
||||
logging.debug("Configuration file not found, installing jrnl...")
|
||||
config = install()
|
||||
return True
|
||||
|
||||
logging.debug('Using configuration:\n"%s"', pretty_repr(config))
|
||||
return config
|
||||
default_config = {
|
||||
'journal': os.path.expanduser("~/journal.txt"),
|
||||
'editor': "",
|
||||
'encrypt': False,
|
||||
'password': "",
|
||||
'default_hour': 9,
|
||||
'default_minute': 0,
|
||||
'timeformat': "%Y-%m-%d %H:%M",
|
||||
'tagsymbols': '@',
|
||||
'highlight': True,
|
||||
}
|
||||
|
||||
|
||||
def install() -> dict:
|
||||
_initialize_autocomplete()
|
||||
def install_jrnl(config_path='~/.jrnl_config'):
|
||||
def autocomplete(text, state):
|
||||
expansions = glob.glob(os.path.expanduser(text)+'*')
|
||||
expansions = [e+"/" if os.path.isdir(e) else e for e in expansions]
|
||||
expansions.append(None)
|
||||
return expansions[state]
|
||||
readline.set_completer_delims(' \t\n;')
|
||||
readline.parse_and_bind("tab: complete")
|
||||
readline.set_completer(autocomplete)
|
||||
|
||||
# Where to create the journal?
|
||||
default_journal_path = get_default_journal_path()
|
||||
user_given_path = print_msg(
|
||||
Message(
|
||||
MsgText.InstallJournalPathQuestion,
|
||||
MsgStyle.PROMPT,
|
||||
params={
|
||||
"default_journal_path": default_journal_path,
|
||||
},
|
||||
),
|
||||
get_input=True,
|
||||
)
|
||||
journal_path = absolute_path(user_given_path or default_journal_path)
|
||||
default_config = get_default_config()
|
||||
default_config["journals"][DEFAULT_JOURNAL_KEY]["journal"] = journal_path
|
||||
|
||||
# If the folder doesn't exist, create it
|
||||
path = os.path.split(journal_path)[0]
|
||||
with contextlib.suppress(OSError):
|
||||
os.makedirs(path)
|
||||
path_query = 'Path to your journal file (leave blank for ~/journal.txt): '
|
||||
journal_path = raw_input(path_query).strip() or os.path.expanduser('~/journal.txt')
|
||||
default_config['journal'] = os.path.expanduser(journal_path)
|
||||
|
||||
# Encrypt it?
|
||||
encrypt = yesno(Message(MsgText.EncryptJournalQuestion), default=False)
|
||||
if encrypt:
|
||||
default_config["encrypt"] = True
|
||||
print_msg(Message(MsgText.JournalEncrypted, MsgStyle.NORMAL))
|
||||
if module_exists("Crypto"):
|
||||
password = getpass.getpass("Enter password for journal (leave blank for no encryption): ")
|
||||
if password:
|
||||
default_config['encrypt'] = True
|
||||
print("Journal will be encrypted.")
|
||||
print("If you want to, you can store your password in .jrnl_config and will never be bothered about it again.")
|
||||
else:
|
||||
password = None
|
||||
print("PyCrypto not found. To encrypt your journal, install the PyCrypto package from http://www.pycrypto.org and run 'jrnl --encrypt'. For now, your journal will be stored in plain text.")
|
||||
|
||||
# Use colors?
|
||||
use_colors = yesno(Message(MsgText.UseColorsQuestion), default=True)
|
||||
if use_colors:
|
||||
default_config["colors"] = get_default_colors()
|
||||
# Use highlighting:
|
||||
if module_exists("clint"):
|
||||
print("clint not found. To turn on highlighting, install clint and set highlight to true in your .jrnl_conf.")
|
||||
default_config['highlight'] = False
|
||||
|
||||
save_config(default_config)
|
||||
open(default_config['journal'], 'a').close() # Touch to make sure it's there
|
||||
|
||||
print_msg(
|
||||
Message(
|
||||
MsgText.InstallComplete,
|
||||
MsgStyle.NORMAL,
|
||||
params={"config_path": get_config_path()},
|
||||
)
|
||||
)
|
||||
# Write config to ~/.jrnl_conf
|
||||
with open(config_path, 'w') as f:
|
||||
json.dump(default_config, f, indent=2)
|
||||
config = default_config
|
||||
if password:
|
||||
config['password'] = password
|
||||
return config
|
||||
|
||||
return default_config
|
||||
|
||||
|
||||
def _initialize_autocomplete() -> None:
|
||||
# readline is not included in Windows Active Python and perhaps some other distss
|
||||
if sys.modules.get("readline"):
|
||||
import readline
|
||||
|
||||
readline.set_completer_delims(" \t\n;")
|
||||
readline.parse_and_bind("tab: complete")
|
||||
readline.set_completer(_autocomplete_path)
|
||||
|
||||
|
||||
def _autocomplete_path(text: str, state: int) -> list[str | None]:
|
||||
expansions = glob.glob(expand_path(text) + "*")
|
||||
expansions = [e + "/" if os.path.isdir(e) else e for e in expansions]
|
||||
expansions.append(None)
|
||||
return expansions[state]
|
||||
|
|
@ -1,219 +0,0 @@
|
|||
# Copyright © 2012-2023 jrnl contributors
|
||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
import contextlib
|
||||
import datetime
|
||||
import fnmatch
|
||||
import os
|
||||
import platform
|
||||
import plistlib
|
||||
import re
|
||||
import socket
|
||||
import time
|
||||
import uuid
|
||||
import zoneinfo
|
||||
from pathlib import Path
|
||||
from xml.parsers.expat import ExpatError
|
||||
|
||||
import tzlocal
|
||||
|
||||
from jrnl import __title__
|
||||
from jrnl import __version__
|
||||
|
||||
from .Entry import Entry
|
||||
from .Journal import Journal
|
||||
|
||||
|
||||
class DayOne(Journal):
|
||||
"""A special Journal handling DayOne files"""
|
||||
|
||||
# InvalidFileException was added to plistlib in Python3.4
|
||||
PLIST_EXCEPTIONS = (
|
||||
(ExpatError, plistlib.InvalidFileException)
|
||||
if hasattr(plistlib, "InvalidFileException")
|
||||
else ExpatError
|
||||
)
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.entries = []
|
||||
self._deleted_entries = []
|
||||
self.can_be_encrypted = False
|
||||
super().__init__(**kwargs)
|
||||
|
||||
def open(self) -> "DayOne":
|
||||
filenames = []
|
||||
for root, dirnames, f in os.walk(self.config["journal"]):
|
||||
for filename in fnmatch.filter(f, "*.doentry"):
|
||||
filenames.append(os.path.join(root, filename))
|
||||
self.entries = []
|
||||
for filename in filenames:
|
||||
with open(filename, "rb") as plist_entry:
|
||||
try:
|
||||
dict_entry = plistlib.load(plist_entry, fmt=plistlib.FMT_XML)
|
||||
except self.PLIST_EXCEPTIONS:
|
||||
pass
|
||||
else:
|
||||
try:
|
||||
timezone = zoneinfo.ZoneInfo(dict_entry["Time Zone"])
|
||||
except KeyError:
|
||||
timezone_name = str(tzlocal.get_localzone())
|
||||
timezone = zoneinfo.ZoneInfo(timezone_name)
|
||||
date = dict_entry["Creation Date"]
|
||||
# convert the date to UTC rather than keep messing with
|
||||
# timezones
|
||||
if timezone.key != "UTC":
|
||||
date = date.replace(fold=1) + timezone.utcoffset(date)
|
||||
|
||||
entry = Entry(
|
||||
self,
|
||||
date,
|
||||
text=dict_entry["Entry Text"],
|
||||
starred=dict_entry["Starred"],
|
||||
)
|
||||
entry.uuid = dict_entry["UUID"]
|
||||
entry._tags = [
|
||||
self.config["tagsymbols"][0] + tag.lower()
|
||||
for tag in dict_entry.get("Tags", [])
|
||||
]
|
||||
if entry._tags:
|
||||
entry._tags.sort()
|
||||
|
||||
"""Extended DayOne attributes"""
|
||||
# just ignore it if the keys don't exist
|
||||
with contextlib.suppress(KeyError):
|
||||
entry.creator_device_agent = dict_entry["Creator"][
|
||||
"Device Agent"
|
||||
]
|
||||
entry.creator_host_name = dict_entry["Creator"]["Host Name"]
|
||||
entry.creator_os_agent = dict_entry["Creator"]["OS Agent"]
|
||||
entry.creator_software_agent = dict_entry["Creator"][
|
||||
"Software Agent"
|
||||
]
|
||||
entry.location = dict_entry["Location"]
|
||||
entry.weather = dict_entry["Weather"]
|
||||
|
||||
entry.creator_generation_date = dict_entry.get("Creator", {}).get(
|
||||
"Generation Date", date
|
||||
)
|
||||
|
||||
self.entries.append(entry)
|
||||
self.sort()
|
||||
return self
|
||||
|
||||
def write(self) -> None:
|
||||
"""Writes only the entries that have been modified into plist files."""
|
||||
for entry in self.entries:
|
||||
if entry.modified:
|
||||
utc_time = datetime.datetime.utcfromtimestamp(
|
||||
time.mktime(entry.date.timetuple())
|
||||
)
|
||||
|
||||
if not hasattr(entry, "uuid"):
|
||||
entry.uuid = uuid.uuid1().hex
|
||||
if not hasattr(entry, "creator_device_agent"):
|
||||
entry.creator_device_agent = "" # iPhone/iPhone5,3
|
||||
if not hasattr(entry, "creator_generation_date"):
|
||||
entry.creator_generation_date = utc_time
|
||||
if not hasattr(entry, "creator_host_name"):
|
||||
entry.creator_host_name = socket.gethostname()
|
||||
if not hasattr(entry, "creator_os_agent"):
|
||||
entry.creator_os_agent = "{}/{}".format(
|
||||
platform.system(), platform.release()
|
||||
)
|
||||
if not hasattr(entry, "creator_software_agent"):
|
||||
entry.creator_software_agent = "{}/{}".format(
|
||||
__title__, __version__
|
||||
)
|
||||
|
||||
fn = (
|
||||
Path(self.config["journal"])
|
||||
/ "entries"
|
||||
/ (entry.uuid.upper() + ".doentry")
|
||||
)
|
||||
|
||||
entry_plist = {
|
||||
"Creation Date": utc_time,
|
||||
"Starred": entry.starred if hasattr(entry, "starred") else False,
|
||||
"Entry Text": entry.title + "\n" + entry.body,
|
||||
"Time Zone": str(tzlocal.get_localzone()),
|
||||
"UUID": entry.uuid.upper(),
|
||||
"Tags": [
|
||||
tag.strip(self.config["tagsymbols"]).replace("_", " ")
|
||||
for tag in entry.tags
|
||||
],
|
||||
"Creator": {
|
||||
"Device Agent": entry.creator_device_agent,
|
||||
"Generation Date": entry.creator_generation_date,
|
||||
"Host Name": entry.creator_host_name,
|
||||
"OS Agent": entry.creator_os_agent,
|
||||
"Software Agent": entry.creator_software_agent,
|
||||
},
|
||||
}
|
||||
if hasattr(entry, "location"):
|
||||
entry_plist["Location"] = entry.location
|
||||
if hasattr(entry, "weather"):
|
||||
entry_plist["Weather"] = entry.weather
|
||||
|
||||
# plistlib expects a binary object
|
||||
with fn.open(mode="wb") as f:
|
||||
plistlib.dump(entry_plist, f, fmt=plistlib.FMT_XML, sort_keys=False)
|
||||
|
||||
for entry in self._deleted_entries:
|
||||
filename = os.path.join(
|
||||
self.config["journal"], "entries", entry.uuid + ".doentry"
|
||||
)
|
||||
os.remove(filename)
|
||||
|
||||
def editable_str(self) -> str:
|
||||
"""Turns the journal into a string of entries that can be edited
|
||||
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])
|
||||
|
||||
def _update_old_entry(self, entry: Entry, new_entry: Entry) -> None:
|
||||
for attr in ("title", "body", "date", "tags"):
|
||||
old_attr = getattr(entry, attr)
|
||||
new_attr = getattr(new_entry, attr)
|
||||
if old_attr != new_attr:
|
||||
entry.modified = True
|
||||
setattr(entry, attr, new_attr)
|
||||
|
||||
def _get_and_remove_uuid_from_entry(self, entry: Entry) -> Entry:
|
||||
uuid_regex = "^ *?# ([a-zA-Z0-9]+) *?$"
|
||||
m = re.search(uuid_regex, entry.body, re.MULTILINE)
|
||||
entry.uuid = m.group(1) if m else None
|
||||
|
||||
# remove the uuid from the body
|
||||
entry.body = re.sub(uuid_regex, "", entry.body, flags=re.MULTILINE, count=1)
|
||||
entry.body = entry.body.rstrip()
|
||||
|
||||
return entry
|
||||
|
||||
def parse_editable_str(self, edited: str) -> None:
|
||||
"""Parses the output of self.editable_str and updates its entries."""
|
||||
# Method: create a new list of entries from the edited text, then match
|
||||
# UUIDs of the new entries against self.entries, updating the entries
|
||||
# if the edited entries differ, and deleting entries from self.entries
|
||||
# if they don't show up in the edited entries anymore.
|
||||
entries_from_editor = self._parse(edited)
|
||||
|
||||
for entry in entries_from_editor:
|
||||
entry = self._get_and_remove_uuid_from_entry(entry)
|
||||
if entry._tags:
|
||||
entry._tags.sort()
|
||||
|
||||
# Remove deleted entries
|
||||
edited_uuids = [e.uuid for e in entries_from_editor]
|
||||
self._deleted_entries = [e for e in self.entries if e.uuid not in edited_uuids]
|
||||
self.entries[:] = [e for e in self.entries if e.uuid in edited_uuids]
|
||||
|
||||
for entry in entries_from_editor:
|
||||
for old_entry in self.entries:
|
||||
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)
|
||||
break
|
|
@ -1,231 +0,0 @@
|
|||
# Copyright © 2012-2023 jrnl contributors
|
||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
import datetime
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from jrnl.color import colorize
|
||||
from jrnl.color import highlight_tags_with_background_color
|
||||
from jrnl.output import wrap_with_ansi_colors
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .Journal import Journal
|
||||
|
||||
|
||||
class Entry:
|
||||
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.date = date or datetime.datetime.now()
|
||||
self.text = text
|
||||
self._title = None
|
||||
self._body = None
|
||||
self._tags = None
|
||||
self.starred = starred
|
||||
self.modified = False
|
||||
|
||||
@property
|
||||
def fulltext(self) -> str:
|
||||
return self.title + " " + self.body
|
||||
|
||||
def _parse_text(self):
|
||||
raw_text = self.text
|
||||
lines = raw_text.splitlines()
|
||||
if lines and lines[0].strip().endswith("*"):
|
||||
self.starred = True
|
||||
raw_text = lines[0].strip("\n *") + "\n" + "\n".join(lines[1:])
|
||||
self._title, self._body = split_title(raw_text)
|
||||
if self._tags is None:
|
||||
self._tags = list(self._parse_tags())
|
||||
|
||||
@property
|
||||
def title(self) -> str:
|
||||
if self._title is None:
|
||||
self._parse_text()
|
||||
return self._title
|
||||
|
||||
@title.setter
|
||||
def title(self, x: str):
|
||||
self._title = x
|
||||
|
||||
@property
|
||||
def body(self) -> str:
|
||||
if self._body is None:
|
||||
self._parse_text()
|
||||
return self._body
|
||||
|
||||
@body.setter
|
||||
def body(self, x: str):
|
||||
self._body = x
|
||||
|
||||
@property
|
||||
def tags(self) -> list[str]:
|
||||
if self._tags is None:
|
||||
self._parse_text()
|
||||
return self._tags
|
||||
|
||||
@tags.setter
|
||||
def tags(self, x: list[str]):
|
||||
self._tags = x
|
||||
|
||||
@staticmethod
|
||||
def tag_regex(tagsymbols: str) -> re.Pattern:
|
||||
pattern = rf"(?<!\S)([{tagsymbols}][-+*#/\w]+)"
|
||||
return re.compile(pattern)
|
||||
|
||||
def _parse_tags(self) -> set[str]:
|
||||
tagsymbols = self.journal.config["tagsymbols"]
|
||||
return {
|
||||
tag.lower() for tag in re.findall(Entry.tag_regex(tagsymbols), self.text)
|
||||
}
|
||||
|
||||
def __str__(self):
|
||||
"""Returns string representation of the entry to be written to journal file."""
|
||||
date_str = self.date.strftime(self.journal.config["timeformat"])
|
||||
title = "[{}] {}".format(date_str, self.title.rstrip("\n "))
|
||||
if self.starred:
|
||||
title += " *"
|
||||
return "{title}{sep}{body}\n".format(
|
||||
title=title,
|
||||
sep="\n" if self.body.rstrip("\n ") else "",
|
||||
body=self.body.rstrip("\n "),
|
||||
)
|
||||
|
||||
def pprint(self, short: bool = False) -> str:
|
||||
"""Returns a pretty-printed version of the entry.
|
||||
If short is true, only print the title."""
|
||||
# Handle indentation
|
||||
if self.journal.config["indent_character"]:
|
||||
indent = self.journal.config["indent_character"].rstrip() + " "
|
||||
else:
|
||||
indent = ""
|
||||
|
||||
date_str = colorize(
|
||||
self.date.strftime(self.journal.config["timeformat"]),
|
||||
self.journal.config["colors"]["date"],
|
||||
bold=True,
|
||||
)
|
||||
|
||||
if not short and self.journal.config["linewrap"]:
|
||||
columns = self.journal.config["linewrap"]
|
||||
|
||||
if columns == "auto":
|
||||
try:
|
||||
columns = os.get_terminal_size().columns
|
||||
except OSError:
|
||||
logging.debug(
|
||||
"Can't determine terminal size automatically 'linewrap': '%s'",
|
||||
self.journal.config["linewrap"],
|
||||
)
|
||||
columns = 79
|
||||
|
||||
# Color date / title and bold title
|
||||
title = wrap_with_ansi_colors(
|
||||
date_str
|
||||
+ " "
|
||||
+ highlight_tags_with_background_color(
|
||||
self,
|
||||
self.title,
|
||||
self.journal.config["colors"]["title"],
|
||||
is_title=True,
|
||||
),
|
||||
columns,
|
||||
)
|
||||
body = highlight_tags_with_background_color(
|
||||
self, self.body.rstrip(" \n"), self.journal.config["colors"]["body"]
|
||||
)
|
||||
|
||||
body = wrap_with_ansi_colors(body, columns - len(indent))
|
||||
if indent:
|
||||
# Without explicitly colorizing the indent character, it will lose its
|
||||
# color after a tag appears.
|
||||
body = "\n".join(
|
||||
colorize(indent, self.journal.config["colors"]["body"]) + line
|
||||
for line in body.splitlines()
|
||||
)
|
||||
|
||||
body = colorize(body, self.journal.config["colors"]["body"])
|
||||
else:
|
||||
title = (
|
||||
date_str
|
||||
+ " "
|
||||
+ highlight_tags_with_background_color(
|
||||
self,
|
||||
self.title.rstrip("\n"),
|
||||
self.journal.config["colors"]["title"],
|
||||
is_title=True,
|
||||
)
|
||||
)
|
||||
body = highlight_tags_with_background_color(
|
||||
self, self.body.rstrip("\n "), self.journal.config["colors"]["body"]
|
||||
)
|
||||
|
||||
# Suppress bodies that are just blanks and new lines.
|
||||
has_body = len(self.body) > 20 or not all(
|
||||
char in (" ", "\n") for char in self.body
|
||||
)
|
||||
|
||||
if short:
|
||||
return title
|
||||
else:
|
||||
return "{title}{sep}{body}\n".format(
|
||||
title=title, sep="\n" if has_body else "", body=body if has_body else ""
|
||||
)
|
||||
|
||||
def __repr__(self):
|
||||
return "<Entry '{}' on {}>".format(
|
||||
self.title.strip(), self.date.strftime("%Y-%m-%d %H:%M")
|
||||
)
|
||||
|
||||
def __hash__(self):
|
||||
return hash(self.__repr__())
|
||||
|
||||
def __eq__(self, other: "Entry"):
|
||||
if (
|
||||
not isinstance(other, Entry)
|
||||
or self.title.strip() != other.title.strip()
|
||||
or self.body.rstrip() != other.body.rstrip()
|
||||
or self.date != other.date
|
||||
or self.starred != other.starred
|
||||
):
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other: "Entry"):
|
||||
return not self.__eq__(other)
|
||||
|
||||
|
||||
# Based on Segtok by Florian Leitner
|
||||
# https://github.com/fnl/segtok
|
||||
SENTENCE_SPLITTER = re.compile(
|
||||
r"""
|
||||
(
|
||||
[.!?\u2026\u203C\u203D\u2047\u2048\u2049\u22EF\uFE52\uFE57] # Sequence starting with a sentence terminal,
|
||||
[\'\u2019\"\u201D]? # an optional right quote,
|
||||
[\]\)]* # optional closing bracket
|
||||
\s+ # AND a sequence of required spaces.
|
||||
)
|
||||
|[\uFF01\uFF0E\uFF1F\uFF61\u3002] # CJK full/half width terminals usually do not have following spaces.
|
||||
""", # noqa: E501
|
||||
re.VERBOSE,
|
||||
)
|
||||
|
||||
SENTENCE_SPLITTER_ONLY_NEWLINE = re.compile("\n")
|
||||
|
||||
|
||||
def split_title(text: str) -> tuple[str, str]:
|
||||
"""Splits the first sentence off from a text."""
|
||||
sep = SENTENCE_SPLITTER_ONLY_NEWLINE.search(text.lstrip())
|
||||
if not sep:
|
||||
sep = SENTENCE_SPLITTER.search(text)
|
||||
if not sep:
|
||||
return text, ""
|
||||
return text[: sep.end()].strip(), text[sep.end() :].strip()
|
|
@ -1,158 +0,0 @@
|
|||
# Copyright © 2012-2023 jrnl contributors
|
||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
import codecs
|
||||
import os
|
||||
import pathlib
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from jrnl import time
|
||||
|
||||
from .Journal import Journal
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from jrnl.journals import Entry
|
||||
|
||||
# glob search patterns for folder/file structure
|
||||
DIGIT_PATTERN = "[0123456789]"
|
||||
YEAR_PATTERN = DIGIT_PATTERN * 4
|
||||
MONTH_PATTERN = "[01]" + DIGIT_PATTERN
|
||||
DAY_PATTERN = "[0123]" + DIGIT_PATTERN + ".txt"
|
||||
|
||||
|
||||
class Folder(Journal):
|
||||
"""A Journal handling multiple files in a folder"""
|
||||
|
||||
def __init__(self, name: str = "default", **kwargs):
|
||||
self.entries = []
|
||||
self._diff_entry_dates = []
|
||||
self.can_be_encrypted = False
|
||||
super().__init__(name, **kwargs)
|
||||
|
||||
def open(self) -> "Folder":
|
||||
filenames = []
|
||||
self.entries = []
|
||||
|
||||
if os.path.exists(self.config["journal"]):
|
||||
filenames = Folder._get_files(self.config["journal"])
|
||||
for filename in filenames:
|
||||
with codecs.open(filename, "r", "utf-8") as f:
|
||||
journal = f.read()
|
||||
self.entries.extend(self._parse(journal))
|
||||
self.sort()
|
||||
|
||||
return self
|
||||
|
||||
def write(self) -> None:
|
||||
"""Writes only the entries that have been modified into proper files."""
|
||||
# Create a list of dates of modified entries. Start with diff_entry_dates
|
||||
modified_dates = self._diff_entry_dates
|
||||
seen_dates = set(self._diff_entry_dates)
|
||||
|
||||
for e in self.entries:
|
||||
if e.modified:
|
||||
if e.date not in modified_dates:
|
||||
modified_dates.append(e.date)
|
||||
if e.date not in seen_dates:
|
||||
seen_dates.add(e.date)
|
||||
|
||||
# For every date that had a modified entry, write to a file
|
||||
for d in modified_dates:
|
||||
write_entries = []
|
||||
filename = os.path.join(
|
||||
self.config["journal"],
|
||||
d.strftime("%Y"),
|
||||
d.strftime("%m"),
|
||||
d.strftime("%d") + ".txt",
|
||||
)
|
||||
dirname = os.path.dirname(filename)
|
||||
# create directory if it doesn't exist
|
||||
if not os.path.exists(dirname):
|
||||
os.makedirs(dirname)
|
||||
for e in self.entries:
|
||||
if (
|
||||
e.date.year == d.year
|
||||
and e.date.month == d.month
|
||||
and e.date.day == d.day
|
||||
):
|
||||
write_entries.append(e)
|
||||
journal = "\n".join([e.__str__() for e in write_entries])
|
||||
with codecs.open(filename, "w", "utf-8") as journal_file:
|
||||
journal_file.write(journal)
|
||||
# look for and delete empty files
|
||||
filenames = []
|
||||
filenames = Folder._get_files(self.config["journal"])
|
||||
for filename in filenames:
|
||||
if os.stat(filename).st_size <= 0:
|
||||
os.remove(filename)
|
||||
|
||||
def delete_entries(self, entries_to_delete: list["Entry"]) -> None:
|
||||
"""Deletes specific entries from a journal."""
|
||||
for entry in entries_to_delete:
|
||||
self.entries.remove(entry)
|
||||
self._diff_entry_dates.append(entry.date)
|
||||
self.deleted_entry_count += 1
|
||||
|
||||
def change_date_entries(self, date: str, entries_to_change: list["Entry"]) -> None:
|
||||
"""Changes entry dates to given date."""
|
||||
|
||||
date = time.parse(date)
|
||||
|
||||
self._diff_entry_dates.append(date)
|
||||
|
||||
for entry in entries_to_change:
|
||||
self._diff_entry_dates.append(entry.date)
|
||||
entry.date = date
|
||||
entry.modified = True
|
||||
|
||||
def parse_editable_str(self, edited: str) -> None:
|
||||
"""Parses the output of self.editable_str and updates its entries."""
|
||||
mod_entries = self._parse(edited)
|
||||
diff_entries = set(self.entries) - set(mod_entries)
|
||||
for e in diff_entries:
|
||||
self._diff_entry_dates.append(e.date)
|
||||
# Match those entries that can be found in self.entries and set
|
||||
# these to modified, so we can get a count of how many entries got
|
||||
# modified and how many got deleted later.
|
||||
for entry in mod_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
|
||||
|
||||
@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)
|
|
@ -1,525 +0,0 @@
|
|||
# Copyright © 2012-2023 jrnl contributors
|
||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
import datetime
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
|
||||
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 MsgStyle
|
||||
from jrnl.messages import MsgText
|
||||
from jrnl.output import print_msg
|
||||
from jrnl.path import expand_path
|
||||
from jrnl.prompt import yesno
|
||||
|
||||
from .Entry import Entry
|
||||
|
||||
|
||||
class Tag:
|
||||
def __init__(self, name, count=0):
|
||||
self.name = name
|
||||
self.count = count
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Tag '{self.name}'>"
|
||||
|
||||
|
||||
class Journal:
|
||||
def __init__(self, name="default", **kwargs):
|
||||
self.config = {
|
||||
"journal": "journal.txt",
|
||||
"encrypt": False,
|
||||
"default_hour": 9,
|
||||
"default_minute": 0,
|
||||
"timeformat": "%Y-%m-%d %H:%M",
|
||||
"tagsymbols": "@",
|
||||
"highlight": True,
|
||||
"linewrap": 80,
|
||||
"indent_character": "|",
|
||||
}
|
||||
self.config.update(kwargs)
|
||||
# Set up date parser
|
||||
self.search_tags = None # Store tags we're highlighting
|
||||
self.name = name
|
||||
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):
|
||||
"""Returns the number of entries"""
|
||||
return len(self.entries)
|
||||
|
||||
def __iter__(self):
|
||||
"""Iterates over the journal's entries."""
|
||||
return (entry for entry in self.entries)
|
||||
|
||||
@classmethod
|
||||
def from_journal(cls, other: "Journal") -> "Journal":
|
||||
"""Creates a new journal by copying configuration and entries from
|
||||
another journal object"""
|
||||
new_journal = cls(other.name, **other.config)
|
||||
new_journal.entries = other.entries
|
||||
logging.debug(
|
||||
"Imported %d entries from %s to %s",
|
||||
len(new_journal),
|
||||
other.__class__.__name__,
|
||||
cls.__name__,
|
||||
)
|
||||
return new_journal
|
||||
|
||||
def import_(self, other_journal_txt: str) -> None:
|
||||
imported_entries = self._parse(other_journal_txt)
|
||||
for entry in imported_entries:
|
||||
entry.modified = True
|
||||
|
||||
self.entries = list(frozenset(self.entries) | frozenset(imported_entries))
|
||||
self.sort()
|
||||
|
||||
def _get_encryption_method(self) -> None:
|
||||
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)."""
|
||||
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)
|
||||
print_msg(
|
||||
Message(
|
||||
MsgText.JournalCreated,
|
||||
MsgStyle.NORMAL,
|
||||
{
|
||||
"journal_name": self.name,
|
||||
"filename": filename,
|
||||
},
|
||||
)
|
||||
)
|
||||
self.write()
|
||||
|
||||
text = self._load(filename)
|
||||
text = self._decrypt(text)
|
||||
self.entries = self._parse(text)
|
||||
self.sort()
|
||||
logging.debug("opened %s with %d entries", self.__class__.__name__, len(self))
|
||||
return self
|
||||
|
||||
def write(self, filename: str | None = None) -> None:
|
||||
"""Dumps the journal into the config file, overwriting it"""
|
||||
filename = filename or self.config["journal"]
|
||||
text = self._to_text()
|
||||
text = self._encrypt(text)
|
||||
self._store(filename, text)
|
||||
|
||||
def validate_parsing(self) -> bool:
|
||||
"""Confirms that the jrnl is still parsed correctly after conversion to text."""
|
||||
new_entries = self._parse(self._to_text())
|
||||
return all(entry == new_entries[i] for i, entry in enumerate(self.entries))
|
||||
|
||||
@staticmethod
|
||||
def create_file(filename: str) -> None:
|
||||
with open(filename, "w"):
|
||||
pass
|
||||
|
||||
def _to_text(self) -> str:
|
||||
return "\n".join([str(e) for e in self.entries])
|
||||
|
||||
def _load(self, filename: str) -> bytes:
|
||||
with open(filename, "rb") as f:
|
||||
return f.read()
|
||||
|
||||
def _store(self, filename: str, text: bytes) -> None:
|
||||
with open(filename, "wb") as f:
|
||||
f.write(text)
|
||||
|
||||
def _parse(self, journal_txt: str) -> list[Entry]:
|
||||
"""Parses a journal that's stored in a string and returns a list of entries"""
|
||||
|
||||
# Return empty array if the journal is blank
|
||||
if not journal_txt:
|
||||
return []
|
||||
|
||||
# Initialise our current entry
|
||||
entries = []
|
||||
|
||||
date_blob_re = re.compile("(?:^|\n)\\[([^\\]]+)\\] ")
|
||||
last_entry_pos = 0
|
||||
for match in date_blob_re.finditer(journal_txt):
|
||||
date_blob = match.groups()[0]
|
||||
try:
|
||||
new_date = datetime.datetime.strptime(
|
||||
date_blob, self.config["timeformat"]
|
||||
)
|
||||
except ValueError:
|
||||
# Passing in a date that had brackets around it
|
||||
new_date = time.parse(date_blob, bracketed=True)
|
||||
|
||||
if new_date:
|
||||
if entries:
|
||||
entries[-1].text = journal_txt[last_entry_pos : match.start()]
|
||||
last_entry_pos = match.end()
|
||||
entries.append(Entry(self, date=new_date))
|
||||
|
||||
# If no entries were found, treat all the existing text as an entry made now
|
||||
if not entries:
|
||||
entries.append(Entry(self, date=time.parse("now")))
|
||||
|
||||
# Fill in the text of the last entry
|
||||
entries[-1].text = journal_txt[last_entry_pos:]
|
||||
|
||||
for entry in entries:
|
||||
entry._parse_text()
|
||||
return entries
|
||||
|
||||
def pprint(self, short: bool = False) -> str:
|
||||
"""Prettyprints the journal's entries"""
|
||||
return "\n".join([e.pprint(short=short) for e in self.entries])
|
||||
|
||||
def __str__(self):
|
||||
return self.pprint()
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Journal with {len(self.entries)} entries>"
|
||||
|
||||
def sort(self) -> None:
|
||||
"""Sorts the Journal's entries by date"""
|
||||
self.entries = sorted(self.entries, key=lambda entry: entry.date)
|
||||
|
||||
def limit(self, n: int | None = None) -> None:
|
||||
"""Removes all but the last n entries"""
|
||||
if n:
|
||||
self.entries = self.entries[-n:]
|
||||
|
||||
@property
|
||||
def tags(self) -> list[Tag]:
|
||||
"""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 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)]
|
||||
# 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}
|
||||
return [Tag(tag, count=count) for count, tag in sorted(tag_counts)]
|
||||
|
||||
def filter(
|
||||
self,
|
||||
tags=[],
|
||||
month=None,
|
||||
day=None,
|
||||
year=None,
|
||||
start_date=None,
|
||||
end_date=None,
|
||||
starred=False,
|
||||
tagged=False,
|
||||
exclude_starred=False,
|
||||
exclude_tagged=False,
|
||||
strict=False,
|
||||
contains=[],
|
||||
exclude=[],
|
||||
):
|
||||
"""Removes all entries from the journal that don't match the filter.
|
||||
|
||||
tags is a list of tags, each being a string that starts with one of the
|
||||
tag symbols defined in the config, e.g. ["@John", "#WorldDomination"].
|
||||
|
||||
start_date and end_date define a timespan by which to filter.
|
||||
|
||||
starred limits journal to starred entries
|
||||
|
||||
If strict is True, all tags must be present in an entry. If false, the
|
||||
|
||||
exclude is a list of the tags which should not appear in the results.
|
||||
entry is kept if any tag is present, unless they appear in exclude."""
|
||||
self.search_tags = {tag.lower() for tag in tags}
|
||||
excluded_tags = {tag.lower() for tag in exclude}
|
||||
end_date = time.parse(end_date, inclusive=True)
|
||||
start_date = time.parse(start_date)
|
||||
|
||||
# If strict mode is on, all tags have to be present in entry
|
||||
has_tags = (
|
||||
self.search_tags.issubset if strict else self.search_tags.intersection
|
||||
)
|
||||
|
||||
def excluded(tags):
|
||||
return 0 < len([tag for tag in tags if tag in excluded_tags])
|
||||
|
||||
if contains:
|
||||
contains_lower = [substring.casefold() for substring in contains]
|
||||
|
||||
# Create datetime object for comparison below
|
||||
# this approach allows various formats
|
||||
if month or day or year:
|
||||
compare_d = time.parse(f"{month or 1}.{day or 1}.{year or 1}")
|
||||
|
||||
result = [
|
||||
entry
|
||||
for entry in self.entries
|
||||
if (not tags or has_tags(entry.tags))
|
||||
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 day or entry.date.day == compare_d.day)
|
||||
and (not year or entry.date.year == compare_d.year)
|
||||
and (not start_date or entry.date >= start_date)
|
||||
and (not end_date or entry.date <= end_date)
|
||||
and (not exclude or not excluded(entry.tags))
|
||||
and (
|
||||
not contains
|
||||
or (
|
||||
strict
|
||||
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
|
||||
|
||||
def delete_entries(self, entries_to_delete: list[Entry]) -> None:
|
||||
"""Deletes specific entries from a journal."""
|
||||
for entry in entries_to_delete:
|
||||
self.entries.remove(entry)
|
||||
self.deleted_entry_count += 1
|
||||
|
||||
def change_date_entries(
|
||||
self, date: datetime.datetime, entries_to_change: list[Entry]
|
||||
) -> None:
|
||||
"""Changes entry dates to given date."""
|
||||
date = time.parse(date)
|
||||
|
||||
for entry in entries_to_change:
|
||||
entry.date = date
|
||||
entry.modified = True
|
||||
|
||||
def prompt_action_entries(self, msg: MsgText) -> list[Entry]:
|
||||
"""Prompts for action for each entry in a journal, using given message.
|
||||
Returns the entries the user wishes to apply the action on."""
|
||||
to_act = []
|
||||
|
||||
def ask_action(entry):
|
||||
return yesno(
|
||||
Message(
|
||||
msg,
|
||||
params={"entry_title": entry.pprint(short=True)},
|
||||
),
|
||||
default=False,
|
||||
)
|
||||
|
||||
for entry in self.entries:
|
||||
if ask_action(entry):
|
||||
to_act.append(entry)
|
||||
|
||||
return to_act
|
||||
|
||||
def new_entry(self, raw: str, date=None, sort: bool = True) -> Entry:
|
||||
"""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.
|
||||
"""
|
||||
|
||||
raw = raw.replace("\\n ", "\n").replace("\\n", "\n")
|
||||
# Split raw text into title and body
|
||||
sep = re.search(r"\n|[?!.]+ +\n?", raw)
|
||||
first_line = raw[: sep.end()].strip() if sep else raw
|
||||
starred = False
|
||||
|
||||
if not date:
|
||||
colon_pos = first_line.find(": ")
|
||||
if colon_pos > 0:
|
||||
date = time.parse(
|
||||
raw[:colon_pos],
|
||||
default_hour=self.config["default_hour"],
|
||||
default_minute=self.config["default_minute"],
|
||||
)
|
||||
if date: # Parsed successfully, strip that from the raw text
|
||||
starred = raw[:colon_pos].strip().endswith("*")
|
||||
raw = raw[colon_pos + 1 :].strip()
|
||||
starred = (
|
||||
starred
|
||||
or first_line.startswith("*")
|
||||
or first_line.endswith("*")
|
||||
or raw.startswith("*")
|
||||
)
|
||||
if not date: # Still nothing? Meh, just live in the moment.
|
||||
date = time.parse("now")
|
||||
entry = Entry(self, date, raw, starred=starred)
|
||||
entry.modified = True
|
||||
self.entries.append(entry)
|
||||
if sort:
|
||||
self.sort()
|
||||
return entry
|
||||
|
||||
def editable_str(self) -> str:
|
||||
"""Turns the journal into a string of entries that can be edited
|
||||
manually and later be parsed with self.parse_editable_str."""
|
||||
return "\n".join([str(e) for e in self.entries])
|
||||
|
||||
def parse_editable_str(self, edited: str) -> None:
|
||||
"""Parses the output of self.editable_str and updates it's entries."""
|
||||
mod_entries = self._parse(edited)
|
||||
# Match those entries that can be found in self.entries and set
|
||||
# these to modified, so we can get a count of how many entries got
|
||||
# modified and how many got deleted later.
|
||||
for entry in mod_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
|
||||
|
||||
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)
|
||||
|
||||
def get_change_counts(self) -> dict:
|
||||
return {
|
||||
"added": self.added_entry_count,
|
||||
"deleted": self.deleted_entry_count,
|
||||
"modified": len([e for e in self.entries if e.modified]),
|
||||
}
|
||||
|
||||
|
||||
class LegacyJournal(Journal):
|
||||
"""Legacy class to support opening journals formatted with the jrnl 1.x
|
||||
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."""
|
||||
|
||||
def _parse(self, journal_txt: str) -> list[Entry]:
|
||||
"""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
|
||||
# long the date will be by constructing one
|
||||
date_length = len(datetime.datetime.today().strftime(self.config["timeformat"]))
|
||||
|
||||
# Initialise our current entry
|
||||
entries = []
|
||||
current_entry = None
|
||||
new_date_format_regex = re.compile(r"(^\[[^\]]+\].*?$)")
|
||||
for line in journal_txt.splitlines():
|
||||
line = line.rstrip()
|
||||
try:
|
||||
# try to parse line as date => new entry begins
|
||||
new_date = datetime.datetime.strptime(
|
||||
line[:date_length], self.config["timeformat"]
|
||||
)
|
||||
|
||||
# parsing successful => save old entry and create new one
|
||||
if new_date and current_entry:
|
||||
entries.append(current_entry)
|
||||
|
||||
if line.endswith("*"):
|
||||
starred = True
|
||||
line = line[:-1]
|
||||
else:
|
||||
starred = False
|
||||
|
||||
current_entry = Entry(
|
||||
self, date=new_date, text=line[date_length + 1 :], starred=starred
|
||||
)
|
||||
except ValueError:
|
||||
# Happens when we can't parse the start of the line as an date.
|
||||
# In this case, just append line to our body (after some
|
||||
# escaping for the new format).
|
||||
line = new_date_format_regex.sub(r" \1", line)
|
||||
if current_entry:
|
||||
current_entry.text += line + "\n"
|
||||
|
||||
# Append last entry
|
||||
if current_entry:
|
||||
entries.append(current_entry)
|
||||
for entry in entries:
|
||||
entry._parse_text()
|
||||
return entries
|
||||
|
||||
|
||||
def open_journal(journal_name: str, config: dict, legacy: bool = False) -> Journal:
|
||||
"""
|
||||
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
|
||||
backwards compatibility with jrnl 1.x
|
||||
"""
|
||||
logging.debug(f"open_journal '{journal_name}'")
|
||||
validate_journal_name(journal_name, config)
|
||||
config = config.copy()
|
||||
config["journal"] = expand_path(config["journal"])
|
||||
|
||||
if os.path.isdir(config["journal"]):
|
||||
if config["encrypt"]:
|
||||
print_msg(
|
||||
Message(
|
||||
MsgText.ConfigEncryptedForUnencryptableJournalType,
|
||||
MsgStyle.WARNING,
|
||||
{
|
||||
"journal_name": journal_name,
|
||||
},
|
||||
)
|
||||
)
|
||||
|
||||
if config["journal"].strip("/").endswith(".dayone") or "entries" in os.listdir(
|
||||
config["journal"]
|
||||
):
|
||||
from jrnl.journals import DayOne
|
||||
|
||||
return DayOne(**config).open()
|
||||
else:
|
||||
from jrnl.journals import Folder
|
||||
|
||||
return Folder(journal_name, **config).open()
|
||||
|
||||
if not config["encrypt"]:
|
||||
if legacy:
|
||||
return LegacyJournal(journal_name, **config).open()
|
||||
if config["journal"].endswith(os.sep):
|
||||
from jrnl.journals import Folder
|
||||
|
||||
return Folder(journal_name, **config).open()
|
||||
return Journal(journal_name, **config).open()
|
||||
|
||||
if legacy:
|
||||
config["encrypt"] = "jrnlv1"
|
||||
return LegacyJournal(journal_name, **config).open()
|
||||
return Journal(journal_name, **config).open()
|
|
@ -1,5 +0,0 @@
|
|||
from .DayOneJournal import DayOne
|
||||
from .Entry import Entry
|
||||
from .FolderJournal import Folder
|
||||
from .Journal import Journal
|
||||
from .Journal import open_journal
|
198
jrnl/jrnl.py
Executable file
|
@ -0,0 +1,198 @@
|
|||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
"""
|
||||
jrnl
|
||||
|
||||
license: MIT, see LICENSE for more details.
|
||||
"""
|
||||
|
||||
import Journal
|
||||
from install import *
|
||||
import os
|
||||
import tempfile
|
||||
import subprocess
|
||||
import argparse
|
||||
import sys
|
||||
try: import simplejson as json
|
||||
except ImportError: import json
|
||||
|
||||
|
||||
__title__ = 'jrnl'
|
||||
__version__ = '0.3.0'
|
||||
__author__ = 'Manuel Ebert, Stephan Gabler'
|
||||
__license__ = 'MIT'
|
||||
|
||||
CONFIG_PATH = os.path.expanduser('~/.jrnl_config')
|
||||
PYCRYPTO = module_exists("Crypto")
|
||||
|
||||
def update_config(config):
|
||||
"""Checks if there are keys missing in a given config dict, and if so, updates the config file accordingly.
|
||||
This essentially automatically ports jrnl installations if new config parameters are introduced in later
|
||||
versions."""
|
||||
missing_keys = set(default_config).difference(config)
|
||||
if missing_keys:
|
||||
for key in missing_keys:
|
||||
config[key] = default_config[key]
|
||||
with open(CONFIG_PATH, 'w') as f:
|
||||
json.dump(config, f, indent=2)
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser()
|
||||
composing = parser.add_argument_group('Composing', 'Will make an entry out of whatever follows as arguments')
|
||||
composing.add_argument('-date', dest='date', help='Date, e.g. "yesterday at 5pm"')
|
||||
composing.add_argument('text', metavar='text', nargs="*", help='Log entry (or tags by which to filter in viewing mode)')
|
||||
|
||||
reading = parser.add_argument_group('Reading', 'Specifying either of these parameters will display posts of your journal')
|
||||
reading.add_argument('-from', dest='start_date', metavar="DATE", help='View entries after this date')
|
||||
reading.add_argument('-to', dest='end_date', metavar="DATE", help='View entries before this date')
|
||||
reading.add_argument('-and', dest='strict', action="store_true", help='Filter by tags using AND (default: OR)')
|
||||
reading.add_argument('-n', dest='limit', default=None, metavar="N", help='Shows the last n entries matching the filter', nargs="?", type=int)
|
||||
reading.add_argument('-short', dest='short', action="store_true", help='Show only titles or line containing the search tags')
|
||||
|
||||
exporting = parser.add_argument_group('Export / Import', 'Options for transmogrifying your journal')
|
||||
exporting.add_argument('--tags', dest='tags', action="store_true", help='Returns a list of all tags and number of occurences')
|
||||
exporting.add_argument('--json', dest='json', action="store_true", help='Returns a JSON-encoded version of the Journal')
|
||||
exporting.add_argument('--markdown', dest='markdown', action="store_true", help='Returns a Markdown-formated version of the Journal')
|
||||
exporting.add_argument('--encrypt', metavar='FILENAME', dest='encrypt', help='Encrypts your existing journal with a new password', nargs='?', default=False, const=None)
|
||||
exporting.add_argument('--decrypt', metavar='FILENAME', dest='decrypt', help='Decrypts your journal and stores it in plain text', nargs='?', default=False, const=None)
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
def guess_mode(args, config):
|
||||
"""Guesses the mode (compose, read or export) from the given arguments"""
|
||||
compose = True
|
||||
export = False
|
||||
if args.json or args.decrypt or args.encrypt or args.markdown or args.tags:
|
||||
compose = False
|
||||
export = True
|
||||
elif args.start_date or args.end_date or args.limit or args.strict or args.short:
|
||||
# Any sign of displaying stuff?
|
||||
compose = False
|
||||
elif not args.date and args.text and all(word[0] in config['tagsymbols'] for word in args.text):
|
||||
# No date and only tags?
|
||||
compose = False
|
||||
|
||||
return compose, export
|
||||
|
||||
def get_text_from_editor(config):
|
||||
tmpfile = os.path.join(tempfile.gettempdir(), "jrnl")
|
||||
subprocess.call(config['editor'].split() + [tmpfile])
|
||||
if os.path.exists(tmpfile):
|
||||
with open(tmpfile) as f:
|
||||
raw = f.read()
|
||||
os.remove(tmpfile)
|
||||
else:
|
||||
print('nothing saved to file')
|
||||
raw = ''
|
||||
|
||||
return raw
|
||||
|
||||
|
||||
def encrypt(journal, filename=None):
|
||||
""" Encrypt into new file. If filename is not set, we encrypt the journal file itself. """
|
||||
journal.make_key(prompt="Enter new password:")
|
||||
journal.config['encrypt'] = True
|
||||
journal.config['password'] = ""
|
||||
if not filename:
|
||||
journal.write()
|
||||
journal.save_config(CONFIG_PATH)
|
||||
print("Journal encrypted to %s." % journal.config['journal'])
|
||||
else:
|
||||
journal.write(filename)
|
||||
print("Journal encrypted to %s." % os.path.realpath(filename))
|
||||
|
||||
def decrypt(journal, filename=None):
|
||||
""" Decrypts into new file. If filename is not set, we encrypt the journal file itself. """
|
||||
journal.config['encrypt'] = False
|
||||
journal.config['password'] = ""
|
||||
if not filename:
|
||||
journal.write()
|
||||
journal.save_config()
|
||||
print("Journal decrypted to %s." % journal.config['journal'])
|
||||
else:
|
||||
journal.write(filename)
|
||||
print("Journal encrypted to %s." % os.path.realpath(filename))
|
||||
|
||||
def print_tags(journal):
|
||||
"""Prints a list of all tags and the number of occurances."""
|
||||
# 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.
|
||||
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]
|
||||
tag_counts = {(tags.count(tag), tag) for tag in tags}
|
||||
for n, tag in sorted(tag_counts, reverse=True):
|
||||
print("{:20} : {}".format(tag, n))
|
||||
|
||||
def cli():
|
||||
if not os.path.exists(CONFIG_PATH):
|
||||
config = install_jrnl(CONFIG_PATH)
|
||||
else:
|
||||
with open(CONFIG_PATH) as f:
|
||||
config = json.load(f)
|
||||
update_config(config)
|
||||
|
||||
# check if the configuration is supported by available modules
|
||||
if config['encrypt'] and not PYCRYPTO:
|
||||
print("According to your jrnl_conf, your journal is encrypted, however PyCrypto was not found. To open your journal, install the PyCrypto package from http://www.pycrypto.org.")
|
||||
sys.exit(-1)
|
||||
|
||||
args = parse_args()
|
||||
mode_compose, mode_export = guess_mode(args, config)
|
||||
|
||||
# open journal file
|
||||
journal = Journal.Journal(config=config)
|
||||
|
||||
if mode_compose and not args.text:
|
||||
if config['editor']:
|
||||
raw = get_text_from_editor(config)
|
||||
else:
|
||||
raw = raw_input("Compose Entry: ")
|
||||
if raw:
|
||||
args.text = [raw]
|
||||
else:
|
||||
mode_compose = False
|
||||
|
||||
# Writing mode
|
||||
if mode_compose:
|
||||
raw = " ".join(args.text).strip()
|
||||
journal.new_entry(raw, args.date)
|
||||
print("Entry added.")
|
||||
journal.write()
|
||||
|
||||
# Reading mode
|
||||
elif not mode_export:
|
||||
journal.filter(tags=args.text,
|
||||
start_date=args.start_date, end_date=args.end_date,
|
||||
strict=args.strict,
|
||||
short=args.short)
|
||||
journal.limit(args.limit)
|
||||
print(journal)
|
||||
|
||||
# Various export modes
|
||||
elif args.tags:
|
||||
print_tags(journal)
|
||||
|
||||
elif args.json: # export to json
|
||||
print(journal.to_json())
|
||||
|
||||
elif args.markdown: # export to json
|
||||
print(journal.to_md())
|
||||
|
||||
elif (args.encrypt is not False or args.decrypt is not False) and not PYCRYPTO:
|
||||
print("PyCrypto not found. To encrypt or decrypt your journal, install the PyCrypto package from http://www.pycrypto.org.")
|
||||
|
||||
elif args.encrypt is not False:
|
||||
encrypt(journal, filename=args.encrypt)
|
||||
|
||||
elif args.decrypt is not False:
|
||||
decrypt(journal, filename=args.decrypt)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
cli()
|
||||
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
# 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)
|
88
jrnl/main.py
|
@ -1,88 +0,0 @@
|
|||
# Copyright © 2012-2023 jrnl contributors
|
||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
import logging
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
from rich.logging import RichHandler
|
||||
|
||||
from jrnl import controller
|
||||
from jrnl.args import parse_args
|
||||
from jrnl.exception import JrnlException
|
||||
from jrnl.messages import Message
|
||||
from jrnl.messages import MsgStyle
|
||||
from jrnl.messages import MsgText
|
||||
from jrnl.output import print_msg
|
||||
|
||||
|
||||
def configure_logger(debug: bool = False) -> None:
|
||||
if not debug:
|
||||
logging.disable()
|
||||
return
|
||||
|
||||
logging.basicConfig(
|
||||
level=logging.DEBUG,
|
||||
datefmt="[%X]",
|
||||
format="%(message)s",
|
||||
handlers=[RichHandler()],
|
||||
)
|
||||
logging.getLogger("parsedatetime").setLevel(logging.INFO)
|
||||
logging.getLogger("keyring.backend").setLevel(logging.ERROR)
|
||||
logging.debug("Logging start")
|
||||
|
||||
|
||||
def run(manual_args: list[str] | None = None) -> int:
|
||||
try:
|
||||
if manual_args is None:
|
||||
manual_args = sys.argv[1:]
|
||||
|
||||
args = parse_args(manual_args)
|
||||
configure_logger(args.debug)
|
||||
logging.debug("Parsed args:\n%s", args)
|
||||
|
||||
status_code = controller.run(args)
|
||||
|
||||
except JrnlException as e:
|
||||
status_code = 1
|
||||
e.print()
|
||||
|
||||
except KeyboardInterrupt:
|
||||
status_code = 1
|
||||
|
||||
print_msg(
|
||||
Message(
|
||||
MsgText.KeyboardInterruptMsg,
|
||||
MsgStyle.ERROR_ON_NEW_LINE,
|
||||
)
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
# uncaught exception
|
||||
status_code = 1
|
||||
debug = False
|
||||
try:
|
||||
if args.debug: # type: ignore
|
||||
debug = True
|
||||
except NameError:
|
||||
# This should only happen when the exception
|
||||
# happened before the args were parsed
|
||||
if "--debug" in sys.argv:
|
||||
debug = True
|
||||
|
||||
if debug:
|
||||
from rich.console import Console
|
||||
|
||||
traceback.print_tb(sys.exc_info()[2])
|
||||
Console(stderr=True).print_exception(extra_lines=1)
|
||||
|
||||
print_msg(
|
||||
Message(
|
||||
MsgText.UncaughtException,
|
||||
MsgStyle.ERROR,
|
||||
{"name": type(e).__name__, "exception": e},
|
||||
)
|
||||
)
|
||||
|
||||
# This should be the only exit point
|
||||
return status_code
|
|
@ -1,17 +0,0 @@
|
|||
# Copyright © 2012-2023 jrnl contributors
|
||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import Mapping
|
||||
from typing import NamedTuple
|
||||
|
||||
from jrnl.messages.MsgStyle import MsgStyle
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from jrnl.messages.MsgText import MsgText
|
||||
|
||||
|
||||
class Message(NamedTuple):
|
||||
text: "MsgText"
|
||||
style: MsgStyle = MsgStyle.NORMAL
|
||||
params: Mapping = {}
|
|
@ -1,93 +0,0 @@
|
|||
# Copyright © 2012-2023 jrnl contributors
|
||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
from enum import Enum
|
||||
from typing import Callable
|
||||
from typing import NamedTuple
|
||||
|
||||
from rich import box
|
||||
from rich.panel import Panel
|
||||
|
||||
from jrnl.messages.MsgText import MsgText
|
||||
|
||||
|
||||
class MsgStyle(Enum):
|
||||
class _Color(NamedTuple):
|
||||
"""
|
||||
String representing a standard color to display
|
||||
see: https://rich.readthedocs.io/en/stable/appendix/colors.html
|
||||
"""
|
||||
|
||||
color: str
|
||||
|
||||
class _Decoration(Enum):
|
||||
NONE = {
|
||||
"callback": lambda x, **_: x,
|
||||
"args": {},
|
||||
}
|
||||
BOX = {
|
||||
"callback": Panel,
|
||||
"args": {
|
||||
"expand": False,
|
||||
"padding": (0, 2),
|
||||
"title_align": "left",
|
||||
"box": box.HEAVY,
|
||||
},
|
||||
}
|
||||
|
||||
@property
|
||||
def callback(self) -> Callable:
|
||||
return self.value["callback"]
|
||||
|
||||
@property
|
||||
def args(self) -> dict:
|
||||
return self.value["args"]
|
||||
|
||||
PROMPT = {
|
||||
"decoration": _Decoration.NONE,
|
||||
"color": _Color("white"),
|
||||
"append_space": True,
|
||||
}
|
||||
TITLE = {
|
||||
"decoration": _Decoration.BOX,
|
||||
"color": _Color("cyan"),
|
||||
}
|
||||
NORMAL = {
|
||||
"decoration": _Decoration.BOX,
|
||||
"color": _Color("white"),
|
||||
}
|
||||
WARNING = {
|
||||
"decoration": _Decoration.BOX,
|
||||
"color": _Color("yellow"),
|
||||
}
|
||||
ERROR = {
|
||||
"decoration": _Decoration.BOX,
|
||||
"color": _Color("red"),
|
||||
"box_title": str(MsgText.Error),
|
||||
}
|
||||
ERROR_ON_NEW_LINE = {
|
||||
"decoration": _Decoration.BOX,
|
||||
"color": _Color("red"),
|
||||
"prepend_newline": True,
|
||||
"box_title": str(MsgText.Error),
|
||||
}
|
||||
|
||||
@property
|
||||
def decoration(self) -> _Decoration:
|
||||
return self.value["decoration"]
|
||||
|
||||
@property
|
||||
def color(self) -> _Color:
|
||||
return self.value["color"].color
|
||||
|
||||
@property
|
||||
def prepend_newline(self) -> bool:
|
||||
return self.value.get("prepend_newline", False)
|
||||
|
||||
@property
|
||||
def append_space(self) -> bool:
|
||||
return self.value.get("append_space", False)
|
||||
|
||||
@property
|
||||
def box_title(self) -> MsgText:
|
||||
return self.value.get("box_title")
|
|
@ -1,291 +0,0 @@
|
|||
# Copyright © 2012-2023 jrnl contributors
|
||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class MsgText(Enum):
|
||||
def __str__(self) -> str:
|
||||
return self.value
|
||||
|
||||
# -- Welcome --- #
|
||||
WelcomeToJrnl = """
|
||||
Welcome to jrnl {version}!
|
||||
|
||||
It looks like you've been using an older version of jrnl until now. That's
|
||||
okay - jrnl will now upgrade your configuration and journal files. Afterwards
|
||||
you can enjoy all of the great new features that come with jrnl 2:
|
||||
|
||||
- Support for storing your journal in multiple files
|
||||
- Faster reading and writing for large journals
|
||||
- New encryption back-end that makes installing jrnl much easier
|
||||
- Tons of bug fixes
|
||||
|
||||
Please note that jrnl 1.x is NOT forward compatible with this version of jrnl.
|
||||
If you choose to proceed, you will not be able to use your journals with
|
||||
older versions of jrnl anymore.
|
||||
"""
|
||||
|
||||
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 --- #
|
||||
InstallJournalPathQuestion = """
|
||||
Path to your journal file (leave blank for {default_journal_path}):
|
||||
"""
|
||||
DeleteEntryQuestion = "Delete entry '{entry_title}'?"
|
||||
ChangeTimeEntryQuestion = "Change time for '{entry_title}'?"
|
||||
EncryptJournalQuestion = """
|
||||
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]"
|
||||
YesOrNoPromptDefaultNo = "[y/N]"
|
||||
ContinueUpgrade = "Continue upgrading jrnl?"
|
||||
|
||||
# these should be lowercase, if possible in language
|
||||
# "lowercase" means whatever `.lower()` returns
|
||||
OneCharacterYes = "y"
|
||||
OneCharacterNo = "n"
|
||||
|
||||
# --- Exceptions ---#
|
||||
Error = "Error"
|
||||
UncaughtException = """
|
||||
{name}
|
||||
{exception}
|
||||
|
||||
This is probably a bug. Please file an issue at:
|
||||
https://github.com/jrnl-org/jrnl/issues/new/choose
|
||||
"""
|
||||
|
||||
ConfigDirectoryIsFile = """
|
||||
Problem with config file!
|
||||
The path to your jrnl configuration directory is a file, not a directory:
|
||||
|
||||
{config_directory_path}
|
||||
|
||||
Removing this file will allow jrnl to save its configuration.
|
||||
"""
|
||||
|
||||
CantParseConfigFile = """
|
||||
Unable to parse config file at:
|
||||
{config_path}
|
||||
"""
|
||||
|
||||
LineWrapTooSmallForDateFormat = """
|
||||
The provided linewrap value of {config_linewrap} is too small by
|
||||
{columns} columns to display the timestamps in the configured time
|
||||
format for journal {journal}.
|
||||
|
||||
You can avoid this error by specifying a linewrap value that is larger
|
||||
by at least {columns} in the configuration file or by using
|
||||
--config-override at the command line
|
||||
"""
|
||||
|
||||
CannotEncryptJournalType = """
|
||||
The journal {journal_name} can't be encrypted because it is a
|
||||
{journal_type} journal.
|
||||
|
||||
To encrypt it, create a new journal referencing a file, export
|
||||
this journal to the new journal, then encrypt the new journal.
|
||||
"""
|
||||
|
||||
ConfigEncryptedForUnencryptableJournalType = """
|
||||
The config for journal "{journal_name}" has 'encrypt' set to true, but this type
|
||||
of journal can't be encrypted. Please fix your config file.
|
||||
"""
|
||||
|
||||
DecryptionFailedGeneric = "The decryption of journal data failed."
|
||||
|
||||
KeyboardInterruptMsg = "Aborted by user"
|
||||
|
||||
CantReadTemplate = """
|
||||
Unable to find a template file {template_path}.
|
||||
|
||||
The following paths were checked:
|
||||
* {jrnl_template_dir}{template_path}
|
||||
* {actual_template_path}
|
||||
"""
|
||||
|
||||
NoNamedJournal = "No '{journal_name}' journal configured\n{journals}"
|
||||
|
||||
DoesNotExist = "{name} does not exist"
|
||||
|
||||
# --- Journal status ---#
|
||||
JournalNotSaved = "Entry NOT saved to journal"
|
||||
JournalEntryAdded = "Entry added to {journal_name} journal"
|
||||
|
||||
JournalCountAddedSingular = "{num} entry added"
|
||||
JournalCountModifiedSingular = "{num} entry modified"
|
||||
JournalCountDeletedSingular = "{num} entry deleted"
|
||||
|
||||
JournalCountAddedPlural = "{num} entries added"
|
||||
JournalCountModifiedPlural = "{num} entries modified"
|
||||
JournalCountDeletedPlural = "{num} entries deleted"
|
||||
|
||||
JournalCreated = "Journal '{journal_name}' created at {filename}"
|
||||
DirectoryCreated = "Directory {directory_name} created"
|
||||
JournalEncrypted = "Journal will be encrypted"
|
||||
JournalEncryptedTo = "Journal encrypted to {path}"
|
||||
JournalDecryptedTo = "Journal decrypted to {path}"
|
||||
BackupCreated = "Created a backup at {filename}"
|
||||
|
||||
# --- Editor ---#
|
||||
WritingEntryStart = """
|
||||
Writing Entry
|
||||
To finish writing, press {how_to_quit} on a blank line.
|
||||
"""
|
||||
HowToQuitWindows = "Ctrl+z and then Enter"
|
||||
HowToQuitLinux = "Ctrl+d"
|
||||
|
||||
EditorMisconfigured = """
|
||||
No such file or directory: '{editor_key}'
|
||||
|
||||
Please check the 'editor' key in your config file for errors:
|
||||
editor: '{editor_key}'
|
||||
"""
|
||||
|
||||
EditorNotConfigured = """
|
||||
There is no editor configured
|
||||
|
||||
To use the --edit option, please specify an editor your config file:
|
||||
{config_file}
|
||||
|
||||
For examples of how to configure an external editor, see:
|
||||
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"
|
||||
|
||||
NoTextReceived = """
|
||||
No entry to save, because no text was received
|
||||
"""
|
||||
NoChangesToTemplate = """
|
||||
No entry to save, because the template was not changed
|
||||
"""
|
||||
# --- Upgrade --- #
|
||||
JournalFailedUpgrade = """
|
||||
The following journal{s} failed to upgrade:
|
||||
{failed_journals}
|
||||
|
||||
Please tell us about this problem at the following URL:
|
||||
https://github.com/jrnl-org/jrnl/issues/new?title=JournalFailedUpgrade
|
||||
"""
|
||||
|
||||
UpgradeAborted = "jrnl was NOT upgraded"
|
||||
|
||||
AbortingUpgrade = "Aborting upgrade..."
|
||||
|
||||
ImportAborted = "Entries were NOT imported"
|
||||
|
||||
JournalsToUpgrade = """
|
||||
The following journals will be upgraded to jrnl {version}:
|
||||
|
||||
"""
|
||||
|
||||
JournalsToIgnore = """
|
||||
The following journals will not be touched:
|
||||
|
||||
"""
|
||||
|
||||
UpgradingJournal = """
|
||||
Upgrading '{journal_name}' journal stored in {path}...
|
||||
"""
|
||||
|
||||
UpgradingConfig = "Upgrading config..."
|
||||
|
||||
PaddedJournalName = "{journal_name:{pad}} -> {path}"
|
||||
|
||||
# -- Config --- #
|
||||
AltConfigNotFound = """
|
||||
Alternate configuration file not found at the given path:
|
||||
{config_file}
|
||||
"""
|
||||
|
||||
ConfigUpdated = """
|
||||
Configuration updated to newest version at {config_path}
|
||||
"""
|
||||
|
||||
ConfigDoubleKeys = """
|
||||
There is at least one duplicate key in your configuration file.
|
||||
|
||||
Details:
|
||||
{error_message}
|
||||
"""
|
||||
|
||||
# --- Password --- #
|
||||
Password = "Password:"
|
||||
PasswordFirstEntry = "Enter password for journal '{journal_name}': "
|
||||
PasswordConfirmEntry = "Enter password again: "
|
||||
PasswordMaxTriesExceeded = "Too many attempts with wrong password"
|
||||
PasswordCanNotBeEmpty = "Password can't be empty!"
|
||||
PasswordDidNotMatch = "Passwords did not match, please try again"
|
||||
WrongPasswordTryAgain = "Wrong password, try again"
|
||||
PasswordStoreInKeychain = "Do you want to store the password in your keychain?"
|
||||
|
||||
# --- Search --- #
|
||||
NothingToDelete = """
|
||||
No entries to delete, because the search returned no results
|
||||
"""
|
||||
|
||||
NothingToModify = """
|
||||
No entries to modify, because the search returned no results
|
||||
"""
|
||||
|
||||
NoEntriesFound = "no entries found"
|
||||
EntryFoundCountSingular = "{num} entry found"
|
||||
EntryFoundCountPlural = "{num} entries found"
|
||||
|
||||
# --- Formats --- #
|
||||
HeadingsPastH6 = """
|
||||
Headings increased past H6 on export - {date} {title}
|
||||
"""
|
||||
|
||||
YamlMustBeDirectory = """
|
||||
YAML export must be to a directory, not a single file
|
||||
"""
|
||||
|
||||
JournalExportedTo = "Journal exported to {path}"
|
||||
|
||||
# --- Import --- #
|
||||
ImportSummary = """
|
||||
{count} imported to {journal_name} journal
|
||||
"""
|
||||
|
||||
ImporterNotFound = """
|
||||
No importer found for file type '{format}'.
|
||||
'{format}' is likely to be an export-only format.
|
||||
"""
|
||||
|
||||
# --- Color --- #
|
||||
InvalidColor = "{key} set to invalid color: {color}"
|
||||
|
||||
# --- Keyring --- #
|
||||
KeyringBackendNotFound = """
|
||||
Keyring backend not found.
|
||||
|
||||
Please install one of the supported backends by visiting:
|
||||
https://pypi.org/project/keyring/
|
||||
"""
|
||||
|
||||
KeyringRetrievalFailure = "Failed to retrieve keyring"
|
||||
|
||||
# --- Deprecation --- #
|
||||
DeprecatedCommand = """
|
||||
The command {old_cmd} is deprecated and will be removed from jrnl soon.
|
||||
Please use {new_cmd} instead.
|
||||
"""
|
|
@ -1,10 +0,0 @@
|
|||
# Copyright © 2012-2023 jrnl contributors
|
||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
from jrnl.messages import Message
|
||||
from jrnl.messages import MsgStyle
|
||||
from jrnl.messages import MsgText
|
||||
|
||||
Message = Message.Message
|
||||
MsgStyle = MsgStyle.MsgStyle
|
||||
MsgText = MsgText.MsgText
|
|
@ -1,18 +0,0 @@
|
|||
# Copyright © 2012-2023 jrnl contributors
|
||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
import shlex
|
||||
from sys import platform
|
||||
|
||||
|
||||
def on_windows() -> bool:
|
||||
return "win32" in platform
|
||||
|
||||
|
||||
def on_posix() -> bool:
|
||||
return not on_windows()
|
||||
|
||||
|
||||
def split_args(args: str) -> list[str]:
|
||||
"""Split arguments and add escape characters as appropriate for the OS"""
|
||||
return shlex.split(args, posix=on_posix())
|
142
jrnl/output.py
|
@ -1,142 +0,0 @@
|
|||
# Copyright © 2012-2023 jrnl contributors
|
||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
import textwrap
|
||||
from typing import Callable
|
||||
|
||||
from rich.console import Console
|
||||
from rich.text import Text
|
||||
|
||||
from jrnl.messages import Message
|
||||
from jrnl.messages import MsgStyle
|
||||
from jrnl.messages import MsgText
|
||||
|
||||
|
||||
def deprecated_cmd(
|
||||
old_cmd: str, new_cmd: str, callback: Callable | None = None, **kwargs
|
||||
) -> None:
|
||||
print_msg(
|
||||
Message(
|
||||
MsgText.DeprecatedCommand,
|
||||
MsgStyle.WARNING,
|
||||
{"old_cmd": old_cmd, "new_cmd": new_cmd},
|
||||
)
|
||||
)
|
||||
|
||||
if callback is not None:
|
||||
callback(**kwargs)
|
||||
|
||||
|
||||
def journal_list_to_json(journal_list: dict) -> str:
|
||||
import json
|
||||
|
||||
return json.dumps(journal_list)
|
||||
|
||||
|
||||
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(
|
||||
journal, ml, cfg["journal"] if isinstance(cfg, dict) else cfg
|
||||
)
|
||||
return result
|
||||
|
||||
|
||||
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"""
|
||||
kwargs["style"] = msg.style
|
||||
return print_msgs([msg], **kwargs)
|
||||
|
||||
|
||||
def print_msgs(
|
||||
msgs: list[Message],
|
||||
delimiter: str = "\n",
|
||||
style: MsgStyle = MsgStyle.NORMAL,
|
||||
get_input: bool = False,
|
||||
hide_input: bool = False,
|
||||
) -> str | None:
|
||||
# Same as print_msg, but for a list
|
||||
text = Text("", end="")
|
||||
kwargs = style.decoration.args
|
||||
|
||||
for i, msg in enumerate(msgs):
|
||||
kwargs = _add_extra_style_args_if_needed(kwargs, msg=msg)
|
||||
|
||||
m = format_msg_text(msg)
|
||||
|
||||
if i != len(msgs) - 1:
|
||||
m.append(delimiter)
|
||||
|
||||
text.append(m)
|
||||
|
||||
if style.append_space:
|
||||
text.append(" ")
|
||||
|
||||
decorated_text = style.decoration.callback(text, **kwargs)
|
||||
|
||||
# Always print messages to stderr
|
||||
console = _get_console(stderr=True)
|
||||
|
||||
if get_input:
|
||||
return str(console.input(prompt=decorated_text, password=hide_input))
|
||||
console.print(decorated_text, new_line_start=style.prepend_newline)
|
||||
|
||||
|
||||
def _get_console(stderr: bool = True) -> Console:
|
||||
return Console(stderr=stderr)
|
||||
|
||||
|
||||
def _add_extra_style_args_if_needed(args: dict, msg: Message):
|
||||
args["border_style"] = msg.style.color
|
||||
args["title"] = msg.style.box_title
|
||||
return args
|
||||
|
||||
|
||||
def format_msg_text(msg: Message) -> Text:
|
||||
text = textwrap.dedent(msg.text.value)
|
||||
text = text.format(**msg.params)
|
||||
# dedent again in case inserted text needs it
|
||||
text = textwrap.dedent(text)
|
||||
text = text.strip()
|
||||
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()
|
|
@ -1,79 +0,0 @@
|
|||
# Copyright © 2012-2023 jrnl contributors
|
||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from jrnl.config import make_yaml_valid_dict
|
||||
from jrnl.config import update_config
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from argparse import Namespace
|
||||
|
||||
|
||||
# import logging
|
||||
def apply_overrides(args: "Namespace", base_config: dict) -> dict:
|
||||
"""Unpack CLI provided overrides into the configuration tree.
|
||||
|
||||
:param overrides: List of configuration key-value pairs collected from the CLI
|
||||
:type overrides: list
|
||||
:param base_config: Configuration Loaded from the saved YAML
|
||||
:type base_config: dict
|
||||
:return: Configuration to be used during runtime with the overrides applied
|
||||
:rtype: dict
|
||||
"""
|
||||
overrides = vars(args).get("config_override")
|
||||
if not overrides:
|
||||
return base_config
|
||||
|
||||
cfg_with_overrides = base_config.copy()
|
||||
for pairs in overrides:
|
||||
pairs = make_yaml_valid_dict(pairs)
|
||||
key_as_dots, override_value = _get_key_and_value_from_pair(pairs)
|
||||
keys = _convert_dots_to_list(key_as_dots)
|
||||
cfg_with_overrides = _recursively_apply(
|
||||
cfg_with_overrides, keys, override_value
|
||||
)
|
||||
|
||||
update_config(base_config, cfg_with_overrides, None)
|
||||
return base_config
|
||||
|
||||
|
||||
def _get_key_and_value_from_pair(pairs: dict) -> tuple:
|
||||
key_as_dots, override_value = list(pairs.items())[0]
|
||||
return key_as_dots, override_value
|
||||
|
||||
|
||||
def _convert_dots_to_list(key_as_dots: str) -> list[str]:
|
||||
keys = key_as_dots.split(".")
|
||||
keys = [k for k in keys if k != ""] # remove empty elements
|
||||
return keys
|
||||
|
||||
|
||||
def _recursively_apply(tree: dict, nodes: list, override_value) -> dict:
|
||||
"""Recurse through configuration and apply overrides at the leaf of the config tree
|
||||
|
||||
Credit to iJames on SO: https://stackoverflow.com/a/47276490 for algorithm
|
||||
|
||||
Args:
|
||||
config (dict): Configuration to modify
|
||||
nodes (list): Vector of override keys; the length of the vector indicates tree
|
||||
depth
|
||||
override_value (str): Runtime override passed from the command-line
|
||||
"""
|
||||
key = nodes[0]
|
||||
if len(nodes) == 1:
|
||||
tree[key] = override_value
|
||||
else:
|
||||
next_key = nodes[1:]
|
||||
next_node = _get_config_node(tree, key)
|
||||
_recursively_apply(next_node, next_key, override_value)
|
||||
|
||||
return tree
|
||||
|
||||
|
||||
def _get_config_node(config: dict, key: str):
|
||||
if key in config:
|
||||
pass
|
||||
else:
|
||||
config[key] = None
|
||||
return config[key]
|
72
jrnl/path.py
|
@ -1,72 +0,0 @@
|
|||
# Copyright © 2012-2023 jrnl contributors
|
||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
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() -> str:
|
||||
return os.path.expanduser("~")
|
||||
|
||||
|
||||
def expand_path(path: str) -> str:
|
||||
return os.path.expanduser(os.path.expandvars(path))
|
||||
|
||||
|
||||
def absolute_path(path: str) -> str:
|
||||
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)
|
|
@ -1,50 +0,0 @@
|
|||
# Copyright © 2012-2023 jrnl contributors
|
||||
# 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.fancy_exporter import FancyExporter
|
||||
from jrnl.plugins.jrnl_importer import JRNLImporter
|
||||
from jrnl.plugins.json_exporter import JSONExporter
|
||||
from jrnl.plugins.markdown_exporter import MarkdownExporter
|
||||
from jrnl.plugins.tag_exporter import TagExporter
|
||||
from jrnl.plugins.text_exporter import TextExporter
|
||||
from jrnl.plugins.xml_exporter import XMLExporter
|
||||
from jrnl.plugins.yaml_exporter import YAMLExporter
|
||||
|
||||
__exporters = [
|
||||
CalendarHeatmapExporter,
|
||||
DatesExporter,
|
||||
FancyExporter,
|
||||
JSONExporter,
|
||||
MarkdownExporter,
|
||||
TagExporter,
|
||||
TextExporter,
|
||||
XMLExporter,
|
||||
YAMLExporter,
|
||||
]
|
||||
__importers = [JRNLImporter]
|
||||
|
||||
__exporter_types = {name: plugin for plugin in __exporters for name in plugin.names}
|
||||
__exporter_types["pretty"] = None
|
||||
__exporter_types["short"] = None
|
||||
__importer_types = {name: plugin for plugin in __importers for name in plugin.names}
|
||||
|
||||
EXPORT_FORMATS = sorted(__exporter_types.keys())
|
||||
IMPORT_FORMATS = sorted(__importer_types.keys())
|
||||
|
||||
|
||||
def get_exporter(format: str) -> Type[TextExporter] | None:
|
||||
for exporter in __exporters:
|
||||
if hasattr(exporter, "names") and format in exporter.names:
|
||||
return exporter
|
||||
return None
|
||||
|
||||
|
||||
def get_importer(format: str) -> Type[JRNLImporter] | None:
|
||||
for importer in __importers:
|
||||
if hasattr(importer, "names") and format in importer.names:
|
||||
return importer
|
||||
return None
|
|
@ -1,117 +0,0 @@
|
|||
# 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)
|