DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:webcomics

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:webcomics [2013-09-17 15:37] – Updated the plugin to work properly again 193.23.251.59plugin:webcomics [2023-10-31 00:34] (current) Klap-in
Line 1: Line 1:
-====== webcomics plugin ======+====== webcomics Plugin ======
  
 ---- plugin ---- ---- plugin ----
 description: It displays various Webcomics. Based on Dilbert Plugin. description: It displays various Webcomics. Based on Dilbert Plugin.
-author     : Christoph Lang +author     : LarsDW223 
-email      : calbity@gmx.de +email      : - 
-type       :  +type       : syntax 
-lastupdate : 2009-07-09 +lastupdate : 2019-02-16 
-compatible : +compatible : Greebo, Hogfather
 depends    :  depends    : 
 conflicts  conflicts 
 similar    : garfield, dil, xkcd similar    : garfield, dil, xkcd
-tags       : comic +tags       : comic,
-----+
  
-===== Purpose =====+downloadurl: https://github.com/LarsGit223/dokuwiki-plugin-webcomics/archive/2019-02-16.zip 
 +bugtracker : https://github.com/LarsGit223/dokuwiki-plugin-webcomics/issues 
 +sourcerepo : https://github.com/LarsGit223/dokuwiki-plugin-webcomics 
 +donationurl: 
  
-I love comics, and so does all other people on my private Wiki. I like to have a new comic every day.+screenshot_img:  
 +----
  
-The plugin includes the same functionality as the [[:plugin:dil|dilbert-plugin]] **and** the [[:plugin:garfield|garfield-plugin]]. +===== Description =====
-Also the plugin is extended with two new comics. Check the (static) examples below. +
-===== Download=====+
  
-Copy into **webcomics/syntax.php** in lib folder. +This plugin lets the user add a comic to a page taken from an RSS feedThe list of supported/known RSS feeds is configurable.
-<code php> +
-<?php +
-/** +
- * Webcomics Plugin +
- * +
- * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) +
- * @author Christoph Lang <calbity@gmx.de> +
- */+
  
-// based on http://wiki.splitbrain.org/plugin:tutorial+===== History =====
  
-// must be run within Dokuwiki +The plugin was created by Christoph Lang in 2013.
-if (! defined('DOKU_INC')) die();+
  
-if (! defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/'); +===== Installation =====
-require_once (DOKU_PLUGIN . 'syntax.php');+
  
-/** +Search and install the plugin using the Extension Manager. Refer to Plugins on how to install plugins manually.
- * All DokuWiki plugins to extend the parser/rendering mechanism +
- * need to inherit from this class +
- */ +
-class syntax_plugin_webcomics extends DokuWiki_Syntax_Plugin +
-{+
  
- function getInfo () +===== Configuration =====
-+
- return array( +
- 'author' => 'Christoph Lang', +
- 'email' => 'calbity@gmx.de',  +
- 'date' => '2013-09-17', +
- 'name' => 'Webcomics Plugin',  +
- 'desc' => 'It displays various Webcomics. Based on Dilbert Plugin.',  +
- 'url' => 'http://www.christophs-blog.de/dokuwiki-plugins/'); +
- }+
  
- private function _listhd ($type) +The configuration contains a list of comic names assigned to RSS feeds. The format per entry is  
-+<code> 
- require_once (DOKU_INC . 'inc/HTTPClient.php'); +comicname="feeduri"; 
- switch ($type) +</code
-+A linebreak after semicolon is allowed.
- case "XKCD": +
- $url = 'http://xkcd.com/rss.xml'; +
- $pre = 'http://imgs.xkcd.com/comics/'; +
- $post = '.png'; +
- break; +
- case "GARFIELD": +
- $url = 'http://feeds.hafcom.nl/garfield.xml'; +
- $pre = 'http://images.ucomics.com/comics/'; +
- $post '.gif'; +
- break; +
- case "DILBERT"+
- $url = 'http://pipes.yahoo.com/pipes/pipe.run?_id=1fdc1d7a66bb004a2d9ebfedfb3808e2&_render=rss'+
- $pre = 'http://www.dilbert.com/dyn/str_strip/'; +
- $post = '.gif'; +
- break; +
- case "CYANIDE": +
- $url = 'http://pipes.yahoo.com/pipes/pipe.run?_id=9b91d1900e14d1caff163aa6fa1b24bd&_render=rss'; +
- $pre = 'http://www.explosm.net/db/'; +
- $post = '.png'; +
- break; +
- case "SHACKLES": +
- $url = 'http://feeds2.feedburner.com/virtualshackles'; +
- $pre = 'http://www.virtualshackles.com/img/'; +
- $post = '.jpg'; +
- break; +
- default: +
- return $type . " will be supported soon!"; +
-+
-  +
- $ch = new DokuHTTPClient(); +
- $piece = $ch->get($url); +
-  +
- $xml = simplexml_load_string($piece); +
-  +
- $= explode($pre, (string) $xml->channel->item->description); +
- $b = explode($post, $a[1]); +
-  +
- $feed_contents .= '<a href="' . $url . '" alt="">' . '<img src="' . $pre . +
- $b[0] . $post . '" alt=""/></a>' . "\n"; +
-  +
- return $feed_contents; +
- }+
  
- function connectTo ($mode) +For example see the default configuration below: 
- { +<code> 
- $this->Lexer->addSpecialPattern('\[XKCD\]', $mode, 'plugin_webcomics')+xkcd="https://xkcd.com/rss.xml"
- $this->Lexer->addSpecialPattern('\[GARFIELD\]', $mode,  +dilbert="https://www.comicsrss.com/rss/dilbert.rss"
- 'plugin_webcomics')+peanuts="https://www.comicsrss.com/rss/peanuts.rss"
- $this->Lexer->addSpecialPattern('\[DILBERT\]', $mode,  +garfield="https://www.comicsrss.com/rss/garfield.rss"
- 'plugin_webcomics')+</code>
- $this->Lexer->addSpecialPattern('\[SHACKLES\]', $mode,  +
- 'plugin_webcomics')+
- $this->Lexer->addSpecialPattern('\[CYANIDE\]', $mode,  +
- 'plugin_webcomics'); +
- }+
  
- function getType () +===== Syntax =====
-+
- return 'substition'; +
- }+
  
- function getSort () +The syntax is ''<comic="comic-name">''.
-+
- return 667; +
- }+
  
- function handle ($match, $state, $pos, &$handler) +===== Examples =====
-+
- $match str_replace(array("[", "]"), array("", ""), $match); +
- return array($match, $state, $pos); +
- }+
  
- function render ($mode, &$renderer, $data) +<code> 
- +<comic="garfield">
-  +
- if ($mode == 'xhtml'+
-+
- $renderer->doc .= $this->_listhd($data[0]); +
- return true; +
-+
- return false; +
-+
-}+
 </code> </code>
- 
-===== Example ===== 
-^ Exampe Iamge ^ Syntax ^ 
-| {{http://www.virtualshackles.com/img/dantes_inferno_fraud.jpg|}} | [SHACKLES] | 
-| {{http://imgs.xkcd.com/comics/revolutionary.png|}} | [XKCD] | 
-| {{http://images.ucomics.com/comics/ga/2009/ga091215.gif|}} | [GARFIELD] | 
-| {{http://dilbert.com/dyn/str_strip/000000000/00000000/0000000/000000/70000/6000/700/76732/76732.strip.print.gif|}} | [DILBERT] | 
- 
- 
  
plugin/webcomics.1379425067.txt.gz · Last modified: 2013-09-17 15:37 by 193.23.251.59

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