They can cause instability, introduce issues and may conflict with future updates. Apply at your own risk!
Dynamic Glossary
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:
|
|
For example:
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 <book-url>/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
head.html
|
|
Install as Module (Beta)
If using BookStack v26.03 or later, you can install this hack as a theme module on your BookStack instance by running the below artisan command from your BookStack installation folder:
php artisan bookstack:install-module https://www.bookstackapp.com/hack-modules/dynamic-glossary.zip
Request an Update
Hack not working on the latest version of BookStack?
You can request this hack to be updated & tested for a small one-time fee.
This helps keeps these hacks updated & maintained in a sustainable manner.
Latest Hacks
View Block: Developer Info
This hack registers a custom view block which will show developer-focused details such as: ID for the current item viewed (With click-to-copy ID) A link to open that item in the API A link to the relevant section in the docs This is available to be added to all content-based layouts. »
View Block: Instance Total Stats
This hack registers a custom view block which can be used on any type of home page. This block lists total counts for shelves, books, chapters, pages and users in the system. »
Azure/Entra OIDC User Avatar Images on Initial Login
This hack hooks into the OIDC login process to fetch and assign user avatar images from Azure/Entra on first user login/registration. »
Tag Values in Page Content via Includes
This hack allows you to dynamically pull in the value of tags into page content, via customizing how page include tags are parsed. This hack will attempt to use tags on the page itself, then look to the parent chapter (if existing), then the parent book’s tags. »