raster pushed a commit to branch master. http://git.enlightenment.org/website/www.git/commit/?id=72e8602ad6589a990ce114130481c496ba4f644c
commit 72e8602ad6589a990ce114130481c496ba4f644c Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com> Date: Mon Jul 13 12:06:19 2015 +0900 www - add 2 plugins - youtube and html5video --- public_html/.htaccess | 7 + public_html/conf/mime.local.conf | 3 + public_html/lib/plugins/html5video/README | 27 ++++ public_html/lib/plugins/html5video/TODO | 3 + public_html/lib/plugins/html5video/plugin.info.txt | 7 + .../lib/plugins/html5video/syntax/video.php | 145 +++++++++++++++++++++ public_html/lib/plugins/youtube/img/youtube.png | Bin 0 -> 1443 bytes public_html/lib/plugins/youtube/object.htm | 4 + public_html/lib/plugins/youtube/style.css | 7 + public_html/lib/plugins/youtube/syntax.php | 83 ++++++++++++ 10 files changed, 286 insertions(+) diff --git a/public_html/.htaccess b/public_html/.htaccess index 4233b3d..b0956f5 100644 --- a/public_html/.htaccess +++ b/public_html/.htaccess @@ -13,3 +13,10 @@ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule (.*) doku.php?id=$1 [QSA,L] RewriteRule ^index.php$ doku.php + +AddType application/webm webm +AddType video/webm webm +AddType application/ogg ogv +AddType video/ogg ogv +AddType application/mp4 mp4 +AddType video/mp4 mp4 diff --git a/public_html/conf/mime.local.conf b/public_html/conf/mime.local.conf index febd3f1..2a2f6e1 100644 --- a/public_html/conf/mime.local.conf +++ b/public_html/conf/mime.local.conf @@ -1 +1,4 @@ svg image/svg+xml +webm video/webm +ogv video/ogg +mp4 video/mp4 diff --git a/public_html/lib/plugins/html5video/README b/public_html/lib/plugins/html5video/README new file mode 100644 index 0000000..fb34421 --- /dev/null +++ b/public_html/lib/plugins/html5video/README @@ -0,0 +1,27 @@ +html5video Plugin for DokuWiki + +Embeds video using HTML5 syntax + +All documentation for this plugin can be found at +http://www.dokuwiki.org/plugin:html5video + +If you install this plugin manually, make sure it is installed in +lib/plugins/html5video/ - 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) Jason van Gumster (Fweeb) <ja...@monsterjavaguns.com> + +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 diff --git a/public_html/lib/plugins/html5video/TODO b/public_html/lib/plugins/html5video/TODO new file mode 100644 index 0000000..a19b17b --- /dev/null +++ b/public_html/lib/plugins/html5video/TODO @@ -0,0 +1,3 @@ +* Allow for graceful fallback to other web video formats for different browsers + +* Might be a good idea to use a stylesheet instead of inline styles for alignment diff --git a/public_html/lib/plugins/html5video/plugin.info.txt b/public_html/lib/plugins/html5video/plugin.info.txt new file mode 100644 index 0000000..985eb4d --- /dev/null +++ b/public_html/lib/plugins/html5video/plugin.info.txt @@ -0,0 +1,7 @@ +base html5video +author Jason van Gumster (Fweeb) +email ja...@monsterjavaguns.com +date 2013-03-07 +name html5video plugin +desc Embeds video using HTML5 syntax +url http://www.dokuwiki.org/plugin:html5video diff --git a/public_html/lib/plugins/html5video/syntax/video.php b/public_html/lib/plugins/html5video/syntax/video.php new file mode 100644 index 0000000..ff78300 --- /dev/null +++ b/public_html/lib/plugins/html5video/syntax/video.php @@ -0,0 +1,145 @@ +<?php +/** + * DokuWiki Plugin html5video (Syntax Component) + * + * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html + * @author Jason van Gumster (Fweeb) <ja...@monsterjavaguns.com> + * + * Parts borrowed from the videogg plugin written by Ludovic Kiefer, + * which is based on Christophe Benz' Dailymotion plugin, which, in turn, + * is based on Ikuo Obataya's Youtube plugin. Whew... + * + * Currently only supports webm videos + */ + +// must be run within Dokuwiki +if (!defined('DOKU_INC')) die(); + +if (!defined('DOKU_LF')) define('DOKU_LF', "\n"); +if (!defined('DOKU_TAB')) define('DOKU_TAB', "\t"); +if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); + +require_once DOKU_PLUGIN.'syntax.php'; + +class syntax_plugin_html5video_video extends DokuWiki_Syntax_Plugin { + + public function getType() { + return 'substition'; + } + + public function getPType() { + return 'block'; + } + + public function getSort() { + return 159; + } + + public function connectTo($mode) { + // Kind of a nasty regex, but it allows us to avoid using a + // plugin-specific prefix. We can use syntax directly from Media + // Manager. + // http://gskinner.com/RegExr is a big help + $this->Lexer->addSpecialPattern('\{\{[^}]*(?:(?:webm)|(?:ogv)|(?:mp4))(?:\|(?:\d{2,4}x\d{2,4})?(?:\|(?:loop)?,?(?:autoplay)?(?:,loop)?)?)? ?\}\}',$mode,'plugin_html5video_video'); + } + + public function handle($match, $state, $pos, &$handler){ + $params = substr($match, strlen('{{'), - strlen('}}')); //Strip markup + if(strpos($params, ' ') === 0) { // Space as first character + if(substr_compare($params, ' ', -1, 1) === 0) { // Space a front and back = centered + $params = trim($params); + $params = 'center|' . $params; + } + else { // Only space at front = right-aligned + $params = trim($params); + $params = 'right|' . $params; + } + } + elseif(substr_compare($params, ' ', -1, 1) === 0) { // Space only as last character = left-aligned + $params = trim($params); + $params = 'left|' . $params; + } + else { // No space padding = inline + $params = 'inline|' . $params; + } + return array(state, explode('|', $params)); + } + + public function render($mode, &$renderer, $data) { + if($mode != 'xhtml') return false; + + list($state, $params) = $data; + list($video_align, $video_url, $video_size, $video_attr) = $params; + + if($video_align == "center") { + $align = "margin: 0 auto;"; + } + elseif($video_align == "left") { + $align = "float: left;"; + } + elseif($video_align == "right") { + $align = "float: right;"; + } + else { // Inline + $align = ""; + } + + if(!substr_count($video_url, '/')) { + $video_url = ml($video_url); + } + + if(substr($video_url, -4) != 'webm' && substr($video_url, -3) != 'ogv' && substr($video_url, -3) != 'mp4') { + $renderer->doc .= "Error: The video must be in webm, ogv, or mp4 format.<br />" . $video_url; + return false; + } + + if(is_null($video_size) or !substr_count($video_size, 'x')) { + $width = 640; + $height = 360; + } + else { + $obj_dimensions = explode('x', $video_size); + $width = $obj_dimensions[0]; + $height = $obj_dimensions[1]; + } + + if(is_null($video_attr)) { + $attr = ""; + } + else { + $arr_attr = explode(',', $video_attr); + if(count($arr_attr) == 1) { + if($arr_attr[0] == "loop") { + $attr = 'loop="loop"'; + } + elseif($arr_attr[0] == "autoplay") { + $attr = 'autoplay="autoplay"'; + } + } + elseif(count($arr_attr) == 2) { + if($arr_attr[0] != $arr_attr[1]) { + $attr = 'loop="loop" autoplay="autoplay"'; + } + else { + $renderer->doc .= "Error: Duplicate parameters.<br />"; + return false; + } + } + else { + $renderer->doc .= "Error: Wrong number of parameters.<br />"; + return false; + } + } + + $obj = '<video src="' . $video_url . '" width="' . $width . '" height="' . $height . '" controls="controls" ' . $attr . '></video>'; + if($align != "") { + $obj = '<div style="width: ' . $width . 'px; ' . $align . '">' . $obj . '</div>'; + } + + $renderer->doc .= $obj; + return true; + } + private function _getAlts($filename) { + return false; + } +} diff --git a/public_html/lib/plugins/youtube/img/youtube.png b/public_html/lib/plugins/youtube/img/youtube.png new file mode 100644 index 0000000..24aad8a Binary files /dev/null and b/public_html/lib/plugins/youtube/img/youtube.png differ diff --git a/public_html/lib/plugins/youtube/object.htm b/public_html/lib/plugins/youtube/object.htm new file mode 100644 index 0000000..67e6592 --- /dev/null +++ b/public_html/lib/plugins/youtube/object.htm @@ -0,0 +1,4 @@ +<object width="%s" height="%s" type="application/x-shockwave-flash" data="http://www.youtube.com/v/%s" align="%s" title="%s"> + <param name="movie" value="http://www.youtube.com/v/%s"></param> + <param name="wmode" value="transparent"></param> +</object> diff --git a/public_html/lib/plugins/youtube/style.css b/public_html/lib/plugins/youtube/style.css new file mode 100644 index 0000000..35cfd5b --- /dev/null +++ b/public_html/lib/plugins/youtube/style.css @@ -0,0 +1,7 @@ +div.dokuwiki div.youtube_icon +{ + background-image:url('img/youtube.png'); + background-repeat:no-repeat; + min-height:16px; + padding-left:45px; +} diff --git a/public_html/lib/plugins/youtube/syntax.php b/public_html/lib/plugins/youtube/syntax.php new file mode 100644 index 0000000..39ced15 --- /dev/null +++ b/public_html/lib/plugins/youtube/syntax.php @@ -0,0 +1,83 @@ +<?php +/** + * Plugin YouTube: Create YouTube link and object from ID. + * + * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) + * @author Ikuo Obataya <I.Obataya[at]gmail.com + * @version 2008-04-05 + * @update 2008-04-05 + */ + +if(!defined('DOKU_INC')) die(); +if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); +require_once(DOKU_PLUGIN.'syntax.php'); + +class syntax_plugin_youtube extends DokuWiki_Syntax_Plugin { + var $html; + var $pattern; + function syntax_plugin_youtube(){ + $this->html = @file_get_contents(DOKU_PLUGIN.'youtube/object.htm'); + $this->pattern = '/\{\{(\s?)youtube>(small|large|link):([^} |]+)\|?(.*?)(\s?)\}\}/'; + } + function getInfo(){ + return array( + 'author' => 'Ikuo Obataya', + 'email' => 'i.obat...@gmail.com', + 'date' => '2008-04-05', + 'name' => 'YouTube Plugin', + 'desc' => 'YouTube link and object{{youtube>[small|large|link]:ID}}', + 'url' => 'http://wiki.symplus.co.jp/computer/en/youtube_plugin', + ); + } + function getType(){ return 'substition'; } + function getSort(){ return 159; } + function connectTo($mode) { $this->Lexer->addSpecialPattern('\{\{\s?youtube>[^}]*\s?\}\}',$mode,'plugin_youtube'); } + + function handle($match, $state, $pos, &$handler){ + $pm = preg_match_all($this->pattern,$match,$result); + $left = ($result[1][0]==" "); + $right = ($result[5][0]==" "); + $cmd = $result[2][0]; + $id = $result[3][0]; + $title = $result[4][0]; + if ($left==true && $right==true){ + $align = 'center'; + }else if($left==true){ + $align = 'right'; + }else if($right==true){ + $align = 'left'; + } + return array($state, array($cmd,$id,$align,$title)); + } + + function render($mode, &$renderer, $data){ + if($mode != 'xhtml'){return false;} + list($state, $match) = $data; + list($cmd,$id,$align,$title) = $match; + $id = urlencode($id); + $title = urlencode($title); + $title = str_replace("+"," ",$title); + switch($cmd){ + case 'link': + $lnkFormat='<a href="http://www.youtube.com/watch?v=%s" title="%s">'; + $href_start=sprintf($lnkFormat,$id,empty($title)?$id:$title.' ('.$id.')'); + $renderer->doc.=$href_start.'<div class="youtube_icon">'.$title.'</div></a>'; + return true; + + case 'large': + if ($align=='center'){$renderer->doc.="<center>";} + $renderer->doc.=sprintf($this->html,425,350,$id,$align,$title,$id); + if ($align=='center'){$renderer->doc.="</center>";} + $renderer->doc.=NL; + return true; + + case 'small': + if ($align=='center'){$renderer->doc.="<center>";} + $renderer->doc.=sprintf($this->html,255,210,$id,$align,$title,$id); + if ($align=='center'){$renderer->doc.="</center>";} + return true; + } + $renderer->doc.=NL; + } +} +?> \ No newline at end of file --