bridge:trumpsuits-dokuwiki-plugin
Verschillen
Dit geeft de verschillen weer tussen de geselecteerde revisie en de huidige revisie van de pagina.
| Beide kanten vorige revisieVorige revisieVolgende revisie | Vorige revisie | ||
| bridge:trumpsuits-dokuwiki-plugin [2020/12/19 16:39] – oude revisie hersteld (2020/08/26 22:09) 85.208.210.27 | bridge:trumpsuits-dokuwiki-plugin [2024/03/08 19:45] (huidige) – [Notes] Pieter van der Meulen | ||
|---|---|---|---|
| Regel 1: | Regel 1: | ||
| ====== Trump suits plugin for DokuWiki ====== | ====== Trump suits plugin for DokuWiki ====== | ||
| - | This may not be the most spectacular DokuWiki plugin available, but it suits my own needs just fine. The plugin renders the diamond and heart card suit symbols in red (♦/♥), and the clubs and spade card suit symbols in black (♣/♠). It also adds four buttons to the editor toolbar for quick access to the trump suit symbols. | + | This may not be the most spectacular DokuWiki plugin available, but it suits my own needs just fine. The plugin renders |
| - | Due to my very limited knowledge of PHP and javascript I can't guarantee this won't set fire to your DokuWiki server. Mine seems to have survived | + | Due to my very limited knowledge of PHP and javascript I can't guarantee this won't set fire to your DokuWiki server. Mine seems to have survived |
| ===== Syntax ===== | ===== Syntax ===== | ||
| No special syntax. Just use standard UTF card suit symbols (optionally inserted by using the toolbar buttons). | No special syntax. Just use standard UTF card suit symbols (optionally inserted by using the toolbar buttons). | ||
| - | |||
| - | ===== Versions ===== | ||
| - | |||
| - | ;2010-09-03 | ||
| - | :Fixed javascript that was broken in DokuWiki version 2009-12-25, “Lemming”. | ||
| - | ;2009-11-05 | ||
| - | :Initial version | ||
| - | | ||
| - | |||
| - | |||
| ===== Installation ===== | ===== Installation ===== | ||
| - | |||
| Regel 26: | Regel 15: | ||
| - | Point your plug-in manager at [[http://home.vdmeulen.net/ | + | Point your plug-in manager at [[/downloads/trumpsuits-dokuwiki-plugin.tar.gz]] or [[/downloads/trumpsuits-dokuwiki-plugin.zip]]. |
| ==== Manual ==== | ==== Manual ==== | ||
| Regel 33: | Regel 21: | ||
| Create the folder '' | Create the folder '' | ||
| - | ^ Suit ^ | + | ^ Suit ^ Filename |
| - | | Clubs | 2663 | 2667 | + | | Clubs |
| - | | Diamonds | + | | Diamonds |
| - | | Hearts | + | | Hearts |
| - | | Spades | + | | Spades |
| === syntax.php === | === syntax.php === | ||
| Take care not to include whitespace in front of the first php tag or after the last php tag. This leads to strange behaviour by DokuWiki. | Take care not to include whitespace in front of the first php tag or after the last php tag. This leads to strange behaviour by DokuWiki. | ||
| - | |||
| <code php> | <code php> | ||
| <?php | <?php | ||
| /** | /** | ||
| - | * Plugin | + | * Plugin |
| * | * | ||
| * @license | * @license | ||
| Regel 52: | Regel 40: | ||
| */ | */ | ||
| - | if(!defined(' | + | if(!defined(' |
| if(!defined(' | if(!defined(' | ||
| require_once(DOKU_PLUGIN.' | require_once(DOKU_PLUGIN.' | ||
| Regel 61: | Regel 49: | ||
| */ | */ | ||
| class syntax_plugin_trumpsuits extends DokuWiki_Syntax_Plugin { | class syntax_plugin_trumpsuits extends DokuWiki_Syntax_Plugin { | ||
| - | |||
| - | public static $SPADES=' | ||
| - | public static $HEARTS=' | ||
| - | public static $DIAMONDS=' | ||
| - | public static $CLUBS=' | ||
| /** | /** | ||
| * return some info | * return some info | ||
| */ | */ | ||
| - | function getInfo() { | + | function getInfo(){ |
| return array( | return array( | ||
| ' | ' | ||
| ' | ' | ||
| - | ' | + | ' |
| ' | ' | ||
| - | ' | + | ' |
| ' | ' | ||
| ); | ); | ||
| Regel 84: | Regel 67: | ||
| * What kind of syntax are we? | * What kind of syntax are we? | ||
| */ | */ | ||
| - | function getType() { | + | function getType(){ |
| return ' | return ' | ||
| } | } | ||
| //This must be implemented | //This must be implemented | ||
| - | function getSort() { | + | function getSort(){ return 123; } |
| - | | + | |
| - | | + | |
| + | |||
| + | } | ||
| + | ?> | ||
| + | </ | ||
| + | |||
| + | Hieruit eventueel nog stukje gebruiken: | ||
| + | |||
| + | <code php> | ||
| + | <?php | ||
| + | /** | ||
| + | * Plugin Trumpsigns: Inserts <font size=" | ||
| + | | ||
| + | * @license | ||
| + | * @author | ||
| + | */ | ||
| + | |||
| + | if(!defined(' | ||
| + | if(!defined(' | ||
| + | require_once(DOKU_PLUGIN.' | ||
| + | |||
| + | /** | ||
| + | * All DokuWiki plugins to extend the parser/ | ||
| + | * need to inherit from this class | ||
| + | */ | ||
| + | class syntax_plugin_tab extends DokuWiki_Syntax_Plugin { | ||
| + | |||
| /** | /** | ||
| - | | + | |
| */ | */ | ||
| - | function | + | function |
| - | return 'normal'; | + | return |
| + | | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ); | ||
| } | } | ||
| + | |||
| + | /** | ||
| + | * What kind of syntax are we? | ||
| + | */ | ||
| + | function getType(){ | ||
| + | return ' | ||
| + | } | ||
| + | |||
| + | |||
| + | /** | ||
| + | * Where to sort in? | ||
| + | */ | ||
| + | function getSort(){ | ||
| + | return 789; | ||
| + | } | ||
| + | |||
| + | |||
| /** | /** | ||
| * Connect pattern to lexer | * Connect pattern to lexer | ||
| */ | */ | ||
| function connectTo($mode) { | function connectTo($mode) { | ||
| - | | + | |
| - | $this-> | + | $this-> |
| - | $this-> | + | $this-> |
| - | $this-> | + | $this-> |
| - | $this-> | + | |
| } | } | ||
| + | |||
| /** | /** | ||
| * Handle the match | * Handle the match | ||
| */ | */ | ||
| - | function handle($match, | + | function handle($match, |
| - | $repl = $match; | + | switch ($state) { |
| - | switch ($match) { | + | case DOKU_LEXER_ENTER |
| - | case self:: | + | break; |
| - | $repl = $this-> | + | case DOKU_LEXER_MATCHED |
| - | | + | break; |
| - | case self:: | + | case DOKU_LEXER_UNMATCHED |
| - | $repl = $this-> | + | break; |
| - | | + | case DOKU_LEXER_EXIT |
| - | case self:: | + | break; |
| - | $repl = $this-> | + | case DOKU_LEXER_SPECIAL |
| - | | + | break; |
| - | case self:: | + | |
| - | $repl = $this-> | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | if (preg_match($regex, | + | |
| - | $repl = substr($match, | + | |
| - | $repl .= $this-> | + | |
| - | $repl .= substr($match, | + | |
| - | } | + | |
| - | else { | + | |
| - | $repl = $match; | + | |
| - | } | + | |
| } | } | ||
| - | return array($match, $repl); | + | return array(); |
| } | } | ||
| + | |||
| /** | /** | ||
| - | * Create output. On non-xhtml formasts leave symbols unaffected | + | * Create output |
| - | * | + | |
| - | * @param < | + | |
| - | * @param < | + | |
| - | * @param < | + | |
| - | * @return < | + | |
| */ | */ | ||
| - | function render($format, & | + | function render($mode, & |
| - | if($format | + | if($mode == ' |
| - | $renderer-> | + | $renderer-> |
| - | } else { | + | $renderer-> |
| - | $renderer-> | + | $renderer-> |
| + | return true; | ||
| } | } | ||
| - | return | + | return |
| } | } | ||
| + | } | ||
| + | |||
| + | //Setup VIM: ex: et ts=4 enc=utf-8 : | ||
| - | function render_style($s, | ||
| - | return '< | ||
| - | } | ||
| - | function nt_symbol_regex() { | ||
| - | return ' | ||
| - | } | ||
| - | |||
| - | } | ||
| - | ?> | ||
| </ | </ | ||
| + | |||
| + | |||
| + | |||
| === script.js === | === script.js === | ||
| <code javascript> | <code javascript> | ||
| - | if(window.toolbar!=undefined){ | + | //create a single toolbutton with desired properties |
| - | var icobase | + | function plugin_trumpsuits_createToolbutton |
| - | | + | var ico = document.createElement(" |
| - | | + | ico.src |
| - | " | + | |
| - | " | + | btn.id = "syntax__plugin_trumpsuits_" |
| - | | + | |
| - | " | + | btn.appendChild(ico); |
| - | | + | |
| - | | + | btn.accessKey = accKey; |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| } | } | ||
| - | </ | ||
| - | |||
| - | |||
| - | |||
| + | //if this is an " | ||
| + | function plugin_trumpsuits_toolbar_additions() { | ||
| + | var toolbar = $(" | ||
| + | if(!toolbar) {return;} | ||
| + | if(!$(" | ||
| + | var tbtn = plugin_trumpsuits_createToolbutton(" | ||
| + | if (tbtn) {toolbar.appendChild(tbtn); | ||
| + | tbtn = plugin_trumpsigns_createToolbutton(" | ||
| + | if (tbtn) {toolbar.appendChild(tbtn); | ||
| + | tbtn = plugin_trumpsigns_createToolbutton(" | ||
| + | if (tbtn) {toolbar.appendChild(tbtn); | ||
| + | tbtn = plugin_trumpsigns_createToolbutton(" | ||
| + | if (tbtn) {toolbar.appendChild(tbtn); | ||
| + | } | ||
| + | addInitEvent(plugin_trumpsuits_toolbar_additions); | ||
| + | </ | ||
| + | ===== Notes ===== | ||
| + | Notes on javasript in plugins: http:// | ||
| - | ===== Wishlist ===== | + | Browser an OS dependent CSS selectors: https:// |
| - | *Configuration options for trump suit symbol replacement | ||
| - | *Language options. Can one use language conf in javascript? | ||
bridge/trumpsuits-dokuwiki-plugin.1608392353.txt.gz · Laatst gewijzigd: (Externe bewerking)
