Working on the YunoHost web admin
When using ynh-dev
, run in the container:
./ynh-dev use-git yunohost-admin
It launches gulp, such as each time you modify sources, it recompiles the code and you can use it by refreshing (Ctrl+F5) your web administration.
To stop the command, just do Ctrl+C.
You might need to force-clear the cache of your browser sometimes to refresh
the JavaScript and/or HTML (so each time you edit something in js
or views
).
The web interface uses the API to interact with YunoHost. The API
commands/requests are also defined via the actionsmap. For instance, accessing
the page https://domain.tld/yunohost/api/users
corresponds to a GET /users
requests on the YunoHost API. It is mapped to the function
user_list()
. Accessing the URL should display the JSON returned by this
function. 'GET' requests are typically meant to ask information to the server.
'POST' requests are meant to ask the server to edit/change some information,
or to execute some actions.
-
js/yunohost/controllers
contains the JavaScript parts, and define which requests to make to the API when loading a specific page of the interface, and how to process the data to generate the page, using templates. -
views
contains the various templates for the pages of the interface. In the template, data coming from the JavaScript part can be used with the syntax{{some-variable}}
, which will be replaced when building/accessing the page. It is also possible to have conditions using the handlebars.js syntax:{{#if some-variable}}<p>Some conditional HTML code here !</p>{{/if}}
-
For internationalized strings, use
y18n.t('some-string-code')
in the JavaScript, or{{t 'some-string-code'}}
in the HTML template, and put your string inlocales/en.json
. Don't edit other locales files, this will be done using Weblate!