From: Dan Brown Date: Wed, 13 Nov 2024 16:21:58 +0000 (+0000) Subject: Added glossary hack X-Git-Url: http://source.bookstackapp.com/hacks/commitdiff_plain/aae83ab11b11c6f80552e5bb4ea79dd2442e94fa Added glossary hack --- diff --git a/content/dynamic-glossary/head.html b/content/dynamic-glossary/head.html new file mode 100644 index 0000000..85028fb --- /dev/null +++ b/content/dynamic-glossary/head.html @@ -0,0 +1,193 @@ + + \ No newline at end of file diff --git a/content/dynamic-glossary/index.md b/content/dynamic-glossary/index.md new file mode 100644 index 0000000..2233f70 --- /dev/null +++ b/content/dynamic-glossary/index.md @@ -0,0 +1,46 @@ ++++ +title = "Dynamic Glossary" +author = "@ssddanbrown" +date = 2024-11-13T16:20:00Z +updated = 2024-11-13T16:20:00Z +tested = "v24.10.2" ++++ + +This hack adds the ability to write global and book-level glossaries, which will then be utilised when viewing pages by marking those words in page content with a dashed underline. On hover, the set definitions will show in a popup below the word. + +#### Considerations + +- This will only work for single-word terms (terms without a space). Multi-word terms would require more complex and computationally costly logic. +- The term matching is quite simplistic and case-insensitive, with words/terms trimmed, lower-cased, and with common punctuation trimmed before matching. +- This runs in the browser after a page has loaded, so the term highlighting may seem to pop-in just after page load. +- This will perform requests in the background to load in the definitions from other pages. +- The glossary terms are stored after the first fetch, so changes to the glossary may not be represented. You can force a refresh of this by opening a relevant "glossary page". +- Accessibility has not been considered in this implementation. +- This will only work for standard page viewing, not for exports and other page viewing options. + +#### Usage + +"Glossary pages" are just normal BookStack pages, but with their content in the format: + +``` +Term: Description for term +``` + +For example: + +``` +BookStack: An open source documentation platform built on a PHP & MySQL stack. + +Cat: A type of small house tiger that constantly demands food. +``` + +Create a page somewhere in your instance to act as the global glossary. +With the hack code added to the "Custom HTML Head Content", find the `defaultGlossaryPage` and tweak the path to match that of your created global glossary page. You should only need to change the `my-book` and `main-glossary` parts of the text, don't change the format or other parts of that. Then save your changes. + +That's the global glossary configured. Any matching terms in page content will then be converted to a highlighted term on page view. The hack will also look-up a book-level glossary page at the `/pages/glossary` URL. The terms in this book-level glossary page will override those in the global glossary. You can create this in the same manner as the global glossary, but it just needs to be part of the intended book, and named "Glossary", so that it's available on the expected path within the book. + +Glossary terms are stored after being loaded, to avoid extra requests and loading time. You can view a glossary page to force the terms to be re-loaded and re-stored from that glossary page. + +#### Code + +{{}}