Skip to content

Instantly share code, notes, and snippets.

View ssddanbrown's full-sized avatar

Dan Brown ssddanbrown

View GitHub Profile
@ssddanbrown
ssddanbrown / show.blade.php
Created December 8, 2023 14:20
bookstack-hack-custom-seo-title-description
@php
// This is an override for the page display template to allow
// the HTML title and meta description to be set via tag values.
// The tags must have a name of "@title" or "@description".
// Note: Having long tag values may present badly in other parts
// of the application where tags are shown.
//
// Via the visual theme system, place this at:
// <theme_folder>/pages/show.blade.php
//
@ssddanbrown
ssddanbrown / functions.php
Last active November 29, 2023 20:01
bookstack-hack-send-notifications-to-email-tags
<?php
use BookStack\Activity\ActivityType;
use BookStack\Activity\Models\Tag;
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;
@ssddanbrown
ssddanbrown / functions.php
Last active July 13, 2023 21:14
bookstack-hack-http-call-on-tagged-page
<?php
use BookStack\Entities\Models\Page;
use BookStack\Activity\Models\View;
use BookStack\Users\Models\User;
use Illuminate\Support\Facades\Http;
// Enter the URL of your webhook endpoint between the two quote marks below.
$webhookUrl = '';
@ssddanbrown
ssddanbrown / example.php
Last active March 3, 2023 03:22
console.log in PHP
<?php
// Note: The namespace is required since a 'log' function already exists in PHP
// and that can't be overriden without having an extension installed, so we
// use a namespace which allows us to use the function name.
namespace app;
const console = '';
@ssddanbrown
ssddanbrown / functions.php
Created January 21, 2023 23:06
bookstack autosort tagged books
<?php
use BookStack\Actions\ActivityType;
use BookStack\Entities\Models\Book;
use BookStack\Entities\Models\Chapter;
use BookStack\Entities\Models\Page;
use BookStack\Facades\Theme;
use BookStack\Theming\ThemeEvents;
/**
@ssddanbrown
ssddanbrown / _readme.md
Last active October 1, 2023 12:33
BookStack RSS Feed Loglcal Theme System

This is a hack to add a simple latest-page RSS feed to the BookStack using the logical theme system.

Setup

This uses the logical theme system.

  1. Within the BookStack install folder, you should have a themes folder.
  2. Create a themes/custom/functions.php file with the contents of the functions.php file example below.
  3. Add APP_THEME=custom to your .env file.
  4. Save the contents of the rss.blade.php file below to a themes/custom/rss.blade.php file.
@ssddanbrown
ssddanbrown / functions.php
Created December 1, 2022 03:38
bookstack-notify-page-updates-for-tagged-books
<?php
use BookStack\Actions\ActivityType;
use BookStack\Actions\Tag;
use BookStack\Auth\Role;
use BookStack\Auth\User;
use BookStack\Entities\Models\Page;
use BookStack\Facades\Theme;
use BookStack\Notifications\MailNotification;
use BookStack\Theming\ThemeEvents;
@ssddanbrown
ssddanbrown / functions.php
Last active December 1, 2022 12:24
bookstack-notify-page-updates-for-favourites
<?php
use BookStack\Actions\ActivityType;
use BookStack\Auth\User;
use BookStack\Entities\Models\Page;
use BookStack\Facades\Theme;
use BookStack\Notifications\MailNotification;
use BookStack\Theming\ThemeEvents;
use Illuminate\Notifications\Messages\MailMessage;
@ssddanbrown
ssddanbrown / functions.php
Last active November 25, 2022 10:13
bookstack-username-login-hack
<?php
use BookStack\Facades\Theme;
use BookStack\Theming\ThemeEvents;
use Illuminate\Http\Request;
const EMAIL_DOMAIN = 'admin.com';
Theme::listen(ThemeEvents::WEB_MIDDLEWARE_BEFORE, function(Request $request) {
@ssddanbrown
ssddanbrown / readme.md
Created November 5, 2022 08:59
BookStack permission setup

BookStack Permission Setup

This document provides an approach for setting permissions for your BookStack instance, which allows updating by the login user while providing the webserver with the required permissions.

The below makes the following assumptions, you will need to change these parts of the command to make it work for you:

  • Your normal login user (That you may run updates with) is called barry.
  • Your bookstack folder is located at /var/www/bookstack.
  • Your webserver/php user called www-data (Default on Ubuntu systems).