This repository has been archived by the owner on Mar 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit. Plugin generated by devtools.
- Loading branch information
Robert van Bregt
committed
Aug 11, 2018
0 parents
commit 0356b61
Showing
7 changed files
with
182 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# v0.1.0 | ||
## 08/11/2018 | ||
|
||
1. [](#new) | ||
* ChangeLog started... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: [email protected] | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
en: | ||
PLUGIN_REL_ME: | ||
TEXT_VARIABLE: Text Variable | ||
TEXT_VARIABLE_HELP: Text to add to the top of a page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
namespace Grav\Plugin; | ||
|
||
use Grav\Common\Plugin; | ||
use RocketTheme\Toolbox\Event\Event; | ||
|
||
/** | ||
* Class RelMePlugin | ||
* @package Grav\Plugin | ||
*/ | ||
class RelMePlugin extends Plugin | ||
{ | ||
/** | ||
* @return array | ||
* | ||
* The getSubscribedEvents() gives the core a list of events | ||
* that the plugin wants to listen to. The key of each | ||
* array section is the event that the plugin listens to | ||
* and the value (in the form of an array) contains the | ||
* callable (or function) as well as the priority. The | ||
* higher the number the higher the priority. | ||
*/ | ||
public static function getSubscribedEvents() | ||
{ | ||
return [ | ||
'onPluginsInitialized' => ['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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
enabled: true | ||
text_var: Custom Text added by the **Rel Me** plugin (disable plugin to remove) |