Giter Club home page Giter Club logo

silverstripe-fail-whale's Introduction

SilverStripe Fail Whale 🐳

SilverStripe error pages, just without the pages.

What is this?

CMS-editable error pages (404, 500 etc), without clogging up the site tree and confusing content authors who rarely (if ever) need to edit them. Also works without the CMS module installed.

How does it work?

Error documents are DataObjects which can be edited via the “Settings” area of the CMS. There is no versioning or draft/live stages, so all changes are published immediately. On encountering an error, SilverStripe will look for a matching error document and render it if one is found.

Cached content is still stored in assets/error-<code>.html files, and it’s still possible to use custom templates if required.

When the CMS module is installed, PageController::init() will be called before rendering the error document to ensure any requirements are included. If you need different behaviour in this method in the event of an error, you can check if ($this->data()->ClassName === ErrorDocument::class).

How do I use custom templates?

As an example, in the event of a 404 error this module will look for the following templates:

  • <theme>/templates/Bigfork/SilverStripeFailWhale/Model/Layout/ErrorDocument_404.ss
  • <theme>/templates/Bigfork/SilverStripeFailWhale/Model/Layout/ErrorDocument.ss
  • <theme>/templates/Bigfork/SilverStripeFailWhale/Model/ErrorDocument.ss

If none of the above templates are present and you have the CMS module installed, the module will fall back to using the default Page templates.

What’s with the name?

The “Fail Whale” is an illustration of a white beluga whale held up by a flock of birds, originally named “Lifting a Dreamer”, illustrated by Australian artist Yiying Lu. It was used during periods of downtime by the social networking service Twitter.

http://www.whatisfailwhale.info/

h/t to @andrewandante for the suggestion!

silverstripe-fail-whale's People

Contributors

kinglozzer avatar micschk avatar

Stargazers

 avatar  avatar Fred Condo avatar Nic avatar Lukas avatar Georgy Malanichev avatar Kristian Daugaard avatar Andrew Paxley avatar

Watchers

Michal Kleiner avatar James Cloos avatar  avatar Colin Richardson avatar  avatar

Forkers

micschk

silverstripe-fail-whale's Issues

Error on dev/build if templates don’t exist

None of the following templates could be found: Array ( [0] => Bigfork\SilverStripeFailWhale\Model\ErrorDocument_404...

Ideal outcome: display a warning on the dev/build output instead... if feasible

Templates-not-found warning if no (custom) themes defined

Screenshot 2022-06-25 at 15 44 29

I'd propose to append the framework Controller template to the array in order to fallback to that if nothing else found (like the framework does).

ErrorDocument::render():

            ...
            $templatesFound[] = $page->getViewerTemplates();

            // Fallback to framework template in case no themes defined (prevent template-not-found warning)
            $templatesFound[] = [ Controller::class ];

It would seem we'd need to include that twice, once for if PageController exists and once if not;

        if (class_exists(\PageController::class)) {
            ...
            $templatesFound[] = [ Controller::class ];

            return $controller->renderWith(array_merge(...$templatesFound), $this);
        }

        $templatesFound[] = [ Controller::class ];

        return $this->renderWith(array_merge(...$templatesFound));

Slightly simplify ErrorDocument::render() call to renderWith()

Is there a reason why ErrorDocument::render() calls renderWith() with two slightly different signatures? In the PageController block the call includes $this as the second argument, the other call doesn't. If that's not intentional maybe renderWith() could just be called once for both cases? In that case we also just have to add the fallback template once.

        if (class_exists(\PageController::class)) {
            ...
        }

        $templatesFound[] = [ Controller::class ];

        return $controller->renderWith(array_merge(...$templatesFound), $this);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.