DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:codepad

codepad Plugin

Compatible with DokuWiki

No compatibility info given!

plugin uses interpreters on codepad.org to execute sourcecode

Last updated on
2011-08-28
Provides
Syntax

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Tagged with code

By deshi

Installation

Install manually.

codepad/syntax.php
<?php
/**
 * Plugin codepad: 
 * @author deshi
 * @copyright Copyright (C) 2011 deshi
 * @license GPL >=3 (http://www.gnu.org/licenses/)
 * @version 1.0.0
 * @link http://www.dokuwiki.org/plugin:codepad
 */
if (!defined('DOKU_INC')) die();
if (!defined('DOKU_PLUGIN_CODEPAD')) define('DOKU_PLUGIN_CODEPAD',DOKU_PLUGIN.'codepad/');
 
class syntax_plugin_codepad extends DokuWiki_Syntax_Plugin {
	function getType() { return 'substition'; }
	function getPType() { return 'normal'; }
	function getSort() { return 999; }
	function connectTo($mode) { 
		$this->Lexer->addSpecialPattern('~~codepad~~', $mode, 'plugin_codepad'); 
		//$this->Lexer->addSpecialPattern('~~codepad.*?~~', $mode, 'plugin_codepad'); 
	}
 
	function handle($match, $state, $pos, Doku_Handler $handler) {
		$match_array = array();
		//strip ~~codepad: from start and ~~ from end
		$match = substr($match,10,-2);
		// split parameters 
		// $match_array = explode(",", $match);
		// $match_array[0] will be language
		return $match_array;
	}
	/**
	 * Create output
	 */
	function render($mode, Doku_Renderer $renderer, $data) {
		global $conf;
            if($mode == 'xhtml'){
                  $renderer->doc .= '<form action="http://codepad.org/" method="post" target=_blank>';
                  $renderer->doc .= '  <table width="100%" cellpadding="10">';
                  $renderer->doc .= '    <tbody>';			  
                  $renderer->doc .= '  <tr>';
                  $renderer->doc .= '    <td style="vertical-align: middle;"><textarea id="textarea" name="code" style="width: 100%;" rows="15" wrap="off"></textarea></td>';
                  $renderer->doc .= '  </tr>';
                  $renderer->doc .= '  <tr>';
                  $renderer->doc .= '    <td colspan="2" style="vertical-align: middle; text-align: right;">';
                  $renderer->doc .= '      <table width="100%" cellpadding="0" cellspacing="0"><tbody><tr>';
                  $renderer->doc .= '      <td style="text-align: right;">';
                  $renderer->doc .= '      <div style="float: right">';
                  $renderer->doc .= '      <table><tbody><tr>';
                  $renderer->doc .= '      <td>';
                  $renderer->doc .= '      <label style="margin-right:1em">';
                  $renderer->doc .= '        <input style="vertical-align: middle;" name="private" value="True" checked="checked" type="checkbox"><span style="vertical-align:middle" class="label">privat</span>';
                  $renderer->doc .= '      </label>';
                  $renderer->doc .= '      </td>';
                  $renderer->doc .= '      <td>';
                  $renderer->doc .= '      <label style="margin-right:1em">';
                  $renderer->doc .= '        <input style="vertical-align: middle;" name="run" value="True" checked="checked" type="checkbox"><span style="vertical-align:middle" class="label">Quellcode ausführen</span>';
                  $renderer->doc .= '      </label>';
                  $renderer->doc .= '      </td>';
                  $renderer->doc .= '      <td>';
                  $renderer->doc .= '      <label style="margin-right:1em">';
                  $renderer->doc .= '      <select id="lang" name="lang" style="vertical-align:middle"><option value="C">C</option><option value="C++">C++</option><option selected="selected" value="PHP">PHP</option></select>';
                  $renderer->doc .= '      </td>';
                  $renderer->doc .= '      <td style="text-align: right;">';
                  $renderer->doc .= '      <input name="submit" value="ausführen" type="submit">';
                  $renderer->doc .= '      </td>';
                  $renderer->doc .= '      </tr></tbody></table>';
                  $renderer->doc .= '      </div>';
                  $renderer->doc .= '      </td></tr></tbody></table>';
                  $renderer->doc .= '    </td>';
                  $renderer->doc .= '  </tr>';
                  $renderer->doc .= '  </tbody></table>';
                  $renderer->doc .= '  </form>';
 
				return true;
            }
            return false;
	}
}
?>

Examples/Usage

~~codepad~~

Syntax

~~codepad~~

Configuration and Settings

Development

anyone

Change Log

  • 2011-08-28
    • Initial release

Known Bugs and Issues

none

ToDo/Wish List

FAQ

Discussion

Could be placed on an external page (e.g. plugin:pluginname:discussion) to have a distinction between user comments and author docs

plugin/codepad.txt · Last modified: 2016-01-06 22:18 by Aleksandr