(Grav GitSync) Automatic Commit from dan
This commit is contained in:
parent
335e4ff817
commit
4a4e911cc0
26 changed files with 1219 additions and 0 deletions
|
@ -5,6 +5,7 @@ taxonomy:
|
|||
- news
|
||||
tag:
|
||||
- 'TECH SAVIOURS'
|
||||
- GRAV
|
||||
media_order: 'ts&grav.png'
|
||||
aura:
|
||||
author: dan
|
||||
|
|
127
plugins/frontend-edit-button/CHANGELOG.md
Normal file
127
plugins/frontend-edit-button/CHANGELOG.md
Normal file
|
@ -0,0 +1,127 @@
|
|||
# v1.2.3
|
||||
## 12-05-2021
|
||||
|
||||
1. [](#modification)
|
||||
* [solved] Portugese translation added
|
||||
|
||||
# v1.2.2
|
||||
## 14-01-2019
|
||||
|
||||
1. [](#bug)
|
||||
* [solved] Problem with assets organization solved, button sometimes didn't show properly
|
||||
|
||||
# v1.2.1
|
||||
## 28-10-2018
|
||||
|
||||
1. [](#bug)
|
||||
* [solved] Button was not removed, even when admin cookie did not exist (anymore)
|
||||
|
||||
# v1.2
|
||||
## 25-10-2018
|
||||
|
||||
1. [](#modification)
|
||||
* Restructuring of the assets folder and combined sass/css.
|
||||
* Corrected bug where button was only shown after doing a page refresh
|
||||
|
||||
# v1.0.12.1
|
||||
## 19-10-2018
|
||||
|
||||
1. [](#bugfix)
|
||||
* Corrected the check if admin is logged on. In the former version the button was not on shown when not logged in.
|
||||
* Version 1.12 (former version) is not working with release 1.5 and later of Grav CMS.
|
||||
|
||||
# v1.0.12
|
||||
## 22-07-2018
|
||||
|
||||
1. [](#bugfix)
|
||||
* Corrected that the button still was showing sometimes, even after the admin was logged out. (Paul Hibbits, thanks for noticing)
|
||||
|
||||
# v1.0.11
|
||||
## 16-07-2018
|
||||
|
||||
1. [](#bugfix)
|
||||
* Corrected that page kept on refreshing, even after logged out. Now it refreshes 1 time after logging out to remove the button and the JavaScript to reload the page.
|
||||
|
||||
# v1.0.10
|
||||
## 13-07-2018
|
||||
|
||||
1. [](#bugfix)
|
||||
* Button is not displayed anymore when admin has logged out, button disappears after refresh (when clicking the tab with the page)
|
||||
|
||||
|
||||
# v1.0.9
|
||||
## 02-06-2018
|
||||
|
||||
1. [](#feature)
|
||||
* Automatic update of the contents in other tabs is now optional
|
||||
|
||||
# v1.0.8
|
||||
## 23-03-2018
|
||||
|
||||
1. [](#feature)
|
||||
* Button icon is now an independent font for this plugin
|
||||
2. [](#new)
|
||||
* New language Croatian
|
||||
|
||||
|
||||
# v1.0.7
|
||||
## 16-03-2018
|
||||
|
||||
1. [](#feature)
|
||||
* Optional, if user has to be logged in before showing the button
|
||||
|
||||
# v1.0.6
|
||||
## 15-03-2018
|
||||
|
||||
1. [](#bugfix)
|
||||
* Fix for incorrect edit button href
|
||||
2. [](#new)
|
||||
* New language Spanish and Catalunian
|
||||
|
||||
# v1.0.5
|
||||
## 27-01-2018
|
||||
|
||||
1. [](#bugfix)
|
||||
* Solved problem of multilanguage URL redirecting to wrong corresponding URL in backend
|
||||
|
||||
2. [](#bugfix)
|
||||
* Updated README.md content
|
||||
|
||||
# v1.0.4
|
||||
## 16-12-2017
|
||||
|
||||
1. [](#bugfix)
|
||||
* Solved the hardcoded '/admin' in relocate URL in case the admin route has been modified to something other than '/admin'
|
||||
|
||||
2. [](#bugfix)
|
||||
* Updated README.md content
|
||||
|
||||
3. [](#bugfix)
|
||||
* Renamed some files
|
||||
|
||||
# v1.0.3
|
||||
## 14-10-2017
|
||||
|
||||
1. [](#bugfix)
|
||||
* Solved problem when Grav is installed in sub folder
|
||||
|
||||
# v1.0.2
|
||||
## 01-11-2017
|
||||
|
||||
1. [](#bugfix)
|
||||
* Solved issue when Grav is installed in sub folder
|
||||
|
||||
|
||||
# v1.0.1
|
||||
## 04-08-2017
|
||||
|
||||
1. [](#bugfix)
|
||||
* Problem solved with `NULL` on the `header()` function
|
||||
in the `onOutputGenerated` event
|
||||
|
||||
|
||||
# v1.0.0
|
||||
## 04-03-2017
|
||||
|
||||
1. [](#new)
|
||||
* Initial version committed to Github
|
21
plugins/frontend-edit-button/LICENSE
Normal file
21
plugins/frontend-edit-button/LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 Johan van de Merwe
|
||||
|
||||
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.
|
150
plugins/frontend-edit-button/README.md
Normal file
150
plugins/frontend-edit-button/README.md
Normal file
|
@ -0,0 +1,150 @@
|
|||
# Frontend Edit Button Plugin
|
||||
|
||||
The **Frontpage Edit Button** Plugin is for [Grav CMS](http://github.com/getgrav/grav).
|
||||
|
||||
This plugin adds an 'edit this page' button on the frontend pages when logged in with a user account with
|
||||
admin rights. After clicking the button it will open the Admin Dashboard in another tab in your browser where you can start editing the page.
|
||||
|
||||
IMPORTANT (1): If no user is logged in as administrator (superuser), the button will show up only when this is explicitely set this in the plugin settings! By default a user has to be logged in to see the button.
|
||||
|
||||
IMPORTANT (2): You can't login from this plugin itself. You have to login by using the login to enter the Administrator Dashboard. When not logged in, the login dialog will be shown from GRAV CMS.
|
||||
|
||||
It will also work when you have an admin dashboard open in another tab of your browser. The moment you are logged in and are able to edit pages, the button will show up on the frontend pages. The moment you logout you are not able to edit any pages that are at that time displayed. The automatic refresh will prevent this.
|
||||
|
||||
## Requirements
|
||||
|
||||
This plugin requires that you have the following plugins installed and enabled:
|
||||
|
||||
* admin
|
||||
* login
|
||||
|
||||
## Installation
|
||||
|
||||
Installing the _Frontend Edit Button plugin_ can be done in different 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 frontend-edit-button
|
||||
|
||||
This will install the Frontpage Edit Button plugin into your `/user/plugins` directory within Grav. Its files can be found under `/your/site/grav/user/plugins/grav-frontend-edit-button`.
|
||||
|
||||
### Git clone ###
|
||||
|
||||
In the user/plugins folder of your site:
|
||||
```
|
||||
git clone https://github.com/enovision/grav-frontend-edit-button
|
||||
```
|
||||
|
||||
### Manual Installation
|
||||
|
||||
To install this plugin, download the zip version of this repository and unzip it under `/your/site/grav/user/plugins`. Then, rename the folder to `grav-frontend-edit-button`. You can find these files on [GitHub](https://github.com/johan-van-de-merwe/grav-plugin-frontend-edit-button) or via [GetGrav.org](http://getgrav.org/downloads/plugins#extras).
|
||||
|
||||
You should now have all the plugin files under
|
||||
|
||||
/your/site/grav/user/plugins/grav-frontend-edit-button
|
||||
|
||||
> 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.
|
||||
|
||||
## Configuration
|
||||
|
||||
Before configuring this plugin, you should copy the `user/plugins/grav-frontend-edit-button/grav-frontend-edit-button.yaml` to `user/config/plugins/grav-frontend-edit-button.yaml` and only edit that copy.
|
||||
|
||||
Here is the default configuration and an explanation of available options:
|
||||
|
||||
```yaml
|
||||
enabled: true
|
||||
```
|
||||
|
||||
Position of the button
|
||||
The following options are available:
|
||||
* (tr) Top right (default)
|
||||
* (tl) Top left
|
||||
* (br) Bottom right
|
||||
* (bl) Bottom left
|
||||
|
||||
```yaml
|
||||
position: tr
|
||||
```
|
||||
|
||||
Show the label on the button
|
||||
```yaml
|
||||
showLabel: true
|
||||
```
|
||||
|
||||
Show icon (requires Fontawesome to be loaded, it works when you install the plugin `Markdown Font Awesome`)
|
||||
```yaml
|
||||
showIcon: true
|
||||
```
|
||||
|
||||
IMPORTANT:
|
||||
_When both_ `showLabel` _and_ `showIcon` _are disabled, it will use internally_ `showLabel = true` _automatically_.
|
||||
|
||||
Only visible after login
|
||||
```yaml
|
||||
requiresAuth: true
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
When the plugin is enabled there is nothing else to do, it will show the button on the frontend pages.
|
||||
|
||||
It is possible however to switch the frontend editing off per page by adding the following to the header of a page (frontmatter):
|
||||
|
||||
```yaml
|
||||
protectEdit: true
|
||||
```
|
||||
|
||||
### Refreshing
|
||||
This plugin has a simple mechanism build in that will react on a `blur` and `focus` of the browser tab involved.
|
||||
The moment you click the button it will open the Dashboard in another tab in the browser. The moment you click back
|
||||
on the page you have just left by clicking on the button, this page will automatically refresh.
|
||||
|
||||
This refresh will always execute when you leave (blur) the tab and click back (focus) on the tab with the presented page.
|
||||
|
||||
### CSS and JavaScript
|
||||
|
||||
The required CSS and JavaScript will only be loaded if the plugin meets the requirements for executing.
|
||||
|
||||
#### CSS
|
||||
|
||||
You can change the styling of the button by modifying the `style.scss` file in the `scss` folder.
|
||||
It is required that the following CSS tags stay intact:
|
||||
|
||||
```css
|
||||
#frontend-edit-button {
|
||||
position: fixed;
|
||||
z-index: 10000;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
#frontend-edit-button.top {
|
||||
top: 0;
|
||||
}
|
||||
|
||||
#frontend-edit-button.bottom {
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
#frontend-edit-button.left {
|
||||
left: 0;
|
||||
}
|
||||
|
||||
#frontend-edit-button.right {
|
||||
right: 0;
|
||||
}
|
||||
```
|
||||
|
||||
You can compile the SASS by entering in the root of /assets folder of this plugin
|
||||
`./sass.cmd`. It is required that you have the compiler installed.
|
||||
|
||||
## i18n
|
||||
|
||||
There is a languages file available for multilanguage support
|
||||
|
||||
## Credits
|
||||
|
||||
* The amazing GRAV CMS Team for building such an amazing CMS.
|
||||
* [Nick Bell]() for correcting some path mistakes
|
||||
* [Christian Bewernitz](https://github.com/newmedicine) for adding the login requirement option (version 1.0.7)
|
41
plugins/frontend-edit-button/assets/css-compiled/style.css
Normal file
41
plugins/frontend-edit-button/assets/css-compiled/style.css
Normal file
|
@ -0,0 +1,41 @@
|
|||
#frontend-edit-button {
|
||||
position: fixed;
|
||||
z-index: 10000;
|
||||
padding: 5px; }
|
||||
|
||||
#frontend-edit-button .label {
|
||||
font-size: 16px; }
|
||||
|
||||
#frontend-edit-button.top {
|
||||
top: 0; }
|
||||
|
||||
#frontend-edit-button.bottom {
|
||||
bottom: 0; }
|
||||
|
||||
#frontend-edit-button.left {
|
||||
left: 0; }
|
||||
|
||||
#frontend-edit-button.right {
|
||||
right: 0; }
|
||||
|
||||
.frontend-edit-button {
|
||||
background-color: #0090D9;
|
||||
border: 1px solid #0090D9;
|
||||
border-radius: 5px;
|
||||
color: rgba(255, 255, 255, 0.85);
|
||||
padding: 5px 5px;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
font-size: 16px;
|
||||
margin: 4px 2px;
|
||||
cursor: pointer; }
|
||||
|
||||
.frontend-edit-button:hover {
|
||||
background: #26a1df;
|
||||
color: #fff; }
|
||||
|
||||
.icon-feb-editor:before {
|
||||
padding-right: 5px; }
|
||||
|
||||
/*# sourceMappingURL=style.css.map */
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"version": 3,
|
||||
"mappings": "AAOA,qBAAsB;EACpB,QAAQ,EAAE,KAAK;EACf,OAAO,EAAE,KAAK;EACd,OAAO,EAAE,GAAG;;AAGd,4BAA6B;EACzB,SAAS,EAAE,IAAI;;AAGnB,yBAA0B;EACxB,GAAG,EAAE,CAAC;;AAGR,4BAA6B;EAC3B,MAAM,EAAE,CAAC;;AAGX,0BAA2B;EACzB,IAAI,EAAE,CAAC;;AAGT,2BAA4B;EAC1B,KAAK,EAAE,CAAC;;AAGV,qBAAsB;EACpB,gBAAgB,EA9BI,OAAgB;EA+BpC,MAAM,EAAE,iBAA8B;EACtC,aAAa,EAAE,GAAG;EAClB,KAAK,EAhCc,yBAAa;EAiChC,OAAO,EAAE,OAAO;EAChB,UAAU,EAAE,MAAM;EAClB,eAAe,EAAE,IAAI;EACrB,OAAO,EAAE,YAAY;EACrB,SAAS,EAAE,IAAI;EACf,MAAM,EAAE,OAAO;EACf,MAAM,EAAE,OAAO;;AAGjB,2BAA4B;EACxB,UAAU,EA7CU,OAAO;EA8C3B,KAAK,EAhDY,IAAI;;AAmDzB,uBAAwB;EACnB,aAAa,EAAE,GAAG",
|
||||
"sources": ["../../scss/style.scss"],
|
||||
"names": [],
|
||||
"file": "style.css"
|
||||
}
|
41
plugins/frontend-edit-button/assets/css/style.css
Normal file
41
plugins/frontend-edit-button/assets/css/style.css
Normal file
|
@ -0,0 +1,41 @@
|
|||
#frontend-edit-button {
|
||||
position: fixed;
|
||||
z-index: 10000;
|
||||
padding: 5px; }
|
||||
|
||||
#frontend-edit-button .label {
|
||||
font-size: 16px; }
|
||||
|
||||
#frontend-edit-button.top {
|
||||
top: 0; }
|
||||
|
||||
#frontend-edit-button.bottom {
|
||||
bottom: 0; }
|
||||
|
||||
#frontend-edit-button.left {
|
||||
left: 0; }
|
||||
|
||||
#frontend-edit-button.right {
|
||||
right: 0; }
|
||||
|
||||
.frontend-edit-button {
|
||||
background-color: #0090D9;
|
||||
border: 1px solid #0090D9;
|
||||
border-radius: 5px;
|
||||
color: rgba(255, 255, 255, 0.85);
|
||||
padding: 5px 5px;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
font-size: 16px;
|
||||
margin: 4px 2px;
|
||||
cursor: pointer; }
|
||||
|
||||
.frontend-edit-button:hover {
|
||||
background: #26a1df;
|
||||
color: #fff; }
|
||||
|
||||
.icon-feb-editor:before {
|
||||
padding-right: 5px; }
|
||||
|
||||
/*# sourceMappingURL=style.css.map */
|
7
plugins/frontend-edit-button/assets/css/style.css.map
Normal file
7
plugins/frontend-edit-button/assets/css/style.css.map
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"version": 3,
|
||||
"mappings": "AAOA,qBAAsB;EACpB,QAAQ,EAAE,KAAK;EACf,OAAO,EAAE,KAAK;EACd,OAAO,EAAE,GAAG;;AAGd,4BAA6B;EACzB,SAAS,EAAE,IAAI;;AAGnB,yBAA0B;EACxB,GAAG,EAAE,CAAC;;AAGR,4BAA6B;EAC3B,MAAM,EAAE,CAAC;;AAGX,0BAA2B;EACzB,IAAI,EAAE,CAAC;;AAGT,2BAA4B;EAC1B,KAAK,EAAE,CAAC;;AAGV,qBAAsB;EACpB,gBAAgB,EA9BI,OAAgB;EA+BpC,MAAM,EAAE,iBAA8B;EACtC,aAAa,EAAE,GAAG;EAClB,KAAK,EAhCc,yBAAa;EAiChC,OAAO,EAAE,OAAO;EAChB,UAAU,EAAE,MAAM;EAClB,eAAe,EAAE,IAAI;EACrB,OAAO,EAAE,YAAY;EACrB,SAAS,EAAE,IAAI;EACf,MAAM,EAAE,OAAO;EACf,MAAM,EAAE,OAAO;;AAGjB,2BAA4B;EACxB,UAAU,EA7CU,OAAO;EA8C3B,KAAK,EAhDY,IAAI;;AAmDzB,uBAAwB;EACnB,aAAa,EAAE,GAAG",
|
||||
"sources": ["../scss/style.scss"],
|
||||
"names": [],
|
||||
"file": "style.css"
|
||||
}
|
1
plugins/frontend-edit-button/assets/css/style.min.css
vendored
Normal file
1
plugins/frontend-edit-button/assets/css/style.min.css
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
#frontend-edit-button{position:fixed;z-index:10000;padding:5px}#frontend-edit-button .label{font-size:16px}#frontend-edit-button.top{top:0}#frontend-edit-button.bottom{bottom:0}#frontend-edit-button.left{left:0}#frontend-edit-button.right{right:0}.frontend-edit-button{background-color:#0090d9;border:1px solid #0090d9;border-radius:5px;color:rgba(255,255,255,0.85);padding:5px 5px;text-align:center;text-decoration:none;display:inline-block;font-size:16px;margin:4px 2px;cursor:pointer}.frontend-edit-button:hover{background:#26a1df;color:#fff}.icon-feb-editor:before{padding-right:5px}
|
Binary file not shown.
|
@ -0,0 +1,12 @@
|
|||
<?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 Fontastic.me</metadata>
|
||||
<defs>
|
||||
<font id="frontend-edit-button" horiz-adv-x="512">
|
||||
<font-face font-family="frontend-edit-button" units-per-em="512" ascent="480" descent="-32"/>
|
||||
<missing-glyph horiz-adv-x="512" />
|
||||
|
||||
<glyph glyph-name="feb-editor" unicode="r" d="M254 174l33 33-44 43-33-33 0-16 28 0 0-27z m125 205c-3 3-6 3-9 0l-100-100c-3-3-3-6 0-9 3-3 6-3 9 0l100 100c3 3 3 6 0 9z m23-169l0-55c0-22-8-42-24-58-16-16-35-24-58-24l-238 0c-22 0-42 8-58 24-16 16-24 36-24 58l0 238c0 23 8 42 24 58 16 16 36 24 58 24l238 0c12 0 23-2 33-7 3-1 5-3 6-6 0-4-1-6-3-9l-14-14c-3-2-6-3-9-2-5 1-9 2-13 2l-238 0c-12 0-23-5-32-14-9-9-13-19-13-32l0-238c0-12 4-23 13-32 9-9 20-13 32-13l238 0c13 0 23 4 32 13 9 9 14 20 14 32l0 36c0 3 1 5 2 7l19 18c2 3 6 4 10 2 3-2 5-4 5-8z m-27 211l82-83-192-192-82 0 0 83z m127-38l-27-26-82 82 26 26c6 5 12 8 20 8 7 0 14-3 19-8l44-43c5-6 8-12 8-20 0-7-3-14-8-19z"/>
|
||||
<glyph glyph-name="feb-pencil" unicode="a" d="M140 73l26 26-67 67-26-26 0-30 37 0 0-37z m150 265c0 4-2 7-7 7-1 0-3-1-4-2l-155-155c-2-2-2-3-2-5 0-4 2-6 6-6 2 0 4 0 5 2l155 154c1 2 2 3 2 5z m-16 55l119-119-238-237-118 0 0 118z m195-27c0-10-3-19-10-26l-48-47-118 118 47 48c7 7 15 10 26 10 10 0 18-3 26-10l67-67c7-8 10-16 10-26z"/>
|
||||
</font></defs></svg>
|
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
Binary file not shown.
56
plugins/frontend-edit-button/assets/icons-reference.html
Normal file
56
plugins/frontend-edit-button/assets/icons-reference.html
Normal file
|
@ -0,0 +1,56 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Font Reference - frontend-edit-button</title>
|
||||
<link href="http://fonts.googleapis.com/css?family=Dosis:400,500,700" rel="stylesheet" type="text/css">
|
||||
<link rel="stylesheet" href="styles.css">
|
||||
<style type="text/css">html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;outline:0;font-weight:inherit;font-style:inherit;font-family:inherit;font-size:100%;vertical-align:baseline}body{line-height:1;color:#000;background:#fff}ol,ul{list-style:none}table{border-collapse:separate;border-spacing:0;vertical-align:middle}caption,th,td{text-align:left;font-weight:normal;vertical-align:middle}a img{border:none}*{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}body{font-family:'Dosis','Tahoma',sans-serif}.container{margin:15px auto;width:80%}h1{margin:40px 0 20px;font-weight:700;font-size:38px;line-height:32px;color:#fb565e}h2{font-size:18px;padding:0 0 21px 5px;margin:45px 0 0 0;text-transform:uppercase;font-weight:500}.small{font-size:14px;color:#a5adb4;}.small a{color:#a5adb4;}.small a:hover{color:#fb565e}.glyphs.character-mapping{margin:0 0 20px 0;padding:20px 0 20px 30px;color:rgba(0,0,0,0.5);border:1px solid #d8e0e5;-webkit-border-radius:3px;border-radius:3px;}.glyphs.character-mapping li{margin:0 30px 20px 0;display:inline-block;width:90px}.glyphs.character-mapping .icon{margin:10px 0 10px 15px;padding:15px;position:relative;width:55px;height:55px;color:#162a36 !important;overflow:hidden;-webkit-border-radius:3px;border-radius:3px;font-size:32px;}.glyphs.character-mapping .icon svg{fill:#000}.glyphs.character-mapping input{margin:0;padding:5px 0;line-height:12px;font-size:12px;display:block;width:100%;border:1px solid #d8e0e5;-webkit-border-radius:5px;border-radius:5px;text-align:center;outline:0;}.glyphs.character-mapping input:focus{border:1px solid #fbde4a;-webkit-box-shadow:inset 0 0 3px #fbde4a;box-shadow:inset 0 0 3px #fbde4a}.glyphs.character-mapping input:hover{-webkit-box-shadow:inset 0 0 3px #fbde4a;box-shadow:inset 0 0 3px #fbde4a}.glyphs.css-mapping{margin:0 0 60px 0;padding:30px 0 20px 30px;color:rgba(0,0,0,0.5);border:1px solid #d8e0e5;-webkit-border-radius:3px;border-radius:3px;}.glyphs.css-mapping li{margin:0 30px 20px 0;padding:0;display:inline-block;overflow:hidden}.glyphs.css-mapping .icon{margin:0;margin-right:10px;padding:13px;height:50px;width:50px;color:#162a36 !important;overflow:hidden;float:left;font-size:24px}.glyphs.css-mapping input{margin:0;margin-top:5px;padding:8px;line-height:16px;font-size:16px;display:block;width:150px;height:40px;border:1px solid #d8e0e5;-webkit-border-radius:5px;border-radius:5px;background:#fff;outline:0;float:right;}.glyphs.css-mapping input:focus{border:1px solid #fbde4a;-webkit-box-shadow:inset 0 0 3px #fbde4a;box-shadow:inset 0 0 3px #fbde4a}.glyphs.css-mapping input:hover{-webkit-box-shadow:inset 0 0 3px #fbde4a;box-shadow:inset 0 0 3px #fbde4a}</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>frontend-edit-button</h1>
|
||||
<p class="small">This font was created with<a href="http://fontastic.me/">Fontastic</a></p>
|
||||
<h2>CSS mapping</h2>
|
||||
<ul class="glyphs css-mapping">
|
||||
<li>
|
||||
<div class="icon icon-feb-editor"></div>
|
||||
<input type="text" readonly="readonly" value="feb-editor">
|
||||
</li>
|
||||
<li>
|
||||
<div class="icon icon-feb-pencil"></div>
|
||||
<input type="text" readonly="readonly" value="feb-pencil">
|
||||
</li>
|
||||
</ul>
|
||||
<h2>Character mapping</h2>
|
||||
<ul class="glyphs character-mapping">
|
||||
<li>
|
||||
<div data-icon="r" class="icon"></div>
|
||||
<input type="text" readonly="readonly" value="r">
|
||||
</li>
|
||||
<li>
|
||||
<div data-icon="a" class="icon"></div>
|
||||
<input type="text" readonly="readonly" value="a">
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<script>(function() {
|
||||
var glyphs, i, len, ref;
|
||||
|
||||
ref = document.getElementsByClassName('glyphs');
|
||||
for (i = 0, len = ref.length; i < len; i++) {
|
||||
glyphs = ref[i];
|
||||
glyphs.addEventListener('click', function(event) {
|
||||
if (event.target.tagName === 'INPUT') {
|
||||
return event.target.select();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}).call(this);
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
19
plugins/frontend-edit-button/assets/js/script.js
Normal file
19
plugins/frontend-edit-button/assets/js/script.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
var frontEditButton_refreshMe = false;
|
||||
|
||||
function onBlur () {
|
||||
frontEditButton_refreshMe = true;
|
||||
}
|
||||
function onFocus () {
|
||||
if (frontEditButton_refreshMe) {
|
||||
window.location.reload(true);
|
||||
}
|
||||
}
|
||||
|
||||
// check for Internet Explorer
|
||||
if (/*@cc_on!@*/false) {
|
||||
document.onfocusin = onFocus;
|
||||
document.onfocusout = onBlur;
|
||||
} else {
|
||||
window.onfocus = onFocus;
|
||||
window.onblur = onBlur;
|
||||
}
|
2
plugins/frontend-edit-button/assets/sass.cmd
Normal file
2
plugins/frontend-edit-button/assets/sass.cmd
Normal file
|
@ -0,0 +1,2 @@
|
|||
#!/bin/sh
|
||||
scss --watch --sourcemap=auto scss:css
|
55
plugins/frontend-edit-button/assets/scss/style.scss
Normal file
55
plugins/frontend-edit-button/assets/scss/style.scss
Normal file
|
@ -0,0 +1,55 @@
|
|||
$button-color: rgba(255,255,255,0.85);
|
||||
$button-color-hover: #fff;
|
||||
$button-bg-color: #0090D9;
|
||||
$button-bg-color-hover: #26a1df;
|
||||
$button-border-color: $button-bg-color;
|
||||
$button-label-color: $button-color;
|
||||
|
||||
#frontend-edit-button {
|
||||
position: fixed;
|
||||
z-index: 10000;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
#frontend-edit-button .label {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
#frontend-edit-button.top {
|
||||
top: 0;
|
||||
}
|
||||
|
||||
#frontend-edit-button.bottom {
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
#frontend-edit-button.left {
|
||||
left: 0;
|
||||
}
|
||||
|
||||
#frontend-edit-button.right {
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.frontend-edit-button {
|
||||
background-color: $button-bg-color;
|
||||
border: 1px solid $button-border-color;
|
||||
border-radius: 5px;
|
||||
color: $button-color;
|
||||
padding: 5px 5px;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
font-size: 16px;
|
||||
margin: 4px 2px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.frontend-edit-button:hover {
|
||||
background: $button-bg-color-hover;
|
||||
color: $button-color-hover;
|
||||
}
|
||||
|
||||
.icon-feb-editor:before {
|
||||
padding-right: 5px;
|
||||
}
|
46
plugins/frontend-edit-button/assets/styles.css
Normal file
46
plugins/frontend-edit-button/assets/styles.css
Normal file
|
@ -0,0 +1,46 @@
|
|||
@charset "UTF-8";
|
||||
|
||||
@font-face {
|
||||
font-family: "frontend-edit-button";
|
||||
src:url("fonts/frontend-edit-button.eot");
|
||||
src:url("fonts/frontend-edit-button.eot?#iefix") format("embedded-opentype"),
|
||||
url("fonts/frontend-edit-button.woff") format("woff"),
|
||||
url("fonts/frontend-edit-button.ttf") format("truetype"),
|
||||
url("fonts/frontend-edit-button.svg#frontend-edit-button") format("svg");
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
|
||||
}
|
||||
|
||||
[data-icon]:before {
|
||||
font-family: "frontend-edit-button" !important;
|
||||
content: attr(data-icon);
|
||||
font-style: normal !important;
|
||||
font-weight: normal !important;
|
||||
font-variant: normal !important;
|
||||
text-transform: none !important;
|
||||
speak: none;
|
||||
line-height: 1;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
[class^="icon-"]:before,
|
||||
[class*=" icon-"]:before {
|
||||
font-family: "frontend-edit-button" !important;
|
||||
font-style: normal !important;
|
||||
font-weight: normal !important;
|
||||
font-variant: normal !important;
|
||||
text-transform: none !important;
|
||||
speak: none;
|
||||
line-height: 1;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
.icon-feb-editor:before {
|
||||
content: "\72";
|
||||
}
|
||||
.icon-feb-pencil:before {
|
||||
content: "\61";
|
||||
}
|
80
plugins/frontend-edit-button/blueprints.yaml
Normal file
80
plugins/frontend-edit-button/blueprints.yaml
Normal file
|
@ -0,0 +1,80 @@
|
|||
name: Frontend Edit Button
|
||||
version: 1.2.2
|
||||
description: Adds an 'edit this page' on the frontend when logged in as administrator
|
||||
icon: newspaper-o
|
||||
author:
|
||||
name: Johan van de Merwe
|
||||
email: j.vd.merwe@enovision.net
|
||||
url: https://github.com/enovision
|
||||
homepage: https://github.com/enovision/grav-frontend-edit-button
|
||||
keywords: grav, plugin, frontend
|
||||
bugs: https://github.com/enovision/grav-frontend-edit-button/issues
|
||||
docs: https://github.com/enovision/grav-frontend-edit-button/blob/master/README.md
|
||||
license: MIT
|
||||
|
||||
form:
|
||||
validation: strict
|
||||
fields:
|
||||
enabled:
|
||||
type: toggle
|
||||
label: Plugin status
|
||||
highlight: 1
|
||||
default: 0
|
||||
options:
|
||||
1: PLUGIN_FRONTEND_EDIT_BUTTON.ENABLED
|
||||
0: PLUGIN_FRONTEND_EDIT_BUTTON.DISABLED
|
||||
validate:
|
||||
type: bool
|
||||
position:
|
||||
type: select
|
||||
label: PLUGIN_FRONTEND_EDIT_BUTTON.POSITION_LABEL
|
||||
help: PLUGIN_FRONTEND_EDIT_BUTTON.POSITION_LABEL_HELP
|
||||
size: medium
|
||||
highlight: tr
|
||||
options:
|
||||
tl: PLUGIN_FRONTEND_EDIT_BUTTON.TOP_LEFT
|
||||
tr: PLUGIN_FRONTEND_EDIT_BUTTON.TOP_RIGHT
|
||||
bl: PLUGIN_FRONTEND_EDIT_BUTTON.BOTTOM_LEFT
|
||||
br: PLUGIN_FRONTEND_EDIT_BUTTON.BOTTOM_RIGHT
|
||||
showLabel:
|
||||
type: toggle
|
||||
label: PLUGIN_FRONTEND_EDIT_BUTTON.SHOW_LABEL
|
||||
highlight: 1
|
||||
default: 0
|
||||
options:
|
||||
1: PLUGIN_FRONTEND_EDIT_BUTTON.ENABLED
|
||||
0: PLUGIN_FRONTEND_EDIT_BUTTON.DISABLED
|
||||
validate:
|
||||
type: bool
|
||||
showIcon:
|
||||
type: toggle
|
||||
label: PLUGIN_FRONTEND_EDIT_BUTTON.SHOW_ICON
|
||||
highlight: 1
|
||||
default: 0
|
||||
options:
|
||||
1: PLUGIN_FRONTEND_EDIT_BUTTON.ENABLED
|
||||
0: PLUGIN_FRONTEND_EDIT_BUTTON.DISABLED
|
||||
validate:
|
||||
type: bool
|
||||
requiresAuth:
|
||||
type: toggle
|
||||
label: PLUGIN_FRONTEND_EDIT_BUTTON.REQUIRES_AUTH_LABEL
|
||||
help: PLUGIN_FRONTEND_EDIT_BUTTON.REQUIRES_AUTH_LABEL_HELP
|
||||
highlight: 1
|
||||
default: 1
|
||||
options:
|
||||
1: PLUGIN_FRONTEND_EDIT_BUTTON.ENABLED
|
||||
0: PLUGIN_FRONTEND_EDIT_BUTTON.DISABLED
|
||||
validate:
|
||||
type: bool
|
||||
autoRefresh:
|
||||
type: toggle
|
||||
label: PLUGIN_FRONTEND_EDIT_BUTTON.AUTO_REFRESH_LABEL
|
||||
help: PLUGIN_FRONTEND_EDIT_BUTTON.AUTO_REFRESH_LABEL_HELP
|
||||
highlight: 1
|
||||
default: 1
|
||||
options:
|
||||
1: PLUGIN_FRONTEND_EDIT_BUTTON.ENABLED
|
||||
0: PLUGIN_FRONTEND_EDIT_BUTTON.DISABLED
|
||||
validate:
|
||||
type: bool
|
309
plugins/frontend-edit-button/frontend-edit-button.php
Normal file
309
plugins/frontend-edit-button/frontend-edit-button.php
Normal file
|
@ -0,0 +1,309 @@
|
|||
<?php
|
||||
/**
|
||||
* frontend-edit-button
|
||||
*
|
||||
* This plugin adds an 'edit this page' button on the frontend
|
||||
*
|
||||
* Licensed under MIT, see LICENSE.
|
||||
*/
|
||||
|
||||
namespace Grav\Plugin;
|
||||
|
||||
use Grav\Common\Page;
|
||||
use Grav\Common\Plugin;
|
||||
use Grav\Plugin\Login\Events\UserLoginEvent;
|
||||
use RocketTheme\Toolbox\Event\Event;
|
||||
|
||||
/**
|
||||
* Class FrontendEditButtonPlugin
|
||||
* @package Grav\Plugin
|
||||
*/
|
||||
class FrontendEditButtonPlugin extends Plugin
|
||||
{
|
||||
|
||||
private $_config = null;
|
||||
private $adminRoute = '/admin';
|
||||
|
||||
private $adminCookieSet = false;
|
||||
private $adminCookie = '';
|
||||
private $editUrl = null;
|
||||
|
||||
// private $adminCookieSuffix = '-admin-authenticated'; // till version 1.12
|
||||
private $adminCookieSuffix = '-admin'; // since version 1.12.1
|
||||
|
||||
/**
|
||||
* @function getSubscribedEvents
|
||||
* @return array
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return [
|
||||
'onPluginsInitialized' => ['onPluginsInitialized', 0]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @event onPluginsInitialized
|
||||
*
|
||||
* It is only allowed to process when:
|
||||
* - we are not on an admin page already
|
||||
* - Admin is logged in in any of the other tabs
|
||||
* - Login plugin is enabled
|
||||
* - Admin plugin is enabled
|
||||
* - This plugin is enabled (but that it is)
|
||||
* - Page has no frontmatter: protectEdit: true
|
||||
*
|
||||
*/
|
||||
public function onPluginsInitialized()
|
||||
{
|
||||
$this->adminCookie = session_name();
|
||||
|
||||
$this->enable([
|
||||
'onUserLogin' => ['onUserLogin', 0],
|
||||
'onUserLogout' => ['onUserLogout', 0]
|
||||
]);
|
||||
|
||||
if ($this->isAdmin()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$config = $this->grav['config'];
|
||||
|
||||
if ($config->get('plugins.frontend-edit-button.requiresAuth')) {
|
||||
if (isset($_COOKIE[$this->adminCookie]) === false) {
|
||||
return;
|
||||
}
|
||||
$this->adminCookieSet = true;
|
||||
}
|
||||
|
||||
/* Stop if no users exist */
|
||||
if ($this->doAnyUsersExist() === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$plugins = $config->get('plugins');
|
||||
|
||||
$adminPlugin = isset($plugins['admin']) ? $this->config->get('plugins.admin') : false;
|
||||
$loginPlugin = isset($plugins['login']) ? $this->config->get('plugins.login') : false;
|
||||
|
||||
$this->adminRoute = $adminPlugin !== false ? $adminPlugin['route'] : $this->adminRoute;
|
||||
|
||||
// Works only with the login and admin plugin installed and enabled
|
||||
if ($adminPlugin === false || $loginPlugin === false) {
|
||||
return;
|
||||
} else {
|
||||
if ($adminPlugin['enabled'] === false || $loginPlugin['enabled'] === false) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$this->enable([
|
||||
'onPageContentProcessed' => ['onPageContentProcessed', 0],
|
||||
'onTwigSiteVariables' => ['onTwigSiteVariables', 0],
|
||||
'onOutputGenerated' => ['onOutputGenerated', 0],
|
||||
'onTwigTemplatePaths' => ['onTwigTemplatePaths', 0]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* check for any users, see admin.php
|
||||
*/
|
||||
private function doAnyUsersExist()
|
||||
{
|
||||
$account_dir = $file_path = $this->grav['locator']->findResource('account://');
|
||||
$user_check = glob($account_dir . '/*.yaml');
|
||||
|
||||
// If no users found, stop here !!!
|
||||
return $user_check == false || count((array)$user_check) == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @event onPageContentProcessed
|
||||
*
|
||||
* @param Event $event
|
||||
*/
|
||||
public function onPageContentProcessed(Event $event)
|
||||
{
|
||||
$page = $event['page'];
|
||||
$this->_config = $this->mergeConfig($page);
|
||||
}
|
||||
|
||||
/**
|
||||
* @event onOutputGenerated
|
||||
*/
|
||||
public function onOutputGenerated()
|
||||
{
|
||||
if ($this->isAdmin()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// frontend !!!
|
||||
// $this->adminCookie = session_name() . '-admin-authenticated'; // till version 1.12
|
||||
$this->adminCookie = session_name() . $this->adminCookieSuffix; // since version 1.12.1
|
||||
|
||||
$page = $this->grav['page'];
|
||||
|
||||
$header = $page->header();
|
||||
|
||||
$adminCookie = $this->getAdminCookie();
|
||||
|
||||
if ((isset($header->protectEdit) && $header->protectEdit == true) || $adminCookie === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$content = $this->grav->output;
|
||||
|
||||
$twig = $this->grav['twig'];
|
||||
|
||||
$position = $this->config->get('plugins.frontend-edit-button.position');
|
||||
|
||||
$vertical = substr($position, 0, 1) === 't' ? 'top' : 'bottom';
|
||||
$horizontal = substr($position, 1, 1) === 'l' ? 'left' : 'right';
|
||||
|
||||
//$pageUrl = $page->url( false, false, true, false );
|
||||
$uri = $this->grav['uri'];
|
||||
//$pageUrl = $uri->url(false, false);
|
||||
$pageUrl = $uri->path();
|
||||
|
||||
/* otherwise the home page can't be edited */
|
||||
if ($pageUrl == '/') {
|
||||
$pageUrl .= $page->slug();
|
||||
}
|
||||
|
||||
if (isset($header->editUrl)) {
|
||||
$editUrl = $header->editUrl;
|
||||
} else {
|
||||
$editUrl = $uri->rootUrl(true) . $this->adminRoute . '/pages' . $pageUrl;
|
||||
}
|
||||
|
||||
$this->editUrl = $editUrl;
|
||||
|
||||
$icon = $uri->base() . '/' . $this->config->get('plugins.frontend-edit-button.iconSrc');
|
||||
|
||||
$params = array(
|
||||
'config' => $this->_config,
|
||||
'header' => $header,
|
||||
'horizontal' => $horizontal,
|
||||
'vertical' => $vertical,
|
||||
'pageUrl' => $pageUrl,
|
||||
'editUrl' => $editUrl,
|
||||
'icon' => $icon,
|
||||
'adminCookieSet' => $adminCookie
|
||||
);
|
||||
|
||||
$insertThis = $twig->processTemplate('partials/edit-button.html.twig', $params);
|
||||
|
||||
$pos = strpos($content, '<body', 0);
|
||||
|
||||
if ($pos > 0) {
|
||||
|
||||
$pos = strpos($content, '>', $pos);
|
||||
|
||||
if ($pos > 0) {
|
||||
|
||||
$str1 = substr($content, 0, $pos + 1);
|
||||
$str2 = substr($content, $pos + 1);
|
||||
|
||||
$content = $str1 . $insertThis . $str2;
|
||||
|
||||
$this->grav->output = $content;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getAdminCookie()
|
||||
{
|
||||
$this->adminCookieSet = false;
|
||||
|
||||
if ($this->config->get('plugins.frontend-edit-button.requiresAuth')) {
|
||||
if (isset($_COOKIE[$this->adminCookie]) === true) {
|
||||
$this->adminCookieSet = true;
|
||||
}
|
||||
} else {
|
||||
$this->adminCookieSet = true;
|
||||
}
|
||||
|
||||
return $this->adminCookieSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @event onTwigSiteVariables
|
||||
*/
|
||||
public function onTwigSiteVariables()
|
||||
{
|
||||
$page = $this->grav['page'];
|
||||
$header = $page->header();
|
||||
|
||||
if (isset($header->protectEdit) && $header->protectEdit == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->adminCookie = session_name() . $this->adminCookieSuffix;
|
||||
$adminCookie = $this->getAdminCookie();
|
||||
|
||||
$this->grav['assets']
|
||||
->addCss('plugin://frontend-edit-button/assets/css/style.css');
|
||||
|
||||
if ($this->config->get('plugins.frontend-edit-button.autoRefresh') === true && $adminCookie === true) {
|
||||
$this->grav['assets']
|
||||
->addJs('plugin://frontend-edit-button/assets/js/script.js');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @event onTwigTemplatePaths
|
||||
*/
|
||||
public function onTwigTemplatePaths()
|
||||
{
|
||||
$this->grav['twig']->twig_paths[] = __DIR__ . '/templates';
|
||||
}
|
||||
|
||||
/**
|
||||
* @event onUserLogout
|
||||
*
|
||||
* Hook on onUserLogout of the Login plugin
|
||||
* It should remove the cookie
|
||||
*/
|
||||
public function onUserLogout(UserLoginEvent $event)
|
||||
{
|
||||
$user = $event->getUser();
|
||||
|
||||
$params = session_get_cookie_params();
|
||||
// $cookieName = session_name() . '-authenticated'; // till version 1.12
|
||||
$cookieName = session_name(); // since version 1.12.1
|
||||
|
||||
setcookie(
|
||||
$cookieName,
|
||||
session_id(),
|
||||
time() - 42000,
|
||||
$params['path'],
|
||||
$params['domain'],
|
||||
$params['secure'],
|
||||
$params['httponly']
|
||||
);
|
||||
}
|
||||
|
||||
public function onUserLogin(UserLoginEvent $event)
|
||||
{
|
||||
$user = $event->getUser();
|
||||
|
||||
if ($user->authenticated) {
|
||||
|
||||
$params = session_get_cookie_params();
|
||||
// $cookieName = session_name() . '-authenticated'; // till version 1.12
|
||||
$cookieName = session_name(); // since version 1.12.1
|
||||
|
||||
setcookie(
|
||||
$cookieName,
|
||||
session_id(),
|
||||
time() + $params['lifetime'],
|
||||
$params['path'],
|
||||
$params['domain'],
|
||||
$params['secure'],
|
||||
$params['httponly']
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
5
plugins/frontend-edit-button/frontend-edit-button.yaml
Normal file
5
plugins/frontend-edit-button/frontend-edit-button.yaml
Normal file
|
@ -0,0 +1,5 @@
|
|||
enabled: true
|
||||
position: tr
|
||||
showLabel: true
|
||||
showIcon: true
|
||||
iconSrc: user/plugins/frontend-edit-button/images/icons/edit.png
|
19
plugins/frontend-edit-button/js/script.js
Normal file
19
plugins/frontend-edit-button/js/script.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
var frontEditButton_refreshMe = false;
|
||||
|
||||
function onBlur () {
|
||||
frontEditButton_refreshMe = true;
|
||||
}
|
||||
function onFocus () {
|
||||
if (frontEditButton_refreshMe) {
|
||||
window.location.reload(true);
|
||||
}
|
||||
}
|
||||
|
||||
// check for Internet Explorer
|
||||
if (/*@cc_on!@*/false) {
|
||||
document.onfocusin = onFocus;
|
||||
document.onfocusout = onBlur;
|
||||
} else {
|
||||
window.onfocus = onFocus;
|
||||
window.onblur = onBlur;
|
||||
}
|
142
plugins/frontend-edit-button/languages.yaml
Normal file
142
plugins/frontend-edit-button/languages.yaml
Normal file
|
@ -0,0 +1,142 @@
|
|||
en:
|
||||
PLUGIN_FRONTEND_EDIT_BUTTON:
|
||||
ENABLED: Enabled
|
||||
DISABLED: Disabled
|
||||
POSITION_LABEL: Label Position
|
||||
POSITION_LABEL_HELP: Where to put the button on the frontend
|
||||
SHOW_LABEL: Show text on button
|
||||
SHOW_ICON: Show icon on button
|
||||
BUTTON_TEXT: Edit this Page
|
||||
TOP_LEFT: Top Left
|
||||
TOP_RIGHT: Top Right
|
||||
BOTTOM_LEFT: Bottom Left
|
||||
BOTTOM_RIGHT: Bottom Right
|
||||
REQUIRES_AUTH_LABEL: Only visible after login
|
||||
REQUIRES_AUTH_LABEL_HELP: If deactivated, the button will always be shown if the required plugins are active.
|
||||
AUTO_REFRESH_LABEL: Automatic refresh of content
|
||||
AUTO_REFRESH_LABEL_HELP: If activated, content within pages will automatically refreshed when the tab in the browser is clicked.
|
||||
de:
|
||||
PLUGIN_FRONTEND_EDIT_BUTTON:
|
||||
ENABLED: Aktiviert
|
||||
DISABLED: Deaktiviert
|
||||
POSITION_LABEL: Position
|
||||
POSITION_LABEL_HELP: Wo soll der Button angezeigt werden
|
||||
SHOW_LABEL: Text auf dem Button anzeigen
|
||||
SHOW_ICON: Symbol auf dem Button anzeigen
|
||||
BUTTON_TEXT: Bearbeiten
|
||||
TOP_LEFT: Linksoben
|
||||
TOP_RIGHT: Rechtsoben
|
||||
BOTTOM_LEFT: Linksuntern
|
||||
BOTTOM_RIGHT: Rechtsuntern
|
||||
REQUIRES_AUTH_LABEL: Nur anzeigen wen eingeloggt
|
||||
REQUIRES_AUTH_LABEL_HELP: Wenn deaktiviert, wird der Button immer angezeigt wenn die benötigten Plugins aktiviert sind.
|
||||
AUTO_REFRESH_LABEL: Automatisch erfrischen von Inhalte
|
||||
AUTO_REFRESH_LABEL_HELP: Wenn aktiviert, Inhalte auf Seiten werden automatisch erfrischt wenn der Reiter im Browser geklickt wird.
|
||||
|
||||
hr:
|
||||
PLUGIN_FRONTEND_EDIT_BUTTON:
|
||||
ENABLED: Omogućen
|
||||
DISABLED: Onemogućen
|
||||
POSITION_LABEL: Položaj gumba
|
||||
POSITION_LABEL_HELP: Gdje da postavim gumb na stranici
|
||||
SHOW_LABEL: Prikaži text na gumbu
|
||||
SHOW_ICON: Prikaži ikonu na gumbu
|
||||
BUTTON_TEXT: Uredi ovu stranicu
|
||||
TOP_LEFT: Gore Lijevo
|
||||
TOP_RIGHT: Gore Desno
|
||||
BOTTOM_LEFT: Dolje Lijevo
|
||||
BOTTOM_RIGHT: Dolje Desno
|
||||
REQUIRES_AUTH_LABEL: Vidljiv samo nakon prijave.
|
||||
REQUIRES_AUTH_LABEL_HELP: Ako je deaktiviran, gumb će uvijek biti prikazan ako su potrebni plugini aktivni.
|
||||
AUTO_REFRESH_LABEL: Automatic refresh of pages
|
||||
AUTO_REFRESH_LABEL_HELP: If activated, pages will automatically refreshed when the tab in the browser is clicked.
|
||||
|
||||
nl:
|
||||
PLUGIN_FRONTEND_EDIT_BUTTON:
|
||||
ENABLED: Ingeschakeld
|
||||
DISABLED: Uitgeschakeld
|
||||
POSITION_LABEL: Positie van de button
|
||||
POSITION_LABEL_HELP: Waar moet de button worden getoond
|
||||
SHOW_LABEL: Tonen tekst op de button
|
||||
SHOW_ICON: Tonen icon op de button
|
||||
BUTTON_TEXT: Pagina wijzigen
|
||||
TOP_LEFT: Linksboven
|
||||
TOP_RIGHT: Rechtsboven
|
||||
BOTTOM_LEFT: Linksonder
|
||||
BOTTOM_RIGHT: Rechtsonder
|
||||
REQUIRES_AUTH_LABEL: Alleen zichtbaar indien ingelogt
|
||||
REQUIRES_AUTH_LABEL_HELP: Indien inaktief, wordt de button altijd getoond als de plugin aktief is.
|
||||
AUTO_REFRESH_LABEL: Automatisch updaten van de inhoud
|
||||
AUTO_REFRESH_LABEL_HELP: Indien aktief, inhoud van pagina's wordt automatisch bijgewerkt indien op de tab in de browser wordt geklikt.
|
||||
|
||||
es:
|
||||
PLUGIN_FRONTEND_EDIT_BUTTON:
|
||||
ENABLED: Habilitado
|
||||
DISABLED: Deshabilitado
|
||||
POSITION_LABEL: Posición de etiqueta
|
||||
POSITION_LABEL_HELP: Donde poner el botón en la portada
|
||||
SHOW_LABEL: Muestra la etiqueta
|
||||
SHOW_ICON: Muestra el icono en el botón
|
||||
BUTTON_TEXT: Editar
|
||||
TOP_LEFT: Arriba a la izquierda
|
||||
TOP_RIGHT: Arriba a la derecha
|
||||
BOTTOM_LEFT: Debajo a la izquierda
|
||||
BOTTOM_RIGHT: Debajo a la derecha
|
||||
REQUIRES_AUTH_LABEL: Solo visible después del inicio de sesión
|
||||
REQUIRES_AUTH_LABEL_HELP: Si se desactiva, el botón siempre se mostrará si los complementos necesarios están activos.
|
||||
AUTO_REFRESH_LABEL: Automatic refresh of content
|
||||
AUTO_REFRESH_LABEL_HELP: If activated, content within pages will automatically refreshed when the tab in the browser is clicked.
|
||||
|
||||
ca:
|
||||
PLUGIN_FRONTEND_EDIT_BUTTON:
|
||||
ENABLED: Habilitat
|
||||
DISABLED: Deshabilitat
|
||||
POSITION_LABEL: Posició d'etiqueta
|
||||
POSITION_LABEL_HELP: On posar el botó a la portada
|
||||
SHOW_LABEL: Mostra l'etiqueta
|
||||
SHOW_ICON: Mostra la icona al botó
|
||||
BUTTON_TEXT: Edita
|
||||
TOP_LEFT: A dalt a l'esquerra
|
||||
TOP_RIGHT: A dalt a la dreta
|
||||
BOTTOM_LEFT: A sota a l'esquerra
|
||||
BOTTOM_RIGHT: A sota a la dreta
|
||||
REQUIRES_AUTH_LABEL: Només visible després d'iniciar sessió
|
||||
REQUIRES_AUTH_LABEL_HELP: Si està desactivat, el botó sempre es mostrarà si els connectors requerits estan actius.
|
||||
AUTO_REFRESH_LABEL: Automatic refresh of content
|
||||
AUTO_REFRESH_LABEL_HELP: If activated, content within pages will automatically refreshed when the tab in the browser is clicked.
|
||||
|
||||
fr:
|
||||
PLUGIN_FRONTEND_EDIT_BUTTON:
|
||||
ENABLED: Activé
|
||||
DISABLED: Désactivé
|
||||
POSITION_LABEL: Position du tag
|
||||
POSITION_LABEL_HELP: Où mettre le bouton sur la couverture
|
||||
SHOW_LABEL: Afficher le tag
|
||||
SHOW_ICON: Afficher l'icône sur le bouton
|
||||
BUTTON_TEXT: Modifier
|
||||
TOP_LEFT: En haut à gauche
|
||||
TOP_RIGHT: En haut à droite
|
||||
BOTTOM_LEFT: Ci-dessous à gauche
|
||||
BOTTOM_RIGHT: Ci-dessous à droite
|
||||
REQUIRES_AUTH_LABEL: Seulement visible après la connexion
|
||||
REQUIRES_AUTH_LABEL_HELP: Si désactivé, le bouton sera toujours affiché si les plugins requis sont actifs.
|
||||
AUTO_REFRESH_LABEL: Automatic refresh of content
|
||||
AUTO_REFRESH_LABEL_HELP: If activated, content within pages will automatically refreshed when the tab in the browser is clicked.
|
||||
|
||||
pt:
|
||||
PLUGIN_FRONTEND_EDIT_BUTTON:
|
||||
ENABLED: Habilitado
|
||||
DISABLED: Desabilitado
|
||||
POSITION_LABEL: Posição do texto
|
||||
POSITION_LABEL_HELP: Onde posicionar o botão no frontend
|
||||
SHOW_LABEL: Mostrar texto do botão
|
||||
SHOW_ICON: Mostrar ícone do botão
|
||||
BUTTON_TEXT: Editar esta página
|
||||
TOP_LEFT: No topo à esquerda
|
||||
TOP_RIGHT: No topo à direita
|
||||
BOTTOM_LEFT: Embaixo à esquerda
|
||||
BOTTOM_RIGHT: Embaixo à direita
|
||||
REQUIRES_AUTH_LABEL: Apenas visível após login
|
||||
REQUIRES_AUTH_LABEL_HELP: Se desativado, o botão sempre será mostrado se os plugins necessários estiverem ativos.
|
||||
AUTO_REFRESH_LABEL: Atualização automática de conteúdo
|
||||
AUTO_REFRESH_LABEL_HELP: Se ativado, o conteúdo das páginas será atualizado automaticamente quando a aba do navegador for clicada.
|
2
plugins/frontend-edit-button/scss.sh
Normal file
2
plugins/frontend-edit-button/scss.sh
Normal file
|
@ -0,0 +1,2 @@
|
|||
#!/bin/sh
|
||||
scss --watch scss:assets/css-compiled
|
55
plugins/frontend-edit-button/scss/style.scss
Normal file
55
plugins/frontend-edit-button/scss/style.scss
Normal file
|
@ -0,0 +1,55 @@
|
|||
$button-color: rgba(255,255,255,0.85);
|
||||
$button-color-hover: #fff;
|
||||
$button-bg-color: #0090D9;
|
||||
$button-bg-color-hover: #26a1df;
|
||||
$button-border-color: $button-bg-color;
|
||||
$button-label-color: $button-color;
|
||||
|
||||
#frontend-edit-button {
|
||||
position: fixed;
|
||||
z-index: 10000;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
#frontend-edit-button .label {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
#frontend-edit-button.top {
|
||||
top: 0;
|
||||
}
|
||||
|
||||
#frontend-edit-button.bottom {
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
#frontend-edit-button.left {
|
||||
left: 0;
|
||||
}
|
||||
|
||||
#frontend-edit-button.right {
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.frontend-edit-button {
|
||||
background-color: $button-bg-color;
|
||||
border: 1px solid $button-border-color;
|
||||
border-radius: 5px;
|
||||
color: $button-color;
|
||||
padding: 5px 5px;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
font-size: 16px;
|
||||
margin: 4px 2px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.frontend-edit-button:hover {
|
||||
background: $button-bg-color-hover;
|
||||
color: $button-color-hover;
|
||||
}
|
||||
|
||||
.icon-feb-editor:before {
|
||||
padding-right: 5px;
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
{% set _showIcon = config.showIcon|defined(true) %}
|
||||
{% set _showLabel = config.showLabel|defined(true) %}
|
||||
|
||||
{% if _showLabel == false and _showIcon == false %}
|
||||
{% set _showLabel = true %}
|
||||
{% endif %}
|
||||
|
||||
<div id='frontend-edit-button' class='{{ vertical }} {{ horizontal }}'>
|
||||
<div class='page-item' data-nav-id='/grav-cms{{ pageUrl }}'>
|
||||
<a class='page-edit frontend-edit-button' target='_blank' href='{{ editUrl }}'>
|
||||
{% if _showIcon == true %}
|
||||
<i class='icon-feb-editor'></i>
|
||||
{% endif %}
|
||||
{% if _showLabel == true %}
|
||||
<span class="label">
|
||||
{{ 'PLUGIN_FRONTEND_EDIT_BUTTON.BUTTON_TEXT'|t }}
|
||||
</span>
|
||||
{% endif %}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in a new issue