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();
let i = lib_cfg.scheme_idx("default").unwrap();
(*lib_cfg).scheme[i].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 for copy-counter.
- Configuration of filename parsing, deserialized from the configuration file.
- Configuration related to various Tera template filters.
- Configuration describing how to localize and check front matter variables.
- 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
. - Global variable containing the filename and template related configuration data.
- Configuration data, deserialized from the configuration file.
- Configuration data, deserialized and preprocessed.
- Configuration data, deserialized from the configuration file.
- Requirements for chronological sort tags.
- Configuration for sort-tag.
- 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:Value
properties. - Defines the way the HTML exporter rewrites local links. The command line option
--export-link-rewriting
expects this enum. Consult the manpage for details.
Constants§
- When a filename is taken already, Tp-Note adds a copy counter number in the range of
0..COPY_COUNTER_MAX
at the end. - Maximum length of a note’s filename in bytes. If a filename template produces a longer string, it will be truncated.
- The appearance of a file with this filename marks the position of
TMPL_VAR_ROOT_PATH
. - Default library configuration as TOML.
- A pseudo language tag for the
get_lang_filter
. When placed in theTMP_FILTER_GET_LANG
list, all available languages are selected. - HTML template variable used in the error page containing the error message explaining why this page could not be rendered.
- HTML template variable used in the error page containing a verbatim HTML rendition with hyperlinks of the erroneous note file.
- HTML template variable name. The value contains Tp-Note’s CSS code to be included in the HTML rendition produced by the exporter.
- 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 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
. - 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. - HTML template variable containing the automatically generated JavaScript code to be included in the HTML rendition.
- HTML template variable name. The value contains the path, for which the viewer delivers Tp-Note’s highlighting CSS code.
- 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. - 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 body of the file the command line option
<path>
points to. Only available in thetmpl.from_text_file_content
,tmpl.sync_filename
and 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::SystemTime
resolves to on the platform. Only available in thetmpl.from_text_file_content
,tmpl.sync_filename
and HTML templates. Note: this variable might not be defined with some filesystems or on some platforms. - All the front matter fields serialized as text, exactly as they appear in the front matter.
- 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_filename
and 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_filename
defines the function of of this variable as follows: Contains the value of the front matter fieldfile_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. - 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
. - If present, this header variable can switch the
settings.current_theme
before the filename template is processed. - By default, the template
tmpl.sync_filename
defines 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
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 variableTPNOTE_LANG
overwrites this value (all operating systems). - 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 nopath
is 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
stdin
input stream, this contains the body only. Otherwise, it contains the whole input stream. - Contains the YAML header (if any) of the
stdin
input stream. Otherwise the empty string. - Contains the content of the first non empty environment variable
LOGNAME
,USERNAME
orUSER
.