Prepared for initial gpm release

This commit is contained in:
matt-j-m 2020-06-23 15:53:31 +10:00
parent 225ff1bd4e
commit 7716ae9c48
11 changed files with 125 additions and 155 deletions

View File

@ -1,5 +1,5 @@
# v0.1.0
## 29-02-2020
# v1.0.0
## 23-06-2020
1. [](#new)
* ChangeLog started...

View File

@ -18,7 +18,7 @@ It is recommended to install Aura Authors directly through the Admin Plugin by b
## Configuration
* Enter author details via the `Authors` section of the Admin Plugin.
* Enter author details via the Admin Plugin by browsing to `Plugins` > `Aura Authors` and selecting `Add Item`.
* Copy the following code snippet to the relevant Twig template within your theme, at the place where you would like the author bio to be displayed.
@ -32,7 +32,7 @@ It is recommended to install Aura Authors directly through the Admin Plugin by b
## Usage
Authors can be selected per page via the page editor, on the `Aura` tab. The list of authors will be automatically populated with author records you create via the `Authors` menu item.
Authors can be selected per page via the page editor, on the `Aura` tab. The list of authors will be automatically populated with author records you create via the Plugins panel.
## Credits

View File

@ -1 +0,0 @@
$('<i class="fa fa-check"></i> ').prependTo('#authorSave');

View File

@ -1 +0,0 @@
#authorSave{margin-left:1.5rem}#authorSave:active{margin:1px 0 -1px 1.5rem}#authorSave i{margin-right:5px}

View File

@ -1,90 +0,0 @@
---
title: Authors
access:
admin.authors: true
admin.super: true
form:
name: authors
action: '/authors'
template: authors
refresh_prevention: true
fields:
authors:
type: list
display_label: false
collapsed: true
style: vertical
help: "Add or edit author details"
data-default@: ['\Grav\Plugin\AuraAuthorsPlugin::getAuthors']
fields:
.name:
type: text
size: large
label: Name
validate:
required: true
.label:
type: text
size: large
label: Taxonomy Label
validate:
pattern: "[a-z][a-z0-9_\-]+"
message: "Use all lowercase letters and replace spaces with hyphens."
required: true
.image:
type: file
size: large
label: Image
multiple: false
destination: 'user/images'
accept:
- image/*
.description:
type: textarea
size: long
label: Description
.person-facebook-url:
type: text
size: large
label: Facebook URL
placeholder: 'https://www.facebook.com/username'
.person-twitter-user:
type: text
size: large
label: Twitter Username
placeholder: 'username'
.person-instagram-url:
type: text
size: large
label: Instagram URL
placeholder: 'https://www.instagram.com/username'
.person-linkedin-url:
type: text
size: large
label: LinkedIn URL
placeholder: 'https://www.linkedin.com/in/name'
.person-pinterest-url:
type: text
size: large
label: Pinterest URL
placeholder: 'https://www.pinterest.com/user/username'
.person-youtube-url:
type: text
size: large
label: YouTube URL
placeholder: 'https://www.youtube.com/username'
.person-website-url:
type: text
label: Website URL
placeholder: 'https://www.example.com'
buttons:
submit:
type: submit
value: Save
classes: button
id: authorSave
---

View File

@ -1,11 +0,0 @@
{% extends 'partials/base.html.twig' %}
{% block titlebar %}
<h1><i class="fa fa-fw fa-users"></i> Authors</h1>
{% endblock %}
{% block content %}
{% include "forms/form.html.twig" %}
{% do assets.addCss('user://plugins/aura-authors/admin/assets/style.min.css') %}
{% do assets.addJs('user://plugins/aura-authors/admin/assets/admin.min.js', { 'loading':'defer' }) %}
{% endblock %}

View File

@ -1 +1 @@
.author-bio{background-color:#f5f5f5;margin:40px 0;padding:25px;border-radius:15px;overflow:hidden}.author-bio .author-heading{font-weight:bold;margin:0;padding:0}.author-bio hr{margin:5px 0 15px;padding:0}.author-bio .author-image{border-radius:50%;width:128px;height:auto;float:left;margin:0 25px 15px 0 !important;padding:0 !important}.author-bio .author-name{float:left;margin-bottom:10px}.author-bio .author-name p{font-weight:bolder;margin:0;padding:0}.author-bio .author-social{float:right;margin-bottom:10px}.author-bio .author-social ul{margin:0;padding:0;list-style:none}.author-bio .author-social ul li{display:inline}.author-bio .author-social ul li:not(:first-child){padding-left:10px}.author-bio .author-social ul li a,.author-bio .author-social ul li a:active,.author-bio .author-social ul li a:focus,.author-bio .author-social ul li a:hover{text-decoration:none}.author-bio .clear-right{clear:right}.author-bio .author-description p{overflow:hidden;margin:0;padding:0}@media only screen and (max-width: 767px){.author-bio .author-description p{overflow:unset}}@media only screen and (max-width: 575px){.author-bio .author-name,.author-bio .author-social{float:unset}}@font-face{font-family:"icomoon";src:url("fonts/icomoon.eot?aizbyq");src:url("fonts/icomoon.eot?aizbyq#iefix") format("embedded-opentype"),url("fonts/icomoon.ttf?aizbyq") format("truetype"),url("fonts/icomoon.woff?aizbyq") format("woff"),url("fonts/icomoon.svg?aizbyq#icomoon") format("svg");font-weight:normal;font-style:normal;font-display:block}[class^=aura-icon-],[class*=" aura-icon-"]{font-family:"icomoon" !important;speak:none;font-style:normal;font-weight:normal;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.aura-icon-website:before{content:""}.aura-icon-facebook:before{content:""}.aura-icon-instagram:before{content:""}.aura-icon-twitter:before{content:""}.aura-icon-youtube:before{content:""}.aura-icon-linkedin:before{content:""}.aura-icon-pinterest:before{content:""}/*# sourceMappingURL=style.min.css.map */
.author-bio{background-color:#f5f5f5;margin:40px 0;padding:25px;border-radius:15px;overflow:hidden}.author-bio .author-heading{font-weight:bold;margin:0;padding:0}.author-bio hr{margin:5px 0 15px;padding:0}.author-bio .author-image{border-radius:50%;width:128px;height:auto;float:left;margin:0 25px 15px 0 !important;padding:0 !important}.author-bio .author-name{float:left;margin-bottom:10px}.author-bio .author-name p{font-weight:bolder;margin:0;padding:0}.author-bio .author-social{float:right;margin-bottom:10px}.author-bio .author-social ul{margin:0;padding:0;list-style:none}.author-bio .author-social ul li{display:inline}.author-bio .author-social ul li:not(:first-child){padding-left:10px}.author-bio .author-social ul li a,.author-bio .author-social ul li a:active,.author-bio .author-social ul li a:focus,.author-bio .author-social ul li a:hover{text-decoration:none}.author-bio .clear-right{clear:right}.author-bio .author-description p{overflow:hidden;margin:0;padding:0}@media only screen and (max-width: 767px){.author-bio .author-description p{overflow:unset}}@media only screen and (max-width: 575px){.author-bio .author-name,.author-bio .author-social{float:unset}}@font-face{font-family:"icomoon";src:url("fonts/icomoon.eot?aizbyq");src:url("fonts/icomoon.eot?aizbyq#iefix") format("embedded-opentype"),url("fonts/icomoon.ttf?aizbyq") format("truetype"),url("fonts/icomoon.woff?aizbyq") format("woff"),url("fonts/icomoon.svg?aizbyq#icomoon") format("svg");font-weight:normal;font-style:normal;font-display:block}[class^=aura-icon-],[class*=" aura-icon-"]{font-family:"icomoon" !important;speak:none;font-style:normal;font-weight:normal;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.aura-icon-website:before{content:""}.aura-icon-facebook:before{content:""}.aura-icon-instagram:before{content:""}.aura-icon-twitter:before{content:""}.aura-icon-youtube:before{content:""}.aura-icon-linkedin:before{content:""}.aura-icon-pinterest:before{content:""}/*# sourceMappingURL=style.min.css.map */

View File

@ -1 +1 @@
{"version":3,"sourceRoot":"","sources":["style.scss"],"names":[],"mappings":"CAAA,YACE,yBACA,cACA,aACA,mBACA,gBACA,4BACE,iBACA,SACA,UAEF,eACE,kBACA,UAEF,0BACE,kBACA,YACA,YACA,WACA,gCACA,qBAEF,yBACE,WACA,mBACA,2BACE,mBACA,SACA,UAGJ,2BACE,YACA,mBACA,8BACE,SACA,UACA,gBACA,iCACE,eACA,mDACE,kBAEF,+JACE,qBAKR,yBACE,YAGA,kCACE,gBACA,SACA,UAKN,0CAGM,kCACE,gBAMR,0CAEI,oDACE,aAKN,WACE,sBACA,oCACA,+NAIA,mBACA,kBACA,mBAGF,2CAEE,iCACA,WACA,kBACA,mBACA,oBACA,oBACA,cAGA,mCACA,kCAGF,0BACE,YAEF,2BACE,YAEF,4BACE,YAEF,0BACE,YAEF,0BACE,YAEF,2BACE,YAEF,4BACE","file":"style.min.css"}
{"version":3,"sourceRoot":"","sources":["style.scss"],"names":[],"mappings":"AAAA,YACE,yBACA,cACA,aACA,mBACA,gBACA,4BACE,iBACA,SACA,UAEF,eACE,kBACA,UAEF,0BACE,kBACA,YACA,YACA,WACA,gCACA,qBAEF,yBACE,WACA,mBACA,2BACE,mBACA,SACA,UAGJ,2BACE,YACA,mBACA,8BACE,SACA,UACA,gBACA,iCACE,eACA,mDACE,kBAEF,+JACE,qBAKR,yBACE,YAGA,kCACE,gBACA,SACA,UAKN,0CAGM,kCACE,gBAMR,0CAEI,oDACE,aAKN,WACE,sBACA,oCACA,+NAIA,mBACA,kBACA,mBAGF,2CAEE,iCACA,WACA,kBACA,mBACA,oBACA,oBACA,cAGA,mCACA,kCAGF,0BACE,YAEF,2BACE,YAEF,4BACE,YAEF,0BACE,YAEF,0BACE,YAEF,2BACE,YAEF,4BACE","file":"style.min.css"}

View File

@ -4,8 +4,6 @@ namespace Grav\Plugin;
use Grav\Common\Plugin;
use Grav\Common\Page\Page;
use RocketTheme\Toolbox\Event\Event;
use RocketTheme\Toolbox\File\File;
use Symfony\Component\Yaml\Yaml;
/**
* Class AuraAuthorsPlugin
@ -13,16 +11,13 @@ use Symfony\Component\Yaml\Yaml;
*/
class AuraAuthorsPlugin extends Plugin
{
protected static $authorsFile = DATA_DIR . 'authors/authors.yaml';
protected $route = 'authors';
/** @var array */
static protected $authors = [];
public static function getAuthors()
{
$fileInstance = File::instance(self::$authorsFile);
if (!$fileInstance->content()) {
return;
}
return Yaml::parse($fileInstance->content());
return self::$authors;
}
public function onPluginsInitialized()
@ -30,15 +25,26 @@ class AuraAuthorsPlugin extends Plugin
// Admin only events
if ($this->isAdmin()) {
$this->enable([
'onAdminMenu' => ['onAdminMenu', 0],
'onTwigTemplatePaths' => ['onTwigTemplatePaths', 0],
'onPageInitialized' => ['onPageInitialized', 0],
'onGetPageBlueprints' => ['onGetPageBlueprints', 0],
'onAdminSave' => ['onAdminSave', 0],
]);
return;
}
// Frontend events
$this->enable([
'onTwigSiteVariables' => ['onTwigSiteVariables', 0],
'onTwigTemplatePaths' => ['onTwigTemplatePaths', 0],
]);
}
/**
* Add plugin directory to twig lookup paths
*/
public function onTwigTemplatePaths()
{
$this->grav['twig']->twig_paths[] = __DIR__ . '/templates';
}
/**
@ -48,8 +54,11 @@ class AuraAuthorsPlugin extends Plugin
*/
public function onGetPageBlueprints($event)
{
$types = $event->types;
$types->scanBlueprints('plugins://' . $this->name . '/blueprints');
self::$authors = $this->grav['config']->get('plugins.aura-authors.authors');
$types = $event->types;
$types->scanBlueprints('plugins://' . $this->name . '/blueprints');
}
public function onAdminSave(Event $event)
@ -61,37 +70,20 @@ class AuraAuthorsPlugin extends Plugin
$page = $event['object'];
if (isset($page->header()->aura['author'])) {
$author = array('author' => array($page->header()->aura['author']));
$page->header()->taxonomy = array_merge($page->header()->taxonomy, $author);
}
}
public function onPageInitialized()
{
$page = $this->grav['page'];
if ($page->template() === 'authors') {
$post = $this->grav['uri']->post();
if ($post) {
$authors = isset($post['data']['authors']) ? $post['data']['authors'] : [];
$file = File::instance(self::$authorsFile);
$file->save(Yaml::dump($authors));
$admin = $this->grav['admin'];
$admin->setMessage($admin::translate('PLUGIN_ADMIN.SUCCESSFULLY_SAVED'), 'info');
// TODO: tidy this section
// Also consider how to remove an author (currently need to go to expert mode)
// Also what if someone wants to set multiple author tags? should proably allow but only consider the aura one for meta output
if (isset($page->header()->taxonomy)) {
$taxonomy = $page->header()->taxonomy;
} else {
$taxonomy = [];
}
$taxonomy['author'] = array($page->header()->aura['author']);
$page->header()->taxonomy = $taxonomy;
}
}
public function onTwigTemplatePaths()
{
$this->grav['twig']->twig_paths[] = __DIR__ . '/admin/templates';
}
public function onAdminMenu()
{
$this->grav['twig']->plugins_hooked_nav['Authors'] = ['route' => $this->route, 'icon' => 'fa-users'];
}
public static function listAuthors() {
$authorList = [];
$authors = self::getAuthors();
@ -102,4 +94,19 @@ class AuraAuthorsPlugin extends Plugin
return $authorList;
}
/**
* Create structured authors array and expose to Twig
*/
public function onTwigSiteVariables()
{
$authors = array();
$raw = $this->grav['config']->get('plugins.aura-authors.authors');
if ($raw) {
foreach ($raw as $author) {
$authors[$author['label']] = $author;
}
}
$this->grav['twig']->twig_vars['authors'] = $authors;
}
}

View File

@ -1,5 +1,5 @@
name: Aura Authors
version: 0.1.0
version: 1.0.0
description: Store author bios in a central repository for display on multiple pages.
icon: users
author:
@ -34,3 +34,68 @@ form:
0: PLUGIN_ADMIN.DISABLED
validate:
type: bool
authors:
type: list
label: Author details
help: "Add or edit author details"
fields:
.name:
type: text
size: large
label: Name
validate:
required: true
.label:
type: text
size: large
label: Taxonomy Label
validate:
pattern: "[a-z][a-z0-9_\-]+"
message: "Use all lowercase letters and replace spaces with hyphens."
required: true
.image:
type: file
size: large
label: Image
multiple: false
destination: 'user/images'
accept:
- image/*
.description:
type: textarea
size: long
label: Description
.person-facebook-url:
type: text
size: large
label: Facebook URL
placeholder: 'https://www.facebook.com/username'
.person-twitter-user:
type: text
size: large
label: Twitter Username
placeholder: 'username'
.person-instagram-url:
type: text
size: large
label: Instagram URL
placeholder: 'https://www.instagram.com/username'
.person-linkedin-url:
type: text
size: large
label: LinkedIn URL
placeholder: 'https://www.linkedin.com/in/name'
.person-pinterest-url:
type: text
size: large
label: Pinterest URL
placeholder: 'https://www.pinterest.com/user/username'
.person-youtube-url:
type: text
size: large
label: YouTube URL
placeholder: 'https://www.youtube.com/username'
.person-website-url:
type: text
label: Website URL
placeholder: 'https://www.example.com'

View File

@ -1,7 +1,6 @@
{% set author = authors[page.header.aura.author] %}
{% if author %}
{% set social = [
'twitter',
'linkedin',
'youtube',
'facebook',
@ -13,8 +12,7 @@
<p class="author-heading">About the author</p>
<hr />
{% if author.image %}
{% set path = 'user://plugins/aura-authors/assets/' ~ author.image|first.name %}
{{ media[path].html('', author.name, 'author-image') }}
{{ media['user://images/' ~ author.image|first.name].html('', author.name, 'author-image') }}
{% endif %}
<div class="author-text">
<div>
@ -24,12 +22,15 @@
<div class="author-social">
<ul>
{% for item in social %}
{% set href = author[item ~ '-url'] %}
{% set href = author['person-' ~ item ~ '-url'] %}
{% if href %}
<li><a href="{{ href }}" target="_blank"><span class="aura-icon-{{ item }}"></span></a></li>
{% endif %}
{% endfor %}
</ul>
{% if author['person-twitter-user'] %}
<li><a href="https://twitter.com/{{ author['person-twitter-user'] }}" target="_blank"><span class="aura-icon-twitter"></span></a></li>
{% endif %}
</ul>&nbsp;
</div>
<div class="clear-right"></div>
</div>