Delicious Extension
From ThePlaz.com
I made a delicious extension for my MediaWiki site. The extension lets you insert all of the stories with a given tag into the wiki. Note, I made the extension for my purposes; not general use. This means the extension has 2 downsides: right now it is hard coded to my username and the you have to edit a CSS file and add an image somewhere. These things can be easily modified by someone in the future. (If someone does modify the code, I would be glad to host/link to your modifications). Also, when you manually add the css to MediaWiki:Common.css you do not impact load times as much as if the CSS would be a separate file that the script calls.
The extension uses thumbnails from http://thumbshots.com. I am using the free server, so it on;y shows the homepage of the site. It's not very useful, but I think it adds some color to the list.
This extension is released under the Creative Commons BY license.
Contents |
Installation
- Save the Extension code as
/extensions/Delicious.php
- Save the Delicious logo to
/extensions/delicious.20.gif
- Copy the CSS code to MediaWiki:Common.css
- Link to the Delicious Code in LocalSettings.php:
include("/extensions/Delicious.php");
Extension Code
Invalid language.
You need to specify a language like this: <source lang="html4strict">...</source>
Supported languages for syntax highlighting:
4cs, 6502acme, 6502kickass, 6502tasm, 68000devpac, abap, actionscript, actionscript3, ada, algol68, apache, applescript, apt_sources, arm, asm, asp, asymptote, autoconf, autohotkey, autoit, avisynth, awk, bascomavr, bash, basic4gl, bf, bibtex, blitzbasic, bnf, boo, c, c_loadrunner, c_mac, caddcl, cadlisp, cfdg, cfm, chaiscript, cil, clojure, cmake, cobol, coffeescript, cpp, cpp-qt, csharp, css, cuesheet, d, dcl, dcpu16, dcs, delphi, diff, div, dos, dot, e, ecmascript, eiffel, email, epc, erlang, euphoria, f1, falcon, fo, fortran, freebasic, freeswitch, fsharp, gambas, gdb, genero, genie, gettext, glsl, gml, gnuplot, go, groovy, gwbasic, haskell, haxe, hicest, hq9plus, html4strict, html5, icon, idl, ini, inno, intercal, io, j, java, java5, javascript, jquery, kixtart, klonec, klonecpp, latex, lb, ldif, lisp, llvm, locobasic, logtalk, lolcode, lotusformulas, lotusscript, lscript, lsl2, lua, m68k, magiksf, make, mapbasic, matlab, mirc, mmix, modula2, modula3, mpasm, mxml, mysql, nagios, netrexx, newlisp, nsis, oberon2, objc, objeck, ocaml, ocaml-brief, octave, oobas, oorexx, oracle11, oracle8, oxygene, oz, parasail, parigp, pascal, pcre, per, perl, perl6, pf, php, php-brief, pic16, pike, pixelbender, pli, plsql, postgresql, povray, powerbuilder, powershell, proftpd, progress, prolog, properties, providex, purebasic, pycon, pys60, python, q, qbasic, rails, rebol, reg, rexx, robots, rpmspec, rsplus, ruby, sas, scala, scheme, scilab, sdlbasic, smalltalk, smarty, spark, sparql, sql, stonescript, systemverilog, tcl, teraterm, text, thinbasic, tsql, typoscript, unicon, upc, urbi, uscript, vala, vb, vbnet, vedit, verilog, vhdl, vim, visualfoxpro, visualprolog, whitespace, whois, winbatch, xbasic, xml, xorg_conf, xpp, yaml, z80, zxbasic
<?php # Delicious MediaWiki extension v.1 # Michael Plasmeier (http://theplaz.com) 2010.07 # $wgExtensionFunctions[] = 'wfDelicious'; $wgExtensionCredits['parserhook'][] = array( 'name' => 'Delicious Reader', 'description' => 'Displays Delicious sets.', 'author' => 'Michael Plasmeier (ThePlaz)', 'url' => 'http://theplaz.com/' ); function wfDelicious() { global $wgParser; $wgParser->setHook('delicious', 'renderDeliciousTag'); } function renderDeliciousTag($tag){ $feed_xml = getURL('http://feeds.delicious.com/v2/rss/theplaz/'.$tag); $feed = simplexml_load_string($feed_xml); $output = ''; $output .= '<div id="delicious">'; $output .= '<h3><a href="http://delicious.com"><img src="http://wiki.theplaz.com/w/extensions/delicious.20.gif" /><strong style="color:#3274D1">Delicious</strong></a> / <a href="http://delicious.com/theplaz">theplaz</a> / <a href="http://delicious.com/theplaz/'.$tag.'/">'.$tag.'</a></h3>'; foreach ($feed->channel->item as $item) { /*["title"]=> string(62) "Design // Amtrak Subway Map - Cameron Booth | Graphic Designer" ["pubDate"]=> string(31) "Wed, 21 Jul 2010 20:36:56 +0000" ["guid"]=> string(65) "http://delicious.com/url/87905d02fb6498d8852245d398a3e5bc#theplaz" ["link"]=> string(36) "http://www.cambooth.net/archives/246" ["comments"]=> string(57) "http://delicious.com/url/87905d02fb6498d8852245d398a3e5bc" ["source"]=> string(19) "theplaz's bookmarks" ["description"]=> string(18) "A really nice job!" ["category"]=> array(2) { [0]=> string(6) "design" [1]=> string(7) "transit" } } */ $output .= '<div class="deliciousitem"> <span class="date">'.date("n/j", strtotime($item->pubDate)).'</span> <img src="http://open.thumbshots.org/image.pxf?url='.$item->link.'" /> <div class="info"> <a href="'.$item->link.'" class="title">'.$item->title.'</a> <div class="description">'.$item->description.'</div> <a href="'.$item->link.'" class="url">'.$item->link.'</a> <div class="othertags">'; foreach ($item->category as $category) { $output .= '<a href="http://delicious.com/theplaz/'.$tag.'/">'.$category.'</a> | '; } $output .= '</div></div></div>'; } $output .= '</div>'; return $output; } function getURL($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $http_result = curl_exec($ch); $error = curl_error($ch); $http_code = curl_getinfo($ch ,CURLINFO_HTTP_CODE); //var_dump(curl_getinfo($ch)); curl_close($ch); //should really throw an exception here if ($error) { print "<br /><br />CURL Error: $error"; return FALSE; } return $http_result; } ?>
CSS
Invalid language.
You need to specify a language like this: <source lang="html4strict">...</source>
Supported languages for syntax highlighting:
4cs, 6502acme, 6502kickass, 6502tasm, 68000devpac, abap, actionscript, actionscript3, ada, algol68, apache, applescript, apt_sources, arm, asm, asp, asymptote, autoconf, autohotkey, autoit, avisynth, awk, bascomavr, bash, basic4gl, bf, bibtex, blitzbasic, bnf, boo, c, c_loadrunner, c_mac, caddcl, cadlisp, cfdg, cfm, chaiscript, cil, clojure, cmake, cobol, coffeescript, cpp, cpp-qt, csharp, css, cuesheet, d, dcl, dcpu16, dcs, delphi, diff, div, dos, dot, e, ecmascript, eiffel, email, epc, erlang, euphoria, f1, falcon, fo, fortran, freebasic, freeswitch, fsharp, gambas, gdb, genero, genie, gettext, glsl, gml, gnuplot, go, groovy, gwbasic, haskell, haxe, hicest, hq9plus, html4strict, html5, icon, idl, ini, inno, intercal, io, j, java, java5, javascript, jquery, kixtart, klonec, klonecpp, latex, lb, ldif, lisp, llvm, locobasic, logtalk, lolcode, lotusformulas, lotusscript, lscript, lsl2, lua, m68k, magiksf, make, mapbasic, matlab, mirc, mmix, modula2, modula3, mpasm, mxml, mysql, nagios, netrexx, newlisp, nsis, oberon2, objc, objeck, ocaml, ocaml-brief, octave, oobas, oorexx, oracle11, oracle8, oxygene, oz, parasail, parigp, pascal, pcre, per, perl, perl6, pf, php, php-brief, pic16, pike, pixelbender, pli, plsql, postgresql, povray, powerbuilder, powershell, proftpd, progress, prolog, properties, providex, purebasic, pycon, pys60, python, q, qbasic, rails, rebol, reg, rexx, robots, rpmspec, rsplus, ruby, sas, scala, scheme, scilab, sdlbasic, smalltalk, smarty, spark, sparql, sql, stonescript, systemverilog, tcl, teraterm, text, thinbasic, tsql, typoscript, unicon, upc, urbi, uscript, vala, vb, vbnet, vedit, verilog, vhdl, vim, visualfoxpro, visualprolog, whitespace, whois, winbatch, xbasic, xml, xorg_conf, xpp, yaml, z80, zxbasic
#delicious .date{font-size:smaller;color:gray;position:relative;float:left;} #delicious img{padding-right:5px;padding-left:5px;float:left;} #delicious .deliciousitem{padding-top:10px;clear:both;} #delicious .info{padding-left:150px;} #delicious .title{font-weight:700;} #delicious .description{background:url("http://friendfeed.com/static/images/comment-lighter.png?v=2") no-repeat scroll 0 5px transparent;padding-left:18px;}