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§
- CfgVal
- A newtype holding configuration data.
- Copy
Counter - 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.
- 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.
- Tmpl
Html - 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. - Local
Link Kind - 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§
- 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_
FILTER_ GET_ LANG_ ALL - A pseudo language tag for the
get_lang_filter
. When placed in theTMP_FILTER_GET_LANG
list, all available languages are selected. - 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_ 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 toTMPL_VAR_PATH
, - TMPL_
VAR_ DOC_ BODY_ TEXT - 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. - 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 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. - TMPL_
VAR_ DOC_ FM_ TEXT - All the front matter fields serialized as text, exactly as they appear in the front matter.
- 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 tofilename_sync: false
, the filename synchronization mechanism is disabled for this note file. Default value istrue
. - TMPL_
VAR_ FM_ FILE_ EXT - 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. - TMPL_
VAR_ FM_ NO_ FILENAME_ SYNC - 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
. - 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 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_ HTML_ CLIPBOARD - If there is a meta header in the HTML clipboard, this contains the body only. Otherwise, it contains the whole clipboard content. Note: as current HTML clipboard provider never send YAML headers (yet), expect this to be the whole HTML clipboard.
- TMPL_
VAR_ HTML_ CLIPBOARD_ HEADER - Contains the YAML header (if any) of the HTML clipboard content. Otherwise the empty string. Note: as current HTML clipboard provider never send YAML headers (yet), expect this to be 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 variableTPNOTE_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 nopath
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 namedFILENAME_ROOT_PATH_MARKER
. The root directory is used by Tp-Note’s viewer as base directory - TMPL_
VAR_ STDIN - If there is a YAML header in the
stdin
input stream, this contains the body only. Otherwise, it contains the whole input stream. - TMPL_
VAR_ STDIN_ HEADER - Contains the YAML header (if any) of the
stdin
input stream. Otherwise the empty string. - TMPL_
VAR_ TXT_ CLIPBOARD - If there is a YAML header in the plain text clipboard, this contains the body only. Otherwise, it contains the whole clipboard content.
- TMPL_
VAR_ TXT_ CLIPBOARD_ HEADER - Contains the YAML header (if any) of the plain text clipboard content. Otherwise the empty string.
- TMPL_
VAR_ USERNAME - Contains the content of the first non empty environment variable
LOGNAME
,USERNAME
orUSER
.
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
.