Module tp_note::config[][src]

Collects Tp-Note’s configuration from a configuration file, the command line parameters. It also reads the clipboard.

Structs

ARGS

Structure to hold the parsed command line arguments.

Args

Tp-Note is a note-taking-tool and a template system, that consistently synchronizes the note’s meta-data with its filename. tp-note collects various information about its environment and the clipboard and stores them in variables. New notes are created by filling these variables in predefined and customizable Tera-templates. In case <path> points to an existing tp-note-file, the note’s meta-data is analysed and, if necessary, its filename is modified. For all other file types, tp-note creates a new note that annotates the file <path> points to. If <path> is a directory (or, when omitted the current working directory), a new note is created in that directory. After creation, tp-note launches an external editor of your choice. Although the note’s structure follows pandoc-conventions, it is not tied to any specific markup language.

CFG

Reads and parses the configuration file “tp-note.toml”. An alternative filename (optionally with absolute path) can be given on the command line with “–config”.

CFG_FILE_LOADING

Variable indicating with Err if the loading of the configuration file went wrong.

CLIPBOARD

Reads the clipboard, if there is any and empties it.

CONFIG_PATH

This is where the confy crate stores the configuration file.

Cfg

Configuration data, deserialized from the configuration file.

Hyperlink

Represents a hyperlink.

LAUNCH_EDITOR

Shall we launch the external text editor?

LAUNCH_VIEWER

Shall we launch the internal http server and the external browser?

RUNS_ON_CONSOLE

Do we run on a console?

STDIN

Reads the input stream stdin if there is any.

VIEWER_SERVED_MIME_TYPES_HMAP

Store the extension as key and mime type as value in HashMap.

Constants

BROWSER_ARGS

Default command line argument list when launching the web browser. The list is executed item by item until an installed web browser is found. Can be changed in config file.

CLIPBOARD_EMPTY_ENABLED

Should the clipboard be emptied when tp-note closes? Default value.

CLIPBOARD_READ_ENABLED

By default clipboard support is enabled, can be disabled in config file. A false value here will set ENABLE_EMPTY_CLIPBOARD to false.

CONFIG_FILENAME

Crate confy version 0.4 uses this filename by default.

COPY_COUNTER_CLOSING_BRACKETS

Tp-Note may add a counter at the end of the filename when it can not save a file because the name is taken already. This is the closing bracket search pattern. Some examples: "-", “‘_’”“, "_-","-_", "(" Can be empty.

COPY_COUNTER_EXTRA_SEPARATOR

If the stem of a filename ends with a pattern, that is similar to a copy counter, add this extra separator. Must be -, _ or any combination of both. Shorter looks better.

COPY_COUNTER_MAX

When a filename is taken already, Tp-Note adds a copy counter number in the range of 0..COPY_COUNTER_MAX at the end.

COPY_COUNTER_OPENING_BRACKETS

Tp-Note may add a counter at the end of the filename when it can not save a file because the name is taken already. This is the opening bracket search pattern. Some examples: "-", “‘_’”“, "_-","-_", "(" Can be empty.

CURRENT_EXE

Name of this executable (without the Windows “.exe” extension).

DEBUG_ARG_DEFAULT

Default value for command line option --debug. Determines the maximum debug level events must have, to be logged. If the command line option --debug is present, its value will be used instead.

EDITOR_ARGS

Default command line argument list when launching external editor. The editor list is executed item by item until an editor is found. Can be changed in config file.

EDITOR_ARG_DEFAULT

Default value for command line flag --edit to disable file watcher, (Markdown)-renderer, html server and a web browser launcher set to true.

EDITOR_CONSOLE_ARGS

Default command line argument list when launching an external editor and no graphical environment is available (DISPLAY=''). This lists console file editors only. The editor list is executed item by item until an editor is found. Can be changed in config file.

EXPORTER_RENDITION_TMPL

Template used to render a note into html when the rendition is saved to disk

EXTENSION_DEFAULT

File extension of to-note files.

NOTE_FILENAME_LEN_MAX

Maximum length of a note’s filename in bytes. If a filename template produces a longer string, it will be truncated.

NOTE_FILE_EXTENSIONS_HTML

The present list contains file extensions of HTML encoded Tp-Note files. For these file types their content is forwarded to the web browser without modification.

NOTE_FILE_EXTENSIONS_MD

The variables NOTE_FILE_EXTENSIONS_* list file extensions that Tp-Note considers as its own note files. Tp-Note opens these files, reads their their YAML header and launches an external file editor and an file viewer (web browser). According to the markup language used, the appropriate renderer is called to convert the note’s content into HTML. The rendered HTML is then shown to the user with his web browser.

NOTE_FILE_EXTENSIONS_NO_VIEWER

The present list contains file extensions of Tp-Note files for which no viewer is opened (unless Tp-Note is invoked with --view).

NOTE_FILE_EXTENSIONS_RST

The present list contains file extensions of RestructuredText encoded Tp-Note files.

NOTE_FILE_EXTENSIONS_TXT

The present list contains file extensions of Text encoded Tp-Note files that the viewer shows literally without (almost) any additional rendering. Only hyperlinks in Markdown, reStructuredText, Asciidoc and HTML are rendered, thus clickable.

NO_FILENAME_SYNC_ARG_DEFAULT

Default value for command line flag --no-filename-sync to disable the title to filename synchronisation mechanism permanently. If set to true, the corresponding command line flag is ignored.

POPUP_ARG_DEFAULT

Default value for command line flag --popup If the command line flag --popup or POPUP is true, all log events will also trigger the appearance of a popup alert window. Note, that error level debug events will always pop up, regardless of --popup and POPUP (unless --debug=off).

SILENTLY_IGNORE_MISSING_HEADER

Tp-Note opens all .md files with an external editor. It recognizes its own files, by the file extension .md, by a valid YAML header and the presence of a “title” variable*). When set to false, popup alert windows inform the user about missing headers. true suppresses the popup alert windows and the text editor starts without further notification. See also VIEWER_MISSING_HEADER_DISABLES.

TMPL_ANNOTATE_CONTENT

Default template used when the command line parameter points to an existing non-.md-file. Can be modified through editing the configuration file.

TMPL_ANNOTATE_FILENAME

Filename of a new note, that annotates an existing file on disk given in .

TMPL_CLIPBOARD_CONTENT

Default template used, when the clipboard or the input stream stdin contains a string and this string has no valid YAML front matter section. The clipboards content is in {{ clipboard }}, its truncated version in {{ clipboard | heading }} When the clipboard contains a hyperlink in Markdown or reStruncturedText format. See crate parse-hyperlinks for details. For example: [<link-name>](<link-url> "link-title"), can be accessed with the variables: {{ clipboard | linkname }}, {{ clipboard | linktarget }} and {{ clipboard | linkttitle }}. Trick: the expression {% if clipboard != clipboard | heading %} detects if the clipboard content has more than one line of text.

TMPL_CLIPBOARD_FILENAME

Default filename template used when the stdin ~ clipboard contains a string.

TMPL_COMPULSORY_FIELD_CONTENT

As all application logic is encoded in Tp-Note’s templates, it does not know about field names. Nevertheless it is useful to identify at least one field as the field that identifies a note the most. When TMPL_COMPULSORY_FIELD_CONTENT is not empty, Tp-Note will not synchronize the note’s filename and will pop up an error message, unless it finds the field in the note’s header. When TMPL_COMPULSORY_FIELD_CONTENT is empty, all files are synchronized without any further field check. Make sure to define a default value with fm_* | default(value=*) in case the variable fm_* does not exist in the note’s front matter.

TMPL_COPY_CONTENT

Default template used, when the clipboard or the input stream stdin contains a string and one the of these strings contains a valid YAML front matter section. The clipboards body is in {{ clipboard }}, the header is in {{ clipboard_header }}. The stdin’s body is in {{ stdin }}, the header is in {{ stdin_header }}. First all variables defined in the clipboard’s front matter are registered, the ones defined in the input stream stdin. The latter can overwrite the former. One of the front matters must define the title variable, which is then available in this template as {{ fm_title }}. When placed in YAML front matter, the filter | json_encode must be appended to each variable.

TMPL_COPY_FILENAME

Default filename template used when the stdin or the clipboard contains a string and one of them has a valid YAML header.

TMPL_NEW_CONTENT

Default content template used when the command line argument is a directory. Can be changed through editing the configuration file. The following variables are defined: {{ sanit | stem }}, {{ path | stem }}, {{ path | ext }}, {{ extension_default }} {{ file | tag }}, {{ username }}, {{ date }}, {{ lang }}, {{ dir_path }}. In addition all environment variables can be used, e.g. {{ get_env(name=\"LOGNAME\") }} When placed in YAML front matter, the filter | json_encode must be appended to each variable.

TMPL_NEW_FILENAME

Default filename template for a new note file on disk. It implements the sync criteria for note metadata in front matter and filename. Useful variables in this context are: {{ title| sanit }}, {{ subtitle| sanit }}, {{ extension_default }}, All variables also exist in a {{ <var>| sanit(alpha) }} variant: in case its value starts with a number, the string is prepended with '. The first non-numerical variable must be some {{ <var>| sanit(alpha) }} variant. Note, as this is filename template, all variables (except now and extension_default must be filtered by a sanit or sanit(alpha=true) filter.

TMPL_SYNC_FILENAME

Default filename template to test, if the filename of an existing note file on disk, corresponds to the note’s meta data stored in its front matter. If it is not the case, the note’s filename will be renamed. Can be modified through editing the configuration file.

VIEWER_ERROR_TMPL

Template used by the viewer to render error messages into html.

VIEWER_MISSING_HEADER_DISABLES

When set to true, the viewer feature is automatically disabled when Tp-Note encounters an .md file without header. Experienced users can set this to true. See also SILENTLY_IGNORE_MISSING_HEADER.

VIEWER_NOTIFY_PERIOD

How often should the file watcher check for changes? Delay in milliseconds.

VIEWER_RENDITION_TMPL

Template used by the viewer to render a note into html.

VIEWER_SERVED_MIME_TYPES

Served file types with corresponding mime types. First entry per line is the file extension, the second the corresponding mime type. Embedded files with types other than those listed here are silently ignored. Note, that image files must be located in the same directory than the note file to be served.

VIEWER_TCP_CONNECTIONS_MAX

The maximum number of TCP connections the HTTP server can handle at the same time. In general, the serving and live update of the HTML rendition of the note file, requires normally 3 TCP connections: 1 old event channel (that is still open from the previous update), 1 TCP connection to serve the HTML, the local images (and referenced documents), and 1 new event channel. In practise, stale connection are not always closed immediately. Hence 4 open connections are not uncommon.

Functions

backup_config_file