From 0356b61d25af8e9daa595e89280ab0323fb6fa17 Mon Sep 17 00:00:00 2001 From: Robert van Bregt Date: Sat, 11 Aug 2018 14:11:57 +0200 Subject: [PATCH] Initial commit. Plugin generated by devtools. --- CHANGELOG.md | 5 ++++ LICENSE | 21 +++++++++++++++++ README.md | 56 +++++++++++++++++++++++++++++++++++++++++++ blueprints.yaml | 31 ++++++++++++++++++++++++ languages.yaml | 4 ++++ rel-me.php | 63 +++++++++++++++++++++++++++++++++++++++++++++++++ rel-me.yaml | 2 ++ 7 files changed, 182 insertions(+) create mode 100644 CHANGELOG.md create mode 100644 LICENSE create mode 100644 README.md create mode 100644 blueprints.yaml create mode 100644 languages.yaml create mode 100644 rel-me.php create mode 100644 rel-me.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..32895ca --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +# v0.1.0 +## 08/11/2018 + +1. [](#new) + * ChangeLog started... diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2146851 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2018 Robert van Bregt + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..4b43f6c --- /dev/null +++ b/README.md @@ -0,0 +1,56 @@ +# Rel Me Plugin + +**This README.md file should be modified to describe the features, installation, configuration, and general usage of this plugin.** + +The **Rel Me** Plugin is for [Grav CMS](http://github.com/getgrav/grav). Add rel=me links to your website. + +## Installation + +Installing the Rel Me 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)](http://learn.getgrav.org/advanced/grav-gpm) through your system's terminal (also called the command line). From the root of your Grav install type: + + bin/gpm install rel-me + +This will install the Rel Me plugin into your `/user/plugins` directory within Grav. Its files can be found under `/your/site/grav/user/plugins/rel-me`. + +### 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 `rel-me`. You can find these files on [GitHub](https://github.com/metbril/grav-plugin-rel-me) or via [GetGrav.org](http://getgrav.org/downloads/plugins#extras). + +You should now have all the plugin files under + + /your/site/grav/user/plugins/rel-me + +> NOTE: This plugin is a modular component for Grav which requires [Grav](http://github.com/getgrav/grav) and the [Error](https://github.com/getgrav/grav-plugin-error) and [Problems](https://github.com/getgrav/grav-plugin-problems) to operate. + +### Admin Plugin + +If you use the admin plugin, you can install directly through the admin plugin by browsing the `Plugins` tab and clicking on the `Add` button. + +## Configuration + +Before configuring this plugin, you should copy the `user/plugins/rel-me/rel-me.yaml` to `user/config/plugins/rel-me.yaml` and only edit that copy. + +Here is the default configuration and an explanation of available options: + +```yaml +enabled: true +``` + +Note that if you use the admin plugin, a file with your configuration, and named rel-me.yaml will be saved in the `user/config/plugins/` folder once the configuration is saved in the admin. + +## Usage + +**Describe how to use the plugin.** + +## Credits + +**Did you incorporate third-party code? Want to thank somebody?** + +## To Do + +- [ ] Future plans, if any + diff --git a/blueprints.yaml b/blueprints.yaml new file mode 100644 index 0000000..079c2d9 --- /dev/null +++ b/blueprints.yaml @@ -0,0 +1,31 @@ +name: Rel Me +version: 0.1.0 +description: Add rel=me links to your website. +icon: plug +author: + name: Robert van Bregt + email: robert@robertvanbregt.nl +homepage: https://github.com/metbril/grav-plugin-rel-me +demo: http://demo.yoursite.com +keywords: grav, plugin, etc +bugs: https://github.com/metbril/grav-plugin-rel-me/issues +docs: https://github.com/metbril/grav-plugin-rel-me/blob/develop/README.md +license: MIT + +form: + validation: strict + fields: + enabled: + type: toggle + label: PLUGIN_ADMIN.PLUGIN_STATUS + highlight: 1 + default: 0 + options: + 1: PLUGIN_ADMIN.ENABLED + 0: PLUGIN_ADMIN.DISABLED + validate: + type: bool + text_var: + type: text + label: PLUGIN_REL_ME.TEXT_VARIABLE + help: PLUGIN_REL_ME.TEXT_VARIABLE_HELP diff --git a/languages.yaml b/languages.yaml new file mode 100644 index 0000000..b6e8abd --- /dev/null +++ b/languages.yaml @@ -0,0 +1,4 @@ +en: + PLUGIN_REL_ME: + TEXT_VARIABLE: Text Variable + TEXT_VARIABLE_HELP: Text to add to the top of a page diff --git a/rel-me.php b/rel-me.php new file mode 100644 index 0000000..5e6082b --- /dev/null +++ b/rel-me.php @@ -0,0 +1,63 @@ + ['onPluginsInitialized', 0] + ]; + } + + /** + * Initialize the plugin + */ + public function onPluginsInitialized() + { + // Don't proceed if we are in the admin plugin + if ($this->isAdmin()) { + return; + } + + // Enable the main event we are interested in + $this->enable([ + 'onPageContentRaw' => ['onPageContentRaw', 0] + ]); + } + + /** + * Do some work for this event, full details of events can be found + * on the learn site: http://learn.getgrav.org/plugins/event-hooks + * + * @param Event $e + */ + public function onPageContentRaw(Event $e) + { + // Get a variable from the plugin configuration + $text = $this->grav['config']->get('plugins.rel-me.text_var'); + + // Get the current raw content + $content = $e['page']->getRawContent(); + + // Prepend the output with the custom text and set back on the page + $e['page']->setRawContent($text . "\n\n" . $content); + } +} diff --git a/rel-me.yaml b/rel-me.yaml new file mode 100644 index 0000000..5c67f01 --- /dev/null +++ b/rel-me.yaml @@ -0,0 +1,2 @@ +enabled: true +text_var: Custom Text added by the **Rel Me** plugin (disable plugin to remove)