mirror of
https://github.com/YunoHost-Apps/dokuwiki_ynh.git
synced 2024-09-03 18:26:20 +02:00
[enh] Add vshare plugin.
This commit is contained in:
parent
16d59707cb
commit
0220a4c5ce
14 changed files with 366 additions and 0 deletions
25
sources/lib/plugins/vshare/README
Normal file
25
sources/lib/plugins/vshare/README
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
vshare Plugin for DokuWiki
|
||||||
|
|
||||||
|
All documentation for this plugin can be found at
|
||||||
|
http://www.dokuwiki.org/plugin:vshare
|
||||||
|
|
||||||
|
If you install this plugin manually, make sure it is installed in
|
||||||
|
lib/plugins/vshare/ - if the folder is called different it
|
||||||
|
will not work!
|
||||||
|
|
||||||
|
Please refer to http://www.dokuwiki.org/plugins for additional info
|
||||||
|
on how to install plugins in DokuWiki.
|
||||||
|
|
||||||
|
----
|
||||||
|
Copyright (C) Andreas Gohr <andi@splitbrain.org>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; version 2 of the License
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
See the COPYING file in your DokuWiki folder for details
|
20
sources/lib/plugins/vshare/all.css
Normal file
20
sources/lib/plugins/vshare/all.css
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
iframe.vshare__left,
|
||||||
|
div.vshare__left {
|
||||||
|
float: left;
|
||||||
|
margin-right: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
iframe.vshare__right,
|
||||||
|
div.vshare__right {
|
||||||
|
float: right;
|
||||||
|
margin-left: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
iframe.vshare__center,
|
||||||
|
div.vshare__center {
|
||||||
|
text-align: center;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
BIN
sources/lib/plugins/vshare/button.png
Normal file
BIN
sources/lib/plugins/vshare/button.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 710 B |
6
sources/lib/plugins/vshare/lang/en/lang.php
Normal file
6
sources/lib/plugins/vshare/lang/en/lang.php
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$lang['js']['button'] = 'Insert video from video sharing sites';
|
||||||
|
$lang['js']['prompt'] = 'Please paste the full URL to the video page here:';
|
||||||
|
$lang['js']['notfound'] = "Sorry, this URL wasn't recognized.\nPlease refer to the documentation on how to insert the correct syntax manually.";
|
||||||
|
|
10
sources/lib/plugins/vshare/lang/fr/lang.php
Normal file
10
sources/lib/plugins/vshare/lang/fr/lang.php
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* French language file for vshare plugin
|
||||||
|
*
|
||||||
|
* @author Fabrice DEJAIGHER <fabrice@chtiland.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
$lang['js']['button'] = 'Insère une vidéo depuis des sites de partage vidéo';
|
||||||
|
$lang['js']['prompt'] = 'Copiez/collez le lien complet de la page contenant la vidéo ici :';
|
||||||
|
$lang['js']['notfound'] = "Désolé, cette URL n'a pas été reconnue. Consultez la documentation sur la syntaxe pour insérer une vidéo manuellement.";
|
10
sources/lib/plugins/vshare/lang/ko/lang.php
Normal file
10
sources/lib/plugins/vshare/lang/ko/lang.php
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Korean language file for vshare plugin
|
||||||
|
*
|
||||||
|
* @author Myeongjin <aranet100@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
$lang['js']['button'] = '동영상 공유 사이트에서 동영상 넣기';
|
||||||
|
$lang['js']['prompt'] = '여기에 동영상 페이지의 전체 URL을 붙여넣으세요:';
|
||||||
|
$lang['js']['notfound'] = "죄송하지만 이 URL을 인식할 수 없습니다.\n수동으로 올바른 문법을 넣는 방법에 대해서는 설명서를 참고하세요.";
|
10
sources/lib/plugins/vshare/lang/nl/lang.php
Normal file
10
sources/lib/plugins/vshare/lang/nl/lang.php
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dutch language file for vshare plugin.
|
||||||
|
*
|
||||||
|
* @author Mark C. Prins <mprins@users.sf.net>
|
||||||
|
*/
|
||||||
|
$lang['js']['button'] = 'Voeg een video van een video-delen website in';
|
||||||
|
$lang['js']['prompt'] = 'Plak hier de volledige URL voor de video pagina:';
|
||||||
|
$lang['js']['notfound'] = "Sorry, deze URL werd niet herkend.\nRaadpleeg de documentatie over de juiste syntax om een URL handmatig in te voegen.";
|
16
sources/lib/plugins/vshare/pdf.css
Normal file
16
sources/lib/plugins/vshare/pdf.css
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
|
||||||
|
div.vshare__left,
|
||||||
|
div.vshare__right,
|
||||||
|
div.vshare__center {
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
text-align: center;
|
||||||
|
padding: 2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.vshare {
|
||||||
|
color: #aaa;
|
||||||
|
font-size: 2em;
|
||||||
|
font-weight: bold;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
8
sources/lib/plugins/vshare/plugin.info.txt
Normal file
8
sources/lib/plugins/vshare/plugin.info.txt
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
base vshare
|
||||||
|
author Andreas Gohr
|
||||||
|
email andi@splitbrain.org
|
||||||
|
date 2013-10-22
|
||||||
|
name Video Sharing Site Plugin
|
||||||
|
desc Easily embed videos from various Video Sharing sites. Example: {{youtube>XXXXXX}}
|
||||||
|
url http://www.dokuwiki.org/plugin:vshare
|
||||||
|
|
35
sources/lib/plugins/vshare/script.js
Normal file
35
sources/lib/plugins/vshare/script.js
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Append a toolbar button
|
||||||
|
*/
|
||||||
|
if(window.toolbar != undefined){
|
||||||
|
toolbar[toolbar.length] = {"type": "pluginvshare",
|
||||||
|
"title": LANG['plugins']['vshare']['button'],
|
||||||
|
"icon": DOKU_BASE+"lib/plugins/vshare/button.png",
|
||||||
|
"key": ""};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Try to determine the video service, extract the ID and insert
|
||||||
|
* the correct syntax
|
||||||
|
*/
|
||||||
|
function tb_pluginvshare(btn, props, edid) {
|
||||||
|
var text = prompt(LANG['plugins']['vshare']['prompt']);
|
||||||
|
if(!text) return;
|
||||||
|
|
||||||
|
// This includes the site patterns:
|
||||||
|
/* DOKUWIKI:include sites.js */
|
||||||
|
|
||||||
|
for (var key in sites){
|
||||||
|
var RE = new RegExp(sites[key],'i');
|
||||||
|
var match = text.match(RE);
|
||||||
|
if(match){
|
||||||
|
var code = '{{'+key+'>'+match[1]+'?medium}}';
|
||||||
|
insertAtCarret(edid, code);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
alert(LANG['plugins']['vshare']['notfound']);
|
||||||
|
}
|
||||||
|
|
32
sources/lib/plugins/vshare/sites.conf
Normal file
32
sources/lib/plugins/vshare/sites.conf
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
# configure video site flash or iframe URLs here, @VIDEO@ is the ID placeholder
|
||||||
|
|
||||||
|
vimeo iframe http://player.vimeo.com/video/@VIDEO@
|
||||||
|
ustream iframe http://www.ustream.tv/embed/recorded/@VIDEO@
|
||||||
|
youtube iframe http://www.youtube.com/embed/@VIDEO@
|
||||||
|
|
||||||
|
12seconds flash http://embed.12seconds.tv/players/remotePlayer.swf?vid=@VIDEO@
|
||||||
|
5min flash http://www.5min.com/Embeded/@VIDEO@/
|
||||||
|
bambuser flash http://bambuser.com/r/player.swf?vid=@VIDEO@&context=external
|
||||||
|
bliptv flash http://blip.tv/scripts/flash/showplayer.swf?file=http%3A%2F%2Fblip.tv/rss/flash/@VIDEO@
|
||||||
|
blogtv flash http://www.blogtv.com/vb/@VIDEO@
|
||||||
|
break flash http://embed.break.com/@VIDEO@
|
||||||
|
clipfish flash http://www.clipfish.de/cfng/flash/clipfish_player_3.swf?as=0&vid=@VIDEO@&r=1&angebot=extern&
|
||||||
|
current flash http://current.com/e/@VIDEO@
|
||||||
|
dailymotion flash http://www.dailymotion.com/swf/@VIDEO@
|
||||||
|
googlevideo flash http://video.google.com/googleplayer.swf?docid=@VIDEO@
|
||||||
|
gtrailers flash http://www.gametrailers.com/remote_wrap.php?mid=@VIDEO@
|
||||||
|
justintv flash http://www.justin.tv/widgets/jtv_tip_embed.swf?tip_id=@VIDEO@&channel=justin.tv
|
||||||
|
metacafe flash http://www.metacafe.com/fplayer/@VIDEO@/foo.swf
|
||||||
|
myspacetv flash http://lads.myspace.com/videos/vplayer.swf?m=@VIDEO@&v=2&type=video
|
||||||
|
rcmovie flash http://www.rcmovie.de/embed/@VIDEO@
|
||||||
|
revver flash http://flash.revver.com/player/1.0/player.swf?mediaId=@VIDEO@
|
||||||
|
scivee flash http://www.scivee.tv/flash/embedPlayer.swf?id=@VIDEO@&type=3
|
||||||
|
sevenload flash http://en.sevenload.com/pl/@VIDEO@/500x408/swf
|
||||||
|
slideshare flash http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=@VIDEO@&allowFullScreen=true&allowScriptAccess=always
|
||||||
|
stickam flash http://player.stickam.com/flashVarMediaPlayer/@VIDEO@
|
||||||
|
veoh flash http://www.veoh.com/videodetails2.swf?player=videodetailsembedded&type=v&permalinkId=@VIDEO@&id=anonymous
|
||||||
|
viddler flash http://www.viddler.com/player/@VIDEO@/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
32
sources/lib/plugins/vshare/sites.js
Normal file
32
sources/lib/plugins/vshare/sites.js
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
/**
|
||||||
|
* video URL recognition patterns
|
||||||
|
*
|
||||||
|
* The first match group is used as video ID
|
||||||
|
*
|
||||||
|
* You need to touch conf/local.php to refresh the cache after changing
|
||||||
|
* this file
|
||||||
|
*/
|
||||||
|
|
||||||
|
var sites = {
|
||||||
|
'youtube': 'youtube\\.com/.*[&?]v=([a-z0-9_\\-]+)',
|
||||||
|
'vimeo': 'vimeo\\.com\\/(\\d+)',
|
||||||
|
'ustream': 'ustream\\.tv\\/recorded\\/(\\d+)\\/',
|
||||||
|
'12seconds': '12seconds\\.com\\/v\\/([a-z0-9_]+)',
|
||||||
|
'5min': '5min\\.com\\/Video/.*-([0-9]+)([&?]|$)',
|
||||||
|
'clipfish': 'clipfishi\\.de\\/.*\\/video\\/([0-9])+\\/',
|
||||||
|
'blogtv': 'blogtv\.com\\/Shows\\/\\d+\\/([a-z0-9]+_[a-z0-9]+)([&?]|$)',
|
||||||
|
'current': 'current\\.com\\/items\\/(\\d+)',
|
||||||
|
'dailymotion': 'dailymotion\\.com\\/video\\/([a-z0-9]+)_',
|
||||||
|
'googlevideo': 'video\\.google\\.com\\/videoplay\\?docid=([\\-\\d]+)',
|
||||||
|
'gtrailers': 'gametrailers\\.com\\/.*\\/(\\d+)',
|
||||||
|
'justintv': 'justin\\.tv\\/clip\\/([a-f0-9]+)',
|
||||||
|
'metacafe': 'metacafe\\.com\\/watch\\/(\\d+)\\/',
|
||||||
|
'myspacetv': 'vids\\.myspace\\.com\\/.*videoid=(\\d+)',
|
||||||
|
'rcmovie': 'rcmovie\\.de\\/video\\/([a-f0-9]+)\\/',
|
||||||
|
'revver': 'revver\\.com\\/video\\/(\\d+)\\/',
|
||||||
|
'scivee': 'scivee\\.tv\\/node\\/(\\d+)',
|
||||||
|
'sevenload': 'sevenload\\.com\\/.*\\/([a-z0-9]+)-[^\\/]*$',
|
||||||
|
'stickam': 'stickam\\.com\\/viewMedia.do\\?mId=(\\d+)',
|
||||||
|
'veoh': 'veoh\\.com\\/.*watch[^v]*(v[a-z0-9]+)'
|
||||||
|
};
|
||||||
|
|
162
sources/lib/plugins/vshare/syntax.php
Normal file
162
sources/lib/plugins/vshare/syntax.php
Normal file
|
@ -0,0 +1,162 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Easily embed videos from various Video Sharing sites
|
||||||
|
*
|
||||||
|
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||||
|
* @author Andreas Gohr <andi@splitbrain.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
if(!defined('DOKU_INC')) die();
|
||||||
|
require_once(DOKU_PLUGIN.'syntax.php');
|
||||||
|
|
||||||
|
class syntax_plugin_vshare extends DokuWiki_Syntax_Plugin {
|
||||||
|
var $sites;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
* Intitalizes the supported video sites
|
||||||
|
*/
|
||||||
|
function syntax_plugin_vshare(){
|
||||||
|
$this->sites = confToHash(dirname(__FILE__).'/sites.conf');
|
||||||
|
}
|
||||||
|
|
||||||
|
function getType(){
|
||||||
|
return 'substition';
|
||||||
|
}
|
||||||
|
|
||||||
|
function getPType(){
|
||||||
|
return 'block';
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSort(){
|
||||||
|
return 159;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connect to the parser
|
||||||
|
*/
|
||||||
|
function connectTo($mode) {
|
||||||
|
$pattern = join('|',array_keys($this->sites));
|
||||||
|
$this->Lexer->addSpecialPattern('\{\{\s?(?:'.$pattern.')>[^}]*\}\}',$mode,'plugin_vshare');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse the parameters
|
||||||
|
*/
|
||||||
|
function handle($match, $state, $pos, &$handler){
|
||||||
|
$command = substr($match,2,-2);
|
||||||
|
|
||||||
|
// title
|
||||||
|
list($command,$title) = explode('|',$command);
|
||||||
|
$title = trim($title);
|
||||||
|
|
||||||
|
// alignment
|
||||||
|
$align = 0;
|
||||||
|
if(substr($command,0,1) == ' ') $align += 1;
|
||||||
|
if(substr($command,-1) == ' ') $align += 2;
|
||||||
|
$command = trim($command);
|
||||||
|
|
||||||
|
// get site and video
|
||||||
|
list($site,$vid) = explode('>',$command);
|
||||||
|
if(!$this->sites[$site]) return null; // unknown site
|
||||||
|
if(!$vid) return null; // no video!?
|
||||||
|
|
||||||
|
// what size?
|
||||||
|
list($vid,$param) = explode('?',$vid,2);
|
||||||
|
if(preg_match('/(\d+)x(\d+)/i',$param,$m)){ // custom
|
||||||
|
$width = $m[1];
|
||||||
|
$height = $m[2];
|
||||||
|
}elseif(strpos($param,'small') !== false){ // small
|
||||||
|
$width = 255;
|
||||||
|
$height = 210;
|
||||||
|
}elseif(strpos($param,'large') !== false){ // large
|
||||||
|
$width = 520;
|
||||||
|
$height = 406;
|
||||||
|
}else{ // medium
|
||||||
|
$width = 425;
|
||||||
|
$height = 350;
|
||||||
|
}
|
||||||
|
|
||||||
|
list($type, $url) = explode(' ', $this->sites[$site], 2);
|
||||||
|
$url = trim($url);
|
||||||
|
$type = trim($type);
|
||||||
|
$url = str_replace('@VIDEO@',rawurlencode($vid),$url);
|
||||||
|
$url = str_replace('@WIDTH@',$width,$url);
|
||||||
|
$url = str_replace('@HEIGHT@',$height,$url);
|
||||||
|
list(,$vars) = explode('?',$url,2);
|
||||||
|
$varr = array();
|
||||||
|
parse_str($vars,$varr);
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'site' => $site,
|
||||||
|
'video' => $vid,
|
||||||
|
'url' => $url,
|
||||||
|
'vars' => $varr,
|
||||||
|
'align' => $align,
|
||||||
|
'width' => $width,
|
||||||
|
'height' => $height,
|
||||||
|
'title' => $title,
|
||||||
|
'type' => $type
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render the flash player
|
||||||
|
*/
|
||||||
|
function render($mode, &$R, $data){
|
||||||
|
if($mode != 'xhtml') return false;
|
||||||
|
if(is_null($data)) return false;
|
||||||
|
|
||||||
|
if($data['align'] == 0) $align = 'none';
|
||||||
|
if($data['align'] == 1) $align = 'right';
|
||||||
|
if($data['align'] == 2) $align = 'left';
|
||||||
|
if($data['align'] == 3) $align = 'center';
|
||||||
|
if($data['title']) $title = ' title="'.hsc($data['title']).'"';
|
||||||
|
|
||||||
|
if(is_a($R,'renderer_plugin_dw2pdf')){
|
||||||
|
// Output for PDF renderer
|
||||||
|
$R->doc .= '<div class="vshare__'.$align.'"
|
||||||
|
width="'.$data['width'].'"
|
||||||
|
height="'.$data['height'].'">';
|
||||||
|
|
||||||
|
$R->doc .= '<a href="'.$data['url'].'" class="vshare">';
|
||||||
|
$R->doc .= '<img src="'.DOKU_BASE.'lib/plugins/vshare/video.png" />';
|
||||||
|
$R->doc .= '</a>';
|
||||||
|
|
||||||
|
$R->doc .= '<br />';
|
||||||
|
|
||||||
|
$R->doc .= '<a href="'.$data['url'].'" class="vshare">';
|
||||||
|
$R->doc .= ($data['title'] ? hsc($data['title']) : 'Video');
|
||||||
|
$R->doc .= '</a>';
|
||||||
|
|
||||||
|
$R->doc .= '</div>';
|
||||||
|
}else{
|
||||||
|
// Normal output
|
||||||
|
if($data['type'] == 'flash') {
|
||||||
|
// embed flash
|
||||||
|
$R->doc .= '<div class="vshare__'.$align.'"'.$title.'>';
|
||||||
|
$R->doc .= html_flashobject(
|
||||||
|
$data['url'],
|
||||||
|
$data['width'],
|
||||||
|
$data['height'],
|
||||||
|
$data['vars'],
|
||||||
|
$data['vars']);
|
||||||
|
$R->doc .= '</div>';
|
||||||
|
}else{
|
||||||
|
// embed iframe
|
||||||
|
$R->doc .= '<iframe ';
|
||||||
|
$R->doc .= buildAttributes(array(
|
||||||
|
'src' => $data['url'],
|
||||||
|
'height' => $data['height'],
|
||||||
|
'width' => $data['width'],
|
||||||
|
'class' => 'vshare__'.$align,
|
||||||
|
'allowfullscreen' => '',
|
||||||
|
'frameborder' => 0,
|
||||||
|
'scrolling' => 'no'
|
||||||
|
));
|
||||||
|
$R->doc .= '>'.hsc($data['title']).'</iframe>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
BIN
sources/lib/plugins/vshare/video.png
Normal file
BIN
sources/lib/plugins/vshare/video.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.5 KiB |
Loading…
Add table
Reference in a new issue