Module tpnote_lib::config
source · Expand description
Set configuration defaults, reads and writes Tp-Note’s configuration file
and exposes the configuration as the static variable LIB_CFG behind a
mutex. This makes it possible to modify all configuration defaults
(and templates) at runtime.
use tpnote_lib::config::LIB_CFG;
let mut lib_cfg = LIB_CFG.write();
(*lib_cfg).filename.copy_counter_extra_separator = '@'.to_string();Contract: although LIB_CFG is mutable at runtime, it is sourced only
once at the start of Tp-Note. All modification terminates before accessing
the high-level API in the workflow module of this crate.
Structs
- Configuration of filename parsing, deserialized from the configuration file.
- Global variable containing the filename and template related configuration data.
- Configuration data, deserialized from the configuration file.
- Filename templates and content templates, deserialized from the configuration file.
- Configuration for the HTML exporter feature, deserialized from the configuration file.
Enums
- Describes a set of tests, that assert template variable
tera:Valueproperties. - Defines the way the HTML exporter rewrites local links.
Constants
- When a filename is taken already, Tp-Note adds a copy counter number in the range of
0..COPY_COUNTER_MAXat the end. - This a dot by definition.
- Maximum length of a note’s filename in bytes. If a filename template produces a longer string, it will be truncated.
- The apperance of a file with this filename marks the position of
TMPL_VAR_ROOT_PATH. - A pseudo language tag for the
get_lang_filter. When placed in theTMP_FILTER_GET_LANGlist, all available languages are selected. - HTML template variable containing the note’s body. We could set
#[cfg(feature = "viewer")], but we prefer the same config file structure independent of the enabled features. - HTML template variable name. The value contains the highlighting CSS code to be included in the HTML rendition produced by the exporter.
- HTML template variable name. The value contains the path, for which the viewer delivers CSS code. Note, the viewer delivers the same CSS code which is stored as value for
TMPL_VAR_NOTE_CSS. - The constant URL for which Tp-Note’s internal web server delivers the CSS stylesheet. In HTML templates, this constant can be accessed as value of the
TMPL_VAR_NOTE_CSS_PATHvariable. - HTML template variable used in the error page containing a verbatim HTML rendition with hyperlinks of the erroneous note file. We could set
#[cfg(feature = "viewer")], but we prefer the same config file structure independent of the enabled features. - HTML template variable used in the error page containing the error message explaining why this page could not be rendered. We could set
#[cfg(feature = "viewer")], but we prefer the same config file structure independent of the enabled features. - HTML template variable containing the automatically generated JavaScript code to be included in the HTML rendition. We could set
#[cfg(feature = "viewer")], but we prefer the same config file structure independent of the enabled features. - If there is a YAML header in the clipboard content, this contains the body only. Otherwise, it contains the whole clipboard content.
- Contains the YAML header (if any) of the clipboard content. Otherwise the empty string.
- Contains the fully qualified directory path of the
<path>command line argument. If<path>points to a file, the last component (the file name) is omitted. If it points to a directory, the content of this variable is identical toTMPL_VAR_PATH, - Contains the default file extension for new note files as defined in the configuration file.
- Prefix prepended to front matter field names when a template variable is generated with the same name.
- Contains a Hash Map with all front matter fields. Lists are flattened into strings. These variables are only available in the
TMPL_FROM_TEXT_FILE_CONTENT,TMPL_SYNC_FILENAMEand HTML templates. - Contains the value of the front matter field
filename_sync. When set tofilename_sync: false, the filename synchronization mechanism is disabled for this note file. Default value istrue. - By default, the template
TMPL_SYNC_FILENAMEdefines the function of of this variable as follows: Contains the value of the front matter fieldfile_extand determines the markup language used to render the document. When the field is missing the markup language is derived from the note’s filename extension. - Contains the value of the front matter field
no_filename_sync. When set tono_filename_sync:orno_filename_sync: true, the filename synchronisation mechanism is disabled for this note file. Depreciated in favour ofTMPL_VAR_FM_FILENAME_SYNC. - By default, the template
TMPL_SYNC_FILENAMEdefines the function of of this variable as follows: If this variable is defined, the sort tag of the filename is replaced with the value of this variable next time the filename is synchronized. If not defined, the sort tag of the filename is never changed. - Contains the user’s language tag as defined in RFC 5646. Not to be confused with the UNIX
LANGenvironment variable from which this value is derived under Linux/MacOS. Under Windows, the user’s language tag is queried through the WinAPI. If defined, the environment variableTPNOTE_LANGoverwrites this value (all operating systems). - Contains the body of the file the command line option
<path>points to. Only available in theTMPL_FROM_TEXT_FILE_CONTENT,TMPL_SYNC_FILENAMEand HTML templates. - Contains the date of the file the command line option
<path>points to. The date is represented as an integer the waystd::time::SystemTimeresolves to on the platform. Only available in theTMPL_FROM_TEXT_FILE_CONTENT,TMPL_SYNC_FILENAMEand HTML templates. - All the front matter fields serialized as text, exactly as they appear in the front matter.
- The template variable contains the fully qualified path of the
<path>command line argument. If<path>points to a file, the variable contains the file path. If it points to a directory, it contains the directory path, or - if nopathis given - the current working directory. - The root directory of the current note. This is the first directory, that upwards from
TMPL_VAR_DIR_PATH, contains a file namedFILENAME_ROOT_PATH_MARKER. The root directory is used by Tp-Note’s viewer as base directory - If there is a YAML header in the
stdininput stream, this contains the body only. Otherwise, it contains the whole input stream. - Contains the YAML header (if any) of the
stdininput stream. Otherwise the empty string. - Contains the content of the first non empty environment variable
LOGNAME,USERNAMEorUSER.