Welcome to FeretUI’s documentation!

Feretui.

Small web client to build an admin user interface without any link with a framework.

This project is not a nodejs project. The client is generated with static templates. The javascrip library Htmx to improve the capability to manipulate the DOM and to add HTTP verb (DELETE, PUT, PATCH).

The client is not a Framework, and don’t use any web-server, orm, connector Frameworks. The goal is to separate the concept between both.

In a classical project the database, the ORM model’s and the user interface is declared on the same place. They are both the same configuration. But It is a mistake, because that limit the possibility and force to have only entry point by the user interface. The rules as required, readonly, … should be depending only on the user-interface. It is possible to define an interface based on more than one Model, or with another constraints.

To isolate it about the web-server projects, This project add objects to do absctract with web server:

FeretUI include to mecanism of templating:

  • feretui.template.Template : Import template by addons, the template can be modified by another template file. They are compiled by id and language. The compiled template are stored.

  • jinja.

The both are used in the same time, the internal allow the modularity, and jinja allow the loop and setter the variable inside the template

[my/template.tmpl]

<template id="my-template">
  <ul>
    {% for tag in tags %}
    <li>{{ tag }}</li>
    {% endfor %}
  </ul>
</template>

import of the template file

myferet.register_template_file('my/template.tmpl')

render the template

template_str = myferet.render_template(
    session, 'my-template', tags=['foo', 'bar'])

If the template need a static file (js, css, image), it is possible to add this static in existing client

myferet.register_js('my-lib.js', 'path in the filesystem')
myferet.register_css('my-lib.css', 'path in the filesystem')
myferet.register_image('my-picture.png', 'path in the filesystem')

Note

Python os lib give helper to find the path where the module is installed.

Note

An existing entrypoint is called at during the initialisation of the instance. In this entrypoint you may declare any static you need feretui.feretui.FeretUI.register_addons_from_entrypoint().

FeretUI include theme mecanism base on Bulma watch. It is easier to add your new theme file with feretui.feretui.FeretUI.register_theme().

myferet.register_theme('my-theme', 'path in the filesystem')

FeretUI add Action mechanism. The actions are callbacks and take as arguments the request and the argument of the action.

FeretUI allow to add page mecanisme. The page are function and take as arguments the session and the querystring or the body.

@myferet.register_page(
    name='my-page',
    template='''
        <template id="my-page">
            <div>My page</div>
        </template>
    '''
)
def my_page(feretui, session, option):
    return feretui.render_template(session, 'my-page')

In the case of the fully static page.

myferet.register_static_page(
    'my-static-page',
    '''
        <div>...</div>
    '''
)

or

from feretui.pages import static_page

myferet.register_page(name='my-page')(static_page('my-page-id))

To display the page a menu mecanism exist to call the render method of the page.

myferet.register_toolbar_right_menus([
    ToolBarMenu(
        'My static page',
        page='my-static-page',
        description="Go to my static page"
    ),
])

They are two main type of menu:

The helpers to register or get them are:

The client FeretUI add WTForm mecanism. The goal is to display easily formulaire in the pages and validate the entry in the actions.

To link the form with the translation and the bulma renderer you must inherit feretui.form.FeretUIForm.

If you need to register a password you must use the validator feretui.form.Password

The resource is a set of page and form to represent a data and tools to manipulate this data.

The client FeretUI add translation mechanism. This mecanism can be declared with addon’s name attribute. This attribute is used to extract the translation of FeretUI or an additionnal project. The translated object are:

To export the translation, the console script export-feretui-catalog extract all the translation messages in pot file.

from feretui import FeretUI, Session


myferet = FeretUI()
session = Session()

@route('an/url')
def do_something(request):
    frequest = Request(
        session=session,
        method=Request.POST,
        body=request.body.read(),
        headers=dict(request.headers),
    )
    response = myferet.execute_action(frequest, 'action-arg1-arg2')
    return response.body

Indices and tables