Skip to content

Instantly share code, notes, and snippets.

@ssddanbrown
Last active October 1, 2023 12:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssddanbrown/c251005f6492565cb2449bcd5d7b07db to your computer and use it in GitHub Desktop.
Save ssddanbrown/c251005f6492565cb2449bcd5d7b07db to your computer and use it in GitHub Desktop.
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.

Note

These customizations are not officially supported any may break upon, or conflict with, future updates. Quickly tested on BookStack v22.11.1.

<?php
use BookStack\Entities\Models\Page;
use Illuminate\Support\Facades\Route;
Route::get('/rss/pages/new', function() {
$pages = Page::query()
->visible()
->orderBy('created_at', 'desc')
->take(25)
->get();
return response()->view('rss', ['pages' => $pages], 200, ['Content-Type' => 'text/xml']);
});
<?xml version="1.0"?>
<rss version="2.0">
<channel>
<title>Latest BookStack Pages</title>
<link>{{ url('/') }}</link>
<description>Latest pages in our BookStack instance</description>
<lastBuildDate>{{ date(DATE_RSS) }}</lastBuildDate>
@foreach($pages as $page)
<item>
<title>{{ $page->name }}</title>
<link>{{ $page->getUrl() }}</link>
<description>{{ $page->getExcerpt() }}</description>
<pubDate>{{ $page->created_at->format(DATE_RSS) }}</pubDate>
<guid>page#{{ $page->id }}</guid>
</item>
@endforeach
</channel>
</rss>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment