Skip to content

Commit

Permalink
install youtube plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
fannymugnier committed Mar 7, 2021
1 parent 7ea533f commit aa14bca
Show file tree
Hide file tree
Showing 15 changed files with 1,173 additions and 0 deletions.
1 change: 1 addition & 0 deletions user/plugins/youtube/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
66 changes: 66 additions & 0 deletions user/plugins/youtube/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# v3.1.0
## 05/20/2020

1. [](#new)
* Added "Lazy Load" Option [#30](https://github.com/getgrav/grav-plugin-youtube/pull/30)
* Added option for video size [#29](https://github.com/getgrav/grav-plugin-youtube/pull/29)

# v3.0.1
## 08/20/2018

1. [](#improved)
* Refactor to remove GravTrait

# v3.0.0
## 08/02/2018

1. [](#new)
* Added shortcode support

# v2.0.4
## 09/28/2017

1. [](#improved)
* Always use HTTPS for YouTube [#21](https://github.com/getgrav/grav-plugin-youtube/pull/21)

# v2.0.3
## 12/23/2016

1. [](#bugfix)
* Fixed a JavaScript issue [#16](https://github.com/getgrav/grav-plugin-youtube/pull/16)

# v2.0.2
## 05/23/2016

1. [](#improved)
* Supports `youtu.be` based short links
1. [](#bugfix)
* Fixed for invalid URL with YouTube editor buttons
* Fixed editor button to work with Admin v1.1

# v2.0.1
## 11/24/2015

1. [](#bugfix)
* Fixed issue with case sensitivity when including new `YoutubeTwigExtension`

# v2.0.0
## 11/23/2015

1. [](#new)
* Added player parameters configuration values (@hctom)
* Added various YouTube options (@hctom)
* Reworked output to use overridable Twig template (@hctom)
* Added hebe.json (@hctom)

# v1.1.0
## 10/07/2015

1. [](#new)
* Added admin editor button

# v1.0.0
## 05/09/2015

1. [](#new)
* ChangeLog started...
21 changes: 21 additions & 0 deletions user/plugins/youtube/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015 Grav

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.
91 changes: 91 additions & 0 deletions user/plugins/youtube/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Grav YouTube Plugin

`YouTube` is a simple [Grav][grav] Plugin that converts markdown links into responsive embeds.

# Installation

Installing the YouTube plugin can be done in one of two ways. Our 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 youtube

This will install the YouTube plugin into your `/user/plugins` directory within Grav. Its files can be found under `/your/site/grav/user/plugins/youtube`.

## 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 `youtube`. You can find these files either on [GitHub](https://github.com/getgrav/grav-plugin-youtube) or via [GetGrav.org](http://getgrav.org/downloads/plugins#extras).

You should now have all the plugin files under

/your/site/grav/user/plugins/youtube

# Config Defaults

```
enabled: true
built_in_css: true
player_parameters:
autoplay: 0
cc_load_policy: 0
color: red
controls: 1
disablekb: 0
enablejsapi: 0
fs: 1
hl: ''
iv_load_policy: 1
loop: 0
modestbranding: 0
origin: ''
playsinline: 0
rel: 1
showinfo: 1
vq: default
privacy_enhanced_mode: false
```

If you need to change any value, then the best process is to copy the [youtube.yaml](youtube.yaml) file into your `users/config/plugins/` folder (create it if it doesn't exist), and then modify there. This will override the default settings.

You can also set any of these settings on a per-page basis by adding them under a `youtube:` setting in your page header. For example:

---
title: YouTube Video
youtube:
player_parameters:
autoplay: 1
---

[plugin:youtube](https://www.youtube.com/watch?v=BK8guP9ov2U)

This will display a video and auto-play it.

For more details on the `player_parameters`, please check out the [YouTube official documentation](https://developers.google.com/youtube/player_parameters)

# Usage

To use this plugin you simply need to include a youtube URL in markdown link such as:

```
[plugin:youtube](https://www.youtube.com/watch?v=BK8guP9ov2U)
```

Will be converted into the following embeded HTML:

```
<div class="grav-youtube"><iframe src="https://www.youtube.com/embed/BK8guP9ov2U" frameborder="0" allowfullscreen=""></iframe></div>
```

CSS is also loaded to provide the appropriate responsive layout.

# Shortcode Syntax

As of version `3.0` you can now use an alternative _shortcode_ syntax that supports passing in the player parameter values inline

```
[youtube color=white autoplay=1]https://www.youtube.com/watch?v=BK8guP9ov2U[/youtube]
```

[grav]: http://github.com/getgrav/grav
36 changes: 36 additions & 0 deletions user/plugins/youtube/admin/editor-button/js/button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
(function($){
$(function(){
$('body').on('grav-editor-ready', function() {
var Instance = Grav.default.Forms.Fields.EditorField.Instance;
Instance.addButton({
youtube: {
identifier: 'youtube-video',
title: 'YouTube Video',
label: '<i class="fa fa-fw fa-youtube"></i>',
modes: ['gfm', 'markdown'],
action: function(_ref) {
var codemirror = _ref.codemirror, button = _ref.button, textarea = _ref.textarea;
button.on('click.editor.youtube',function() {
var videoURL = prompt("Enter the YouTube Video URL. E.g. https://www.youtube.com/watch?v=vQ4qK36UenI");

if (videoURL) {
var text = '[plugin:youtube](' + videoURL + ')';

//Add text to the editor
var pos = codemirror.getDoc().getCursor(true);
var posend = codemirror.getDoc().getCursor(false);

for (var i=pos.line; i<(posend.line+1);i++) {
codemirror.replaceRange(text+codemirror.getLine(i), { line: i, ch: 0 }, { line: i, ch: codemirror.getLine(i).length });
}

codemirror.setCursor({ line: posend.line, ch: codemirror.getLine(posend.line).length });
codemirror.focus();
}
});
}
}
});
});
});
})(jQuery);
Loading

0 comments on commit aa14bca

Please sign in to comment.