This commit is contained in:
gwen 2026-02-16 18:55:51 +01:00
parent 4585d1aa66
commit 13b77b38f6
2 changed files with 118 additions and 68 deletions

View file

@ -73,6 +73,50 @@ CLI root
┣━━ 📓 HTTPS address: https.proxy.net ◀ loaded from the YAML file "config/01/config.yml" (⏳ https.proxy.net ◀ loaded from the YAML file "config/01/config.yml" ⏳ http.proxy.net) ┣━━ 📓 HTTPS address: https.proxy.net ◀ loaded from the YAML file "config/01/config.yml" (⏳ https.proxy.net ◀ loaded from the YAML file "config/01/config.yml" ⏳ http.proxy.net)
┗━━ 📓 HTTPS port: 3128 ┗━━ 📓 HTTPS port: 3128
---
sortie normale:
sortie pour n'afficher qu'une family:
::
rougail -m firefox/ -u yaml -yf config/01/config
on a:
::
Variables:
┣━━ 📓 Configure Proxy Access to the Internet: Manual proxy configuration ◀ loaded from the YAML file "config/01/config.yml" (⏳ No proxy)
┗━━ 📂 Manual proxy configuration
┣━━ 📂 HTTP Proxy
┃ ┣━━ 📓 HTTP address: http.proxy.net ◀ loaded from the YAML file "config/01/config.yml"
┃ ┗━━ 📓 HTTP Port: 3128 ◀ loaded from the YAML file "config/01/config.yml" (⏳ 8080)
┣━━ 📓 Also use this proxy for HTTPS: false ◀ loaded from the YAML file "config/01/config.yml" (⏳ true)
┣━━ 📂 HTTPS Proxy
┃ ┣━━ 📓 HTTPS address: https.proxy.net ◀ loaded from the YAML file "config/01/config.yml" (⏳ http.proxy.net)
┃ ┗━━ 📓 HTTPS port: 3128
┗━━ 📂 SOCKS Proxy
┣━━ 📓 SOCKS address: http.proxy.net
┣━━ 📓 SOCKS port: 3128
┗━━ 📓 SOCKS host version used by proxy: v5
sortie plus précise:
::
rougail -m firefox/ -u yaml -yf config/01/config.yml --cli.root manual.https_proxy
on a:
::
Variables:
┣━━ 📓 HTTPS address: https.proxy.net ◀ loaded from the YAML file "config/01/config.yml" (⏳ https.proxy.net ◀ loaded from the YAML file "config/01/config.yml" ⏳ http.proxy.net)
┗━━ 📓 HTTPS port: 3128
Invalid user data error Invalid user data error
----------------------------- -----------------------------

View file

@ -32,10 +32,31 @@ Playing with Jinja
git clone https://forge.cloud.silique.fr/stove/rougail-tutorials.git git clone https://forge.cloud.silique.fr/stove/rougail-tutorials.git
git switch --detach v1.1_070 git switch --detach v1.1_070
.. type-along:: Why the jinja templating engine ?
We are going to embed some `jinja templating code <https://jinja.palletsprojects.com/en/stable/>`_ in our structure file.
.. questions:: What about a `Jinja` calculation?
The :term:`Jinja` templating language enables some complex calculation.
We can code more complex behavior that hiding or disabling a variable depending on the value of another variable,
as we saw before.
.. glossary::
Jinja
`Jinja <https://jinja.palletsprojects.com>`_ is a template engine.
we are using Jinja in a classical way, that is, Jinja allows us to handle different cases,
for example with the `if` statement.
A conditional hidden family with Jinja A conditional hidden family with Jinja
--------------------------------------- ---------------------------------------
Let's show add some jinja code in our structure file: Here we are going to use the Jinja conditional (testing) statement.
Here is our structure file:
.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_070/firefox/20-manual.yml .. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_070/firefox/20-manual.yml
:language: yaml :language: yaml
@ -82,12 +103,25 @@ Let's show add some jinja code in our structure file:
when: HTTPS when: HTTPS
... ...
In this jinja code, we are testing the `use_for_https` variable:
If we set the `use_for_https` to `false`: .. code-block:: jinja
{% if _.use_for_https %}
HTTPS is same has HTTP
{% endif %}
If this variable is set to `true`, the `"HTTPS is same has HTTP"` expression
will appear.
.. note:: Have a look at the `jinja website's test section <https://jinja.palletsprojects.com/en/stable/templates/#tests>`_
for a closer look about testing a variable.
But first, let's set our `use_for_https` variable to `false`:
.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_070/config/01/config.yml .. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_070/config/01/config.yml
:language: yaml :language: yaml
:caption: FIXME :caption: The :file:`config/01/config.yml` user data file with the `use_for_https` set to `false`
.. ..
--- ---
@ -107,54 +141,11 @@ Nothing special appears when we launch the Rougail CLI:
:class: terminal :class: terminal
.. ..
rougail -m firefox/ -u yaml -yf config/01/config.The rougail -m firefox/ -u yaml -yf config/01/config.yml
--- We have this output:
..
env ROUGAIL_MANUAL.USE_FOR_HTTPS=true
:: .. raw:: html
rougail -m firefox/ -u yaml -yf config/01/config.yml --cli.root manual.https_proxy
we have a warning:
::
🔔 Warning
┗━━ Manual proxy configuration
┗━━ HTTPS Proxy
┗━━ HTTPS address: 🔔 family "HTTPS Proxy" has property hidden, so
cannot access to "HTTPS address", it will be ignored when loading
from the YAML file "config/01/config.yml"
╭────────────── Caption ──────────────╮
│ Unmodifiable variable Default value │
╰─────────────────────────────────────╯
Variables:
┣━━ 📓 HTTPS address: http.proxy.net
┗━━ 📓 HTTPS port: 3128
It is interesting here to launch the Rougail CLI in the :term:`read write mode`:
..
env ROUGAIL_MANUAL.USE_FOR_HTTPS=true
::
rougail -m firefox/ --cli.root manual.https_proxy -u yaml environment -yf config/01/config.yml --cli.read_write
.. code-block:: bash
ERROR: cannot access to optiondescription "HTTPS Proxy"
because has property "hidden"
(HTTPS is same has HTTP)
yml standard output:
.. raw:: html
:url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_070/config/01/output_ro.html :url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_070/config/01/output_ro.html
:class: output :class: output
@ -174,6 +165,40 @@ yml standard output:
┣━━ 📓 SOCKS port: 3128 ┣━━ 📓 SOCKS port: 3128
┗━━ 📓 SOCKS host version used by proxy: v5 ┗━━ 📓 SOCKS host version used by proxy: v5
If we set the `use_for_https` to `true` in the :file:`config.yml` user data file,
then we launch again the Rougail CLI:
.. raw:: html
:url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_070/config/01/cmd_ro.txt
:class: terminal
then we have a warning:
::
🔔 Warning
┗━━ Manual proxy configuration
┗━━ HTTPS Proxy
┗━━ HTTPS address: 🔔 family "HTTPS Proxy" has property hidden,
so cannot access to "HTTPS address",
it will be ignored when loading from the YAML file "config/01/config.yml"
It is interesting here to launch the Rougail CLI in the :term:`read write mode`:
::
rougail -m firefox/ --cli.root manual.https_proxy -u yaml environment \
-yf config/01/config.yml --cli.read_write
Then we have an error:
.. code-block:: bash
ERROR: cannot access to optiondescription "HTTPS Proxy"
because has property "hidden"
(HTTPS is same has HTTP)
FIXME
We can hide or disable some variables or families with other techniques than We can hide or disable some variables or families with other techniques than
pointing on a variable's value. pointing on a variable's value.
@ -287,25 +312,6 @@ Let's explain it more precisely.
.. note:: The "the proxy mode is not manual" output is be used in the log outputs .. note:: The "the proxy mode is not manual" output is be used in the log outputs
for example while for example while
Why Jinja?
---------------
.. questions:: What about this `Jinja` type?
If the :term:`Jinja` template returns some text, then the family will be `disabled`. Otherwise it is accessible.
Deactivating a family means that we will not be able to access it as well as the variables or families included in this family.
.. note:: If the Jinja template does not return any text, the variable will be **enabled**.
Here we are using the Jinja condition statement.
.. glossary::
Jinja
`Jinja <https://jinja.palletsprojects.com>`_ is a template engine.
we are using Jinja in a classical way, that is, Jinja allows us to handle different cases,
for example with the `if` statement.
What can be calculated? What can be calculated?
--------------------------- ---------------------------