Initial commit
This commit is contained in:
commit
ea84035fee
17 changed files with 499 additions and 0 deletions
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
# Auto detect text files and perform LF normalization
|
||||||
|
* text=auto
|
5
CHANGELOG.md
Normal file
5
CHANGELOG.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# v0.1.0
|
||||||
|
## 29-02-2020
|
||||||
|
|
||||||
|
1. [](#new)
|
||||||
|
* ChangeLog started...
|
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2020 Matt Mulhall
|
||||||
|
|
||||||
|
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.
|
38
README.md
Normal file
38
README.md
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
# Aura Authors Plugin
|
||||||
|
|
||||||
|
The **Aura Authors** Plugin for [Grav CMS](https://github.com/getgrav/grav) enables you to store author bios in a centrally managed repository and have them displayed across various pages of your site.
|
||||||
|
|
||||||
|
![Aura Authors Plugin for Grav - Demo](assets/demo-min.png)
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
* Easily manage author bios via the Grav admin interface
|
||||||
|
* Central repository ensures that a single change to an author's bio will automatically update it across multiple pages
|
||||||
|
* Optionally include author's image and links to social media accounts such as Twitter, LinkedIn etc.
|
||||||
|
* Use the included mobile and desktop responsive styling or provide your own
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
It is recommended to install Aura Authors directly through the Admin Plugin by browsing to the `Plugins` tab and selecting `Add`.
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
|
```
|
||||||
|
{% include 'partials/author-bio.html.twig' ignore missing %}
|
||||||
|
```
|
||||||
|
|
||||||
|
* The above will output the relevant author bio on all pages of that type, once an author is defined at the page level (see Usage below). Alternatively if you do not have access or do not wish to edit the theme you can include the code snippet directly within a page via the page editor. For this option to work you will need ensure Twig processing is enabled either at the page level (`Page Editor` > `Advanced` > `Overrides` > `Process`) or the site level (`Configuration` > `System` > `Content` > `Process`).
|
||||||
|
|
||||||
|
* Optionally customise the layout of the author bio by copying the included templates/partials/author-bio.html.twig into the same location under your theme and editing it. Default styling can be disabled via the Plugin configuration panel if you wish to provide your own.
|
||||||
|
|
||||||
|
## 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 Plugins panel.
|
||||||
|
|
||||||
|
## Credits
|
||||||
|
|
||||||
|
Includes a subset of the [IcoMoon - Free](https://icomoon.io/#icons-icomoon) icon pack.
|
BIN
assets/demo-min.png
Normal file
BIN
assets/demo-min.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 60 KiB |
BIN
assets/fonts/icomoon.eot
Normal file
BIN
assets/fonts/icomoon.eot
Normal file
Binary file not shown.
17
assets/fonts/icomoon.svg
Normal file
17
assets/fonts/icomoon.svg
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" standalone="no"?>
|
||||||
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<metadata>Generated by IcoMoon</metadata>
|
||||||
|
<defs>
|
||||||
|
<font id="icomoon" horiz-adv-x="1024">
|
||||||
|
<font-face units-per-em="1024" ascent="960" descent="-64" />
|
||||||
|
<missing-glyph horiz-adv-x="1024" />
|
||||||
|
<glyph unicode=" " horiz-adv-x="512" d="" />
|
||||||
|
<glyph unicode="" glyph-name="website" d="M440.236 324.234c-13.31 0-26.616 5.076-36.77 15.23-95.134 95.136-95.134 249.934 0 345.070l192 192c46.088 46.086 107.36 71.466 172.534 71.466s126.448-25.38 172.536-71.464c95.132-95.136 95.132-249.934 0-345.070l-87.766-87.766c-20.308-20.308-53.23-20.308-73.54 0-20.306 20.306-20.306 53.232 0 73.54l87.766 87.766c54.584 54.586 54.584 143.404 0 197.99-26.442 26.442-61.6 41.004-98.996 41.004s-72.552-14.562-98.996-41.006l-192-191.998c-54.586-54.586-54.586-143.406 0-197.992 20.308-20.306 20.306-53.232 0-73.54-10.15-10.152-23.462-15.23-36.768-15.23zM256-52c-65.176 0-126.45 25.38-172.534 71.464-95.134 95.136-95.134 249.934 0 345.070l87.764 87.764c20.308 20.306 53.234 20.306 73.54 0 20.308-20.306 20.308-53.232 0-73.54l-87.764-87.764c-54.586-54.586-54.586-143.406 0-197.992 26.44-26.44 61.598-41.002 98.994-41.002s72.552 14.562 98.998 41.006l192 191.998c54.584 54.586 54.584 143.406 0 197.992-20.308 20.308-20.306 53.232 0 73.54 20.306 20.306 53.232 20.306 73.54-0.002 95.132-95.134 95.132-249.932 0.002-345.068l-192.002-192c-46.090-46.088-107.364-71.466-172.538-71.466z" />
|
||||||
|
<glyph unicode="" glyph-name="facebook" d="M608 768h160v192h-160c-123.514 0-224-100.486-224-224v-96h-128v-192h128v-512h192v512h160l32 192h-192v96c0 17.346 14.654 32 32 32z" />
|
||||||
|
<glyph unicode="" glyph-name="instagram" d="M512 867.8c136.8 0 153-0.6 206.8-3 50-2.2 77-10.6 95-17.6 23.8-9.2 41-20.4 58.8-38.2 18-18 29-35 38.4-58.8 7-18 15.4-45.2 17.6-95 2.4-54 3-70.2 3-206.8s-0.6-153-3-206.8c-2.2-50-10.6-77-17.6-95-9.2-23.8-20.4-41-38.2-58.8-18-18-35-29-58.8-38.4-18-7-45.2-15.4-95-17.6-54-2.4-70.2-3-206.8-3s-153 0.6-206.8 3c-50 2.2-77 10.6-95 17.6-23.8 9.2-41 20.4-58.8 38.2-18 18-29 35-38.4 58.8-7 18-15.4 45.2-17.6 95-2.4 54-3 70.2-3 206.8s0.6 153 3 206.8c2.2 50 10.6 77 17.6 95 9.2 23.8 20.4 41 38.2 58.8 18 18 35 29 58.8 38.4 18 7 45.2 15.4 95 17.6 53.8 2.4 70 3 206.8 3zM512 960c-139 0-156.4-0.6-211-3-54.4-2.4-91.8-11.2-124.2-23.8-33.8-13.2-62.4-30.6-90.8-59.2-28.6-28.4-46-57-59.2-90.6-12.6-32.6-21.4-69.8-23.8-124.2-2.4-54.8-3-72.2-3-211.2s0.6-156.4 3-211c2.4-54.4 11.2-91.8 23.8-124.2 13.2-33.8 30.6-62.4 59.2-90.8 28.4-28.4 57-46 90.6-59 32.6-12.6 69.8-21.4 124.2-23.8 54.6-2.4 72-3 211-3s156.4 0.6 211 3c54.4 2.4 91.8 11.2 124.2 23.8 33.6 13 62.2 30.6 90.6 59s46 57 59 90.6c12.6 32.6 21.4 69.8 23.8 124.2 2.4 54.6 3 72 3 211s-0.6 156.4-3 211c-2.4 54.4-11.2 91.8-23.8 124.2-12.6 34-30 62.6-58.6 91-28.4 28.4-57 46-90.6 59-32.6 12.6-69.8 21.4-124.2 23.8-54.8 2.6-72.2 3.2-211.2 3.2v0zM512 711c-145.2 0-263-117.8-263-263s117.8-263 263-263 263 117.8 263 263c0 145.2-117.8 263-263 263zM512 277.4c-94.2 0-170.6 76.4-170.6 170.6s76.4 170.6 170.6 170.6c94.2 0 170.6-76.4 170.6-170.6s-76.4-170.6-170.6-170.6zM846.8 721.4c0-33.91-27.49-61.4-61.4-61.4s-61.4 27.49-61.4 61.4c0 33.91 27.49 61.4 61.4 61.4s61.4-27.49 61.4-61.4z" />
|
||||||
|
<glyph unicode="" glyph-name="twitter" d="M1024 733.6c-37.6-16.8-78.2-28-120.6-33 43.4 26 76.6 67.2 92.4 116.2-40.6-24-85.6-41.6-133.4-51-38.4 40.8-93 66.2-153.4 66.2-116 0-210-94-210-210 0-16.4 1.8-32.4 5.4-47.8-174.6 8.8-329.4 92.4-433 219.6-18-31-28.4-67.2-28.4-105.6 0-72.8 37-137.2 93.4-174.8-34.4 1-66.8 10.6-95.2 26.2 0-0.8 0-1.8 0-2.6 0-101.8 72.4-186.8 168.6-206-17.6-4.8-36.2-7.4-55.4-7.4-13.6 0-26.6 1.4-39.6 3.8 26.8-83.4 104.4-144.2 196.2-146-72-56.4-162.4-90-261-90-17 0-33.6 1-50.2 3 93.2-59.8 203.6-94.4 322.2-94.4 386.4 0 597.8 320.2 597.8 597.8 0 9.2-0.2 18.2-0.6 27.2 41 29.4 76.6 66.4 104.8 108.6z" />
|
||||||
|
<glyph unicode="" glyph-name="youtube" d="M1013.8 652.8c0 0-10 70.6-40.8 101.6-39 40.8-82.6 41-102.6 43.4-143.2 10.4-358.2 10.4-358.2 10.4h-0.4c0 0-215 0-358.2-10.4-20-2.4-63.6-2.6-102.6-43.4-30.8-31-40.6-101.6-40.6-101.6s-10.2-82.8-10.2-165.8v-77.6c0-82.8 10.2-165.8 10.2-165.8s10-70.6 40.6-101.6c39-40.8 90.2-39.4 113-43.8 82-7.8 348.2-10.2 348.2-10.2s215.2 0.4 358.4 10.6c20 2.4 63.6 2.6 102.6 43.4 30.8 31 40.8 101.6 40.8 101.6s10.2 82.8 10.2 165.8v77.6c-0.2 82.8-10.4 165.8-10.4 165.8zM406.2 315.2v287.8l276.6-144.4-276.6-143.4z" />
|
||||||
|
<glyph unicode="" glyph-name="linkedin" d="M384 576h177.106v-90.782h2.532c24.64 44.194 84.958 90.782 174.842 90.782 186.946 0 221.52-116.376 221.52-267.734v-308.266h-184.61v273.278c0 65.184-1.334 149.026-96.028 149.026-96.148 0-110.82-70.986-110.82-144.292v-278.012h-184.542v576zM64 576h192v-576h-192v576zM256 736c0-53.019-42.981-96-96-96s-96 42.981-96 96c0 53.019 42.981 96 96 96s96-42.981 96-96z" />
|
||||||
|
<glyph unicode="" glyph-name="pinterest" d="M512 960c-282.4 0-512-229.6-512-512s229.6-512 512-512 512 229.6 512 512-229.6 512-512 512zM512 4.4c-45.8 0-89.8 7-131.4 19.8 18 29.4 45.2 77.8 55.2 116.2 5.4 20.8 27.6 105.4 27.6 105.4 14.4-27.6 56.8-51 101.6-51 133.8 0 230.2 123 230.2 276 0 146.6-119.6 256.2-273.4 256.2-191.4 0-293-128.6-293-268.4 0-65 34.6-146 90-171.8 8.4-4 12.8-2.2 14.8 6 1.4 6.2 9 36.2 12.4 50.4 1 4.4 0.6 8.4-3 12.8-18.4 22.2-33 63.2-33 101.2 0 97.8 74 192.6 200.2 192.6 109 0 185.2-74.2 185.2-180.4 0-120-60.6-203.2-139.4-203.2-43.6 0-76.2 36-65.6 80.2 12.6 52.8 36.8 109.6 36.8 147.6 0 34-18.2 62.4-56.2 62.4-44.6 0-80.2-46-80.2-107.8 0-39.2 13.2-65.8 13.2-65.8s-44-185.8-52-220.4c-9-38.4-5.4-92.2-1.6-127.2-165 64.4-282 224.8-282 412.8 0 245 198.6 443.6 443.6 443.6s443.6-198.6 443.6-443.6c0-245-198.6-443.6-443.6-443.6z" />
|
||||||
|
</font></defs></svg>
|
After Width: | Height: | Size: 5.6 KiB |
BIN
assets/fonts/icomoon.ttf
Normal file
BIN
assets/fonts/icomoon.ttf
Normal file
Binary file not shown.
BIN
assets/fonts/icomoon.woff
Normal file
BIN
assets/fonts/icomoon.woff
Normal file
Binary file not shown.
1
assets/style.min.css
vendored
Normal file
1
assets/style.min.css
vendored
Normal file
|
@ -0,0 +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 */
|
1
assets/style.min.css.map
Normal file
1
assets/style.min.css.map
Normal file
|
@ -0,0 +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"}
|
128
assets/style.scss
Normal file
128
assets/style.scss
Normal file
|
@ -0,0 +1,128 @@
|
||||||
|
.author-bio {
|
||||||
|
background-color: #F5F5F5;
|
||||||
|
margin: 40px 0;
|
||||||
|
padding: 25px;
|
||||||
|
border-radius: 15px;
|
||||||
|
overflow: hidden;
|
||||||
|
.author-heading {
|
||||||
|
font-weight: bold;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
hr {
|
||||||
|
margin: 5px 0 15px;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.author-image {
|
||||||
|
border-radius: 50%;
|
||||||
|
width: 128px;
|
||||||
|
height: auto;
|
||||||
|
float: left;
|
||||||
|
margin: 0 25px 15px 0 !important;
|
||||||
|
padding: 0 !important;
|
||||||
|
}
|
||||||
|
.author-name {
|
||||||
|
float: left;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
p {
|
||||||
|
font-weight: bolder;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.author-social {
|
||||||
|
float: right;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
ul {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
list-style: none;
|
||||||
|
li {
|
||||||
|
display: inline;
|
||||||
|
&:not(:first-child) {
|
||||||
|
padding-left: 10px;
|
||||||
|
}
|
||||||
|
a, a:active, a:focus, a:hover {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.clear-right {
|
||||||
|
clear: right;
|
||||||
|
}
|
||||||
|
.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-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-"] {
|
||||||
|
/* use !important to prevent issues with browser extensions that change fonts */
|
||||||
|
font-family: 'icomoon' !important;
|
||||||
|
speak: none;
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: normal;
|
||||||
|
font-variant: normal;
|
||||||
|
text-transform: none;
|
||||||
|
line-height: 1;
|
||||||
|
|
||||||
|
/* Better Font Rendering =========== */
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
}
|
||||||
|
|
||||||
|
.aura-icon-website:before {
|
||||||
|
content: "\e9cb";
|
||||||
|
}
|
||||||
|
.aura-icon-facebook:before {
|
||||||
|
content: "\ea90";
|
||||||
|
}
|
||||||
|
.aura-icon-instagram:before {
|
||||||
|
content: "\ea92";
|
||||||
|
}
|
||||||
|
.aura-icon-twitter:before {
|
||||||
|
content: "\ea96";
|
||||||
|
}
|
||||||
|
.aura-icon-youtube:before {
|
||||||
|
content: "\ea9d";
|
||||||
|
}
|
||||||
|
.aura-icon-linkedin:before {
|
||||||
|
content: "\eaca";
|
||||||
|
}
|
||||||
|
.aura-icon-pinterest:before {
|
||||||
|
content: "\ead2";
|
||||||
|
}
|
122
aura-authors.php
Normal file
122
aura-authors.php
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
<?php
|
||||||
|
namespace Grav\Plugin;
|
||||||
|
|
||||||
|
use Grav\Common\Data;
|
||||||
|
use Grav\Common\Plugin;
|
||||||
|
use RocketTheme\Toolbox\Event\Event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class AuraAuthorsPlugin
|
||||||
|
* @package Grav\Plugin
|
||||||
|
*/
|
||||||
|
class AuraAuthorsPlugin extends Plugin
|
||||||
|
{
|
||||||
|
|
||||||
|
/** @var array */
|
||||||
|
static protected $authorList = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getSubscribedEvents()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'onPluginsInitialized' => ['onPluginsInitialized', 0],
|
||||||
|
'onTwigTemplatePaths' => ['onTwigTemplatePaths', 0],
|
||||||
|
'onPageInitialized' => ['onPageInitialized', 0],
|
||||||
|
'onTwigSiteVariables' => ['onTwigSiteVariables', 0],
|
||||||
|
'onBlueprintCreated' => ['onBlueprintCreated', 0],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize configuration
|
||||||
|
*/
|
||||||
|
public function onPluginsInitialized()
|
||||||
|
{
|
||||||
|
|
||||||
|
// Add author to site taxonomies
|
||||||
|
$taxonomies = $this->config->get('site.taxonomies');
|
||||||
|
$taxonomies[] = 'author';
|
||||||
|
$this->config->set('site.taxonomies', $taxonomies);
|
||||||
|
|
||||||
|
// Populate author list for use in blueprint
|
||||||
|
$authors = $this->grav['config']->get('plugins.aura-authors.authors');
|
||||||
|
if ($authors) {
|
||||||
|
foreach ($authors as $author) {
|
||||||
|
if (!array_key_exists($author['label'], self::$authorList)) {
|
||||||
|
self::$authorList[$author['label']] = $author['name'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
asort(self::$authorList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extend page blueprints with additional configuration options.
|
||||||
|
*
|
||||||
|
* @param Event $event
|
||||||
|
*/
|
||||||
|
public function onBlueprintCreated(Event $event)
|
||||||
|
{
|
||||||
|
static $inEvent = false;
|
||||||
|
|
||||||
|
/** @var Data\Blueprint $blueprint */
|
||||||
|
$blueprint = $event['blueprint'];
|
||||||
|
if (!$inEvent && $blueprint->get('form/fields/tabs', null, '/')) {
|
||||||
|
$inEvent = true;
|
||||||
|
$blueprints = new Data\Blueprints(__DIR__ . '/blueprints/');
|
||||||
|
$extends = $blueprints->get('aura-authors');
|
||||||
|
$blueprint->extend($extends, true);
|
||||||
|
$inEvent = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add plugin directory to twig lookup paths
|
||||||
|
*/
|
||||||
|
public function onTwigTemplatePaths()
|
||||||
|
{
|
||||||
|
$this->grav['twig']->twig_paths[] = __DIR__ . '/templates';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add author to page taxonomy
|
||||||
|
*
|
||||||
|
* @param Event $e
|
||||||
|
*/
|
||||||
|
public function onPageInitialized()
|
||||||
|
{
|
||||||
|
if ($this->isAdmin()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$page = $this->grav['page'];
|
||||||
|
$header = $page->header();
|
||||||
|
if ((isset($header->aura['author'])) && ($header->aura['author'] != '')) {
|
||||||
|
$taxonomy = $page->taxonomy();
|
||||||
|
$taxonomy['author'][] = $header->aura['author'];
|
||||||
|
$page->taxonomy($taxonomy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function listAuthors() {
|
||||||
|
return self::$authorList;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
2
aura-authors.yaml
Normal file
2
aura-authors.yaml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
enabled: true
|
||||||
|
include-css: true
|
101
blueprints.yaml
Normal file
101
blueprints.yaml
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
name: Aura Authors
|
||||||
|
version: 0.1.0
|
||||||
|
description: Store author bios in a central repository for display on multiple pages.
|
||||||
|
icon: users
|
||||||
|
author:
|
||||||
|
name: Matt Mulhall
|
||||||
|
email: matt@theskylab.net
|
||||||
|
url: https://www.theskylab.net
|
||||||
|
homepage: https://github.com/matt-j-m/grav-plugin-aura-authors
|
||||||
|
keywords: author, bio, blog
|
||||||
|
bugs: https://github.com/matt-j-m/grav-plugin-aura-authors/issues
|
||||||
|
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
|
||||||
|
include-css:
|
||||||
|
type: toggle
|
||||||
|
label: Include default CSS
|
||||||
|
highlight: 1
|
||||||
|
default: 1
|
||||||
|
options:
|
||||||
|
1: PLUGIN_ADMIN.ENABLED
|
||||||
|
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/plugins/aura-authors/assets'
|
||||||
|
accept:
|
||||||
|
- image/*
|
||||||
|
.description:
|
||||||
|
type: textarea
|
||||||
|
size: long
|
||||||
|
label: Description
|
||||||
|
.facebook-url:
|
||||||
|
type: text
|
||||||
|
size: large
|
||||||
|
label: Facebook URL
|
||||||
|
placeholder: 'https://www.facebook.com/username'
|
||||||
|
.twitter-url:
|
||||||
|
type: text
|
||||||
|
size: large
|
||||||
|
label: Twitter URL
|
||||||
|
placeholder: 'https://twitter.com/username'
|
||||||
|
.instagram-url:
|
||||||
|
type: text
|
||||||
|
size: large
|
||||||
|
label: Instagram URL
|
||||||
|
placeholder: 'https://www.instagram.com/username'
|
||||||
|
.linkedin-url:
|
||||||
|
type: text
|
||||||
|
size: large
|
||||||
|
label: LinkedIn URL
|
||||||
|
placeholder: 'https://www.linkedin.com/in/name'
|
||||||
|
.pinterest-url:
|
||||||
|
type: text
|
||||||
|
size: large
|
||||||
|
label: Pinterest URL
|
||||||
|
placeholder: 'https://www.pinterest.com/user/username'
|
||||||
|
.youtube-url:
|
||||||
|
type: text
|
||||||
|
size: large
|
||||||
|
label: YouTube URL
|
||||||
|
placeholder: 'https://www.youtube.com/username'
|
||||||
|
.website-url:
|
||||||
|
type: text
|
||||||
|
label: Website URL
|
||||||
|
placeholder: 'https://www.example.com'
|
17
blueprints/aura-authors.yaml
Normal file
17
blueprints/aura-authors.yaml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
form:
|
||||||
|
fields:
|
||||||
|
tabs:
|
||||||
|
fields:
|
||||||
|
aura:
|
||||||
|
type: tab
|
||||||
|
title: Aura
|
||||||
|
|
||||||
|
fields:
|
||||||
|
|
||||||
|
header.aura.author:
|
||||||
|
type: select
|
||||||
|
label: Author
|
||||||
|
size: medium
|
||||||
|
data-options@: '\Grav\Plugin\AuraAuthorsPlugin::listAuthors'
|
||||||
|
options:
|
||||||
|
'': ''
|
44
templates/partials/author-bio.html.twig
Normal file
44
templates/partials/author-bio.html.twig
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
{% set author = authors[page.header.aura.author] %}
|
||||||
|
{% if author %}
|
||||||
|
{% set social = [
|
||||||
|
'twitter',
|
||||||
|
'linkedin',
|
||||||
|
'youtube',
|
||||||
|
'facebook',
|
||||||
|
'instagram',
|
||||||
|
'pinterest',
|
||||||
|
'website',
|
||||||
|
] %}
|
||||||
|
<div class="author-bio">
|
||||||
|
<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') }}
|
||||||
|
{% endif %}
|
||||||
|
<div class="author-text">
|
||||||
|
<div>
|
||||||
|
<div class="author-name">
|
||||||
|
<p>{{ author.name }}</p>
|
||||||
|
</div>
|
||||||
|
<div class="author-social">
|
||||||
|
<ul>
|
||||||
|
{% for item in social %}
|
||||||
|
{% set href = author[item ~ '-url'] %}
|
||||||
|
{% if href %}
|
||||||
|
<li><a href="{{ href }}" target="_blank"><span class="aura-icon-{{ item }}"></span></a></li>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="clear-right"></div>
|
||||||
|
</div>
|
||||||
|
<div class="author-description">
|
||||||
|
<p>{{ author.description }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% if config.plugins['aura-authors']['include-css'] %}
|
||||||
|
{% do assets.addCss('user://plugins/aura-authors/assets/style.min.css') %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
Loading…
Reference in a new issue