Module config

Source
Expand description

Set configuration defaults by reading the internal default configuration file LIB_CONFIG_DEFAULT_TOML. After processing, the configuration data is exposed via the variable LIB_CFG behind a mutex. This makes it possible to modify all configuration defaults (including templates) at runtime.

use tpnote_lib::config::LIB_CFG;

let mut lib_cfg = LIB_CFG.write();
let i = lib_cfg.scheme_idx("default").unwrap();
(*lib_cfg).scheme[i].filename.copy_counter.extra_separator = '@'.to_string();

Contract to be uphold by the user of this API: seeing that LIB_CFG is mutable at runtime, it must be sourced before the start of Tp-Note. All modification of LIB_CFG is terminated before accessing the high-level API in the workflow module of this crate.

Structs§

CopyCounter
Configuration for copy-counter.
Filename
Configuration of filename parsing, deserialized from the configuration file.
Filter
Configuration related to various Tera template filters.
FmVar
Configuration describing how to localize and check front matter variables.
GetLang
Configuration related to various Tera template filters.
LibCfg
Processed configuration data.
Scheme
Configuration data, deserialized from the configuration file.
Sequential
Requirements for chronological sort tags.
SortTag
Configuration for sort-tag.
Tmpl
Filename templates and content templates, deserialized from the configuration file.
TmplHtml
Configuration for the HTML exporter feature, deserialized from the configuration file.

Enums§

Assertion
Describes a set of tests, that assert template variable tera:Value properties.
LocalLinkKind
Defines the way the HTML exporter rewrites local links. The command line option --export-link-rewriting expects this enum. Consult the manpage for details.
Mode

Constants§

FILENAME_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.
FILENAME_LEN_MAX
Maximum length of a note’s filename in bytes. If a filename template produces a longer string, it will be truncated.
FILENAME_ROOT_PATH_MARKER
The appearance of a file with this filename marks the position of TMPL_VAR_ROOT_PATH.
LIB_CFG_RAW_FIELD_NAMES
An array of field names after deserialization.
LIB_CONFIG_DEFAULT_TOML
Default library configuration as TOML.
TMPL_HTML_VAR_DOC_ERROR
HTML template variable used in the error page containing the error message explaining why this page could not be rendered.
TMPL_HTML_VAR_DOC_TEXT
HTML template variable used in the error page containing a verbatim HTML rendition with hyperlinks of the erroneous note file.
TMPL_HTML_VAR_EXPORTER_DOC_CSS
HTML template variable name. The value contains Tp-Note’s CSS code to be included in the HTML rendition produced by the exporter.
TMPL_HTML_VAR_EXPORTER_HIGHLIGHTING_CSS
HTML template variable name. The value contains the highlighting CSS code to be included in the HTML rendition produced by the exporter.
TMPL_HTML_VAR_VIEWER_DOC_CSS_PATH
HTML template variable name. The value contains the path, for which the viewer delivers Tp-Note’s CSS code. Note, the viewer delivers the same CSS code which is stored as value for TMPL_HTML_VAR_VIEWER_DOC_CSS.
TMPL_HTML_VAR_VIEWER_DOC_CSS_PATH_VALUE
The constant URL for which Tp-Note’s internal web server delivers the CSS style sheet. In HTML templates, this constant can be accessed as value of the TMPL_HTML_VAR_VIEWER_DOC_CSS_PATH variable.
TMPL_HTML_VAR_VIEWER_DOC_JS
HTML template variable containing the automatically generated JavaScript code to be included in the HTML rendition.
TMPL_HTML_VAR_VIEWER_HIGHLIGHTING_CSS_PATH
HTML template variable name. The value contains the path, for which the viewer delivers Tp-Note’s highlighting CSS code.
TMPL_HTML_VAR_VIEWER_HIGHLIGHTING_CSS_PATH_VALUE
The constant URL for which Tp-Note’s internal web server delivers the CSS style sheet. In HTML templates, this constant can be accessed as value of the TMPL_HTML_VAR_NOTE_CSS_PATH variable.
TMPL_VAR_BODY
Names the body of some Content.
TMPL_VAR_CURRENT_SCHEME
Contains the name of the selected scheme.
TMPL_VAR_DIR_PATH
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 to TMPL_VAR_PATH,
TMPL_VAR_DOC
Contains the body of the file the command line option <path> points to. Only available in the tmpl.from_text_file_content, tmpl.sync_filename and HTML templates.
TMPL_VAR_DOC_FILE_DATE
Contains the date of the file the command line option <path> points to. The date is represented as an integer the way std::time::SystemTime resolves to on the platform. Only available in the tmpl.from_text_file_content, tmpl.sync_filename and HTML templates. Note: this variable might not be defined with some file systems or on some platforms.
TMPL_VAR_EXTENSION_DEFAULT
Contains the default file extension for new note files as defined in the configuration file.
TMPL_VAR_FM_
Prefix prepended to front matter field names when a template variable is generated with the same name.
TMPL_VAR_FM_ALL
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_filename and HTML templates.
TMPL_VAR_FM_FILENAME_SYNC
Contains the value of the front matter field filename_sync. When set to filename_sync: false, the filename synchronization mechanism is disabled for this note file. Default value is true.
TMPL_VAR_FM_FILE_EXT
By default, the template tmpl.sync_filename defines the function of this variable as follows: Contains the value of the front matter field file_ext and 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.
TMPL_VAR_FM_NO_FILENAME_SYNC
Contains the value of the front matter field no_filename_sync. When set to no_filename_sync: or no_filename_sync: true, the filename synchronization mechanism is disabled for this note file. Depreciated in favor of TMPL_VAR_FM_FILENAME_SYNC.
TMPL_VAR_FM_SCHEME
If present, this header variable can switch the settings.current_theme before the filename template is processed.
TMPL_VAR_FM_SORT_TAG
By default, the template tmpl.sync_filename defines the function 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.
TMPL_VAR_FORCE_LANG
A copy of the command line option --force_lang. The empty value means “disable language forcing”.
TMPL_VAR_HEADER
Names the header of some Content.
TMPL_VAR_HTML_CLIPBOARD
The name of the HTML clipboard to refer to in templates. Note: as current HTML clipboard provider never send YAML headers (yet), html_clipboard.header is always empty.
TMPL_VAR_LANG
Contains the user’s language tag as defined in RFC 5646. Not to be confused with the UNIX LANG environment variable from which this value is derived under Linux/MacOS. Under Windows, the user’s language tag is queried through the Win-API. If defined, the environment variable TPNOTE_LANG overwrites this value (all operating systems).
TMPL_VAR_PATH
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 no path is given - the current working directory.
TMPL_VAR_ROOT_PATH
The root directory of the current note. This is the first directory, that upwards from TMPL_VAR_DIR_PATH contains a file named FILENAME_ROOT_PATH_MARKER. The root directory is used by Tp-Note’s viewer as base directory
TMPL_VAR_SCHEME_SYNC_DEFAULT
Contains the name of the default scheme when no scheme: field is present in the note’s YAML header. This value defined in the configuration file under the same name and copied from there.
TMPL_VAR_STDIN
The name of the standard input stream to refer to in templates.
TMPL_VAR_TXT_CLIPBOARD
The name of the plain text clipboard to refer to in templates.
TMPL_VAR_USERNAME
Contains the content of the first non empty environment variable LOGNAME, USERNAME or USER.

Statics§

LIB_CFG
Global variable containing the filename and template related configuration data. This can be changed by the consumer of this library. Once the initialization done, this should remain static. For session configuration see: settings::SETTINGS.