Hacks & Customizations
These hacks are unsupported customizations meant as unofficial workarounds.
They can cause instability, introduce issues and may conflict with future updates. Apply at your own risk!

Simple Latest Pages RSS Feed

  • Author: @ssddanbrown
  • Created: 12th Feb 2023
  • Updated: 12th Feb 2023
  • Last Tested On: v22.11.1

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.

Considerations

This does not take into account access control at all or enforce login, the RSS data endpoint will be publicly accessible. The code will effectively use the permissions of the “Guest” user.

Options

  • The 25 in functions.php controls the count of rss feed items to show.
  • created_at in functions.php can be changed to updated_at to instead reflect the latest updated pages.

Code

functions.php
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
<?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']);
});
rss.blade.php
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
<?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>

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