<?php if (!defined('PmWiki')) exit(); /* Copyright 2006-2008 Jon Haupt (jhaupt@gmail.com) with additions by Adam Overton (10-2009) This file is delicious.php; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This script enables you to create interaction between PmWiki and delicious.com. To use this script, copy it into the cookbook/ directory and add the following line to config.php (or a per-page/per-group customization file). include_once("$FarmD/cookbook/delicious.php"); The script will generate a linkroll or tagroll. The simplest linkroll can be created by using the markup (:linkroll user=foo:) where foo is the desired delicious username, creating a roll of 10 recent links. Similarly (:tagroll user=foo:) creates a complete tag cloud of user foo. The script can also add a delicious.com tagometer, by using the markup (:deliciousbadge:). The recipe is derived from the delicious.com help pages, specifically: http://delicious.com/help/tagrolls http://delicious.com/help/linkrolls http://delicious.com/help/tagometer The following is a list of arguments for tagrolls and linkrolls: For (:linkroll:) user: delicious.com username (required) number: the number of links you want to display (default: 10) sort: recent or alpha (default: recent) tags: Limit the linkroll by tag(s). Multiple tags use the syntax 'tag+tag' icon: large, small, rss, or none (default: large) title: text to display as a header (default: My Delicious Bookmarks) - due to a bug, please use title='my title' rather than title="my title" showtags: true or false (default: false) - include the tags associated with each link shownotes: true or false (default: false) - include the notes associated with each link showname: true or false (default: false) - displays username at the bottom, with a link to user's delicious page showadd: true or false (default: false) - displays link to add user to your delicious network For (:tagroll:) number: number of tags to display sizerange: in the syntax '8-25', the lowest and highest text size used for display title: text to display as a header sort: options are freq (frequency) or alpha flow: cloud or list color1/color2: color1 is the least frequent tag, color2 is the most frequent (colors are used on a gradient between color1 and color2). must use html colors, no # (aka like this: '000099') counts: true or false - include the frequency of each tag user: delicious.com username (required) For (:deliciousbadge:) to simply copy& paste from http://delicious.com/help/tagometer, add $DeliciousBadgeFmt = 'yourjavascript'; to config.php size: wide or tall (default: wide) icon: true or false (default: true) - shows or hides delicious icon timesSaved: true or false (default: true) - shows or hides # of times saved graph: true or false (default: true) - shows or hides graph tags: true or false (default: true) - shows or hides tag Declare your own set of default values via $DeliciousBadgeDefaults in config.php: $DeliciousBadgeDefaults = array( 'size' => 'wide', 'icon' => 'true', 'timesSaved' => 'true', 'graph' => 'true', 'tags' => 'true' ); Version Log: * March 2006 1.0 - Initial Release * January 2007 1.1 - Added tagometer badge * November 2008 - Updated for change from delicious.com to delicious.com * April 2009 - Bug fixes. changed "label" to "title" to match delicious.com * 2009-10-03 - re-uploaded supposed version of April 2009 (just guessing), as it appears November 2008 was what was still being offered above; fixed issue with 'title' not displaying; plus, added $DeliciousBookmarkDefaults and $DeliciousTagDefaults as SDVA's, for easy config.php declaration * 2009-10-04 - can now display notes via shownotes=true, plus added showname & showadd; revised (:deliciousbadge:) to permit arguments */ $RecipeInfo['delicious']['Version']='2009-10-04b'; Markup("linkroll", ">block", '/\\(:linkroll\\s(.*?):\\)/ei', "DeliciousLinks('$1')"); Markup("tagroll", ">block", '/\\(:tagroll\\s(.*?):\\)/ei', "DeliciousTags('$1')"); SDVA($DeliciousBookmarkDefaults, array ( 'number' => '10', 'sort' => 'recent', 'tags' => '', 'user' => '', 'icon' => 'large', 'title' => 'My Delicious Bookmarks', 'showtags' => 'false', 'shownotes' => 'false', 'showadd' => 'false', 'showname' => 'false' )); function DeliciousLinks($p) { global $DeliciousBookmarkDefaults; // Defaults & Inputs $opt = array_merge($DeliciousBookmarkDefaults, ParseArgs($p)); // Return nothing if no username listed if ($opt['user'] == '') { return ''; } // Begin output $output = "<span class='linkroll'><script type='text/javascript' src='http://feeds.delicious.com/v2/js/".$opt['user']; if ($opt['tags'] != '') $output=$output."/".$opt['tags']; $output=$output."?"; $output=$output."count=".$opt['number']; if ($opt['title'] != '') { //$opt['title'] = str_replace('"',"'",$opt['title']); # replace double-quotes with single-quotes, or else problems with title $output .= "&title=".$opt['title']; } /* if ($opt['bullet'] != '' && $opt['bullet'] != 'none') { #$output .= "&bullet=%E2%80%A2"; # ¥ $output .= "&bullet=%C2%BB"; # >> } */ if ($opt['icon'] != 'none') { $output=$output."&icon"; if ($opt['icon'] == 'small') $output=$output."=s"; else if ($opt['icon'] == 'rss') $output=$output."=rss"; $output=$output.";"; } $output=$output."&sort=".$opt['sort']; if ($opt['showtags'] == 'true') $output=$output."&tags"; if ($opt['shownotes'] == 'true') $output=$output."&extended"; if ($opt['showname'] == 'true') $output=$output."&name"; if ($opt['showadd'] == 'true') $output=$output."&showadd"; $output=$output."'></script></span>"; // Finish output and return it return $output; }; SDVA($DeliciousTagDefaults, array( 'number' => '', 'sort' => 'alpha', 'sizerange' => '12-35', 'user' => '', 'flow' => 'cloud', 'title' => 'My Delicious Tags', 'color1' => '87ceeb', 'color2' => '0000ff', 'counts' => 'false' )); function DeliciousTags($p) { global $DeliciousTagDefaults; // Defaults & Inputs $opt = array_merge($DeliciousTagDefaults, ParseArgs($p)); // Return nothing if no username listed if ($opt['user'] == '') { return ''; } // Begin output $output = "<span class='tagroll'> <script type='text/javascript' src='http://feeds.delicious.com/v2/js/tags/".$opt['user']."?sort=".$opt['sort'].";icon;"; if ($opt['number'] == '') $output=$output; else $output=$output."count=".$opt['number'].";"; if ($opt['counts'] == 'true') $output=$output."totals;"; if ($opt['flow'] == 'list') $output=$output."flow=list;"; $output=$output."size=".$opt['sizerange'].";color=".$opt['color1']."-".$opt['color2'].";title=".$opt['title']."'></script> </span>"; // Finish output and return it return $output; } # DELICIOUS TAGOMETER BADGE SDV($DeliciousBadgeFmt, ''); SDVA($DeliciousBadgeDefaults, array( 'size' => 'wide', 'icon' => 'true', 'timesSaved' => 'true', 'graph' => 'true', 'tags' => 'true' )); Markup("deliciousbadge", ">block", '/\\(:deliciousbadge\\s*(.*?):\\)/ei', "DeliciousTagometerBadge('$1')"); function DeliciousTagometerBadge($p) { global $DeliciousBadgeDefaults, $DeliciousBadgeFmt; # allow user to declare their own badge, using the copy&paste method from http://delicious.com/help/tagometer if ($DeliciousBadgeFmt) { return Keep($DeliciousBadgeFmt); } $opt = array_merge($DeliciousBadgeDefaults, ParseArgs($p)); $output = "<script type=\"text/javascript\"> if (typeof window.Delicious == \"undefined\") window.Delicious = {};"; if($opt['size']=='tall') $output .= "\nDelicious.BLOGBADGE_DEFAULT_CLASS = 'delicious-blogbadge-tall'"; if($opt['icon']=='false') $output .= "\nDelicious.BLOGBADGE_ICON_SHOW = false"; if($opt['timesSaved']=='false') $output .= "\nDelicious.BLOGBADGE_SAVECOUNT_SHOW = false"; if($opt['graph']=='false') $output .= "\nDelicious.BLOGBADGE_GRAPH_SHOW = false"; if($opt['tags']=='false') $output .= "\nDelicious.BLOGBADGE_TAGS_SHOW = false"; $output .= "\n</script> <script src=\"http://static.delicious.com/js/d2-blogbadge.js\"></script>"; return Keep($output); }