DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:delicious

DokuWiki Plugin : del.icio.us

Compatible with DokuWiki

2008-05-05

plugin Displays a list of del.icio.us links

Last updated on
2009-02-09
Provides
Syntax

The missing download url means that this extension cannot be installed via the Extension Manager. Please see Publishing a Plugin on dokuwiki.org. Recommended are public repository hosts like GitHub, GitLab or Bitbucket.

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Tagged with !experimental, bookmark, embed, links, listing, tags

experimental

Updated 2009-02-09
Updated 2009-01-24
Updated 2009-01-20
Updated 2008-12-31

Description

Using this plugin, you can display a list of your del.icio.us bookmarks inside a DokuWiki page. It makes use of 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 question mark!
  • You can use as many tags as you want, delimited by a white space (' ')

Examples

To make it easier to get into the usage of this plugin, I registered a demo account at del.icio.us: Username is 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:

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}}

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}}

NOT, multiple tags

Now we want to list all bookmarks tagged 'web2.0' but not tagged 'dokuwiki':

{{delicious>n?web2.0 del.icio.us}}


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

  1. Install the plugin using the plugin manager from delicious.zip FIXME URL is forbidden
  2. 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 (description, tags or none) tags
Items to show Maximum of item to show in a listing (between 1 and 100) 20
urlencode() tag query string disable if you have trouble with AND not working as it should 1

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:

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:

Known Bugs / Troubleshooting

  • 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 caching 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 (added as option in 2008-01-20)
  • make it not choke on question marks in URLs (not reproducible - if you have a consistent test case for this problem, please write me a mail!)
  • improve the error messages even more
  • understand what the problem with urlencode is

Changelog

2009-02-09

  • adapted the JSON parser to the new structure (delicious now saves the user name in a new field). (thanks Marco Garcês)

2009-01-24

  • added configuration option to disable urlencode()-ing of tag string
  • removed both the get_file_contents and cURL download method in favour of DokuWiki's native HTTPClient (thanks Andi)

2009-01-20

  • changed getType() to 'baseonly' (now it should be valid XHTML)
  • _external_link respects $conf['target']['extern'] (thanks to Laurence Diver)
  • implemented optional cURL support for those php installations with disabled file_get_contents (thanks to jakub!)

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 <unixprog@gmail.com>
*/
 
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

Request bookmarks from multiple delicious accounts

Hi,

I just needed the possibility to request bookmarks by a specified tag from separate delicious accounts. So I've implemented a little hack which might be useful for everybody.

My modifications in syntax.php (getJSON(); line 201)

    function getJSON($tag) {
        $this->loadConfig();
        $users  = split( ';', $this->conf['diu_user']);
        if ( $this->conf['diu_urlencode'] ) {
            $tag = urlencode($tag); // to avoid possible encoding problems
        }
        $http_client = new DokuHTTPClient();
        foreach ($users as $user) {
            $url = "http://feeds.delicious.com/v2/json/$user/$tag?count=100";
            $json .= $http_client->get( $url );
        }
        return $json;
    }

Define the usernames in conf/default.php

$conf['diu_user']            = 'user1;user2';   //Usernames

André König 2009/01/22 00:20

I adapted your modified getJSON() method to use the DokuHTTPClient. The idea is nice, but I hesitate to implement it. While this makes sense for some cases, it might not be what users want as the global default. — konstantin baierer 2009/01/24 14:19

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 will find it useful. — 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) == '<DT>') {
        $line   = str_replace(array('<DT><A ', '</A>', '">'), 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         = '<a href="'.$url.'">'.$description.'</a>';
 
        $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.

Password-secured del.icio.us account?

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 API. This API blocks more requests than one every second.
If anyway someone interested in my patch you can contact me. — nougad 2008-07-05 04:13
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. — 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. — konstantin baierer 2008/12/31 11:36
I've just been looking for a solution to the AND tags problem and I have commented-out the urlencode line as suggested above and that worked. I've got the latest version from this page today. Maybe there's some other reason why this is needed? — Steven Robertson 2009/01/23 15:03
I can't reproduce the issue, but it seems to be an issue nonetheless, so I added a configuration option that disables the offending urlencode($tag) line. Could you give me an example of a tag set that fails with urlencode enabled? — konstantin baierer 2009/01/24 03:56
plugin/delicious.txt · Last modified: 2019-01-14 19:23 by LarsDW223

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