Module reahl.web.libraries¶
New in version 3.2.
Reahl uses CSS and JavaScript from other projects. The CSS and JavaScript world has its own ecosystem of tools that allow you to do various things, for example:
Compile your own customised CSS using a CSS preprocessor like Sass
Manage the versions and interdependencies of such projects.
Some code is hosted on Content Delivery Networks (CDNs).
Some code is minified.
This module is a start towards supporting such “front-end frameworks” which Reahl depends upon. Currently, Reahl merely includes the correct versions of the front-end libraries it needs and a user is not able to customise these in any way. In the future we hope to extend this infrastructure to be able to make use of everything the JavaScript / CSS tool ecosystem offers.
Reahl also contains its own JavaScript and CSS code. Where we do this, our own code is also managed using this same infrastructure.
If you write your own Widgets that make use of CSS or JavaScript,
creating a Library
is the way to do it going forward.
LibraryIndex¶
-
class
reahl.web.libraries.
LibraryIndex
(*libraries)¶ An ordered collection of
Library
instances.A LibraryIndex instance is available in the configuration as web.config.frontend_libraries. All the
Library
instances contained in web.config.frontend_libraries are included on anyHTML5Page
.Libraries in a LibraryIndex are included on a page in the order that they appear in the LibraryIndex.
- Parameters
libraries –
Library
instances (in order) to initialise this LibraryIndex with.
-
clear
()¶ Removes all Libraries from the list.
-
add
(library)¶ Adds a Library to the end of the list.
-
__contains__
(name)¶ An implementation of the in operator, so that one can ask whether a library with given name is in this index.
- Parameters
name – The unique name of the Library to check for.
Library¶
-
class
reahl.web.libraries.
Library
(name)¶ A frontend-library: a collection of CSS and JavaScript code that can be used with Reahl.
To create your own Library, subclass from this class and set its attributes to indicate which files to include as part of it and where to find them.
To use a library, add it to the web.config.frontend_libraries config setting. The CSS and JavaScript files of all such configured libraries are automatically included in any
HTML5Page
.- Parameters
name – A unique name for this Library.
-
name
¶ The unique name of this Library
-
egg_name
¶ The component (egg) that contains the files of this library
-
shipped_in_directory
¶ The directory that contains the files of this library (relative to the egg root)
-
files
¶ The JavaScript and CSS files that form part of this library (relative to the shipped_in_directory)
JQuery¶
ReahlBootstrap4Additions¶
-
class
reahl.web.libraries.
ReahlBootstrap4Additions
¶ Reahl specific JavaScript and CSS for use with
Bootstrap4
.
JQueryUI¶
-
class
reahl.web.libraries.
JQueryUI
¶ A heavily customised subset of version 1.12.1 of JQuery UI.
Only contains the Widget Factory and :tabbable, :focusable Selector.