This library allows for abstract declaration of available CSS and Javascript resources and their dependencies using html_resource/2. Based on these declarations, html generating code can declare that it depends on specific CSS or Javascript functionality, after which this library ensures that the proper links appear in the HTML head. The implementation is based on mail system implemented by html_post/2 of library html_write.pl.
Declarations come in two forms. First of all http locations are declared
using the http_path.pl library. Second, html_resource/2 specifies HTML
resources to be used in the head
and their dependencies. Resources are
currently limited to Javascript files (.js) and style sheets (.css). It
is trivial to add support for other material in the head. See
html_include//1.
For usage in HTML generation, there is the DCG rule html_requires//1 that demands named resources in the HTML head.
All calls to html_requires//1 for the page are collected and duplicates are removed. Next, the following steps are taken:
Use ?- debug(html(script))
. to see the requested and final set of
resources. All declared resources are in html_resource/3. The edit/1
command recognises the names of HTML resources.
true
(default false
), do not include About itself,
but only its dependencies. This allows for defining an
alias for one or more resources.Registering the same About multiple times extends the properties defined for About. In particular, this allows for adding additional dependencies to a (virtual) resource.
head
using html_post/2. The actual
dependencies are computed during the HTML output phase by
html_insert_resource//1.text/css
and text/javascript
are tried. For example, to
include a =.pl= files as a Prolog script, use:
:- multifile html_head:mime_include//2. html_head:mime_include(text/'x-prolog', Path) --> !, html(script([ type('text/x-prolog'), src(Path) ], [])).