Skip to content

Commit cdfd09d

Browse files
author
Fabien Basmaison
committed
First commit.
0 parents  commit cdfd09d

7 files changed

+199
-0
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# v0.1.0
2+
## 04/24/2020
3+
4+
1. [](#new)
5+
* Add basic functional code and documentation.

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2020 Fabien Basmaison (https://arkhi.org/)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Web Monetization Plugin
2+
3+
The **Web Monetization** Plugin is an extension for [Grav CMS](https://getgrav.org/).
4+
5+
It adds a meta tag on the website pointing to the wallet that will receive the payments.
6+
7+
## Installation
8+
9+
Installing the Web Monetization plugin can be done with git or a zip file.
10+
11+
### Git Installation
12+
13+
In the terminal, go to the root of your Grav installation, then enter:
14+
15+
```shell
16+
cd user/plugins && git clone git@framagit.org:arkhi/grav-plugin-web-monetization.git web-monetization
17+
```
18+
19+
### Zip file Installation
20+
21+
To install the plugin manually, download the zip version of this repository and unzip it in the `user/plugins` directory. Then rename the directory to `web-monetization`. You can find these files on [Gitlab](https://framagit.org/arkhi/grav-plugin-web-monetization).
22+
23+
---
24+
25+
You should now have all the plugin files under `user/plugins/web-monetization`.
26+
27+
## Usage
28+
29+
1. [Choose a _Wallet_](https://webmonetization.org/docs/ilp-wallets) to point to.
30+
2. Configure this plugin with the _Pointer_ to the _Wallet_ you just created.
31+
32+
## Configuration
33+
34+
**Nota‑bene:** If you use the Admin Plugin, a file with your configuration named “web-monetization.yaml” will be saved in the `user/config/plugins/` directory once the configuration is saved in the Admin.
35+
36+
1. Make sure the file `user/config/plugins/web-monetization.yaml` mirrors `user/plugins/web-monetization/web-monetization.yaml`
37+
1. Only edit `user/config/plugins/web-monetization.yaml`.
38+
39+
Here is the default configuration and an explanation of available options:
40+
41+
```yaml
42+
---
43+
enabled: true
44+
pointer: null
45+
```
46+
47+
- _pointer_ needs to point to the wallet that will receive the payment.
48+
49+
## Contributing
50+
51+
If you think something can be improved, please submit Issues or make a Pull Request. All comments and collaboration are welcome.

blueprints.yaml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
name: Web Monetization
3+
version: 0.1.0
4+
description: Implements Web Monetization on the website.
5+
icon: money
6+
author:
7+
name: Fabien Basmaison
8+
email: contact@arkhi.org
9+
url: https://arkhi.org/
10+
homepage: https://framagit.org/arkhi/grav-plugin-web-monetization
11+
keywords: grav, plugin, monetization, revenue
12+
bugs: https://framagit.org/arkhi/grav-plugin-web-monetization/issues
13+
docs: https://framagit.org/arkhi/grav-plugin-web-monetization/blob/master/README.md
14+
license: MIT
15+
dependencies:
16+
- {name: grav, version: '>=1.6.0'}
17+
18+
form:
19+
validation: strict
20+
fields:
21+
enabled:
22+
type: toggle
23+
label: PLUGIN_ADMIN.PLUGIN_STATUS
24+
highlight: 1
25+
default: 0
26+
options:
27+
1: PLUGIN_ADMIN.ENABLED
28+
0: PLUGIN_ADMIN.DISABLED
29+
validate:
30+
type: bool
31+
32+
pointer:
33+
type: text
34+
label: PLUGIN_WEB_MONETIZATION.POINTER

languages.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
# Español
3+
es:
4+
PLUGIN_WEB_MONETIZATION:
5+
POINTER: Apuntador
6+
7+
# English
8+
en:
9+
PLUGIN_WEB_MONETIZATION:
10+
POINTER: Pointer
11+
12+
# French
13+
fr:
14+
PLUGIN_WEB_MONETIZATION:
15+
POINTER: Pointeur

web-monetization.php

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
namespace Grav\Plugin;
3+
4+
use Grav\Common\Page\Page;
5+
use Grav\Common\Plugin;
6+
use RocketTheme\Toolbox\Event\Event;
7+
8+
/**
9+
* Class WebMonetizationPlugin
10+
*
11+
* @package Grav\Plugin
12+
* @see https://webmonetization.org/
13+
*/
14+
class WebMonetizationPlugin extends Plugin
15+
{
16+
/**
17+
* @return array
18+
*
19+
* Give the core an array of events the plugin listens to. For each event:
20+
* 1. Key: Name of the event.
21+
* 2. Value: array containing:
22+
* 1. Callable; a named function;
23+
* 2. Priority; a higher number is a higher priority.
24+
*/
25+
public static function getSubscribedEvents()
26+
{
27+
return [
28+
'onPluginsInitialized' => ['onPluginsInitialized', 0]
29+
];
30+
}
31+
32+
/**
33+
* Initialize the plugin.
34+
*/
35+
public function onPluginsInitialized()
36+
{
37+
// Don’t proceed if we are in the admin plugin.
38+
if ($this->isAdmin()) {
39+
return;
40+
}
41+
42+
// Enable the main events we are interested in.
43+
$this->enable([
44+
'onPageInitialized' => ['onPageInitialized', 0],
45+
]);
46+
}
47+
48+
/**
49+
* When a Grav Page is initiliazed…
50+
*/
51+
public function onPageInitialized(Event $e)
52+
{
53+
// Get current page object.
54+
$page = $this->grav['page'];
55+
56+
// Get current metadata.
57+
$meta = $page->metadata();
58+
59+
// Add a meta to the list of metadata if a pointer exists.
60+
$pointer = $this->config->get('plugins.web-monetization.pointer');
61+
62+
if ($pointer) {
63+
$meta['monetization'] = [
64+
'name' => 'monetization',
65+
'content' => $pointer,
66+
];
67+
68+
$page->metadata($meta);
69+
}
70+
}
71+
}

web-monetization.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
enabled: true

0 commit comments

Comments
 (0)