From 8453c268f55ef7cfbc2fe6a6bc5c8ca7a67c8880 Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Thu, 1 Oct 2020 23:04:58 +0200 Subject: Moved misc docs to sphinx --- docs/source/moving_data_between_collections.rst | 41 +++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 docs/source/moving_data_between_collections.rst (limited to 'docs/source/moving_data_between_collections.rst') diff --git a/docs/source/moving_data_between_collections.rst b/docs/source/moving_data_between_collections.rst new file mode 100644 index 0000000..23c693e --- /dev/null +++ b/docs/source/moving_data_between_collections.rst @@ -0,0 +1,41 @@ +******************************* +Moving Data between Collections +******************************* + +Entries can be exported from a lesana collection to another using the +``lesana export`` command and a jinja2 template. + +The template should generate a yaml file that is a valid lesana entry +for the destination collection and it can use the fields of the starting +collection as variables. The variable ``entry`` is also available and +gives complete access to the entry of the original collection, so fields +with names that aren't valid jinja templates can be accessed as +``entry.data[]``. + +E.g. to convert between a collection with fields ``name``, +``short-desc``, ``desc`` to a collection with fields ``name``, +``description`` one could use the following template:: + + name: {{ name }} + description: | + {{ entry.data.[short-desc] }} + + {{ desc | indent(width=4, first=False) }} + +From the origin collection you can then run the command:: + + lesana export + +to export all entries. + +You can also export just a subset of entries by adding a xapian query +with the parameter ``--query``; you can test the search using:: + + lesana search --all + +and then actually run the export with:: + + lesana search --query ''