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§
- 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.
- 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.
- 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. - 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 toTMPL_VAR_PATH
, - TMPL_
VAR_ DOC - 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 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 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 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 synchronization mechanism is disabled for this note file. Depreciated in favor 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 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 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_ 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
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
.