====== PGN Viewer Plugin ====== ---- plugin ---- description: JavaScript viewer for chess games in PGN format (based on jsPgnViewer library by Toomas Römer) author : Dominik Smatana email : dominiks@users.sourceforge.net type : syntax lastupdate : 2007-11-09 compatible : 2007-06-26b depends : conflicts : similar : tags : media, images, diagram, game, javascript ---- ===== Warning ===== This plugin is still in development (alpha version)! Use it on your own risk only! ===== Legal info ===== This plugin is based on jsPgnViewer library developed by [[toomasr@gmail.com|Toomas Römer]]. More info at http://tom.jabber.ee/chess/ ===== Installation ===== coming soon... ===== Configuration ===== coming soon... ===== Usage ===== Put the PGN ((PGN - Portable Game Notation, [[wp>Portable game notation]])) code of your game between and tags. Example: [Event "gameID 5127359"] [Site "http://www.chessmaniac.com"] [Date "2007.10.20"] [Round ""] [White "CaptainMuleus"] [Black "d0minik"] [TimeControl "normal"] [Result "1-0"] [ECO "oft "] 1.e4 e5 2.Qh5 Nbc6 3.Bfc4 Bfc5 4.Qxf7+ 1-0 ===== Plugin ===== * * This plugin in based on jsPgnViewer library: * * @license Apache License ver 2.0 * @author Toomas Römer */ if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'syntax.php'); /** * All DokuWiki plugins to extend the parser/rendering mechanism * need to inherit from this class */ class syntax_plugin_pgnviewer extends DokuWiki_Syntax_Plugin { /** * return some info */ function getInfo(){ return array( 'author' => 'Dominik Smatana', 'email' => 'dominiks@users.sourceforge.net', 'date' => '2007-11-09', 'name' => 'PGN Viewer', 'desc' => 'JavaScript viewer for chess games in PGN format', 'url' => 'http://www.dokuwiki.org/plugin:pgnviewer', ); } /** * What kind of syntax are we? */ function getType(){ return 'protected'; } /** * Where to sort in? */ function getSort(){ return 999; } /** * Connect pattern to lexer */ function connectTo($mode) { $this->Lexer->addEntryPattern('(?=.*)',$mode,'plugin_pgnviewer'); } function postConnect() { $this->Lexer->addExitPattern('', 'plugin_pgnviewer'); } /** * Handle the match */ function handle($match, $state, $pos, &$handler){ switch ($state) { case DOKU_LEXER_ENTER : break; case DOKU_LEXER_MATCHED : break; case DOKU_LEXER_UNMATCHED : break; case DOKU_LEXER_EXIT : break; case DOKU_LEXER_SPECIAL : break; } return array($match, $state); } /** * Create output */ function render($mode, &$renderer, $data) { if ($mode == 'xhtml') { if ($data[1] == DOKU_LEXER_UNMATCHED) { $path = 'lib/plugins/pgnviewer/jspgnviewer/'; $pgn = $data[0]; $now = time() + mt_rand(); $out = ''; // hidden div with the game information $out .= '\n"; // the div that will contain the graphical board $out .= '
'; // initialize the board $out .= ''; $out .= ''; $renderer->doc .= $out; } return true; } return false; } }
===== Change log ===== coming soon... ===== ToDo's ===== * don't include external JavaScript in the middle of body element! * add configuration parameters (e.g. etc...) * is there need to support