fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-10-24 11:42 am

[dw-free] Diigo user tag/external site listing

[commit: http://hg.dwscoalition.org/dw-free/rev/e2cfe30251a5]

http://bugs.dwscoalition.org/show_bug.cgi?id=3904

Add diigo.com to the list of sites that can be used in the user tag.

Patch by [personal profile] rb.

Files modified:
  • cgi-bin/DW/External/Site.pm
  • cgi-bin/DW/External/Site/Diigo.pm
--------------------------------------------------------------------------------
diff -r 5944e2aac132 -r e2cfe30251a5 cgi-bin/DW/External/Site.pm
--- a/cgi-bin/DW/External/Site.pm	Mon Oct 24 19:12:04 2011 +0800
+++ b/cgi-bin/DW/External/Site.pm	Mon Oct 24 19:40:57 2011 +0800
@@ -41,6 +41,7 @@
 $domaintosite{"twitter.com"} = DW::External::Site->new("9", "twitter.com", "twitter.com", "Twitter", "Twitter");
 $domaintosite{"tumblr.com"} = DW::External::Site->new("10", "tumblr.com", "tumblr.com", "Tumblr", "Tumblr");
 $domaintosite{"etsy.com"} = DW::External::Site->new("11", "www.etsy.com", "etsy.com", "Etsy", "Etsy");
+$domaintosite{"diigo.com"} = DW::External::Site->new("12", "www.diigo.com", "diigo.com", "Diigo", "Diigo");
 
 foreach my $value (values %domaintosite) {
     $idtosite{$value->{siteid}} = $value;
diff -r 5944e2aac132 -r e2cfe30251a5 cgi-bin/DW/External/Site/Diigo.pm
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cgi-bin/DW/External/Site/Diigo.pm	Mon Oct 24 19:40:57 2011 +0800
@@ -0,0 +1,74 @@
+#!/usr/bin/perl
+#
+# DW::External::Site::Diigo
+#
+# Class to support Diigo linking.
+#
+# Authors:
+#      Mark Smith <mark@dreamwidth.org>
+#      Ricky Buchanan <ricky@notdoneliving.net>
+#
+# Copyright (c) 2011 by Dreamwidth Studios, LLC.
+#
+# This program is free software; you may redistribute it and/or modify it under
+# the same terms as Perl itself.  For a copy of the license, please reference
+# 'perldoc perlartistic' or 'perldoc perlgpl'.
+#
+
+package DW::External::Site::Diigo;
+
+use strict;
+use base 'DW::External::Site';
+use Carp qw/ croak /;
+
+
+# new does nothing for these classes
+sub new { croak 'cannot build with new'; }
+
+
+# returns an object if we allow this domain; else undef
+sub accepts {
+    my ( $class, $parts ) = @_;
+
+    # let's just assume the last two parts are good if we have them
+    return undef unless scalar( @$parts ) >= 2;
+
+    return bless { hostname => "$parts->[-2].$parts->[-1]" }, $class;
+}
+
+
+# argument: DW::External::User
+# returns URL to this account's library
+sub journal_url {
+    my ( $self, $u ) = @_;
+    croak 'need a DW::External::User'
+        unless $u && ref $u eq 'DW::External::User';
+
+    return 'http://' . $self->{hostname} . '/user/' . $u->user;
+}
+
+
+# argument: DW::External::User
+# returns URL to this account's profile
+sub profile_url {
+    my ( $self, $u ) = @_;
+    croak 'need a DW::External::User'
+        unless $u && ref $u eq 'DW::External::User';
+
+    return 'http://' . $self->{hostname} . '/profile/' . $u->user;
+}
+
+
+# argument: DW::External::User
+# returns URL to the badge image (userhead icon) for this user
+sub badge_image_url {
+    my ( $self, $u ) = @_;
+    croak 'need a DW::External::User'
+        unless $u && ref $u eq 'DW::External::User';
+
+    # for lack of anything better, let's use the favicon
+    return "http://www.diigo.com/favicon.ico";
+}
+
+
+1;
--------------------------------------------------------------------------------