diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..b834943 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,26 @@ +{ + "name": "Project Devcontainer", + "image": "python:3.10-bookworm", + "customizations": { + "vscode": { + "settings": { + "editor.wordWrapColumn": 79, + "editor.wordWrap": "bounded" + + }, + "extensions": [ + "streetsidesoftware.code-spell-checker", + "adpyke.codesnap", + "Shinotatwu-DS.file-tree-generator", + "yzhang.markdown-all-in-one", + "DavidAnson.vscode-markdownlint", + "vscode-icons-team.vscode-icons", + "ms-azuretools.vscode-docker", + "ms-vscode.makefile-tools", + "njpwerner.autodocstring", + "ms-python.python", + "ms-python.debugpy" + ] + } + } +} diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..2bfb158 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,67 @@ +# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners + +# This is a comment. +# Each line is a file pattern followed by one or more owners. + +# These owners will be the default owners for everything in +# the repo. Unless a later match takes precedence, +# @global-owner1 and @global-owner2 will be requested for +# review when someone opens a pull request. +* @global-owner1 @global-owner2 + +# Order is important; the last matching pattern takes the most +# precedence. When someone opens a pull request that only +# modifies JS files, only @js-owner and not the global +# owner(s) will be requested for a review. +*.js @js-owner #This is an inline comment. + +# You can also use email addresses if you prefer. They'll be +# used to look up users just like we do for commit author +# emails. +*.go docs@example.com + +# Teams can be specified as code owners as well. Teams should +# be identified in the format @org/team-name. Teams must have +# explicit write access to the repository. In this example, +# the octocats team in the octo-org organization owns all .txt files. +*.txt @octo-org/octocats + +# In this example, @doctocat owns any files in the build/logs +# directory at the root of the repository and any of its +# subdirectories. +/build/logs/ @doctocat + +# The `docs/*` pattern will match files like +# `docs/getting-started.md` but not further nested files like +# `docs/build-app/troubleshooting.md`. +docs/* docs@example.com + +# In this example, @octocat owns any file in an apps directory +# anywhere in your repository. +apps/ @octocat + +# In this example, @doctocat owns any file in the `/docs` +# directory in the root of your repository and any of its +# subdirectories. +/docs/ @doctocat + +# In this example, any change inside the `/scripts` directory +# will require approval from @doctocat or @octocat. +/scripts/ @doctocat @octocat + +# In this example, @octocat owns any file in a `/logs` directory such as +# `/build/logs`, `/scripts/logs`, and `/deeply/nested/logs`. Any changes +# in a `/logs` directory will require approval from @octocat. +**/logs @octocat + +# In this example, @octocat owns any file in the `/apps` +# directory in the root of your repository except for the `/apps/github` +# subdirectory, as its owners are left empty. +/apps/ @octocat +/apps/github + +# In this example, @octocat owns any file in the `/apps` +# directory in the root of your repository except for the `/apps/github` +# subdirectory, as this subdirectory has its own owner @doctocat +/apps/ @octocat +/apps/github @doctocat diff --git a/docs/.nojekyll b/.github/CODE_OF_CONDUCT.md similarity index 100% rename from docs/.nojekyll rename to .github/CODE_OF_CONDUCT.md diff --git a/setup.cfg b/.github/CONTRIBUTING.md similarity index 100% rename from setup.cfg rename to .github/CONTRIBUTING.md diff --git a/.github/DISCUSSION_TEMPLATE/EXAMPLE.yml b/.github/DISCUSSION_TEMPLATE/EXAMPLE.yml new file mode 100644 index 0000000..d8b33dc --- /dev/null +++ b/.github/DISCUSSION_TEMPLATE/EXAMPLE.yml @@ -0,0 +1,57 @@ +# https://docs.github.com/en/discussions/managing-discussions-for-your-community/syntax-for-discussion-category-forms + +title: "[General] " +labels: ["General Introduction"] +body: + - type: markdown + attributes: + value: | + This is text that will show up in the template! + - type: textarea + id: improvements + attributes: + label: Top 3 improvements + description: "What are the top 3 improvements we could make to this project?" + value: | + 1. + 2. + 3. + ... + render: bash + validations: + required: true + - type: markdown + attributes: + value: | + ## Markdown header + And some more markdown + - type: input + id: has-id + attributes: + label: Suggestions + description: A description about suggestions to help you + validations: + required: true + - type: dropdown + id: download + attributes: + label: Which area of this project could be most improved? + options: + - Documentation + - Pull request review time + - Bug fix time + - Release cadence + validations: + required: true + - type: checkboxes + attributes: + label: Check that box! + options: + - label: This one! + required: true + - label: I won't stop you if you check this one, too + - type: markdown + attributes: + value: | + ### The thrilling conclusion + _to our template_ diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..e69de29 diff --git a/.github/GOVERNANCE.md b/.github/GOVERNANCE.md new file mode 100644 index 0000000..e69de29 diff --git a/.github/ISSUE_TEMPLATE/EXAMPLE.yml b/.github/ISSUE_TEMPLATE/EXAMPLE.yml new file mode 100644 index 0000000..2e27330 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/EXAMPLE.yml @@ -0,0 +1,66 @@ +# https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/configuring-issue-templates-for-your-repository + +name: Bug Report +description: File a bug report. +title: "[Bug]: " +labels: ["bug", "triage"] +projects: ["octo-org/1", "octo-org/44"] +assignees: + - octocat +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this bug report! + - type: input + id: contact + attributes: + label: Contact Details + description: How can we get in touch with you if we need more info? + placeholder: ex. email@example.com + validations: + required: false + - type: textarea + id: what-happened + attributes: + label: What happened? + description: Also tell us, what did you expect to happen? + placeholder: Tell us what you see! + value: "A bug happened!" + validations: + required: true + - type: dropdown + id: version + attributes: + label: Version + description: What version of our software are you running? + options: + - 1.0.2 (Default) + - 1.0.3 (Edge) + default: 0 + validations: + required: true + - type: dropdown + id: browsers + attributes: + label: What browsers are you seeing the problem on? + multiple: true + options: + - Firefox + - Chrome + - Safari + - Microsoft Edge + - type: textarea + id: logs + attributes: + label: Relevant log output + description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. + render: shell + - type: checkboxes + id: terms + attributes: + label: Code of Conduct + description: By submitting this issue, you agree to follow our [Code of Conduct](https://example.com). + options: + - label: I agree to follow this project's Code of Conduct + required: true diff --git a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md new file mode 100644 index 0000000..b6e1f9d --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md @@ -0,0 +1,5 @@ + + +# Example + +Hello World diff --git a/.github/SECURITY.md b/.github/SECURITY.md new file mode 100644 index 0000000..e69de29 diff --git a/.github/SUPPORT.md b/.github/SUPPORT.md new file mode 100644 index 0000000..e69de29 diff --git a/.github/actions/example.yml b/.github/actions/example.yml new file mode 100644 index 0000000..15a61d6 --- /dev/null +++ b/.github/actions/example.yml @@ -0,0 +1,18 @@ +name: GitHub Actions Demo +run-name: ${{ github.actor }} is testing out GitHub Actions 🚀 +on: [push] +jobs: + Explore-GitHub-Actions: + runs-on: ubuntu-latest + steps: + - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." + - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" + - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." + - name: Check out repository code + uses: actions/checkout@v4 + - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." + - run: echo "🖥️ The workflow is now ready to test your code on the runner." + - name: List files in the repository + run: | + ls ${{ github.workspace }} + - run: echo "🍏 This job's status is ${{ job.status }}." diff --git a/.gitignore b/.gitignore index 3db99aa..a63c512 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,6 @@ __pycache__/ # Distribution / packaging .Python -env/ build/ develop-eggs/ dist/ @@ -20,9 +19,12 @@ lib64/ parts/ sdist/ var/ +wheels/ +share/python-wheels/ *.egg-info/ .installed.cfg *.egg +MANIFEST # PyInstaller # Usually these files are written by a python script from a template @@ -37,13 +39,17 @@ pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ +.nox/ .coverage .coverage.* .cache nosetests.xml coverage.xml -*,cover +*.cover +*.py,cover .hypothesis/ +.pytest_cache/ +cover/ # Translations *.mo @@ -52,6 +58,8 @@ coverage.xml # Django stuff: *.log local_settings.py +db.sqlite3 +db.sqlite3-journal # Flask stuff: instance/ @@ -64,65 +72,90 @@ instance/ docs/_build/ # PyBuilder +.pybuilder/ target/ -# IPython Notebook +# Jupyter Notebook .ipynb_checkpoints -# pyenv -.python-version +# IPython +profile_default/ +ipython_config.py -# celery beat schedule file +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff celerybeat-schedule +celerybeat.pid -# dotenv -.env +# SageMath parsed files +*.sage.py -# virtualenv +# Environments +.env +.venv +env/ venv/ ENV/ +env.bak/ +venv.bak/ # Spyder project settings .spyderproject +.spyproject # Rope project settings .ropeproject -# ZettelGeist Ignores -data/ -zettels.db +# mkdocs documentation +/site -# OS X Junk -.DS_Store - -*.class -*.log -*~ - -# vim -*.swp -*.swo - -# sbt specific -.cache -.history -.lib/ -dist/* -target/ -lib_managed/ -src_managed/ -project/boot/ -project/plugins/project/ -scala-2.10/ -scala-2.11/ +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json -# Scala-IDE specific -.scala_dependencies -.worksheet -.idea/ +# Pyre type checker +.pyre/ +# pytype static type analyzer +.pytype/ -# Temporary folders +# Cython debug symbols +cython_debug/ -scratch/ -.vscode/ +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ +build-docs/* diff --git a/.isort.cfg b/.isort.cfg new file mode 100644 index 0000000..8b65abd --- /dev/null +++ b/.isort.cfg @@ -0,0 +1,8 @@ +[settings] +profile = black +multi_line_output = 3 +include_trailing_comma = True +force_grid_wrap = 0 +use_parentheses = True +ensure_newline_before_comments = True +line_length = 79 diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 0000000..985d358 --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,5 @@ +{ + "MD007": false, + "MD013": false, + "MD030": false +} diff --git a/.mdformat.toml b/.mdformat.toml new file mode 100644 index 0000000..1cdb3e2 --- /dev/null +++ b/.mdformat.toml @@ -0,0 +1,2 @@ +wrap = 80 +number = false diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..7bd6ee4 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,64 @@ +default_language_version: + python: python3.10 +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: check-added-large-files + - id: check-case-conflict + - id: check-json + - id: check-shebang-scripts-are-executable + - id: check-merge-conflict + - id: check-symlinks + - id: check-toml + # - id: check-vcs-permalinks + - id: check-xml + - id: check-yaml + - id: debug-statements + - id: destroyed-symlinks + - id: detect-private-key + - id: end-of-file-fixer + - id: requirements-txt-fixer + - id: sort-simple-yaml + - id: trailing-whitespace + + - repo: https://github.com/regebro/pyroma + rev: "4.2" + hooks: + - id: pyroma + files: '\.toml$' + + - repo: https://github.com/PyCQA/isort + rev: 5.13.2 + hooks: + - id: isort + files: '\.py$' + + - repo: https://github.com/psf/black + rev: 23.12.1 + hooks: + - id: black + files: '\.py$' + + - repo: https://github.com/pycqa/flake8 + rev: 7.1.0 + hooks: + - id: flake8 + files: '\.py$' + + - repo: https://github.com/PyCQA/bandit + rev: 1.7.9 + hooks: + - id: bandit + files: '\.py$' + + - repo: https://github.com/executablebooks/mdformat + rev: 0.7.17 + hooks: + - id: mdformat + files: '\.md$' + additional_dependencies: + - mdformat-black + - mdformat-gfm + - mdformat-tables + - mdformat-toc diff --git a/BETA.md b/BETA.md deleted file mode 100644 index 5e2b4b0..0000000 --- a/BETA.md +++ /dev/null @@ -1,21 +0,0 @@ -These are some quick notes for the beta. - -Beginning July 17, 2017, we will be placing emphasis on packaging and being able to "use" the tools, even as they are -being created. - -Before beginnign a session, you should set up your environment variables. This is done by sourcing the `setpath.sh` -script as follows: - -```shell -cd zettelgeist -source setpath.sh -``` - -You can also put this in your `.bashrc` (or equivalent, e.g. .zshrc) if you wish to avoid re-running it each time you -start a new terminal session, using your favorite text editor. - -Once you have made these settings, you can run any of the ZettelGeist commands, e.g. `zcreate`, `zimport`, and the like. -Not all commands are available yet but will be soon. - -To find out what commands are available, you can `ls zettelgeist/bin` to see what commands are available. - diff --git a/CITATION.cff b/CITATION.cff new file mode 100644 index 0000000..4916b97 --- /dev/null +++ b/CITATION.cff @@ -0,0 +1 @@ +# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-citation-files diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fe585e3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1 @@ +FROM python:3.10-bookworm diff --git a/LICENSE b/LICENSE index 8dada3e..0ad25db 100644 --- a/LICENSE +++ b/LICENSE @@ -1,201 +1,661 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are 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. + + 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. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + 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 Affero 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. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + 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 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 work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero 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 Affero 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 Affero 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 Affero 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. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + 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 AGPL, see +. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c7b7e2a --- /dev/null +++ b/Makefile @@ -0,0 +1,20 @@ +build: + poetry build + pip install dist/*.tar.gz + +build-docs: + sphinx-build --builder html src-docs build-docs + +create-dev: + pre-commit install + rm -rf env + python3.10 -m venv env + ( \ + . env/bin/activate; \ + pip install -r requirements.txt; \ + poetry install; \ + deactivate; \ + ) + +create-docs: + sphinx-apidoc src --output-dir src-docs --maxdepth 100 --separate diff --git a/README.md b/README.md index 4456a0c..6d2406d 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,36 @@ -# ZettelGeist +# Python Template Repository -ZettelGeist is a plaintext notetaking system inspired by the Zettelkasten approach. +> A template repository that Python projects can inherit from to ensure tooling +> consistency -# Build Status +## Table of Contents -Coming soon. We are migrating from Travis-CI to GitHub Actions. +- [Python Template Repository](#python-template-repository) + - [Table of Contents](#table-of-contents) + - [About](#about) + - [Supported Tooling](#supported-tooling) -# Getting Started +## About -Please see the [ZettelGeist Wiki](https://github.com/ZettelGeist/zettelgeist/wiki) for detailed installation and usage instructions. +This is a template repository that is intended to be inherited by other template +repositories *to ensure consistent common tool deployment across languages*. +This will also support *optional* tooling that services like GitHub offer in +order to provide repository owners access to these features without them having +to discover it themselves. + +## Supported Tooling + +The following tooling is supported: + +- [Base Template Tooling](https://github.com/NicholasSynovic/template_base) +- [Python .gitignore](.gitignore) +- [Pypi Requirements](requirements.txt) + - [Poetry](.pyproject.toml) + - Sphinx +- [Python pre-commit hooks](.pre-commit-config.yaml) + - Pyroma + - [isort](.isort.cfg) + - Black + - Flake8 + - Bandit diff --git a/adhoc/convert-dbd.py b/adhoc/convert-dbd.py deleted file mode 100644 index fb8ed10..0000000 --- a/adhoc/convert-dbd.py +++ /dev/null @@ -1,61 +0,0 @@ -import yaml -import os -import sys - -dir = sys.argv[1] -files = os.listdir(dir) - -def process(filename): - print("Processing %s" % filename) - (base, ext) = os.path.splitext(filename) - ICONV='iconv -f iso8859-1 -t utf-8 "%(base)s%(ext)s" > "%(base)s.utf8%(ext)s"' % vars() - print("Running",ICONV) - os.system(ICONV) - filename = "%(base)s.utf8%(ext)s" % vars() - #os.system(ICONV) - lines = [] - with open(filename) as infile: - id = infile.readline() - print("Doc ID %s" % id) - lines.append( ('id', id) ) - for line in infile: - kwline = line.strip() - if len(kwline) == 0: - continue - if kwline.startswith('#""'): - lines.append( ('bibkey', kwline[3:])) - elif kwline.startswith('#'): - lines.append( ('tag', kwline[1:])) - else: - lines.append( ('text', line) ) - - doc = { 'id': "", 'tags': [], 'bibkey' : [], 'text' : [] } - for (code, text) in lines: - if code == 'id': - doc['id'] = text.strip() - elif code == 'tag': - doc['tags'].append(text.strip()) - elif code == 'bibkey': - doc['bibkey'].append(text.strip()) - elif code == 'text': - doc['text'].append(text) - - doc['text'] = "\n".join(doc['text']) - - (basename, extension) = os.path.splitext(filename) - outfilename = basename + '.yaml' - with open(outfilename, "w") as outfile: - outfile.write(doc['id'] + '\n') - outfile.write('---\n') - del(doc['id']) - outfile.write(yaml.dump(doc)) - - -for f in files: - if f.endswith('.md'): - if not f.endswith('.utf8.md'): - process( os.path.join(dir, f) ) - else: - print("Skipping generated UTF-8 file", f) - - diff --git a/bin/zcreate b/bin/zcreate deleted file mode 100755 index f2c1f60..0000000 --- a/bin/zcreate +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env python3 - -from zettelgeist import zcreate - -zcreate.main() diff --git a/bin/zettel b/bin/zettel deleted file mode 100755 index 40fee23..0000000 --- a/bin/zettel +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env python3 - -from zettelgeist import zettel - -zettel.main() diff --git a/bin/zfind b/bin/zfind deleted file mode 100755 index 9dfb65e..0000000 --- a/bin/zfind +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env python3 - -from zettelgeist import zfind - -zfind.main() diff --git a/bin/zimport b/bin/zimport deleted file mode 100755 index 3972e7e..0000000 --- a/bin/zimport +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env python3 - -from zettelgeist import zimport - -zimport.main() diff --git a/deprecated/docs/Gemfile b/deprecated/docs/Gemfile deleted file mode 100644 index c5eafb3..0000000 --- a/deprecated/docs/Gemfile +++ /dev/null @@ -1,28 +0,0 @@ -source "https://rubygems.org" -ruby RUBY_VERSION - -# Hello! This is where you manage which Jekyll version is used to run. -# When you want to use a different version, change it below, save the -# file and run `bundle install`. Run Jekyll with `bundle exec`, like so: -# -# bundle exec jekyll serve -# -# This will help ensure the proper Jekyll version is running. -# Happy Jekylling! -gem "jekyll", "3.6.3" - -# This is the default theme for new Jekyll sites. You may change this to anything you like. -gem "minima", "~> 2.0" - -# If you want to use GitHub Pages, remove the "gem "jekyll"" above and -# uncomment the line below. To upgrade, run `bundle update github-pages`. -# gem "github-pages", group: :jekyll_plugins - -# If you have any plugins, put them here! -group :jekyll_plugins do - gem "jekyll-feed", "~> 0.6" -end - -# Windows does not include zoneinfo files, so bundle the tzinfo-data gem -gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] - diff --git a/deprecated/docs/Gemfile.lock b/deprecated/docs/Gemfile.lock deleted file mode 100644 index a5a8656..0000000 --- a/deprecated/docs/Gemfile.lock +++ /dev/null @@ -1,61 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - addressable (2.7.0) - public_suffix (>= 2.0.2, < 5.0) - colorator (1.1.0) - ffi (1.11.1) - forwardable-extended (2.6.0) - jekyll (3.6.3) - addressable (~> 2.4) - colorator (~> 1.0) - jekyll-sass-converter (~> 1.0) - jekyll-watch (~> 1.1) - kramdown (~> 1.14) - liquid (~> 4.0) - mercenary (~> 0.3.3) - pathutil (~> 0.9) - rouge (>= 1.7, < 3) - safe_yaml (~> 1.0) - jekyll-feed (0.9.2) - jekyll (~> 3.3) - jekyll-sass-converter (1.5.2) - sass (~> 3.4) - jekyll-watch (1.5.1) - listen (~> 3.0) - kramdown (1.17.0) - liquid (4.0.3) - listen (3.2.0) - rb-fsevent (~> 0.10, >= 0.10.3) - rb-inotify (~> 0.9, >= 0.9.10) - mercenary (0.3.6) - minima (2.1.1) - jekyll (~> 3.3) - pathutil (0.16.2) - forwardable-extended (~> 2.6) - public_suffix (4.0.1) - rb-fsevent (0.10.3) - rb-inotify (0.10.0) - ffi (~> 1.0) - rouge (2.2.1) - safe_yaml (1.0.5) - sass (3.7.4) - sass-listen (~> 4.0.0) - sass-listen (4.0.0) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - -PLATFORMS - ruby - -DEPENDENCIES - jekyll (= 3.6.3) - jekyll-feed (~> 0.6) - minima (~> 2.0) - tzinfo-data - -RUBY VERSION - ruby 2.4.1p111 - -BUNDLED WITH - 1.15.0 diff --git a/deprecated/docs/_config.yml b/deprecated/docs/_config.yml deleted file mode 100644 index d9c8ce7..0000000 --- a/deprecated/docs/_config.yml +++ /dev/null @@ -1,32 +0,0 @@ -# Welcome to Jekyll! -# -# This config file is meant for settings that affect your whole blog, values -# which you are expected to set up once and rarely edit after that. If you find -# yourself editing this file very often, consider using Jekyll's data files -# feature for the data you need to update frequently. -# -# For technical reasons, this file is *NOT* reloaded automatically when you use -# 'bundle exec jekyll serve'. If you change this file, please restart the server process. - -# Site settings -# These are used to personalize your new site. If you look in the HTML files, -# you will see them accessed via {{ site.title }}, {{ site.email }}, and so on. -# You can create any custom variable you would like, and they will be accessible -# in the templates via {{ site.myvariable }}. -title: ZettelGeist -email: thiruvathukal@gmail.com -description: > # this means to ignore newlines until "baseurl:" - ZettelGeist is a notetaking system based on ZettelKasten system for notetaking. -baseurl: "" # the subpath of your site, e.g. /blog -url: "" # the base hostname & protocol for your site, e.g. http://example.com -twitter_username: tbd -github_username: ZettelGeist - -# Build settings -markdown: kramdown -theme: minima -gems: - - jekyll-feed -exclude: - - Gemfile - - Gemfile.lock diff --git a/deprecated/docs/_posts/2017-05-28-welcome-to-zettelgeist.markdown b/deprecated/docs/_posts/2017-05-28-welcome-to-zettelgeist.markdown deleted file mode 100644 index d5f4498..0000000 --- a/deprecated/docs/_posts/2017-05-28-welcome-to-zettelgeist.markdown +++ /dev/null @@ -1,19 +0,0 @@ ---- -layout: post -title: "Welcome to ZettelGeist" -date: 2017-05-28 23:21:33 -0500 -categories: zettelgeist update ---- - -Welcome to our project. We are still in the formative stages, especially when it comes to our web site. Luckily, it has become really easy to make -web sites for GitHub projects, simply by putting Markdown for your Jekyll site in the `/docs` folder. Whoa! - -As we haven't really built a beautiful landing page, this post is aimed at helping you find items of interest. - -- GitHub Repository: [zettelgeist-repo][zettelgeist-repo] -- Developer Mailing List: _coming soon_ - -If you are interested in our project, please join the mailing list when it becomes available. -We will also have a list of projects on this site shortly. - -[zettelgeist-repo]: https://github.com/ZettelGeist/zettelgeist diff --git a/deprecated/docs/_posts/2021-05-01-see-wiki.markdown b/deprecated/docs/_posts/2021-05-01-see-wiki.markdown deleted file mode 100644 index 85dde90..0000000 --- a/deprecated/docs/_posts/2021-05-01-see-wiki.markdown +++ /dev/null @@ -1,10 +0,0 @@ ---- -layout: post -title: "Migrating to GitHub Wiki" -date: 2017-05-01 23:21:00 -0500 -categories: zettelgeist update ---- - -For now, we have decided to use [github.com/zettelgeist/zettelgeist](https://github.com/zettelgeist/zettelgeist/) as the main presence for the ZettelGeist project. We're focusing on our energy on building the next version of ZettelGeist. Hosting code *and* documentation on GitHub will allow us to focus on improvements to ZettelGeist and keeping documentation up-to-date. - -If you have any questions about ZettelGeist or wish to help us, please don't hesitate to reach out to [Team ZettelGeist](https://github.com/ZettelGeist/zettelgeist/wiki/Team). diff --git a/deprecated/docs/about.md b/deprecated/docs/about.md deleted file mode 100644 index e6c657c..0000000 --- a/deprecated/docs/about.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -layout: page -title: About -permalink: /about/ ---- - -See our [Wiki](https://github.com/ZettelGeist/zettelgeist/wiki). diff --git a/deprecated/docs/example/mlb/20170731132024-chicago-cubs.yaml b/deprecated/docs/example/mlb/20170731132024-chicago-cubs.yaml deleted file mode 100644 index 11db390..0000000 --- a/deprecated/docs/example/mlb/20170731132024-chicago-cubs.yaml +++ /dev/null @@ -1,24 +0,0 @@ -title: MLB Teams -url: https://en.wikipedia.org/wiki/Chicago_Cubs -summary: Chicago Cubs -note: "The Chicago Cubs are an American professional baseball team based in Chicago,\ - \ Illinois. The Cubs compete in Major League Baseball (MLB) as a member club of\ - \ the National League (NL) Central division, where they are the defending World\ - \ Series champions. The team plays its home games at Wrigley Field, located on the\ - \ city's North Side. The Cubs are one of two major league teams in Chicago; the\ - \ other, the Chicago White Sox, is a member of the American League (AL) Central\ - \ division. The Cubs, first known as the White Stockings, was a founding member\ - \ of the NL in 1876, becoming the Chicago Cubs in 1903.[2] The Cubs have appeared\ - \ in a total of eleven World Series. The 1906 Cubs won 116 games, finishing 116\u2013\ - 36 and posting a modern-era record winning percentage of .763, before losing the\ - \ World Series to the Chicago White Sox by four games to two. The Cubs won back-to-back\ - \ World Series championships in 1907 and 1908, becoming the first major league team\ - \ to play in three consecutive World Series, and the first to win it twice. Most\ - \ recently, the Cubs won the 2016 National League Championship Series and 2016 World\ - \ Series, which ended a 71-year National League pennant drought and a 108-year World\ - \ Series championship drought," -tags: -- MLB -- National League -- NL East - diff --git a/deprecated/docs/example/mlb/20170731133642-cincinnati-reds.yaml b/deprecated/docs/example/mlb/20170731133642-cincinnati-reds.yaml deleted file mode 100644 index 5de8286..0000000 --- a/deprecated/docs/example/mlb/20170731133642-cincinnati-reds.yaml +++ /dev/null @@ -1,12 +0,0 @@ -title: MLB Teams -url: https://en.wikipedia.org/wiki/Cincinnati_Reds -summary: Cincinnati Reds -note: The Cincinnati Reds are an American professional baseball team based in Cincinnati, - Ohio. The Reds compete in Major League Baseball (MLB) as a member club of the National - League (NL) Central division. They were a charter member of the American Association - in 1882 and joined the NL in 1890. -tags: -- MLB -- National League -- NL Central - diff --git a/deprecated/docs/example/mlb/20170731134823-milwaukee-brewers.yaml b/deprecated/docs/example/mlb/20170731134823-milwaukee-brewers.yaml deleted file mode 100644 index 16abff1..0000000 --- a/deprecated/docs/example/mlb/20170731134823-milwaukee-brewers.yaml +++ /dev/null @@ -1,18 +0,0 @@ -title: MLB Teams -url: https://en.wikipedia.org/wiki/Milwaukee_Brewers -summary: Milwaukee Brewers -note: The Milwaukee Brewers are an American professional baseball team and are based - in Milwaukee, Wisconsin. The team is named for the city's association with the brewing - industry.[1] Since 2001, the Brewers have played their home games at Miller Park, - which has a seating capacity of 41,900. The team was founded in 1969 as the Seattle - Pilots, an expansion team of the American League (AL), in Seattle, Washington. The - Pilots played their home games at Sick's Stadium. After only one season, the team - relocated to Milwaukee, becoming known as the Brewers and playing their home games - at Milwaukee County Stadium. In 1998, the Brewers joined the National League. They - are the only franchise to play in four divisions since the advent of divisional - play in Major League Baseball in 1969. -tags: -- MLB -- National League -- NL Central - diff --git a/deprecated/docs/example/mlb/20170731135121-pittsburgh-pirates.yaml b/deprecated/docs/example/mlb/20170731135121-pittsburgh-pirates.yaml deleted file mode 100644 index 9061999..0000000 --- a/deprecated/docs/example/mlb/20170731135121-pittsburgh-pirates.yaml +++ /dev/null @@ -1,16 +0,0 @@ -title: MLB Teams -url: https://en.wikipedia.org/wiki/Pittsburgh_Pirates -summary: Pittsburgh Pirates -note: The Pittsburgh Pirates are an American professional baseball team based in Pittsburgh, - Pennsylvania. The Pirates compete in Major League Baseball (MLB) as a member club - of the National League (NL) Central division. The Pirates play their home games - at PNC Park; the team previously played at Forbes Field and Three Rivers Stadium, - the latter of which was named after its location near the confluence of the Allegheny, - Monongahela, and Ohio Rivers. Founded on October 15, 1881[2] as Allegheny, the franchise - has won five World Series championships. The Pirates are also often referred to - as the Bucs or the Buccos (derived from buccaneer, a synonym for pirate). -tags: -- MLB -- National League -- NL Central - diff --git a/deprecated/docs/example/mlb/20170731135823-st-louis-cardinals.yaml b/deprecated/docs/example/mlb/20170731135823-st-louis-cardinals.yaml deleted file mode 100644 index f4caf6c..0000000 --- a/deprecated/docs/example/mlb/20170731135823-st-louis-cardinals.yaml +++ /dev/null @@ -1,21 +0,0 @@ -title: MLB Teams -url: https://en.wikipedia.org/wiki/St._Louis_Cardinals -summary: St. Louis Cardinals -note: The St. Louis Cardinals are an American professional baseball team based in - St. Louis, Missouri. The Cardinals compete in Major League Baseball (MLB) as a member - club of the National League (NL) Central division. Busch Stadium has been their - home ballpark since 2006. With origins as one of the early professional baseball - clubs in St. Louis, entrepreneur Chris von der Ahe purchased a barnstorming club - in 1881, then known as the Brown Stockings, and established them as charter members - of the American Association (AA) the following season. Upon the discontinuation - of the AA, St. Louis joined the NL in 1892; at that time, they were called the Browns - and the Perfectos before they were officially renamed as the Cardinals in 1900. - One of the most successful franchises in baseball history, the Cardinals have won - 11 World Series championships, the second-most in Major League Baseball and most - in the National League. Their 19 National League pennants rank third in NL history. - In addition, St. Louis has won 13 division titles in the East and Central divisions. -tags: -- MLB -- National League -- NL Central - diff --git a/deprecated/docs/example/mlb/20170731140433-atlanta-braves.yaml b/deprecated/docs/example/mlb/20170731140433-atlanta-braves.yaml deleted file mode 100644 index 30a5d83..0000000 --- a/deprecated/docs/example/mlb/20170731140433-atlanta-braves.yaml +++ /dev/null @@ -1,17 +0,0 @@ -title: MLB Teams -url: https://en.wikipedia.org/wiki/Atlanta_Braves -summary: Atlanta Braves -note: "The Atlanta Braves are an American professional baseball franchise based in\ - \ the Atlanta metropolitan area. The franchise competes in Major League Baseball\ - \ (MLB) as a member of the National League (NL) East division. The Braves played\ - \ home games at Atlanta\u2013Fulton County Stadium from 1966 to 1996, and Turner\ - \ Field from 1997 to 2016. Since 2017, their home stadium has been SunTrust Park,\ - \ a new stadium 10 miles (16 km) northwest of downtown Atlanta in the Cumberland\ - \ neighborhood of Cobb County.[3] The Braves play spring training games in Lake\ - \ Buena Vista, Florida. In January 2017, the Braves announced a formal agreement\ - \ to move their spring training home to North Port, Florida." -tags: -- MLB -- National League -- NL East - diff --git a/deprecated/docs/example/mlb/20170731140750-miami-marlins.yaml b/deprecated/docs/example/mlb/20170731140750-miami-marlins.yaml deleted file mode 100644 index d078458..0000000 --- a/deprecated/docs/example/mlb/20170731140750-miami-marlins.yaml +++ /dev/null @@ -1,13 +0,0 @@ -title: MLB Teams -url: https://en.wikipedia.org/wiki/Miami_Marlins -summary: Miami Marlins -note: The Miami Marlins are an American professional baseball team based in Miami, - Florida. The Marlins compete in Major League Baseball (MLB) as a member of the National - League (NL) East division. Their home park is Marlins Park. Though one of only two - MLB franchises to have never won a division title (the other is the Colorado Rockies), - the Marlins have won two World Series championships as a wild card team. -tags: -- MLB -- National League -- NL East - diff --git a/deprecated/docs/example/mlb/20170731141025-new-york-mets.yaml b/deprecated/docs/example/mlb/20170731141025-new-york-mets.yaml deleted file mode 100644 index c544cb1..0000000 --- a/deprecated/docs/example/mlb/20170731141025-new-york-mets.yaml +++ /dev/null @@ -1,14 +0,0 @@ -title: MLB Teams -url: https://en.wikipedia.org/wiki/New_York_Mets -summary: New York Mets -note: 'The New York Mets are an American professional baseball team based in the New - York City borough of Queens. The Mets compete in Major League Baseball (MLB) as - a member club of the National League (NL) East division. The Mets are one of two - Major League clubs based in New York City; the other is the New York Yankees. One - of baseball''s first expansion teams, the Mets were founded in 1962 to replace New - York''s departed NL teams, the Brooklyn Dodgers and the New York Giants. ' -tags: -- MLB -- National League -- NL East - diff --git a/deprecated/docs/example/mlb/20170731141248-philadelphia-phillies.yaml b/deprecated/docs/example/mlb/20170731141248-philadelphia-phillies.yaml deleted file mode 100644 index e3cf2c7..0000000 --- a/deprecated/docs/example/mlb/20170731141248-philadelphia-phillies.yaml +++ /dev/null @@ -1,16 +0,0 @@ -title: MLB Teams -url: https://en.wikipedia.org/wiki/Philadelphia_Phillies -summary: Philadelphia Phillies -note: The Philadelphia Phillies are an American professional baseball team based in - Philadelphia, Pennsylvania. They are the oldest continuous, one-name, one-city franchise - in all of professional American sports, dating back to 1883.[6] The Phillies compete - in Major League Baseball (MLB) as a member club of the National League (NL) East - division. Since 2004, the team's home has been Citizens Bank Park, located in South - Philadelphia. The Phillies have won two World Series championships (against the - Kansas City Royals in 1980 and the Tampa Bay Rays in 2008) and seven National League - pennants, the first of which came in 1915. -tags: -- MLB -- National League -- NL East - diff --git a/deprecated/docs/example/mlb/20170731141625-washington-nationals.yaml b/deprecated/docs/example/mlb/20170731141625-washington-nationals.yaml deleted file mode 100644 index bc7429d..0000000 --- a/deprecated/docs/example/mlb/20170731141625-washington-nationals.yaml +++ /dev/null @@ -1,14 +0,0 @@ -title: MLB Teams -url: https://en.wikipedia.org/wiki/Washington_Nationals -summary: Washington Nationals -note: 'The Washington Nationals are a professional baseball team based in Washington, - D.C. The Nationals compete in Major League Baseball (MLB) as a member club of the - National League (NL) East division. From 2005 to 2007, the team played in RFK Stadium; - since 2008 their home stadium has been Nationals Park on South Capitol Street in - Southeast D.C., near the Anacostia River.[2] The Nationals are the fourth major - league franchise to be based in Washington, D.C., and the first since 1971. ' -tags: -- MLB -- National League -- NL East - diff --git a/deprecated/docs/example/mlb/20170731141908-arizona-diamondbacks.yaml b/deprecated/docs/example/mlb/20170731141908-arizona-diamondbacks.yaml deleted file mode 100644 index 7724960..0000000 --- a/deprecated/docs/example/mlb/20170731141908-arizona-diamondbacks.yaml +++ /dev/null @@ -1,16 +0,0 @@ -title: MLB Teams -url: https://en.wikipedia.org/wiki/Arizona_Diamondbacks -summary: Arizona Diamondbacks -note: The Arizona Diamondbacks, often shortened as the D-backs, are an American professional - baseball franchise based in Phoenix, Arizona. The club competes in Major League - Baseball (MLB) as a member of the National League (NL) West division. Since the - team's inception in 1998, the franchise has played home games at Chase Field, formerly - known as Bank One Ballpark. The Diamondbacks have won one World Series championship - (in 2001), becoming the fastest expansion team in the Major Leagues to win a championship, - doing it in only the fourth season since the franchise's inception in the 1998 Major - League Baseball season. -tags: -- MLB -- National League -- NL West - diff --git a/deprecated/docs/example/mlb/20170731142237-colorado-rockies.yaml b/deprecated/docs/example/mlb/20170731142237-colorado-rockies.yaml deleted file mode 100644 index 50aaf52..0000000 --- a/deprecated/docs/example/mlb/20170731142237-colorado-rockies.yaml +++ /dev/null @@ -1,15 +0,0 @@ -title: MLB Teams -url: https://en.wikipedia.org/wiki/Colorado_Rockies -summary: Colorado Rockies -note: The Colorado Rockies are an American professional baseball team based in Denver, - Colorado. The Rockies compete in Major League Baseball (MLB) as a member club of - the National League (NL) West division. The team's home venue is Coors Field, located - in the Lower Downtown area of Denver. The Rockies have won one National League championship, - in 2007, after having won 14 of their final 15 games in order to secure a Wild Card - position. In the World Series they were swept by the American League (AL) champion - Boston Red Sox in four games. -tags: -- MLB -- National League -- NL West - diff --git a/deprecated/docs/example/mlb/20170731143033-los-angeles-dodgers.yaml b/deprecated/docs/example/mlb/20170731143033-los-angeles-dodgers.yaml deleted file mode 100644 index ee737a2..0000000 --- a/deprecated/docs/example/mlb/20170731143033-los-angeles-dodgers.yaml +++ /dev/null @@ -1,14 +0,0 @@ -title: MLB Teams -url: https://en.wikipedia.org/wiki/Los_Angeles_Dodgers -summary: Los Angeles Dodgers -note: The Los Angeles Dodgers are an American professional baseball team based in - Los Angeles, California. The Dodgers compete in Major League Baseball (MLB) as a - member club of the National League (NL) West division. Established in 1883 in Brooklyn, - New York,[1][2] the team moved to Los Angeles before the 1958 season.[3] They played - for four seasons at the Los Angeles Memorial Coliseum before moving to their current - home of Dodger Stadium in 1962. -tags: -- MLB -- National League -- NL West - diff --git a/deprecated/docs/example/mlb/20170731143425-san-diego-padres.yaml b/deprecated/docs/example/mlb/20170731143425-san-diego-padres.yaml deleted file mode 100644 index 4b233da..0000000 --- a/deprecated/docs/example/mlb/20170731143425-san-diego-padres.yaml +++ /dev/null @@ -1,14 +0,0 @@ -title: MLB Teams -url: https://en.wikipedia.org/wiki/San_Diego_Padres -summary: San Diego Padres -note: 'The San Diego Padres are an American professional baseball franchise based - in San Diego, California. The Padres compete in Major League Baseball (MLB) as a - member club of the National League (NL) West division, along with the Arizona Diamondbacks, - Colorado Rockies, Los Angeles Dodgers and San Francisco Giants. Founded in 1969, - the Padres have won the NL pennant twice: in 1984 and 1998, losing in the World - Series both times.' -tags: -- MLB -- National League -- NL West - diff --git a/deprecated/docs/example/mlb/20170731154135-baltimore-orioles.yaml b/deprecated/docs/example/mlb/20170731154135-baltimore-orioles.yaml deleted file mode 100644 index a9a772a..0000000 --- a/deprecated/docs/example/mlb/20170731154135-baltimore-orioles.yaml +++ /dev/null @@ -1,22 +0,0 @@ -title: MLB Teams -url: https://en.wikipedia.org/wiki/Baltimore_Orioles -summary: Baltimore Orioles -note: "The Baltimore Orioles are an American professional baseball team based in Baltimore,\ - \ Maryland. The Orioles compete in Major League Baseball (MLB) as a member of the\ - \ American League (AL) East division. As one of the AL's original eight charter\ - \ franchises when the league was established in 1901, this particular franchise\ - \ spent its first year as a major league club in Milwaukee, Wisconsin, as the Milwaukee\ - \ Brewers before moving to St. Louis, Missouri to become the St. Louis Browns. After\ - \ 52 often-beleaguered years in St. Louis, the Browns franchise was purchased in\ - \ November 1953 by a syndicate of Baltimore business interests led by attorney/civic\ - \ activist Clarence Miles and Mayor Thomas D'Alesandro, Jr. The franchise officially\ - \ moved to Baltimore for the 1954 season and began play in Memorial Stadium. The\ - \ Orioles adopted their team name in honor of the official state bird of Maryland;\ - \ it had also been used by several previous major and minor league baseball clubs\ - \ in Baltimore, including the 1901\u20131903 Orioles that would later move and become\ - \ the New York Yankees. Nicknames for the team include the 'O's' and the 'Birds'" -tags: -- MLB -- National League -- AL East - diff --git a/deprecated/docs/example/mlb/20170731154404-boston-red-sox.yaml b/deprecated/docs/example/mlb/20170731154404-boston-red-sox.yaml deleted file mode 100644 index e8396d3..0000000 --- a/deprecated/docs/example/mlb/20170731154404-boston-red-sox.yaml +++ /dev/null @@ -1,14 +0,0 @@ -title: MLB Teams -url: ihttps://en.wikipedia.org/wiki/Boston_Red_Sox -summary: Boston Red Sox -note: 'The Boston Red Sox are an American professional baseball team based in Boston, - Massachusetts. The Red Sox compete in Major League Baseball (MLB) as a member club - of the American League (AL) East division. The Red Sox have won eight World Series - championships and have played in twelve. Founded in 1901 as one of the American - League''s eight charter franchises, the Red Sox'' home ballpark has been Fenway - Park since 1912. ' -tags: -- MLB -- National League -- AL East - diff --git a/deprecated/docs/example/mlb/20170731154645-new-york-yankees.yaml b/deprecated/docs/example/mlb/20170731154645-new-york-yankees.yaml deleted file mode 100644 index e0a5c94..0000000 --- a/deprecated/docs/example/mlb/20170731154645-new-york-yankees.yaml +++ /dev/null @@ -1,17 +0,0 @@ -title: MLB Teams -url: https://en.wikipedia.org/wiki/New_York_Yankees -summary: New York Yankees -note: The New York Yankees are an American professional baseball team based in the - New York City borough of the Bronx. The Yankees compete in Major League Baseball - (MLB) as a member club of the American League (AL) East division. They are one of - two major league clubs based in New York City, the other being the New York Mets - of the National League. In the 1901 season, the club began play in the AL as the - Baltimore Orioles (no relation to the modern Baltimore Orioles). Frank Farrell and - Bill Devery purchased the franchise (which had ceased operations) and moved it to - New York City, renaming the club the New York Highlanders.[1] The Highlanders were - officially renamed the Yankees in 1913. -tags: -- MLB -- National League -- AL East - diff --git a/deprecated/docs/example/mlb/20170731154837-tampa-bay-rays.yaml b/deprecated/docs/example/mlb/20170731154837-tampa-bay-rays.yaml deleted file mode 100644 index 501d2b3..0000000 --- a/deprecated/docs/example/mlb/20170731154837-tampa-bay-rays.yaml +++ /dev/null @@ -1,12 +0,0 @@ -title: MLB Teams -url: ihttps://en.wikipedia.org/wiki/Tampa_Bay_Rays -summary: Tampa Bay Rays -note: The Tampa Bay Rays are an American professional baseball team based in St. Petersburg, - Florida. The Rays compete in Major League Baseball (MLB) as a member of the American - League (AL) East division. Since its inception, the team's home venue has been Tropicana - Field. -tags: -- MLB -- National League -- AL East - diff --git a/deprecated/docs/example/mlb/20170731155132-toronto-blue-jays.yaml b/deprecated/docs/example/mlb/20170731155132-toronto-blue-jays.yaml deleted file mode 100644 index 69554c1..0000000 --- a/deprecated/docs/example/mlb/20170731155132-toronto-blue-jays.yaml +++ /dev/null @@ -1,14 +0,0 @@ -title: MLB Teams -url: https://en.wikipedia.org/wiki/Toronto_Blue_Jays -summary: Toronto Blue Jays -note: 'The Toronto Blue Jays are a Canadian professional baseball team based in Toronto, - Ontario. The Blue Jays compete in Major League Baseball (MLB) as a member club of - the American League (AL) East division. The team plays its home games at the Rogers - Centre. The ''Blue Jays'' name originates from the bird of the same name, and blue - is also the traditional colour of two of Toronto''s other professional sports teams: - the Maple Leafs (ice hockey) and the Argonauts (Canadian football).' -tags: -- MLB -- National League -- AL East - diff --git a/deprecated/docs/example/mlb/20170731155613-chicago-grey-sox.yaml b/deprecated/docs/example/mlb/20170731155613-chicago-grey-sox.yaml deleted file mode 100644 index 4960b4d..0000000 --- a/deprecated/docs/example/mlb/20170731155613-chicago-grey-sox.yaml +++ /dev/null @@ -1,16 +0,0 @@ -title: MLB Teams -url: https://en.wikipedia.org/wiki/Chicago_White_Sox -summary: Chicago White Sox -note: The White Sox won the 1906 World Series with a defense-oriented team dubbed - 'the Hitless Wonders', and the 1917 World Series led by Eddie Cicotte, Eddie Collins, - and Shoeless Joe Jackson. The 1919 World Series was marred by the Black Sox Scandal, - in which several members of the White Sox were accused of conspiring with gamblers - to fix games. In response, Major League Baseball's new Commissioner Kenesaw Mountain - Landis banned the players from Major League Baseball for life. In 1959, led by Early - Wynn, Nellie Fox, Luis Aparicio and manager Al Lopez, the White Sox won the American - League pennant. They won the AL pennant in 2005, and went on to win the World Series. -tags: -- MLB -- National League -- AL Central - diff --git a/deprecated/docs/example/mlb/20170731160002-cleveland-indians.yaml b/deprecated/docs/example/mlb/20170731160002-cleveland-indians.yaml deleted file mode 100644 index 8ec203f..0000000 --- a/deprecated/docs/example/mlb/20170731160002-cleveland-indians.yaml +++ /dev/null @@ -1,17 +0,0 @@ -title: MLB Teams -url: https://en.wikipedia.org/wiki/Cleveland_Indians -summary: Cleveland Indians -note: 'The Cleveland Indians are an American professional baseball team based in Cleveland, - Ohio. The Indians compete in Major League Baseball (MLB) as a member club of the - American League (AL) Central division. Since 1994, they have played at Progressive - Field and are the defending American League champions. The team''s spring training - facility is at Goodyear Ballpark in Goodyear, Arizona.[2] Since their establishment - as a major league franchise in 1901, the Indians have won two World Series championships: - in 1920 and 1948, along with eight Central Division titles and six American League - pennants. The Indians'' current World Series championship drought is the longest - active drought, and through 2016 is the fifth-longest in baseball history' -tags: -- MLB -- National League -- AL Central - diff --git a/deprecated/docs/example/mlb/20170731160508-detroit-tigers.yaml b/deprecated/docs/example/mlb/20170731160508-detroit-tigers.yaml deleted file mode 100644 index 6ef1fd5..0000000 --- a/deprecated/docs/example/mlb/20170731160508-detroit-tigers.yaml +++ /dev/null @@ -1,18 +0,0 @@ -title: MLB Teams -url: https://en.wikipedia.org/wiki/Detroit_Tigers -summary: Detroit Tigers -note: iThe Detroit Tigers are an American professional baseball team based in Detroit, - Michigan. The Tigers compete in Major League Baseball (MLB) as a member club of - the American League (AL) Central division. One of the AL's eight charter franchises, - the club was founded in Detroit in 1901. They are the oldest continuous one-name, - one-city franchise in the AL.[2] The Tigers have won four World Series championships - (1935, 1945, 1968, and 1984), 11 AL pennants (1907, 1908, 1909, 1934, 1935, 1940, - 1945, 1968, 1984, 2006, and 2012), and four AL Central division championships (2011, - 2012, 2013, and 2014). The Tigers also won division titles in 1972, 1984 and 1987 - while members of the AL East. The team currently plays its home games at Comerica - Park in Downtown Detroit. -tags: -- MLB -- National League -- AL Central - diff --git a/deprecated/docs/example/mlb/20170731160722-kansas-city-royals.yaml b/deprecated/docs/example/mlb/20170731160722-kansas-city-royals.yaml deleted file mode 100644 index e70faaa..0000000 --- a/deprecated/docs/example/mlb/20170731160722-kansas-city-royals.yaml +++ /dev/null @@ -1,15 +0,0 @@ -title: MLB Teams -url: https://en.wikipedia.org/wiki/Kansas_City_Royals -summary: Kansas City Royals -note: The Kansas City Royals are an American professional baseball team based in Kansas - City, Missouri. The Royals compete in Major League Baseball (MLB) as a member team - of the American League (AL) Central division. The team was founded as an expansion - franchise in 1969, and has participated in four World Series, winning in 1985 and - 2015, and losing in 1980 and 2014. The name Royals originates from the American - Royal, a livestock show, horse show, rodeo, and championship barbeque competition - held annually in Kansas City since 1899. -tags: -- MLB -- National League -- AL Central - diff --git a/deprecated/docs/example/mlb/20170731160940-minnesota-twins.yaml b/deprecated/docs/example/mlb/20170731160940-minnesota-twins.yaml deleted file mode 100644 index 2af5575..0000000 --- a/deprecated/docs/example/mlb/20170731160940-minnesota-twins.yaml +++ /dev/null @@ -1,14 +0,0 @@ -title: MLB Teams -url: https://en.wikipedia.org/wiki/Minnesota_Twins -summary: Minnesota Twins -note: The Minnesota Twins are an American professional baseball team based in Minneapolis, - Minnesota. The Twins compete in Major League Baseball (MLB) as a member club of - the American League (AL) Central division. The team is named after the Twin Cities - area comprising Minneapolis and St. Paul. They played in Metropolitan Stadium from - 1961 to 1981 and the Hubert H. Humphrey Metrodome from 1982 to 2009. They played - their inaugural game at the newly completed Target Field on April 12, 2010. -tags: -- MLB -- National League -- AL Central - diff --git a/deprecated/docs/example/mlb/20170731161550-houston-astros.yaml b/deprecated/docs/example/mlb/20170731161550-houston-astros.yaml deleted file mode 100644 index d9e3cf7..0000000 --- a/deprecated/docs/example/mlb/20170731161550-houston-astros.yaml +++ /dev/null @@ -1,17 +0,0 @@ -title: MLB Teams -url: https://en.wikipedia.org/wiki/Houston_Astros -summary: Houston Astros -note: "The Houston Astros are an American professional baseball team based in Houston,\ - \ Texas. The Astros compete in Major League Baseball (MLB) as a member club of the\ - \ American League (AL) West division, having moved to the division in 2013 after\ - \ spending their first 51 seasons in the National League (NL).[2][3] The Astros\ - \ have played their home games at Minute Maid Park since 2000.[4] The Astros were\ - \ established as the Houston Colt .45s and entered the National League in 1962 with\ - \ the expansion New York Mets. The current name\u2014reflecting Houston's role as\ - \ the control center of the U.S. space program\u2014was adopted three years later,\ - \ when they moved into the Astrodome, the world's first domed sports stadium." -tags: -- MLB -- National League -- AL West - diff --git a/deprecated/docs/example/mlb/20170731161927-los-angeles-angels.yaml b/deprecated/docs/example/mlb/20170731161927-los-angeles-angels.yaml deleted file mode 100644 index a91b29d..0000000 --- a/deprecated/docs/example/mlb/20170731161927-los-angeles-angels.yaml +++ /dev/null @@ -1,16 +0,0 @@ -title: MLB Teams -url: https://en.wikipedia.org/wiki/Houston_Astros -summary: Houston Astros -note: The Los Angeles Angels of Anaheim, commonly known as the Los Angeles Angels, - are an American professional baseball franchise based in Anaheim, California. The - Angels compete in Major League Baseball (MLB) as a member club of the American League - (AL) West division. The Angels have played home games at Angel Stadium since 1966. - The current Major League franchise was established as an expansion team in 1961 - by Gene Autry, the team's first owner. The Angels name was taken by Autry in tribute - to the original Los Angeles Angels, a Minor League franchise in the Pacific Coast - League (PCL), which played in South Central Los Angeles from 1903 to 1957. -tags: -- MLB -- National League -- AL West - diff --git a/deprecated/docs/example/mlb/20170731162502-oakland-athletics.yaml b/deprecated/docs/example/mlb/20170731162502-oakland-athletics.yaml deleted file mode 100644 index f534d04..0000000 --- a/deprecated/docs/example/mlb/20170731162502-oakland-athletics.yaml +++ /dev/null @@ -1,19 +0,0 @@ -title: MLB Teams -url: https://en.wikipedia.org/wiki/Oakland_Athletics -summary: Oakland Athletics -note: "The Oakland Athletics (often abbreviated to A's) are an American professional\ - \ baseball team based in Oakland, California. The Athletics compete in Major League\ - \ Baseball (MLB) as a member club of the American League (AL) West division. The\ - \ club plays its home games at the Oakland\u2013Alameda County Coliseum. The club\ - \ has won nine World Series championships, the third most of all current Major League\ - \ Baseball teams. The Athletics' 2017 season will be the team's 50th season in Oakland.\ - \ One of the American League's eight charter franchises, the club was founded in\ - \ Philadelphia, in 1901 as the Philadelphia Athletics. They won three World Series\ - \ championships from 1910 to 1913 and two in a row in 1929 and 1930. The team's\ - \ owner and manager for its first 50 years was Connie Mack and Hall of Fame players\ - \ included Chief Bender, Frank 'Home Run' Baker, Jimmie Foxx, and Lefty Grove." -tags: -- MLB -- National League -- AL West - diff --git a/deprecated/docs/example/mlb/20170731162806-seattle-mariners.yaml b/deprecated/docs/example/mlb/20170731162806-seattle-mariners.yaml deleted file mode 100644 index ea32c0a..0000000 --- a/deprecated/docs/example/mlb/20170731162806-seattle-mariners.yaml +++ /dev/null @@ -1,18 +0,0 @@ -title: MLB Teams -url: https://en.wikipedia.org/wiki/Seattle_Mariners -summary: Seattle Mariners -note: The Seattle Mariners is an American professional baseball team based in Seattle, - Washington. The Mariners compete in Major League Baseball (MLB) as a member club - of the American League (AL) West Division. The team joined the AL as an expansion - team in 1977. Since July 1999, the Mariners' home ballpark has been Safeco Field, - located in the SoDo neighborhood of Seattle. The 'Mariners' name originates from - the prominence of marine culture in the city of Seattle. They are nicknamed the - M's, a title featured in their primary logo from 1987 to 1992. They adopted their - current team colors - Navy blue, northwest green (teal), and silver - prior to the - 1993 season, after having been royal blue and gold since the team's inception.[1] - Their mascot is the Mariner Moose. -tags: -- MLB -- National League -- AL West - diff --git a/deprecated/docs/example/mlb/20170731163040-texas-rangers.yaml b/deprecated/docs/example/mlb/20170731163040-texas-rangers.yaml deleted file mode 100644 index 2cdbf8a..0000000 --- a/deprecated/docs/example/mlb/20170731163040-texas-rangers.yaml +++ /dev/null @@ -1,14 +0,0 @@ -title: MLB Teams -url: https://en.wikipedia.org/wiki/Texas_Rangers_(baseball) -summary: Texas Rangers -note: "The Texas Rangers are an American professional baseball team based in Arlington,\ - \ Texas, located in the Dallas\u2013Fort Worth metroplex. The Rangers franchise\ - \ is currently a member of the West division of the American League (AL) in Major\ - \ League Baseball (MLB). Since 1994, the Rangers have played in Globe Life Park\ - \ in Arlington in Arlington, Texas. The team's name is borrowed from the famous\ - \ law enforcement agency of the same name." -tags: -- MLB -- National League -- AL West - diff --git a/deprecated/docs/example/mlb/README.md b/deprecated/docs/example/mlb/README.md deleted file mode 100644 index 451a325..0000000 --- a/deprecated/docs/example/mlb/README.md +++ /dev/null @@ -1 +0,0 @@ -Dave: Put the .yaml files in this folder. diff --git a/deprecated/docs/gs.md b/deprecated/docs/gs.md deleted file mode 100644 index 4cdca41..0000000 --- a/deprecated/docs/gs.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -layout: page -title: User's Guide -permalink: /gs/ ---- - -See [Using the Tools](https://github.com/ZettelGeist/zettelgeist/wiki/Using-the-Tools). diff --git a/deprecated/docs/index.md b/deprecated/docs/index.md deleted file mode 100644 index 1eb5d67..0000000 --- a/deprecated/docs/index.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -# You don't need to edit this file, it's empty on purpose. -# Edit theme's home layout instead if you wanna make some changes -# See: https://jekyllrb.com/docs/themes/#overriding-theme-defaults -layout: home ---- diff --git a/deprecated/docs/install.md b/deprecated/docs/install.md deleted file mode 100644 index 6e6a0c0..0000000 --- a/deprecated/docs/install.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -layout: page -title: Installation -permalink: /install/ ---- - -See [Installing the Tools](https://github.com/ZettelGeist/zettelgeist/wiki/Installing-the-Tools). diff --git a/deprecated/docs/team.md b/deprecated/docs/team.md deleted file mode 100644 index 63574c0..0000000 --- a/deprecated/docs/team.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -layout: page -title: The Team -permalink: /team/ ---- - -See [Team](https://github.com/ZettelGeist/zettelgeist/wiki/Team). - diff --git a/deprecated/docs/thenote.md b/deprecated/docs/thenote.md deleted file mode 100644 index ea3c4c2..0000000 --- a/deprecated/docs/thenote.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -layout: page -title: Note Format -permalink: /notes/ ---- - -See [The Zettel Format](https://github.com/ZettelGeist/zettelgeist/wiki/The-Zettel-format). diff --git a/deprecated/docs/tutorial-GDocs.md b/deprecated/docs/tutorial-GDocs.md deleted file mode 100644 index 6ec7e6f..0000000 --- a/deprecated/docs/tutorial-GDocs.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -layout: page -title: Tutorial-GDocs -permalink: /tutorial-gdocs/ ---- - -See [Writing with Google Docs](https://github.com/ZettelGeist/zettelgeist/wiki/Writing-with-Google-Docs). diff --git a/deprecated/docs/tutorial-Terminal.md b/deprecated/docs/tutorial-Terminal.md deleted file mode 100644 index 9430efc..0000000 --- a/deprecated/docs/tutorial-Terminal.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -layout: page -title: Tutorial-Terminal -permalink: /tutorial-term/ ---- - -See [Tutorial](https://github.com/ZettelGeist/zettelgeist/wiki/Tutorial). diff --git a/deprecated/docs/tutorial-Word.md b/deprecated/docs/tutorial-Word.md deleted file mode 100644 index 96247d8..0000000 --- a/deprecated/docs/tutorial-Word.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -layout: page -title: Tutorial-Word -permalink: /tutorial-word/ ---- - -See [Writing with Word](https://github.com/ZettelGeist/zettelgeist/wiki/Word-Musings). diff --git a/deprecated/zettelgeist/zfilter.py b/deprecated/zettelgeist/zfilter.py deleted file mode 100644 index 2090c8b..0000000 --- a/deprecated/zettelgeist/zfilter.py +++ /dev/null @@ -1,301 +0,0 @@ -import sys -import argparse -import re -import os -import os.path -import yaml -import json -from time import strftime - -from . import zdb, zettel, zquery - - -def get_argparse(): - parser = zdb.get_argparse() - - for field in zettel.ZettelFieldsOrdered: - parser.add_argument('--show-%s' % field, - action='store_const', const=True, default=False, - help="include field <%s> in output" % field) - - parser.add_argument( - '--metadata', action='store_const', const=True, default=False, - help="write metadata") - - parser.add_argument( - '--query-prompt', action='store_const', const=True, default=False, - help="prompt for ZQL query (overrides --query, --query-file))") - - parser.add_argument( - '--query-file', help="load ZQL query from file (overrides --query)", default=None) - - parser.add_argument( - '--query-string', - help="load ZQL from string", default=None) - - parser.add_argument( - '--save-query', - help="save source query to file", default=None) - - parser.add_argument( - '--trace-sql', - help="log all SQL statements used to file", default=None) - - parser.add_argument( - '--save-sql', - help="save compiled SQL to file (for developers only)", default=None) - - parser.add_argument( - '--save', - help="save to output folder", required=True) - - parser.add_argument( - '--snip-size', - help="snippet size", type=int, default=2500) - - return parser - - -def write_data(filename, mode, comment, statement): - if not filename: - return - with open(filename, mode) as outfile: - outfile.write("\n".join([comment, statement]) + "\n\n") - - -def counter(): - i = 0 - while True: - yield i - i = i + 1 - - -def offsets_gen(int_offsets, text): - iterations = len(int_offsets) // 4 - grouped = [tuple(int_offsets[i * 4:i * 4 + 4]) for i in range(0, iterations)] - grouped = sorted(grouped, key=lambda item: item[2]) - - for group in grouped: - (column, term, pos, size) = group - yield {'column': column, - 'term': term, - 'pos': pos, - 'size': size, - 'substring': text[pos:pos + size]} - - -def process_offsets(filename, text, offsets, context): - int_offsets = [int(offset) for offset in offsets.split()] - results = [] - - previous = (len(text), 0) - for info in offsets_gen(int_offsets, text): - pos = info['pos'] - offset = info['size'] - low_pos = max(pos - offset - context, 0) - high_pos = min(pos + offset + context, len(text)) - if pos >= previous[0] and pos + offset <= previous[1]: - continue - else: - previous = (low_pos, high_pos) - results.append(text[low_pos:high_pos]) - return results - - -def write_to_file(filepath, text, **kwargs): - mode = kwargs.get("mode", "a") - newlines = kwargs.get("newlines", 1) - with open(filepath, mode) as outfile: - outfile.write(text) - if newlines: - outfile.write("\n" * int(newlines)) - - -def get_context(snip): - text = snip.strip() - ws_matches = list(re.finditer("\s+", text)) - if len(ws_matches) < 2: - return text - - first = ws_matches[0].end() - last = ws_matches[-1].start() - return text[first:last] - - -# TODO Create zutils.py module - -def dirname(path): - return os.path.split(path)[0] - - -def basename(path): - return os.path.split(path)[1] - -def get_match_clause(query): - try: - match_pos = query.find("MATCH") - query = query[match_pos+len("MATCH"):] - and_pos = query.find("AND") - query = query[:and_pos] - except: - pass - return query - -def main(): - parser = get_argparse() - args = parser.parse_args() - argsd = vars(args) - - output_dir = args.save - if os.path.exists(output_dir): - print("Will not overwrite existing directory %s (exiting)." % output_dir) - sys.exit(1) - - try: - os.mkdir(output_dir) - except: - print("Could not create output folder %s (exiting)." % output_dir) - sys.exit(1) - - if args.query_prompt: - input_line = input("zfilter> ") - elif args.query_file: - with open(args.query_file) as infile: - input_line = infile.read() - elif args.query_string: - input_line = args.query_string - else: - print("No query option (--query, --query-file, or --prompt) found (exiting).") - sys.exit(1) - - print("zfilter writing results to folder %s" % output_dir) - - (ast2, semantics2) = zquery.compile2(input_line) - db = zdb.get(args.database) - gen = None - for statement in [semantics2.sql_drop_matches_table(), semantics2.sql_create_matches_table(ast2)]: - write_data(args.trace_sql, "a", "", statement) - gen = db.fts_query(statement) - for g in gen: - pass - - select_sql = semantics2.sql_get_matches() - - write_data(args.trace_sql, "a", "# query match", select_sql) - write_data(args.save_query, "w", "", input_line) - write_data(args.save_sql, "w", "", ast2) - write_data(args.trace_sql, "a", "# saved SQL query", ast2) - - search_counter = counter() - - search_count = next(search_counter) - snippets_count = 0 - - search_result_generator = db.fts_query(select_sql) - - all_results = list(search_result_generator) - format_d_length = len(str(len(all_results))) - match_filenames = [] - snips_written = set() - - for search_result in all_results: - docid = search_result['docid'] - base_name = output_dir + ("-%%0%dd" % format_d_length) % search_count - base_path = os.path.join(output_dir, base_name) - yaml_path = base_path + '.yaml.in' - - print("... " + yaml_path) - - write_to_file( - yaml_path, "# Note: This is a generated .yaml.in file intended for editing (editor or zettel command)", mode="w", newlines=0) - - bound_query = "SELECT *,docid from zettels where docid = %(docid)s" % vars( - ) - write_data(args.trace_sql, "a", - "# finding zettels by docid", bound_query) - - search_details_generator = db.fts_query(bound_query) - try: - row = next(search_details_generator) - except: - print("Unexpected end of iteration") - - current_filename = row['filename'] - match_filenames.append(current_filename) - - write_to_file(yaml_path, "# zfind search results", - mode="a", newlines=1) - write_to_file(yaml_path, "# filename = %s" % - current_filename, mode="a", newlines=1) - write_to_file(yaml_path, "# query = %s" % - input_line.strip(), mode="a", newlines=2) - - try: - loader = zettel.ZettelLoader(row['filename']) - zettels = loader.getZettels() - z = next(zettels) - except: - print("Warning: Cannot load source Zettel %s from filesystem (using database instead)" % - row['filename']) - z = None - - snip_size = max(args.snip_size, 250) - for field in zettel.ZettelFields: - show_field = "show_" + field - if argsd.get(show_field, None): - for query in semantics2.get_field_query_sql(field, snip_size, docid): - field_query_generator = db.fts_query(query) - write_data(args.trace_sql, "a", "", query) - for result in field_query_generator: - if query.find("offsets(") >= 0: - #print("Processing offsets for %s" % field) - snippets = process_offsets(current_filename, - result[field + "_verbatim"], result[field + "_offsets"], snip_size) - snippets_count = snippets_count + len(snippets) - - # Write text version - snip_path = base_path + '-%s.txt' % field - - for snip in snippets: - write_to_file(snip_path, "# filename = %s" % - current_filename, mode="a", newlines=1) - write_to_file(snip_path, "# field = %s" % - field, mode="a", newlines=2) - write_to_file(snip_path, "# query = %s" % get_match_clause(query), mode="a", newlines=2) - write_to_file(snip_path, snip, mode="a", newlines=2) - - snip_id = (field, snip_path) - if snip_id not in snips_written: - write_to_file(yaml_path, - "# %s -> See %s for snippets." % (field, snip_path), mode="a", newlines=2) - snips_written.add(snip_id) - - elif result[field]: - write_to_file(yaml_path, z.get_yaml( - [field]), mode="a", newlines=1) - - search_count = next(search_counter) - - if False: - drop_temp_matches_table = semantics2.sql_drop_matches_table() - write_data(args.trace_sql, "a", "", drop_temp_matches_table) - gen = db.fts_query(drop_temp_matches_table) - for g in gen: - pass - - if args.metadata: - stats_path = os.path.join(output_dir, output_dir + '-stats.json') - files_path = os.path.join(output_dir, output_dir + '-fileset.txt') - - doc = {'count': search_count, - 'query': input_line.strip(), - 'snips': list(snips_written)} - - write_to_file(stats_path, - json.dumps(doc, indent=4, sort_keys=True), mode="w", newlines=1) - write_to_file(files_path, "\n".join( - match_filenames), mode="w", newlines=1) - - -if __name__ == '__main__': - main() diff --git a/docs/.gitignore b/docs/.gitignore deleted file mode 100644 index 45c1505..0000000 --- a/docs/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -_site -.sass-cache -.jekyll-metadata diff --git a/docs/RELEASING.md b/docs/RELEASING.md deleted file mode 100644 index f0d2689..0000000 --- a/docs/RELEASING.md +++ /dev/null @@ -1,13 +0,0 @@ -# Notes to Selves - -- Start by updating `zversion.py` - -- We only use major, minor, and point releases (x.y.z) - -- To bump the release, modify `zversion.py`. At some point, we may add a "version bumping" framework, e.g. bump2version, but I don't see an immediate need for this yet. - -- Commit the changes - -- Tag a release in GitHub. Note that releasing on PyPI and releasing on GitHub are two different things. You can avoid having to keep track by runnign `git tag $(python setup.py --version)`. This will give the version that is associated with the Python setup.py file and use it not only to make a release but to ensure this release triggers a release on PyPI. - -- Make sure not only to `git push` but to `git push --tags`. diff --git a/docs/index.html b/docs/index.html deleted file mode 100644 index 2b90e04..0000000 --- a/docs/index.html +++ /dev/null @@ -1,5 +0,0 @@ - - -Redirecting to https://github.com/ZettelGeist/zettelgeist/wiki - - diff --git a/jupyter/xyz.txt b/jupyter/xyz.txt deleted file mode 100644 index 3e4679d..0000000 --- a/jupyter/xyz.txt +++ /dev/null @@ -1,7 +0,0 @@ -@misc{blahblahblah, - title = {In Depth - In Depth: Ray Kurzweil - Book {TV}}, - url = {http://www.booktv.org/Program/7515/In+Depth+Ray+Kurzweil.aspx}, - urldate = {2011-02-11}, - keywords = {*{AddedToZettels}}, - file = {In Depth - In Depth\: Ray Kurzweil - Book TV:/Users/dbdennis/Library/Application Support/Zotero/Profiles/duztnovb.default/zotero/storage/TWWBX3QV/In+Depth+Ray+Kurzweil.html:text/html} -} diff --git a/jupyter/zdemo.ipynb b/jupyter/zdemo.ipynb deleted file mode 100644 index c5c8172..0000000 --- a/jupyter/zdemo.ipynb +++ /dev/null @@ -1,687 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "YAML support is provided by PyYAML at http://pyyaml.org/. This notebook depends on it." - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "import yaml\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The following cell provides an initial example of a *note* in our system. \n", - "\n", - "A *note* is nothing more than a YAML document. The idea of notetaking is to keep it simple, so a note should make no assumptions about formatting whatsoever.\n", - "\n", - "In our current thinking, we have the following sections:\n", - "\n", - "- title: an optional title (text)\n", - "- tags: one or more keywords (text, sequence of text, no nesting)\n", - "- mentions: one or more mentions (text, sequence of text, no nesting)\n", - "- outline: one or more items (text, sequence of text, nesting is permitted)\n", - "- dates (numeric text, sequence, must follow established historical ways of representing dates)\n", - "- text (text from the source as multiline string)\n", - "- bibtex, ris, or inline (text for the bibliographic item; will be syntax checked)\n", - "- bibkey (text, a hopefully unique identifier for referring to this source in other Zettels)\n", - "- cite: Used to cite a bibkey from the same or other notes. In addition, the citation may be represented as a list, where the first item is the bibkey and subsequent items are pages or ranges of page numbers. See below for a good example of how this will work.\n", - "- note (any additional details that you wish to hide from indexing)\n", - "\n", - "In most situations, freeform text is permitted. If you need to do crazy things, you must put quotes around the text so YAML can process it. However, words separated by whitespace and punctuation seems to work fine in most situations.\n", - "\n", - "These all are intended to be string data, so there are no restrictions on what can be in any field; however, we will likely limit tags, mentions, dates in some way as we go forward. Fields such as bibtex, ris, or inline are also subject to validity checking." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Print the document to the console (nothing special here)." - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "myFirstZettel=\"\"\"\n", - "title: First BIB Note for Castells\n", - "tags:\n", - " - Castells\n", - " - Network Society\n", - " - Charles Babbage is Awesome\n", - " - Charles Didn't do Everything\n", - "mentions:\n", - " - gkt\n", - " - dbdennis\n", - "dates: 2016\n", - "cite:\n", - " - Castells Rise 2016\n", - " - ii-iv\n", - " - 23-36\n", - "outline:\n", - " - Introduction\n", - " - - Computers\n", - " - People\n", - " - Conclusions\n", - " - - Great Ideas of Computing\n", - "\n", - "text: |\n", - " Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam eleifend est sed diam maximus rutrum. Quisque sit amet imperdiet odio, id tristique libero. Aliquam viverra convallis mauris vel tristique. Cras ac dolor non risus porttitor molestie vel at nisi. Donec vitae finibus quam. Phasellus vehicula urna sed nibh condimentum, ultrices interdum velit eleifend. Nam suscipit dolor eu rutrum fringilla. Sed pulvinar purus purus, sit amet venenatis enim convallis a. Duis fringilla nisl sit amet erat lobortis dictum. Nunc fringilla arcu nec ex blandit, a gravida purus commodo. Vivamus lacinia tellus dui, vel maximus lacus ornare id.\n", - "\n", - " Vivamus euismod justo sit amet luctus bibendum. Integer non mi ullamcorper enim fringilla vulputate sit amet in urna. Nullam eu sodales ipsum. Curabitur id convallis ex. Duis a condimentum lorem. Nulla et urna massa. Duis in nibh eu elit lobortis vehicula. Mauris congue mauris mollis metus lacinia, ut suscipit mi egestas. Donec luctus ante ante, eget viverra est mollis vitae.\n", - "\n", - " Vivamus in purus in erat dictum scelerisque. Aliquam dictum quis ligula ac euismod. Mauris elementum metus vel scelerisque feugiat. Vivamus bibendum massa eu pellentesque sodales. Nulla nec lacus dolor. Donec scelerisque, nibh sed placerat gravida, nunc turpis tristique nibh, ac feugiat enim massa ut eros. Nulla finibus, augue egestas hendrerit accumsan, tellus augue tempor eros, in sagittis dolor turpis nec mi. Nunc fringilla mi non malesuada aliquet.\n", - "\n", - "bibkey:\n", - " Castells Rise 1996\n", - "bibtex: |\n", - " @book{castells_rise_1996,\n", - " address = {Cambridge, Mass.},\n", - " series = {Castells, {Manuel}, 1942- {Information} age . v},\n", - " title = {The rise of the network society},\n", - " isbn = {978-1-55786-616-5},\n", - " language = {eng},\n", - " publisher = {Blackwell Publishers},\n", - " author = {Castells, Manuel},\n", - " year = {1996},\n", - " keywords = {Information networks., Information society., Information technology Economic aspects., Information technology Social aspects., Technology and civilization.}\n", - " }\n", - "\n", - "note:\n", - " George likes this new format.\n", - "\"\"\"" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "title: First BIB Note for Castells\n", - "tags:\n", - " - Castells\n", - " - Network Society\n", - " - Charles Babbage is Awesome\n", - " - Charles Didn't do Everything\n", - "mentions:\n", - " - gkt\n", - " - dbdennis\n", - "dates: 2016\n", - "cite:\n", - " - Castells Rise 2016\n", - " - ii-iv\n", - " - 23-36\n", - "outline:\n", - " - Introduction\n", - " - - Computers\n", - " - People\n", - " - Conclusions\n", - " - - Great Ideas of Computing\n", - "\n", - "text: |\n", - " Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam eleifend est sed diam maximus rutrum. Quisque sit amet imperdiet odio, id tristique libero. Aliquam viverra convallis mauris vel tristique. Cras ac dolor non risus porttitor molestie vel at nisi. Donec vitae finibus quam. Phasellus vehicula urna sed nibh condimentum, ultrices interdum velit eleifend. Nam suscipit dolor eu rutrum fringilla. Sed pulvinar purus purus, sit amet venenatis enim convallis a. Duis fringilla nisl sit amet erat lobortis dictum. Nunc fringilla arcu nec ex blandit, a gravida purus commodo. Vivamus lacinia tellus dui, vel maximus lacus ornare id.\n", - "\n", - " Vivamus euismod justo sit amet luctus bibendum. Integer non mi ullamcorper enim fringilla vulputate sit amet in urna. Nullam eu sodales ipsum. Curabitur id convallis ex. Duis a condimentum lorem. Nulla et urna massa. Duis in nibh eu elit lobortis vehicula. Mauris congue mauris mollis metus lacinia, ut suscipit mi egestas. Donec luctus ante ante, eget viverra est mollis vitae.\n", - "\n", - " Vivamus in purus in erat dictum scelerisque. Aliquam dictum quis ligula ac euismod. Mauris elementum metus vel scelerisque feugiat. Vivamus bibendum massa eu pellentesque sodales. Nulla nec lacus dolor. Donec scelerisque, nibh sed placerat gravida, nunc turpis tristique nibh, ac feugiat enim massa ut eros. Nulla finibus, augue egestas hendrerit accumsan, tellus augue tempor eros, in sagittis dolor turpis nec mi. Nunc fringilla mi non malesuada aliquet.\n", - "\n", - "bibkey:\n", - " Castells Rise 1996\n", - "bibtex: |\n", - " @book{castells_rise_1996,\n", - " address = {Cambridge, Mass.},\n", - " series = {Castells, {Manuel}, 1942- {Information} age . v},\n", - " title = {The rise of the network society},\n", - " isbn = {978-1-55786-616-5},\n", - " language = {eng},\n", - " publisher = {Blackwell Publishers},\n", - " author = {Castells, Manuel},\n", - " year = {1996},\n", - " keywords = {Information networks., Information society., Information technology Economic aspects., Information technology Social aspects., Technology and civilization.}\n", - " }\n", - "\n", - "note:\n", - " George likes this new format.\n", - "\n" - ] - } - ], - "source": [ - "print(myFirstZettel)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This shows how to load just the YAML portion of the document, resulting in a Python dictionary data structure. Observe that the Python dictionary has { key : value, ... }. So we can extract the YAML fields from the Python dictionary data structure.\n", - "\n", - "Notice that when you write a YAML list of mentions, there is a nested Python list ['gkt', 'dbdennis']." - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "doc = yaml.load(myFirstZettel)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Closing the loop, the following shows how to *iterate* the keys of the data structure." - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "mentions = ['gkt', 'dbdennis']\n", - "dates = 2016\n", - "outline = ['Introduction', ['Computers', 'People'], 'Conclusions', ['Great Ideas of Computing']]\n", - "bibtex = @book{castells_rise_1996,\n", - " address = {Cambridge, Mass.},\n", - " series = {Castells, {Manuel}, 1942- {Information} age . v},\n", - " title = {The rise of the network society},\n", - " isbn = {978-1-55786-616-5},\n", - " language = {eng},\n", - " publisher = {Blackwell Publishers},\n", - " author = {Castells, Manuel},\n", - " year = {1996},\n", - " keywords = {Information networks., Information society., Information technology Economic aspects., Information technology Social aspects., Technology and civilization.}\n", - "}\n", - "\n", - "title = First BIB Note for Castells\n", - "bibkey = Castells Rise 1996\n", - "tags = ['Castells', 'Network Society', 'Charles Babbage is Awesome', \"Charles Didn't do Everything\"]\n", - "cite = ['Castells Rise 2016', 'ii-iv', '23-36']\n", - "note = George likes this new format.\n", - "text = Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam eleifend est sed diam maximus rutrum. Quisque sit amet imperdiet odio, id tristique libero. Aliquam viverra convallis mauris vel tristique. Cras ac dolor non risus porttitor molestie vel at nisi. Donec vitae finibus quam. Phasellus vehicula urna sed nibh condimentum, ultrices interdum velit eleifend. Nam suscipit dolor eu rutrum fringilla. Sed pulvinar purus purus, sit amet venenatis enim convallis a. Duis fringilla nisl sit amet erat lobortis dictum. Nunc fringilla arcu nec ex blandit, a gravida purus commodo. Vivamus lacinia tellus dui, vel maximus lacus ornare id.\n", - "\n", - "Vivamus euismod justo sit amet luctus bibendum. Integer non mi ullamcorper enim fringilla vulputate sit amet in urna. Nullam eu sodales ipsum. Curabitur id convallis ex. Duis a condimentum lorem. Nulla et urna massa. Duis in nibh eu elit lobortis vehicula. Mauris congue mauris mollis metus lacinia, ut suscipit mi egestas. Donec luctus ante ante, eget viverra est mollis vitae.\n", - "\n", - "Vivamus in purus in erat dictum scelerisque. Aliquam dictum quis ligula ac euismod. Mauris elementum metus vel scelerisque feugiat. Vivamus bibendum massa eu pellentesque sodales. Nulla nec lacus dolor. Donec scelerisque, nibh sed placerat gravida, nunc turpis tristique nibh, ac feugiat enim massa ut eros. Nulla finibus, augue egestas hendrerit accumsan, tellus augue tempor eros, in sagittis dolor turpis nec mi. Nunc fringilla mi non malesuada aliquet.\n", - "\n" - ] - } - ], - "source": [ - "for key in doc.keys():\n", - " print(key, \"=\", doc[key])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "And this shows how to get any particular item of interest. In this case, we're extracting the *bibtex* key so we can do something with the embedded BibTeX (e.g. print it)." - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Castells Rise 1996\n", - "@book{castells_rise_1996,\n", - " address = {Cambridge, Mass.},\n", - " series = {Castells, {Manuel}, 1942- {Information} age . v},\n", - " title = {The rise of the network society},\n", - " isbn = {978-1-55786-616-5},\n", - " language = {eng},\n", - " publisher = {Blackwell Publishers},\n", - " author = {Castells, Manuel},\n", - " year = {1996},\n", - " keywords = {Information networks., Information society., Information technology Economic aspects., Information technology Social aspects., Technology and civilization.}\n", - "}\n", - "\n" - ] - } - ], - "source": [ - "print(doc['bibkey'])\n", - "print(doc['bibtex'])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Adapted from http://stackoverflow.com/questions/12472338/flattening-a-list-recursively. There really must be a nicer way to do stuff like this. I will rewrite this using a walker so we can have custom processing of the list items." - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "def flatten(item):\n", - " if type(item) != type([]):\n", - " return [str(item)]\n", - " if item == []:\n", - " return item\n", - " if isinstance(item[0], list):\n", - " return flatten(item[0]) + flatten(item[1:])\n", - " return item[:1] + flatten(item[1:])\n" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "['George was here']" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "flatten(\"George was here\")" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "['A', 'B', 'C', 'D', 'E']" - ] - }, - "execution_count": 9, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "flatten(['A', ['B', 'C'], ['D', ['E']]])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now we are onto some `sqlite3` explorations." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Ordinarily, I would use some sort of mapping framework to handle database operations. However, it's not clear the FTS support is part of any ORM (yet). I will continue to research but since there is likely only one table, it might not be worth the trouble." - ] - }, - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "Next we will actually add the Zettel to the database and do a test query. Almost there." - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "CREATE VIRTUAL TABLE zettels USING fts4(mentions,dates,outline,bibtex,inline,title,bibkey,ris,tags,cite,note,text,summary)\n", - "{ 'bibkey': 'Castells Rise 1996',\n", - " 'bibtex': '@book{castells_rise_1996,\\n'\n", - " ' address = {Cambridge, Mass.},\\n'\n", - " ' series = {Castells, {Manuel}, 1942- {Information} age . v},\\n'\n", - " ' title = {The rise of the network society},\\n'\n", - " ' isbn = {978-1-55786-616-5},\\n'\n", - " ' language = {eng},\\n'\n", - " ' publisher = {Blackwell Publishers},\\n'\n", - " ' author = {Castells, Manuel},\\n'\n", - " ' year = {1996},\\n'\n", - " ' keywords = {Information networks., Information society., '\n", - " 'Information technology Economic aspects., Information technology '\n", - " 'Social aspects., Technology and civilization.}\\n'\n", - " '}\\n',\n", - " 'cite': ['Castells Rise 2016', 'ii-iv', '23-36'],\n", - " 'dates': 2016,\n", - " 'mentions': ['gkt', 'dbdennis'],\n", - " 'note': 'George likes this new format.',\n", - " 'outline': [ 'Introduction',\n", - " ['Computers', 'People'],\n", - " 'Conclusions',\n", - " ['Great Ideas of Computing']],\n", - " 'tags': [ 'Castells',\n", - " 'Network Society',\n", - " 'Charles Babbage is Awesome',\n", - " \"Charles Didn't do Everything\"],\n", - " 'text': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam '\n", - " 'eleifend est sed diam maximus rutrum. Quisque sit amet imperdiet '\n", - " 'odio, id tristique libero. Aliquam viverra convallis mauris vel '\n", - " 'tristique. Cras ac dolor non risus porttitor molestie vel at nisi. '\n", - " 'Donec vitae finibus quam. Phasellus vehicula urna sed nibh '\n", - " 'condimentum, ultrices interdum velit eleifend. Nam suscipit dolor '\n", - " 'eu rutrum fringilla. Sed pulvinar purus purus, sit amet venenatis '\n", - " 'enim convallis a. Duis fringilla nisl sit amet erat lobortis '\n", - " 'dictum. Nunc fringilla arcu nec ex blandit, a gravida purus '\n", - " 'commodo. Vivamus lacinia tellus dui, vel maximus lacus ornare id.\\n'\n", - " '\\n'\n", - " 'Vivamus euismod justo sit amet luctus bibendum. Integer non mi '\n", - " 'ullamcorper enim fringilla vulputate sit amet in urna. Nullam eu '\n", - " 'sodales ipsum. Curabitur id convallis ex. Duis a condimentum lorem. '\n", - " 'Nulla et urna massa. Duis in nibh eu elit lobortis vehicula. Mauris '\n", - " 'congue mauris mollis metus lacinia, ut suscipit mi egestas. Donec '\n", - " 'luctus ante ante, eget viverra est mollis vitae.\\n'\n", - " '\\n'\n", - " 'Vivamus in purus in erat dictum scelerisque. Aliquam dictum quis '\n", - " 'ligula ac euismod. Mauris elementum metus vel scelerisque feugiat. '\n", - " 'Vivamus bibendum massa eu pellentesque sodales. Nulla nec lacus '\n", - " 'dolor. Donec scelerisque, nibh sed placerat gravida, nunc turpis '\n", - " 'tristique nibh, ac feugiat enim massa ut eros. Nulla finibus, augue '\n", - " 'egestas hendrerit accumsan, tellus augue tempor eros, in sagittis '\n", - " 'dolor turpis nec mi. Nunc fringilla mi non malesuada aliquet.\\n',\n", - " 'title': 'First BIB Note for Castells'}\n", - "INSERT INTO zettels VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)\n", - "dict_keys(['mentions', 'dates', 'outline', 'bibtex', 'inline', 'bibkey', 'ris', 'title', 'cite', 'tags', 'note', 'text', 'summary'])\n", - "[ 'gkt,dbdennis',\n", - " '2016',\n", - " 'Introduction,Computers,People,Conclusions,Great Ideas of Computing',\n", - " '@book{castells_rise_1996,\\n'\n", - " ' address = {Cambridge, Mass.},\\n'\n", - " ' series = {Castells, {Manuel}, 1942- {Information} age . v},\\n'\n", - " ' title = {The rise of the network society},\\n'\n", - " ' isbn = {978-1-55786-616-5},\\n'\n", - " ' language = {eng},\\n'\n", - " ' publisher = {Blackwell Publishers},\\n'\n", - " ' author = {Castells, Manuel},\\n'\n", - " ' year = {1996},\\n'\n", - " ' keywords = {Information networks., Information society., Information '\n", - " 'technology Economic aspects., Information technology Social aspects., '\n", - " 'Technology and civilization.}\\n'\n", - " '}\\n',\n", - " '',\n", - " 'Castells Rise 1996',\n", - " '',\n", - " 'First BIB Note for Castells',\n", - " 'Castells Rise 2016,ii-iv,23-36',\n", - " \"Castells,Network Society,Charles Babbage is Awesome,Charles Didn't do \"\n", - " 'Everything',\n", - " 'George likes this new format.',\n", - " 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam eleifend est '\n", - " 'sed diam maximus rutrum. Quisque sit amet imperdiet odio, id tristique '\n", - " 'libero. Aliquam viverra convallis mauris vel tristique. Cras ac dolor non '\n", - " 'risus porttitor molestie vel at nisi. Donec vitae finibus quam. Phasellus '\n", - " 'vehicula urna sed nibh condimentum, ultrices interdum velit eleifend. Nam '\n", - " 'suscipit dolor eu rutrum fringilla. Sed pulvinar purus purus, sit amet '\n", - " 'venenatis enim convallis a. Duis fringilla nisl sit amet erat lobortis '\n", - " 'dictum. Nunc fringilla arcu nec ex blandit, a gravida purus commodo. '\n", - " 'Vivamus lacinia tellus dui, vel maximus lacus ornare id.\\n'\n", - " '\\n'\n", - " 'Vivamus euismod justo sit amet luctus bibendum. Integer non mi ullamcorper '\n", - " 'enim fringilla vulputate sit amet in urna. Nullam eu sodales ipsum. '\n", - " 'Curabitur id convallis ex. Duis a condimentum lorem. Nulla et urna massa. '\n", - " 'Duis in nibh eu elit lobortis vehicula. Mauris congue mauris mollis metus '\n", - " 'lacinia, ut suscipit mi egestas. Donec luctus ante ante, eget viverra est '\n", - " 'mollis vitae.\\n'\n", - " '\\n'\n", - " 'Vivamus in purus in erat dictum scelerisque. Aliquam dictum quis ligula ac '\n", - " 'euismod. Mauris elementum metus vel scelerisque feugiat. Vivamus bibendum '\n", - " 'massa eu pellentesque sodales. Nulla nec lacus dolor. Donec scelerisque, '\n", - " 'nibh sed placerat gravida, nunc turpis tristique nibh, ac feugiat enim '\n", - " 'massa ut eros. Nulla finibus, augue egestas hendrerit accumsan, tellus '\n", - " 'augue tempor eros, in sagittis dolor turpis nec mi. Nunc fringilla mi non '\n", - " 'malesuada aliquet.\\n',\n", - " '']\n" - ] - } - ], - "source": [ - "import sqlite3\n", - "\n", - "# This is for showing data structures only.\n", - "\n", - "import pprint\n", - "printer = pprint.PrettyPrinter(indent=2)\n", - "\n", - "class SQLiteFTS(object): \n", - " def __init__(self, db_name, table_name, field_names):\n", - " self.db_name = db_name\n", - " self.conn = sqlite3.connect(db_name)\n", - " self.cursor = self.conn.cursor()\n", - " \n", - " self.table_name = table_name\n", - " self.fts_field_names = field_names\n", - " self.fts_field_refs = ['?'] * len(self.fts_field_names) # for sqlite insert template generation\n", - " self.fts_field_init = [''] * len(self.fts_field_names)\n", - " self.fts_fields = dict(zip(self.fts_field_names, self.fts_field_refs))\n", - " self.fts_default_record = dict(zip(self.fts_field_names, self.fts_field_init))\n", - "\n", - " def bind(self, doc):\n", - " self.record = self.fts_default_record.copy()\n", - " for k in doc.keys():\n", - " if k in self.record.keys():\n", - " self.record[k] = doc[k]\n", - " else:\n", - " print(\"Unknown fts field %s\" % k)\n", - " self.record.update(doc)\n", - " \n", - " def drop_table(self):\n", - " self.conn.execute(\"DROP TABLE IF EXISTS %s\" % self.table_name)\n", - "\n", - " def create_table(self):\n", - " sql_fields = \",\".join(self.fts_default_record.keys())\n", - " print(\"CREATE VIRTUAL TABLE zettels USING fts4(%s)\" % sql_fields)\n", - " self.conn.execute(\"CREATE VIRTUAL TABLE zettels USING fts4(%s)\" % sql_fields) \n", - " \n", - " def insert_into_table(self):\n", - " sql_params = \",\".join(self.fts_fields.values())\n", - " #printer.pprint(self.record)\n", - " #printer.pprint(self.record.values())\n", - " sql_insert_values = [ \",\".join(flatten(value)) for value in list(self.record.values())]\n", - " print(\"INSERT INTO zettels VALUES (%s)\" % sql_params)\n", - " print(self.record.keys())\n", - " printer.pprint(sql_insert_values)\n", - " self.conn.execute(\"INSERT INTO zettels VALUES (%s)\" % sql_params, sql_insert_values)\n", - "\n", - " def done(self):\n", - " self.conn.commit()\n", - " self.conn.close()\n", - " \n", - "sql = SQLiteFTS('zettels.db', 'zettels', ['title', 'tags', 'mentions', 'outline', 'cite', 'dates', 'summary', 'text', 'bibkey', 'bibtex', 'ris', 'inline', 'note' ])\n", - "\n", - "#doc_keys = list(doc.keys())\n", - "#doc_keys.sort()\n", - "#rec_keys = list(sql.record.keys())\n", - "#rec_keys.sort()\n", - "#print(\"doc keys %s\" % doc_keys)\n", - "#print(\"record keys %s\" % rec_keys)\n", - "\n", - "sql.drop_table()\n", - "sql.create_table()\n", - "printer.pprint(doc)\n", - "sql.bind(doc)\n", - "sql.insert_into_table()\n", - "sql.done()\n", - "\n", - "#sql_insert_values = [ str(field) for field in sql.record.values()]\n", - "#print(sql_insert_values)\n", - "\n", - "#print(record)" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "with open(\"xyz.txt\") as datafile:\n", - " text = datafile.read()\n", - "\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "@misc{blahblahblah,\n", - " title = {In Depth - In Depth: Ray Kurzweil - Book {TV}},\n", - " url = {http://www.booktv.org/Program/7515/In+Depth+Ray+Kurzweil.aspx},\n", - " urldate = {2011-02-11},\n", - " keywords = {*{AddedToZettels}},\n", - " file = {In Depth - In Depth\\: Ray Kurzweil - Book TV:/Users/dbdennis/Library/Application Support/Zotero/Profiles/duztnovb.default/zotero/storage/TWWBX3QV/In+Depth+Ray+Kurzweil.html:text/html}\n", - "}\n", - "\n" - ] - } - ], - "source": [ - "print(text)" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [], - "source": [ - "bibkey = 'blahblahblah'\n", - "bibtex = text\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "bibkey: blahblahblah\n", - "bibtex: |\n", - " @misc{blahblahblah,\n", - " title = {In Depth - In Depth: Ray Kurzweil - Book {TV}},\n", - " url = {http://www.booktv.org/Program/7515/In+Depth+Ray+Kurzweil.aspx},\n", - " urldate = {2011-02-11},\n", - " keywords = {*{AddedToZettels}},\n", - " file = {In Depth - In Depth\\: Ray Kurzweil - Book TV:/Users/dbdennis/Library/Application Support/Zotero/Profiles/duztnovb.default/zotero/storage/TWWBX3QV/In+Depth+Ray+Kurzweil.html:text/html}\n", - " }\n", - "\n" - ] - } - ], - "source": [ - "import yaml\n", - "from collections import OrderedDict\n", - "\n", - "class quoted(str): pass\n", - "\n", - "def quoted_presenter(dumper, data):\n", - " return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='\"')\n", - "yaml.add_representer(quoted, quoted_presenter)\n", - "\n", - "class literal(str): pass\n", - "\n", - "def literal_presenter(dumper, data):\n", - " return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='|')\n", - "yaml.add_representer(literal, literal_presenter)\n", - "\n", - "def ordered_dict_presenter(dumper, data):\n", - " return dumper.represent_dict(data.items())\n", - "yaml.add_representer(OrderedDict, ordered_dict_presenter)\n", - "\n", - "d = OrderedDict(bibkey=bibkey, bibtex=literal(bibtex))\n", - "print(yaml.dump(d))\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.6.1" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/poetry.lock b/poetry.lock new file mode 100644 index 0000000..4e57c1d --- /dev/null +++ b/poetry.lock @@ -0,0 +1,101 @@ +# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. + +[[package]] +name = "colorama" +version = "0.4.6" +description = "Cross-platform colored terminal text." +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +files = [ + {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, + {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, +] + +[[package]] +name = "exceptiongroup" +version = "1.2.2" +description = "Backport of PEP 654 (exception groups)" +optional = false +python-versions = ">=3.7" +files = [ + {file = "exceptiongroup-1.2.2-py3-none-any.whl", hash = "sha256:3111b9d131c238bec2f8f516e123e14ba243563fb135d3fe885990585aa7795b"}, + {file = "exceptiongroup-1.2.2.tar.gz", hash = "sha256:47c2edf7c6738fafb49fd34290706d1a1a2f4d1c6df275526b62cbb4aa5393cc"}, +] + +[package.extras] +test = ["pytest (>=6)"] + +[[package]] +name = "iniconfig" +version = "2.0.0" +description = "brain-dead simple config-ini parsing" +optional = false +python-versions = ">=3.7" +files = [ + {file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"}, + {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, +] + +[[package]] +name = "packaging" +version = "24.1" +description = "Core utilities for Python packages" +optional = false +python-versions = ">=3.8" +files = [ + {file = "packaging-24.1-py3-none-any.whl", hash = "sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124"}, + {file = "packaging-24.1.tar.gz", hash = "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002"}, +] + +[[package]] +name = "pluggy" +version = "1.5.0" +description = "plugin and hook calling mechanisms for python" +optional = false +python-versions = ">=3.8" +files = [ + {file = "pluggy-1.5.0-py3-none-any.whl", hash = "sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669"}, + {file = "pluggy-1.5.0.tar.gz", hash = "sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1"}, +] + +[package.extras] +dev = ["pre-commit", "tox"] +testing = ["pytest", "pytest-benchmark"] + +[[package]] +name = "pytest" +version = "8.3.3" +description = "pytest: simple powerful testing with Python" +optional = false +python-versions = ">=3.8" +files = [ + {file = "pytest-8.3.3-py3-none-any.whl", hash = "sha256:a6853c7375b2663155079443d2e45de913a911a11d669df02a50814944db57b2"}, + {file = "pytest-8.3.3.tar.gz", hash = "sha256:70b98107bd648308a7952b06e6ca9a50bc660be218d53c257cc1fc94fda10181"}, +] + +[package.dependencies] +colorama = {version = "*", markers = "sys_platform == \"win32\""} +exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} +iniconfig = "*" +packaging = "*" +pluggy = ">=1.5,<2" +tomli = {version = ">=1", markers = "python_version < \"3.11\""} + +[package.extras] +dev = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] + +[[package]] +name = "tomli" +version = "2.0.1" +description = "A lil' TOML parser" +optional = false +python-versions = ">=3.7" +files = [ + {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, + {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, +] + +[metadata] +lock-version = "2.0" +python-versions = "^3.10" +content-hash = "9ee9e740b3f82cf45aebad516c7a4dc67c2b853898cbc8b87840783690bcd6ce" diff --git a/project/assembly.sbt b/project/assembly.sbt deleted file mode 100644 index a740601..0000000 --- a/project/assembly.sbt +++ /dev/null @@ -1,2 +0,0 @@ -addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.1") - diff --git a/project/build.properties b/project/build.properties deleted file mode 100644 index 64317fd..0000000 --- a/project/build.properties +++ /dev/null @@ -1 +0,0 @@ -sbt.version=0.13.15 diff --git a/project/plugins.sbt b/project/plugins.sbt deleted file mode 100644 index 6ec84aa..0000000 --- a/project/plugins.sbt +++ /dev/null @@ -1,4 +0,0 @@ -addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.6.0") -addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.1.9") -addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "0.8.0") - diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..c32e500 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,21 @@ +[tool.poetry] +name = "src" +version = "0.1.0" +description = "ZettelGeist - a historigraphically focused notetaking system" +license = "GNU Affero" +authors = ["George K. Thiruvathukal ", "Nicholas M. Synovic "] +readme = "README.md" +homepage = "https://github.com/ZettelGeist/ZettelGeist" +repository = "https://github.com/ZettelGeist/ZettelGeist" +keywords = ["notetaking", "YAML", "Markdown", "sqlite3", "GitHub"] +classifiers = ["Development Status :: 4 - Beta", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3 :: Only", "Topic :: Software Development", "License :: OSI Approved :: Apache Software License"] + + +[tool.poetry.dependencies] +python = "^3.10" +pytest = "^8.3.3" + + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 5dae8d2..9aee001 100644 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -5,4 +5,3 @@ rm -rf dist/* python setup.py sdist bdist_wheel twine upload --repository pypi dist/* - diff --git a/setup.py b/setup.py deleted file mode 100644 index 386f90a..0000000 --- a/setup.py +++ /dev/null @@ -1,38 +0,0 @@ -# setup.py - placeholder for eventual setup script - -from setuptools import setup -from zettelgeist import zversion - -setup( - name='zettelgeist', - packages=['zettelgeist'], - version=zversion.version(), - description='ZettelGeist - a historiographically focused notetaking system', - long_description='ZettelGeist - a historiographically focused notetaking system', - author='ZettelGeist Laboratories', - author_email='gkt@cs.luc.edu', - license='Apache License 2.0', - url='https://github.com/zettelgeist/zettelgeist', - keywords=['notetaking', 'YAML', 'Markdown', 'sqlite3', 'GitHub'], - classifiers=[ - 'Development Status :: 4 - Beta', - 'Programming Language :: Python :: 3', - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3 :: Only", - "Topic :: Software Development", - 'License :: OSI Approved :: Apache Software License' - ], - python_requires='>=3.10', - install_requires=[ - 'python-frontmatter', - 'tatsu' - ], - entry_points = { - 'console_scripts': [ - 'zcreate = zettelgeist.zcreate:main', - 'zimport = zettelgeist.zimport:main', - 'zfind = zettelgeist.zfind:main', - 'zettel = zettelgeist.zettel:main' - ] - } -) diff --git a/sphinx-docs/Makefile b/sphinx-docs/Makefile deleted file mode 100644 index d0c3cbf..0000000 --- a/sphinx-docs/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -# Minimal makefile for Sphinx documentation -# - -# You can set these variables from the command line, and also -# from the environment for the first two. -SPHINXOPTS ?= -SPHINXBUILD ?= sphinx-build -SOURCEDIR = source -BUILDDIR = build - -# Put it first so that "make" without argument is like "make help". -help: - @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) - -.PHONY: help Makefile - -# Catch-all target: route all unknown targets to Sphinx using the new -# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). -%: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/sphinx-docs/make.bat b/sphinx-docs/make.bat deleted file mode 100644 index 6247f7e..0000000 --- a/sphinx-docs/make.bat +++ /dev/null @@ -1,35 +0,0 @@ -@ECHO OFF - -pushd %~dp0 - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=sphinx-build -) -set SOURCEDIR=source -set BUILDDIR=build - -if "%1" == "" goto help - -%SPHINXBUILD% >NUL 2>NUL -if errorlevel 9009 ( - echo. - echo.The 'sphinx-build' command was not found. Make sure you have Sphinx - echo.installed, then set the SPHINXBUILD environment variable to point - echo.to the full path of the 'sphinx-build' executable. Alternatively you - echo.may add the Sphinx directory to PATH. - echo. - echo.If you don't have Sphinx installed, grab it from - echo.http://sphinx-doc.org/ - exit /b 1 -) - -%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% -goto end - -:help -%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% - -:end -popd diff --git a/sphinx-docs/source/about.rst b/sphinx-docs/source/about.rst deleted file mode 100644 index 6db08d1..0000000 --- a/sphinx-docs/source/about.rst +++ /dev/null @@ -1,34 +0,0 @@ -About -====== - -ZettelGeist is a plaintext note-taking system, inspired by the -`ZettelKasten -Method `__. - -The project founders have both been interested in taking notes long -before discovering ZettelKasten. We really like the thought process -behind ZettelKasten, however, and think it is ahead of its time by being -“less is more” in its focus. - -A key, salient feature of our approach to implementing a ZettelKasten -system is *not* to get distracted by GUI tools at an early stage of -development. The default assumption of our system is that we work from -plaintext files. We are particularly inspired by systems like Jekyll (a -static-site generator for building web sites) that uses YAML to organize -its front matter and Markdown as the body. We’re even starting more -simply by just using YAML without Markdown, although we might introduce -it at release time. The idea is to focus on true notetaking by not -encouraging the writing of large, complex documents (which aren’t really -notes, right??) - -So ZettelGeist is aimed at supporting the *spirit* of ZettelKasten, -while ensuring that it will be useful in other domains. Our primary -audience is the scholar who wants to write notes using a simple text -editor and storing these notes in the cloud, e.g. in Dropbox, GitHub, -etc. While we’d love to build something like the successor to Evernote -or OneNote–even as a graphical client–our view is that no such tool -should be developed without having the right core abstractions in place. -Ultimately, the *note* is the central abstraction. Having support for -metadata is crucial, especially for scholarly–or other serious–projects. - -Stay tuned!! diff --git a/sphinx-docs/source/conf.py b/sphinx-docs/source/conf.py deleted file mode 100644 index ee69074..0000000 --- a/sphinx-docs/source/conf.py +++ /dev/null @@ -1,76 +0,0 @@ -# Configuration file for the Sphinx documentation builder. -# -# This file only contains a selection of the most common options. For a full -# list see the documentation: -# https://www.sphinx-doc.org/en/master/usage/configuration.html - -# -- Path setup -------------------------------------------------------------- - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -# -import os -import sys -# sys.path.insert(0, os.path.abspath('.')) - - -# -- Project information ----------------------------------------------------- - -project = 'ZettelGeist' -copyright = '2020, George K. Thiruvathukal and David B. Dennis' -author = 'George K. Thiruvathukal and David B. Dennis' - -# The full version, including alpha/beta/rc tags -version = os.environ.get("BOOK_VERSION", "beta") -release = version - - -rst_epilog = """ - -.. |site-version| replace:: **version %(version)s** - -""" % vars() - -# -- General configuration --------------------------------------------------- - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - 'sphinx.ext.todo', - 'sphinx.ext.mathjax', -] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] -source_suffix = ['.rst', '.md'] - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -# This pattern also affects html_static_path and html_extra_path. -exclude_patterns = [] - - -# -- Options for HTML output ------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -# -html_theme = 'alabaster' - -html_theme_options = { - 'logo': 'peace.png', - 'github_user': 'zettelgeist', - 'github_repo': 'zettelgeist', - #'analytics_id' : 'UA-23507985-1', - 'extra_nav_links' : { - 'Site Index' : 'genindex.html', - 'Software Systems Laboratory' : 'https://ssl.cs.luc.edu', - } -} - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] diff --git a/sphinx-docs/source/gs.rst b/sphinx-docs/source/gs.rst deleted file mode 100644 index e3f19f9..0000000 --- a/sphinx-docs/source/gs.rst +++ /dev/null @@ -1,335 +0,0 @@ -Getting Started -=================== - - -Prerequisites -------------- - -Please visit the `Installation `__ before starting the -tutorial. This tutorial assumes you have installed ZettelGeist and have -confirmed that the tools are available in a Python virtualenv. - -We assume that your virtualenv is named ``zenv`` here. Wherever you see -``zenv`` here, your setup can be different, as long as you completed the -installation and verified that it is nominally functioning. - -This tutorial also depends on sample files, provided at -https://github.com/ZettelGeist/zg-tutorial. You can visit this page to -download the examples, or you can use ``git`` to fetch it: - -.. code:: shell - - $ git clone https://github.com/ZettelGeist/zg-tutorial.git - -This will create the folder ``zg-tutorial``, which we’ll reference in -this tutorial. - -Creating Zettels ----------------- - -The ``zettel`` command is used to create zettels. You can also create -zettels using an ordinary text editor. - -Getting help -~~~~~~~~~~~~ - -.. code:: shell - - zettel --help - -The help shows what at first glance appears to be a bewildering number -of options. However, most of the options are *the same* and are just -being used to do an operation (set, delete, append, etc.) on any given -field. - -Create a simple zettel -~~~~~~~~~~~~~~~~~~~~~~ - -.. code:: shell - - zettel --set-title "My First Zettel" - -This results in the following output: - -.. code:: yaml - - title: My First Zettel - -Create zettel with multiple fields -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -A zettel can have as few fields as you wish, including zero. However, a -zettel only becomes interesting as you add more information. Let’s add a -*summary* and a *note*. - -.. code:: shell - - zettel --set-title "My First Zettel" --set-summary "A Zettel with a note" --set-note "Line 1\nLine 2\nLine 3" - -This results in - -.. code:: yaml - - title: My First Zettel - summary: A Zettel with a note - note: |- - Line 1 - Line 2 - Line 3 - -When setting a field to a string value as we have done for each of these -fields, it is permitted to have *embedded newlines* anywhere you like. -For the note we have written, we have three input lines, each of which -appears on a separate line. - -YAML (the format in which Zettels are stored) provides excellent support -for this concept and will take your text and indent it using a multiline -string. As long as each line is indented consistently relative to the -*note* key, it will be valid. - -Obviously, writing longer strings using the command line is sometimes -impractical, so we created two ways of being able to do this easily: -prompting for input (using the ``--prompt-`` options) or by -loading the plaintext from a file (using ``--load-``). Each of -these is easy to demonstrate. - -Let’s try loading some text by having ``zettel`` prompt for it. We’ll -modify the above command as follows: - -.. code:: shell - - zettel --set-title "My First Zettel" --set-summary "A Zettel with a note" --prompt-note - -:: - - Enter text for note. ctrl-d to end. - note> Line 1 - note> Line 2 - note> Line 3 - note> - note> Even a blank line is allowed. - note> - -Results - -.. code:: yaml - - title: My First Zettel - summary: A Zettel with a note - note: |- - Line 1 - Line 2 - Line 3 - - Even a blank line is allowed. - -Load field from another file -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -TODO - -Indexing Zettels for Search ---------------------------- - -For this section, we provide you with access to some sample zettels. -These can be found in the ZettelGeist tutorial repository at -https://github.com/ZettelGeist/zg-tutorial.git. (See Prerequisites -above.) - -You can be in any folder while trying this, but we’ll assume you are in -the ``zettelgeist\docs`` after performing an initial clone of our -repository. - -.. code:: shell - - $ cd zg-tutorial - $ zcreate --database mlb.db - Creating new database mlb.db - - -.. code:: shell - - $ ls zettels/baseball - - arizona-diamondbacks.yaml milwaukee-brewers.yaml - atlanta-braves.yaml minnesota-twins.yaml - baltimore-orioles.yaml new-york-mets.yaml - boston-red-sox.yaml new-york-yankees.yaml - chicago-cubs.yaml oakland-athletics.yaml - chicago-grey-sox.yaml philadelphia-phillies.yaml - cincinnati-reds.yaml pittsburgh-pirates.yaml - cleveland-indians.yaml san-diego-padres.yaml - colorado-rockies.yaml seattle-mariners.yaml - detroit-tigers.yaml st-louis-cardinals.yaml - houston-astros.yaml tampa-bay-rays.yaml - kansas-city-royals.yaml texas-rangers.yaml - los-angeles-angels.yaml toronto-blue-jays.yaml - los-angeles-dodgers.yaml washington-nationals.yaml - miami-marlins.yaml``` - - -.. code:: shell - - $ zimport --database mlb.db --dir $(pwd) - - Importing /Users/gkt/Work/zg-tutorial/zettels/baseball/baltimore-orioles.yaml - Importing /Users/gkt/Work/zg-tutorial/zettels/baseball/kansas-city-royals.yaml - Importing /Users/gkt/Work/zg-tutorial/zettels/baseball/los-angeles-angels.yaml - Importing /Users/gkt/Work/zg-tutorial/zettels/baseball/miami-marlins.yaml - Importing /Users/gkt/Work/zg-tutorial/zettels/baseball/milwaukee-brewers.yaml - Importing /Users/gkt/Work/zg-tutorial/zettels/baseball/seattle-mariners.yaml - Importing /Users/gkt/Work/zg-tutorial/zettels/baseball/arizona-diamondbacks.yaml - Importing /Users/gkt/Work/zg-tutorial/zettels/baseball/st-louis-cardinals.yaml - Importing /Users/gkt/Work/zg-tutorial/zettels/baseball/houston-astros.yaml - Importing /Users/gkt/Work/zg-tutorial/zettels/baseball/oakland-athletics.yaml - Importing /Users/gkt/Work/zg-tutorial/zettels/baseball/boston-red-sox.yaml - Importing /Users/gkt/Work/zg-tutorial/zettels/baseball/new-york-yankees.yaml - Importing /Users/gkt/Work/zg-tutorial/zettels/baseball/pittsburgh-pirates.yaml - Importing /Users/gkt/Work/zg-tutorial/zettels/baseball/detroit-tigers.yaml - Importing /Users/gkt/Work/zg-tutorial/zettels/baseball/cincinnati-reds.yaml - [...] - -What you see will differ slightly. Where you see ``/Users/gkt/Work``, -you are likely to see the path to your own checkout directory. - -Let’s look at one of these zettels. - -.. code:: yaml - - title: MLB Teams - summary: Arizona Diamondbacks - note: | - The Arizona Diamondbacks, often shortened as the D-backs, are an American professional - baseball franchise based in Phoenix, Arizona. The club competes in Major League - Baseball (MLB) as a member of the National League (NL) West division. Since the - team's inception in 1998, the franchise has played home games at Chase Field, formerly - known as Bank One Ballpark. The Diamondbacks have won one World Series championship - (in 2001), becoming the fastest expansion team in the Major Leagues to win a championship, - doing it in only the fourth season since the franchise's inception in the 1998 Major - League Baseball season. - tags: - - MLB - - National League - - NL West - cite: - bibkey: arizona-diamondbacks-wikipedia - page: web page - -Each of these zettels contains some information one might typically -place on a note card. In our view of the world, notes would include -important basics. The note will often be one of the longer fields. It -can be written using what is known as the YAML block style. This means -that all lines of input are taken, provided they maintain the same -indentation level and/or blank. Everything will be taken as input until -the next field or end of file is found. - -Also shown here are how you can maintain a list of tags. The ``tags`` -field allows you to specify one or more tags. While we hope one day to -build an auto-classifier (someday, someday…), we find that we actually -need to assign labels, especially in our own book project that is -actually making use of these tools. - -Search Examples ---------------- - -Searching is done (at present) using the ``zfind`` tool. This tool can -only perform AND-style queries, but it will soon offer every conceivable -possibility. This limitation is similar to what you find in systems like -Gmail’s search operators, but even Gmail allows for NOT terms. - -The ``zfind`` tool has options to search every field. Once a field -matches, you can use the show options to project values from the Zettel. -There is also a ``--count`` option to tell you how many Zettels matched -a query. - -Find how many Zettels mention Chicago in the ``summary`` field: - -:: - - zfind --database mlb.db --find-summary Chicago --count - 2 Zettels matched search - -…and print the ``summary and``\ filename\` of the zettels: - -:: - - zfind --database mlb.db --find-summary Chicago --count --show-filename - filename: - 20170731132024-chicago-cubs.yaml - - ---------------------------------------- - - filename: - 20170731155613-chicago-grey-sox.yaml - - ---------------------------------------- - - 2 Zettels matched search - -…and show the ``summary`` about the teams: - -:: - - zfind --database mlb.db --find-summary Chicago --count --show-filename --show-summary - summary: - Chicago Cubs - - filename: - 20170731132024-chicago-cubs.yaml - - ---------------------------------------- - - summary: - Chicago White Sox - - filename: - 20170731155613-chicago-grey-sox.yaml - - ---------------------------------------- - -Find the terms MLB and Central in the ``note`` field. Upon finding a -match, show the ``filename`` and the ``summary`` fields. - -:: - - zfind --database mlb.db --find-note "MLB Central" --show-filename --show-summary - summary: - Chicago Cubs - - filename: - 20170731132024-chicago-cubs.yaml - - ---------------------------------------- - - summary: - Cincinnati Reds - - filename: - 20170731133642-cincinnati-reds.yaml - - ---------------------------------------- - - summary: - Pittsburgh Pirates - - filename: - 20170731135121-pittsburgh-pirates.yaml - - ---------------------------------------- - - summary: - St. Louis Cardinals - - filename: - 20170731135823-st-louis-cardinals.yaml - - ---------------------------------------- - -Find all zettels with Cubs mentioned in the ``note`` field: - -:: - - zfind --database mlb.db --find-note Cubs --show-note - - note: - The Chicago Cubs are an American professional baseball team based in Chicago, Illinois. The Cubs compete in Major League Baseball (MLB) as a member club of the National League (NL) Central division, where they are the defending World Series champions. The team plays its home games at Wrigley Field, located on the city's North Side. The Cubs are one of two major league teams in Chicago; the other, the Chicago White Sox, is a member of the American League (AL) Central division. The Cubs, first known as the White Stockings, was a founding member of the NL in 1876, becoming the Chicago Cubs in 1903.[2] The Cubs have appeared in a total of eleven World Series. The 1906 Cubs won 116 games, finishing 116–36 and posting a modern-era record winning percentage of .763, before losing the World Series to the Chicago White Sox by four games to two. The Cubs won back-to-back World Series championships in 1907 and 1908, becoming the first major league team to play in three consecutive World Series, and the first to win it twice. Most recently, the Cubs won the 2016 National League Championship Series and 2016 World Series, which ended a 71-year National League pennant drought and a 108-year World Series championship drought, diff --git a/sphinx-docs/source/index.rst b/sphinx-docs/source/index.rst deleted file mode 100644 index eeb4b6d..0000000 --- a/sphinx-docs/source/index.rst +++ /dev/null @@ -1,17 +0,0 @@ -Welcome to ZettelGeist -====================== - -ZettelGeist is research software for plaintext notettaking. - -.. toctree:: - :hidden: - :caption: Contents: - - about - gs - install - team - thenote - tutorial-gdocs - tutorial-terminal - tutorial-world diff --git a/sphinx-docs/source/install.rst b/sphinx-docs/source/install.rst deleted file mode 100644 index 6ffda30..0000000 --- a/sphinx-docs/source/install.rst +++ /dev/null @@ -1,102 +0,0 @@ -Prerequisites for All Installations ------------------------------------ - -Python 3 is *required* to use ZettelGeist. We don’t have resources to -support multiple versions of Python. - -We also recommend installing -`bibutils `__ and -`sqlite3 with full-text search `__. -You may not need either of these, but should you run into issues, we may -ask you to share some output from sqlite3 commands with us in your bug -reports. - -We only support Unix/Linux, OS X using `Homebrew `__, -and Windows using `Windows Subsystem for -Linux `__. - -Please also note that ZettelGeist is not a web-based or GUI program -(yet). This system is for people who *prefer* working with plaintext, -text editors, and the command line. If this is not you, you will -probably not like ZettelGeist and should proceed at your own peril. - -Installation for General Users ------------------------------- - -- Create a virtual environment for running ZettelGeist: - - .. code:: shell - - python3 -m venv ~/zenv - - You can install your environment wherever you like, but we are going - to assume ``~/zenv`` in the remaining discussion and in our tutorial - to *avoid* having to talk about user-specific details. - -- Source the virtual environment - - .. code:: shell - - . ~/zenv/bin/activate - -- And *ensure* that you are picking up the right ``python`` and - ``pip``. - - .. code:: shell - - ~ . ~/zenv/bin/activate - (zenv) ~ which pip - /Users/gkt/zenv/bin/pip - (zenv) ~ which python - /Users/gkt/zenv/bin/python - - Your username would likely appear above instead of *gkt*, unless you - share my initials. - -- Now install ZettelGeist - - .. code:: shell - - (zenv) ~ pip install zettelgeist - Collecting zettelgeist - Downloading zettelgeist-0.12.2-py3-none-any.whl - Collecting tatsu (from zettelgeist) - Using cached TatSu-4.2.5-py2.py3-none-any.whl - Collecting PyYAML (from zettelgeist) - Installing collected packages: tatsu, PyYAML, zettelgeist - Successfully installed PyYAML-3.12 tatsu-4.2.5 zettelgeist-0.12.2 - - If you see ``zettelgeist-`` in the above output, you should - have a successful install. Let’s verify: - - .. code:: shell - - (zenv) ~ which zcreate - /Users/gkt/zenv2/bin/zcreate - (zenv) ~ which zimport - /Users/gkt/zenv2/bin/zimport - (zenv) ~ which zquicksearch - /Users/gkt/zenv2/bin/zquicksearch - (zenv) ~ which zfilter - /Users/gkt/zenv2/bin/zfilter - (zenv) ~ which zettel - /Users/gkt/zenv2/bin/zettel - -- And create your first zettel: - - .. code:: shell - - zettel --set-title "My First Zettel" --set-summary "I feel empowered." --append-tags "Tutorial" "ZettelGeist" "Install" - title: My First Zettel - summary: I feel empowered. - tags: - - Tutorial - - ZettelGeist - - Install - -- Then you should proceed to the `Getting Started `__ page. - -Developer Install ------------------ - -Coming soon. diff --git a/sphinx-docs/source/team.rst b/sphinx-docs/source/team.rst deleted file mode 100644 index f685804..0000000 --- a/sphinx-docs/source/team.rst +++ /dev/null @@ -1,8 +0,0 @@ -Team -========== - - -- `George K. Thiruvathukal `__ - - Professor of Computer Science at Loyola University Chicago -- `David B. Dennis `__ - - Professor of History at Loyola University Chicago diff --git a/sphinx-docs/source/thenote.rst b/sphinx-docs/source/thenote.rst deleted file mode 100644 index 6f3180d..0000000 --- a/sphinx-docs/source/thenote.rst +++ /dev/null @@ -1,93 +0,0 @@ -The Note Format -================= - -A note is nothing more than a YAML document. Please note that, -hereafter, we may use the terms notes, cards, and zettels rather -interchangeably. We’ve used other systems and sometimes find ourselves -using the terminology rather freely. - -When we use the term *note*, please keep in mind that the term as we see -it is interchangeable with *index cards*, *cards*, or *zettels*. So -regardless of what terminlology you prefer, we welcome you! - -Anyway, the idea of notetaking is to keep it simple, so a note should -make no assumptions about formatting whatsoever. In our view of the -world, we should be able to introduce other fields but are hopeful that -we have identified most of the important ones. - -In our current thinking, we have the following sections: - -- title: an optional title (string) -- tags: one or more keywords (list of string) -- mentions: one or more mentions (list of string) -- dates: a year (string) and era (string) as a nested dictionary -- bibtex, ris, or inline (string) -- url (string) -- bibkey (string) -- cite: a bibkey (from same or another zettel) and a page number (or - range of page numbers) -- summary: (string) - concise summary of the note (by convention) -- note (string) - details, usually the text you are wanting to cite -- comment (string) - any comment you want to make about the zettel in - general - -In most situations, freeform text is permitted. In some situations, you -will need to put quotes around the text, especially if you are using -reserved YAML characters. - -These all are intended to be string data, so there are no restrictions -on what can be in any field; however, we will likely limit tags, -mentions, dates in some way as we go forward. Fields such as bibtex, -ris, or inline are also subject to validity checking. - -Here’s an example where of a zettel where most fields are being used. - -.. code:: yaml - - title: First BIB Note for Castells - tags: - - Castells - - Network Society - - Charles Babbage is Awesome - - Charles Didn't do Everything - mentions: - - gkt - - dbdennis - dates: - year: "2016" - era: "AD" - cite: - bibkey: Castells Rise 2016 - page: ii-iv - comment: This is my first zettel but my comments have nothing to do with the note itself. - summary: Lorem ipsum rocks. This is a summary of what you see in the note field. - note: | - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam eleifend est sed diam maximus rutrum. Quisque sit amet imperdiet odio, id tristique libero. Aliquam viverra convallis mauris vel tristique. Cras ac dolor non risus porttitor molestie vel at nisi. Donec vitae finibus quam. Phasellus vehicula urna sed nibh condimentum, ultrices interdum velit eleifend. Nam suscipit dolor eu rutrum fringilla. Sed pulvinar purus purus, sit amet venenatis enim convallis a. Duis fringilla nisl sit amet erat lobortis dictum. Nunc fringilla arcu nec ex blandit, a gravida purus commodo. Vivamus lacinia tellus dui, vel maximus lacus ornare id. - - Vivamus euismod justo sit amet luctus bibendum. Integer non mi ullamcorper enim fringilla vulputate sit amet in urna. Nullam eu sodales ipsum. Curabitur id convallis ex. Duis a condimentum lorem. Nulla et urna massa. Duis in nibh eu elit lobortis vehicula. Mauris congue mauris mollis metus lacinia, ut suscipit mi egestas. Donec luctus ante ante, eget viverra est mollis vitae. - - Vivamus in purus in erat dictum scelerisque. Aliquam dictum quis ligula ac euismod. Mauris elementum metus vel scelerisque feugiat. Vivamus bibendum massa eu pellentesque sodales. Nulla nec lacus dolor. Donec scelerisque, nibh sed placerat gravida, nunc turpis tristique nibh, ac feugiat enim massa ut eros. Nulla finibus, augue egestas hendrerit accumsan, tellus augue tempor eros, in sagittis dolor turpis nec mi. Nunc fringilla mi non malesuada aliquet. - bibkey: - Castells Rise 1996 - bibtex: | - @book{castells_rise_1996, - address = {Cambridge, Mass.}, - series = {Castells, {Manuel}, 1942- {Information} age . v}, - title = {The rise of the network society}, - isbn = {978-1-55786-616-5}, - language = {eng}, - publisher = {Blackwell Publishers}, - author = {Castells, Manuel}, - year = {1996}, - keywords = {Information networks., Information society., Information technology Economic aspects., Information technology Social aspects., Technology and civilization.} - } - -Here is a simple example of a bookmark: - -.. code:: yaml - - title: Zettelgeist.com - url: http://zettelgeist.com - note: Zettelgeist is a plaintext notetaking system designed for scholarly/research purposes. - -It’s really that simple! diff --git a/sphinx-docs/source/tutorial-gdocs.rst b/sphinx-docs/source/tutorial-gdocs.rst deleted file mode 100644 index 3579923..0000000 --- a/sphinx-docs/source/tutorial-gdocs.rst +++ /dev/null @@ -1,549 +0,0 @@ -Gdocs -======== - - -**This page is under construction. Pardon the sketchiness for now.** - -What do you want to do? ------------------------ - -- Take research notes for a paper in order to be able to search them - for … anything. - -- Follow the traditional (and ever-valid) methods of writing a note - with a title, some keywords (tags), a note (with comment or summary - if desired), and some bibliographical information (book or article - title and page number[s]). - -- Find particular notes on particular themes and issues. - -- Send those particular notes to a file that will be the basis for a - portion of your outline or draft. - -All of these basic research, organization, and writing steps are steeped in traditional methods. ------------------------------------------------------------------------------------------------- - -- As researchers and writers of papers, articles, books – from grade - school, high school, college, graduate school, through our - professional writings – as well as teachers and editors of countless - efforts by others, we know the game. Indeed, we are the coaches and - referees and main players of the game! And our own coaches taught us - how to do it right! - -- On the basis of this experience, we made ZettelGeist to do the most - important, fundamental steps of research and writing as clearly and - directly as possible, based on the methods that our mentors used to - write great books before personal computers came into being. - -- But because we are ourselves computerized (having come into - professional life just as the pc revolution occurred and, therefore, - having played *that game* ever since), we have here merged these - techniques into the computer world more directly than any program has - before. (Believe us: we know! We have tried and deployed every option - out there, from 1980 until yesterday – as a matter of professional - need.) - -- Since we know the frustration that many so-called “notetaking - programs” cause, we have made a fundamental decision to ensure that - the basis for all of this is already in the computer you own and the - internet sites you have access to. - -- You don’t have to go and buy anything new. You already have - *supercomputers* that earlier great writers could never have - imagined. This system will just help you to take advantage of these - machines in ways consistent with the key principles of research and - organization that the great writers developed, but most computer - programs have left out. - -- This is the Research-Writing-Computer Singularity we have been - waiting for! - -The first thing to know is that with ZettelGeist you can do ALL of the above by starting (and finishing) your writing with ANY SOFTWARE YOU WANT TO USE!! The ZettelGeist program works with and *between* your preferred word processors. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -- Many programs suggest they are “app-gnostic” (agnostic or indifferent - about which app you use), but that usually just means you can save - your work into another format (docx, pdf, txt, etc.). - -- ZettelGeist is truly app neutral in the sense that you can make notes - (zettels) with any software, as long as you make them according to a - certain pattern (indicating note section, title section, etc…) and - save or download them in good old “.txt” format. - -- The “pattern” is exactly what you would use to write out a notecard - in the traditional way (by hand, or typed on paper or computer), so - it really isn’t that big a deal. Plus, once you make one card (or - zettel), you can just edit the same card to make any necessary - changes for the next card (change the note, change the page numbers, - etc.) then save the new card with a new filename, eg. “note02.txt” - and move on… - -- You can do this with ANY word processor you want to use: Google Docs, - Microsoft Word, LibreOffice. In fact, you could just use one of the - most basic editors that are already residing on your computer, or - easily installed for free: Notepad, Wordpad (on Windows), TextEdit - (Mac), Vim, Emacs, etc. - -- If that last sentence confuses you, don’t worry. Just use Google Docs - or Word or whatever you are used to. (The surprise is that you don’t - actually have to buy any word processor at all because the above - basic text editors come with your system and ZettelGeist would allow - you to use those for free to research, organize, and write any great - work you need to produce – but let’s set that issue aside for the - moment.) - -Let’s try it out with Google Docs since we all have access to that. -------------------------------------------------------------------- - -- As you can see on the “Get Started” and “Note Format” page above, a - note in ZettelGeist is just a set of information put together in - sections marked with a colon, like title: or note: or tags:, etc. - -- There are a number of those built into the system (see Note Format - page) because, as researchers, we know you might also want to - “comment:” or write a “summary:” or add bibliographical information - such as “bibkey:” and “pages:”, and so on. - -- BUT this is completely up to you. You can add any of these elements, - or only one or two, in any order according to your needs. A - completely valid note would just start with “note:” and then just - consist of the text of your note in the following line surrounded by - quotations, including all the information you want to produce or - record right there. That would work just fine. You could then save it - as “note-01.txt” and it could be processed in ZettelGeist without a - problem (after a minor change to the filename so it can be searched - and used in the system – more on that in a minute). - -- If you want the other elements, like title: summary: or comment: - great, just add them too. As long as you name sections according to - the list on the “Note Format” page, or listed in “zettel –help”, you - can create notes however you prefer, with sections in whatever order - you like. Basically, you are making up your own notetaking system - (based on these universally valid “fields”) and can treat any “file” - as a blank notecard, just as you do when you buy a pack of 3 x 5 - notecards at the pharmacy and make flash cards for a high school - class. Fill them out as you like! - -So, with that flexibilty in mind, let’s make your first note. -------------------------------------------------------------- - -For now, just go to Google Docs (or Word, or…your choice – but we will use Google Docs for this example since we all have access and some familiarity with this editor.) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -- Start a new Doc. - -- Then take one step that will help with this experiment. - - - Go to “Tools>Preferences” and **uncheck** most of the automatic - styling elements. - -``Uncheck "Automatically capitalize" "Use smart quotes" "Automatically detect lists" and the main "Automatic substitution."`` - -- We want the simplest and plainest characters possible (most programs - add fancier “unicode” characters with these features – but we don’t - need them and they actually mess up searching and finding later). - -- You can always turn these back on later, but you probably wouldn’t - miss most of these anyway. - -- Close preferences and then just look at your plain Doc page. But now - you can think of it a little differently. This is now a *notecard* - (right out of your 3 x 5 package)! Even though it is on a - supercomputer in the “cloud” linked to the internet, it is just a - “card” now. Let’s just fill it in as we would by hand. - -- Let’s say you want to give it a title (remember, it’s up to you - whether you need a title, but this will remind you what this field - and other subsequent ones in this research session are about). - -- So, type: - -``title: Reading notes on The Great Gatsby`` - -- Ok. That’s the top line of your note, just like on the “red” line of - your good old notecard. - -- Now, let’s put in something about the book you are reading, for - instance (you could be taking notes for anything including your own - novel or writing poetry or writing a shopping list, but we are - thinking research paper for now). - -- Make a new line and type: - -``note: "This is a note about The Great Gatsby, a novel by F. Scott Fitzgerald. Written during The Jazz Age, it is a masterpiece of American Literature."`` - -- Notice that I put the text part of this note: “inside quotation - marks.” This is necessary when you write longer notes because it - means you can put quotes and colons and multiple lines into your - plain text card. Just a formality, but not a big deal. If you just - write a single line without colons and other such things, you don’t - need the quotes. But it works better with them if you are making - notes this initial way with GDocs or another word processer. - -- For now, let’s just stop there and see what we can do with that very - first note. - -- Let’s name the file, on Google Docs, by simply clicking in the file - name box above (as usual – you know) and typing “Gatsby-Note”. - -- Now let’s download it to your computer so we can soon make it into a - zettel for research processing. - -- Click “File>Download as” and select “Plain Text (.txt)”. - -- Immediately, it will save to your computer (into the directory set by - your browser for downloads – usually Downloads). - -- If you want, you can click on the download tab at the bottom of your - browser to open it, or go into the directory to see it there. It will - look just like your original, but maybe a little simpler in a plain - text editor (which is retro-cool). - -But let’s make a couple of more notes (zettels) before we do any more. ----------------------------------------------------------------------- - -- All you need to do to make your next note(s) is edit your existing - Google Doc! You don’t have to create a new one or anything. You - already saved your first card, so it is safe. Now just edit your next - one on the basis of this start, and save the new iteration as the - next note. - -- We can leave title: the same… So no changes there. - -- Let’s change the note: (obviously). Just highlight from the first - quotation mark to the last, delete the original note, and write - another. - -``note: "The novel opens with the lines 'In my younger and more vulnerable years my father gave me some advice that I’ve been turning over in my mind ever since. 'Whenever you feel like criticizing any one,' he told me, 'just remember that all the people in this world haven’t had the advantages that you’ve had.' (Gatsby, 1)"`` - -- We just added a quote from the book. So you might want to write - something about that citation (your own opinion of its importance, - etc.) as well. (Teachers want to hear your voice, and you want to - remember why you took the note.) - -- That’s simple: You could just add something to the “note:” section - itself: - -``"The novel opens with the lines 'In my younger and more vulnerable years my father gave me some advice that I’ve been turning over in my mind ever since. “Whenever you feel like criticizing any one,' he told me, 'just remember that all the people in this world haven’t had the advantages that you’ve had.' (Gatsby, 1) Comment: This is a famous first line and my teacher says that we should analyze it carefully."`` - -- See the “Comment” at the end? That would do it. As a result, you have - title, note, citation-page (Gatsby, 1), and a comment (inside that - last quotation mark). All the elements of a traditional notecard are - there, just within the “note:” field. So let’s save that as a second - note. - -- Just click “File>Download>Plain Text (.txt) again. It will - automatically download (and get a new name with”(1)" added by Google - Docs) – so you don’t have to do anything to change the filename, etc. - Just click. - -- Cool. Two notes are now in your research “card stack” for processing. - If we did pull them into the system, they would be completely - searchable and usable. Again: you could just take notes with “notes:” - or “title:” and “note:” and that will do the job. - -- But, you can do a lot more if you want to. ZettelGeist allows you to - break up these elements of research notes into each of the - traditional elements listed on the “Note Format” page! - -So let’s go back to our GDocs page and adjust this note to make a third with a little more…zing! ------------------------------------------------------------------------------------------------- - -- Highlight “Comment: This is a famous first line and my teacher says - that we should analyze it carefully.” Then cut that (not delete). - -- Make a new line and paste it. Then make the capital “C” into a - lowercase “c” and put your comment in quotations, resulting in: - -``comment: This is a famous first line and my teacher says that we should analyze it carefully."`` - -- You just set up a new “comment:” field that can be searched - separately if you want. This is not necessary (as above) but it does - allow you to separate, let’s say, the quotes you take from the source - (in “note:”) and your ideas (in “comment:”). It’s up to you, but just - in case you like it, it’s that easy to add more fields (per the “Note - Format” page). - -- Now, let’s do something else that is key to research. Add “tags” to - the note. This is another traditional part of any notecard system. It - allows you to mark each note as being relevant to a theme or a - keyword or a part of your paper (Intro, Body 1, Body 2, Conclusion, - etc.). Adding tags is also really easy with the ZettelGeist method. - -- Continue with the existing GDoc. - - - (See? Making new “cards” just means editing and then re-saving - your existing card in .txt format with a new name – done - automatically in GDocs. But the process is essentially the same - for Word or whatever editor you are using – just give each new - “save as” a different number: Gatsby-Note-01.yaml, - Gatsby-Note-02.yaml, Gatsby-Note-03.yaml, etc. The existing - elements just get reused over and over as you save every new - version to your “stack.”) - -- To add tags, start a new line under the “comment:” line. - -- Type this: - -:: - - tags: - - My first tag - - Gatsby note - - First line of book - -- Could it be simpler? Ha! “tags:” is the new section, just as above. - But each tag is separate, so you just start the line for each tag - with a hyphen to indicate this is the case. That’s all!!! (BTW: This - is why we turned off “automatic lists,” because that feature would - make those hyphens into bullet points. We just want clean hyphens.) - -- Let’s save that fancier note, just as above: “File>Download>Plain - Text.” - -Your research stack is growing! Let’s do one more, adding one more feature. Again, it isn’t necessary, but “It’s there!” So what the heck? ------------------------------------------------------------------------------------------------------------------------------------------- - -- Edit the GDoc again. - -- Let’s find a new citation from the book and put it in the “note:” - section (between quotes) and write a new “comment:” Just zap the old - material and add the new, adjusting only what is necessary for the - new note, resulting in something like: - -:: - - title: Reading notes on The Great Gatsby - note: "Conduct may be founded on the hard rock or the wet marshes, but after a certain point I don’t care what it’s founded on. When I came back from the East last autumn I felt that I wanted the world to be in uniform and at a sort of moral attention forever; I wanted no more riotous excursions with privileged glimpses into the human heart." - comment: "In second paragraph, Fitzgerald begins to suggest Gatsby's cynicism and hints at fact that he was a veteran of the First World War" - tags: - - Gatsby note - - Cynicism - - Impact of WWI - -- You can also change the tags for this next note, as I did here. - -- Obviously, you could save this to the “stack,” go on to the next, and - be fine. - -- But notice that this time (for demonstration purposes) I didn’t add - an bibliographical indicator like “(Gatsby, 2)”. Most of us would - just put that MLA element in and be fine. In fact, for 99% of users, - that’s enough. Just keep track of which books you are using and add - the notes or footnotes when you pull things together later. No - problem. - -- But if you are into “bibtex” and plan to build your paper with zotero - and pandoc (for more advanced users) you could also use this system - to keep track of your bibliography. That just involves adding the - following at the bottom: - -:: - - cite: - bibkey: fitzgerald_gatsby_1925 - page: p. 2 - -- That’s all. If you don’t know what “bibkey” means right now, don’t - worry about it. (Just use MLA as above.) But if you do, you can add - it and link this to your .bib file and when you build with pandoc all - will be well. Just notice the spaces before bibkey: and page: Don’t - use tabs to indent – put in two spaces. - -- Now let’s save this new card, as above. - -- OK! Now we have a “Stack” of cards in our “Downloads” directory, each - named “Gatsby-Note….txt” You could write a million more. Just change - the elements that need to be changed and save the new version as a - new card: copy or type out new quotes from your book; add comments; - just write out notes; change tags; change page(s); change title if - you want, etc. - - - *Quick tip*: copying and pasting from electronic sources can be a - little tricky because you don’t know about the “fancy characters” - that will end up in your note. It’s best to just type out a quote - (and paraphrase more than quoting, as the masters say). But if you - do this, then *highlight* the whole note and click the “Clear - formatting” button to zap weird characters (as much as it will). - Also make sure you are pasting things are inside those quotation - marks). You might end up, after processing below, with some - strange charcters like in your notecards. - They can be deleted, but are a little bit of a pain (and why plain - text writing emphasizes plain text). - -Let’s process our notes. ------------------------- - -- Anyway, based on our start, let’s begin to process the notes we have - made. (Just think about how you would start shuffling or organizing a - stack of notecards you have written on paper.) - -- This is actually where the real power of this system starts. - - - Remember, the idea is to make a notecard for every idea for your - project, then be able to find them, select the ones you need, then - print them out for your paper or for each section of your paper, - according to themes or keywords or… - - - This is waaaaaaay different from having all of your notes in a - single document or having them on a few “Onenote” or “Evernote” - pages, but then having difficulty selecting the particular cards - or notes you need in particular. This is where the ZettelGeist - system becomes an electronic version of “moving the cards around” - when you start to outline or write the paper. - -- First, think about whether you want to keep working in the directory - where your browser saved the cards, or somewhere else. It’s probably - best to move them. - -- If you want to move them out of Downloads, make a new directory - called Gatsby-Paper and move the notes there. - -- Now, we just need to rename these “.txt” files so they are understood - as “.yaml” files by the system. That’s the “format” that the - ZettelGeist system needs to work with. - - - This can be done a number of ways. Since we only have a few cards - now, we can just do it with File Manager (or whatever) - individually. You can also do them in bulk with some File Managers - (on Mac) or with a command in the terminal. But for now, just - change them by hand. - - - So, in your new Gatsby-Paper directory, change the names of each - “.txt” file to “Gatsby-Note.yaml”. For GDocs users, you might also - adjust the numbers automatically added, removing the parentheses - but not the numbers. So, Gatsby-Note (1).txt becomes - Gatsby-Note-1.yaml. It’s just neater that way. - -- When this is done, you are ready to rock. Now you can do everything - that is demonstrated with the “test” materials on the “Getting - Started” page, but with your own research notes written in GDocs or - Word or… - -- Everything from this point on assumes you have installed ZettelGeist - and have your zenv environment working as explained on the - Installation page. - -- This can be done right in the same directory you are working in. - -- First create a database name. - -``zcreate --database gatsby.db`` - -- Then import all of the new yaml notecards (or zettels) into your - database. - -``zimport --database --dir $(pwd)`` - -- The output will show each of your notes being pulled into the - database. - -- Once that is done, you are ready to start searching and organizing - your notes. - -- Of course, with only a few it isn’t super exciting. But if you have - taken notes on every thought you had when reading The Great Gatsby, - the game would really be on!! - -- Let’s search for something in our stack. To do this, you use “zfind.” - To see all the elements of zfind, you could type “zfind –help”. But - we will keep things simple now. - -- Let’s search for the card that had to do with the First World War. - -- To do that, at the command line, type: - -``zfind --database Gatsby.db --query-string 'comment:"First World War"' --show-title --show-note --show-comment`` - -- When you enter this, the output will be the card that included the - “string” First World War in the “commment:” field. See? - -- There are a zillion things to be done now that you have this - searching ability. Again, it really comes into play when you have a - bunch of notes and want to search on them. But this is the start. - Let’s do one more. - -``zfind --database Gatsby.db --query-string 'tags:"First Line"' --show-title --show-note --show-comment`` - -- Take a look at what each of those commands is doing. ``zfind`` is - starting the search engine. It is looking in the - ``--database Gatsby.db``. It is searching for particular strings of - letters in particular fields - ``--query-string 'comment:"First World War"' and --query-string 'tags:"First line"'``. - Then, for each card that has those elements, it is showing the title, - showing the note, and showing the comment. That is what is showing up - on the output. - -- The real power of zfind (searching in ZettelGeist) comes from - combining these things (in as many ways as you want to use for your - purposes). Here is an example. Let’s search for *both* of these - elements in your cards: those with tags with First Line and those - with commments with First World War. To do that, you just use the - “or” command (the vertical bar created by [shift-backslash] in the - query string, as in: - -``zfind --database Gatsby.db --query-string 'tags:"First Line" | comment:"First World War"' --show-title --show-note --show-comment`` - -- Hit enter, and both of those cards will flash by (or the parts you - specified: title, note, and comment – though you could have asked for - tags and cite and… any elements you include). - -- You have just searched and found the two notes that met those - requirements. Not such a big deal out of 4 notes, but out of 100? - That’s cool. - -But, you want to use them for a portion of your paper on those themes, right? ------------------------------------------------------------------------------ - -- To do that, just add one more basic element into your search command: - “> search-results.txt” That’s all you need. The “>” sign (like an - arrow) means “send that output into a file” – as in, your results - file… Or your Gatsby-results.txt file… Or your - “Gatsby-Body-Part-1.txt” file, depending on how you want to arrange - your information. - -Let’s do the last one: - -``zfind --database Gatsby.db --query-string 'tags:"First Line" | comment:"First World War"' --show-title --show-note --show-comment > Gatsby-Body-Part-1.txt`` - -- Hit enter, and in an instant you will have a file with all the - searched data under that name. Open Gatsby-Body-Part-1.txt with your - editor. Or upload it to GDocs and open it there. It will have your - notes on those issues all in one place for you to put into your paper - document where you need it. - -- THAT’S how to use the *notecard* notetaking system to take notes, - mark them for particular content, find them, collect them, and then - pull them into your paper – all using the computer instead of paper - notecards (not that there is anything wrong with paper notecards, - they still rock, but we are digital writers now). - -- ZettelGeist has been made to make this great, traditional, powerful - way to do research (on anything) or just write or just make lists or… - as immediate as possible, but without trapping you in one word - processing system OR trapping your notes (etc.) in a onenote system - or an evernote system. (Nerd joke: EverNote keeps your notes, - forever: like a black hole, once the information goes in, it never - comes out.) ZettelGeist allows you to put your material in (according - to some classic rules) and then GET IT OUT in the bits and pieces - that you actually need. - -- The zfind feature can be modified in many ways to get more - “fine-tuned” material from your electronic card stack(s). Also, you - can break things up into the various fields we have discussed. BUT, - again, you could also just take notes as “note:” and be fine, - including whatever you need in that field alone (in quotations to be - sure there aren’t processing issues) and then search for strings in - all the “notes” sections. It can be that simple, or as complex or - professional as you want. It is completely up to you. - -- It is as flexible as paper notecards were, but as powerful as any - supercomputers are. That’s what we are talking about!!!! - -In conclusion, for GDocs users… -------------------------------- - -**Your notetaking system is still there, ready and waiting for you to -continue with your project! Just take a look back at the GDocs page you -were working on – the master “card” is ever-ready for you to edit and -save your next idea, and your next, and … (Fractals, baby!!)** diff --git a/sphinx-docs/source/tutorial-terminal.rst b/sphinx-docs/source/tutorial-terminal.rst deleted file mode 100644 index 8a5debc..0000000 --- a/sphinx-docs/source/tutorial-terminal.rst +++ /dev/null @@ -1,1302 +0,0 @@ -Terminal -=========== - -**This page is under construction. Pardon the sketchiness for now.** - -As made clear in Tutorial A, there is no wrong way to create notes (zettels) for use in a ZettelGeist database, as long as the basic protocols are maintained. --------------------------------------------------------------------------------------------------------------------------------------------------------------- - -But, some of you might be more comfortable – or interested in – doing all of your writing of notes or zettels at the command line itself (not using an outside editor at all – free or not). -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -There are some advantages to doing it in the most immediate, plain-text way: mainly because it avoids the issues of “fancy” characters and their problems. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -This Tutorial Level B will introduce you to the Command Line (terminal) methods to create notes, as well as some more things that can be done with zfind and other aspects of ZettelGeist. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Set up note with title, keywords, tags, citation/bibtex, page numbers, using ZettelGeist at the Command Line (terminal). ------------------------------------------------------------------------------------------------------------------------- - -- This is the starting point for doing the above: estabilishing a - “template” note that you can use to take a series of notes on a - particular source (book, article, etc.). The subsequent commands will - then lead you through various ways to create new ones, adjust tags, - then search, find, and manage information in a set of notes - (zettels). - -:: - - zettel --set-title "My Favorite Ada and Charles Book" --append-tags "Charles Babbage" "Ada Lovelace" Victorian Era" --set-cite Campbell_Kelly_2010 "pp. 1-2" --save campbell-kelly-template.yaml - -:: - - cat campbell-kelly-template.yaml [to see] - -- Create new zettel but change the page numbers - -:: - - zettel --file campbell-kelly-template.yaml --set-cite "" "pp. 2-4" - -- Create new zettel and prompt for a note: - -:: - - zettel --file campbell-kelly-template.yaml --set-cite "" "pp. 2-4" --prompt-note - -Save the new note with unique identifiter - -:: - - zettel --file campbell-kelly-template.yaml --set-cite "" "pp. 2-4" --prompt-note --id campbell-kelly --counter campbell-kelly next --name - -- This will save to a zettel with unique id plus suffix. - -:: - - cat new filename [to see] - -- Now, use that note but add a tag and change page numbers - -:: - - zettel --file last.filename.yaml --append-tags "Analytical Engine" --set-cite "" "pp. 4-5" --prompt-note --id campbell-kelly --counter campbell-kelly next --name - -- Making notes based on prompt sequences - -:: - - zettel --campbell-kelly-template.yaml --set-cite "" "p. 33" --prompt-note --prompt-tags --id campbell-kelly --counter campbell-kelly next --name - -- This will have you enter note and tags as you create on command line. - -- **Avoid trailing space at the end of lines, when possible. It will - work but result in :raw-latex:`\n `between lines.** - - - BTW, –prompt-cite will ask for both bibkey and pages, so you would - need to keep entering bibkey. - - - But using –set-cite "" “pp. 56-60” for former lets you just change - the page in the command itself before you ask for prompts. - -- To eliminate previous tags on a template - -:: - - zettel --campbell-kelly-template.yaml --set-cite "" "p. 33" --reset-tags --prompt-note --prompt-tags --id campbell-kelly --counter campbell-kelly next --name - - -- ``--reset-tags`` deletes old ones and –prompt-tags means adding all - new, not just appending. - -- If you use special characters in notes, it will go to “safe” format - and add backslashes  . It will look ugly, but still work. - -- you can arrow back or ctrl-p to go to previous command and just edit - it for the next note. [Or open it up in Vim or use Vim-mode in zsh. - see below.] - -- George uses prompt mainly for note: For the rest, he uses set. - -:: - - zettel --campbell-kelly-template.yaml --set-cite "" "p. 48" --prompt-note --append-tags "new tags" --id campbell-kelly --counter campbell-kelly next --name - - -Do search with more results. ----------------------------- - -:: - - zfind --database index.db --find-tags "babbage" --count --show-filename --showtitle --show-note --show-tags - -Results have dashed lines between each - --------------- - -[TODO: This line could be a configurable option… Make this -configurable?] - -To put these results into a new file… -------------------------------------- - -[TODO: next tool is a report, with a way to style what you see. Make -each field name a markdown heading.] - -Linux way is to redirect - -:: - - add "> results.txt" to command to make the result.txt file with eveything in it. - -[TODO: add zFind command option to make headings into markdown. Put -everything into a nice markdown format.] - -To have *just* the basic stuff to pull into a document, just include --------------------------------------------------------------------- - -- notes and citations are really all you need if you search on good - tags that you have created. - -:: - - zfind --database index.db --find-tags "babbage" --show-note --show-cite - -- Then you would just get the notes (maybe commments and summary too, - and citation for the material tagged as “babbage.” This could be - copied or read right into a file or section of an outline. Clean, - with just the material so tagged. - -- THIS IS the way to get things out of the system!!!! - -[TODO: reporting… and turning citations into proper citations. Turn it -into something pandoc friendly and pandoc plus cite.] - -[TODO: future lecture process for teaching – do zfind on everything on a -topic. then just go through the results. This is the memory extender -that lets you pull up information through a retrieval system. The -retrieval system is what is the new and the best of the system. This is -what Onenote is lacking. ] - -Any editor can be used: command line, sublime text, vim…. Just follow conventions and save as .yaml ---------------------------------------------------------------------------------------------------- - -Some recipes for using VIM to make Zettel commands and work with PDFS. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Use VIM to edit command -~~~~~~~~~~~~~~~~~~~~~~~ - -In Oh-My-Zsh: add “vi-mode” to plugins in .zshrc [plugins=(git vi-mode)] - -Set up first command [save for future use] - -:: - - zettel --set-title "Notes on Tedre" --set-cite tedre_science-2014 "0" --set-note "First note on Tedre" --set-comment "First note" --append-tags "Tedre" "General computer history" --now --now-id tedre-science - -Repeat [up arrow] Hit [esc-v] to edit in VIM [move quickly to delete all -between quotation marks, etc. Replace tags, comments, page number, note, -etc.] - -ci" will replace everything within quotation marks. [Do this between -note: and page: and tags:] - -:: - - :wq - [enter] - -Arrow up, REPEAT endlessly - -Alias to zcreate database [alias “zcreatetoday”] ------------------------------------------------- - -:: - - zcreate --database Zettels-Today.db" - -zcreate –database Zettels-Today.db" ## Alias to zimport into new -database - -:: - - alias zimporttoday="zimport --database Zettels-Today.db --zettel-dir ~/zettels/hocz/dbdz" - -From Video Session 2017-12-20 13.47.55 ZG INSTRUCTIONS-ZFind-filter[?]-Demo -=========================================================================== - -Starting --------- - -:: - - zcreate --database index.db - -:: - - zimport --database index.db --dir $(pwd) - -- $(pwd) means current directory and everything beneath it. - -- also puts entire path to file into the index. - -zettel ------- - -zettel is making and replacing command itself–and many other functions -(append tags, reset tags, etc., etc.) The “Swiss Army Knife” for -notetaking - -zFind ------ - -Most of above applies to zFind - -[TODO: make sure the rest of this is actually about zfilter, after name -change.] - -zFilter -------- - -- Create query file “zql” - -:: - - title:Campbell & ( note:"Charles Babbage" | note:"Ada Lovelace") - -save as charles-and-ada.zql - -- zql = Zettel Query Language - -:: - - zfilter --database index.db --query docs/zquery-examples/charles-and-ada.zql --count - -[TODO: –count doesn’t really do much for a zfilter command… still -produces all the yaml.in cards. Better to zfind to count, then zfilter?] - -[TODO: results on yaml.in still read as “zfind” results, rather than -“zfilter” results… Minor detail to fix ] - -[TODO: default name suffix for a zfilter folder is “-zfind”. This should -be changed to “-zfilter”] - -[TODO: Can URL go into cite? Or should we make bibcard with bibkey for -all videos and add url there?] - -- Add, for instance… - -:: - - --show-filename - -:: - - --show-note - -:: - - --show-note | less - -/ada to search less to see just Ada, etc. - -/Babbage to search less to see just Babbage… - -Adjust query ------------- - -- edit charles-and-ada.zql to - -:: - - title:Campbell & ( note:"Charles Babbage" | note:"Ada Lovelace") & note:"programming language" - -- save as new query - -:: - - charles-and-ada+programming.zql - -- Do same zFilter as above… fewer results, etc. - -Use Zettel command for “replace” --------------------------------- - -- Copy filepath/filename from the results of the search - -- pass that into - -:: - - zettel --file [filepath/filename.yaml] - -:: - - --append tags "programming language" - -- That adds the new tag to the end of that yaml. - -- Save as a new zettel by adding - -:: - - --now -now-id ada-programming - -- This creates new zettel with new tag at the end. - -Adding tags to multiple Zettels -------------------------------- - -- To get list of filenames from a set of query results, use grep - -:: - - zfilter --database index.db --query docs/zquery-examples/charles-and-ada.zql --count --show-filename | grap filename: - -- This gives list of all the files that were found. - -:: - - zfilter --database index.db --query docs/zquery-examples/charles-and-ada.zql --count --show-filename | grap filename: | cut -f2 -d" " - -- This cuts off the “filename:” part to give list of files - -- This could all be in a for loop: - -:: - - for filename in $(zfilter --database index.db --query docs/zquery-examples/charles-and-ada.zql --count --show-filename | grap filename: | cut -f2 -d" "); do - zettel --file $filename --now --now-id "new id" --append-tags "programmming languages "demo for Dave" - done - -- This will create new zettels with the new tags added to all of the - zettels found with the original query. - -[Taking the results of the command, just filenames, to create new “pile” -of zettels with the new tags.] - -- Zettel command a way to edit any zettel. Supports adding a tag, not - deleting a tag. Removing may came later. - -- Use it to pipe through results from zFilter, or zFind. - -[TODO: Now that zFilter creates note.txt, title.txt, … and yaml.in, how -would you make a “for loop” to create zettels with new tags for all of -the results? [Which is what you were doing at this stage?]] - -How to create zql files with prompt ------------------------------------ - -:: - - zfilter [or zfind?] --database index.db --prompt --save-query quantum-computing.zql - -- This will prompt for the search you want to do, for instance: - -:: - - zquery> note:"quantum computing" & note:"Seth Lloyd" - -- That will create a valid zql file. - -[TODO: Does this still work with zfilter? It seems to create a yaml.in -directory file in addition to a zql file.] - -Now do search: - -:: - - zfind [or zfilter?] --database index.db --query quantum-computing.zql --count --show-filename --show-title --show-note - -To put into text file ---------------------- - -add > new-filename.md - -:: - - zfind [or zfilter?] --database index.db --query quantum-computing.zql --count --show-filename --show-title --show-note > quantum-computing-textfile.md - -For Loop --------- - -As we do a search we want to add tag to all the zettels. Then we don’t -have to worry about the query again… - -Add bibtex ----------- - -:: - - --show-bibtex - -:: - - --show-cite - -2017-12-29 12.25.52 ZG INSTRUCTIONS -=================================== - -:: - - zfind --database index.db --query docs/zquery-examples/charles-and-ada.zql --count --show-note --show-summary --show-bibtex --use-index --output charles-and-ada [folder name] - -- Inside the results… create new zettels with new title and new tags… - -:: - - for filename in *.yaml - do - zettel --file $filename --now --now-id charles+ada --append-tags "Charles Babbage" "Ada Lovelace" --set-title "Thoughts for Chapter 1" - done - -- This will let us do anything with the Zettels - add tags, - (delete/replace?], etc. - -[TODO: now that zfilter creates note.txt and yaml.in files, this doesn’t -work… How would one just make yamls out of “hits” from zfilter or zfind? -I assume it would mean writing loop that passes both yaml.in and -note.txt somehow–as below.] - -See everything in a folder --------------------------- - -:: - - less | *.yaml - cat folder/*.yaml |less - -.. _zg-instructions-1: - -2018-01-03 11.04.04 ZG INSTRUCTIONS ------------------------------------ - -:: - - zimport --database index.db $(pwd)/docs - -- That would only do docs folder…. - -:: - - zfilter --database index.db --query docs/zquery-examples/kurzweil2.zql --count --show-title --show-summary --show-cite --output kurzweil-singularity - -- Go into folder - -filename.Note.txt files for results in notes field title.txt for results -in title summary.txt for results in summary, etc. yaml.in files for the -yaml associated with each - -yaml.in shows what the query was - -filename says where to see the actual snippets includes cite: if in -original… - -note.txt file has “snippets” and the filename and the field name they -came from. - -- Make a zettel out of it. - -:: - - zettel --file name.yaml.in --load-note name.note.txt - -- Result is zettel which joins the yaml.in with the note.txt that has - only the snippets with the selections from the book! - -[Putting it into a text file makes it easier than moving from yaml to -yaml…] - -- Something for amusement purposes - -:: - - for filename in *.yaml.in - do - rootname=$(basename $filename .yaml.in) - zettel --now --now-id new-zettel --append-tags "searched notes" --load-note $rootname-note.txt - done - -- This would create yamls from all the fragments from the search - results… And it will add a new name indicating this and a new tag. - Haha. - -- Then you would have yamls of each snippet set with the correct cite, - etc. - -- To just do “human” in the title. - -- Change zql file - -:: - - title:Human & note:Kurzweil & note:singularity - -- Run search again - -- then you will have - -note.txt title.txt yaml.in - -To create zettel from *each* or just one of the found snippet sets at a time. ------------------------------------------------------------------------------ - -- for each set - -:: - - zettel --file filename.yaml.in --load-note filename.note.txt --load-title filename.title.txt - --same thing with real content - -:: - - zettel --file 20180205130743-09.yaml.in --load-note 20180205130743-09-note.txt --now --now-id new-note-from-snippets-in-09.txt - -- same thing, and add tag indicating content of that snippet set - -:: - - zettel --file 20180205130743-09.yaml.in --load-note 20180205130743-09-note.txt --now --now-id new-note-from-snippets-in-09.txt --append-tags "new zettel from a single set of snippets" - -- that would create zettel with all of the found material from note and - other zettel info… - -- The note is where the details are. But you may want to see summary - too, etc. Could add –load-title –load-summary –load-comment –load - tags, etc. Can see snippets whereever, but main target is note or - comments. - -Create zettel from just an interesting part of a snippet --------------------------------------------------------- - -- Read note.txt on console using cat - -- copy what you want - -:: - - zettel --file filename.yaml.in --prompt-note --prompt-summary --now - -- follow prompt to write summary and past in the note that you copied. - -[no editor] - -Limited indexing ----------------- - -:: - - zcreate --database new-research.db - zimport --database new-research.db --dir $(pwd)/foldername - -- this would just do the folder indicated after $(pwd) - -Filing things in right places ------------------------------ - -- copy new yamls from studying zfilter results into another directory - -- delete notes.txt delete yaml.in [They won’t be indexed anyway, but - they can be deleted after you are done studying them and creating - yamls, in various ways.] - -- Actually create the zettels in second session in preferred hocz - directory… - -- Specify location of zettel creation - -:: - - zettel --save /temp/blank.yaml - -- Just can’t do that AND –now - -(That could be a feature added later) - -[TODO: Make it possible to do a cite without a page number…] - -Creating Queries: ------------------ - -& and \| or ! not - -Whole section on creating bibcards… ------------------------------------ - -But we ran into some problems…. - -.. _zg-instructions-2: - -2018-01-12 11.11.15 ZG INSTRUCTIONS -=================================== - -Dave demonstrating Voom to George… - -SOME OTHER Examples of using Zfilter -==================================== - -First create database and index it ----------------------------------- - -:: - - zcreate --database index.db - zimport --database index.db --dir $(pwd) - -Example 0 ---------- - -- show note for filtered results, but limit to 1000 character context - -:: - - zfilter --database index.db --query iPhone4.zql --count --show-title --show-note --snip-size 1000 --output iPhone4-search - -Example 1 ---------- - -- do basic zfilter search, put all results into a .txt file to - -:: - - zfilter --database index.db --query ~/Work/zettels/zfiltering/zql-files/kurzweil2.zql --count --show-title --show-note --show-summary --show-cite --show-url --output kurzweil-singularity - -- Move into created directory - -:: - - cd 20180105135229-kurzweil-singularity - -- to look at all the results in same file - -:: - - more *.txt > results.txt - -- open results.txt to copy the parts you like [if you are using VIM, - the command is "+y to copy into shared register so you can paste into - the prompt] then create zettel and paste selection into “note” prompt - -:: - - zettel --file 20180105135229-01.yaml.in --prompt-note --prompt-comment --prompt-tags --now --now-id Testing-new-zFilter - -- take note of the correct note.txt file that you are working with and - adjusting the yaml.in filename accordingly - -Example 2 ---------- - -- make sure you include –show-cite to get full bibkey and page - -- include –show-url to get url of videos referenced - -- pick preferred snip size - -:: - - zfilter --database ~/Work/zettels/index.db --query ~/Work/zettels/zfiltering/zql-files/Apollo-Guidance-Computer.zql --count --show-title --show-note --show-summary --show-cite --show-url --snip-size 3000 --output Apollo-Guidance-Computer - -- Inside the directory created, - /20180131113830-Apollo-Guidance-Computer, open the “note.txt” files - with VIM to study and select. - -- [if you are using VIM, the command is "+y to copy into shared - register so you can paste into the prompt] - -- Open another terminal session and go into the directory where you - want to create zettels. [hocz/dbdz or gktz] Then you can create - zettels there, referring back to this zfiltering directory. - -- To do this, make sure you use full file location for the yaml - information. [readlink -f filename will give it to you]. - -:: - - zettel --file ~/Work/zettels/zfiltering/20180131113830-Apollo-Guidance-Computer/20180131113830-58.yaml.in --prompt-note --prompt-comment --prompt-tags --now --now-id Testing-new-zFilter - -- Again, as you look at different note.txt files for results, change - the *number* of the yaml.in file accordingly… Just the last digits. - -- Then you can just go through and create notes based on the filtered - results. - -Example 3 ---------- - -- Do a zfilter. Select a portion of one [inside vim or from cat], and - create a new card that will include the zettel information from the - original, but prompt for you to paste in the portion you want, and - comment about it. - -:: - - zfilter --database ~/Work/zettels/index.db --query ~/Work/zettels/zfiltering/zql-files/Apollo-Guidance-Computer.zql --count --show-title --show-note --show-summary --show-cite --show-url --snip-size 3000 --output Apollo-Guidance-Computer - ls - cd 20180109115129-Apollo-Guidance-Computer - ls - vim 20180109115129-58-note.txt - zettel --file ~/Work/zettels/zfiltering/20180109115129-Apollo-Guidance-Computer/20180109115129-58.yaml.in --prompt-note --prompt-comment --prompt-tags --now --now-id Testing-new-zFilter - -Example 4 ---------- - -- Tried some zfinds just to see basic results – how many zettels have - some information…. - -:: - - zfind --database index.db --find-note "Second World War Zuse Computer Nazi Hitler Rocket" --count --show-title --show-filename --show-cite - -- went to Work/zettels/zfiltering/zql-files - -- opened VIM and added - -note:“Second World War” & note:Zuse & note:Computer & note:Nazi & -note:Hitler & note:rocket - -- saved as Second-World-War-Zuse-Computer-Nazi-Hitler-Rocket.zql - -- did zfilter [Reduced snip size for this one…] - -:: - - zfilter --database ~/Work/zettels/index.db --query ~/Work/zettels/zfiltering/zql-files/Second-World-War-Zuse-Computer-Nazi-Hitler-Rocket.zql --count --show-title --show-note --show-summary --show-cite --show-url --snip-size 300 --output Second-World-War-Zuse-test - -.. _example-4-1: - -Example 4 ---------- - -- Taking the next step to use zFind to find some material. - -:: - - zfind --database index.db --find-note "saved the Apollo team from prematurely aborting the mission" --show-filename --show-note | less - -- searched for passage using /saved - -- highlighted and copied passage - -- created zettel - -:: - - zettel --prompt-note --prompt-comment --prompt-tags --now --now-id Saving-Apollo - Zettel saved to 20180131133145-Saving-Apollo.yaml - Enter text for comment. ctrl-d to end. - comment> This is a note I am creating to test process. - comment> - Enter text for note. ctrl-d to end. - note> Their solution was to just ignore the errors since the AGC would free up memory on it's own by terminating non-critical programs through a reboot. Garman and Bale's quick-thinking saved the Apollo team from prematurely aborting the mission. While we may look at those errors as glitches in the AGC, but in reality the computer was behaving exactly as it was designed to. The near disaster the Apollo team encountered is a testament to the ingenuity of the AGC engineering team and training of the mission crew. - note> - Enter text for tags. ctrl-d to end. - tags> Test - tags> Apollo - tags> - -- create Markdown from that zettel - -:: - - zettel --save Saving-Apollo.md --file 20180131133145-Saving-Apollo.yaml - Zettel being saved to Saving-Apollo.md (mode = .md) - -- import into a .md file using VIM and VOoM. - -:: - - VIM - :r - tab to filename - enter - -- File entered into Vim with .md - -:: - - comment - ======= - - This is a note I am creating to test process. - - - note - ==== - - Their solution was to just ignore the errors since the AGC would free up memory on it's own by terminating non-critical programs through a reboot. Garman and Bale's quick-thinking saved the Apollo team from prematurely aborting the mission. While we may look at those errors as glitches in the AGC, but in reality the computer was behaving exactly as it was designed to. The near disaster the Apollo team encountered is a testament to the ingenuity of the AGC engineering team and training of the mission crew. - - - tags - ==== - - - Test - - Apollo - -Example 6 ---------- - -- zfind some notes, and automatically put them into a new zettel…[used - semi-colon to combine] - -:: - - zfind --database ~/Work/zettels/index.db --find-note "saved the Apollo team from prematurely aborting the mission" --show-filename --show-cite > test.md; zettel --load-note test.md --prompt-title --prompt-comment --now --now-id test-piping - -Example 7 ---------- - -- OR, use zfind to get notes, then use zettel to create a markdown file - out of them. [Used semi-colon to combine.] Pass zfind results to - Markdown using Zettel!! Write to a temp file, then load that and save - with zettel. Use semi-colon to combine . - -:: - - zfind --database ~/Work/zettels/index.db --find-note "saved the Apollo team from prematurely aborting the mission" --show-filename --show-cite > test.md; zettel --load-note test.md --prompt-title --prompt-comment --save piping-test-save.md - - Zettel being saved to piping-test-save.md (mode = .md) - Enter text for title. ctrl-d to end. - title> a title - title> - Enter text for comment. ctrl-d to end. - comment> a comment - comment> - -Commands from Zoom Demonstration Video 20180206 Updated zettel zfind zfilter recipes -==================================================================================== - -Getting started ---------------- - -:: - - zcreate --database mlb.db - zimport --database mlb.db --dir $(pwd) - ls - -Zfind basics ------------- - -:: - - zfind --database mlb.db --find-note "World Series" --count - zfind --database mlb.db --find-note "World Series" --show-summary --count - zfind --database mlb.db --find-note "World Series" --show-summary --show-note --count - zfind --database mlb.db --find-note "World Series" --show-summary --show-note --show-cite --count - -:: - - ls - ls baseball - ls bibs - more bibs/chicago-cubs.yaml - zfind --database mlb.db --find-bibkey chicago --show-bibkey - -.. _section-1: - -:: - - zettel --set-title "George's scholarly notes about the Chicago Cubs" --prompt-summary --prompt-cite - cat > chicago-cubs-gkt-notes.yaml - ls - mkdir gkt-musings - mv chicago-cubs-gkt-notes.yaml gkt-musings - ls - -.. _section-2: - -:: - - rm mlb.db - zcreate --database mlb.db - zimport --database mlb.db --dir $(pwd) - zfind --database mlb.db --find-summary "lovable losers" --show-summary - zfind --database mlb.db --find-summary "Cubs" --show-summary - zfind --database mlb.db --find-note "Cubs" --show-note - zfind --database mlb.db --find-note "Cubs" --show-note --show-title - zfind --help - zfind --database mlb.db --find-note "Cubs" --show-note --show-title - zfind --database mlb.db --find-note "Cubs" --show-note --show-title > the-cubs-report.md - vim the-cubs-report.md - zfind --database mlb.db --find-summary "Cubs" --show-summary --show-note > the-cubs-report.md - vim the-cubs-report.md - pandoc the-cubs-report.md -o the-cubs-report.html - open the-cubs-report.html - vim the-cubs-report.md - pandoc the-cubs-report.md -o the-cubs-report.html - open the-cubs-report. - open the-cubs-report.html - -.. _section-3: - -:: - - pwd - cd examples - ls - cd .. - ls - cd baseball - ls - cat chicago-cubs.yaml - zettel --file chicago-cubs.yaml - zettel --file chicago-cubs.yaml --append-tags "World Champions 2016" - zettel --file chicago-cubs.yaml --append-tags "World Champions 2016" --now - diff chicago-cubs.yaml 20180206135815.yaml - mv 20180206135815.yaml chicago-cubs.yaml - git diff - zfind --database mlb.db --find-note "World Series" --show-summary --show-note --show-cite - pwd - cd ../.. - ls - cd - - ls - pwd - mv mlb.db .. - cd . - cd .. - ls - -.. _section-4: - -:: - - rm mlb.db - zcreate --database mlb.db; zimport --database mlb.db --dir $(pwd) - zfind --database mlb.db --find-note "World Series" --show-summary --show-note --show-cite - zfind --database mlb.db --find-note "World Series" --show-summary --show-note --show-cite > gkt-musings/world-series-ch1.yaml - vim gkt-musings/world-series-ch1.yaml - ls - zettel --file gkt-musings/world-series-ch1.yaml - zcreate --database mlb.db; zimport --database mlb.db --dir $(pwd) - vim gkt-musings/world-series-ch1.yaml - zettel --file gkt-musings/world-series-ch1.yaml - -.. _section-5: - -:: - - zcreate --database mlb.db; zimport --database mlb.db --dir $(pwd) - zfind --find-tags "Chapter 10" --show-note - zfind --database mlb.db --find-tags "Chapter 10" --show-note - zfind --database mlb.db --find-tags "Chapter 10" --show-note --show-tags - zfind --database mlb.db --find-tags "Chapter 10" --show-note --show-tags > temp.yaml; zettel --file temp.yaml - ls - cd baseball - ls - more arizona-diamondbacks.yaml - ls - for team in *.yaml\ndo\n team_name=$(basename $team .yaml)\n echo $team_name\ndone - for team in *.yaml\ndo\n team_name=$(basename $team .yaml)\n zettel --file $team --append-tags "Baseball History" --save $team.yaml.new\ndone - ls - rm *yaml.yaml* - for team in *.yaml\ndo\n team_name=$(basename $team .yaml)\n zettel --file $team --append-tags "Baseball History" --save $team_name.new.yaml\ndone - diff chicago-cubs.yaml chicago-cubs.new.yaml - for team in *.new.yaml\ndo\n team_name=$(basename $team .new.yaml)\n mv $team $team_name.yaml\ndone - ls - more chicago-cubs.yaml - ls - git diff - -Find out which tags you have used. [TODO: this did not work on NUC. Which zettelgeist directory should one use? ] ------------------------------------------------------------------------------------------------------------------ - -:: - - ls - cd - cd Work/zettelgeist - ls - cat zdb_funcs.sh - source zdb_funcs.sh - zdb_tags - zdb_tags blah - cd .. - ls - cd zg-tutorial - ls - cd zettels - zdb_tags mlb.db - -.. _section-6: - -:: - - ls - pwd - ls ~/Work/zettelgeist/ - ls ~/Work/zettels/docs/zquery-examples/charles-and-ada.zql - cat ~/Work/zettels/docs/zquery-examples/charles-and-ada.zql - ls - pw - pwd - cd .. - ls - mkdir queries - vim queries/chicago-world-series.zql - ls - rm zettels/mlb.db - zcreate --database mlb.db; zimport --database mlb.db --dir $(pwd) - ls - cat queries/chicago-world-series.zql - zfilter --help - zfilter --query queries/chicago-world-series.zql --database mlb.db --show-summary --show-note --show-cite - ls - cd 20180206142546-zfind - ls - more 20180206142546-0.yaml.in - ls - more 20180206142546-0.yaml.in - ls - more 20180206142546-0-summary.txt - ls - zettel --file 20180206142546-0.yaml.in --load-summary 20180206142546-0-summary.txt --load-note 20180206142546-0-note.txt - zettel --file 20180206142546-0.yaml.in --load-summary 20180206142546-0-summary.txt --load-note 20180206142546-0-note.txt --save chicago-cubs-zfilter.yaml - subl chicago-cubs-zfilter.yaml - zettel --file chicago-cubs-zfilter.yaml - ls - zettel --file 20180206142546-1.yaml.in --load-summary 20180206142546-1-summary.txt --load-note 20180206142546-1-note.txt --save chicago-white-sox-zfilter.yaml - ls - vim chicago-cubs-zfilter.yaml - vim chicago-white-sox-zfilter.yaml - ls - zettel --file 20180206142546-1.yaml.in --load-summary 20180206142546-1-summary.txt --load-note 20180206142546-1-note.txt --save chicago-white-sox-zfilter.md - vim chicago-white-sox-zfilter. - vim chicago-white-sox-zfilter.md - pandoc chicago-white-sox-zfilter.md chicago-white-sox-zfilter.html - pandoc chicago-white-sox-zfilter.md -o chicago-white-sox-zfilter.html - open chicago-white-sox-zfilter. - open chicago-white-sox-zfilter.html - -.. _section-7: - -:: - - . ~/zenv/bin/activate - ls - cd Work/zg-tutorial - ls - cd 20180206142546-zfind - ls - for file in *.yaml.in\ndo\n name=$(basename $file .yaml.in)\n zettel --file $file --load-summary ${name}-summary.txt --load-note ${name}-note.txt \ndone - for file in *.yaml.in\ndo\n name=$(basename $file .yaml.in)\n zettel --file $file --load-summary ${name}-summary.txt --load-note ${name}-note.txt --save ${file}.md\ndone - for file in *.yaml.in\ndo\n name=$(basename $file .yaml.in)\n zettel --file $file --load-summary ${name}-summary.txt --load-note ${name}-note.txt --save ${name}.md\ndone - -Some more recipes by Dave -========================= - -Study results of a zfilter in a single file, using Vim. -------------------------------------------------------- - -:: - - zfilter --database ~/Work/zettels/index.db --query ~/Work/zettels/zfiltering/zql-files/Renaissance+Medici.zql --show-title --show-note --show-cite --snip-size 500 - -:: - - cat *note.txt > results-Renaissance-Medici.md - -:: - - vim results-Renaissance-Medici.md - -Inside vim - -:: - - :set hlsearch "set highlight searches - :set ignorcase "will ignore case for searches - -:: - - /Renaissance\|Medici "search Renaissance OR Medici in document with vim.... Then see what you want and build zettels using above techniques with copied material... - -Find something and make a zettel from it. ------------------------------------------ - -- Go through results.md file in vim as above - -- Find something to make a real zettel out of… - -- notice which filename it came from. - -- open another session in zfilter results directory - -- determine which yaml.in file is associated with that filename - -:: - - grep "keyword from that filename title" *.yaml.in - -- note results - -- create zettel command passing that yaml.in in as file, and then - prompting for note [–prompt-note] - -:: - - zettel --file 20180207121633-1.yaml.in --prompt-note --now --now-id Renaissance+Medici - -- in Vim, select (and justify, if you wish) the section you want to - make a note with - -VjJ - -- yank it to the common register - -"+y - -- go back to zettel command and copy into note prompt - -:: - - zettel --file 20180207121633-1.yaml.in --prompt-note --now --now-id Renaissance+Medici - Zettel saved to 20180207122548-Renaissance+Medici.yaml - Enter text for note. ctrl-d to end. - note> the press in terms relatively familiar to them. At the heart of printing, as they saw it, was a practical activity--a craft. It was a fast-growing and in some ways extraordinary one, to be sure, but it was still a craft nonetheless. And that suggested how it could be accommodated. Early modern people knew how crafts should be organized, conducted, and regulated so as to take their place in an orderly commonwealth. The practitioners of the press, therefore--ranging from the great scholar-printers of Renaissance Italy to the first denizens of Grub Street-- organized themselves into communities large and small, along lines familiar from existing crafts. They established "chapels" of journeymen in their houses, and formed guilds or companies to handle the aOairs of the book trades as a whole in particular cities. At the same time, ecclesiastical, academic, and royal authorities devised their own systems to render these 8 - note> - -- Zettel now created. It will include all the original title and cite - information because you pulled that from the yaml.in file - -:: - - title: Adrian-Johns-Piracy-The-Intellectual-Property-W-BookFi.pdf - note: the press in terms relatively familiar to them. At the heart of printing, as - they saw it, was a practical activity--a craft. It was a fast-growing and in some - ways extraordinary one, to be sure, but it was still a craft nonetheless. And that - suggested how it could be accommodated. Early modern people knew how crafts should - be organized, conducted, and regulated so as to take their place in an orderly commonwealth. - The practitioners of the press, therefore--ranging from the great scholar-printers - of Renaissance Italy to the first denizens of Grub Street-- organized themselves - into communities large and small, along lines familiar from existing crafts. They - established "chapels" of journeymen in their houses, and formed guilds or companies - to handle the aOairs of the book trades as a whole in particular cities. At the - same time, ecclesiastical, academic, and royal authorities devised their own systems - to render these 8 - cite: - bibkey: Johns_Piracyintellectualproperty_2011 - -- Move to your Zettel collection directory. [OR, create it in that - directory using full filenames. OR, make all notes in this directory, - then do - -:: - - mv *.yaml ~/Work/zettels/hocz/dbdz/ - -- This will move all the proper zettels you have created to your data - directory. Then you can delete all the zfilter results. - -To find the yaml.in for the precise quotation you want to use… --------------------------------------------------------------- - -- Select the quotation, then grep the whole thing or just a unique - phrase in it. - -:: - - grep -i "The clerks and scribes of the Middle Ages" *note.txt - -This will give you the name of the note.txt it is in, and then you can -build the zettel with the corresponding yaml.in, as above. ## To easily -make zql queries - -:: - - cat > zql-files/name-of-new-query.zql - note:SearchTerm & note:"Second Search Term" etc. - ctrl-d - -- now just pass that query name into last iteration of zfilter. - -:: - - zfilter --database ~/Work/zettels/index.db --query ~/Work/zettels/zfiltering/zql-files/Ancient-Egypt.zql --show-title --show-note --show-cite --snip-size 500 --output Ancient-Egypt - -Create and zimport database that ONLY includes hocz material…. --------------------------------------------------------------- - -:: - - zcreate --database index.db - zimport --database index.db --dir $(pwd)/hocz/ - -create the results.md files for the zfilter results and save them in hocz/dbdz, etc. ------------------------------------------------------------------------------------- - -- THEN GO BACK AND STUDY THEM, using the above recipes to create new - zettels. - -- You can REDO the zfilter searches using the ZQLs to get the new set - of note.txt and yaml.in, and then just grep for right number based on - selected string to make zettels later. [As above.] - -Sample command flows creating these results.md files ----------------------------------------------------- - -:: - - cat > zql-files/Mesopotamia.zql - zfilter --database ~/Work/zettels/index.db --query ~/Work/zettels/zfiltering/zql-files/Mesopotamia.zql --show-title --show-not - e --show-cite --snip-size 500 --output Mesopotamia - ls - cd 20180207132331-Mesopotamia - ls - cat *note.txt > results-Mesopotamia.md - vim results-Mesopotamia.md - mv results* ~/Work/zettels/hocz/dbdz/ - cd .. - ls - rm -r 20180207132331-Mesopotamia - ls - cat > zql-files/Ancient-Greece.zql - zfilter --database ~/Work/zettels/index.db --query ~/Work/zettels/zfiltering/zql-files/Ancient-Greece.zql --show-title --show- - note --show-cite --snip-size 1000 --output Ancient-Greece - ls - cd 20180207133450-Ancient-Greece - ls - cat *note.txt > results-Ancient-Greece.md - ls - vim results-Ancient-Greece.md - mv results* ~/Work/zettels/hocz/dbdz/ - -Sample with creation of a Zettel --------------------------------- - -vim results-Medieval+Middle-Ages+Gothic.md grep -i “The clerks and -scribes of the Middle Ages” \*note.txt zettel –file -20180207135333-010.yaml.in –prompt-note –now –now-id Medieval-Gothic - -[TODO: searching in zql does not allow use of hyphens, even in quotation marks: “seventeenth-century” doesn’t work. -------------------------------------------------------------------------------------------------------------------- - -In order to remove duplicate lines from the results.md file ------------------------------------------------------------ - -:: - - awk '/^#/ || !seen[$0]++' results.md > results-without-duplicates.md - -This will retain all the lines that start with #, so all the filename -and field, etc., will remain in place. So this will zap the duplicate -lines, AND leave the data indicating the sources… Which lets you then -put the quote together with the proper yaml.in file. - -Here is a single command to create duplicate-free results files from all -the note.txt files from a zfilter. - -:: - - cat *note.txt > temp.md; awk '/^#/ || !a[$0]++' temp.md > results.md; rm temp.md - -TO remove duplicate lines from files IN zfind directory (retaining each) ------------------------------------------------------------------------- - -for file in \*note.txt do awk ‘/^#/ \|\| !a[$0]++’ -“:math:`file" > "`\ file.nodups.txt” done - -Then, in vim, do - -``args: *nodups.txt`` ``:n`` moves to next ``ctrl-g`` tells you which -nodups.txt you are in so you can associate with correct yaml.in file - -This lets you study each zfilter file individually, using vim search, -etc., and then more easily create new zettels with associated yaml.in -files. And, you can move around in all of them, while seeing where you -are to make zettels in separate session. - -If you do that combined with - -``:set hlsearch`` [highlight search] - -and ``:set ignorecase`` - -you can really look around at the results and make zettels. - -Using args in VIM you can do a lot of moving around. But this alone lets -you go through each and see what’s there. diff --git a/sphinx-docs/source/tutorial-world.rst b/sphinx-docs/source/tutorial-world.rst deleted file mode 100644 index 0761916..0000000 --- a/sphinx-docs/source/tutorial-world.rst +++ /dev/null @@ -1,525 +0,0 @@ -World -======== - - -**This page is under construction. Pardon the sketchiness for now.** - -What do you want to do? ------------------------ - -- Take research notes for a paper in order to be able to search them - for … anything. - -- Follow the traditional (and ever-valid) methods of writing a note - with a title, some keywords (tags), a note (with comment or summary - if desired), and some bibliographical information (book or article - title and page number[s]). - -- Find particular notes on particular themes and issues. - -- Send those particular notes to a file that will be the basis for a - portion of your outline or draft. - -All of these basic research, organization, and writing steps are steeped in traditional methods. ------------------------------------------------------------------------------------------------- - -- As researchers and writers of papers, articles, books – from grade - school, high school, college, graduate school, through our - professional writings – as well as teachers and editors of countless - efforts by others, we know the game. Indeed, we are the coaches and - referees and main players of the game! And our own coaches taught us - how to do it right! - -- On the basis of this experience, we made ZettelGeist to do the most - important, fundamental steps of research and writing as clearly and - directly as possible, based on the methods that our mentors used to - write great books before personal computers came into being. - -- But because we are ourselves computerized (having come into - professional life just as the pc revolution occurred and, therefore, - having played *that game* ever since), we have here merged these - techniques into the computer world more directly than any program has - before. (Believe us: we know! We have tried and deployed every option - out there, from 1980 until yesterday – as a matter of professional - need.) - -- Since we know the frustration that many so-called “notetaking - programs” cause, we have made a fundamental decision to ensure that - the basis for all of this is already in the computer you own and the - internet sites you have access to. - -- You don’t have to go and buy anything new. You already have - *supercomputers* that earlier great writers could never have - imagined. This system will just help you to take advantage of these - machines in ways consistent with the key principles of research and - organization that the great writers developed, but most computer - programs have left out. - -- This is the Research-Writing-Computer Singularity we have been - waiting for! - -The first thing to know is that with ZettelGeist you can do ALL of the above by starting (and finishing) your writing with ANY SOFTWARE YOU WANT TO USE!! The ZettelGeist program works with and *between* your preferred word processors. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -- Many programs suggest they are “app-gnostic” (agnostic or indifferent - about which app you use), but that usually just means you can save - your work into another format (docx, pdf, txt, etc.). - -- ZettelGeist is truly app neutral in the sense that you can make notes - (zettels) with any software, as long as you make them according to a - certain pattern (indicating note section, title section, etc…) and - save or download them in good old “.txt” format. - -- The “pattern” is exactly what you would use to write out a notecard - in the traditional way (by hand, or typed on paper or computer), so - it really isn’t that big a deal. Plus, once you make one card (or - zettel), you can just edit the same card to make any necessary - changes for the next card (change the note, change the page numbers, - etc.) then save the new card with a new filename, eg. “note02.txt” - and move on… - -- You can do this with ANY word processor you want to use: Google Docs, - Microsoft Word, LibreOffice. In fact, you could just use one of the - most basic editors that are already residing on your computer, or - easily installed for free: Notepad, Wordpad (on Windows), TextEdit - (Mac), Vim, Emacs, etc. - -- If that last sentence confuses you, don’t worry. Just use Google Docs - or Word or whatever you are used to. (The surprise is that you don’t - actually have to buy any word processor at all because the above - basic text editors come with your system and ZettelGeist would allow - you to use those for free to research, organize, and write any great - work you need to produce – but let’s set that issue aside for the - moment.) - -Let’s try it out with Microsoft Word. -------------------------------------- - -- As you can see on the “Get Started” and “Note Format” page above, a - note in ZettelGeist is just a set of information put together in - sections marked with a colon, like title: or note: or tags:, etc. - -- There are a number of those built into the system (see Note Format - page) because, as researchers, we know you might also want to - “comment:” or write a “summary:” or add bibliographical information - such as “bibkey:” and “pages:”, and so on. - -- BUT this is completely up to you. You can add any of these elements, - or only one or two, in any order according to your needs. A - completely valid note would just start with “note:” and then just - consist of the text of your note in the following line surrounded by - quotations, including all the information you want to produce or - record right there. That would work just fine. You could then save it - as “note-01.txt” and it could be processed in ZettelGeist without a - problem (after a minor change to the filename so it can be searched - and used in the system – more on that in a minute). - -- If you want the other elements, like title: summary: or comment: - great, just add them too. As long as you name sections according to - the list on the “Note Format” page, or listed in “zettel –help”, you - can create notes however you prefer, with sections in whatever order - you like. Basically, you are making up your own notetaking system - (based on these universally valid “fields”) and can treat any “file” - as a blank notecard, just as you do when you buy a pack of 3 x 5 - notecards at the pharmacy and make flash cards for a high school - class. Fill them out as you like! - -So, with that flexibilty in mind, let’s make your first note. -------------------------------------------------------------- - -For now, just go to Word, or GDocs (on the other tab)…your choice. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -- Start a new document. - -- Then take one step that will help with this experiment. - - - Go to “Tools>Preferences>AutoCorrect” and **uncheck** most of the - automatic styling elements. (This is based on the Mac version, but - it should be about the same on the PC.) - - - Uncheck “Capitalize first letter of sentences” - - - Under “AutoFormat As You Type” uncheck “Automatic bulleted - lists” and "“Straight quotes with smart quotes” and all the - others. - - - We want the simplest and plainest characters possible (most - programs add fancier “unicode” characters with these features – - but we don’t need them and they actually mess up searching and - finding later). - - - You can always turn these back on later, but you probably wouldn’t - miss most of these anyway. - -- Close preferences and then just look at your plain document page. But - now you can think of it a little differently. This is now a - *notecard* (right out of your 3 x 5 package)! Even though it is on a - supercomputer in the “cloud” linked to the internet, it is just a - “card” now. Let’s just fill it in as we would by hand. - -- Let’s say you want to give it a title (remember, it’s up to you - whether you need a title, but this will remind you what this field - and other subsequent ones in this research session are about). - -- So, type: - -``title: Reading notes on The Great Gatsby`` - -- Ok. That’s the top line of your note, just like on the “red” line of - your good old notecard. - -- Now, let’s put in something about the book you are reading, for - instance (you could be taking notes for anything including your own - novel or writing poetry or writing a shopping list, but we are - thinking research paper for now). - -- Make a new line and type: - -``note: "This is a note about The Great Gatsby, a novel by F. Scott Fitzgerald. Written during The Jazz Age, it is a masterpiece of American Literature."`` - -- Notice that I put the text part of this note: “inside quotation - marks.” This is necessary when you write longer notes because it - means you can put quotes and colons and multiple lines into your - plain text card. Just a formality, but not a big deal. If you just - write a single line without colons and other such things, you don’t - need the quotes. But it works better with them if you are making - notes this initial way with Word or another word processer. - -- For now, let’s just stop there and see what we can do with that very - first note. - -- Let’s name the file, on Google Docs, by simply clicking in the file - name box above (as usual – you know) and typing “Gatsby-Note”. - -- Now let’s save it so we can soon make it into a zettel for research - processing. - -- Click File> Save As, then, under file format “Plain Text.txt.” - -- Then name the file “Gatsby-Note-1.yaml” and save it to a directory - called “Gatsby-Reading-Notes” (for this project): “.yaml” is the - “format” that the ZettelGeist system needs to work with. - -- If it asks about “text encoding,” select "Western (ASCII) - -- Immediately, it will save to your computer (into the directory set by - your browser for downloads – usually Downloads). - -But let’s make a couple of more notes (zettels) before we do any more. ----------------------------------------------------------------------- - -- All you need to do to make your next note(s) is edit your existing - document! You don’t have to create a new one or anything. You already - saved your first card, so it is safe. Now just edit your next one on - the basis of this start, and save the new iteration as the next note. - -- We can leave title: the same… So no changes there. - -- Let’s change the note: (obviously). Just highlight from the first - quotation mark to the last, delete the original note, and write - another. - -``note: "The novel opens with the lines 'In my younger and more vulnerable years my father gave me some advice that I’ve been turning over in my mind ever since. 'Whenever you feel like criticizing any one,' he told me, 'just remember that all the people in this world haven’t had the advantages that you’ve had.' (Gatsby, 1)"`` - -- We just added a quote from the book. So you might want to write - something about that citation (your own opinion of its importance, - etc.) as well. (Teachers want to hear your voice, and you want to - remember why you took the note.) - -- That’s simple: You could just add something to the “note:” section - itself: - -``"The novel opens with the lines 'In my younger and more vulnerable years my father gave me some advice that I’ve been turning over in my mind ever since. “Whenever you feel like criticizing any one,' he told me, 'just remember that all the people in this world haven’t had the advantages that you’ve had.' (Gatsby, 1) Comment: This is a famous first line and my teacher says that we should analyze it carefully."`` - -- See the “Comment” at the end? That would do it. As a result, you have - title, note, citation-page (Gatsby, 1), and a comment (inside that - last quotation mark). All the elements of a traditional notecard are - there, just within the “note:” field. So let’s save that as a second - note. - -- Just click “File>Save As” again. You don’t have to change settings - again. Just change the name to “Gatsby-Note-2.yaml”. - -- Cool. Two notes are now in your research “card stack” for processing. - If we did pull them into the system, they would be completely - searchable and usable. Again: you could just take notes with “notes:” - or “title:” and “note:” and that will do the job. - -- But, you can do a lot more if you want to. ZettelGeist allows you to - break up these elements of research notes into each of the - traditional elements listed on the “Note Format” page! - -So let’s go back to our document and adjust this note to make a third with a little more…zing! ----------------------------------------------------------------------------------------------- - -- Highlight “Comment: This is a famous first line and my teacher says - that we should analyze it carefully.” Then cut that (not delete). - -- Make a new line and paste it. Then make the capital “C” into a - lowercase “c” and put your comment in quotations, resulting in: - -``comment: This is a famous first line and my teacher says that we should analyze it carefully."`` - -- You just set up a new “comment:” field that can be searched - separately if you want. This is not necessary (as above) but it does - allow you to separate, let’s say, the quotes you take from the source - (in “note:”) and your ideas (in “comment:”). It’s up to you, but just - in case you like it, it’s that easy to add more fields (per the “Note - Format” page). - -- Now, let’s do something else that is key to research. Add “tags” to - the note. This is another traditional part of any notecard system. It - allows you to mark each note as being relevant to a theme or a - keyword or a part of your paper (Intro, Body 1, Body 2, Conclusion, - etc.). Adding tags is also really easy with the ZettelGeist method. - -- Continue with the existing document. - - - (See? Making new “cards” just means editing and then re-saving - your existing card in .yaml format with a new numbered name. Just - give each new “save as” a different number: Gatsby-Note-01.yaml, - Gatsby-Note-02.yaml, Gatsby-Note-03.yaml, etc. The existing - elements just get reused over and over as you save every new - version to your “stack.”) - -- To add tags, start a new line under the “comment:” line. - -- Type this: - -:: - - tags: - - My first tag - - Gatsby note - - First line of book - -- Could it be simpler? Ha! “tags:” is the new section, just as above. - But each tag is separate, so you just start the line for each tag - with a hyphen to indicate this is the case. That’s all!!! (BTW: This - is why we turned off “automatic lists,” because that feature would - make those hyphens into bullet points. We just want clean hyphens.) - -- Let’s save that fancier note, just as above: “File>Save - as>Gatsby-Note-03.yaml,” and so on.) - -Your research stack is growing! Let’s do one more, adding one more feature. Again, it isn’t necessary, but “It’s there!” So what the heck? ------------------------------------------------------------------------------------------------------------------------------------------- - -- Edit the document again. - -- Let’s find a new citation from the book and put it in the “note:” - section (between quotes) and write a new “comment:” Just zap the old - material and add the new, adjusting only what is necessary for the - new note, resulting in something like: - -:: - - title: Reading notes on The Great Gatsby - note: "Conduct may be founded on the hard rock or the wet marshes, but after a certain point I don’t care what it’s founded on. When I came back from the East last autumn I felt that I wanted the world to be in uniform and at a sort of moral attention forever; I wanted no more riotous excursions with privileged glimpses into the human heart." - comment: "In second paragraph, Fitzgerald begins to suggest Gatsby's cynicism and hints at fact that he was a veteran of the First World War" - tags: - - Gatsby note - - Cynicism - - Impact of WWI - -- You can also change the tags for this next note, as I did here. - -- Obviously, you could save this to the “stack,” go on to the next, and - be fine. - -- But notice that this time (for demonstration purposes) I didn’t add - an bibliographical indicator like “(Gatsby, 2)”. Most of us would - just put that MLA element in and be fine. In fact, for 99% of users, - that’s enough. Just keep track of which books you are using and add - the notes or footnotes when you pull things together later. No - problem. - -- But if you are into “bibtex” and plan to build your paper with zotero - and pandoc (for more advanced users) you could also use this system - to keep track of your bibliography. That just involves adding the - following at the bottom: - -:: - - cite: - bibkey: fitzgerald_gatsby_1925 - page: p. 2 - -- That’s all. If you don’t know what “bibkey” means right now, don’t - worry about it. (Just use MLA as above.) But if you do, you can add - it and link this to your .bib file and when you build with pandoc all - will be well. Just notice the spaces before bibkey: and page: Don’t - use tabs to indent – put in two spaces. - -- Now let’s save this new card, as above. - -- OK! Now we have a “Stack” of cards in our “Gatsby-Reading-Notes” - directory, each named “Gatsby-Note….txt” You could write a million - more. Just change the elements that need to be changed and save the - new version as a new card: copy or type out new quotes from your - book; add comments; just write out notes; change tags; change - page(s); change title if you want, etc. - - - *Quick tip*: copying and pasting from electronic sources can be a - little tricky because you don’t know about the “fancy characters” - that will end up in your note. It’s best to just type out a quote - (and paraphrase more than quoting, as the masters say). But if you - do this, saving as plain text and Western (ASCII) should take care - of it. Also make sure you are pasting things are inside those - quotation marks). You might end up, after processing below, with - some strange charcters like in your - notecards. They can be deleted, but are a little bit of a pain - (and why plain text writing emphasizes plain text). - -Let’s process our notes. ------------------------- - -- Anyway, based on our start, let’s begin to process the notes we have - made. (Just think about how you would start shuffling or organizing a - stack of notecards you have written on paper.) - -- This is actually where the real power of this system starts. - - - Remember, the idea is to make a notecard for every idea for your - project, then be able to find them, select the ones you need, then - print them out for your paper or for each section of your paper, - according to themes or keywords or… - - - This is waaaaaaay different from having all of your notes in a - single document or having them on a few “Onenote” or “Evernote” - pages, but then having difficulty selecting the particular cards - or notes you need in particular. This is where the ZettelGeist - system becomes an electronic version of “moving the cards around” - when you start to outline or write the paper. - -- OK: you are ready to rock. Now you can do everything that is - demonstrated with the “test” materials on the “Getting Started” page, - but with your own research notes written in Word or GDocs or … - -- Everything from this point on assumes you have installed ZettelGeist - and have your zenv environment working as explained on the - Installation page. - -- This can be done right in the same directory you are working in. - -- First create a database name. - -``zcreate --database gatsby.db`` - -- Then import all of the new yaml notecards (or zettels) into your - database. - -``zimport --database --dir $(pwd)`` - -- The output will show each of your notes being pulled into the - database. - -- Once that is done, you are ready to start searching and organizing - your notes. - -- Of course, with only a few it isn’t super exciting. But if you have - taken notes on every thought you had when reading The Great Gatsby, - the game would really be on!! - -- Let’s search for something in our stack. To do this, you use “zfind.” - To see all the elements of zfind, you could type “zfind –help”. But - we will keep things simple now. - -- Let’s search for the card that had to do with the First World War. - -- To do that, at the command line, type: - -``zfind --database Gatsby.db --query-string 'comment:"First World War"' --show-title --show-note --show-comment`` - -- When you enter this, the output will be the card that included the - “string” First World War in the “commment:” field. See? - -- There are a zillion things to be done now that you have this - searching ability. Again, it really comes into play when you have a - bunch of notes and want to search on them. But this is the start. - Let’s do one more. - -``zfind --database Gatsby.db --query-string 'tags:"First Line"' --show-title --show-note --show-comment`` - -- Take a look at what each of those commands is doing. ``zfind`` is - starting the search engine. It is looking in the - ``--database Gatsby.db``. It is searching for particular strings of - letters in particular fields - ``--query-string 'comment:"First World War"' and --query-string 'tags:"First line"'``. - Then, for each card that has those elements, it is showing the title, - showing the note, and showing the comment. That is what is showing up - on the output. - -- The real power of zfind (searching in ZettelGeist) comes from - combining these things (in as many ways as you want to use for your - purposes). Here is an example. Let’s search for *both* of these - elements in your cards: those with tags with First Line and those - with commments with First World War. To do that, you just use the - “or” command (the vertical bar created by [shift-backslash] in the - query string, as in: - -``zfind --database Gatsby.db --query-string 'tags:"First Line" | comment:"First World War"' --show-title --show-note --show-comment`` - -- Hit enter, and both of those cards will flash by (or the parts you - specified: title, note, and comment – though you could have asked for - tags and cite and… any elements you include). - -- You have just searched and found the two notes that met those - requirements. Not such a big deal out of 4 notes, but out of 100? - That’s cool. - -But, you want to use them for a portion of your paper on those themes, right? ------------------------------------------------------------------------------ - -- To do that, just add one more basic element into your search command: - “> search-results.txt” That’s all you need. The “>” sign (like an - arrow) means “send that output into a file” – as in, your results - file… Or your Gatsby-results.txt file… Or your - “Gatsby-Body-Part-1.txt” file, depending on how you want to arrange - your information. - -Let’s do the last one: - -``zfind --database Gatsby.db --query-string 'tags:"First Line" | comment:"First World War"' --show-title --show-note --show-comment > Gatsby-Body-Part-1.txt`` - -- Hit enter, and in an instant you will have a file with all the - searched data under that name. Open Gatsby-Body-Part-1.txt with Word - or any editor. It will have your notes on those issues all in one - place for you to put into your paper document where you need it. - -- THAT’S how to use the *notecard* notetaking system to take notes, - mark them for particular content, find them, collect them, and then - pull them into your paper – all using the computer instead of paper - notecards (not that there is anything wrong with paper notecards, - they still rock, but we are digital writers now). - -- ZettelGeist has been made to make this great, traditional, powerful - way to do research (on anything) or just write or just make lists or… - as immediate as possible, but without trapping you in one word - processing system OR trapping your notes (etc.) in a onenote system - or an evernote system. (Nerd joke: EverNote keeps your notes, - forever: like a black hole, once the information goes in, it never - comes out.) ZettelGeist allows you to put your material in (according - to some classic rules) and then GET IT OUT in the bits and pieces - that you actually need. - -- The zfind feature can be modified in many ways to get more - “fine-tuned” material from your electronic card stack(s). Also, you - can break things up into the various fields we have discussed. BUT, - again, you could also just take notes as “note:” and be fine, - including whatever you need in that field alone (in quotations to be - sure there aren’t processing issues) and then search for strings in - all the “notes” sections. It can be that simple, or as complex or - professional as you want. It is completely up to you. - -- It is as flexible as paper notecards were, but as powerful as any - supercomputers are. That’s what we are talking about!!!! - -In conclusion, for Word (etc.) users… -------------------------------------- - -**Your notetaking system is still there, ready and waiting for you to -continue with your project! Just take a look back at the Word document -you were working on – the master “card” is ever-ready for you to edit -and “save as” your next idea, and your next, and … (Fractals, baby!!)** diff --git a/src-docs/conf.py b/src-docs/conf.py new file mode 100644 index 0000000..684ab0d --- /dev/null +++ b/src-docs/conf.py @@ -0,0 +1,35 @@ +# Configuration file for the Sphinx documentation builder. +# +# For the full list of built-in configuration values, see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information + +import os +import sys + +project = "Template Project" +copyright = "2024, Nicholas M. Synovic" +author = "Nicholas M. Synovic" + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration + +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.napoleon", +] + + +templates_path = ["_templates"] +exclude_patterns = [] + + +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output + +html_theme = "alabaster" +html_static_path = ["_static"] + +sys.path.insert(0, os.path.abspath("../src")) diff --git a/src-docs/index.rst b/src-docs/index.rst new file mode 100644 index 0000000..20eea04 --- /dev/null +++ b/src-docs/index.rst @@ -0,0 +1,20 @@ +.. Template Project documentation master file, created by + sphinx-quickstart on Sun Jul 7 17:20:16 2024. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to Template Project's documentation! +============================================ + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/src-docs/modules.rst b/src-docs/modules.rst new file mode 100644 index 0000000..e9ff8ac --- /dev/null +++ b/src-docs/modules.rst @@ -0,0 +1,7 @@ +src +=== + +.. toctree:: + :maxdepth: 4 + + src diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/main.py b/src/main.py new file mode 100644 index 0000000..4693850 --- /dev/null +++ b/src/main.py @@ -0,0 +1,6 @@ +def main() -> None: + pass + + +if __name__ == "__main__": + main() diff --git a/src/ps.text b/src/ps.text deleted file mode 100644 index 156eae2..0000000 --- a/src/ps.text +++ /dev/null @@ -1,9 +0,0 @@ -USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND -_windowserver 22462 5.3 0.6 3810764 52512 ?? Ss Tue11PM 97:34.94 /System/Library/PrivateFrameworks/SkyLight.framework/Resources/WindowServer -daemon -gkt 41927 5.3 4.6 3569996 387396 ?? S 9:52PM 0:43.32 /Applications/Paltalk.app/Contents/MacOS/Paltalk -_coreaudiod 170 4.9 0.1 2474348 5288 ?? Ss Sun11PM 112:38.13 /usr/sbin/coreaudiod -gkt 22660 3.5 2.5 3677892 206684 ?? S Wed07AM 109:15.02 /Applications/Google Chrome.app/Contents/MacOS/Google Chrome -gkt 26378 3.1 1.0 2940736 86936 ?? S Thu03PM 4:56.22 /Applications/iTerm.app/Contents/MacOS/iTerm2 -root 57 1.7 0.2 2509160 18132 ?? Ss Sun11PM 14:47.52 /usr/libexec/airportd -_hidd 99 1.2 0.1 2473184 6372 ?? Ss Sun11PM 64:39.83 /usr/libexec/hidd -root 77 0.9 0.2 2521356 16884 ?? Ss Sun11PM 1:24.75 /usr/libexec/opendirectoryd diff --git a/tests/.gitkeep b/tests/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_zettelgeist.py b/tests/test_zettelgeist.py deleted file mode 100644 index 51de92f..0000000 --- a/tests/test_zettelgeist.py +++ /dev/null @@ -1,171 +0,0 @@ -import sys -import textwrap -import yaml - -from zettelgeist import zettel - -# content of test_sysexit.py -import pytest - - -def f(): - raise SystemExit(1) - - -def test_mytest(): - with pytest.raises(SystemExit): - f() - - -def test_parse_empty(): - doc = {} - zettel.parse_zettel(doc) - - -def test_parse_simple_valid(): - doc = { - 'title': "Valid title" - } - zettel.parse_zettel(doc) - - -def test_parse_simple_bad_value(): - doc = { - 'title': 35 - } - with pytest.raises(zettel.ParseError): - zettel.parse_zettel(doc) - - -def test_simple_zettel(): - zdoc = """ - title: My First Zettel - mentions: - - dbdennis - - gkt - tags: - - Charles Babbage - - Ada Lovelace - cite: - bibkey: Ifrah - page: "22-36" - dates: - year: "1841" - era: CE - summary: An amazing Zettel - note: Text of Zettel - bibkey: BibKey - bibtex: "@article{key, entries}" - """ - zdoc = textwrap.dedent(zdoc) - print(zdoc) - zdict = yaml.load(zdoc) - z = zettel.Zettel(zdict) - - -def test_creator_and_load(): - z = zettel.Zettel({}) - z.set_field('title', 'My First Zettel') - z.reset_list_field('mentions') - z.append_list_field('mentions', 'dbdennis') - z.append_list_field('mentions', 'gkt') - z.reset_list_field('tags') - z.append_list_field('tags', 'Charles Babbage') - z.append_list_field('tags', 'Ada Lovelace') - z.set_citation('Ifrah', '22-36') - z.set_dates('1841', 'CE') - z.set_field('summary', 'An amazing Zettel') - z.set_field('note', 'Text of Zettel') - z.set_field('bibkey', 'BibKey') - z.set_field('bibtex', '@article{ley, entries}') - text = z.get_yaml() - - ydoc = yaml.load(text) - z2 = zettel.Zettel(ydoc) - text2 = z2.get_yaml() - assert text == text2 - - -def test_creator_and_load_optional_fields(): - z = zettel.Zettel({}) - z.set_field('title', 'My First Zettel') - z.reset_list_field('mentions') - z.append_list_field('mentions', 'dbdennis') - z.append_list_field('mentions', 'gkt') - z.reset_list_field('tags') - z.append_list_field('tags', 'Charles Babbage') - z.append_list_field('tags', 'Ada Lovelace') - z.set_citation('Ifrah') - z.set_dates('1841') - z.set_field('summary', 'An amazing Zettel') - z.set_field('note', 'Text of Zettel') - z.set_field('bibkey', 'BibKey') - z.set_field('bibtex', '@article{ley, entries}') - text = z.get_yaml() - - ydoc = yaml.load(text) - z2 = zettel.Zettel(ydoc) - text2 = z2.get_yaml() - assert text == text2 - - -def test_zettel_fts_strings(): - z = zettel.Zettel({}) - z.set_field("title", "title") - z.set_field("summary", "a summary") - expected = {'title': 'title', 'summary': 'a summary'} - z.get_indexed_representation() == expected - - -def test_zettel_fts_lists(): - z = zettel.Zettel({}) - z.reset_list_field("tags") - z.append_list_field("tags", "Babbage") - z.append_list_field("tags", "Lovelace") - expected = {'tags': 'Babbage,Lovelace'} - z.get_indexed_representation() == expected - - -def test_zettel_fts_cite(): - z = zettel.Zettel({}) - z.set_citation("Castells 2006", "ii-iv") - z.get_indexed_representation() - expected = {'cite': 'bibkey:Castells 2006,page:ii-iv'} - z.get_indexed_representation() == expected - - z.set_citation("Castells 2006") # omitting page numbers - expected = {'cite': 'bibkey:Castells 2006'} - z.get_indexed_representation() == expected - - -def test_zettel_fts_dates(): - z = zettel.Zettel({}) - z.set_dates('2006', 'CE') - expected = {'dates': 'year:2006,era:CE'} - z.get_indexed_representation() == expected - - z.set_dates('2006') # omit era - expected = {'dates': 'year:2006'} - z.get_indexed_representation() == expected - - -def test_invalid_zettel_fields(): - z = zettel.Zettel({}) - with pytest.raises(zettel.ParseError): - z.set_field('blah', 'blah') - z.delete_field('blah') - - # checks for injection of bad values in nested citation dictionary - z.set_citation('Castells 2006', 'ii-iv') - with pytest.raises(zettel.ParseError): - z.zettel['cite']['blah'] = 'blah' - z.get_yaml() # force checks - - del(z.zettel['cite']['blah']) - - # checks for injection of bad values in nested dates dictionary - z.set_dates('2006', 'CE') - with pytest.raises(zettel.ParseError): - z.zettel['dates']['blah'] = 'blah' - z.get_yaml() - del(z.zettel['dates']['blah']) diff --git a/zdb_funcs.sh b/zdb_funcs.sh deleted file mode 100644 index ca1d75a..0000000 --- a/zdb_funcs.sh +++ /dev/null @@ -1,17 +0,0 @@ -# To use these in bash/zsh, you can source this file. -# Usage: -# db_keywords filename.db -# db_mentions filename.db -# -# This is for keyword/mention discoery in a zdb until we can decide on -# proper z-commands and how they would work. - -zdb_tags() { - sqlite3 $1 'select distinct(lower(tag)) from tags' | sort -f | uniq -i -} - -zdb_mentions() { - sqlite3 $1 'select distinct(lower(mention)) from mentions' | sort -f | uniq -i -} - - diff --git a/zettelgeist/zcreate.py b/zettelgeist/zcreate.py index 504789c..d4c0323 100644 --- a/zettelgeist/zcreate.py +++ b/zettelgeist/zcreate.py @@ -1,14 +1,20 @@ # zcreate.py - create Zettel database -import os.path import argparse +import os.path + from . import zdb def parse_options(): parser = zdb.get_argparse() - parser.add_argument('--delete', action='store_const', const=True, - default=False, help="delete if it already exists") + parser.add_argument( + "--delete", + action="store_const", + const=True, + default=False, + help="delete if it already exists", + ) return parser.parse_args() @@ -30,9 +36,12 @@ def zcreate(args): def main(): args = parse_options() - print("Warning: zcreate is deprecated - use zimport --create --database %s" % args.database) + print( + "Warning: zcreate is deprecated - use zimport --create --database %s" + % args.database + ) zcreate(args) -if __name__ == '__main__': +if __name__ == "__main__": main() diff --git a/zettelgeist/zdb.py b/zettelgeist/zdb.py index 4b4fb3b..8945bbb 100644 --- a/zettelgeist/zdb.py +++ b/zettelgeist/zdb.py @@ -1,4 +1,3 @@ - # ZettelGeist uses a FTS system for organizing Zettels. The index is intended # to be emphemeral and can be regenerated at any time. The schema itself is # ephemeral and can be augmented with additional fields of interest. @@ -16,22 +15,22 @@ ZettelSQLFields = zettel.ZettelFieldsOrdered # Default Zettel DB name -ZDB = 'zettels.db' +ZDB = "zettels.db" def get_argparse(): parser = argparse.ArgumentParser() - parser.add_argument( - '--database', help="database name", required=True) + parser.add_argument("--database", help="database name", required=True) return parser import pprint + printer = pprint.PrettyPrinter(indent=2) def unquote(text): - return text.replace('"', '').replace("'", "") + return text.replace('"', "").replace("'", "") class SQLiteFTS(object): @@ -43,18 +42,17 @@ def __init__(self, db_name, field_names): self.fts_field_names = field_names # for sqlite insert template generation - self.fts_field_refs = ['?'] * len(self.fts_field_names) - self.fts_field_init = [''] * len(self.fts_field_names) + self.fts_field_refs = ["?"] * len(self.fts_field_names) + self.fts_field_init = [""] * len(self.fts_field_names) self.fts_fields = dict(zip(self.fts_field_names, self.fts_field_refs)) - self.fts_default_record = dict( - zip(self.fts_field_names, self.fts_field_init)) + self.fts_default_record = dict(zip(self.fts_field_names, self.fts_field_init)) self.zettel = None def bind(self, zettel, filename, document=""): self.zettel = zettel doc = zettel.get_indexed_representation() - doc.update({'filename': filename}) - doc.update({'document': document}) + doc.update({"filename": filename}) + doc.update({"document": document}) self.record = self.fts_default_record.copy() for k in doc.keys(): if k in self.record.keys(): @@ -71,17 +69,17 @@ def drop_table(self): def create_table(self): sql_fields = ",".join(self.fts_default_record.keys()) - #print("CREATE VIRTUAL TABLE zettels USING fts4(%s)" % sql_fields) - self.cursor.execute( - "CREATE VIRTUAL TABLE zettels USING fts4(%s)" % sql_fields) + # print("CREATE VIRTUAL TABLE zettels USING fts4(%s)" % sql_fields) + self.cursor.execute("CREATE VIRTUAL TABLE zettels USING fts4(%s)" % sql_fields) self.conn.commit() - self.create_index_table('tags', 'tag') - self.create_index_table('mentions', 'mention') + self.create_index_table("tags", "tag") + self.create_index_table("mentions", "mention") def create_index_table(self, table_name, field_name): self.cursor.execute("DROP TABLE IF EXISTS %(table_name)s" % vars()) self.cursor.execute( - "CREATE TABLE %(table_name)s (%(field_name)s text)" % vars()) + "CREATE TABLE %(table_name)s (%(field_name)s text)" % vars() + ) self.conn.commit() def update_index(self, table_name, field_name, items): @@ -89,20 +87,20 @@ def update_index(self, table_name, field_name, items): return for item in items: self.cursor.execute( - "INSERT INTO %(table_name)s (%(field_name)s) VALUES (?)" % vars(), (item,)) + "INSERT INTO %(table_name)s (%(field_name)s) VALUES (?)" % vars(), + (item,), + ) # NB: (item,) means to pack this item into a tuple as required by sqlite3. def insert_into_table(self): sql_params = ",".join(self.fts_fields.values()) sql_columns = ",".join(list(self.record.keys())) sql_insert_values = list(self.record.values()) - insert_sql = "INSERT INTO zettels (%s) VALUES (%s)" % ( - sql_columns, sql_params) + insert_sql = "INSERT INTO zettels (%s) VALUES (%s)" % (sql_columns, sql_params) self.cursor.execute(insert_sql, sql_insert_values) self.conn.commit() - self.update_index('tags', 'tag', self.zettel.get_list_field('tags')) - self.update_index('mentions', 'mention', - self.zettel.get_list_field('mentions')) + self.update_index("tags", "tag", self.zettel.get_list_field("tags")) + self.update_index("mentions", "mention", self.zettel.get_list_field("mentions")) # A term_list is a list of 3-tuples (not-option, fieldname, word) @@ -112,8 +110,8 @@ def fts_search(self, term_list): if type(term) == type(()) and len(term) == 3: (name, not_operator, words) = term words = unquote(words) - if not_operator not in '-': - not_operator = '' + if not_operator not in "-": + not_operator = "" if name not in self.fts_field_names: continue for word in words.split(): @@ -124,7 +122,7 @@ def fts_search(self, term_list): Q = "SELECT * from zettels where zettels match '%s'" % fts_terms # print(Q) for row in self.cursor.execute(Q): - yield(row) + yield (row) def fts_query(self, prepared_sql): return self.cursor.execute(prepared_sql) @@ -132,7 +130,7 @@ def fts_query(self, prepared_sql): def get_tags_generator(self): Q = "select distinct(tag) from tags" for row in self.cursor.execute(Q): - yield(row['tag']) + yield (row["tag"]) def get_tags_list(self): gen = self.get_tags_generator() @@ -141,7 +139,7 @@ def get_tags_list(self): def get_mentions_generator(self): Q = "select distinct(mention) from mentions" for row in self.cursor.execute(Q): - yield(row['mention']) + yield (row["mention"]) def get_mentions_list(self): gen = self.get_mentions_generator() @@ -163,6 +161,7 @@ def __str__(self): def get(db_name): return SQLiteFTS(db_name, ZettelSQLFields) + GRAMMAR = """@@grammar::ZQUERY start = expression $ ; @@ -179,7 +178,7 @@ def get(db_name): ; term - = + = | and_expr | factor ; @@ -203,7 +202,7 @@ def get(db_name): | z_field ; -z_field +z_field = field:literal ':' text:literal ; diff --git a/zettelgeist/zettel.py b/zettelgeist/zettel.py index 0a16909..51c0697 100644 --- a/zettelgeist/zettel.py +++ b/zettelgeist/zettel.py @@ -2,38 +2,49 @@ # zettel.py - A checker for Zettels # -import sys import argparse import readline # for input() +import sys -import frontmatter # to accommodate Markdown with YAML frontmatter +import frontmatter # to accommodate Markdown with YAML frontmatter import yaml + try: - from yaml import CLoader as Loader, CDumper as Dumper + from yaml import CDumper as Dumper + from yaml import CLoader as Loader except ImportError: - from yaml import Loader, Dumper + from yaml import Loader, Dumper +import json import os import os.path -import json import shutil - from time import strftime # Recursive descent parsing of Zettel dictionary format. -ZettelStringFields = ['title', 'bibkey', 'bibtex', - 'ris', 'inline', 'url', 'summary', 'comment', 'note'] -ZettelListFields = ['tags', 'mentions'] -ZettelStructuredFields = ['cite', 'dates'] -ZettelExtraFields = ['filename', 'document'] -ZettelFieldsOrdered = ZettelStringFields + \ - ZettelListFields + ZettelStructuredFields + ZettelExtraFields +ZettelStringFields = [ + "title", + "bibkey", + "bibtex", + "ris", + "inline", + "url", + "summary", + "comment", + "note", +] +ZettelListFields = ["tags", "mentions"] +ZettelStructuredFields = ["cite", "dates"] +ZettelExtraFields = ["filename", "document"] +ZettelFieldsOrdered = ( + ZettelStringFields + ZettelListFields + ZettelStructuredFields + ZettelExtraFields +) ZettelFields = set(ZettelFieldsOrdered) -CitationFields = set(['bibkey', 'page']) -DatesFields = set(['year', 'era']) +CitationFields = set(["bibkey", "page"]) +DatesFields = set(["year", "era"]) -ZettelMarkdownExtensions = ['.text', '.txt', '.md', '.markdown'] +ZettelMarkdownExtensions = [".text", ".txt", ".md", ".markdown"] class ParseError(Exception): @@ -51,29 +62,30 @@ def typename(value): def parse_zettel(doc): if not isinstance(doc, dict): raise ParseError( - "Zettels require key/value mappings at top-level. Found %s" % typename(doc)) + "Zettels require key/value mappings at top-level. Found %s" % typename(doc) + ) parse_check_zettel_field_names(doc) # These fields are all optional but, if present, must be strings - parse_string_field(doc, 'title') - parse_string_field(doc, 'bibkey') - parse_string_field(doc, 'bibtex') - parse_string_field(doc, 'ris') - parse_string_field(doc, 'inline') - parse_string_field(doc, 'url') - parse_string_field(doc, 'summary') - parse_string_field(doc, 'comment') - parse_string_field(doc, 'note') - parse_string_field(doc, 'document') + parse_string_field(doc, "title") + parse_string_field(doc, "bibkey") + parse_string_field(doc, "bibtex") + parse_string_field(doc, "ris") + parse_string_field(doc, "inline") + parse_string_field(doc, "url") + parse_string_field(doc, "summary") + parse_string_field(doc, "comment") + parse_string_field(doc, "note") + parse_string_field(doc, "document") # These fields are all optional but, if present, must be list of strings - parse_list_of_string_field(doc, 'tags') - parse_list_of_string_field(doc, 'mentions') + parse_list_of_string_field(doc, "tags") + parse_list_of_string_field(doc, "mentions") - parse_citation(doc, 'cite') - parse_dates(doc, 'dates') + parse_citation(doc, "cite") + parse_dates(doc, "dates") # TODO: Check for extraneous fields in all cases @@ -100,22 +112,27 @@ def parse_string_field(doc, field, required=False): value = doc.get(field, None) if value == None: if required: - raise ParseError("Field %s requires a string but found %s of type %s" % ( - field, value, typename(value))) + raise ParseError( + "Field %s requires a string but found %s of type %s" + % (field, value, typename(value)) + ) # This extra check is needed to handle situation where a YAML field is # present but is null. We cannot allow it. if field in doc: raise ParseError("Field %s may not be (YAML) null" % field) return if not isinstance(value, str): - raise ParseError("Field %s must be a string or not present at all - found value %s of type %s" % - (field, value, typename(value))) - #if len(value) == 0: + raise ParseError( + "Field %s must be a string or not present at all - found value %s of type %s" + % (field, value, typename(value)) + ) + # if len(value) == 0: # raise ParseError("Field %s is an empty string. Not permitted." % field) # TODO: There is a possible bug in list of string that allows a field to be defined as YAML none. + def parse_list_of_string_field(doc, field, required=False): value = doc.get(field, None) if value == None: @@ -127,8 +144,10 @@ def parse_list_of_string_field(doc, field, required=False): raise ParseError("Field %s may not be (YAML) null" % field) return if not isinstance(value, (list, tuple)): - raise ParseError("Field %s must be a list or not present at all - found value %s of type %s" % - (field, value, typename(value))) + raise ParseError( + "Field %s must be a list or not present at all - found value %s of type %s" + % (field, value, typename(value)) + ) # Make a dictionary of the list items for checking purposes only # That is, treat the list like a dictionary. Will simplify with comprehension magic later @@ -148,8 +167,8 @@ def parse_citation(doc, field): if not isinstance(value, dict): raise ParseError("%s must be a nested (citation) dictoinary" % field) parse_check_citation_field_names(value) - parse_string_field(value, 'bibkey', True) - parse_string_field(value, 'page') + parse_string_field(value, "bibkey", True) + parse_string_field(value, "page") def parse_dates(doc, field): @@ -159,8 +178,9 @@ def parse_dates(doc, field): if not isinstance(value, dict): raise ParseError("%s must be a nested (dates) dictionary" % field) parse_check_dates_field_names(value) - parse_string_field(value, 'year', True) - parse_string_field(value, 'era') + parse_string_field(value, "year", True) + parse_string_field(value, "era") + # This is to support formatting of resulting YAML (after modification of the underlying dictionary) @@ -180,15 +200,16 @@ class literal(str): def quoted_presenter(dumper, data): - return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='"') + return dumper.represent_scalar("tag:yaml.org,2002:str", data, style='"') + # Note: Only use multiline syntax when there are actually multiple lines. def str_presenter(dumper, data): if len(data.splitlines()) > 1: - return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='|') - return dumper.represent_scalar('tag:yaml.org,2002:str', data) + return dumper.represent_scalar("tag:yaml.org,2002:str", data, style="|") + return dumper.represent_scalar("tag:yaml.org,2002:str", data) def ordered_dict_presenter(dumper, data): @@ -211,61 +232,124 @@ def get_argparse(): # note is being deprecated in future releases to give users time to migrate away from it for field in ZettelFieldsOrdered: - parser.add_argument('--delete-%s' % field, action="store_true", - help="delete field %s" % field, default=False) - - for field in ZettelStringFields + ZettelExtraFields: # allow for filename, doc - parser.add_argument('--set-%s' % - field, help="set the value of field %s" % field) - parser.add_argument('--load-%s' % - field, help="load field %s from filename" % field) + parser.add_argument( + "--delete-%s" % field, + action="store_true", + help="delete field %s" % field, + default=False, + ) + + for field in ZettelStringFields + ZettelExtraFields: # allow for filename, doc + parser.add_argument( + "--set-%s" % field, help="set the value of field %s" % field + ) + parser.add_argument( + "--load-%s" % field, help="load field %s from filename" % field + ) for field in ZettelListFields: - parser.add_argument('--reset-%s' % field, action="store_true", - help="reset list field %s" % field, default=False) - parser.add_argument('--remove-entries-in-%s' % field, nargs=2, metavar=('FASS ENTRY', 'LIST ENTRY'), type=str, - help="delete comma-separated LIST ENTRY positions from FASS ENTRY") - parser.add_argument('--append-%s' % - field, nargs="+", help="add value to list field %s" % field) + parser.add_argument( + "--reset-%s" % field, + action="store_true", + help="reset list field %s" % field, + default=False, + ) + parser.add_argument( + "--remove-entries-in-%s" % field, + nargs=2, + metavar=("FASS ENTRY", "LIST ENTRY"), + type=str, + help="delete comma-separated LIST ENTRY positions from FASS ENTRY", + ) + parser.add_argument( + "--append-%s" % field, nargs="+", help="add value to list field %s" % field + ) - parser.add_argument('--set-cite', nargs='+', type=str, metavar=('BIBKEY', 'PAGES'), - help="set citation BIBKEY [ PAGE* ] - leave blank to override existing BIBKEY") + parser.add_argument( + "--set-cite", + nargs="+", + type=str, + metavar=("BIBKEY", "PAGES"), + help="set citation BIBKEY [ PAGE* ] - leave blank to override existing BIBKEY", + ) - parser.add_argument('--set-dates', nargs='+', type=str, metavar=('YEAR', 'ERA'), - help="set dates; YEAR required - ERA is optional (extra arguments beyond the 2nd are ignored but allowed") + parser.add_argument( + "--set-dates", + nargs="+", + type=str, + metavar=("YEAR", "ERA"), + help="set dates; YEAR required - ERA is optional (extra arguments beyond the 2nd are ignored but allowed", + ) for field in ZettelFieldsOrdered: - parser.add_argument('--prompt-%s' % field, action="store_true", - help="prompt for input of %s" % field, - default=False) + parser.add_argument( + "--prompt-%s" % field, + action="store_true", + help="prompt for input of %s" % field, + default=False, + ) parser.add_argument( - '--file', help='Zettel file (.yaml) to process (or check syntax)') + "--file", help="Zettel file (.yaml) to process (or check syntax)" + ) - parser.add_argument('--save', help='Write output to specified file.') + parser.add_argument("--save", help="Write output to specified file.") - parser.add_argument('--in-place', action="store_true", default=False, - help="overwrite original file specified by --file") + parser.add_argument( + "--in-place", + action="store_true", + default=False, + help="overwrite original file specified by --file", + ) parser.add_argument( - '--backup-id', help='backup suffix for original filename', default="orig") + "--backup-id", help="backup suffix for original filename", default="orig" + ) - parser.add_argument('--name', nargs='+', help="order of components, e.g. id, or timestamp") - parser.add_argument('--name-dir', type=str, help="folder where to write file generated by --name (will NOT be created, if it does not exist)", default=".") - parser.add_argument('--id', help="human-understandable id to include in filename") - parser.add_argument('--digits', type=int, help="digits in counter (default=4)", default=4) + parser.add_argument( + "--name", nargs="+", help="order of components, e.g. id, or timestamp" + ) + parser.add_argument( + "--name-dir", + type=str, + help="folder where to write file generated by --name (will NOT be created, if it does not exist)", + default=".", + ) + parser.add_argument("--id", help="human-understandable id to include in filename") + parser.add_argument( + "--digits", type=int, help="digits in counter (default=4)", default=4 + ) - parser.add_argument('--separator', type=str, help="separate components with delimiter (default is '-')", default="-") - parser.add_argument('--counter', type=str, help="counter name (defaults to --id if present) ") - parser.add_argument('--counter-path', type=str, help="counter filename/path to filename", default=".counter.dat") + parser.add_argument( + "--separator", + type=str, + help="separate components with delimiter (default is '-')", + default="-", + ) + parser.add_argument( + "--counter", type=str, help="counter name (defaults to --id if present) " + ) + parser.add_argument( + "--counter-path", + type=str, + help="counter filename/path to filename", + default=".counter.dat", + ) - parser.add_argument('--restrict-output-fields', - nargs="+", help="restrict output fields (list of Zettel field names)", - default=ZettelFieldsOrdered) + parser.add_argument( + "--restrict-output-fields", + nargs="+", + help="restrict output fields (list of Zettel field names)", + default=ZettelFieldsOrdered, + ) # deprecated - parser.add_argument('--omit-markdown-header', action="store_true", default=False, - help="add markdown header when writing Markdown for each YAML field") + parser.add_argument( + "--omit-markdown-header", + action="store_true", + default=False, + help="add markdown header when writing Markdown for each YAML field", + ) return parser @@ -298,7 +382,6 @@ def prompt(field): class Zettel(object): - def __init__(self, data={}): self.zettel = data parse_zettel(self.zettel) @@ -309,7 +392,7 @@ def set_field(self, name, value): def delete_field(self, name): try: - del(self.zettel[name]) + del self.zettel[name] except: pass parse_zettel(self.zettel) @@ -323,73 +406,73 @@ def delete_list_field_entries(self, name, positions): return positions.sort(reverse=True) for position in positions: - del(self.zettel[name][position]) + del self.zettel[name][position] if len(self.zettel[name]) == 0: - del(self.zettel[name]) + del self.zettel[name] def append_list_field(self, name, value): self.zettel[name] = self.zettel.get(name, []) tag_set = set(self.zettel[name]) if not value in tag_set: - self.zettel[name].append(value) - parse_zettel(self.zettel) + self.zettel[name].append(value) + parse_zettel(self.zettel) def get_list_field(self, name): return self.zettel.get(name, []) def set_citation(self, bibkey, page=None): - citation = {'bibkey': bibkey} + citation = {"bibkey": bibkey} if page != None: - citation['page'] = page - self.zettel['cite'] = citation + citation["page"] = page + self.zettel["cite"] = citation parse_zettel(self.zettel) def has_citation(self): - return 'cite' in self.zettel + return "cite" in self.zettel def set_cite_bibkey(self, bibkey): if len(bibkey) == 0: return if self.has_citation(): - self.zettel['cite']['bibkey'] = bibkey + self.zettel["cite"]["bibkey"] = bibkey parse_zettel(self.zettel) def set_cite_page(self, page): if len(page) == 0: return if self.has_citation(): - self.zettel['cite']['page'] = page + self.zettel["cite"]["page"] = page parse_zettel(self.zettel) def has_dates(self): - return 'dates' in self.zettel + return "dates" in self.zettel def set_dates_year(self, year): if len(year) == 0: return if self.has_dates(): - self.zettel['dates']['year'] = year + self.zettel["dates"]["year"] = year parse_zettel(self.zettel) def set_dates_era(self, era): if len(era) == 0: return if self.has_dates(): - self.zettel['dates']['era'] = era + self.zettel["dates"]["era"] = era parse_zettel(self.zettel) def set_dates(self, year, era=None): - dates = {'year': year} + dates = {"year": year} if era != None: - dates['era'] = era - self.zettel['dates'] = dates + dates["era"] = era + self.zettel["dates"] = dates parse_zettel(self.zettel) def load_field(self, name, filename): text = [] - with open(filename, 'r') as infile: + with open(filename, "r") as infile: text = infile.readlines() - text = ''.join(text) + text = "".join(text) text = text.strip() self.set_field(name, text) parse_zettel(self.zettel) @@ -407,42 +490,42 @@ def get_yaml(self, restrict_to_fields=ZettelFieldsOrdered): continue if key in ZettelStringFields: yaml_zettel[key] = literal(self.zettel[key]) - elif key != 'document': # Only field not allowed is Markdown document + elif key != "document": # Only field not allowed is Markdown document try: yaml_zettel[key] = self.zettel[key].copy() except: print("Warning: Cannot copy %s" % key) if len(yaml_zettel) > 0: - return yaml.dump(yaml_zettel, default_flow_style=False) + return yaml.dump(yaml_zettel, default_flow_style=False) else: - return "" + return "" def get_document(self): - return self.zettel.get('document','') + return self.zettel.get("document", "") def get_filename(self): - return self.zettel.get('filename','') - -# Unlikely we need this code anymore. -# def get_text(self, omit_markdown_header, restrict_to_fields=ZettelFieldsOrdered): -# text = [] -# parse_zettel(self.zettel) -# for key in ZettelFieldsOrdered: -# if key not in self.zettel: -# continue -# if key not in restrict_to_fields: -# continue -# if not omit_markdown_header: -# text.append(markdown_h1(key)) -# if key in ZettelStringFields: -# text.append(self.zettel[key].strip()) -# elif key in ZettelListFields: -# for item in self.zettel[key]: -# text.append(markdown_listitem(item)) -# else: -# text.append(self.get_yaml([key])) -# text.append("\n") -# return "\n".join(text) + return self.zettel.get("filename", "") + + # Unlikely we need this code anymore. + # def get_text(self, omit_markdown_header, restrict_to_fields=ZettelFieldsOrdered): + # text = [] + # parse_zettel(self.zettel) + # for key in ZettelFieldsOrdered: + # if key not in self.zettel: + # continue + # if key not in restrict_to_fields: + # continue + # if not omit_markdown_header: + # text.append(markdown_h1(key)) + # if key in ZettelStringFields: + # text.append(self.zettel[key].strip()) + # elif key in ZettelListFields: + # for item in self.zettel[key]: + # text.append(markdown_listitem(item)) + # else: + # text.append(self.get_yaml([key])) + # text.append("\n") + # return "\n".join(text) def get_yaml_subset(self, fields=[]): z = Zettel({}) @@ -458,7 +541,7 @@ def get_indexed_representation(self): # def markdown_h1(text): # return "\n".join([text, len(text) * "="]) + "\n" # deprecated -#def markdown_listitem(text): +# def markdown_listitem(text): # return "- %s" % text.strip().replace("\n", "").replace("\r", "") @@ -469,7 +552,7 @@ def __init__(self, message): def load_pure_yaml(filepath): # TODO: Consider using the frontmatter to load the YAML and do all error reporting. - #print("Importing YAML: %s" % filepath) + # print("Importing YAML: %s" % filepath) ydoc = {} document = "" with open(filepath) as infile: @@ -481,7 +564,10 @@ def load_pure_yaml(filepath): try: ydocs = yaml.load_all(text, Loader=Loader) except: - print("- Warning: Cannot load YAML from %s; consider running YAML linter" % filepath) + print( + "- Warning: Cannot load YAML from %s; consider running YAML linter" + % filepath + ) return (ydoc, document) try: @@ -491,8 +577,9 @@ def load_pure_yaml(filepath): return (ydoc, document) return (ydoc, document) + def load_markdown_with_frontmatter(filepath): - #print("Importing Markdown with Frontmatter: %s" % filepath) + # print("Importing Markdown with Frontmatter: %s" % filepath) post = frontmatter.load(filepath) return (post.metadata, post.content) @@ -501,9 +588,9 @@ class ZettelLoader(object): def __init__(self, infile): # developer note: When we developed this code, we were thinking about a "fass" of zettels. # Now we just have individual zettels. - if infile.endswith('.yaml'): + if infile.endswith(".yaml"): self.ydocs = [load_pure_yaml(infile)] - elif infile.endswith('.md'): + elif infile.endswith(".md"): self.ydocs = [load_markdown_with_frontmatter(infile)] else: self.ydocs = [] @@ -511,7 +598,7 @@ def __init__(self, infile): def getZettels(self): for yaml_document in self.ydocs: (ydoc, document) = yaml_document - ydoc['document'] = document + ydoc["document"] = document if isinstance(ydoc, dict): yield Zettel(ydoc) else: @@ -522,7 +609,7 @@ def main(): parser = get_argparse() args = parser.parse_args() argsd = vars(args) - argsd['timestamp'] = True + argsd["timestamp"] = True z_generator = gen_new_zettels(args) try: @@ -537,7 +624,7 @@ def main(): sys.exit(1) filename = args.file filename_parts = os.path.splitext(filename) - if filename_parts[1] not in ['.yaml', '.md']: + if filename_parts[1] not in [".yaml", ".md"]: print("Input file not .yaml/.md: %s" % filename) sys.exit(1) backup_filename = ".".join([filename, args.backup_id]) @@ -546,20 +633,24 @@ def main(): elif args.save: filename = args.save if args.file == args.save: - print("Use --in-place instead of --save if you want to replace input file (specified with --file)") + print( + "Use --in-place instead of --save if you want to replace input file (specified with --file)" + ) sys.exit(1) if os.path.exists(filename): - backup_filename = ".".join([filename, args.backup_id]) - shutil.copyfile(filename, backup_filename) + backup_filename = ".".join([filename, args.backup_id]) + shutil.copyfile(filename, backup_filename) outfile = open(args.save, "w") elif args.name: name_components = {} name_dir = args.name_dir if not os.path.exists(name_dir): - print("Destination directory specified (--name-dir %s) does not exist. Will not write file.") + print( + "Destination directory specified (--name-dir %s) does not exist. Will not write file." + ) sys.exit(1) for arg in args.name: - if arg not in ['id','timestamp', 'counter']: + if arg not in ["id", "timestamp", "counter"]: print("--name may only use id, counter, and timestamp (%s found)" % arg) sys.exit(1) if not argsd.get(arg, None) != None: @@ -567,7 +658,7 @@ def main(): print(argsd) sys.exit(1) if args.id != None: - name_components['id'] = args.id + name_components["id"] = args.id digits = args.digits # --counter and --id can be specified separately @@ -582,16 +673,18 @@ def main(): seq_text = str(seq) digits = max(len(seq_text), digits) pad_text = "0" * (digits - len(seq_text)) - name_components['counter'] = pad_text + seq_text + name_components["counter"] = pad_text + seq_text - name_components['timestamp'] = strftime("%Y%m%d%H%M%S") + name_components["timestamp"] = strftime("%Y%m%d%H%M%S") - name_template = args.separator.join(["%%(%s)s" % name for name in args.name]) + ".md" + name_template = ( + args.separator.join(["%%(%s)s" % name for name in args.name]) + ".md" + ) name_template = "/".join([name_dir, name_template]) filename = name_template % name_components if os.path.exists(filename): - backup_filename = ".".join([filename, args.backup_id]) - shutil.copyfile(filename, backup_filename) + backup_filename = ".".join([filename, args.backup_id]) + shutil.copyfile(filename, backup_filename) outfile = open(filename, "w") else: outfile = sys.stdout @@ -599,20 +692,23 @@ def main(): if filename: (basename, extension) = os.path.splitext(filename) else: - extension = '.yaml' + extension = ".yaml" try: yaml_repr_stripped = first_zettel.get_yaml(args.restrict_output_fields).rstrip() document = first_zettel.get_document() if len(yaml_repr_stripped) > 0: - outfile.write('\n'.join(['---', yaml_repr_stripped, '---', document.rstrip()])+'\n') + outfile.write( + "\n".join(["---", yaml_repr_stripped, "---", document.rstrip()]) + "\n" + ) else: - doc_stripped = document.rstrip() - if len(doc_stripped) > 0: - outfile.write(doc_stripped + '\n') + doc_stripped = document.rstrip() + if len(doc_stripped) > 0: + outfile.write(doc_stripped + "\n") except ParseError as error: print(error) + def gen_id(): id = 0 while True: @@ -627,8 +723,7 @@ def gen_new_zettels(args): loader = ZettelLoader(args.file) last_z = None for z in loader.getZettels(): - last_z = process_zettel_command_line_options( - z, vargs, next(id_gen)) + last_z = process_zettel_command_line_options(z, vargs, next(id_gen)) yield last_z if not last_z: yield process_zettel_command_line_options(Zettel(), vargs, next(id_gen)) @@ -643,22 +738,24 @@ def process_zettel_command_line_options(z, vargs, id): continue if arg.startswith("reset_"): - reset_what = arg[len("reset_"):] + reset_what = arg[len("reset_") :] z.reset_list_field(reset_what) if arg.startswith("delete_"): - delete_what = arg[len("delete_"):] + delete_what = arg[len("delete_") :] z.delete_field(delete_what) if arg.startswith("remove_entries_in_"): - delete_what = arg[len("remove_entries_in_"):] + delete_what = arg[len("remove_entries_in_") :] try: (zettel_id, list_entries) = vargs[arg][:2] zettel_id = int(zettel_id) list_entries = [int(pos) for pos in list_entries.split(",")] except: print( - "Non-integer zettel ID or list position found in %s. Aborting." % arg) + "Non-integer zettel ID or list position found in %s. Aborting." + % arg + ) sys.exit(1) if id == zettel_id: z.delete_list_field_entries(delete_what, list_entries) @@ -680,7 +777,7 @@ def process_zettel_command_line_options(z, vargs, id): elif arg == "set_dates": date_info = vargs[arg] year = date_info[0] - era = ','.join(date_info[1:]) + era = ",".join(date_info[1:]) if z.has_dates(): z.set_dates_year(year) z.set_dates_era(era) @@ -688,12 +785,12 @@ def process_zettel_command_line_options(z, vargs, id): z.set_dates(year, era) elif arg.startswith("set_"): - set_what = arg[len("set_"):] + set_what = arg[len("set_") :] value = vargs[arg].replace(r"\n", "\n") z.set_field(set_what, value) elif arg.startswith("prompt_"): - prompt_field = arg[len("prompt_"):] + prompt_field = arg[len("prompt_") :] lines = prompt(prompt_field) if prompt_field in ZettelStringFields: z.set_field(prompt_field, "\n".join(lines)) @@ -716,12 +813,12 @@ def process_zettel_command_line_options(z, vargs, id): z.set_citation(lines[0]) if arg.startswith("append_"): - append_what = arg[len("append_"):] + append_what = arg[len("append_") :] for text in vargs[arg]: z.append_list_field(append_what, text) if arg.startswith("load_"): - load_what = arg[len("load_"):] + load_what = arg[len("load_") :] z.load_field(load_what, vargs[arg]) return z @@ -729,20 +826,21 @@ def process_zettel_command_line_options(z, vargs, id): def get_count(counter_path, counter_name): # Create counter db if not present. if not os.path.exists(counter_path): - with open(counter_path, 'w') as dbfile: + with open(counter_path, "w") as dbfile: json.dump({}, dbfile) # Read count from counter. If non-existent, start at 0. - with open(counter_path, 'r') as dbfile: - db = json.load(dbfile) - count = db.get(counter_name, -1) + 1 + with open(counter_path, "r") as dbfile: + db = json.load(dbfile) + count = db.get(counter_name, -1) + 1 # save count for next invocation - with open(counter_path, 'w') as dbfile: - db[counter_name] = count - json.dump(db, dbfile) + with open(counter_path, "w") as dbfile: + db[counter_name] = count + json.dump(db, dbfile) return count + def dict_as_yaml(data): yaml.add_representer(quoted, quoted_presenter) yaml.add_representer(literal, str_presenter) @@ -756,5 +854,5 @@ def dict_as_yaml(data): return yaml.dump(presented_data, default_flow_style=False, Dumper=Dumper) -if __name__ == '__main__': +if __name__ == "__main__": main() diff --git a/zettelgeist/zfind.py b/zettelgeist/zfind.py index 57b08c8..3b3ef4b 100644 --- a/zettelgeist/zfind.py +++ b/zettelgeist/zfind.py @@ -1,54 +1,90 @@ import argparse import sys from time import strftime + import yaml + from . import zdb, zettel, zquery from .zutils import * -YAML_HEADER = '---' +YAML_HEADER = "---" + def get_argparse(): parser = zdb.get_argparse() for field in zdb.ZettelSQLFields: - parser.add_argument('--show-%s' % field, - action='store_const', const=True, default=False, - help="include field <%s> in output" % field) - - parser.add_argument('--show-all', - action='store_const', const=True, default=False, - help="include all fields in output") - - parser.add_argument('--publish', help="use template to publish zfind output (suppresses all --show-FIELD)", default=None) + parser.add_argument( + "--show-%s" % field, + action="store_const", + const=True, + default=False, + help="include field <%s> in output" % field, + ) - parser.add_argument('--publish-conf', help="use publish configuration file to format special fields", default=None) - - parser.add_argument('--count', action='store_const', const=True, - default=False, help="Show number of Zettels matching this search") + parser.add_argument( + "--show-all", + action="store_const", + const=True, + default=False, + help="include all fields in output", + ) parser.add_argument( - '--query-prompt', action='store_const', const=True, default=False, - help="prompt for ZQL query (overrides --query-string, --query-file))") + "--publish", + help="use template to publish zfind output (suppresses all --show-FIELD)", + default=None, + ) parser.add_argument( - '--query-file', help="load ZQL query from file (overrides --query)", default=None) + "--publish-conf", + help="use publish configuration file to format special fields", + default=None, + ) parser.add_argument( - '--query-string', - help="load ZQL from string", default=None) + "--count", + action="store_const", + const=True, + default=False, + help="Show number of Zettels matching this search", + ) parser.add_argument( - '--fileset', help="write fileset to filename", default=None) + "--query-prompt", + action="store_const", + const=True, + default=False, + help="prompt for ZQL query (overrides --query-string, --query-file))", + ) parser.add_argument( - '--stats', help="write statistics and parameters to filename", default=None) + "--query-file", + help="load ZQL query from file (overrides --query)", + default=None, + ) + + parser.add_argument("--query-string", help="load ZQL from string", default=None) + + parser.add_argument("--fileset", help="write fileset to filename", default=None) parser.add_argument( - '--get-all-tags', help="show all tags in this database (disables all other options)", action="store_true", default=False) + "--stats", help="write statistics and parameters to filename", default=None + ) parser.add_argument( - '--get-all-mentions', help="show all mentions in this database (disables all other options)", action="store_true", default=False) + "--get-all-tags", + help="show all tags in this database (disables all other options)", + action="store_true", + default=False, + ) + parser.add_argument( + "--get-all-mentions", + help="show all mentions in this database (disables all other options)", + action="store_true", + default=False, + ) return parser @@ -64,11 +100,11 @@ def main(): # TODO: Make each group of functions a function to make this more comprehensible. if args.get_all_tags: - print('\n'.join(db.get_tags_list())) + print("\n".join(db.get_tags_list())) exit(0) if args.get_all_mentions: - print('\n'.join(db.get_mentions_list())) + print("\n".join(db.get_mentions_list())) exit(0) # The --query-{prompt,file,string} options are for ZQL processing. @@ -88,7 +124,9 @@ def main(): ast = zquery.compile(input_line) gen = db.fts_query(ast[0]) else: - print("Warning: Query could not be loaded via --query, --query-file, or --query-prompt") + print( + "Warning: Query could not be loaded via --query, --query-file, or --query-prompt" + ) sys.exit(1) # This is the actual logic to find and process results. @@ -102,46 +140,46 @@ def main(): template_file = args.publish publish_conf = args.publish_conf for row in gen: - loader = zettel.ZettelLoader(row['filename']) - zettels = loader.getZettels() - z = next(zettels) - publish(row, z, template_file, publish_conf) + loader = zettel.ZettelLoader(row["filename"]) + zettels = loader.getZettels() + z = next(zettels) + publish(row, z, template_file, publish_conf) return # This is for the --show options for row in gen: search_count = search_count + 1 printed_something = False - match_filenames.append(row['filename']) - loader = zettel.ZettelLoader(row['filename']) + match_filenames.append(row["filename"]) + loader = zettel.ZettelLoader(row["filename"]) zettels = loader.getZettels() z = next(zettels) # Handle output of YAML here this_result_output = [] for field in row.keys(): - show_field = 'show_' + field - if argsd.get(show_field, None) or argsd.get('show_all'): - if field == 'filename': - filename_yaml = yaml.dump({ 'filename' : row['filename']}) - this_result_output.append(filename_yaml.rstrip()) - elif field == 'document': - continue + show_field = "show_" + field + if argsd.get(show_field, None) or argsd.get("show_all"): + if field == "filename": + filename_yaml = yaml.dump({"filename": row["filename"]}) + this_result_output.append(filename_yaml.rstrip()) + elif field == "document": + continue elif row[field]: - if z: - this_result_output.append(z.get_yaml([field]).rstrip()) - else: - this_result_output.append("%s:" % field) - this_result_output.append(row[field]) + if z: + this_result_output.append(z.get_yaml([field]).rstrip()) + else: + this_result_output.append("%s:" % field) + this_result_output.append(row[field]) # No output if just --- and --- if len(this_result_output) > 0: - print('\n'.join([YAML_HEADER] + this_result_output + [YAML_HEADER])) + print("\n".join([YAML_HEADER] + this_result_output + [YAML_HEADER])) if argsd.get("show_document"): - document = row['document'] + document = row["document"] if len(document) > 0: - print(row['document']) + print(row["document"]) print() # --count here / Should this be added to the YAML payload? I think the answer is yes. @@ -149,24 +187,27 @@ def main(): if args.count: print("%d Zettels matched search" % search_count) - # --fileset handled here / Should --fileset actually suppress the --show options? + # --fileset handled here / Should --fileset actually suppress the --show options? # It's primary purpose is to *avoid* showing output for subsequent processing, say, in a shell loop if args.fileset: if not os.path.exists(args.fileset): - write_to_file(args.fileset, "\n".join(match_filenames), mode="w", newlines=1) + write_to_file( + args.fileset, "\n".join(match_filenames), mode="w", newlines=1 + ) else: - print("Filename %s exists; will not overwrite." % args.fileset) + print("Filename %s exists; will not overwrite." % args.fileset) # --stats seems to duplicate the work of --count. yes, it goes to a file, but that would # allow for subsequent querying, say, with yq or equivalent. if args.stats: if not os.path.exists(args.stats): - doc = {'count': search_count, 'query': input_line.strip()} - write_to_file(args.stats, zettel.dict_as_yaml(doc), mode="w", newlines=1) + doc = {"count": search_count, "query": input_line.strip()} + write_to_file(args.stats, zettel.dict_as_yaml(doc), mode="w", newlines=1) else: - print("Filename %s exists; will not overwrite." % args.stats) + print("Filename %s exists; will not overwrite." % args.stats) + def publish(row, z, template_file, publish_conf): import json @@ -176,17 +217,15 @@ def publish(row, z, template_file, publish_conf): with open(publish_conf) as jsonf: formatting = json.load(jsonf) - all_vars = { k:'' for k in zettel.ZettelFields } + all_vars = {k: "" for k in zettel.ZettelFields} all_vars.update(z.zettel) - all_vars['filename'] = row['filename'] - - + all_vars["filename"] = row["filename"] tags = reformat_tags(all_vars, formatting) mentions = reformat_mentions(all_vars, formatting) cite = reformat_cite(all_vars, formatting) - reformatted_data = { 'tags' : tags, 'mentions' : mentions, 'cite' : cite } + reformatted_data = {"tags": tags, "mentions": mentions, "cite": cite} all_vars.update(reformatted_data) @@ -194,40 +233,55 @@ def publish(row, z, template_file, publish_conf): text = tf.read() print(text % all_vars) + def reformat_tags(all_vars, formatting): - tags_format = formatting.get('tags', {}) - tags = all_vars.get('tags', []) + tags_format = formatting.get("tags", {}) + tags = all_vars.get("tags", []) if len(tags) == 0: - return '' - default_tag_format = '%(tag)s' - formatted_tags = \ - [ tags_format.get('tag', default_tag_format) % { 'tag' : tag } for tag in tags ] - return tags_format.get('before','') + ''.join(formatted_tags) + tags_format.get('after','') + return "" + default_tag_format = "%(tag)s" + formatted_tags = [ + tags_format.get("tag", default_tag_format) % {"tag": tag} for tag in tags + ] + return ( + tags_format.get("before", "") + + "".join(formatted_tags) + + tags_format.get("after", "") + ) + def reformat_mentions(all_vars, formatting): - mentions_format = formatting.get('mentions', {}) - mentions = all_vars.get('mentions', []) + mentions_format = formatting.get("mentions", {}) + mentions = all_vars.get("mentions", []) if len(mentions) == 0: - return '' - default_mention_format = '%(mention)s' - formatted_mentions = \ - [ mentions_format.get('mention', default_mention_format) % { 'mention' : mention } for mention in mentions ] - return mentions_format.get('before','') + ''.join(formatted_mentions) + mentions_format.get('after','') + return "" + default_mention_format = "%(mention)s" + formatted_mentions = [ + mentions_format.get("mention", default_mention_format) % {"mention": mention} + for mention in mentions + ] + return ( + mentions_format.get("before", "") + + "".join(formatted_mentions) + + mentions_format.get("after", "") + ) + def reformat_cite(all_vars, formatting): - cite_format = formatting.get('cite', {}) + cite_format = formatting.get("cite", {}) cite = all_vars.get("cite", {}) if len(cite) == 0: - return '' + return "" if len(cite) > 0 and type(cite_format) == type({}): - cite_template = cite_format.get('before') - cite_template += cite_format.get('bibkey', '%(bibkey)s') - cite_template += cite_format.get('page', '%(page)s') - cite_template += cite_format.get('after') + cite_template = cite_format.get("before") + cite_template += cite_format.get("bibkey", "%(bibkey)s") + cite_template += cite_format.get("page", "%(page)s") + cite_template += cite_format.get("after") new_cite = cite_template % cite return new_cite else: - return '' + return "" + -if __name__ == '__main__': +if __name__ == "__main__": main() diff --git a/zettelgeist/zimport.py b/zettelgeist/zimport.py index a68f105..38c0b6f 100644 --- a/zettelgeist/zimport.py +++ b/zettelgeist/zimport.py @@ -3,41 +3,56 @@ import os import os.path import sys -import frontmatter # to accommodate Markdown with YAML frontmatter + +import frontmatter # to accommodate Markdown with YAML frontmatter +import yaml from . import zdb, zettel -import yaml try: - from yaml import CLoader as Loader, CDumper as Dumper + from yaml import CDumper as Dumper + from yaml import CLoader as Loader except ImportError: - from yaml import Loader, Dumper + from yaml import Dumper, Loader def get_zettels(dir): - for (dirpath, dirnames, filenames) in os.walk(dir): + for dirpath, dirnames, filenames in os.walk(dir): for filename in filenames: - if filename.endswith('.yaml') or filename.endswith('.md'): + if filename.endswith(".yaml") or filename.endswith(".md"): yield os.path.join(dirpath, filename) def main(): parser = zdb.get_argparse() parser.add_argument( - '--dir', help="location of Zettels (path to folder)", required=True) + "--dir", help="location of Zettels (path to folder)", required=True + ) - parser.add_argument('--fullpath', action="store_true", - help="store full path to file in index", default=False) + parser.add_argument( + "--fullpath", + action="store_true", + help="store full path to file in index", + default=False, + ) - parser.add_argument('--validate', action="store_true", - help="check Zettels only (don't import)", default=False) + parser.add_argument( + "--validate", + action="store_true", + help="check Zettels only (don't import)", + default=False, + ) - parser.add_argument('--create', action="store_true", - help="create database and delete existing if present", default=False) + parser.add_argument( + "--create", + action="store_true", + help="create database and delete existing if present", + default=False, + ) args = parser.parse_args() - if args.create or not os.path.exists(args.database): + if args.create or not os.path.exists(args.database): zcreate(args) db = zdb.get(args.database) @@ -49,9 +64,9 @@ def main(): else: filepath = entry print("Processing %s" % filepath) - if filepath.endswith('.yaml'): + if filepath.endswith(".yaml"): yaml_info = zettel.load_pure_yaml(filepath) - elif filepath.endswith('.md'): + elif filepath.endswith(".md"): yaml_info = zettel.load_markdown_with_frontmatter(filepath) else: print("Warning: %s is not .yaml or .md (ignoring)") @@ -82,5 +97,6 @@ def zcreate(args): db.create_table() db.done() -if __name__ == '__main__': + +if __name__ == "__main__": main() diff --git a/zettelgeist/zquery.py b/zettelgeist/zquery.py index 8788629..569f031 100644 --- a/zettelgeist/zquery.py +++ b/zettelgeist/zquery.py @@ -1,18 +1,18 @@ -import sys -import readline -import pprint -import json -import tatsu import argparse +import json import os.path -import tempfile import pprint +import readline +import sys +import tempfile + +import tatsu from . import zdb, zettel def unquote(text): - return text.replace('"', '').replace("'", "") + return text.replace('"', "").replace("'", "") class ZG(object): @@ -22,16 +22,18 @@ def literal(self, ast): def _get_match_clause(self, ast, negate): text = unquote(ast.text) words = text.split() - return " NEAR/1 ".join(["%s%s:%s" % (negate, ast.field, word) for word in words]) + return " NEAR/1 ".join( + ["%s%s:%s" % (negate, ast.field, word) for word in words] + ) def z_field(self, ast): - match_clause = self._get_match_clause(ast, '') + match_clause = self._get_match_clause(ast, "") return "SELECT * FROM zettels WHERE zettels MATCH '%s'" % match_clause def and_expr(self, ast): - if ast.op == '&': + if ast.op == "&": return "SELECT * from (%s INTERSECT %s)" % (ast.left, ast.right) - elif ast.op == '!': + elif ast.op == "!": return "SELECT * from (%s EXCEPT %s)" % (ast.left, ast.right) # else: parser should have caught any non-op @@ -65,12 +67,13 @@ def sql_get_matches(self): return self.select_all def get_field_query_sql(self, field, field_context, docid): - default = """SELECT docid, %(field)s FROM zettels WHERE docid = %(docid)s""" % vars( + default = ( + """SELECT docid, %(field)s FROM zettels WHERE docid = %(docid)s""" % vars() ) field_queries = self.queries.get(field, [default]).copy() for i in range(0, len(field_queries)): field_queries[i] = field_queries[i] % vars() - #print(">>> field_queries", field_queries) + # print(">>> field_queries", field_queries) return field_queries def literal(self, ast): @@ -79,30 +82,48 @@ def literal(self, ast): def _get_match_clause(self, ast, negate): text = unquote(ast.text) words = text.split() - return " NEAR/1 ".join(["%s%s:%s" % (negate, ast.field, word) for word in words]) + return " NEAR/1 ".join( + ["%s%s:%s" % (negate, ast.field, word) for word in words] + ) def z_field(self, ast): - match_clause = self._get_match_clause(ast, '') + match_clause = self._get_match_clause(ast, "") query_list = self.queries.get(ast.field, []) - field_query = "SELECT docid FROM zettels WHERE zettels MATCH '%s'" % match_clause - context_query = """SELECT docid, snippet(zettels, '[', ']', '...', -1, -%%(field_context)s) as %s, %s as %s_verbatim, offsets(zettels) as %s_offsets FROM zettels WHERE zettels MATCH '%s' AND docid = %%(docid)s""" % ( - ast.field, ast.field, ast.field, ast.field, match_clause) + field_query = ( + "SELECT docid FROM zettels WHERE zettels MATCH '%s'" % match_clause + ) + context_query = ( + """SELECT docid, snippet(zettels, '[', ']', '...', -1, -%%(field_context)s) as %s, %s as %s_verbatim, offsets(zettels) as %s_offsets FROM zettels WHERE zettels MATCH '%s' AND docid = %%(docid)s""" + % (ast.field, ast.field, ast.field, ast.field, match_clause) + ) query_list.append(context_query) self.queries[ast.field] = query_list return field_query def and_expr(self, ast): - if ast.op == '&': - return "SELECT %s from (%s INTERSECT %s)" % (self.select_fields, ast.left, ast.right) - elif ast.op == '!': - return "SELECT %s from (%s EXCEPT %s)" % (self.select_fields, ast.left, ast.right) + if ast.op == "&": + return "SELECT %s from (%s INTERSECT %s)" % ( + self.select_fields, + ast.left, + ast.right, + ) + elif ast.op == "!": + return "SELECT %s from (%s EXCEPT %s)" % ( + self.select_fields, + ast.left, + ast.right, + ) # else: parser should have caught any non-op def and_op(self, ast): return ast.op def or_expr(self, ast): - return "SELECT %s from (%s UNION %s)" % (self.select_fields, ast.left, ast.right) + return "SELECT %s from (%s UNION %s)" % ( + self.select_fields, + ast.left, + ast.right, + ) def compile(input_line): diff --git a/zettelgeist/zversion.py b/zettelgeist/zversion.py index 3360df6..548af7a 100644 --- a/zettelgeist/zversion.py +++ b/zettelgeist/zversion.py @@ -4,5 +4,6 @@ __version__ = "1.1.5" + def version(): return __version__