Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • documentation/doc
  • PhilH/doc
  • louis.csn/doc
  • fabien4vo/doc
  • rngadam/doc
  • anastasia/doc
6 results
Show changes
Showing
with 414 additions and 387 deletions
source/_static/images/servers-of-the-future.png

148 KiB

......@@ -32,6 +32,7 @@ templates_path = []
exclude_patterns = []
autosectionlabel_prefix_document = True
# -- Options for HTML output -------------------------------------------------
......
What about the backend ?
------------------------
sib-ac-checker
~~~~~~~~~~~~~~
Hides an element from the page if the current user doesn’t have the
required permissions on it.
.. code:: html
<sib-ac-checker permission="acl:Write" bind-resources>
<sib-route name="member-edit">
<div>Edit</div>
</sib-route>
</sib-ac-checker>
**Attributes :**
- **``permission``**: Displays the element if the user has the
specified right
- **``no-permission``**: Displays the element if the user has not the
specified right
Possible values: -
`acl:Read <https://github.com/solid/web-access-control-spec#aclread>`__
-
`acl:Write <https://github.com/solid/web-access-control-spec#aclwrite>`__
-
`acl:Append <https://github.com/solid/web-access-control-spec#aclappend>`__
-
`acl:Control <https://github.com/solid/web-access-control-spec#aclcontrol>`__
sib-delete
~~~~~~~~~~
Receives the URL of a resource or of a container of resources via its
``data-src`` attribute, and displays a button to delete it when clicked.
.. code:: html
<sib-delete data-src="http://localhost:8000/conversations/9/"></sib-delete>
**Attributes:**
- **``data-src``**: The uri of the LDP resource you want to delete.
- **``data-label``**: The text to display on the delete button.
**Events:**
- **``resourceDeleted``**: triggered when the resource is successfully
deleted.
sib-display
~~~~~~~~~~~
Receives the URL of a resource or of a container of resources via its
``data-src`` attribute, and displays it. Each field of the displayed
resources can be rendered by a specific widget, either custom or chosen
from the default ones. Filters and searching capabilities can be easily
added to interact with the list of data being displayed.
.. code:: html
<sib-display
id="list"
data-src="http://localhost:8000/todos/"
value-created="Created by:"
fields="image, status(state), author(created, name), info(task, date), deadline"
widget-image="sib-display-img"
search-fields="name, author"
next="detail"
></sib-display>
**Attributes:**
- **``data-src``**: The uri of the LDP resource you want to display. If
this resource is a container, ``<sib-display>`` will create a child
``<sib-display>`` for each resource it contains, and ``<sib-form>``
will display a blank form with appropriate fields to create a new
resource.
- **``value-xyz``**: To display a string not contained within the data.
- **``fields``**: The ordered list of fields to be displayed, separated
by commas.
By default, all the fields of the resource are displayed.
To not show any fields, put an empty fields (eg.
``<sib-display fields />)``
To group fields within a ``<div>`` tag that will have the ``name``
attribute set up to ``xyz``, enclose some fields in parenthesis. For
example: ``fields="xyz(first_name, last_name), email"``. You can
customize the group widget, see the `sets widgets <#set-widgets>`__
section below for more info.
By default, all displayed fields are direct children of
``<sib-display>``. Make sure you don’t give your set the same name as
a field as it would result in an infinite loop.
- **``widget-xyz``**: The widget to be used to display the ``xyz``
field. By default, the widget used is ``<sib-display-div>``. Cf the
`Display widgets <#display-widgets>`__ section below for more info.
- **``default-widget``**: The widget to use for all the fields, except
if a specific one is defined for a field.
- **``multiple-xyz``**: Show field ``xyz`` as multiple field containing
one widget for each child. Multiple widget can be specified, example:
``multiple-skills="my-custom-multiple-widget"``. If argument is used
without value, default multiple widget is used. Cf the `Multiple
widgets <#multiple-widgets>`__ section below for more info.
- **``each-label-xyz``**: Used with ``multiple-xyz``, label of each
child of multiple widget
- **``each-class-xyz``**: Used with ``multiple-xyz``, class of each
child of multiple widget
- **``each-range-xyz``**: Used with ``multiple-xyz``, range value of
each child of multiple widget
- **``multiple-xyz-add-label``**: Used with ``multiple-xyz``, text
of the “+” button
- **``multiple-xyz-remove-label``**: Used with ``multiple-xyz``,
text of the “×” button
- **``search-fields``**: It is possible to search/filter your list by
choosing the fields you want to filter it with. To be able to filter
my users by ``name`` for instance, I can set
``search-fields="name"``. This will display a form with the
appropriate inputs to filter the list.
- **``search-value-xyz``**: The default value of the search field
``xyz``
- **``search-label-xyz``**: Set the label for the search field
``xyz``
- **``search-widget-xyz``**: The form widget of the search field
``xyz``
- **``search-range-xyz``**: The range of values of the search field
``xyz``
- **``paginate-by``**: The list can also be split in pages, for example
set ``paginate-by="5"`` to display pages of 5 elements, the prev/next
buttons and the counter will be added automatically
- **``order-by``**: The name of the field you want to use to order the
list. For example, ``order-by="username"`` will order the users list
alphabetically based on the username.
- **``highlight-xyz``**: The resources to put at the top of the list.
For example, ``highlight-date="2019-05-20"`` will display first all
the resources which have a field date equal to “2019-05-20”.
- **``group by``**: The resources will be grouped by the field you give
as a parameter. For example, ``group-by="date"`` will render one
``<div>`` by date, and put the corresponding resources inside.
- **``next``**: ``name`` attribute of the ``<sib-route>`` that should
be accessed when a ``<sib-display>`` element is clicked. See the
documentation of ``<sib-router>`` for more details.
- **``action-xyz``**:
- **``label-xyz``**: Set the label for the field ``xyz``
- **``editable-xyz``**: Add an “edit” button next to the ``xyz`` field
to let the user edit it. The changes are saved as soon as the field
loses focus. The editable attribute works with the following widgets:
``sib-display-div``, ``sib-display-labelled-div``,
``sib-display-mailto`` and ``sib-display-tel``
- **``counter-template``**: To display the number of resources fetched
by the ``sib-display``. It takes a string in which you can use HTML
tags, and the ``counter`` variable to add the number.
i.e. ``"<strong>${counter} results</strong>"``
- **``extra-context``**: The id of the ``<script>`` tag which contains
the context you want to add for this component. An extra context
looks like this:
.. code:: html
<script id="custom-context" type="application/ld+json">
{ "user": "https://api.test-paris.happy-dev.fr/users/" }
</script>
If your ``<script>`` tag has the attribute ``data-default-context``,
this extra context will be applied on all the components which
doesn’t have an ``extra-context`` attribute.
- **``loader-id``**: Id of the loader element you want to display
during the loading time.
- **``class-xyz``**: Class attribute added to the fields ``xyz``.
- **``child-xyz``**: add attribute ``xyz`` to all children.
- **``nested-field``**: Name of the field of the requested resource to
display. Useful when the source url is auto-generated (for instance,
with the attribute ``bind-resources``) but you need to display
another field of this source.
- **``default-xyz``**: Value displayed for field ``xyz`` when it’s
empty or not defined
- **``empty-widget``**: Widget to display when there is no element in
the container
- **``empty-value``**: To display a value in the empty widget. It can
be accessed in the widget like this: ``${value}``
**API:** In Javascript, you have access to different variables and
methods on a ``sib-display`` element: - ``sibDisplay.resource``: returns
the Proxy of the current resource - ``sibDisplay.resource.clearCache()``
(async): clears the cache of the store for this resource -
``sibDisplay.resourceId``: returns the id of the current resource
sib-form
~~~~~~~~
Receives the URL of a ressource via its ``data-src`` attribute, and
displays a form to edit the resource. If given the URL of a container of
ressources, and displays a creation form to add a resource to the
container.
.. code:: html
<sib-form data-src="http://localhost:8000/todos/"></sib-form>
**Attributes:**
- **``label-xyz``**: When displaying a form, the default labels are the
fields names of the model. If you want something fancier, you can set
this attribute. i.e. ``label-username="Your name"``
- **``naked``**: When the attribute is set, the submit button will be
removed. It’s particularly useful to prevent the nested forms to
display their own submit button.
- **``upload-url-xyz``**: URL to upload file for field ``xyz``, it
automatically set ``widget-xyz`` to ``sib-form-file`` if net defined.
It’s particularly useful with a dropdown field.
- **``submit-button``**: Text of the submit button of the form.
- **``range-xyz``**: URL of a container which list the accepted values
for the field ``xyz``. It’s particularly useful with a dropdown
field.
- **``partial``**: Add this attribute when the form does not include
all the fields of the resource to update.
sib-map
~~~~~~~
Receives the URL of a resource or of a container of resources via its
``data-src`` attribute, and displays it on a **map**. Here is the list
of fields needed to display the resources properly:
- ``name``: name of the event displayed on the calendar
- ``lat``: latitude on which the resource will be displayed
- ``lng``: longitude on which the resource will be displayed
Like for sib-display, filters and searching capabilities can be easily
added to interact with the list of data being displayed.
sib-widget
~~~~~~~~~~
Take a ``name`` as an attribute and a HTML template, and create an HTML
custom element you can use as a widget. i.e.
.. code:: html
<!-- Your custom widget to display a customer... -->
<sib-widget name="my-custom-widget">
<template>
<h2>Customer name: ${value.name}</h2>
</template>
</sib-widget>
<!-- ... used in a sib-display -->
<sib-display
data-src="http://server/projects/"
fields="name, customer"
widget-customer="my-custom-widget"
></sib-display>
In a ``sib-widget``, you have access to these values:
- **``id``**: id of the displayed resource
- **``value``**: all the values of the current resources
- **``name``**: name of the current field
- **``label``**: if defined, label of the current field
- **``range``**: if defined, range of the current field
..
NB: Do not forget to define your custom template in a ``<template>``
tag. Otherwise, your widget will not be declared properly.
Widgets
-------
The following widgets are available:
Display widgets
~~~~~~~~~~~~~~~
- **``sib-display-value``** (default): Displays the value.
- **``sib-display-div``**: Displays the ``value`` inside a ``<div>``
HTML tag.
- **``sib-display-labelled-div``**: Displays the ``value`` inside a
``<div>`` HTML tag, after the ``label`` contained in a ``<label>``
HTML tag
- **``sib-display-multiline``**:Displays the ``value`` inside a
``<div>``, ``\n`` are replaced by ``<br>``.
- **``sib-display-labelled-boolean``**: Displays the ``label`` inside a
``<label>`` HTML tag if the ``value`` is true
- **``sib-display-img``**: Inserts the ``value`` as the src attribute
value of an ``<img>`` HTML tag.
- **``sib-display-mailto``**: Displays a link inside a ``<a>`` HTML tag
with a ``mailto:value`` as path. If a label is defined for this
field, it’s displayed as the content of the link.
- **``sib-display-tel``**: Displays a link inside a ``<a>`` HTML tag
with a ``tel:value`` as path
- **``sib-display-link``**: Displays a link inside a ``<a>`` HTML tag
with the value as path, and the label as text content
- **``sib-display-date``**: Displays a date in the browser’s default
locale format
- **``sib-display-date-time``**: Displays a date and a time in the
browser’s default locale format
Form widgets
~~~~~~~~~~~~
- **``sib-form-label-text``**: Inserts an ``<input/>`` HTML tag of type
“text”, in a ``<label>`` HTML tag.
- **``sib-form-checkbox``**: Inserts an ``<input/>`` HTML tag of type
“checkbox”, in a ``<label>`` HTML tag.
- **``sib-form-date``**: Inserts an ``<input/>`` HTML tag of type
“date”, in a ``<label>`` HTML tag.
- **``sib-form-range-date``**:
- **``sib-form-json``**: Inserts an ``<input/>`` HTML tag of type
“text”, in a ``<label>`` HTML tag, and with its ``value`` converted
from JSON to string
- **``sib-form-placeholder-text``**: Inserts an ``<input/>`` HTML tag
of type “text”, with the ``label`` as placeholder.
- **``sib-form-textarea``**: Inserts an ``<textarea>`` HTML tag in a
``<label>`` HTML tag.
- **``sib-form-dropdown``**: Inserts a ``<select>`` HTML tag to select
a unique value from a list. The list is provided via the
``range-xyz``, which expects a container’s URL. **xyz** is the name
of the field using the ``sib-form-dropdown`` widget.
- **``sib-form-placeholder-dropdown``**: Inserts a ``<select>`` HTML
tag to select a unique value from a list. It has no label but a
default disabled value as a label
- **``sib-form-auto-completion``**: Inserts a ``<input />`` HTML tag
and load an autocomplete plugin. The list is provided via the
``range-xyz``, which expects a container’s URL. **xyz** is the name
of the field using the ``sib-form-auto-completion`` widget.
- **``sib-form-number``**: Inserts an ``<input/>`` HTML tag of type
“number”, in a ``<label>`` HTML tag.
- **``sib-form-range-number``**:
- **``sib-form-file``**: Inserts an ``<input/>`` and an
``<input type="file"/>``. when a file is selected it’s uploaded, URL
of file is returned by request and set as the ``<input/>`` value. The
upload URL is provided via the ``upload-url`` attribute.
- **``sib-form-hidden``**: Inserts an ``<input/>`` HTML tag of type
“hidden”, in a ``<label>`` HTML tag.
Multiple widgets
~~~~~~~~~~~~~~~~
- **``sib-multiple``** (default for display): Inserts all the widgets
in a ``<sib-multiple>`` tag.
- **``sib-multiple-form``** (default for forms): Inserts all the
widgets in a ``<sib-multiple-form>`` tag, with a “remove” button for
each widget, and an “add” button.
- **``sib-multiple-select``**: Inserts all the values as ``<option>``
in a ``<select>`` tag with a ``multiple`` attribute.
Set widgets
~~~~~~~~~~~
- **``sib-set-default``** (default): Inserts content directly in the
set tag.
- **``sib-set-div``**: Inserts content in a ``<div/>`` HTML tag
- **``sib-set-ul``**: Inserts content in a ``<ul/>`` HTML tag
- **``sib-set-fieldset``**: Inserts content in a ``<fieldset/>`` HTML
tag
Actions widgets
~~~~~~~~~~~~~~~
- **``sib-action``**: Displays a link inside a ``<sib-link>`` tag with
``src`` for the ``data-src`` attribute, ``value`` for the ``next``
attribute and ``label`` as text content
.. _solid-ac-checker:
solid-ac-checker
================
Hides an element from the page if the current user doesn’t have the
required permissions on it.
.. code:: html
<solid-ac-checker permission="acl:Write" bind-resources>
<solid-route name="member-edit">
<div>Edit</div>
</solid-route>
</solid-ac-checker>
Mixins
------
This component uses the following mixins:
* :ref:`store-mixin <store-mixin>`
Please check their documentation to know more about their capabilities.
Specific attributes
-------------------
``permission``
~~~~~~~~~~~~~~
Displays the element if the user has the specified right
``no-permission``
~~~~~~~~~~~~~~~~~
Displays the element if the user has not the specified right
Possible values:
- `acl:Read <https://github.com/solid/web-access-control-spec#aclread>`__
- `acl:Write <https://github.com/solid/web-access-control-spec#aclwrite>`__
- `acl:Append <https://github.com/solid/web-access-control-spec#aclappend>`__
- `acl:Control <https://github.com/solid/web-access-control-spec#aclcontrol>`__
Mixin attributes
-----------------
**From store-mixin :**
.. include:: ../Mixins/store-mixin.rst
:start-line: 21
:end-before: Events
\ No newline at end of file
.. _sib-auth:
sib-auth
========
Allows your users to login via a given OIDC provider.
Installation
--------------
Initialize ``sib-auth`` in your HTML file :
.. code:: html
<script type="module" src="https://unpkg.com/@startinblox/oidc@latest"></script>
<sib-auth>
<sib-auth-provider
data-authority="https://test-paris.happy-dev.fr/openid/"
data-id="paris"
></sib-auth-provider>
</sib-auth>
`You'll find here the detail of the attributes configuration. <https://github.com/IdentityModel/oidc-client-js/wiki#usermanager>`__
Set an OIDC provider to your server
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The Django package associated is there => https://github.com/jblemee/django-oidc-provider
More documentation here => https://django-oidc-provider.readthedocs.io/en/latest/
Don't forget to set up your RSA key:
.. code:: bash
python3 ./manage.py creatersakey
Setup your login button
~~~~~~~~~~~~~~~~~~~~~~~~~~
Here is an example to make you understand the logic:
.. code:: html
<button id="login">Login</button>
<!-- wherever you want in your interface -->
<script>
// wherever you want in your project
document.querySelector('#login').addEventListener('click', () => {
document.querySelector('sib-auth').login()
});
</script>
Attributes
----------
.. _bind-user:
``bind-user``
~~~~~~~~~~~~~
To associate the currently logged in user to a component, add the bind-user attribute to it.
It will set its ``data-src`` attribute to the currently logged in user's resource URL.
Example:
.. code:: html
<sib-conversation bind-user></sib-conversation>
will result in:
.. code:: html
<sib-conversation data-src="https://your-domain/your-user-uri/3" bind-user></sib-conversation>
``auto-login``
~~~~~~~~~~~~~~
If set, ``auto-login`` will automatically redirect the user to the login page of his
provider if he's not authenticated yet.
Example:
.. code:: html
<sib-auth auto-login>
<sib-auth-provider
data-authority="https://test-paris.happy-dev.fr/openid/"
data-id="paris"
></sib-auth-provider>
</sib-auth>
Methods
-------
``login``
~~~~~~~~~
.. code:: js
document.querySelector('sib-auth').login();
``logout``
~~~~~~~~~~
.. code:: js
document.querySelector('sib-auth').logout();
Get user info
~~~~~~~~~~~~~
.. code:: js
document.querySelector('sib-auth').getUser();
\ No newline at end of file
sib-calendar
~~~~~~~~~~~~
.. _solid-calendar:
solid-calendar
==============
Receives the URL of a resource or of a container of resources via its
``data-src`` attribute, and displays it in a **calendar**. Here is the
......@@ -8,5 +9,44 @@ list of fields needed to display the resources properly:
- ``name``: name of the event displayed on the calendar
- ``date``: date on which the resource will be displayed
Like for sib-display, filters and searching capabilities can be easily
Like for solid-display, filters and searching capabilities can be easily
added to interact with the list of data being displayed.
Mixins
------
This component uses the following mixins:
* :ref:`list-mixin <list-mixin>`
* :ref:`next-mixin <next-mixin>`
* :ref:`store-mixin <store-mixin>`
Please check their documentation to know more about their capabilities.
Mixin attributes
-----------------
**From list-mixin :**
.. include:: ../Mixins/list-mixin.rst
:start-line: 25
**From next-mixin :**
.. include:: ../Mixins/next-mixin.rst
:start-line: 21
**From store-mixin :**
.. include:: ../Mixins/store-mixin.rst
:start-line: 21
:end-before: Events
Events
-------
``resourceSelect``
~~~~~~~~~~~~~~~~~~~
Triggered when an event is clicked on the calendar
.. _solid-delete:
solid-delete
============
Receives the URL of a resource or of a container of resources via its
``data-src`` attribute, and displays a button to delete it when clicked.
.. code:: html
<solid-delete data-src="http://server/conversations/9/"></solid-delete>
Mixins
------
This component uses the following mixin:
* :ref:`next-mixin <next-mixin>`
* :ref:`validation-mixin <validation-mixin>`
Please check their documentation to know more about its capabilities.
Specific attributes
-------------------
``data-src``
~~~~~~~~~~~~
The uri of the LDP resource you want to delete.
``data-label``
~~~~~~~~~~~~~~
The text to display on the delete button.
Mixin attributes
-----------------
**From next-mixin :**
.. include:: ../Mixins/next-mixin.rst
:start-line: 21
**From validation-mixin :**
.. include:: ../Mixins/validation-mixin.rst
:start-line: 17
Events
-------
``save``
~~~~~~~~
Triggered when the resource is successfully deleted.
.. _solid-display:
solid-display
=============
Receives the URL of a resource or of a container of resources via its
``data-src`` attribute, and displays it.
Each field of the displayed
resources can be rendered by a specific widget, either custom or chosen
from the default ones. Filters and searching capabilities can be easily
added to interact with the list of data being displayed.
.. code:: html
<solid-display
data-src="https://server/users/"
fields="first_name, last_name"
></solid-display>
To make the styling easier, if the ``solid-display`` shows a resource,
a ``solid-resource`` attribute is automatically added to the element.
If it's a container, a ``solid-container`` attribute is added.
Then, you can target your elements with the CSS rules ``solid-display[solid-resource]``
or ``solid-display[solid-container]``.
Mixins
------
This component uses the following mixins:
* :ref:`counter-mixin <counter-mixin>`
* :ref:`federation-mixin <federation-mixin>`
* :ref:`filter-mixin <filter-mixin>`
* :ref:`grouper-mixin <grouper-mixin>`
* :ref:`highlighter-mixin <highlighter-mixin>`
* :ref:`list-mixin <list-mixin>`
* :ref:`next-mixin <next-mixin>`
* :ref:`paginate-mixin <paginate-mixin>`
* :ref:`required-mixin <required-mixin>`
* :ref:`paginate-mixin <server-pagination-mixin>`
* :ref:`sorter-mixin <sorter-mixin>`
* :ref:`store-mixin <store-mixin>`
* :ref:`widget-mixin <widget-mixin>`
Please check their documentation to know more about their capabilities.
Specific attributes
-------------------
``fields``
~~~~~~~~~~
List of fields displayed.
By default, all displayed fields are direct children of ``<solid-display>``.
More details on its use below (in **widget-mixin attributes**).
``child-[field]``
~~~~~~~~~~~~~~~~~
Add attribute ``[field]`` to all children.
Mixin attributes
-----------------
**From counter-mixin :**
.. include:: ../Mixins/counter-mixin.rst
:start-line: 17
**From filter-mixin :**
.. include:: ../Mixins/filter-mixin.rst
:start-line: 18
**From grouper-mixin :**
.. include:: ../Mixins/grouper-mixin.rst
:start-line: 18
**From highlighter-mixin :**
.. include:: ../Mixins/highlighter-mixin.rst
:start-line: 17
**From list-mixin :**
.. include:: ../Mixins/list-mixin.rst
:start-line: 25
**From next-mixin :**
.. include:: ../Mixins/next-mixin.rst
:start-line: 21
**From paginate-mixin :**
.. include:: ../Mixins/paginate-mixin.rst
:start-line: 17
**From required-mixin :**
.. include:: ../Mixins/required-mixin.rst
:start-line: 17
**From sorter-mixin :**
.. include:: ../Mixins/sorter-mixin.rst
:start-line: 17
**From store-mixin :**
.. include:: ../Mixins/store-mixin.rst
:start-line: 21
:end-before: Events
**From widget-mixin :**
.. include:: ../Mixins/widget-mixin.rst
:start-line: 18
Widgets
-------
By default, the widget used is ``<solid-display-div>``. Cf the
:ref:`Widget <reference>` page for more info.
Events
-------
``resourceSelect``
~~~~~~~~~~~~~~~~~~~
Triggered when an resource is clicked.