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 revisionBoth sides next revision
plugin:webcomics [2018-05-26 19:26] Aleksandrplugin:webcomics [2019-02-16 11:45] – Webcomics: adopted plugin. Now hosted on github. LarsDW223
Line 3: Line 3:
 ---- 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       : syntax type       : syntax
-lastupdate : 2009-07-09+lastupdate : 2019-02-16
 compatible :  compatible : 
 depends    :  depends    : 
 conflicts  conflicts 
 similar    : garfield, dil, xkcd similar    : garfield, dil, xkcd
-tags       : comic, !obsolete+tags       : comic,
  
-downloadurl: https://trello-attachments.s3.amazonaws.com/5af4815352fa15728c62aaae/5b09972221f98046079ab6b0/988a8e6161be9123ce53eed3fb31c809/webcomics.zip +downloadurl: https://github.com/LarsGit223/dokuwiki-plugin-webcomics/archive/2019-02-16.zip 
-bugtracker :  +bugtracker : https://github.com/LarsGit223/dokuwiki-plugin-webcomics/issues 
-sourcerepo : +sourcerepo : https://github.com/LarsGit223/dokuwiki-plugin-webcomics
 donationurl:  donationurl: 
  
Line 21: Line 21:
 ---- ----
  
-===== Purpose =====+===== Description =====
  
-I love comics, and so does all other people on my private Wiki. I like to have new comic every day.+This plugin lets the user add a comic to a page taken from an RSS feed. The list of supported/known RSS feeds is configurable.
  
-The plugin includes the same functionality as the [[:plugin:dil|dilbert-plugin]] **and** the [[:plugin:garfield|garfield-plugin]].+===== History =====
  
-Also the plugin is extended with two new comics. Check the (static) examples below.+The plugin was created by Christoph Lang in 2013.
  
-===== Download=====+===== Installation =====
  
-Copy into **webcomics/syntax.php** in ''/lib'' folder.+Search and install the plugin using the Extension ManagerRefer to Plugins on how to install plugins manually.
  
-<code php syntax.php> +===== Configuration =====
-<?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+The configuration contains a list of comic names assigned to RSS feeds. The format per entry is  
 +<code> 
 +comicname="feeduri"; 
 +</code> 
 +A linebreak after a semicolon is allowed.
  
-// must be run within Dokuwiki +For example see the default configuration below: 
-if (! defined('DOKU_INC')) die();+<code> 
 +xkcd="https://xkcd.com/rss.xml"; 
 +dilbert="https://www.comicsrss.com/rss/dilbert.rss"; 
 +peanuts="https://www.comicsrss.com/rss/peanuts.rss"; 
 +garfield="https://www.comicsrss.com/rss/garfield.rss"; 
 +</code>
  
-if (! defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/'); +===== Syntax =====
-require_once (DOKU_PLUGIN . 'syntax.php');+
  
-/** +The syntax is ''<comic="comic-name">''.
- * 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 () +====== Examples ======
-+
- 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) +<code
-+<comic="garfield">
- require_once (DOKU_INC . 'inc/HTTPClient.php'); +
- switch ($type) +
-+
- 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); +
-  +
- $a = 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) +
-+
- $this->Lexer->addSpecialPattern('\[XKCD\]', $mode, 'plugin_webcomics'); +
- $this->Lexer->addSpecialPattern('\[GARFIELD\]', $mode,  +
- 'plugin_webcomics'); +
- $this->Lexer->addSpecialPattern('\[DILBERT\]', $mode,  +
- 'plugin_webcomics'); +
- $this->Lexer->addSpecialPattern('\[SHACKLES\]', $mode,  +
- 'plugin_webcomics'); +
- $this->Lexer->addSpecialPattern('\[CYANIDE\]', $mode,  +
- 'plugin_webcomics'); +
-+
- +
- function getType () +
-+
- return 'substition'; +
-+
- +
- function getSort () +
-+
- return 667; +
-+
- +
- function handle ($match, $state, $pos, &$handler) +
-+
- $match str_replace(array("[", "]"), array("", ""), $match); +
- return array($match, $state, $pos); +
-+
- +
- function render ($mode, &$renderer, $data) +
-+
-  +
- if ($mode == 'xhtml'+
-+
- $renderer->doc .= $this->_listhd($data[0]); +
- return true; +
-+
- return false; +
-+
-}+
 </code> </code>
- 
-===== Example ===== 
- 
-==== [SHACKLES] ==== 
-{{http://www.virtualshackles.com/img/dantes_inferno_fraud.jpg|}} 
- 
-==== [XKCD] ==== 
- 
-{{http://imgs.xkcd.com/comics/revolutionary.png|}} 
- 
-==== [GARFIELD] ==== 
- 
-{{http://images.ucomics.com/comics/ga/2009/ga091215.gif|}} 
- 
-==== [DILBERT] ==== 
- 
-{{http://dilbert.com/dyn/str_strip/000000000/00000000/0000000/000000/70000/6000/700/76732/76732.strip.print.gif|}} 
  
plugin/webcomics.txt · Last modified: 2023-10-31 00:34 by Klap-in

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