first commit
This commit is contained in:
@@ -0,0 +1 @@
|
||||
/.idea
|
||||
@@ -0,0 +1,27 @@
|
||||
# v1.0.3
|
||||
## 03/07/2017
|
||||
|
||||
1. [](#bugfix)
|
||||
* Dependency from the `Login Plugin` removed. Plugin can now be used without the `Admin Panel`.
|
||||
|
||||
# v1.0.2
|
||||
## 02/17/2017
|
||||
|
||||
1. [](#bugfix)
|
||||
* Fixed a problem with the Grav Admin Plugin ([Issue #2](https://github.com/cworreschk/grav-plugin-vimeo/issues/2))
|
||||
|
||||
# v1.0.1
|
||||
## 01/09/2017
|
||||
|
||||
1. [](#improved)
|
||||
* Added french translation (@MATsxm)
|
||||
|
||||
# v1.0.0
|
||||
## 01/05/2017
|
||||
|
||||
1. [](#new)
|
||||
* Embed Vimeo videos and configure the player
|
||||
* Override the player parameters for each page
|
||||
* Button to add Vimeo videos in the content editor
|
||||
* Twig functions to embed Vimeo videos in your templates
|
||||
* Multi-Language Support
|
||||
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 Christian Worreschk (cw@marsec.de)
|
||||
|
||||
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.
|
||||
@@ -0,0 +1,121 @@
|
||||
# Vimeo Plugin
|
||||
|
||||
The **Vimeo** Plugin for [Grav CMS](http://github.com/getgrav/grav) converts markdown video links into the [Vimeo](https://vimeo.com) Universal Embed Code.
|
||||
|
||||
### Features
|
||||
- Simply embed Vimeo videos and configure the player
|
||||
- Override the player parameters for each page
|
||||
- Button to add Vimeo videos in the content editor
|
||||
- Twig functions to embed Vimeo videos in your templates
|
||||
- Multi-Language Support
|
||||
|
||||
## Installation
|
||||
|
||||
Installing the Vimeo plugin can be done in one of two 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 vimeo
|
||||
|
||||
This will install the Vimeo plugin into your `/user/plugins` directory within Grav. Its files can be found under `/your/site/grav/user/plugins/vimeo`.
|
||||
|
||||
### 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 `vimeo`. You can find these files on [GitHub](https://github.com/christian-worreschk/grav-plugin-vimeo) or via [GetGrav.org](http://getgrav.org/downloads/plugins#extras).
|
||||
|
||||
You should now have all the plugin files under
|
||||
|
||||
/your/site/grav/user/plugins/vimeo
|
||||
|
||||
> 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/vimeo/vimeo.yaml` to `user/config/plugins/vimeo.yaml` and only edit that copy.
|
||||
|
||||
Here is the default configuration and an explanation of available options:
|
||||
|
||||
```yaml
|
||||
enabled: true
|
||||
plugin_css: true
|
||||
editor_button: true
|
||||
|
||||
player_parameters:
|
||||
autopause: true
|
||||
autoplay: false
|
||||
byline: true
|
||||
color: "#00adef"
|
||||
loop: false
|
||||
player_id: ""
|
||||
portrait: true
|
||||
title: true
|
||||
```
|
||||
|
||||
* `enabled` Toggles if the Vimeo plugin is turned on or off.
|
||||
* `plugin_css` Toggles if the built in CSS for a responsive layout is used or not.
|
||||
* `editor_button` Allows you to easily add Vimeo videos in the page content editor.
|
||||
* `autopause` Enables or disables pausing this video when another video is played.
|
||||
* `autoplay` Plays the video automatically on load. Note that this won’t work on some devices.
|
||||
* `byline` Shows the user’s byline on the video.
|
||||
* `color` Specifies the color of the video controls.
|
||||
* `loop` Plays the video again when it reaches the end.
|
||||
* `player_id` A unique id for the player that will be passed back with all Javascript Vimeo API responses.
|
||||
* `portrait` Shows the user’s portrait on the video.
|
||||
* `title` Shows the title on the video.
|
||||
|
||||
> NOTE: If the owner of the video is a Plus member, `byline`,`color`, `portrait` and `title` may be overridden by their preferences..
|
||||
|
||||
|
||||
You can also set any of these settings on a per-page basis by adding them under a `vimeo:` setting in your page header. For example:
|
||||
```markdown
|
||||
---
|
||||
title: Example page
|
||||
vimeo:
|
||||
player_parameters:
|
||||
autoplay: true
|
||||
---
|
||||
|
||||
[plugin:vimeo](https://vimeo.com/123456789)
|
||||
```
|
||||
|
||||
This will embed a video and play it automatically on load.
|
||||
|
||||
## Usage
|
||||
|
||||
To use this plugin you simply need to include a vimeo URL in markdown link such as:
|
||||
```markdown
|
||||
[plugin:vimeo](https://vimeo/123456789)
|
||||
```
|
||||
|
||||
This will be converted into the following embeded HTML:
|
||||
```html
|
||||
<div class="grav-vimeo">
|
||||
<iframe src="//player.vimeo.com/video/123456789" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
|
||||
</div>
|
||||
```
|
||||
|
||||
## Twig
|
||||
|
||||
This plugin offers two [Twig](http://twig.sensiolabs.org) functions that can be used. `vimeo_embed_url()` and `vimeo_embed_video()`
|
||||
|
||||
#### vimeo_embed_url( video_id, parameters=[] )
|
||||
This function builds and returns the Vimeo embed URL like `//player.vimeo.com/video/123456789?autoplay=1`
|
||||
- `video_id` : The Vimeo video ID
|
||||
- `parameters` : An optional `array` of player parameters. See `player_parameters` in the configuration file.
|
||||
|
||||
#### vimeo_embed_video( video_id, parameters=[], div=true )
|
||||
This function builds and returns the full Vimeo embed iframe snippet.
|
||||
- `video_id` : The Vimeo video ID
|
||||
- `parameters` : An optional `array` of player parameters. See `player_parameters` in the configuration file.
|
||||
- `div` : If set to `true`, the iframe HTML code will be surrounded by a div element with the class `grav-vimeo`.
|
||||
|
||||
## Contributing
|
||||
The **Vimeo Grav Plugin** follows the [GitFlow branching model](http://nvie.com/posts/a-successful-git-branching-model), from development to release. The ```master``` branch always reflects a production-ready state while the latest development is taking place in the ```develop``` branch.
|
||||
|
||||
Each time you want to work on a fix or a new feature, create a new branch based on the ```develop``` branch: ```git checkout -b BRANCH_NAME develop```. Only pull requests to the ```develop``` branch will be merged.
|
||||
|
||||
## Copyright and license
|
||||
|
||||
Copyright © 2017 Christian Worreschk under the [MIT Licence](http://opensource.org/licenses/MIT). See [README](LICENSE).
|
||||
@@ -0,0 +1,32 @@
|
||||
(($) ->
|
||||
$ ->
|
||||
$('body').on 'grav-editor-ready', ->
|
||||
Instance = Grav.default.Forms.Fields.EditorField.Instance
|
||||
Instance.addButton vimeo:
|
||||
identifier: 'vimeo-video'
|
||||
title: GravVimeoPlugin.translations.EDITOR_BUTTON_TOOLTIP
|
||||
label: '<i class="fa fa-fw fa-vimeo"></i>'
|
||||
modes: [
|
||||
'gfm',
|
||||
'markdown'
|
||||
]
|
||||
action: (e) ->
|
||||
e.button.on 'click.editor.vimeo', ->
|
||||
videoId = prompt(GravVimeoPlugin.translations.EDITOR_BUTTON_PROMPT);
|
||||
if videoId
|
||||
text = "[plugin:vimeo](https://vimeo.com/#{videoId})"
|
||||
|
||||
pos = e.codemirror.getDoc().getCursor(true)
|
||||
posend = e.codemirror.getDoc().getCursor(false)
|
||||
|
||||
for l in [pos.line..posend.line]
|
||||
e.codemirror.replaceRange( text + e.codemirror.getLine(l), { line: l, ch: 0 }, { line: l, ch: e.codemirror.getLine(l).length })
|
||||
|
||||
e.codemirror.setCursor({ line: posend.line, ch: e.codemirror.getLine(posend.line).length })
|
||||
e.codemirror.focus()
|
||||
return
|
||||
return
|
||||
return
|
||||
return
|
||||
return
|
||||
) jQuery
|
||||
@@ -0,0 +1,42 @@
|
||||
// Generated by CoffeeScript 1.11.1
|
||||
(function($) {
|
||||
$(function() {
|
||||
$('body').on('grav-editor-ready', function() {
|
||||
var Instance;
|
||||
Instance = Grav["default"].Forms.Fields.EditorField.Instance;
|
||||
Instance.addButton({
|
||||
vimeo: {
|
||||
identifier: 'vimeo-video',
|
||||
title: GravVimeoPlugin.translations.EDITOR_BUTTON_TOOLTIP,
|
||||
label: '<i class="fa fa-fw fa-vimeo"></i>',
|
||||
modes: ['gfm', 'markdown'],
|
||||
action: function(e) {
|
||||
e.button.on('click.editor.vimeo', function() {
|
||||
var i, l, pos, posend, ref, ref1, text, videoId;
|
||||
videoId = prompt(GravVimeoPlugin.translations.EDITOR_BUTTON_PROMPT);
|
||||
if (videoId) {
|
||||
text = "[plugin:vimeo](https://vimeo.com/" + videoId + ")";
|
||||
pos = e.codemirror.getDoc().getCursor(true);
|
||||
posend = e.codemirror.getDoc().getCursor(false);
|
||||
for (l = i = ref = pos.line, ref1 = posend.line; ref <= ref1 ? i <= ref1 : i >= ref1; l = ref <= ref1 ? ++i : --i) {
|
||||
e.codemirror.replaceRange(text + e.codemirror.getLine(l), {
|
||||
line: l,
|
||||
ch: 0
|
||||
}, {
|
||||
line: l,
|
||||
ch: e.codemirror.getLine(l).length
|
||||
});
|
||||
}
|
||||
e.codemirror.setCursor({
|
||||
line: posend.line,
|
||||
ch: e.codemirror.getLine(posend.line).length
|
||||
});
|
||||
e.codemirror.focus();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
||||
@@ -0,0 +1,159 @@
|
||||
name: Vimeo
|
||||
version: 1.0.3
|
||||
description: "**Vimeo** is a plugin that converts markdown video links into the [Vimeo](https://vimeo.com) Universal Embed Code."
|
||||
icon: vimeo
|
||||
author:
|
||||
name: Christian Worreschk
|
||||
email: cw@marsec.de
|
||||
homepage: https://github.com/cworreschk/grav-plugin-vimeo
|
||||
keywords: vimeo, markdown, video, embed, iframe
|
||||
bugs: https://github.com/cworreschk/grav-plugin-vimeo/issues
|
||||
docs: https://github.com/cworreschk/grav-plugin-vimeo/blob/master/README.md
|
||||
license: MIT
|
||||
|
||||
form:
|
||||
validation: strict
|
||||
fields:
|
||||
|
||||
tabs:
|
||||
type: tabs
|
||||
active: 1
|
||||
class: subtle
|
||||
fields:
|
||||
|
||||
general:
|
||||
type: tab
|
||||
title: PLUGIN_VIMEO.GENERAL
|
||||
fields:
|
||||
|
||||
enabled:
|
||||
type: toggle
|
||||
label: PLUGIN_VIMEO.PLUGIN_STATUS
|
||||
highlight: 1
|
||||
default: 0
|
||||
options:
|
||||
1: PLUGIN_VIMEO.ENABLED
|
||||
0: PLUGIN_VIMEO.DISABLED
|
||||
validate:
|
||||
type: bool
|
||||
|
||||
plugin_css:
|
||||
type: toggle
|
||||
label: PLUGIN_VIMEO.PLUGIN_CSS
|
||||
help: PLUGIN_VIMEO.PLUGIN_CSS_HELP
|
||||
highlight: 1
|
||||
default: 1
|
||||
options:
|
||||
1: PLUGIN_VIMEO.ENABLED
|
||||
0: PLUGIN_VIMEO.DISABLED
|
||||
validate:
|
||||
type: bool
|
||||
|
||||
editor_button:
|
||||
type: toggle
|
||||
label: PLUGIN_VIMEO.EDITOR_BUTTON
|
||||
help: PLUGIN_VIMEO.EDITOR_BUTTON_HELP
|
||||
highlight: 1
|
||||
default: 1
|
||||
options:
|
||||
1: PLUGIN_VIMEO.ENABLED
|
||||
0: PLUGIN_VIMEO.DISABLED
|
||||
validate:
|
||||
type: bool
|
||||
|
||||
player_parameters:
|
||||
type: tab
|
||||
title: PLUGIN_VIMEO.PLAYER
|
||||
fields:
|
||||
|
||||
player_parameters.autoplay:
|
||||
type: toggle
|
||||
label: PLUGIN_VIMEO.AUTOPLAY
|
||||
help: PLUGIN_VIMEO.AUTOPLAY_HELP
|
||||
highlight: 1
|
||||
default: 0
|
||||
options:
|
||||
1: PLUGIN_VIMEO.ENABLED
|
||||
0: PLUGIN_VIMEO.DISABLED
|
||||
validate:
|
||||
type: bool
|
||||
|
||||
player_parameters.autopause:
|
||||
type: toggle
|
||||
label: PLUGIN_VIMEO.AUTOPAUSE
|
||||
help: PLUGIN_VIMEO.AUTOPAUSE_HELP
|
||||
highlight: 1
|
||||
default: 1
|
||||
options:
|
||||
1: PLUGIN_VIMEO.ENABLED
|
||||
0: PLUGIN_VIMEO.DISABLED
|
||||
validate:
|
||||
type: bool
|
||||
|
||||
player_parameters.loop:
|
||||
type: toggle
|
||||
label: PLUGIN_VIMEO.LOOP
|
||||
help: PLUGIN_VIMEO.LOOP_HELP
|
||||
highlight: 1
|
||||
default: 0
|
||||
options:
|
||||
1: PLUGIN_VIMEO.ENABLED
|
||||
0: PLUGIN_VIMEO.DISABLED
|
||||
validate:
|
||||
type: bool
|
||||
|
||||
player_parameters.player_id:
|
||||
type: text
|
||||
label: PLUGIN_VIMEO.PLAYER_ID
|
||||
size: medium
|
||||
help: PLUGIN_VIMEO.PLAYER_ID_HELP
|
||||
|
||||
player_parameters.view:
|
||||
type: section
|
||||
title: PLUGIN_VIMEO.PLAYER_VIEW
|
||||
text: PLUGIN_VIMEO.PLAYER_VIEW_TEXT
|
||||
underline: true
|
||||
fields:
|
||||
|
||||
player_parameters.title:
|
||||
type: toggle
|
||||
label: PLUGIN_VIMEO.TITLE
|
||||
help: PLUGIN_VIMEO.TITLE_HELP
|
||||
highlight: 1
|
||||
default: 1
|
||||
options:
|
||||
1: PLUGIN_VIMEO.ENABLED
|
||||
0: PLUGIN_VIMEO.DISABLED
|
||||
validate:
|
||||
type: bool
|
||||
|
||||
player_parameters.portrait:
|
||||
type: toggle
|
||||
label: PLUGIN_VIMEO.PORTRAIT
|
||||
help: PLUGIN_VIMEO.PORTRAIT_HELP
|
||||
highlight: 1
|
||||
default: 1
|
||||
options:
|
||||
1: PLUGIN_VIMEO.ENABLED
|
||||
0: PLUGIN_VIMEO.DISABLED
|
||||
validate:
|
||||
type: bool
|
||||
|
||||
player_parameters.byline:
|
||||
type: toggle
|
||||
label: PLUGIN_VIMEO.BYLINE
|
||||
help: PLUGIN_VIMEO.BYLINE_HELP
|
||||
highlight: 1
|
||||
default: 1
|
||||
options:
|
||||
1: PLUGIN_VIMEO.ENABLED
|
||||
0: PLUGIN_VIMEO.DISABLED
|
||||
validate:
|
||||
type: bool
|
||||
|
||||
player_parameters.color:
|
||||
type: colorpicker
|
||||
label: PLUGIN_VIMEO.COLOR
|
||||
help: PLUGIN_VIMEO.COLOR_HELP
|
||||
highlight: 1
|
||||
default: "#00adef"
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace Grav\Plugin\Vimeo\Twig;
|
||||
|
||||
use Grav\Common\GravTrait;
|
||||
|
||||
/**
|
||||
* Class VimeoTwigExtension
|
||||
* @package Grav\Plugin\Vimeo\Twig
|
||||
*/
|
||||
class VimeoTwigExtension extends \Twig_Extension
|
||||
{
|
||||
|
||||
use GravTrait;
|
||||
|
||||
const VIMEO_PLAYER_URL = '//player.vimeo.com/video/';
|
||||
|
||||
/**
|
||||
* Filters player parameters to only those not matching Vimeo defaults
|
||||
* @param array $params Player parameters
|
||||
* @return array
|
||||
*/
|
||||
private function filterParameters($params=[])
|
||||
{
|
||||
$filtered = [];
|
||||
$grav = static::getGrav();
|
||||
$blueprints = $grav['config']->blueprints();
|
||||
foreach ($params as $key => $value) {
|
||||
|
||||
// Skip if string value is empty
|
||||
if (is_string($value)){
|
||||
$value = trim($value);
|
||||
if (empty($value)) continue;
|
||||
}
|
||||
|
||||
// Skip if there is an default value and it's different to the looping parameter value
|
||||
$blueprint_param = $blueprints->get("plugins.vimeo.player_parameters.{$key}");
|
||||
if (isset($blueprint_param['default']) && ($blueprint_param['default'] == $value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($key == 'color') $value = str_replace('#', '', $value); // Remove # from hexadecimal color value
|
||||
|
||||
$filtered[$key] = $value;
|
||||
}
|
||||
|
||||
return $filtered;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of available twig functions
|
||||
* @return array
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
new \Twig_SimpleFunction('vimeo_embed_url', [$this, 'embedUrl']),
|
||||
new \Twig_SimpleFunction('vimeo_embed_video', [$this, 'embedVideo']),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the Vimeo embed url
|
||||
* @param string $video_id Vimeo Video ID
|
||||
* @param array $params Player parameters
|
||||
* @return string
|
||||
*/
|
||||
public function embedUrl($video_id, $params = [])
|
||||
{
|
||||
$url = static::VIMEO_PLAYER_URL.$video_id;
|
||||
$params = $this->filterParameters($params);
|
||||
if ((!empty($params)) && ($query = http_build_query($params))) $url.= "?{$query}";
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the Vimeo embed iframe
|
||||
* @param string $video_id Vimeo Video ID
|
||||
* @param array $params Player parameters
|
||||
* @param bool $div Surrounds the iframe code with a div element
|
||||
* @return string
|
||||
*/
|
||||
public function embedVideo($video_id, $params = [], $div=true)
|
||||
{
|
||||
$url = $this->embedUrl($video_id, $params);
|
||||
$code = "<iframe src=\"{$url}\" frameborder=\"0\" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>";
|
||||
if ($div) $code = "<div class=\"grav-vimeo\">{$code}</div>";
|
||||
|
||||
return $code;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
.grav-vimeo {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
height: 0;
|
||||
padding-top: 25px;
|
||||
padding-bottom: 50%;
|
||||
margin-bottom: 10px;
|
||||
max-width: 1920px;
|
||||
max-height: 1080px; }
|
||||
|
||||
.grav-vimeo iframe {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%; }
|
||||
@@ -0,0 +1,17 @@
|
||||
.grav-vimeo
|
||||
position: relative
|
||||
overflow: hidden
|
||||
height: 0
|
||||
padding-top: 25px
|
||||
padding-bottom: 50%
|
||||
margin-bottom: 10px
|
||||
max-width: 1920px
|
||||
max-height: 1080px
|
||||
|
||||
.grav-vimeo iframe
|
||||
position: absolute
|
||||
top: 0
|
||||
left: 0
|
||||
width: 100%
|
||||
height: 100%
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
PLUGIN_VIMEO:
|
||||
GENERAL: "Allgemein"
|
||||
ENABLED: "Aktiviert"
|
||||
DISABLED: "Deaktiviert"
|
||||
PLUGIN_STATUS: "Plugin Status"
|
||||
PLUGIN_CSS: "Plugin CSS"
|
||||
PLUGIN_CSS_HELP: "Das CSS des Plugins wird verwendet."
|
||||
EDITOR_BUTTON: "Bearbeitungsschaltfläche"
|
||||
EDITOR_BUTTON_HELP: "In der Seitenbearbeitung kann einfach ein Vimeo Video hinzugefügt werden."
|
||||
EDITOR_BUTTON_TOOLTIP: "Vimeo Video"
|
||||
EDITOR_BUTTON_PROMPT: "Gib bitte eine Vimeo Video ID ein. Die findest du in der Vimeo Video Url.\nZ.B. https://vimeo.com/[123456789] oder https://player.vimeo.com/video/[123456789]"
|
||||
PLAYER: "Player"
|
||||
PLAYER_VIEW: "Ansicht"
|
||||
PLAYER_VIEW_TEXT: "Falls der Video-Eigentümer Plus-Mitglied ist, könnten diese Einstellungen durch ihn überschrieben sein."
|
||||
AUTOPAUSE: "Automatisches Pausieren"
|
||||
AUTOPAUSE_HELP: "Wenn ein anderes Video abgespielt wird, wird das Video automatisch pausiert."
|
||||
AUTOPLAY: "Automatische Wiedergabe"
|
||||
AUTOPLAY_HELP: "Wenn der Player geladen wurde, wird das Video automatisch gestartet. Nicht von allen Geräte unterstützt."
|
||||
BYLINE: "Verfasserangabe"
|
||||
BYLINE_HELP: "Info über den Eigentümer wird angezeigt."
|
||||
COLOR: "Farbe"
|
||||
COLOR_HELP: "Farbe der Video-Bedienelemente."
|
||||
LOOP: "Schleifenwiedergabe"
|
||||
LOOP_HELP: "Das Video wird automatisch neugestartet, wenn es zu Ende ist."
|
||||
PLAYER_ID: "Player ID"
|
||||
PLAYER_ID_HELP: "Eine eindeutige ID für den Player, die mit der Vimeo Javascript API verwendet werden kann."
|
||||
PORTRAIT: "Benutzerbild"
|
||||
PORTRAIT_HELP: "Benutzerbild des Eigentümers wird angezeigt."
|
||||
TITLE: "Titel"
|
||||
TITLE_HELP: "Zeigt den Videotitel an."
|
||||
@@ -0,0 +1,30 @@
|
||||
PLUGIN_VIMEO:
|
||||
GENERAL: "General"
|
||||
ENABLED: "Enabled"
|
||||
DISABLED: "Disabled"
|
||||
PLUGIN_STATUS: "Plugin status"
|
||||
PLUGIN_CSS: "Plugin CSS"
|
||||
PLUGIN_CSS_HELP: "The built in CSS of the plugin will be used."
|
||||
EDITOR_BUTTON: "Editor button"
|
||||
EDITOR_BUTTON_HELP: "Allows you to easily add Vimeo videos in the page content."
|
||||
EDITOR_BUTTON_TOOLTIP: "Vimeo Video"
|
||||
EDITOR_BUTTON_PROMPT: "Please enter a Vimeo Video ID. You'll find it in the Vimeo Video URL.\nE.g. https://vimeo.com/[123456789] or https://player.vimeo.com/video/[123456789]"
|
||||
PLAYER: "Player"
|
||||
PLAYER_VIEW: "View"
|
||||
PLAYER_VIEW_TEXT: "If the owner of the video is a Plus member, some of these settings may be overridden by their preferences."
|
||||
AUTOPAUSE: "Autopause"
|
||||
AUTOPAUSE_HELP: "Enables or disables pausing this video when another video is played."
|
||||
AUTOPLAY: "Autoplay"
|
||||
AUTOPLAY_HELP: "Plays the video automatically on load. Note that this won’t work on some devices."
|
||||
BYLINE: "Byline"
|
||||
BYLINE_HELP: "Shows the user’s byline on the video."
|
||||
COLOR: "Color"
|
||||
COLOR_HELP: "Specifies the color of the video controls."
|
||||
LOOP: "Loop"
|
||||
LOOP_HELP: "Plays the video again when it reaches the end."
|
||||
PLAYER_ID: "Player ID"
|
||||
PLAYER_ID_HELP: "A unique id for the player that will be passed back with all Javascript Vimeo API responses."
|
||||
PORTRAIT: "Portrait"
|
||||
PORTRAIT_HELP: "Shows the user’s portrait on the video."
|
||||
TITLE: "Title"
|
||||
TITLE_HELP: "Shows the title on the video."
|
||||
@@ -0,0 +1,30 @@
|
||||
PLUGIN_VIMEO:
|
||||
GENERAL: "Général"
|
||||
ENABLED: "Activé"
|
||||
DISABLED: "Désactivé"
|
||||
PLUGIN_STATUS: "Statut du plugin"
|
||||
PLUGIN_CSS: "Plugin CSS"
|
||||
PLUGIN_CSS_HELP: "Les CSS internes du plugin seront utilisés."
|
||||
EDITOR_BUTTON: "Bouton éditeur"
|
||||
EDITOR_BUTTON_HELP: "Vous permet d’ajouter facilement des vidéos Vimeo dans le contenu de la page."
|
||||
EDITOR_BUTTON_TOOLTIP: "Vidéo Vimeo"
|
||||
EDITOR_BUTTON_PROMPT: "Veuillez indiquer l'ID d'une vidéo Vimeo. Vous la trouverez dans l’URL de la vidéo Vimeo.\nEx : https://vimeo.com/[123456789] ou https://player.vimeo.com/video/[123456789]"
|
||||
PLAYER: "Lecteur"
|
||||
PLAYER_VIEW: "Vue"
|
||||
PLAYER_VIEW_TEXT: "Si le propriétaire de la vidéo est un Membre Plus, certains de ces paramètres peuvent être remplacés par leurs préférences utilisateur."
|
||||
AUTOPAUSE: "Pause automatique"
|
||||
AUTOPAUSE_HELP: "Active ou désactive la pause de cette vidéo lorsque vous en visionnez une autre."
|
||||
AUTOPLAY: "Lecture automatique"
|
||||
AUTOPLAY_HELP: "Joue la vidéo automatiquement lors du chargement. Notez que cela ne fonctionnera pas sur certains appareils."
|
||||
BYLINE: "Signature"
|
||||
BYLINE_HELP: "Affiche la signature de l’utilisateur sur la vidéo."
|
||||
COLOR: "Couleur"
|
||||
COLOR_HELP: "Indique la couleur des contrôles vidéo."
|
||||
LOOP: "Boucle"
|
||||
LOOP_HELP: "Rejoue la vidéo lorsque la fin est atteinte."
|
||||
PLAYER_ID: "ID de lecteur"
|
||||
PLAYER_ID_HELP: "Une ID unique pour le lecteur qui sera réutilisée pour toutes les réponses de l'API Javascript Vimeo."
|
||||
PORTRAIT: "Portrait"
|
||||
PORTRAIT_HELP: "Affiche le portrait de l’utilisateur sur la vidéo."
|
||||
TITLE: "Titre"
|
||||
TITLE_HELP: "Affiche le titre sur la vidéo."
|
||||
@@ -0,0 +1 @@
|
||||
{{- vimeo_embed_video(video_id, player_parameters) -}}
|
||||
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
namespace Grav\Plugin;
|
||||
|
||||
use Grav\Common\Plugin;
|
||||
use Grav\Plugin\Vimeo\Twig\VimeoTwigExtension;
|
||||
use RocketTheme\Toolbox\Event\Event;
|
||||
|
||||
/**
|
||||
* Class VimeoPlugin
|
||||
* @package Grav\Plugin
|
||||
*/
|
||||
class VimeoPlugin extends Plugin
|
||||
{
|
||||
|
||||
protected $locale;
|
||||
|
||||
const VIMEO_REGEX = '(?:\S*)?:?\/{2}(?:\S*)vimeo.com(?:\/video)?\/(\d*)';
|
||||
|
||||
/**
|
||||
* Returns a list of events the plugins wants to listen to.
|
||||
* @return array
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return [
|
||||
'onPluginsInitialized' => ['onPluginsInitialized', 0],
|
||||
'onAssetsInitialized' => ['onAssetsInitialized', 0]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the plugin
|
||||
*/
|
||||
public function onPluginsInitialized()
|
||||
{
|
||||
$this->initializeLocale();
|
||||
|
||||
// Don't proceed if we are in the admin plugin
|
||||
if ($this->isAdmin()) return;
|
||||
|
||||
// Enable the events we are interested in
|
||||
$this->enable([
|
||||
'onPageContentRaw' => ['onPageContentRaw', 0],
|
||||
'onTwigExtensions' => ['onTwigExtensions', 0],
|
||||
'onTwigTemplatePaths' => ['onTwigTemplatePaths', 0],
|
||||
]);
|
||||
}
|
||||
|
||||
private function initializeLocale() {
|
||||
$locales = [];
|
||||
$language = $this->grav['language'];
|
||||
|
||||
// Available Languages
|
||||
if (isset($this->grav['user']) && $this->grav['user']->authenticated) $locales[] = $this->grav['user']->language;
|
||||
if ($language->enabled())$locales[] = $language->getLanguage();
|
||||
$locales[] = 'en';
|
||||
|
||||
$locales = array_unique(array_filter($locales));
|
||||
foreach ($locales as $locale) {
|
||||
if (isset($this->grav['languages'][$locale]['PLUGIN_VIMEO'])) {
|
||||
$this->locale = $locale;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Built-in CSS and Editor Button JS if wanted
|
||||
*/
|
||||
public function onAssetsInitialized()
|
||||
{
|
||||
if (!$this->isAdmin() && $this->config->get('plugins.vimeo.plugin_css')) {
|
||||
$this->grav['assets']->add('plugin://vimeo/css/vimeo.css');
|
||||
}
|
||||
|
||||
if ($this->isAdmin() && $this->config->get('plugins.vimeo.editor_button')) {
|
||||
$plugin_translations = $this->grav['languages'][$this->locale]['PLUGIN_VIMEO'];
|
||||
$translations = [
|
||||
'EDITOR_BUTTON_TOOLTIP' => $plugin_translations['EDITOR_BUTTON_TOOLTIP'],
|
||||
'EDITOR_BUTTON_PROMPT' => $plugin_translations['EDITOR_BUTTON_PROMPT']
|
||||
];
|
||||
$code = 'this.GravVimeoPlugin = this.GravVimeoPlugin || {};';
|
||||
$code.= 'if (!this.GravVimeoPlugin.translations) this.GravVimeoPlugin.translations = '.json_encode($translations, JSON_UNESCAPED_SLASHES) .';';
|
||||
$this->grav['assets']->addInlineJs($code);
|
||||
$this->grav['assets']->add('plugin://vimeo/admin/editor-button/js/button.js');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* After a page has been found, header processed, but content not processed.
|
||||
* @param Event $e Event
|
||||
*/
|
||||
public function onPageContentRaw(Event $e)
|
||||
{
|
||||
$page = $e['page'];
|
||||
$config = $this->mergeConfig($page, true);
|
||||
if (!$config->get('enabled')) return;
|
||||
|
||||
// Function
|
||||
$twig = $this->grav['twig'];
|
||||
$function = function ($matches) use ($twig, $config) {
|
||||
$search = $matches[0];
|
||||
|
||||
// double check to make sure we found a valid Vimeo video ID
|
||||
if (!isset($matches[1])) return $search;
|
||||
|
||||
// build the replacement embed HTML string
|
||||
$replace = $twig->processTemplate('partials/vimeo.html.twig', [
|
||||
'video_id' => $matches[1],
|
||||
'player_parameters' => $config->get('player_parameters', [])
|
||||
]);
|
||||
|
||||
// do the replacement
|
||||
return str_replace($search, $replace, $search);
|
||||
};
|
||||
|
||||
$raw_content = $page->getRawContent();
|
||||
$page->setRawContent($this->parseLinks($raw_content, $function, static::VIMEO_REGEX));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Vimeo twig extension
|
||||
*/
|
||||
public function onTwigExtensions()
|
||||
{
|
||||
require_once __DIR__ . '/classes/Twig/VimeoTwigExtension.php';
|
||||
$this->grav['twig']->twig->addExtension(new VimeoTwigExtension());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add plugin templates to twig path
|
||||
*/
|
||||
public function onTwigTemplatePaths()
|
||||
{
|
||||
$this->grav['twig']->twig_paths[] = __DIR__ . '/templates';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
enabled: true
|
||||
plugin_css: true
|
||||
editor_button: true
|
||||
|
||||
player_parameters:
|
||||
autopause: true
|
||||
autoplay: false
|
||||
byline: true
|
||||
color: "#00adef"
|
||||
loop: false
|
||||
player_id: ""
|
||||
portrait: true
|
||||
title: true
|
||||
Reference in New Issue
Block a user