Giter Site home page Giter Site logo

perlkonig / grav-plugin-graveyard Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 3.0 13 KB

Returns `410 GONE` status code based on list of intentionally deleted posts

Home Page: https://www.perlkonig.com/demos/graveyard

License: MIT License

PHP 93.41% Twig 6.59%
grav grav-cms gpm plugin http-410 http

grav-plugin-graveyard's Introduction

Graveyard Plugin

Abandonment Notice: I'm afraid I simply don't have the time to maintain my Grav themes and plugins. Those interested in taking over should refer to the "Abandoned Resource Protocol". Feel free to fork and replace. So long, and thanks for all the fish.

The Graveyard Plugin is for Grav CMS. Grav offers powerful routing options to help you when you have to move content, but what it (and most other CMSs) can't do is know when you intentionally deleted something. This plugin lets you record a list of intentionally deleted routes. When those routes are requested, it emits a proper 410 GONE code instead of the more vague 404 NOT FOUND.

For a demo, visit my blog.

Installation

Installing the Graveyard plugin can be done in one of two ways. The GPM (Grav Package Manager) installation method enables you to quickly and easily install the plugin with a simple terminal command, while the manual method enables you to do so via a zip file.

GPM Installation (Preferred)

The simplest way to install this plugin is via the Grav Package Manager (GPM) through your system's terminal (also called the command line). From the root of your Grav install type:

bin/gpm install graveyard

This will install the Graveyard plugin into your /user/plugins directory within Grav. Its files can be found under /your/site/grav/user/plugins/graveyard.

Manual Installation

To install this plugin, just download the zip version of this repository and unzip it under /your/site/grav/user/plugins. Then, rename the folder to graveyard. You can find these files on GitHub or via GetGrav.org.

You should now have all the plugin files under

/your/site/grav/user/plugins/graveyard

NOTE: This plugin is a modular component for Grav which requires Grav and the Error and Problems plugins to operate.

Usage

The plugin works automatically once enabled. All you have to do is maintain the list of intentionally deleted routes.

To render the the error page, it first checks to see if you have the Error plugin configured for 410s. If so, it will render what you have there. Otherwise it will use the built-in page and text. To customize, follow the instructions for the the Error plugin to create your custom page. You can use this plugin's pages/graveyard.md as a base.

Configuration

Here's the default configuration. To override, first copy graveyard.yaml from the user/plugins/graveyard folder to your user/config/plugins folder.

enabled: true
graveyard:
  - /nonexistent/post

The enabled field turns the plugin off and on.

The graveyard field is a simple list of routes. You can use basic shell wildcards. Refer to the PHP function fnmatch for details. When Grav can't find a given page, it first checks to see if that page's route is on this list. If it is, it emits a 410. Otherwise it emits a 404.

grav-plugin-graveyard's People

Contributors

perlkonig avatar roblui avatar tidiview avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

grav-plugin-graveyard's Issues

Unable to match legacy URLs with file extensions / query strings

(Not sure if this plugin is actively maintained and I really wish I hadn't left this until launch day, welp! That's OK. I have used this plugin successfully in the past.)

I was hoping to 410 some awful legacy script.php?id=n style URLs. I don't seem to be able to get them to match, so they are serving 404s. I've tried single-quoting, backslash-escaping (? and . but mainly ?), and double-backslash escaping the string.

Is there a magic form that works? I suspect Grav's webserver routing is interfering before the plugin kicks in.

can't get error message with language

for these addresses: /fr/ikokujin /ja/ikokujin /en/ikokujin, I have an error message in french as it is the site default language while pages are in french, japanese and english.
It would be nice to make possible that the error message looks over the language of the desired page over the site's language โ˜†

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.