Expand description
Set configuration defaults, reads and writes Tp-Note’s configuration file
and exposes the configuration as static
variable.
Structs
Arguments lists for invoking external applications, deserialized from the configuration file.
Command line arguments, deserialized form configuration file.
Reads and parses the configuration file “tp-note.toml”. An alternative filename (optionally with absolute path) can be given on the command line with “–config”.
Variable indicating with Err
if the loading of the configuration file went wrong.
This is where the Tp-Note stores its configuration file.
Configuration data, deserialized from the configuration file.
Configuration of clipboard behaviour, deserialized from the configuration file.
Configuration for the HTML exporter feature, deserialized from the configuration file.
Configuration of filename parsing, deserialized from the configuration file.
Filename templates and content templates, deserialized from the configuration file.
Store the extension as key and mime type as value in HashMap.
Configuration data for the viewer feature, deserialized from the configuration file.
Constants
Default command line argument list when launching the web browser. The list is executed item by item until an installed web browser is found. Can be changed in config file.
Default command line argument list when launching external editor. The editor list is executed item by item until an editor is found. Can be changed in config file.
Default command line argument list when launching an external editor
and no graphical environment is available (DISPLAY=''
).
This lists console file editors only.
The editor list is executed item by item until an editor is found.
Can be changed in config file.
Default value for the command line flag --add-header
. If unset,
Tp-Note exits of when it tries to open a text file without a YAML
header. When this flag is set, the missing header is constructed by
means of the text file’s filename and creation date.
Default value for the command line option --debug
. Determines the maximum
debug level events must have, to be logged. If the command line option
--debug
is present, its value will be used instead.
Default value for the command line flag --edit
to disable file watcher,
(Markdown)-renderer, html server and a web browser launcher set to true
.
Default value for the command line flag --no-filename-sync
to disable
the title to filename synchronisation mechanism permanently.
If set to true
, the corresponding command line flag is ignored.
Default value for the command line flag --popup
. If the command line flag
--popup
or POPUP
is true
, all log events will also trigger the
appearance of a popup alert window. Note, that error level debug events
will always pop up, regardless of --popup
and POPUP
(unless
--debug=off
).
Default value for the command line flag --tty
. Tp-Note tries different
heuristics to detect weather a graphic environment is available or not. For
example, under Linux, the ‘DISPLAY
’ environment variable is evaluated. The
‘--tty
’ flag disables the automatic detection and sets Tp-Note in
“console” mode, where only the non GUI editor (see configuration variable:
‘[app_args] editor_console
’) and no viewer is launched. If this is set
to true
Tp-Note starts in console mode permanently.
Should the clipboard be emptied when tp-note closes? Default value.
By default clipboard support is enabled, can be disabled in config file. A false value here will set ENABLE_EMPTY_CLIPBOARD to false.
Tp-Note’s configuration file filename.
Name of this executable (without the Windows “.exe” extension).
Template used to render a note into html when the rendition is saved to disk
Tp-Note may add a counter at the end of the filename when
it can not save a file because the name is taken already.
This is the closing bracket search pattern. Some examples:
"-"
, “‘_’”“, "_-"
,"-_"
, "("
Can be empty.
If the stem of a filename ends with a pattern, that is
similar to a copy counter, add this extra separator. It
must be one of TRIM_LINE_CHARS
(see definition in
crate: sanitize_filename_reader_friendly
) because they
are known not to appear at the end of sanitze()
’d
strings. This is why they are suitable here.
When a filename is taken already, Tp-Note adds a copy
counter number in the range of 0..COPY_COUNTER_MAX
at the end.
Tp-Note may add a counter at the end of the filename when
it can not save a file because the name is taken already.
This is the opening bracket search pattern. Some examples:
"-"
, “‘_’”“, "_-"
,"-_"
, "("
Can be empty.
This a dot by definition.
The present list contains file extensions of HTML encoded Tp-Note files. For these file types their content is forwarded to the web browser without modification.
The variables FILENAME_EXTENSIONSS_*
list file extensions that Tp-Note
considers as its own note files.
Tp-Note opens these files, reads their their YAML header and
launches an external file editor and an file viewer
(web browser).
According to the markup language used, the appropriate
renderer is called to convert the note’s content into HTML.
The rendered HTML is then shown to the user with his
web browser.
The present list contains file extensions of
Tp-Note files for which no viewer is opened
(unless Tp-Note is invoked with --view
).
The present list contains file extensions of RestructuredText encoded Tp-Note files.
The present list contains file extensions of Text encoded Tp-Note files that the viewer shows literally without (almost) any additional rendering. Only hyperlinks in Markdown, reStructuredText, Asciidoc and HTML are rendered, thus clickable.
File extension of new Tp-Note files.
Maximum length of a note’s filename in bytes. If a filename template produces a longer string, it will be truncated.
List of characters that can be part of a sort tag.
This list must not include SORT_TAG_EXTRA_SEPARATOR
.
The first character in the filename which is not
in this list, marks the end of the sort tag.
In case the file stem starts with a character in
SORT_TAG_CHARS
the SORT_TAG_EXTRA_SEPARATOR
character is inserted in order to separate both parts
when the filename is read next time.
Default template used when the command line .md
-file. Can be modified through editing the configuration file.
Filename of a new note, that annotates an existing file on disk given in
As all application logic is encoded in Tp-Note’s templates, it does not know about field names.
Nevertheless it is useful to identify at least one field as the field that identifies a note
the most. When TMPL_COMPULSORY_HEADER_FIELD
is not empty, Tp-Note will not synchronize the
note’s filename and will pop up an error message, unless it finds the field in the note’s
header. When TMPL_COMPULSORY_HEADER_FIELD
is empty, all files are synchronized without any
further field check. Make sure to define a default value with fm_* | default(value=*)
in case the variable fm_*
does not exist in the note’s front matter.
Default template used, when the clipboard or the input stream stdin
contains a string and
this string has no valid YAML front matter section. The clipboards content is in {{ clipboard }}
, its truncated version in {{ clipboard | heading }}
When the clipboard contains a
hyperlink in Markdown or reStruncturedText format. See crate parse-hyperlinks
for details.
For example: [<link-name>](<link-url> "link-title")
, can be accessed with the variables:
{{ clipboard | linkname }}
, {{ clipboard | linktarget }}
and {{ clipboard | linkttitle }}
.
Default filename template used when the stdin ~ clipboard contains a string.
Default template used, when the clipboard or the input stream stdin
contains a string and one
the of these strings contains a valid YAML front matter section.
The clipboards body is in {{ clipboard }}
, the header is in {{ clipboard_header }}
. The
stdin’s body is in {{ stdin }}
, the header is in {{ stdin_header }}
.
First all variables defined in the clipboard’s front matter are registered, the ones
defined in the input stream stdin
. The latter can overwrite the former. One of the front
matters must define the title
variable, which is then available in this template as {{ fm_title }}
.
When placed in YAML front matter, the filter | json_encode
must be
appended to each variable.
Default filename template used when the stdin or the clipboard contains a string and one of them has a valid YAML header.
Default template used, when the opened text file (with a known file extension) is missing a YAML front matter section. This template prepends such a section. The template inserts information extracted from the input filename and its creation date.
Default filename template used when the input file (with a known file extension) is missing a YAML front matter section. The text file’s sort-tag and file extension are preserved.
Default content template used when the command line argument {{ sanit | stem }}
, {{ path | stem }}
, {{ path | ext }}
, {{ extension_default }}
{{ file | tag }}
, {{ username }}
, {{ date }}
, {{ lang }}
, {{ dir_path }}
.
In addition all environment variables can be used, e.g. {{ get_env(name=\"LOGNAME\") }}
When placed in YAML front matter, the filter | json_encode
must be appended to each variable.
Default filename template for a new note file on disk. It implements the sync criteria for
note metadata in front matter and filename.
Useful variables in this context are:
{{ title| sanit }}
, {{ subtitle| sanit }}
, {{ extension_default }}
,
All variables also exist in a {{ <var>| sanit(alpha) }}
variant: in case its value starts
with a number, the string is prepended with '
. The first non-numerical variable must be some
{{ <var>| sanit(alpha) }}
variant.
Note, as this is filename template, all variables (except now
and extension_default
must be
filtered by a sanit
or sanit(alpha=true)
filter.
Default filename template to test, if the filename of an existing note file on disk, corresponds to the note’s meta data stored in its front matter. If it is not the case, the note’s filename will be renamed. Can be modified through editing the configuration file.
HTML template to render the viewer-error page.
When set to true, the viewer feature is automatically disabled when
Tp-Note encounters an .md
file without header. Experienced users can
set this to true
. This setting is ignored, meaning is considered false
,
if ARG_DEFAULT_ADD_HEADER=true
or ARGS.add_header=true
or
ARGS.viewer=true
.
How often should the file watcher check for changes? Delay in milliseconds.
Served file types with corresponding mime types. First entry per line is
The first entry per line is the file extension in lowercase(!), the second the corresponding mime type. Embedded files with types other than those listed here are silently ignored. Note, that image files must be located in the same or in the note’s parent directory.
When Tp-Note starts, it launches two external applications: some text editor
and the viewer (web browser). By default the two programs are launched at
the same time (VIEWER_STARTUP_DELAY==0
). If VIEWER_STARTUP_DELAY>0
the
viewer (web browser) will be launched VIEWER_STARTUP_DELAY
milliseconds
after the text editor. If VIEWER_STARTUP_DELAY<0
the viewer will be
started first. Common values are -1000
, 0
and 1000
.
The maximum number of TCP connections the HTTP server can handle at the same time. In general, the serving and live update of the HTML rendition of the note file, requires normally 3 TCP connections: 1 old event channel (that is still open from the previous update), 1 TCP connection to serve the HTML, the local images (and referenced documents), and 1 new event channel. In practise, stale connection are not always closed immediately. Hence 4 open connections are not uncommon.
Functions
Parse the configuration file if it exists. Otherwise write one with default values.
Writes the default configuration to Path
.