Skip to content
This repository has been archived by the owner on Mar 21, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1 from metbril/develop
Browse files Browse the repository at this point in the history
Release 0.1.0
  • Loading branch information
metbril authored Aug 12, 2018
2 parents 0356b61 + e98b12a commit 4598f48
Show file tree
Hide file tree
Showing 9 changed files with 143 additions and 36 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# v0.1.0
## 08/11/2018
## 08/12/2018

1. [](#new)
* ChangeLog started...
* Add plugin configuration
* Add list template
* Add link template
* Add initial documentation
66 changes: 54 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# 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 in 2 ways.

The **Rel Me** Plugin is for [Grav CMS](http://github.com/getgrav/grav). Add rel=me links to your website.
1. Add `<link>` to the HTML `<head>` section or create a list.
2. Add an `<ul>` list somewhere on a page.

## Installation

Expand All @@ -12,17 +13,17 @@ Installing the Rel Me plugin can be done in one of two ways. The GPM (Grav Packa

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
bin/gpm install relme

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`.
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/relme`.

### 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).
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 `relme`. You can find these files on [GitHub](https://github.com/metbril/grav-plugin-relme) 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
/your/site/grav/user/plugins/relme

> 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.
Expand All @@ -32,25 +33,66 @@ If you use the admin plugin, you can install directly through the admin plugin b

## 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.
Before configuring this plugin, you should copy the `user/plugins/relme/relme.yaml` to `user/config/plugins/relme.yaml` and only edit that copy.

Here is the default configuration and an explanation of available options:

```yaml
enabled: true
path:
active: true
icons: 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.
option | explanation
--- | ---
enabled | Enable the plugin
path | Path/route to the parent page of the menu items
active | If enabled, insert `<link>` tags in the page
icons | If enabled, show FontAwesome icons in the list

Note that if you use the admin plugin, a file with your configuration, and named relme.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.**
### Pages

1. Add a parent page. The route to this page should be added to the plugin configuration. Disable routing of the page.

2. Create child pages for each menu item that you want to include.

Front matter | Description
------------ | -----------
`title` | Displayed as the list title
`icon` | A FontAwesome icon. Defaults to 'link'.
`link` | The link to your profile page

### Link

Add this code to your template in the `<head>` section.

```twig
{% if config.plugins.relme.enabled %}
{% include 'partials/relme-link.html.twig' %}
{% endif %}
```

### List

Optionally you can add a social menu to a page. For example in your sidebar. Add this code to your template:

```twig
{% if config.plugins.relme.enabled %}
{% include 'partials/relme-list.html.twig' %}
{% endif %}
```

The list items can have icons.
## Credits

**Did you incorporate third-party code? Want to thank somebody?**
This plugin provides [rel=me](https://indieweb.org/rel-me) functionality for the [IndieWeb](https://indieweb.org/).

## To Do

- [ ] Future plans, if any

- [ ] Automatically inject link in HTML header
- [ ] Per page override of link injection
40 changes: 32 additions & 8 deletions blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name: Rel Me
version: 0.1.0
description: Add rel=me links to your website.
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
homepage: https://github.com/metbril/grav-plugin-relme
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
keywords: grav, plugin, social, link, indieweb
bugs: https://github.com/metbril/grav-plugin-relme/issues
docs: https://github.com/metbril/grav-plugin-relme/blob/develop/README.md
license: MIT

form:
Expand All @@ -25,7 +25,31 @@ form:
0: PLUGIN_ADMIN.DISABLED
validate:
type: bool
text_var:
path:
type: text
label: PLUGIN_REL_ME.TEXT_VARIABLE
help: PLUGIN_REL_ME.TEXT_VARIABLE_HELP
size: medium
label: PLUGIN_RELME.PATH_LABEL
help: PLUGIN_RELME.PATH_HELP
placeholder: PLUGIN_RELME.PATH_PLACEHOLDER
active:
type: toggle
label: PLUGIN_RELME.ACTIVE_LABEL
help: PLUGIN_RELME.ACTIVE_HELP
highlight: 0
default: 1
options:
1: PLUGIN_ADMIN.ENABLED
0: PLUGIN_ADMIN.DISABLED
validate:
type: bool
icons:
type: toggle
label: PLUGIN_RELME.ICONS_LABEL
help: PLUGIN_RELME.ICONS_HELP
highlight: 0
default: 1
options:
1: PLUGIN_ADMIN.ENABLED
0: PLUGIN_ADMIN.DISABLED
validate:
type: bool
21 changes: 18 additions & 3 deletions languages.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
en:
PLUGIN_REL_ME:
TEXT_VARIABLE: Text Variable
TEXT_VARIABLE_HELP: Text to add to the top of a page
PLUGIN_RELME:
PATH_LABEL: Path
PATH_HELP: Path to parent of menu items
PATH_PLACEHOLDER: Path to parent of menu items
ACTIVE_LABEL: Active
ACTIVE_HELP: Enabled if meta tags should be generated
ICONS_LABEL: Show icons
ICONS_HELP: Show icons in menu

nl:
PLUGIN_RELME:
PATH_LABEL: Pad
PATH_HELP: Pad naar ouder van menuitems
PATH_PLACEHOLDER: Pad naar ouder van menuitems
ACTIVE_LABEL: Actief
ACTIVE_HELP: Ingeschakeld als meta tags moeten worden gegenereerd
ICONS_LABEL: Iconen weergeven
ICONS_HELP: Iconen weergeven in menu
2 changes: 0 additions & 2 deletions rel-me.yaml

This file was deleted.

18 changes: 9 additions & 9 deletions rel-me.php → relme.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,18 @@ public function onPluginsInitialized()

// Enable the main event we are interested in
$this->enable([
'onPageContentRaw' => ['onPageContentRaw', 0]
'onTwigTemplatePaths' => ['onTwigTemplatePaths', 0],
]);
}

/**
* Add current directory to twig lookup paths.
*/
public function onTwigTemplatePaths()
{
$this->grav['twig']->twig_paths[] = __DIR__ . '/templates';
}

/**
* Do some work for this event, full details of events can be found
* on the learn site: http://learn.getgrav.org/plugins/event-hooks
Expand All @@ -51,13 +59,5 @@ public function onPluginsInitialized()
*/
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);
}
}
4 changes: 4 additions & 0 deletions relme.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
enabled: true
path:
active: true
icons: true
7 changes: 7 additions & 0 deletions templates/partials/relme-link.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% set path = page.find(config.plugins.relme.path) %}
{% set active = config.plugins.relme.active %}
{% if active %}
{%- for menu in path.children.visible.order('default', 'asc') -%}
<link rel="me" href="{{ menu.header.link }}" />
{% endfor %}
{% endif %}
14 changes: 14 additions & 0 deletions templates/partials/relme-list.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% set path = page.find(config.plugins.relme.path) %}
<ul>
{% for menu in path.children.visible.order('default', 'asc') %}
<li>
<a rel="me" href="{{ menu.header.link }}">
{% if config.plugins.relme.icons -%}
{%- set icon = (menu.header.icon) ? menu.header.icon : 'link' -%}
<i class="fa fa-{{ icon }}"></i>
{% endif -%}
{{ menu.title }}
</a>
</li>
{% endfor %}
</ul>

0 comments on commit 4598f48

Please sign in to comment.