LOI has a number of search pages and since the site is massive, it's not feasible for it to use the standard static search approach for using standard exclusions (since the process would have to parse 19,000 files for a search of 300, for instance). So here's the process of creating a new search page:
1. Create a new map-entry in the code/generated/create_search_pages_master.xsl. The id should be the document's id (i.e. search_blort) and the value should be the search page's title ("Search across all the Blorts"). Note that this step may not be necessary in future if the searches pages are kept statically in the site (i.e. if custom text needs to be added etc--at that rate, the pages should just be stashed in an about folder and generated like the rest of the pages).
2. Add new metadata for the XHTML5 files in xhtml_head_module.xsl. The way I've done it so far is to add a new function (loi:createBlortMeta()) that is called if the document needs it (i.e. IF $documentType = "blort" THEN loi:createBlortMeta()). The blort meta function should create
<meta>
tags as per the Static Search documentation (add a meta with a class of staticSearch.(bool|num|date|desc), a `@name` and a `@value`): https://github.com/projectEndings/staticSearch/blob/master/docs/staticSearch.html.
You should also add a new class--call it blortMeta--so that your config can pinpoint that class of metas not to exclude (a weird double negative: by default the static search includes all filters [aka all meta tags] so we need to exclude all of them EXCEPT the blortMetas since we want those to show up on the search page).
3. Create a new config at the root of production, likely by copy pasting. It should likely contain all the same weighting rules as the other configs, but you will need to change the search file path (from whatever_search to blort_search). You'll also want to add a filter exclusion for everything that's not a blort meta--something like so:
<exclude xpath="meta[not(contains-token(@class,'blortMeta'))]" type="filter"/>
4. In the build, create a new task for creating your blort search and, in that search, use the custom <createSearch>
task. This task is just a simple function, basically, for doing the repeated operations for generating the sub-search pages. It just copies all of the necessary files over, does the search on them, moves all the files back out, and deletes the copied files. So it'll look something like:
<createSearch
configPath="../search_config_blort.xml"
searchTempDir="${site.dir}/blort"
pattern="blort_**.html"
searchFile="blort_search.html"
/>
Where:
- configPath is the path to the configuration
- searchTempDir is the same of the temporary search folder (name it whatever you'd like, but I'd use blort)
- pattern is the match pattern for the files (i.e. include="{$pattern}"). blort_* for instance.
- searchFile is the name of the search file html; here it's blort.html
5. Add that target to the main search target as a depends, and then run the search as either part of the full build (just ant) or by itself if you have a copy of the build already completed (ant search)
- Note that once all the searches are complete, the search pages (all pages starting search_) are passed through a quick XSLT that changes the styling/grouping of the search pages just to make it more consistent with the LOI UI. That might change in future or simply be eliminated; it is not a crucial step--just an aesthetic one.
- Also note that there is a process during the getStaticSearch target (the first one in the build's search target) that modifies staticSearch/build.xml such that the JVM is forked and given 4GB of memory; we haven't added any way for the static search codebase to get more memory conditionally (and we don't want to force people to use 4GB of RAM), so this is just a quick hack around that.