Skip to content

Instantly share code, notes, and snippets.

View ssddanbrown's full-sized avatar

Dan Brown ssddanbrown

View GitHub Profile
@ssddanbrown
ssddanbrown / bookstack-backup.sh
Last active March 18, 2024 04:28
bookstack-backup
#!/bin/bash
# Directory to store backups within
# Should not end with a slash and not be stored within
# the BookStack directory
BACKUP_ROOT_DIR="$HOME"
# Directory of the BookStack install
# Should not end with a slash.
BOOKSTACK_DIR="/var/www/bookstack"
@ssddanbrown
ssddanbrown / export-body-start.blade.php
Last active January 17, 2024 12:29
BookStack PDF Export header & footer
@if ($format === 'pdf')
<style media="print">
.print-header-footer {
position: fixed;
width: 100%;
}
.print-footer {
position: fixed;
bottom: -40px;
@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 / export-books.php
Last active January 2, 2024 10:46
BookStack-Export-Books
#!/usr/bin/env php
<?php
// API Credentials
// You can either provide them as environment variables
// or hard-code them in the empty strings below.
$apiUrl = getenv('BS_URL') ?: ''; // http://bookstack.local/
$clientId = getenv('BS_TOKEN_ID') ?: '';
$clientSecret = getenv('BS_TOKEN_SECRET') ?: '';
@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 / _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
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 / docker-compose.yml
Last active July 6, 2023 06:24
bookstack-npm-docker-compose
---
version: "2"
services:
bookstack:
image: lscr.io/linuxserver/bookstack
container_name: bookstack
environment:
- PUID=1000
- PGID=1000
- APP_URL=https://wiki.bookstackapp.com
@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 = '';