ateto


Nameateto JSON
Version 0.2.1 PyPI version JSON
download
home_pagehttps://codeberg.org/bisam/ateto
SummaryThis is a set of tools to write templates outside of Anki.
upload_time2023-02-11 14:09:41
maintainer
docs_urlNone
authorbisam
requires_python>=3.10,<4.0
license
keywords anki templates
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Ateto : Anki templates tools
============================

`ateto` is a set of tools to write templates outside of Anki.

Why ?
-----

It's a collection of scripts I try to reorganize. It started with the Anki
addon called `Templates Import / Export
<https://ankiweb.net/shared/info/712027367>`_, a python tool, `Anki Template
Tester <https://github.com/klieret/anki-template-tester>`_ and now ... look at
this ! Yes, the name is not much creative.

In short, it can :

* **export models templates** (HTML and CSS) from Anki to
  files (inside `$XDG_DATA_HOME/ateto`)
* take some note as samples from Anki and **test the templates**
  with them (producing a file like `html_output/Basic.html`)
* **import** models templates and some shared medias (like `_base.css`)
  to Anki

From the command line, with something like this::

  ateto sync # export from anki
  ateto compile # write test templates files
  ateto sync -i # import in anki

There is also a shorthand command called ``ateto`` and a "watcher". It's useful
to compile test templates at each modification::

  ateto watch

Installation
------------

This should work::

  python -m pip install ateto

Requirements
~~~~~~~~~~~~

Right now it depends on the `AnkiConnect
<https://ankiweb.net/shared/info/2055492159>`_ Anki addon and
anki-templates-tester that I put inside this project to keep things simple.

Default working directory
-------------------------

The default working directory is `$XDG_DATA_HOME/ateto` (something like
`~/.local/share/ateto`). The templates of each Anki "note type" (or "model")
are stored in `models_export`.

Simple how to
-------------

Sync templates with Anki
~~~~~~~~~~~~~~~~~~~~~~~~

First, while Anki is running, we need to export models templates with
AnkiConnect::

  ateto sync

If we change some files in `models_export`, we can import them in Anki with::

  ateto sync -i

Compile test templates
~~~~~~~~~~~~~~~~~~~~~~

We need to get some sample data from Anki and then compile templates. But
first, open Anki and tag some notes with `template_test_data`::

  ateto populate
  ateto compile

Images and CSS or JS assets
~~~~~~~~~~~~~~~~~~~~~~~~~~~

If there is missing images run::

  ateto link

All files under the `models_export/_medias` directory will be linked in
`html_output` with `compile -m`::

  ateto compile -m

But you have to create them first.

Supertemplates
~~~~~~~~~~~~~~

`models_export` contains template export of Anki notes templates. It's basic
HTML. There is "supertemplates" : it's Jinja2 templates that we can use to
generate the models, they are in `supertemplates` folder.

To build the supertemplates use `-s` option with `compile`::

  ateto compile -s

HTML and CSS files in supertemplates are processed, then `models_export` are
converted to `html_output`.

Watcher
~~~~~~~

It's my favorite part. When I'm working on some templates, I want modifications
to be automatically compiled in templates and output HTML some I use `watch`
command::

  ateto watch

And I want it all, supertemplates, medias and images. I want them to be
imported in Anki too. Images are only linked when starting, not watched ::

  ateto watch -ai

More
----

Debug mode
~~~~~~~~~~

`watch` and `compile` commands can be run with debug mode (`-d` option).
This will run supertemplates with a context where `is_debug=True`. It's
useful to debug AnkiDroid with something like this in templates files ::

  {% if is_debug %}
    <script src="https://cdn.jsdelivr.net/npm/eruda"></script>
    <script>eruda.init();</script>
  {% endif %}

File tree
~~~~~~~~~

So at the end, in `$XDG_DATA_HOME`, we have 4 main folders ::

* /supertemplates

  * ModelName/ directories

    * .jinja files
    * .html files
    * style.css file

  * _medias/ directory (optional)

    * .css files
    * .js files

* /models_export

  * ModelName/ directories

    * CardName.html files
    * style.css file

  * _medias/ directory (optional)

    * .css files
    * .js files

* /data

  * ModelName.yaml files
  * ModelName_override.yaml optional files

* /html_output

  * ModelName.html files
  * ModelName.css files
  * .css files linked from models_export/_medias
  * .js files linked from models_export/_medias
  * .png, .jpg, etc. files linked from anki_collection

The content of ``supertemplates`` is only created by hand and
compiled into ``models_export``.

All the content of ``models_export`` is synced with Anki (Ankiconnect). _medias
are treated with a special procedure.

The content of ``data`` is populated from Anki. _override.yaml files are
created by hand if necessary.

``html_output`` is the result of different actions :

* ModelName.html and ModelName.css files are the result of ``models_export``
  and ``data`` files
* others CSS or JS are linked to ``models_export/_medias``
* images are linked to the Anki collection

            

Raw data

            {
    "_id": null,
    "home_page": "https://codeberg.org/bisam/ateto",
    "name": "ateto",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "anki,templates",
    "author": "bisam",
    "author_email": "bisam@r4.re",
    "download_url": "https://files.pythonhosted.org/packages/fe/43/e90d828afc0dd69bc86bad0448617c1d3154c5cdf2567aa447797ecbc98b/ateto-0.2.1.tar.gz",
    "platform": null,
    "description": "Ateto : Anki templates tools\n============================\n\n`ateto` is a set of tools to write templates outside of Anki.\n\nWhy ?\n-----\n\nIt's a collection of scripts I try to reorganize. It started with the Anki\naddon called `Templates Import / Export\n<https://ankiweb.net/shared/info/712027367>`_, a python tool, `Anki Template\nTester <https://github.com/klieret/anki-template-tester>`_ and now ... look at\nthis ! Yes, the name is not much creative.\n\nIn short, it can :\n\n* **export models templates** (HTML and CSS) from Anki to\n  files (inside `$XDG_DATA_HOME/ateto`)\n* take some note as samples from Anki and **test the templates**\n  with them (producing a file like `html_output/Basic.html`)\n* **import** models templates and some shared medias (like `_base.css`)\n  to Anki\n\nFrom the command line, with something like this::\n\n  ateto sync # export from anki\n  ateto compile # write test templates files\n  ateto sync -i # import in anki\n\nThere is also a shorthand command called ``ateto`` and a \"watcher\". It's useful\nto compile test templates at each modification::\n\n  ateto watch\n\nInstallation\n------------\n\nThis should work::\n\n  python -m pip install ateto\n\nRequirements\n~~~~~~~~~~~~\n\nRight now it depends on the `AnkiConnect\n<https://ankiweb.net/shared/info/2055492159>`_ Anki addon and\nanki-templates-tester that I put inside this project to keep things simple.\n\nDefault working directory\n-------------------------\n\nThe default working directory is `$XDG_DATA_HOME/ateto` (something like\n`~/.local/share/ateto`). The templates of each Anki \"note type\" (or \"model\")\nare stored in `models_export`.\n\nSimple how to\n-------------\n\nSync templates with Anki\n~~~~~~~~~~~~~~~~~~~~~~~~\n\nFirst, while Anki is running, we need to export models templates with\nAnkiConnect::\n\n  ateto sync\n\nIf we change some files in `models_export`, we can import them in Anki with::\n\n  ateto sync -i\n\nCompile test templates\n~~~~~~~~~~~~~~~~~~~~~~\n\nWe need to get some sample data from Anki and then compile templates. But\nfirst, open Anki and tag some notes with `template_test_data`::\n\n  ateto populate\n  ateto compile\n\nImages and CSS or JS assets\n~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nIf there is missing images run::\n\n  ateto link\n\nAll files under the `models_export/_medias` directory will be linked in\n`html_output` with `compile -m`::\n\n  ateto compile -m\n\nBut you have to create them first.\n\nSupertemplates\n~~~~~~~~~~~~~~\n\n`models_export` contains template export of Anki notes templates. It's basic\nHTML. There is \"supertemplates\" : it's Jinja2 templates that we can use to\ngenerate the models, they are in `supertemplates` folder.\n\nTo build the supertemplates use `-s` option with `compile`::\n\n  ateto compile -s\n\nHTML and CSS files in supertemplates are processed, then `models_export` are\nconverted to `html_output`.\n\nWatcher\n~~~~~~~\n\nIt's my favorite part. When I'm working on some templates, I want modifications\nto be automatically compiled in templates and output HTML some I use `watch`\ncommand::\n\n  ateto watch\n\nAnd I want it all, supertemplates, medias and images. I want them to be\nimported in Anki too. Images are only linked when starting, not watched ::\n\n  ateto watch -ai\n\nMore\n----\n\nDebug mode\n~~~~~~~~~~\n\n`watch` and `compile` commands can be run with debug mode (`-d` option).\nThis will run supertemplates with a context where `is_debug=True`. It's\nuseful to debug AnkiDroid with something like this in templates files ::\n\n  {% if is_debug %}\n    <script src=\"https://cdn.jsdelivr.net/npm/eruda\"></script>\n    <script>eruda.init();</script>\n  {% endif %}\n\nFile tree\n~~~~~~~~~\n\nSo at the end, in `$XDG_DATA_HOME`, we have 4 main folders ::\n\n* /supertemplates\n\n  * ModelName/ directories\n\n    * .jinja files\n    * .html files\n    * style.css file\n\n  * _medias/ directory (optional)\n\n    * .css files\n    * .js files\n\n* /models_export\n\n  * ModelName/ directories\n\n    * CardName.html files\n    * style.css file\n\n  * _medias/ directory (optional)\n\n    * .css files\n    * .js files\n\n* /data\n\n  * ModelName.yaml files\n  * ModelName_override.yaml optional files\n\n* /html_output\n\n  * ModelName.html files\n  * ModelName.css files\n  * .css files linked from models_export/_medias\n  * .js files linked from models_export/_medias\n  * .png, .jpg, etc. files linked from anki_collection\n\nThe content of ``supertemplates`` is only created by hand and\ncompiled into ``models_export``.\n\nAll the content of ``models_export`` is synced with Anki (Ankiconnect). _medias\nare treated with a special procedure.\n\nThe content of ``data`` is populated from Anki. _override.yaml files are\ncreated by hand if necessary.\n\n``html_output`` is the result of different actions :\n\n* ModelName.html and ModelName.css files are the result of ``models_export``\n  and ``data`` files\n* others CSS or JS are linked to ``models_export/_medias``\n* images are linked to the Anki collection\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "This is a set of tools to write templates outside of Anki.",
    "version": "0.2.1",
    "split_keywords": [
        "anki",
        "templates"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a23a22204200b63b85f9e9af3cbe8133581f1bf815fa56b1dc9eebcff51700cf",
                "md5": "a37e493493a3ada8b3b73b7452a08b8c",
                "sha256": "8dcdf440e63c7040aacb3d64e17f27216c6697a651eaba69483209f4e2baa645"
            },
            "downloads": -1,
            "filename": "ateto-0.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a37e493493a3ada8b3b73b7452a08b8c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 17868,
            "upload_time": "2023-02-11T14:09:39",
            "upload_time_iso_8601": "2023-02-11T14:09:39.736132Z",
            "url": "https://files.pythonhosted.org/packages/a2/3a/22204200b63b85f9e9af3cbe8133581f1bf815fa56b1dc9eebcff51700cf/ateto-0.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fe43e90d828afc0dd69bc86bad0448617c1d3154c5cdf2567aa447797ecbc98b",
                "md5": "ed503a3d80d10e8f6dbb35998d688822",
                "sha256": "ddfe3ccbf0a9278e3bab2e3c0cc2e282a199dee3af79f078f721cef1a4d53117"
            },
            "downloads": -1,
            "filename": "ateto-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "ed503a3d80d10e8f6dbb35998d688822",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 16789,
            "upload_time": "2023-02-11T14:09:41",
            "upload_time_iso_8601": "2023-02-11T14:09:41.790272Z",
            "url": "https://files.pythonhosted.org/packages/fe/43/e90d828afc0dd69bc86bad0448617c1d3154c5cdf2567aa447797ecbc98b/ateto-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-02-11 14:09:41",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "ateto"
}
        
Elapsed time: 0.04616s