====== DokuWiki Plugin : del.icio.us ====== ---- plugin ---- description: Displays a list of del.icio.us links author : Konstantin Baierer email : unixprog@gmail.com type : syntax lastupdate : 2008-12-31 compatible : 2008-05-05 depends : conflicts : similar : tags : links, bookmarks, feed, tags, experimental ---- [[..:experimental]] ^ Updated ^ 2008-12-31 ^ ^ Updated ^ 2007-02-22 ^ ===== Description ===== Using this plugin, you can display a list of your [[http://del.icio.us|del.icio.us]] bookmarks inside a DokuWiki page. It makes use of [[http://del.icio.us/help/api/|del.icio.us' API]] [[http://del.icio.us/help/json/posts|del.icio.us' JSON feed]] and fetches all bookmarks of your account for tags given. You can even combine tags using boolean operators. ===== Syntax ===== {{delicious>[[a|o|n]?]TAG1 [TAG2 TAG3]}} * a, o, n are optional: * a = AND: all bookmarks tagged with each tag * o = OR: all bookmarks tagged with any of the tags * n = NOT: all bookmarks tagged with TAG1, but not TAG2, TAG3 etc. * if you omit a, o or n, **a** will be presumed * if you use a, o or n, don't forget the questionmark! * You can use as many tags as you want, delimited by a whitespace (' ') ==== Examples ==== To make it easier to get into the usage of this plugin, I registered a demo account at del.icio.us: U/P are ''dokuwiki''. It is set as the default account when you install the plugin. After [[#installation]], try these: === one tag === {{delicious>dokuwiki}} which is the same as {{delicious>a?dokuwiki}} or {{delicious>o?dokuwiki}} or {{delicious>n?dokuwiki}} The result should be this:\\ {{http://kokstitan.ath.cx/delicious_dokuwiki.png}} === AND, multiple tags === Now let's search all posts that are tagged 'dokuwiki' and 'reference': {{delicious>dokuwiki reference}} which is the same as {{delicious>a?dokuwiki reference}} {{http://kokstitan.ath.cx/delicious_dokuwiki_reference.png}} === OR, multiple tags === We're searching for all bookmarks tagged either 'web2.0' or 'del.icio.us' or both 'web2.0' and 'del.icio.us': {{delicious>o?web2.0 del.icio.us}} {{http://kokstitan.ath.cx/delicious_web2.0_del.icio.us.png}} === NOT, multiple tags === Now we want to list all bookmarks tagged 'web2.0' but not tagged 'dokuwiki': {{delicious>n?web2.0 del.icio.us}} {{http://kokstitan.ath.cx/delicious_rss_dokuwiki.png}} ---- I think you see the point. You can use as many tags as you want, but be careful: For **OR** and **NOT** queries, a set of results is pulled from del.icio.us for every tag and then merged or reduced respectively. That might be a performance and/or bandwidth issue, though most probably not. ===== Installation ===== To get the plugin to work, you have to do two essential things: - Install the plugin using the plugin manager or by manually copying it to ''/lib/plugins/'': [[http://www2.informatik.hu-berlin.de/~baierer/src/delicious.zip|delicious2008-12-31.zip]] - If you installed the previous version via plugin manager, you should be able to simply update it from the interface. ===== Configuration ===== ^ ^what it means ^ default ^ ^Username | Your del.icio.us username | dokuwiki | ^Update Interval | how long are local files valid? | 60*60*3 | ^Interwiki Icon | To add delicious Interwiki link icon | 0 | ^Links description | What to show after the links (**desc**ription, **tags** or **none**) | tags | ^Items to show | Maximum of item to show in a listing (between 1 and 100) | 20 | ==== delicious link images ==== To make the plugin render lists bulleted with little del.icio.us logos, add this line to your ''/conf/interwiki.conf'': delicious http://del.icio.us/tag/ and move/copy the file ''/lib/plugins/delicious/images/delicious.gif'' to ''/lib/images/interwiki/'' If you set up ''interwiki.conf'', put the icon in place and set ''Interwiki Icon'' to 1, then a post might look like this:\\ {{http://kokstitan.ath.cx/delicious_wikilink_example.png}}\\ Neat, huh? :-) It has the additional benefit, that you can now link to sets of bookmarks on del.icio.us with interwiki syntax: %%[[delicious>dokuwiki+del.icio.us|Bookmarks tagged **dokuwiki** and **del.icio.us** on del.icio.us]]%%. **Note:** This is not necessary to use the plugin. It's just stylistic sugar. ==== Description instead of tags ==== If you change ''Links description'' to desc you get something like this:\\ {{http://kokstitan.ath.cx/delicious_description.png}} ===== Known Bugs ===== * Amount of bookmarks is limited to 100 per request, i.e. per tag. * Characters in tags that can't conveniently be url-encoded (e.g. '?' and '&') will break the matching pattern. ===== To Do ===== * understand and use DokuWiki's cacheing function (done, mostly :-) ) * add switch for recent/all bookmarks (who needs this?) * save the combined xml-responses to disk (like ''rss OR dokuwiki.txt'') (obsolete) * improve match function (improved) * implement the cURL patch by jordan * avoid ''file_get_contents'' as mentioned in the comments * improve the error messages even more ===== Changelog ===== ==== 2008-12-31 ==== * reworked to fit del.icio.us' new JSON format * added option to set limit on amount of links per listing * made the error messages more specific * should be xhtml-compliant now ==== 2007-02-22 ==== * rewrite using del.icio.us JSON interface * should be PHP4-compatible now * uses DokuWiki's cache validity options properly (thanks to Chris Smith!) ==== 2006-12-12 ==== * Initial release ===== Thanks ===== to all those who commented or wrote me mails, reported bugs and everything :-) ===== Source ===== ==== syntax.php ==== echo( "Please download the archive, the source contains < code > tags which messes up DokuWiki's parser apparently. Also, it's pretty long and relies on configuration files. Thanks." ); ==== style.css ==== I just like those round corners. :-) If you like to keep it simple, just delete the whole style.css. If you habe a dark theme, you might want to change ''url("images/delicious_big_light.png")'' to ''url("images/delicious_big_light.png")'' for a dark version of the background logo. /** * del.icio.us Plugin Style * @author Konstantin Baierer */ ul.delicious { border: 2px solid #666; -moz-border-radius: 20px; padding: 10px; background-image: url("images/delicious_big_light.png"); background-position: 99% 10px; background-repeat:no-repeat; } ul.delicious li { list-style:none; } span.delicious { font-size: 70%; } ===== Comments / Discussion ===== ==== Tips for better implementation ==== Hi, about your questions. * take a look at ''inc/cache.php''. I suspect if you use it and give your pages their own file extension you should be alright. Also have a look at how code highlighted snippets are cached, iirc correctly that code is in ''inc/p_parser_utils.php'' near the bottom. If not you'll find it by tracking through the ''code()'' code in ''inc/parser/xhtml.php''. * you might also want to take a look at how rss feeds are handled. Given that DW caches the xhtml output of the page, you can take advantage of that and let DW handle the caching - along with the rest of the page. iirc, "All" you'll need to do is set the correct metadata parameter for page life. e.g. In your ''render()'' function handle the metadata format ... function render($format, &$renderer, $data) { switch ($format) { case 'xhtml' : /* your code for the xhtml renderer */ break; case 'metadata' : $this->meta['date']['valid']['age'] = empty($this->meta['date']['valid']['age']) ? $this->getConf('diu_update_interval') : min($this->getConf('diu_update_interval'),$this->meta['date']['valid']['age']); break; default : /* unsupported format ... do nothing */ } } And will need to raise a feature request for DW native RSS syntax to do the same ''min()'' check I have done here :-). --- //[[chris@jalakai.co.uk|Christopher Smith]] 2006-12-12 19:54// > Just wanted to tell, I'm at it. Thank you for your help. I included an extra action plugin, that uhh. Well I'm not sure yet, what it actually does or even if it works, but as I said, I'm at it. It gets somewhat complicated to check, if DW is using the cached version for exactly three hours. I tried around touching the pages (''touch -d''), but right now, it does not recache the page if I do so. Also right now, it does not even purge the cached version of the page, when I changed and saved it (besides the ''{{delicious}}''-part. \\ >But the mere fact of using '.xml' instead of '.txt' as file extension reduced the warnings significantly. Well, thanks again for the tips. --- //[[unixprog@gmail.com|konstantin baierer]] 2006-12-19 00:56// >> I didn't think you would need an action plugin. DW's native RSS syntax manages without one :-). For testing I would open up the metadata file and edit it. You can also try using an age of only a minute or so. Using ?do=debug will show the page's metadata too. --- //[[chris@jalakai.co.uk|Christopher Smith]] 2006-12-19 21:25// ==== Parse errors ==== > I tried to install that usefull plugin, but on the pluginpage and on a page where it should run in, there is a parse error with an unexpected { in line 134 in syntax.php, i couldn't figure out the reason, so who knows this problem (and its solution)? --- //[[voisard@gmail.com|Benjamin Wasner]] 2007-01-17 17:40// >> Same problem here. Seems like the plugin is written for PHP5 only, because it makes use of PHP5-specific functions (e.g. "simplexml_load_string") and mechanisms ("try...catch"). It would be great to have a PHP4 version as well... // [[info@jensberke.de|Jens Berke]] 2007-01-19 15:25// >>> Sorry Sorry! :( I'll check the script and see what I can do. simplexml is just so - simple. But of course it is possible to use PHP4-compliant XML-functions. I just don't have the time right now to rewrite it (lot of exams threatening me at University). But I promise to update it as soon as I can. Anyway, thanks for trying it! :) --- //[[unixprog@gmail.com|konstantin baierer]] 2007-01-30 02:38// >> Great plugin idea! One problem I've found however is that I'm getting the following error message: Fatal error: Call to undefined method syntax_plugin_delicious::loadConfig() in /lib/plugins/delicious/syntax.php on line 123 --- //[[sspboyd@boydstudio.ca|Stephen Boyd]] 2007-02-01 00:27// >>> I've rewritten the plugin using del.icio.us' [[http://del.icio.us/help/json/posts|JSON interface]] these last two days. Of course I could also rewrite it using PHP's DOMXML functions (which is PHP4 compatible) and del.icio.us XML interface, but for just getting the bookmarks, that's inconvenient to code and causes a lot of overhead traffic for the xml-tags. Moreover, no user authentication is needed to access the JSON feed, which is cool, because users don't have to store their passwords in cleartext anymore. However, the maximum of bookmarks fetched from del.icio.us using JSON is 100, but I guess, nobody wants to have a longer list of bookmarks in a wiki page anyway. I still do some testing and bug-killing, but it should be done next week. --- //[[unixprog@gmail.com|konstantin baierer]] 2007-02-16 16:02// > OK, done. :) Let me know if it works for PHP4 now. --- //[[unixprog@gmail.com|konstantin baierer]] 2007-02-23 02:24// ==== Doesn't display bookmarks ==== Hi, I've installed the Plugin at [[http://jurtenrunde.de/lieder/doku.php?id=spielplatz:test]] but I can't see any information from delicious. I have god my own account at delicious [[http://del.icio.us/Muckel1986]] but I can't see the tags. I have tested it with the DokuWiki example but I have there the same problem. I have test it with: ===== delicious ===== Ob meine Favoriten von delicious auch angezeigt werden? {{delicious>Muckel1986}} ==== Test mit DokuWiki ==== {{delicious>dokuwiki}} {{delicious>a?dokuwiki}} {{delicious>o?dokuwiki}} {{delicious>n?dokuwiki}} I hope here ist somebody who can help me, please. > Should work again, but probably too late for you :( ==== Plugin download unavailable ==== :!: This file is never available, please get this hosted somewhere :!:\\ And I want it. :)\\ - shawn > sorry. hdd crash. plugin is now available again. --- //[[unixprog@gmail.com|konstantin baierer]] 2007-03-19 01:26// ==== Standalone script exporting del.icio.us links to DokuWiki Syntax ==== Hi, I´ve written a class to get all bookmarks into my DokuWiki. You can export all bookmarks from del.icio.us under ''settings -> Bookmarks: export / backup''. Include both tags and notes. After downloading the class turns that file either into an array or DokuWiki syntax. It creates H3's from tags and puts all bookmarks into an unordered list. It's just a quick and dirty solution but maybe someone'll find it usefull. --- //[[monitormensch@gmail.com|Kai Schaper]] 2007-07-19 09:12// class Delicious_HTML_Parser { private $lines; private $linklist; private $dw_linklist = ''; public function __construct($file) { $this->lines = file($file); $this->parse(); } private function parse() { foreach ($this->lines as $line) { if (substr($line, 0, 4) == '
') { $line = str_replace(array('
', '">'), array('', '', '"'), $line); $parts = explode('"', $line); $url = $parts[1]; $tags = isset($parts[7]) ? $parts[7] : 'untagged'; $description = isset($parts[8]) ? trim($parts[8]) : trim($parts[6]); $link = ''.$description.''; $tag_parts = explode(',', $tags); foreach ($tag_parts as $tag) { $this->linklist[$tag][] = array('url' => $url, 'description' => $description, 'link' => $link); } } } ksort($this->linklist); } public function getLinklist() { return $this->linklist; } public function generateDokuWikiList() { foreach ($this->linklist as $tag => $links) { $num = count($links); // Headline $this->dw_linklist .= "==== $tag ($num) ====\n\n"; foreach ($links as $link) { // List Item with Bookmark $description = str_replace(array('[', ']', '|'), array('(', ')', ','), $link['description']); $this->dw_linklist .= ' *[['.$link['url'].'|'.$description.']]'."\n"; } $this->dw_linklist .= "\n"; } return $this->dw_linklist; } } $file = './delicious-20070719-044044.html'; $parser = new Delicious_HTML_Parser($file); #$linklist = $parser->getLinklist(); #print_r($linklist); $dw_linklist = $parser->generateDokuWikiList(); echo $dw_linklist; >in witch file must I put the class and what have it to write into the DokuWiki page? >>It's not an extension for the del.icio.us Plugin. It's just a simple stand alone script to turn your exported bookmarks into DokuWiki syntax. ==== cURL instead of file_get_contents ==== some hosts don't allow you to use file_get_contents, simplexml_load_string etc from remote hosts due to well deserved security concerns. Here is the hack that my host provided to avoid this using cURL. this is at syntax.php:174, I left he old code there commented out to show where I was editing. //* file_get_contents is commonly disabled $ch = curl_init(); $timeout = 5; // set to zero for no timeout curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $json = curl_exec($ch); curl_close($ch); /*/ $json = file_get_contents($url); //*/ They list a few other ideas here: [[http://wiki.dreamhost.com/CURL_PHP_tutorial|Dreamhost's cURL reference]]. I don't appreciate how cURL buffers you from these issues, but they do it for a living so perhaps they aren't wrong. **UPDATE, workaround:**: If there was any problem with patch, DokuWiki is capable of using delicious rss feed, see [[http://delicious.com/help/feeds|here]]. //[[mail@jakubsafar.cz|jakub]] 2008-08-20 14:37// For example: {{rss>http://feeds.delicious.com/v2/rss/USERNAME/TAG1+TAG2+... NUMBEROFBOOKMARKS}} > I will make that patch an option in the next release. Thanks for the work and good idea about the rss interface! --- //[[uniNxprogO@gSmaPilA.cMom|konstantin baierer]] 2008/12/31 11:36// ==== Password-secured del.icio.us account? ==== > --- //[[danjor@infonie.fr|Jordan]] 2007-11-23 15:56// >Hello, is there a way to make it work with a private delicious ? >Giving the password in the conf file ? >It would be great !! >>I wrote a patch to get private links. But I gave up during my tests. If I want to access private links I must use the [[http://del.icio.us/help/api/|API]]. This API blocks more requests than one every second. >>If anyway someone interested in my patch you can contact me. --- //[[dokuwiki_delicious.5.nougad@spamgourmet.com|nougad]] 2008-07-05 04:13// >>> Yeah, the first version of this plugin used the API and respected the "one query per second" policy, but parsing XML is complicated for the differences in PHP4 and PHP5 and overkill for a simple functionality like the one this plugin offers. --- //[[uniNxprogO@gSmaPilA.cMom|konstantin baierer]] 2008/12/31 11:36// ==== New JSON interface broke plugin ==== //[[mail@jakubsafar.cz|jakubsafar.cz]] 2008-07-28 12:33// Hello, it seems that delicious plugin stopped working sometimes during last week. Maybe there was some change on the delicious side? Or am I alone? > Seems delicious changed a few things about their feeds. This concerns the URL and the JSON format which now includes a "dt"-key noting the date-time the bookmark has been added. Furthermore the "n"-key which denotes the extended description is now always set even when there is now description in which case it's just an empty string (""). Most of all the feed is now UTF-8 encoded (using "\u00.." entities). There doesn't seem to be a trivial solution to decode these so I've used json_encode() which unfortunately means the patch only works with PHP >5.2. You can find it at [[http://vergiss-blackjack.de/delicious.patch]]. I haven't tested it extensively but it seems to work for my bookmarks. --- //[[georgsorst@gmx.de|Georg]] 2008-07-05 04:13// >> Nice patch! As for the ''\u12ef'' unicode strings: I translate them directly into HTML entities, which **is** trivial, though it might not work on all browsers. --- //[[uniNxprogO@gSmaPilA.cMom|konstantin baierer]] 2008/12/31 11:36// === Thank You! === * To [[georgsorst@gmx.de|Georg]] * I applied your patch, and have some instructions on how to update the plugin here: http://notesmine.com/dokuwiki_delicious * I didn't try the RSS feed, I'm using the JSON original method(s) of the plugin. * Please contact me at [[nate@notesmine.com]] if you have any questions or suggestions. Thank you to both Georg and the originator of this plugin. :-) It RULEZ!!!! > Also: Nice Instructions. However, as of 2008-12-31, this isn't necessary anymore (and the patch won't work). Just install the new version and all should be well. --- //[[uniNxprogO@gSmaPilA.cMom|konstantin baierer]] 2008/12/31 11:36// ==== "AND" doesn't work ==== With the patch described above. I submitted a hack below. For example, if I have {{delicious>foo bar}} I don't get anything back. I'm using DokuWiki 2008-05-05 with php version 5.2. (I think). I had to comment out the line that runs urlencode on the tags, because it was messing with the ''+'' that is put between the tags when using something like this: Where you want foo+bar. Here's the patch, just rem-out the ''$tags = urlencode($tag)'' line, and then add a line with ''$tags=$tag;''. I haven't had time to really find out why this is occurring, but I did narrow it down to the urlencode function being called. function getJSON($tag) { // urlencode was causing problem with AND queries to delicious // foo+bar+baz // $tags = urlencode($tag); // to avoid possible encoding problems $tags=$tag; > You don't have to put ''+'' between the tags you want to combine with **AND**. Just use spaces! The plugin implements the boolean set logic internally and your patch will break it. Update to the newest version and everything should work again. --- //[[uniNxprogO@gSmaPilA.cMom|konstantin baierer]] 2008/12/31 11:36// ==== I think this plugin need an update ==== I've tried using it and got syntax errors. I installed the curl patch, the error was gone but I didn't get any results. I tried all the other solutions in this thread but none of them gave a solution :-/ --- //[[mail@dbzer0.com|db0]]// >Yes, you are right, it needs an upgrade, I'll do it ASAP. --- //[[uniNxpOrogSP@gmAailM.com|konstantin baierer]] 2008/12/30 17:44// >>Done. The cURL part will follow in the next release. --- //[[uniNxpOrogSP@gmAailM.com|konstantin baierer]] 2008/12/31 02:48//