From 697d24ab9a0df40570d25ab41ef6aaf44c962772 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Fri, 13 Oct 2023 06:57:44 +0200 Subject: [PATCH] First --- README.md | 3 ++ action.php | 25 +++++++++++ conf/default.php | 8 ++++ conf/metadata.php | 9 ++++ images/left.png | Bin 0 -> 531 bytes images/right.png | Bin 0 -> 534 bytes jquery.scrollTo.min.js | 7 +++ lang/en/settings.php | 10 +++++ lang/fr/settings.php | 10 +++++ plugin.info.txt | 7 +++ script.js | 47 +++++++++++++++++++++ style.css | 57 +++++++++++++++++++++++++ syntax.php | 94 +++++++++++++++++++++++++++++++++++++++++ 13 files changed, 277 insertions(+) create mode 100644 action.php create mode 100644 conf/default.php create mode 100644 conf/metadata.php create mode 100644 images/left.png create mode 100644 images/right.png create mode 100644 jquery.scrollTo.min.js create mode 100644 lang/en/settings.php create mode 100644 lang/fr/settings.php create mode 100644 plugin.info.txt create mode 100644 script.js create mode 100644 style.css create mode 100644 syntax.php diff --git a/README.md b/README.md index 90bd46c..7053832 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ # showsamples +DokuWiki Extensions : https://www.dokuwiki.org/plugin:showsamples + +Installs a carousel that contains topic snippets. diff --git a/action.php b/action.php new file mode 100644 index 0000000..9108268 --- /dev/null +++ b/action.php @@ -0,0 +1,25 @@ + + * + * Plugin showSamples: display sample from plugins + */ + +if (!defined ('DOKU_INC')) + die (); +if (!defined ('DOKU_PLUGIN')) + define ('DOKU_PLUGIN', DOKU_INC.'lib/plugins/'); +require_once (DOKU_PLUGIN.'action.php'); + +class action_plugin_showsamples extends DokuWiki_Action_Plugin { + + function register (Doku_Event_Handler $controller) { + $controller->register_hook ('DOKUWIKI_STARTED', 'AFTER', $this, '_defconf'); + } + + function _defconf (&$event, $param) { + global $JSINFO; + $JSINFO ['carousel'] = array ('delai' => ($this->getConf ('carouselDelai')*1000)); + } +} diff --git a/conf/default.php b/conf/default.php new file mode 100644 index 0000000..6160551 --- /dev/null +++ b/conf/default.php @@ -0,0 +1,8 @@ + + * + * Options for the showSamples Plugin + */ +$conf['carouselDelai'] = 10; diff --git a/conf/metadata.php b/conf/metadata.php new file mode 100644 index 0000000..227b69b --- /dev/null +++ b/conf/metadata.php @@ -0,0 +1,9 @@ + + * + * Metadata for configuration manager plugin + * Additions for the schedule plugin + */ +$meta['carouselDelai'] = array('numeric'); diff --git a/images/left.png b/images/left.png new file mode 100644 index 0000000000000000000000000000000000000000..1b6141c11c29a5d0acff29cc91b7ae0fe944bf41 GIT binary patch literal 531 zcmV+u0_^>XP)Px#0%A)?L;(MXkIcUS000SaNLh0L00FxI00FxJI_%@(00007bV*G`2iyV+5hgQb z1Bu`O00EatL_t(2&n=O?Yg2I;M$h}^%iE%fi#38~5aK2!#Qz{mEJCLUrh7L@CdDju zNT`Dl#6g6*NQCO(R5A&!#Tdj zXz$L4<6R8c5!YC>Lr+-+d>ok|+0yQgffy~ZgTK`b70!{t5%8T?{9~mr8*Nhv8HBPfa3NRcIzi>n4%^!Z41G3zgr(7ZnIOe-! zW-w6qOoB%Q!~j%eU#=1pFuU~<30x1O*4(tmcEp?oF$?A#F|v+rTCHg)NH^U-;I4hK zDKn=0-u-MH4oUZ=yNq>RT*I|vFGn87Hzp(kZE1JkmI6SnXmwY%639>o(tEzl{U2$L Vu7F*EMO^>@002ovPDHLkV1gsv-aP;S literal 0 HcmV?d00001 diff --git a/images/right.png b/images/right.png new file mode 100644 index 0000000000000000000000000000000000000000..63fd4560101bce4ebd964aad86321c8c35572fd0 GIT binary patch literal 534 zcmV+x0_pvUP)Px#0%A)?L;(MXkIcUS000SaNLh0L00FxI00FxJI_%@(00007bV*G`2iyV+5hn?{ z6k!tp00EjwL_t(2&n=O$YZGx8K;QSJmv{{trJ&7VI|y-;65=lC5{u9&g6ZVa#UYs# zv(zD>9fVLEL~xP_)j=Femi_}`48>7Ft%F7sO`62>a=G8<(7f^SwkO6hjhrjHg3E(; zwWF>3ACA2kuqm!Gt%tsn2F5s2!CXz7n+9Uk#P3qC16 z^2pv>0*^EqS!e8rw=^nvoW}cq+x$+k3Svu=v3xO(iLB8&2!K8ZkU+T68S08q+V*%d4g($$W%Ud(p? Y2Ncn;K^eu~#Q*>R07*qoM6N<$f;Z{tegFUf literal 0 HcmV?d00001 diff --git a/jquery.scrollTo.min.js b/jquery.scrollTo.min.js new file mode 100644 index 0000000..f927a43 --- /dev/null +++ b/jquery.scrollTo.min.js @@ -0,0 +1,7 @@ +/** + * Copyright (c) 2007-2015 Ariel Flesler - afleslergmailcom | http://flesler.blogspot.com + * Licensed under MIT + * @author Ariel Flesler + * @version 2.1.2 + */ +;(function(f){"use strict";"function"===typeof define&&define.amd?define(["jquery"],f):"undefined"!==typeof module&&module.exports?module.exports=f(require("jquery")):f(jQuery)})(function($){"use strict";function n(a){return!a.nodeName||-1!==$.inArray(a.nodeName.toLowerCase(),["iframe","#document","html","body"])}function h(a){return $.isFunction(a)||$.isPlainObject(a)?a:{top:a,left:a}}var p=$.scrollTo=function(a,d,b){return $(window).scrollTo(a,d,b)};p.defaults={axis:"xy",duration:0,limit:!0};$.fn.scrollTo=function(a,d,b){"object"=== typeof d&&(b=d,d=0);"function"===typeof b&&(b={onAfter:b});"max"===a&&(a=9E9);b=$.extend({},p.defaults,b);d=d||b.duration;var u=b.queue&&1=f[g]?0:Math.min(f[g],n));!a&&1 + * + * English language file + */ + +// for the configuration manager +$lang['carouselDelai'] = 'Carousel turn delai (sec)'; diff --git a/lang/fr/settings.php b/lang/fr/settings.php new file mode 100644 index 0000000..4c797c7 --- /dev/null +++ b/lang/fr/settings.php @@ -0,0 +1,10 @@ + + * + * French language file + */ + +// for the configuration manager +$lang['carouselDelai'] = 'Délai de rotation du carrousel (en secondes)'; diff --git a/plugin.info.txt b/plugin.info.txt new file mode 100644 index 0000000..432b385 --- /dev/null +++ b/plugin.info.txt @@ -0,0 +1,7 @@ +base showsamples +author Francois Merciol +email dokuplugin@merciol.fr +date 2021-03-31 +name showSamples Plugin +desc Show samples from plugins +url http://www.dokuwiki.org/plugin:showsamples diff --git a/script.js b/script.js new file mode 100644 index 0000000..0d9b107 --- /dev/null +++ b/script.js @@ -0,0 +1,47 @@ +/* DOKUWIKI:include_once jquery.scrollTo.min.js */ + +var showCarouselItem = 0; +var showCarouselDelai = JSINFO['carousel']['delai']; +var showCarouselMax = jQuery ('div.showSamples div.slide ul li').length; +var showCarouselTimeout; + +function showCarouselLeft () { + if (showCarouselItem < 1) + return; + showCarouselItem--; + showCarouselMove (); +} + +function showCarouselRight () { + if (showCarouselItem >= showCarouselMax) + return; + showCarouselItem++; + showCarouselMove (); +} + +function showCarouselMove () { + jQuery ("div.showSamples div.navi a img.leftside").each (function () { + this.style.display = (showCarouselItem > 0) ? "" : "none"; + }); + var showCarouselMax = jQuery ('div.showSamples div.slide ul li').length; + jQuery ("div.showSamples div.navi a img.rightside").each (function () { + this.style.display = (showCarouselItem < (showCarouselMax-1)) ? "" : "none"; + }); + jQuery ("div.showSamples div.slide").scrollTo ('li:eq('+showCarouselItem+')', 1000); +} + +function showCarousel () { + showCarouselItem = 0; + showCarouselMove (); + showCarouselTimeout = setTimeout ("showCarouselNext ()", showCarouselDelai); +} + +function showCarouselNext () { + clearTimeout (showCarouselTimeout); + if (showCarouselMax) + showCarouselItem = (showCarouselItem+1) % (jQuery ('div.showSamples div.slide ul li').length); + showCarouselMove (); + showCarouselTimeout = setTimeout ("showCarouselNext ()", showCarouselDelai); +} + +jQuery (showCarousel ()); diff --git a/style.css b/style.css new file mode 100644 index 0000000..c41ea0d --- /dev/null +++ b/style.css @@ -0,0 +1,57 @@ +div.showSamples div.navi { + z-index: 2; + position: absolute; + margin: 0; + padding: 0; + width: 200px; +} + +div.showSamples div.navi img.leftside { + float: left; +} + +div.showSamples div.navi img.rightside { + float: right; +} + +div.showSamples div.slide { + z-index: 1; + position: relative; + margin: 0; + padding: 0; + height: 200px; + width: 200px; + overflow: hidden; +} + +div.showSamples div.slide ul { + position: absolute; + list-style: none outside none; + width: 20000px; +} + +div.showSamples div.slide ul li { + float: left; + font-size: 80%; + width: 200px; +} + +div.showSamples div.slide ul li div.li { + background: none !important; + margin: 0 auto !important; + padding: 0 !important; + text-align: center; +} + +div.showSamples div.slide ul li div.highlightMenu { + border: none; +} + +div.showSamples div.slide ul li div div.tileBlog { + margin: 0 auto; +} + +div.showSamples div.slide ul li div div.glossary div { + margin: 1em auto; + width: 180px; +} \ No newline at end of file diff --git a/syntax.php b/syntax.php new file mode 100644 index 0000000..8e03597 --- /dev/null +++ b/syntax.php @@ -0,0 +1,94 @@ + + * + * Plugin showSamples: display sample from plugins + */ + +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_showSamples extends DokuWiki_Syntax_Plugin { + + // ============================================================ + // function getInfo () { + // return confToHash (dirname (__FILE__).'/INFO.txt'); + // } + function getType () { return 'substition'; } + function getPType () { return 'block'; } + function getSort () { return 299; } + function getAllowedTypes() { return array ('container', 'baseonly', 'formatting', 'substition', 'protected', 'disabled', 'paragraphs'); } + function connectTo ($mode) { + $this->Lexer->addEntryPattern (']*>', $mode, 'plugin_showsamples'); + } + function postConnect() { + $this->Lexer->addExitPattern ('', 'plugin_showsamples'); + } + + // ============================================================ + function handle ($match, $state, $pos, Doku_Handler $handler){ + switch ($state) { + case DOKU_LEXER_ENTER: + return array($state, trim (substr ($match, 12, -1))); // " 12 ">" => 1 + case DOKU_LEXER_UNMATCHED: + return array($state, $match); + case DOKU_LEXER_EXIT: + return array($state); + } + return false; + } + + // ============================================================ + function render ($mode, Doku_Renderer $renderer, $indata) { + if ($mode != 'xhtml') + return false; + if (empty ($indata)) + return false; + list ($instr, $data) = $indata; + //$data = " ".$data." "; + $renderer->info['cache'] = FALSE; + switch ($instr) { + case DOKU_LEXER_ENTER : + if (preg_match_all ("#(\"[^\"]*\")*help(\"[^\"]*\")*#", strtolower ($data), $dumy) > 0) { + $this->help ($renderer); + return true; + } + $imgDir = DOKU_REL.'lib/plugins/showsamples/images/'; + $renderer->doc .= + '
'.NL. + ' '.NL. + '
'; + break; + case DOKU_LEXER_EXIT : + $renderer->doc .= + '
'.NL. + '
'; + break; + case DOKU_LEXER_UNMATCHED: + $renderer->doc .= $renderer->_xmlEntities($data); + break; + } + return true; + } + + // ============================================================ + function help (&$renderer) { + $url = "http://fsl56.org/admin/plugins/showSamples/"; + $renderer->doc .= + '

Help showSamples V1.0

'.NL. + '
    '.NL. + '
  • {{showSamples [help] }}
  • '.NL. + '
'.NL. + '

'.$url.'

'.NL; + } + + // ============================================================ +} // syntax_plugin_showSamples +?>