5.14.2 Basics
5.14.2.1 Where to put extensions
Extensions can be site-specific or shared by all sites.
Site-specific extensions are placed in a directory called cocoon in the directory of the site, thus:
<wikidata directory>/sites/<sitename>/cocoon
Cross-site extensions (shared by all sites) are placed in a directory called cocoon in the sites directory, thus:
<wikidata directory>/sites/cocoon
5.14.2.2 How extensions work
The Cocoon framework, on which the Daisy Wiki is build, has a concept called sitemaps. A sitemap describes how to handle a request, i.e. when a request is handled by Cocoon, Cocoon will consult the sitemap in order to know what it has to do. One sitemap can delegate to another sitemap, and that is how Daisy Wiki extensions are integrated in the main Daisy Wiki.
More specifically, all URLs within a site starting with ext/ are delegated to the extension sitemap: first the site-specific one and then the cross-site one.
Thus for the public URLs, this means all paths below:
http://localhost:8888/daisy/<sitename>/ext/
are handled by the extension sitemaps.
5.14.2.2.1 Some more details about the sitemap mounting
(If you are not familiar with Cocoon, don't be bothered that you don't understand all of this yet.)
The Daisy Wiki sitemap consists of two main blocks: one that handles internal requests and one that handles external requests. Each of these two blocks contains a matcher that will forward requests to the extension sitemap. This is illustrated in the following diagram.

In the diagram, the site-specific sitemap is also split into a part handling external requests and a part handling internal requests, but that is free choice of the implementer of the site-specific sitemap. An advantage of putting the internal requests pipeline above the one for external requests, is that for external requests the internal part will be skipped immediately, leading to a faster matching process. Another reason is that in the Daisy Wiki main sitemap, the pipeline for handling external requests starts with various initialisation actions, such as for determining the locale, looking up the site, ... By putting a separate pipeline for internal requests above the one for external requests, duplicate execution of that code is prevented in case of internal requests.
So in general, it is advisable that pipelines which will only be called internally (e.g. included in a document via the cocoon: protocol, or pipelines called from flow-logic), are put in the internal pipelines section.
Previous