summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2018-02-10 15:47:49 +0100
committerMatthias Beyer <mail@beyermatthias.de>2018-02-10 15:47:49 +0100
commitd5b8020f08a8b61ca4b60fabe5922227f3b009bb (patch)
tree78bc13d7f817334bff8abe1afc49d7d417ca6c76
parentcb36cc8de38001ba4073077253264789698009e1 (diff)
parentaf66dc9229cdb191542ece712cd2c7b73d5a7da2 (diff)
Merge branch 'release-0.6.0'
-rw-r--r--content/blog/2017-12-12-imag-0-5-0.md4
-rw-r--r--content/blog/2018-02-10-imag-0-6-0.md153
-rw-r--r--content/doc.md5
-rw-r--r--content/doc/pdf/0.6.0.pdfbin0 -> 224366 bytes
-rw-r--r--content/doc/web/0.6.0/index.html1169
-rw-r--r--content/releases.md65
6 files changed, 1393 insertions, 3 deletions
diff --git a/content/blog/2017-12-12-imag-0-5-0.md b/content/blog/2017-12-12-imag-0-5-0.md
index 3734c59..b34a546 100644
--- a/content/blog/2017-12-12-imag-0-5-0.md
+++ b/content/blog/2017-12-12-imag-0-5-0.md
@@ -88,7 +88,7 @@ my crates.
This is really unfortunate and I hope that this bug will be fixed in future
cargo releases.
-Also, because nobody is perfect, I accidentially released `libimagnotificaion`
+Also, because nobody is perfect, I accidentially released `libimagnotification`
in 0.4.0 rather than in 0.5.0 (`libimagnotificaion` is a new crate). I yanked
the crate afterwards, but that really shows that we should harden our release
process.
@@ -107,7 +107,7 @@ is, still.
# Changelog
Finally, here again the changelog. You can also find it
-[in the repository]().
+[in the repository](http://git.imag-pim.org/imag/tree/doc/src/09020-changelog.md).
* Major changes
* `imag-counter` and `libimagcounter` was removed.
diff --git a/content/blog/2018-02-10-imag-0-6-0.md b/content/blog/2018-02-10-imag-0-6-0.md
new file mode 100644
index 0000000..044e08c
--- /dev/null
+++ b/content/blog/2018-02-10-imag-0-6-0.md
@@ -0,0 +1,153 @@
+---
+title: "imag 0.6.0"
+slug: "imag-0-6-0"
+date: "2018-02-10T13:22:06"
+tags: [ "linux", " open source", " programming", " rust", " software", " tools", " imag" ]
+---
+
+<!-- more -->
+
+**First of all (same as with the 0.5.0 release): This is not production-ready
+software. Use at your own risk! Make sure you have backups**
+
+
+# What's in there
+
+You might have noticed that there is something missing with the above warning.
+With the 0.5.0 release and prior releases, we had a note in the warning saying
+
+> There _are_ bugs. This is _not_ perfect. This is
+> alpha quality or pre-alpha quality software!
+
+And we do not have that anymore.
+
+That's because I am confident now to use imag for _my_ personal data.
+I do not necessarily recommend imag to all users, but if you want to try it,
+go ahead! With the 0.6.0 release, I will start using imag myself.
+This is a big step for me.
+
+* 204 commits
+* 46 merge-commits / 158 non-merge commits
+* 1 contributor (That was me. We need more!)
+* 363 files changed
+* 3799 insertions(+), 2211 deletions(-)
+
+Some more statistics about the codebase (thank you,
+[tokei](https://github.com/Aaronepower/tokei)), because why not:
+
+```
+-------------------------------------------------------------------------------
+ Language Files Lines Code Comments Blanks
+-------------------------------------------------------------------------------
+ CSS 1 27 24 0 3
+ Makefile 1 161 97 29 35
+ Markdown 142 3441 3441 0 0
+ Nix 2 98 77 0 21
+ Rust 277 31519 19916 6600 5003
+ Shell 12 419 235 101 83
+ TOML 55 2278 1577 272 429
+-------------------------------------------------------------------------------
+ Total 490 37943 25367 7002 5574
+-------------------------------------------------------------------------------
+```
+
+In the following sections I will explain what changed for _users_.
+For a complete list of changes (also library-wise), have a look at the
+[CHANGELOG file in the repository](http://git.imag-pim.org/imag/tree/doc/src/09020-changelog.md)
+or the changelog section below.
+
+
+# New tools
+
+* `imag-init` was introduced. Albeit only usable by direct call and not via
+ `imag init` (note the missing dash), it was introduced as simple
+ setup-script-like tool. It creates the imag store and dumps in the default
+ configuration. It also initializes a git repository, if wanted.
+* `imag-log` as a thin layer above `imag-diary`. A "log" is considered a
+ lightweight blog, like when you "dump in" single lines of text.
+* `imag-edit` as simple tool for editing contents of an imag entry (or
+ headers)
+
+
+# New features
+
+* `imag-diary` is now able to create per-second entries. This was necessary
+ for the `imag-log` tool, but was also included in the `imag-diary` command.
+* `imag-timetrack stop` (without mentioning any tags) stops all running tags
+ now
+* `imag-timetrack list` uses an ASCII-table now.
+
+
+# Bugfixes
+
+* The `imag` command prints the error message that the called subcommand filed
+ to stderr now. Was stdout before.
+* Before it was necessary to fix links by hand after moving an entry with
+ `imag mv`. This works automatically now.
+
+
+## The release process
+
+The release was done with our
+[release.sh script](http://git.imag-pim.org/imag/tree/scripts/release.sh)
+which was added for that purpose.
+
+It worked as smoothly as we expected.
+
+
+# What's coming
+
+The
+[0.7.0 milestone](https://github.com/matthiasbeyer/imag/milestone/7)
+already exists and there are a lot of things already added to it.
+
+When will I be there? The next version will be there if its ready.
+Honestly I don't know. We have a lot of things to tackle and this is growing
+to be a _really_ huge project, especially for a one-man-show, which it almost
+is, still.
+
+
+# Changelog
+
+Finally, here again the changelog. You can also find it
+[in the repository](http://git.imag-pim.org/imag/tree/doc/src/09020-changelog.md).
+
+* Major changes
+ * The config infrastructure of `libimagstore` was removed, as it was unused.
+ * The iterators of `libimagstore` were improved and are now abstract over
+ all iterator types. For example, all iterators over `StoreId` can now be
+ transformed into a `StoreGetIterator`.
+ * `imag-log` was introduced
+ * `imag-init` was introduced
+ * `libimagdiary` supports second-granularity now.
+ * `libimagstore::store::Store::retrieve_copy` was renamed to
+ `libimagstore::store::Store::get_copy`, which describes the semantics of
+ the function way better.
+ * `libimagentryutil` was introduced, a library for helpers for
+ `libimagstore::store::Entry` handling and writing extension-writing.
+ * `imag-edit` was introduced
+ * `imag-diary` got second-granularity support in the CLI.
+* Minor changes
+ * Internals were refactored from `match`ing all the things into function
+ chaining
+ * The `toml-query` dependency was updated to 0.5.0
+ * `imag-timetrack list` lists with a table now
+ * `imag-timetrack stop` now stops all running tags if none are specified
+ * The `toml-query` dependency was updated to 0.6.0
+ * `ResultExt::map_err_trace_exit()` was removed in favour of
+ `ResultExt::map_err_trace_exit_unwrap()`.
+ * `imag-view` shows content by default now. Use `-C` to hide the content.
+ * `kairos` dependency was updated to 0.1.0
+* Bugfixes
+ * `libimagbookmark` contained a type which wrapped a `FileLockEntry` from
+ `libimagstore`. This was considered a bug and was fixed.
+ * We depended on a crate which was licensed as GPLv2, which would yield imag
+ GPL as well. The dependency was removed.
+ * The `imag` crate prints the "command filed" error message to stderr now.
+ It also prefixes the subcommand with `imag-<command>` for better user
+ experience.
+ * `libimagnotes` did not set the note name in the header of the note.
+ * `imag-mv` automatically fixes links when moving an entry in the store.
+ * `imag-log` listed non-log entries (normal diary entries) before, was
+ changed to only list `log` entries.
+
diff --git a/content/doc.md b/content/doc.md
index c97263c..0f00ccc 100644
--- a/content/doc.md
+++ b/content/doc.md
@@ -3,11 +3,14 @@ title: imag - User and developer documentation
---
The imag documentation is only published for releases, whereas the
-v0.5.0
+v0.6.0
is the latest release for which documentation is published.
The source-documentation is not included (yet).
+* v0.6.0
+ * [pdf](/doc/pdf/0.6.0.pdf)
+ * [html](/doc/web/0.6.0/)
* v0.5.0
* [pdf](/doc/pdf/0.5.0.pdf)
* [html](/doc/web/0.5.0/)
diff --git a/content/doc/pdf/0.6.0.pdf b/content/doc/pdf/0.6.0.pdf
new file mode 100644
index 0000000..c2041fb
--- /dev/null
+++ b/content/doc/pdf/0.6.0.pdf
Binary files differ
diff --git a/content/doc/web/0.6.0/index.html b/content/doc/web/0.6.0/index.html
new file mode 100644
index 0000000..2237e47
--- /dev/null
+++ b/content/doc/web/0.6.0/index.html
@@ -0,0 +1,1169 @@
+<!DOCTYPE html>
+<html lang="de">
+<head>
+ <meta charset="utf-8">
+ <meta name="generator" content="pandoc">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
+
+ <meta name="dcterms.date" content="February 2018">
+
+ <title>imag User Documentation</title>
+ <style type="text/css">code{white-space: pre;}</style>
+ <!--[if lt IE 9]>
+ <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
+ <![endif]-->
+
+ <style type="text/css">
+ a.sourceLine { display: inline-block; line-height: 1.25; }
+ a.sourceLine { pointer-events: none; color: inherit; text-decoration: inherit; }
+ a.sourceLine:empty { height: 1.2em; position: absolute; }
+ .sourceCode { overflow: visible; }
+ code.sourceCode { white-space: pre; position: relative; }
+ div.sourceCode { margin: 1em 0; }
+ pre.sourceCode { margin: 0; }
+ @media screen {
+ div.sourceCode { overflow: auto; }
+ }
+ @media print {
+ code.sourceCode { white-space: pre-wrap; }
+ a.sourceLine { text-indent: -1em; padding-left: 1em; }
+ }
+ pre.numberSource a.sourceLine
+ { position: relative; }
+ pre.numberSource a.sourceLine:empty
+ { position: absolute; }
+ pre.numberSource a.sourceLine::before
+ { content: attr(data-line-number);
+ position: absolute; left: -5em; text-align: right; vertical-align: baseline;
+ border: none; pointer-events: all;
+ -webkit-touch-callout: none; -webkit-user-select: none;
+ -khtml-user-select: none; -moz-user-select: none;
+ -ms-user-select: none; user-select: none;
+ padding: 0 4px; width: 4em;
+ color: #aaaaaa;
+ }
+ pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
+ div.sourceCode
+ { }
+ @media screen {
+ a.sourceLine::before { text-decoration: underline; }
+ }
+ code span.al { color: #ff0000; font-weight: bold; } /* Alert */
+ code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
+ code span.at { color: #7d9029; } /* Attribute */
+ code span.bn { color: #40a070; } /* BaseN */
+ code span.bu { } /* BuiltIn */
+ code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
+ code span.ch { color: #4070a0; } /* Char */
+ code span.cn { color: #880000; } /* Constant */
+ code span.co { color: #60a0b0; font-style: italic; } /* Comment */
+ code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
+ code span.do { color: #ba2121; font-style: italic; } /* Documentation */
+ code span.dt { color: #902000; } /* DataType */
+ code span.dv { color: #40a070; } /* DecVal */
+ code span.er { color: #ff0000; font-weight: bold; } /* Error */
+ code span.ex { } /* Extension */
+ code span.fl { color: #40a070; } /* Float */
+ code span.fu { color: #06287e; } /* Function */
+ code span.im { } /* Import */
+ code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
+ code span.kw { color: #007020; font-weight: bold; } /* Keyword */
+ code span.op { color: #666666; } /* Operator */
+ code span.ot { color: #007020; } /* Other */
+ code span.pp { color: #bc7a00; } /* Preprocessor */
+ code span.sc { color: #4070a0; } /* SpecialChar */
+ code span.ss { color: #bb6688; } /* SpecialString */
+ code span.st { color: #4070a0; } /* String */
+ code span.va { color: #19177c; } /* Variable */
+ code span.vs { color: #4070a0; } /* VerbatimString */
+ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
+ </style>
+
+ <link rel="stylesheet" href="/home/m/archive/development/rust/imag/doc/templates/css/table.css">
+
+</head>
+ <body style="margin-left: 20%; margin-right: 20%;">
+ <header>
+ <h1 class="title">imag User Documentation</h1>
+ <small class="date">February 2018</small>
+
+ <small class="date">Version: 0.6.0</small>
+ </header>
+ <hr />
+
+ <h1 id="sec:introduction">Introduction</h1>
+ <p>This document is the user documentation for imag, the personal information management suite for the commandline. Besides being a documentation, it serves also as “roadmap” where this project should go.</p>
+ <p><strong>Basically: This is Hobby stuff. Expect incompleteness, false statements and generally read with big grain of salt.</strong></p>
+ <p>If you have any objections, suggestions for improvements, bugs, etc, please file them. A way to reach out to the imag project maintainer(s) is described in the CONTRIBUTING file of the repository or in this document, in the appropriate section.</p>
+ <h2 id="sec:intro:problem">The Problem</h2>
+ <p>The problem this project tries to solve is to provide a modular commandline application for personal information management.</p>
+ <p>It targets “power users” or “commandline users”, uses plain text as a storage format and tries to be scriptable. imag offers the ability to link data from different “PIM aspects” (such as “diary” and “bookmark” for example).</p>
+ <p>One major goal of imag is to make the PIM data traverseable and queryable. For example: a wiki article can be linked to an appointment which is linked to a todo which is linked to a note which is linked to a contact.</p>
+ <p>imag wants to offer an all-in-one scriptable modular commandline personal information management suite for all PIM aspects one can think of. Because imag uses plain text (TOML headers for structured data and plain text which can be rendered using markdown, for example, for continuous text) the user is always able to access their data without the imag tools at hand.</p>
+ <h2 id="sec:intro:approach">The Approach</h2>
+ <p>The approach “imag” takes on solving this problem is to store content in a “store” and persisting content in a unified way. Meta-information is attached to the content which can be used to store structured data. This can be used to implement a variety of “domain modules” using the store. While content is stored in <em>one</em> place, imag does not duplicate content. imag does not copy or move icalendar files, emails, vcard files, music or movies to the store, but creates references to the actual files and stores meta-information in the store.</p>
+ <p>Detailed explanation on this approach follows in the chapters of this work.</p>
+ <h2 id="sec:intro:implementation">Implementation</h2>
+ <p>The program is written in the Rust programming language.</p>
+ <p>The program consists of libraries which can be re-used by other projects to implement and adapt imag functionality. An external program may use a library of the imag distribution to store content in the store of imag and make it visible to imag this way.</p>
+ <p>This is a technical detail a user does not necessarily need to know, but as imag is intended for power-users anyways, we could say it fits here.</p>
+ <h2 id="sec:intro:alternatives">Alternative Projects</h2>
+ <p>imag is not the only project which tries to solve that particular problem. For example there is <a href="https://orgmode.org">org mode</a> for the <a href="https://www.gnu.org/software/emacs/">emacs</a> text editor. There is also <a href="http://zim-wiki.org/">zim</a>, a desktop wiki editor which is intended to be used for a personal wiki.</p>
+ <p>The difference between imag and the mentioned projects is that imag is not there yet. Some parts can be used, though it is far away from being feature-complete.</p>
+ <h1 id="architecture-of-the-imag-code">Architecture of the imag code</h1>
+ <p>The imag codebase has a rather simple overall architecture. In this chapter the types of crates, architecture of an imag module and the type structure are described.</p>
+ <h2 id="crate-types">Crate types</h2>
+ <p>There are different types of crates in the imag world. A crate is a rust project.</p>
+ <p>First of all, there are core crates. These crates provide the very core of imag and almost all other crates use them:</p>
+ <ul>
+ <li>libimagstore - The imag store is the abstraction over the filesystem. It provides primitives to get, write and manipulate store entries and their header information.</li>
+ <li>libimagrt - The runtime library, which provides functionality to create a store object from libimagstore, helps with configurarion loading and commandline argument handling (through the external “clap” crate).</li>
+ <li>libimagerror - Error handling library for handling errors the imag way. Used in all other crates, even the store itself. It also offers functionality to log and trace errors as well as exiting the application, if necessary.</li>
+ <li>libimagutil - Utilities.</li>
+ </ul>
+ <p>The next type of imag crates are entry extension libraries. Those provide extensional functionality for the types from libimagstore. For example, there is “libimagentrylink” which provides functionality to link two entries in the store.</p>
+ <p>The third kind of crate is the one that offers end-user functionality for a imag domain, for example “libimagtodo” provides functionality to track todos.</p>
+ <p>And last, but not least, the commandline frontend crates provide the user interface. These are the kind of crates that are not library crates, but binaries.</p>
+ <p>Besides these, there are some other utility crates.</p>
+ <h2 id="architecture-of-an-imag-module">Architecture of an imag module</h2>
+ <p>With the things from above, a module could have the following architecture:</p>
+ <pre><code>+---------------------------------------------+
+ | imag-foo |
+ +-----------------------------------+---------+
+ | libimagfoo | |
+ +-----------------+-----------------+ |
+ | | | |
+ | libimagentrybar | libimagentrybaz | |
+ | | | lib |
+ +-----------------+-----------------+ |
+ | | |
+ | ... | |
+ | | imag |
+ +-----------------------------------+ |
+ | | |
+ | libimagrt | |
+ | | error |
+ +-----------------------------------+ |
+ | | |
+ | libimagstore | |
+ | | |
+ +-----------------------------------+---------+</code></pre>
+ <p>The foundation of all imag modules is the store, as one can see in the visualization from above. Above the store library there is the libimagrt, which provides the basic runtime and access to the <code>Store</code> object. Cross-cutting, there is the error library (and possibly the util library, but we do not care about this one here), which is used through all levels. The highest level of all imag modules is the commandline interface on top of the domain library. In between can be any number of entry extension libraries, or none if not needed.</p>
+ <p>Theoretically, the commandline interface crate could be replaced to build a terminal user interface, graphical user interface or web interface.</p>
+ <h2 id="types">Types</h2>
+ <p>The imag core, hence the libimagstore, libimagrt and libimagerror, provide a set of types that a user (as in a library writer) should be aware of.</p>
+ <p>First of all, there is the <code>Runtime</code> type which is provided by the libimagrt. It provides basic access to whether debugging or verbosity is enabled as well as the most important core object: The <code>Store</code>.</p>
+ <p>The <code>Store</code> type is provided by the libimagstore library, the heart of everything.</p>
+ <p>When interacting with the store, two types are visible: <code>FileLockEntry</code> and <code>Entry</code> whereas the former derefs to the latter, which basically means that the former wraps the latter. The <code>FileLockEntry</code> is a necessary wrapper for ensuring that when working concurrently with the store, an entry is only <em>borrowed</em> once from the store. It also ensures that the object is alive as long as the store is.</p>
+ <p>The <code>Entry</code> type provides functionality like reading the actual content, its header and so on. Extensions for its functionality are implemented on this type, not on the <code>FileLockEntry</code>.</p>
+ <p>The <code>Entry</code> provides access to its header, which is a <code>toml::Value</code>, where toml is the toml-rs crate (external project). Convenience functionality is provided via the <code>toml-query</code> crate, which is an external project which was initiated and extracted from the imag project.</p>
+ <p>Error types are also important. All errors in imag projects should be created with <code>error-chain</code>. libimagerror provides functionality to enhance the experience with <code>Result</code> types and general tracing of errors.</p>
+ <h1 id="sec:thestore">The Store</h1>
+ <p>The store is where all the good things happen. The store is basically just a directory on the filesystem imag manages and keeps its state in.</p>
+ <p>One could say that the store is simply a database, and it really is. We opted to go for plain text, though, as we believe that plain text is the only sane way to do such a thing, especially because the amount of data which is to be expected in this domain is in the lower Megabytes range and even if it is <em>really</em> much won’t exceed the Gigabytes ever.</p>
+ <p>Having a storage format which is plain-text based is the superior approach, as text editors will always be there.</p>
+ <p>A user should always be able to read her data without great effort and putting everything in a <em>real</em> database like sqlite or even postgresql would need a user to install additional software just to read his own data. We don’t want that. Text is readable until the worlds end and we think it is therefore better to store the data in plain text.</p>
+ <p>The following sections describe the store and the file format we use to store data. One may skip the following sections, they are included for users who want to dig into the store with their editors.</p>
+ <h2 id="sec:thestore:fileformat">File Format</h2>
+ <p>The contents of the store are encoded in UTF-8. A normal text editor (like <code>vim</code> or the other one) will always be sufficient to dig into the store and modify files. For simple viewing even a pager (like <code>less</code>) is sufficient.</p>
+ <p>Each entry in the store consists of two parts:</p>
+ <ol type="1">
+ <li>Header</li>
+ <li>Content</li>
+ </ol>
+ <p>The following section describe their purpose.</p>
+ <h3 id="sec:thestore:fileformat:header">Header Format</h3>
+ <p>The header format is where imag stores its data. The header is an area at the top of every file which is seperated from the content part by three dashes (<code>---</code>). Between these three dashes there is structured data. imag uses <code>TOML</code> as data format for this structured data, because it fits best and the available <code>TOML</code> parser for the rust programming language is really good.</p>
+ <p>The header can contain any amount of data, but modules (see Section 5) are restricted in their way of altering the data.</p>
+ <p>So normally there are several sections in the header. One section (<code>[imag]</code>) is always present. It contains a <code>version</code> field, which tells imag which version this file was created with.</p>
+ <p>Other sections are named like the modules which created them. Every module is allowed to store arbitrary data under its own section and a module may never read other sections than its own.</p>
+ <p>These conventions are not enforced by imag itself, though.</p>
+ <h3 id="sec:thestore:fileformat:content">Content Format</h3>
+ <p>The content is the part of the file where the user is free to enter any textual content. The content may be rendered as Markdown or other markup format for the users convenience. The store does never expect and specific markup and actually the markup implementation is not inside the very core of imag.</p>
+ <p>Technically it would be possible that the content part of a file is used to store binary data. We don’t want this, though, as it is contrary to the goals of imag.</p>
+ <h3 id="sec:thestore:fileformat:example">Example</h3>
+ <p>An example for a file in the store follows.</p>
+ <pre class="text"><code>
+ ---
+ [imag]
+ version = &quot;0.6.0&quot;
+
+ [note]
+ name = &quot;foo&quot;
+
+ [link]
+ internal = [&quot;some/other/imag/entry&quot;]
+ ---
+
+ This is an example text, written by the user.
+ </code></pre>
+ <h2 id="sec:thestore:fileorganization">File organization</h2>
+ <p>The “Entries” are stored as files in the “Store”, which is a directory the user has access to. The store may exist in the users Home-directory or any other directory the user has read-write-access to.</p>
+ <p>Each module stores its data in an own subdirectory in the store. This is because we like to keep things ordered and clean, not because it is technically necessary.</p>
+ <p>We name the path to a file in the store “Store id” or “Storepath” and we often refer to it by using the store location as root. So if the store exists in <code>/home/user/store/</code>, a file with the storepath <code>/example.file</code> is (on the filesystem) located at <code>/home/user/store/example.file</code>.</p>
+ <p>By convention, each <code>libimagentry&lt;name&gt;</code> and <code>libimag&lt;name&gt;</code> module stores its entries in in <code>/&lt;name&gt;/</code>.</p>
+ <p>So, the pattern for the storepath is</p>
+ <pre><code>/&lt;module name&gt;/&lt;optional sub-folders&gt;/&lt;file name&gt;</code></pre>
+ <p>Any number of subdirectories may be used, so creating folder hierarchies is possible and valid. A file “example” for a module “module” could be stored in sub-folders like this:</p>
+ <pre><code>/module/some/sub/folder/example</code></pre>
+ <h2 id="sec:thestore:backends">Backends</h2>
+ <p>The store itself also has a backend. This backend is the “filesystem abstraction” code.</p>
+ <p>Note: This is a very core thing. Casual users might want to skip this section.</p>
+ <h3 id="sec:thestore:backends:problem">Problem</h3>
+ <p>First, we had a compiletime backend for the store. This means that the actual filesystem operations were compiled into the store either as real filesystem operations (in a normal debug or release build) but as a in-memory variant in the ‘test’ case. So tests did not hit the filesystem when running. This gave us us the possibility to run tests concurrently with multiple stores that did not interfere with each other.</p>
+ <p>This approach worked perfectly well until we started to test not the store itself but crates that depend on the store implementation. When running tests in a crate that depends on the store, the store itself was compiled with the filesystem-hitting-backend. This was problematic, as tests could not be implemented without hitting the filesystem and mess up other currently-running tests.</p>
+ <p>Hence we implemented store backends.</p>
+ <h3 id="sec:thestore:backends:implementation">Implementation</h3>
+ <p>The filesystem is abstracted via a trait <code>FileAbstraction</code> which contains the essential functions for working with the filesystem.</p>
+ <p>Two implementations are provided in the code:</p>
+ <ul>
+ <li>FSFileAbstraction</li>
+ <li>InMemoryFileAbstraction</li>
+ </ul>
+ <p>whereas the first actually works with the filesystem and the latter works with an in-memory HashMap that is used as filesystem.</p>
+ <p>Further, the trait <code>FileAbstractionInstance</code> was introduced for functions which are executed on actual instances of content from the filesystem, which was previousely tied into the general abstraction mechanism.</p>
+ <p>So, the <code>FileAbstraction</code> trait is for working with the filesystem, the <code>FileAbstractionInstance</code> trait is for working with instances of content from the filesystem (speak: actual Files).</p>
+ <p>In case of the <code>FSFileAbstractionInstance</code>, which is the implementation of the <code>FileAbstractionInstance</code> for the actual filesystem-hitting code, the underlying resource is managed like with the old code before. The <code>InMemoryFileAbstractionInstance</code> implementation is corrosponding to the <code>InMemoryFileAbstraction</code> implementation - for the in-memory “filesystem”.</p>
+ <h2 id="sec:thestore:backends:stdio">The StdIo backend</h2>
+ <p>Sidenote: The name is “StdIo” because its main purpose is Stdin/Stdio, but it is abstracted over Read/Write actually, so it is also possible to use this backend in other ways, too.</p>
+ <h3 id="sec:thestore:backends:stdio:why">Why?</h3>
+ <p>This is a backend for the imag store which is created from stdin, by piping contents into the store (via JSON or TOML) and piping the store contents (as JSON or TOML) to stdout when the backend is destructed.</p>
+ <p>This is one of some components which make command-chaining in imag possible. With this, the application does not have to know whether the store actually lives on the filesystem or just “in memory”.</p>
+ <h3 id="sec:thestore:backends:stdio:mappers">Mappers</h3>
+ <p>The backend contains a “Mapper” which defines how the contents get mapped into the in-memory store representation: A JSON implementation or a TOML implementation are possible.</p>
+ <p>The following section assumes a JSON mapper.</p>
+ <p>The mapper reads the JSON, parses it and translates it to a <code>Entry</code>. Then, the entry is made available to the store codebase. To summarize what we do right now, lets have a look at the awesome ascii-art below:</p>
+ <pre><code> libimag*
+ |
+ v
+ IO Mapper Store Mapper IO
+ +--+---------+----------------+--------+--+
+ | | | | | |
+ JSON -&gt; Entry -&gt; JSON</code></pre>
+ <p>This is what gets translated where for one imag call with a stdio store backend.</p>
+ <h3 id="sec:thestore:backends:stdio:json">The JSON Mapper</h3>
+ <p>The JSON mapper maps JSON which is read from a source into a HashMap which represents the in-memory filesystem.</p>
+ <p>The strucure is as follows:</p>
+ <div class="sourceCode" id="cb6"><pre class="sourceCode json"><code class="sourceCode json"><a class="sourceLine" id="cb6-1" data-line-number="1"><span class="fu">{</span></a>
+ <a class="sourceLine" id="cb6-2" data-line-number="2"> <span class="dt">&quot;version&quot;</span><span class="fu">:</span> <span class="st">&quot;0.6.0&quot;</span><span class="fu">,</span></a>
+ <a class="sourceLine" id="cb6-3" data-line-number="3"> <span class="dt">&quot;store&quot;</span><span class="fu">:</span> <span class="fu">{</span></a>
+ <a class="sourceLine" id="cb6-4" data-line-number="4"> <span class="dt">&quot;example&quot;</span><span class="fu">:</span> <span class="fu">{</span></a>
+ <a class="sourceLine" id="cb6-5" data-line-number="5"> <span class="dt">&quot;header&quot;</span><span class="fu">:</span> <span class="fu">{</span></a>
+ <a class="sourceLine" id="cb6-6" data-line-number="6"> <span class="dt">&quot;imag&quot;</span><span class="fu">:</span> <span class="fu">{</span></a>
+ <a class="sourceLine" id="cb6-7" data-line-number="7"> <span class="dt">&quot;version&quot;</span><span class="fu">:</span> <span class="st">&quot;0.6.0&quot;</span><span class="fu">,</span></a>
+ <a class="sourceLine" id="cb6-8" data-line-number="8"> <span class="fu">},</span></a>
+ <a class="sourceLine" id="cb6-9" data-line-number="9"> <span class="fu">},</span></a>
+ <a class="sourceLine" id="cb6-10" data-line-number="10"> <span class="dt">&quot;content&quot;</span><span class="fu">:</span> <span class="st">&quot;hi there!&quot;</span><span class="fu">,</span></a>
+ <a class="sourceLine" id="cb6-11" data-line-number="11"> <span class="fu">},</span></a>
+ <a class="sourceLine" id="cb6-12" data-line-number="12"> <span class="fu">},</span></a>
+ <a class="sourceLine" id="cb6-13" data-line-number="13"><span class="fu">}</span></a></code></pre></div>
+ <h3 id="sec:thestore:backends:todo">TODO</h3>
+ <p>If you look at the version history of this file you will see that this implementation has grown from something complex and probably slow to what we have today.</p>
+ <p>Still, there’s one improvement we could make: abstract all the things away so the <code>libimag*</code> crates handle the header without knowing whether it is JSON or TOML. With this, we would not even have to translate JSON to TOML anymore. We should measure whether this would have actually any performance impact before implementing it.</p>
+ <h2 id="sec:thestore:linking">Linking from an store entry</h2>
+ <p>As described in Section 1.1 the purpose of imag is to <em>link</em> content together. The following section describes, from a technical view, how this is done in imag.</p>
+ <p>There are two ways of linking in imag. You can either link internally or externally. The following sections describe the differences.</p>
+ <h3 id="sec:thestore:linking:internal">Linking to internal content</h3>
+ <p>Internal links are links between store entries themselfes. This means that one store entry can link to another. Actually, links are not pointers but rather tries between entries, meaning that an link is not directed, but always a two-way pointer.</p>
+ <p>How linking works from the user interface is described in Section 5.19.</p>
+ <h3 id="sec:thestore:linking:external">Linking to external content</h3>
+ <p>Linking to external content means linking to files or directories which do not live inside the store itself but outside of it.</p>
+ <p>Each store entry can store <em>one link to external content at most</em>.</p>
+ <p>External linking should not be used from the user interface but rather the <code>ref</code> feature (Section 5.31) should be used. Section 5.31 describes why that is.</p>
+ <h1 id="conventions-best-practices">Conventions, best practices</h1>
+ <p>This section goes about best practices in the imag codebase. It is mainly focused on developers, but a user may read it for getting to know how imag works.</p>
+ <p>Lets work our way up from the store and how to extend it to the commandline user interface.</p>
+ <h2 id="versioning">Versioning</h2>
+ <p>All imag crates are versioned with the same version number until we reach some <code>&quot;1.0.0&quot;</code> version. This means that all imag tools are only tested for compatibility with libraries and such if their version numbers match. It might not be possible to import one imag library in version 0.3.0 and another one in 0.4.0 and make them work together. It also means that if new tools are introduced into the imag codebase, they might start with their first version not at 0.1.0 but at something like 0.5.0.</p>
+ <h2 id="store-and-entry-functionality">Store and Entry functionality</h2>
+ <p>A <code>Entry</code> does not offer much functionality by itself. So its the job of libraries to <em>extend</em> its functionality. This should never be done by wrapping the <code>Entry</code> type itself but by providing and implementing an extension trait on it.</p>
+ <p>Same goes for extending the <code>Store</code> type: never wrap it, always provide an extension trait for it.</p>
+ <p>These two rules ensure that the type does not lose any functionality from a wrapping. <code>Deref</code> could do that, but not over muliple levels, so extension traits it is. It also most likely results in functions inside the extension trait which all return a <code>Result&lt;_, _&gt;</code>.</p>
+ <h2 id="libraries">Libraries</h2>
+ <p>In the next few sections, conventions and best practices for writing a imag library are written down.</p>
+ <p>A developer of imag should read this carefully, a user may skip this section or cross-read it for better understanding of the imag project.</p>
+ <h3 id="library-naming">Library naming</h3>
+ <p>Libraries which provide functionality for entries or the store (most likely entries or both) should be named “libimagentrything” whereas “thing” stands for what the library provides.</p>
+ <p>All other libraries should be prefixed with “libimag” at least. Most likely, one will not write such a library but rather a “libimagentrything” library.</p>
+ <h3 id="library-scope">Library scope</h3>
+ <p>A library should never introduce utility functionality which could be useful for other libraries as well. If there is no such functionality available, the “libimagutil” might be a place where such a function would be put, or, if not yet available, a “libimagentryutil” could be created.</p>
+ <p>If a library has to introduce free functions in its public interface, one should think hard whether this is really necessary.</p>
+ <h3 id="library-error-typeskinds">Library error types/kinds</h3>
+ <p>Libraries must use the “libimagerror” tools to create error types and kinds. Most likely, a library needs some kinds for wrapping the errors from underlying libraries, such as the store itself.</p>
+ <p>A library must <em>never</em> introduce multiple error types, but is free to introduce as many error kinds as required. Indeed, more kinds is better than fewer.</p>
+ <h3 id="libraries-with-commandline-frontends">Libraries with commandline frontends</h3>
+ <p>Libraries with commandline frontends provide end-user functionality. Normally, they depend on one or more “libimagentrything” libraries. They should be named “libimagthing”, though. For example: “libimagdiary”, “libimagtimetrack” or “libimagwiki”, whereas the commandline frontends would be “imag-diary”, “imag-timetrack” and “imag-wiki”, respectively.</p>
+ <p>If such a library needs to depend on another “libimagthing”, for example if “libimagdiary” needs to depend on “libimagnote”, one should think about this and whether the functionality could be outsourced to a more general “libimagentrything”. It is not forbidden, though.</p>
+ <p>A library which implements a functionality for imag may contain helper functions for commandline stuff, but that is discouraged.</p>
+ <h3 id="library-testing">Library testing</h3>
+ <p>All libraries should be tested as much as possible. Sometimes it may not be possible without a lot of effort, but still: more tests = better!</p>
+ <h2 id="commandline-tools">Commandline tools</h2>
+ <p>The next few sections describe how the commandline frontends are implemented. Each imag functionality (or module) has its own library and a commandline frontend for it.</p>
+ <p>The commandline frontends do contain little to no functionality. They simply translate the commandline parameters and options to calls to the appropriate library functions.</p>
+ <h2 id="commandline-tool-testing">Commandline tool testing</h2>
+ <h2 id="commandline-interface">Commandline interface</h2>
+ <h1 id="sec:modules">Modules</h1>
+ <p>A module is a functionality of the program. There is a huge list of modules available in the imag core distribution.</p>
+ <p>From a naming perspective, we do not differ between low-level and high-level modules. Some of the modules shipped with imag cover core functionality such as link