How a query is processed
The purpose of a query is to match with a shortcut. And shortcuts are organized by Namespaces: Every shortcut belongs exactly to one namespace.
Namespace setting
When calling Trovu without query parameters, 3 default namespaces will be set based on the browser's language settings. For instance, if the browser's language is de-DE
, we will use these namespaces and their shortcut files:
Processing a query
Now, let's look at the processing of a query:
- A query comes in, e.g.
g foobar
. - The current namespace setting is
o,de,.de
. -
Given the namespaces, all the shortcuts are fetched from their YAML files into a JavaScript variable in the client.
- The fetch() call checks also if the files are already in the browser cache, and only requests them from remote if they are not cached yet.
- To reload the shortcuts, use the
reload
command (see below).
-
The query is parsed – in the client by JavaScript – into
- keyword:
g
- argument:
foobar
- keyword:
- Based on the query and the namespace settings, the loaded shortcuts are searched whether they match a query with the keyword
g
and one argument, i.e. if they contain a shortcut keyed withg 1
. - We find 2 matches:
- From the found matches, the results are evaluated in namespace order.
- Since namespace
.de
has higher priority thano
, its URL is used for further processinghttps://www.google.de/search?hl=<$language>&q=<query>&ie=utf-8
- The
<$language>
placeholder is being replaced with the variablede
. - The
<query>
placeholder is being replaced with the query argumentfoobar
. - A redirect to the URL is made.
Reloading shortcuts
Since shortcuts are cached in the browser cache, you may want to reload them once they got updated. Do so by
- either prefixing a query:
reload:g foobar
- or only calling
reload
.