BookStack Hacks

This part of the site lists available "hacks" that can be applied to customize BookStack or extend its functionality. These hacks are not official supported and 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. »

Last Tested On v24.10.2

Prune Revisions Command

This hack registers a custom command using the logical theme system, which will prune the revisions of a specific page to just those with a changelog provided (in addition to the current revision), before resetting the revision numbers across the remaining versions to be sequential without gaps. This will also reset the overall revision count on the page. »

Last Tested On v24.05.1

Format Webhooks for Pushover

This is a hack to adapt outgoing webhooks from BookStack so that they are directly compatible with the pushover message API. It specifically targets pushover webhook endpoints, so this won’t affect non-pushover webhooks. »

Last Tested On v23.08.3

WYSIWYG Docx Import

This hack adds the ability to import “.docx” files into the WYSIWYG editor, by dragging and dropping a “docx” file into the editor area. The file contents are converted to HTML then inserted into the editor at the current cursor position. »

Last Tested On v24.05.2

WYSIWYG Editor Autocomplete Suggestions

This hack adds custom autocomplete suggestions to the WYSIWYG page editor (TinyMCE). An autocomplete popup box will show after a “trigger character” (: as configured by default in this hack) is entered after a space, or at the start of a line. Pressing the Escape key will close the autocompleter. »

Last Tested On v23.05

WYSIWYG Editor Footnotes

This hack adds some level of “footnote” support to the WYSIWYG editor. A new “Footnote” button is added to the toolbar, next to the “Italic” button, that allows you to insert a new footnote reference. Footnotes will automatically be listed at the bottom of the page content. The reference numbering is automatic, chronologically from page top to bottom. New references will change existing numbering if inserted before. »

Last Tested On v23.05

Custom WYSIWYG Editor Buttons

This hack provides an example of adding custom actions to the WYSIWYG page editor (TinyMCE). By default, this adds an additional “…” overflow menu to the end of the WYSWIYG toolbar, which contains a single new “Insert Cat” button that has a custom icon. When clicked, this adds a placeholder kitten image into the page. »

Last Tested On v23.02

IFrame Specific Tweaks

This hack will add custom styles & scripts, hiding many parts of the interface while adding additional light/dark mode control, intended to provide a cleaner view that’s suitable for use within iframes embedded on external pages. »

Last Tested On v24.02.3

Page Export Contents List

This hack uses the visual theme system to customize the page export template file, used for both PDF and HTML exports, to add a simple linked “Contents” list to the top of the file, generated from the headers within the document. »

Last Tested On v23.02.1

Render TeX/LaTeX Mathematics with MathJax

This hack will allow TeX/LaTeX mathematic markup to be rendered within a page on BookStack using MathJax. Inline math can be surrounded with $ and math blocks can be surrounded with $$ or \[...\]. Additionally LaTeX environments and \ref{...} commands will be processed. »

Last Tested On v23.02

Simple Latest Pages RSS Feed

This is a hack to add a simple latest-page RSS feed to the BookStack using the logical theme system. A YouTube video covering the build and use of this customization can be found here. »

Last Tested On v22.11.1

Custom Login Form Message

This logical theme system hack allows you to show a custom message on the login form, above the inputs and below the title. »

Last Tested On v22.11.1

Force Page Content Links to Open in New Tabs

This hack will force HTML links, within the main content body of a page, to open in a new tab. »

Last Tested On v22.11.1

Autosort Tagged Books

This is a hack to BookStack to enable auto-sorting of book chapters and pages upon page or chapter create/update. It sorts by name, ascending, with chapters first. By default it will run for any book with an Autosort tag assigned. »

Last Tested On v24.05.2

Notify Page Updates for Tagged Books

This allows you to configure notifications to be sent to users within roles defined via tags applied to parent books. For example, if a tag with name Notify and value Admins, Viewers is applied to a book, updates to pages within will be notified via email to all users within the “Admins” and “Viewers” roles. »

Last Tested On v24.05.3

Notify Updates for Favourited pages

This hack sends out page update notification emails to all users that have marked that page as a favourite. Considerations The sending of emails may slow down page update actions, and these could be noisy if a user edits a page many times quickly. You may run into email system rate-limits with the amount of emails being sent. Options You can customize the email message, if desired, by editing the lines of text within the toMail part at around lines 23-25 of the functions.php code. Code functions.php Download | Logical Theme System 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 <?php use BookStack\Activity\ActivityType; use BookStack\Activity\Notifications\Messages\BaseActivityNotification; use BookStack\Entities\Models\Page; use BookStack\Facades\Theme; use BookStack\Theming\ThemeEvents; use BookStack\Users\Models\User; use Illuminate\Notifications\Messages\MailMessage; // This customization notifies page-updates via email to all users that have marked // that updated page as a favourite, excluding the user performing the update // This notification class represents the notification that'll be sent to users. // The text of the notification can be customized within the 'toMail' function. class PageUpdatedNotification extends BaseActivityNotification { public function toMail($notifiable): MailMessage { /** @var Page $page */ $page = $this->detail; $updater = $this->user; return (new MailMessage()) ->subject('BookStack page update notification') ->line("The page \"{$page->name}\" has been updated by \"{$updater->name}\"") ->action('View Page', $page->getUrl()); } } // This function does the work of sending notifications to the relevant users that have // marked the given page as a favourite. function notifyThoseThatHaveFavouritedPage(Page $page): void { // Find those we need to notify, and find the current updater of the page $userIds = $page->favourites()->pluck('user_id'); $usersToNotify = User::query()->whereIn('id', $userIds) ->where('id', '!=', $page->updated_by) ->get(); $updater = User::query()->findOrFail($page->updated_by); // Send a notification to each of the users we want to notify foreach ($usersToNotify as $user) { $user->notify(new PageUpdatedNotification($page, $updater)); } } // Listen to page update events and kick-start our notification logic Theme::listen(ThemeEvents::ACTIVITY_LOGGED, function (string $type, $detail) { if ($type === ActivityType::PAGE_UPDATE && $detail instanceof Page) { notifyThoseThatHaveFavouritedPage($detail); } }); »

Last Tested On v24.05.2

Username-based Login

This is a hack to BookStack, using the theme system, so that login presents itself as a username. Upon login attempt, this will match to a user of <username>@<configured-domain> within the database. »

Last Tested On v24.05.4