DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:fontcolor

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plugin:fontcolor [2014-02-24 12:50] – [Download and Installation] 122.212.225.106plugin:fontcolor [2024-02-08 08:01] (current) rnck
Line 1: Line 1:
-====== fontcolor plugin ======+====== FontColor Plugin ======
  
 ---- plugin ---- ---- plugin ----
-description: text in various colors+description: Text in various colors
 author     : Thorsten Stratmann author     : Thorsten Stratmann
 email      : thorsten.stratmann@web.de email      : thorsten.stratmann@web.de
 type       : syntax type       : syntax
-lastupdate : 2010-03-23 +lastupdate : 2016-03-05 
-compatible : Anteater, Rincewind, Angua, Adora Belle, Weatherwax, Binky+compatible : Frusterick Manners, Anteater, Rincewind, Angua, Adora Belle, Weatherwax, Binky, Ponder Stibbons, Hrun, Detritus, Greebo, Hogfather, Igor, Jack Jackrum, !Kaos
 depends    :  depends    : 
 conflicts  conflicts 
-similar    : highlight, color +similar    : bbcode, color, highlight 
-tags       : typography, highlight+tags       : typography, highlight, color
  
-downloadurl: https://github.com/lupo49/dokuwiki-plugin-fontcolor/archive/master.zip+downloadurl: https://github.com/lupo49/dokuwiki-plugin-fontcolor/zipball/master 
 +bugtracker : https://github.com/lupo49/dokuwiki-plugin-fontcolor/issues
 sourcerepo : https://github.com/lupo49/dokuwiki-plugin-fontcolor sourcerepo : https://github.com/lupo49/dokuwiki-plugin-fontcolor
 ---- ----
- 
  
 ===== Download and Installation ===== ===== Download and Installation =====
  
-Download and install the plugin using the [[plugin:plugin|Plugin Manager]] using the following URLRefer to [[:Plugins]] on how to install plugins manually.+Search and install the plugin using the [[plugin:extension|Extension Manager]].  
 + 
 +This plugin requires gdlib support, see [[tips:phpwithgd]] for help.
  
-  * [[https://github.com/lupo49/dokuwiki-plugin-fontcolor/archive/master.zip|fontcolor]] (version 3.1) 
-  * [[https://github.com/ssahara/dw-plugin-fontcolor/archive/master.zip|fontcolor]] (version 4.0) backup copy 
 ====== Description ====== ====== Description ======
-See it +You can give colors to text by using the syntax: 
- +<code> 
- +<fc #FF0000>Red Colored Text</fc> or <fc #008000>Green Colored Text</fc>
- +
-===== Code ===== +
-This Code is similar to the [[plugin:highlight|Plugin highlight]] +
-The difference is only, that not the background-color but the font-color changes +
- +
-==== syntax.php==== +
- +
-Put this code into ''lib/plugins/fontcolor/syntax.php'': +
- +
- +
-<code php syntax.php> +
- +
-<?php +
-/** +
- * fontcolor Plugin: Allows user-defined font colors +
- * +
- * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html) +
- * @author     modified by ThorstenStratmann <thorsten.stratmann@web.de> +
- * @link       http://www.dokuwiki.org/plugin:fontcolor +
- * @version    4.0 +
- */ +
-  +
-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_fontcolor extends DokuWiki_Syntax_Plugin { +
-  +
-    function getInfo(){  // return some info +
-        return array( +
-            'author' => 'ThorstenStratmann', +
-            'email'  => 'thorsten.stratmann@web.de', +
-            'date'   => '2010-03-23', +
-            'name'   => 'fontcolor Plugin', +
-            'desc'   => 'color text with a specific color +
-                         Syntax: <fc color>Your Text </fc>', +
-            'url'    => 'http://www.dokuwiki.org/plugin:fontcolor', +
-        ); +
-    } +
-  +
-     // What kind of syntax are we? +
-    function getType(){ return 'formatting';+
-  +
-    // What kind of syntax do we allow (optional) +
-    function getAllowedTypes() { +
-        return array('formatting', 'substition', 'disabled'); +
-    } +
-  +
-   // What about paragraphs? (optional) +
-   function getPType(){ return 'normal';+
-  +
-    // Where to sort in? +
-    function getSort(){ return 90; } +
-  +
-  +
-    // Connect pattern to lexer +
-    function connectTo($mode) { +
-      $this->Lexer->addEntryPattern('(?i)<fc(?: .+?)?>(?=.+</fc>)',$mode,'plugin_fontcolor'); +
-    } +
-    function postConnect() { +
-      $this->Lexer->addExitPattern('(?i)</fc>','plugin_fontcolor'); +
-    } +
-  +
-  +
-    // Handle the match +
-    function handle($match, $state, $pos, &$handler){ +
-        switch ($state) { +
-          case DOKU_LEXER_ENTER : +
-            preg_match("/(?i)<fc (.+?)>/", $match, $color); // get the color +
-            if ( $this->_isValid($color[1]) ) return array($state, $color[1]); +
-            break; +
-          case DOKU_LEXER_MATCHED : +
-            break; +
-          case DOKU_LEXER_UNMATCHED : +
-            return array($state, $match); +
-            break; +
-          case DOKU_LEXER_EXIT : +
-            break; +
-          case DOKU_LEXER_SPECIAL : +
-            break; +
-        } +
-        return array($state, "#ff0"); +
-    } +
-  +
-    // Create output +
-    function render($mode, &$renderer, $data) { +
-        if($mode == 'xhtml'){ +
-          list($state, $color) = $data; +
-          switch ($state) { +
-            case DOKU_LEXER_ENTER : +
-              $renderer->doc .= "<span style=\"color: $color\">"; +
-              break; +
-            case DOKU_LEXER_MATCHED : +
-              break; +
-            case DOKU_LEXER_UNMATCHED : +
-              $renderer->doc .= $renderer->_xmlEntities($color); +
-              break; +
-            case DOKU_LEXER_EXIT : +
-              $renderer->doc .= "</span>"; +
-              break; +
-            case DOKU_LEXER_SPECIAL : +
-              break; +
-          } +
-          return true; +
-        } +
-        return false; +
-    } +
-  +
-    // validate color value $c +
-    // this is cut price validation - only to ensure the basic format is +
-    // correct and there is nothing harmful +
-    // three basic formats  "colorname", "#fff[fff]", "rgb(255[%],255[%],255[%])" +
-    function _isValid($c) { +
-  +
-        $c = trim($c); +
-  +
-        $pattern = "/ +
-            (^[a-zA-Z]+$)|                                #colorname - not verified +
-            (^\#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$)|        #colorvalue +
-            (^rgb\(([0-9]{1,3}%?,){2}[0-9]{1,3}%?\)$)     #rgb triplet +
-            /x"; +
-  +
-        return (preg_match($pattern, $c)); +
-  +
-    } +
-+
-  +
-//Setup VIM: ex: et ts=4 sw=4 enc=utf-8 : +
 </code> </code>
  
-==== action.php ====+This syntax can be included via the toolbar using the button: {{https://raw.githubusercontent.com/lupo49/dokuwiki-plugin-fontcolor/master/images/toolbar_icon.png}}, which shows a color picker.
  
-Put this code into ''lib/plugins/fontcolor/action.php'':+===Notes=== 
 +This formatting behaves equal to other wiki syntax like italic and bold. You can only apply it to text, not to headers.
  
-<code php action.php> 
  
-<?php +===== Development ===== 
-/** +==== Code ==== 
- * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html) +The (original) code is similar to the [[plugin:highlight|Plugin highlight]] 
- * @author     Andreas Gohr <andi@splitbrain.org> +The difference is only, that not the background-color but the font-color changes
- */+
  
-// must be run within Dokuwiki 
-if(!defined('DOKU_INC')) die(); 
  
-if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); +==== Features and issues ==== 
-require_once(DOKU_PLUGIN.'action.php');+Please report your issues just at https://github.com/lupo49/dokuwiki-plugin-fontcolor/issues
  
-class action_plugin_fontcolor extends DokuWiki_Action_Plugin { 
  
-    /** 
-     * return some info 
-     * 
-     * @author Andreas Gohr <andi@splitbrain.org> 
-     */ 
-    function getInfo(){ 
-        return array_merge(confToHash(dirname(__FILE__).'/README'), array('name' => 'Toolbar Component')); 
-    } 
  
-    /** 
-     * register the eventhandlers 
-     * 
-     * @author Andreas Gohr <andi@splitbrain.org> 
-     */ 
-    function register(Doku_Event_Handler $controller){ 
-        $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'handle_toolbar', array ()); 
-    } 
- 
-    function handle_toolbar(&$event, $param) { 
-        $event->data[] = array ( 
-            'type' => 'picker', 
-            'title' => $this->getLang('picker'), 
-            'icon' => '../../plugins/fontcolor/images/toolbar/picker.png', 
-            'list' => array( 
-                array( 
-                    'type'   => 'format', 
-                    'title'  => $this->getLang('black'), 
-                    'icon'   => '../../plugins/fontcolor/images/toolbar/black.png', 
-                    'open'   => '<fc #000000>', 
-                    'close'  => '</fc>', 
-                ), 
-                array( 
-                    'type'   => 'format', 
-                    'title'  => $this->getLang('maroon'), 
-                    'icon'   => '../../plugins/fontcolor/images/toolbar/maroon.png', 
-                    'open'   => '<fc #800000>', 
-                    'close'  => '</fc>', 
-                ), 
-                array( 
-                    'type'   => 'format', 
-                    'title'  => $this->getLang('green'), 
-                    'icon'   => '../../plugins/fontcolor/images/toolbar/green.png', 
-                    'open'   => '<fc #008000>', 
-                    'close'  => '</fc>', 
-                ), 
-                array( 
-                    'type'   => 'format', 
-                    'title'  => $this->getLang('olive'), 
-                    'icon'   => '../../plugins/fontcolor/images/toolbar/olive.png', 
-                    'open'   => '<fc #808000>', 
-                    'close'  => '</fc>', 
-                ), 
-                array( 
-                    'type'   => 'format', 
-                    'title'  => $this->getLang('navy'), 
-                    'icon'   => '../../plugins/fontcolor/images/toolbar/navy.png', 
-                    'open'   => '<fc #000080>', 
-                    'close'  => '</fc>', 
-                ), 
-                array( 
-                    'type'   => 'format', 
-                    'title'  => $this->getLang('purple'), 
-                    'icon'   => '../../plugins/fontcolor/images/toolbar/purple.png', 
-                    'open'   => '<fc #800080>', 
-                    'close'  => '</fc>', 
-                ), 
-                array( 
-                    'type'   => 'format', 
-                    'title'  => $this->getLang('teal'), 
-                    'icon'   => '../../plugins/fontcolor/images/toolbar/teal.png', 
-                    'open'   => '<fc #008080>', 
-                    'close'  => '</fc>', 
-                ), 
-                array( 
-                    'type'   => 'format', 
-                    'title'  => $this->getLang('silver'), 
-                    'icon'   => '../../plugins/fontcolor/images/toolbar/silver.png', 
-                    'open'   => '<fc #C0C0C0>', 
-                    'close'  => '</fc>', 
-                ), 
-                array( 
-                    'type'   => 'format', 
-                    'title'  => $this->getLang('gray'), 
-                    'icon'   => '../../plugins/fontcolor/images/toolbar/gray.png', 
-                    'open'   => '<fc #808080>', 
-                    'close'  => '</fc>', 
-                ), 
-                array( 
-                    'type'   => 'format', 
-                    'title'  => $this->getLang('red'), 
-                    'icon'   => '../../plugins/fontcolor/images/toolbar/red.png', 
-                    'open'   => '<fc #FF0000>', 
-                    'close'  => '</fc>', 
-                ), 
-                array( 
-                    'type'   => 'format', 
-                    'title'  => $this->getLang('lime'), 
-                    'icon'   => '../../plugins/fontcolor/images/toolbar/lime.png', 
-                    'open'   => '<fc #00FF00>', 
-                    'close'  => '</fc>', 
-                ), 
-                array( 
-                    'type'   => 'format', 
-                    'title'  => $this->getLang('yellow'), 
-                    'icon'   => '../../plugins/fontcolor/images/toolbar/yellow.png', 
-                    'open'   => '<fc #FFFF00>', 
-                    'close'  => '</fc>', 
-                ), 
-                array( 
-                    'type'   => 'format', 
-                    'title'  => $this->getLang('blue'), 
-                    'icon'   => '../../plugins/fontcolor/images/toolbar/blue.png', 
-                    'open'   => '<fc #0000FF>', 
-                    'close'  => '</fc>', 
-                ), 
-                array( 
-                    'type'   => 'format', 
-                    'title'  => $this->getLang('fuchsia'), 
-                    'icon'   => '../../plugins/fontcolor/images/toolbar/fuchsia.png', 
-                    'open'   => '<fc #FF00FF>', 
-                    'close'  => '</fc>', 
-                ), 
-                array( 
-                    'type'   => 'format', 
-                    'title'  => $this->getLang('aqua'), 
-                    'icon'   => '../../plugins/fontcolor/images/toolbar/aqua.png', 
-                    'open'   => '<fc #00FFFF>', 
-                    'close'  => '</fc>', 
-                ), 
-                array( 
-                    'type'   => 'format', 
-                    'title'  => $this->getLang('white'), 
-                    'icon'   => '../../plugins/fontcolor/images/toolbar/white.png', 
-                    'open'   => '<fc #FFFFFF>', 
-                    'close'  => '</fc>', 
-                ), 
-            ) 
-        ); 
-    } 
-} 
-</code> 
- 
-===== Question ===== 
- 
-Though the plugin works fine within the text, it does not show in the toolbar any more. 
- 
-This happens in Release 2009-12-25c "Lemming" of DokuWiki. 
- 
-Any ideas? 
- 
- 
-------------------- 
-Have the same problems. 09-03-2010 
- 
------------------- 
- 
-Thanks for the hint. I will look. 
- 
------------------- 
- 
-I have repaired it. Now it works. 
- 
-Please update via the Plugin Manager. 
- 
------------------- 
-I just downloaded it and install it manually but the toolbar button ain't showing though the function works 
- 
------------------- 
- 
-Try cleaning your browser's cache. Worked for me. (03/24/2010) 
- 
------------------- 
- 
-At first it didn't work for me either, then I changed my template to default and back, et voilà (03/29/2010) 
- 
------------------- 
- 
-If <fc #FFFFFF > text </fc> is marked to change to #FF00FF it would be nice to get <fc #FF00FF > text </fc> instead of <fc #FF00FF ><fc #FFFFFF > text </fc></fc> or only if <fc #FFFFFF > is makrked it should be changed to <fc #FF00FF >. Thanks! 
- 
------------------- 
-Why one cannot nest FC tags? <fc #ff0000>This is a red message, <fc #ff0000>but this is a blue one.</fc> And now it's red again.</fc> Do you plan to support this kind of nesting in the very close future? Thanks 
- 
------------------- 
- 
-Hi, I installed the plugin manually, just by cp'ing the directory over to /lib/plugins/fontcolor.  The function works, but it's not in the toolbar.  I saw other people mention that but clearing cache did not work for me.  I'm not sure what the one person meant by changing their template, I'm pretty new to this dokuwiki. 
- 
-Any ideas? 
- 
------------------- 
- 
-<del>I got the same Problem, the Toolbar does not apper in Anteater Version</del> Problem solved after one Day, may be a Caching Problem 
- 
- 
-------------------- 
-2011-06-10  Are there any way to get the ODT export colorized too ? 
- 
-Thanks. 
- 
- 
-------------------- 
-2011-08-20  Would be cool having it working inside a title, like 
-<file>   
-====foo<fc red>bar</fc>==== 
-</file>   
- 
-------------------- 
-2011-08-30 
-Thank you for this great plugin !!! As mention more up, will be cool to make it work with titles (i think will not be easy to manage as the titles don't support anything, **bold**, __underline__, <del>supress</del>, //italic// ... Thanks anyway, it's very usefull :) 
- 
-------------------- 
-2012-02-28 
-Here's a little snippet to provide odt export of colored text - copied from the [[plugin:color]] plugin. I hope somebody can make use of it. Copy above the ''return false;'' line in function ''render()'' in file ''syntax.php''.\\ 
-Klaus 
- 
-Put this code into ''lib/plugins/fontcolor/syntax.php'':) 
- 
-<code php> 
-if($mode == 'odt'){ 
-  list($state, $color) = $data; 
-  switch ($state) { 
-    case DOKU_LEXER_ENTER : 
-      $style_index = $color; 
-      if(empty($this->odt_styles[$style_index])) { 
-        $stylename = "ColorizedText".count($this->odt_styles); 
-        $this->odt_styles[$style_index] = $stylename; 
-        $color = $color?'fo:color="'.$color.'" ':''; 
-        $renderer->autostyles[$stylename] = ' 
-        <style:style style:name="'.$stylename.'" style:family="text"> 
-            <style:text-properties '.$color.'/> 
-        </style:style>'; 
-      } 
-      $renderer->doc .= '<text:span text:style-name="'.$this->odt_styles[$style_index].'">'; 
-      break; 
-  
-    case DOKU_LEXER_UNMATCHED :   
-    $renderer->doc .= $renderer->_xmlEntities($color);  
-    break; 
-    case DOKU_LEXER_EXIT :        
-    $renderer->doc .= "</text:span>";  
-    break; 
-  } 
-  return true; 
-} 
-</code> 
- 
-------------------- 
-Hi there, I have a problem with the toolbar-button as well, i can't see it. but there is a little button-like thing in the toolbar, but without a funktion. Is it maybe an update-problem? 
-by the way, is the description as it is written here correct? 
-------------------- 
-2013-02-14  not working like that, help please. 
-<file>   
-====foo<fc red>bar</fc>==== 
-</file>  
-------------------- 
-2014-02-14 Zip not complete\\ 
-After install apache logs errors:\\ 
-File does not exist: /var/www/wiki/lib/plugins/fontcolor/images/toolbar/green.png,\\ 
-File does not exist: /var/www/wiki/lib/plugins/fontcolor/images/toolbar/olive.png,\\ 
-File does not exist: /var/www/wiki/lib/plugins/fontcolor/images/toolbar/navy.png, \\ 
-File does not exist: /var/www/wiki/lib/plugins/fontcolor/images/toolbar/purple.png,\\ 
-\\ 
-and so on.\\ 
-\\ 
-The folder toolebar is not included in the install zip file.\\ 
-\\ 
-Please check and Fix it!\\ 
-------------------- 
-===== Bugs ===== 
- 
-  * Click on icon make automatic saving comment in Discussion plugin without adding fontcolor syntax 
-  * Chrome 31: //Uncaught ReferenceError: jsEscape is not defined// 
-    * screws functionality of other edit-time plugins like [[plugin:svgedit]] 
- 
-<code> 
-Uncaught ReferenceError: jsEscape is not defined 
-plugin_fontcolor_make_color_button 
-plugin_fontcolor_toolbar_picker 
-c 
-p.fireWith 
-b.extend.ready 
-H 
-</code> 
plugin/fontcolor.1393242600.txt.gz · Last modified: 2014-02-24 12:50 by 122.212.225.106

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki