Documentation on gather-js-jq plugin for Collection

Usage

Other render plugins will provide custom javascript (aka ECMA) or JQuery files to be served with an html page. This plugin takes those files/links and deals with them so that they can be served with the HTML in the content files. This requires modification of the templates, and js files in the plugin directory will need to be copied to the correct output directory.

In addition, the order in which JS / ECMA libraries are loaded may be important, eg., leaflet-providers.js must load after the leaflet library. This is enabled by supplying an ordering parameter. The default ordering is 0. So any ordering a number greater than 0 will go after all 0-order files.

For example, within the config.raku of the LeafletMap plugin, we have


    :js-link(q:to/JS/),
        src="https://unpkg.com/[email protected]/dist/leaflet.js"
        integrity="sha512-BB3hKbKWOc9Ez/TAwyWxNXeoV9c1v6FIeYiBieIWkpLjauysF18NzgR1MBNBXf8/KABdlkX68nAhlwcDFLGPCQ=="
        crossorigin=""
        JS
    :js-script(['leaflet-providers.js',1]),

The Array has the name of a local (see below) js file that has an ordering parameter of 1.

Local javascript files

The js-script key in the other plugin's config file is assumed to be a filename containing text that is to be copied into the destination folder.

This plugin copies all script files to the appropriate sub-directory of the destination directory, and configures the templates to serve them.

The <script> ... </script> tags will be added by the plugin.

Remote javascript

The js-link key in the other plugin's config file is taken to be the URL of the remote source. The plugin configures the templates to access the source.

When a js-link (or jquery-link) is given in the config, the whole of the string is included inside <script ... > , so it is necessary to provide the src="..." as well. This is to allow for a link string to have other attributes, such as cross-origin and integrity.

Local JQuery

The jquery key in the other plugin's config file is assumed to be the filename of the local source. See local javascript files.

Remote JQuery

The jquery-link key in the other plugin's config file is assumed to be the URL to a JQuery source.

If any jquery or jquery-link key is found, then this plugin will load the jquery lib specified in the config file for this plugin. (If another plugin requires a different, eg. later, version of JQuery, then the config for this plugin must be updated manually).

Bottom

If there is any reason to put a script at the bottom of the page, then use the key js-bottom. This is assumed only to apply to local JS scripts because

  • A script link need only be at the top.

  • A JQuery plugin can be loaded before the DOM is loaded but activated only afterwards.

Collection-Plugin-Development v0.3.0

Development and working repository for Collection plugins

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.