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

[dw-free] external sites combo bug

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

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

Add Blogspot (blogspot.com), Delicious (delicious.com), DeviantArt
(deviantart.com), LastFM (last.fm), Ravelry (ravelry.com), Wordpress
(wordpress.com), Plurk (plurk.com) as external sites which can be used in
<user name="..." site="sitename.com">b. Also fix the badge image for
Diigo.

Patch by [staff profile] denise.

Files modified:
  • cgi-bin/DW/External/Site.pm
  • cgi-bin/DW/External/Site/Blogspot.pm
  • cgi-bin/DW/External/Site/Delicious.pm
  • cgi-bin/DW/External/Site/DeviantArt.pm
  • cgi-bin/DW/External/Site/Diigo.pm
  • cgi-bin/DW/External/Site/LastFM.pm
  • cgi-bin/DW/External/Site/Plurk.pm
  • cgi-bin/DW/External/Site/Ravelry.pm
  • cgi-bin/DW/External/Site/Wordpress.pm
--------------------------------------------------------------------------------
diff -r bfaa6254fd33 -r 9f7d41c0cdd4 cgi-bin/DW/External/Site.pm
--- a/cgi-bin/DW/External/Site.pm	Fri Nov 11 19:36:51 2011 +0800
+++ b/cgi-bin/DW/External/Site.pm	Fri Nov 11 19:48:11 2011 +0800
@@ -9,7 +9,7 @@
 # Authors:
 #      Mark Smith <mark@dreamwidth.org>
 #
-# Copyright (c) 2009 by Dreamwidth Studios, LLC.
+# Copyright (c) 2009-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
@@ -42,6 +42,14 @@
 $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");
+$domaintosite{"blogspot.com"} = DW::External::Site->new("13", "blogspot.com", "blogspot.com", "Blogspot", "blogspot");
+$domaintosite{"delicious.com"} = DW::External::Site->new("14", "delicious.com", "delicious.com", "Delicious", "delicious");
+$domaintosite{"deviantart.com"} = DW::External::Site->new("15", "deviantart.com", "deviantart.com", "DeviantArt", "da");
+$domaintosite{"last.fm"} = DW::External::Site->new("16", "last.fm", "last.fm", "LastFM", "lastfm");
+$domaintosite{"ravelry.com"} = DW::External::Site->new("17", "www.ravelry.com", "ravelry.com", "Ravelry", "ravelry");
+$domaintosite{"wordpress.com"} = DW::External::Site->new("18", "wordpress.com", "wordpress.com", "Wordpress", "WP");
+$domaintosite{"plurk.com"} = DW::External::Site->new("19", "plurk.com", "plurk.com", "Plurk", "Plurk");
+
 
 foreach my $value (values %domaintosite) {
     $idtosite{$value->{siteid}} = $value;
diff -r bfaa6254fd33 -r 9f7d41c0cdd4 cgi-bin/DW/External/Site/Blogspot.pm
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cgi-bin/DW/External/Site/Blogspot.pm	Fri Nov 11 19:48:11 2011 +0800
@@ -0,0 +1,77 @@
+#!/usr/bin/perl
+#
+# DW::External::Site::Blogspot
+#
+# Class to support Blogspot linking.
+#
+# Authors:
+#      Mark Smith <mark@dreamwidth.org>
+#      Denise Paolucci <denise@dreamwidth.org>
+#
+# 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::Blogspot;
+
+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 the front page of the blog
+sub journal_url {
+    my ( $self, $u ) = @_;
+    croak 'need a DW::External::User'
+        unless $u && ref $u eq 'DW::External::User';
+
+    return 'http://' . $u->user . '.' . $self->{hostname};
+}
+
+
+# argument: DW::External::User
+# blogspot doesn't really have profiles, so duplicate link
+sub profile_url {
+    my ( $self, $u ) = @_;
+    croak 'need a DW::External::User'
+        unless $u && ref $u eq 'DW::External::User';
+
+    return 'http://' . $u->user . '.' . $self->{hostname};
+}
+
+
+# argument: DW::External::User
+# returns info for the badge image (userhead icon) for this user
+sub badge_image {
+    my ( $self, $u ) = @_;
+    croak 'need a DW::External::User'
+        unless $u && ref $u eq 'DW::External::User';
+
+    return {
+        url     => "http://blogger.com/favicon.ico",
+        width   => 16,
+        height  => 16,
+    }
+}
+
+
+1;
diff -r bfaa6254fd33 -r 9f7d41c0cdd4 cgi-bin/DW/External/Site/Delicious.pm
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cgi-bin/DW/External/Site/Delicious.pm	Fri Nov 11 19:48:11 2011 +0800
@@ -0,0 +1,78 @@
+#!/usr/bin/perl
+#
+# DW::External::Site::Delicious
+#
+# Class to support Delicious linking.
+#
+# Authors:
+#      Mark Smith <mark@dreamwidth.org>
+#      Denise Paolucci <denise@dreamwidth.org>
+#
+# 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::Delicious;
+
+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 bookmarks
+sub journal_url {
+    my ( $self, $u ) = @_;
+    croak 'need a DW::External::User'
+        unless $u && ref $u eq 'DW::External::User';
+
+    return 'http://' . $self->{hostname} . '/' . $u->user;
+}
+
+
+# argument: DW::External::User
+# returns URL to this account's stacks list
+sub profile_url {
+    my ( $self, $u ) = @_;
+    croak 'need a DW::External::User'
+        unless $u && ref $u eq 'DW::External::User';
+
+    return 'http://' . $self->{hostname} . '/stacks/' . $u->user;
+}
+
+
+# argument: DW::External::User
+# returns info for the badge image (userhead icon) for this user
+sub badge_image {
+    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 {
+        url     => "http://delicious.com/favicon.ico",
+        width   => 16,
+        height  => 16,
+    }
+}
+
+
+1;
diff -r bfaa6254fd33 -r 9f7d41c0cdd4 cgi-bin/DW/External/Site/DeviantArt.pm
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cgi-bin/DW/External/Site/DeviantArt.pm	Fri Nov 11 19:48:11 2011 +0800
@@ -0,0 +1,78 @@
+#!/usr/bin/perl
+#
+# DW::External::Site::DeviantArt
+#
+# Class to support DeviantArt linking.
+#
+# Authors:
+#      Mark Smith <mark@dreamwidth.org>
+#      Denise Paolucci <denise@dreamwidth.org>
+#
+# 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::DeviantArt;
+
+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 gallery
+sub journal_url {
+    my ( $self, $u ) = @_;
+    croak 'need a DW::External::User'
+        unless $u && ref $u eq 'DW::External::User';
+
+    return 'http://' . $u->user . '.' . $self->{hostname} . '/gallery';
+}
+
+
+# argument: DW::External::User
+# returns URL to this account's general page
+sub profile_url {
+    my ( $self, $u ) = @_;
+    croak 'need a DW::External::User'
+        unless $u && ref $u eq 'DW::External::User';
+
+    return 'http://' . $u->user . '.' . $self->{hostname};
+}
+
+
+# argument: DW::External::User
+# returns info for the badge image (userhead icon) for this user
+sub badge_image {
+    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 {
+        url     => "http://deviantart.com/favicon.ico",
+        width   => 16,
+        height  => 16,
+    }
+}
+
+
+1;
diff -r bfaa6254fd33 -r 9f7d41c0cdd4 cgi-bin/DW/External/Site/Diigo.pm
--- a/cgi-bin/DW/External/Site/Diigo.pm	Fri Nov 11 19:36:51 2011 +0800
+++ b/cgi-bin/DW/External/Site/Diigo.pm	Fri Nov 11 19:48:11 2011 +0800
@@ -61,7 +61,7 @@
 
 # argument: DW::External::User
 # returns info for the badge image (userhead icon) for this user
-sub badge_imagel {
+sub badge_image {
     my ( $self, $u ) = @_;
     croak 'need a DW::External::User'
         unless $u && ref $u eq 'DW::External::User';
diff -r bfaa6254fd33 -r 9f7d41c0cdd4 cgi-bin/DW/External/Site/LastFM.pm
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cgi-bin/DW/External/Site/LastFM.pm	Fri Nov 11 19:48:11 2011 +0800
@@ -0,0 +1,78 @@
+#!/usr/bin/perl
+#
+# DW::External::Site::LastFM
+#
+# Class to support the Last.fm site.
+#
+# Authors:
+#      Mark Smith <mark@dreamwidth.org>
+#      Denise Paolucci <denise@dreamwidth.org>
+#
+# 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::LastFM;
+
+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 main dashboard
+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 stacks list
+sub profile_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 . '/charts';
+}
+
+
+# argument: DW::External::User
+# returns info for the badge image (userhead icon) for this user
+sub badge_image {
+    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 {
+        url     => "http://cdn.last.fm/flatness/favicon.2.ico",
+        width   => 16,
+        height  => 16,
+    }
+}
+
+
+1;
diff -r bfaa6254fd33 -r 9f7d41c0cdd4 cgi-bin/DW/External/Site/Plurk.pm
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cgi-bin/DW/External/Site/Plurk.pm	Fri Nov 11 19:48:11 2011 +0800
@@ -0,0 +1,77 @@
+#!/usr/bin/perl
+#
+# DW::External::Site::Plurk
+#
+# Class to support Plurk linking.
+#
+# Authors:
+#      Mark Smith <mark@dreamwidth.org>
+#      Denise Paolucci <denise@dreamwidth.org>
+#
+# 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::Plurk;
+
+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
+sub journal_url {
+    my ( $self, $u ) = @_;
+    croak 'need a DW::External::User'
+        unless $u && ref $u eq 'DW::External::User';
+
+    return 'http://' . $self->{hostname} . '/' . $u->user;
+}
+
+
+# argument: DW::External::User
+# no separate profile, so we'll just repeat it
+sub profile_url {
+    my ( $self, $u ) = @_;
+    croak 'need a DW::External::User'
+        unless $u && ref $u eq 'DW::External::User';
+
+    return 'http://' . $self->{hostname} . '/' . $u->user;
+}
+
+
+# argument: DW::External::User
+# returns info for the badge image (userhead icon) for this user
+sub badge_image {
+    my ( $self, $u ) = @_;
+    croak 'need a DW::External::User'
+        unless $u && ref $u eq 'DW::External::User';
+
+    return {
+        url     => "http://plurk.com/favicon.ico",
+        width   => 16,
+        height  => 16,
+    }
+}
+
+
+1;
diff -r bfaa6254fd33 -r 9f7d41c0cdd4 cgi-bin/DW/External/Site/Ravelry.pm
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cgi-bin/DW/External/Site/Ravelry.pm	Fri Nov 11 19:48:11 2011 +0800
@@ -0,0 +1,77 @@
+#!/usr/bin/perl
+#
+# DW::External::Site::Ravelry
+#
+# Class to support Ravelry linking.
+#
+# Authors:
+#      Mark Smith <mark@dreamwidth.org>
+#      Denise Paolucci <denise@dreamwidth.org>
+#
+# 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::Ravelry;
+
+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 profile
+sub journal_url {
+    my ( $self, $u ) = @_;
+    croak 'need a DW::External::User'
+        unless $u && ref $u eq 'DW::External::User';
+
+    return 'http://' . $self->{hostname} . '/people/' . $u->user;
+}
+
+
+# argument: DW::External::User
+# returns URL to this account's projects list
+sub profile_url {
+    my ( $self, $u ) = @_;
+    croak 'need a DW::External::User'
+        unless $u && ref $u eq 'DW::External::User';
+
+    return 'http://' . $self->{hostname} . '/projects/' . $u->user;
+}
+
+
+# argument: DW::External::User
+# returns info for the badge image (userhead icon) for this user
+sub badge_image {
+    my ( $self, $u ) = @_;
+    croak 'need a DW::External::User'
+        unless $u && ref $u eq 'DW::External::User';
+
+    return {
+        url     => "http://ravelry.com/favicon.ico",
+        width   => 16,
+        height  => 16,
+    }
+}
+
+
+1;
diff -r bfaa6254fd33 -r 9f7d41c0cdd4 cgi-bin/DW/External/Site/Wordpress.pm
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cgi-bin/DW/External/Site/Wordpress.pm	Fri Nov 11 19:48:11 2011 +0800
@@ -0,0 +1,79 @@
+#!/usr/bin/perl
+#
+# DW::External::Site::Wordpress
+#
+# Class to support Wordpress linking.
+#
+# Authors:
+#      Mark Smith <mark@dreamwidth.org>
+#      Denise Paolucci <denise@dreamwidth.org>
+#
+# 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::Wordpress;
+
+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 the front page of the blog
+# wordpress is a bit of a pain since it lets you domain-alias, but
+# username.wordpress.com should work for everybody
+sub journal_url {
+    my ( $self, $u ) = @_;
+    croak 'need a DW::External::User'
+        unless $u && ref $u eq 'DW::External::User';
+
+    return 'http://' . $u->user . '.' . $self->{hostname};
+}
+
+
+# argument: DW::External::User
+# wordpress doesn't really have profiles, so duplicate link
+sub profile_url {
+    my ( $self, $u ) = @_;
+    croak 'need a DW::External::User'
+        unless $u && ref $u eq 'DW::External::User';
+
+    return 'http://' . $u->user . '.' . $self->{hostname};
+}
+
+
+# argument: DW::External::User
+# returns info for the badge image (userhead icon) for this user
+sub badge_image {
+    my ( $self, $u ) = @_;
+    croak 'need a DW::External::User'
+        unless $u && ref $u eq 'DW::External::User';
+
+    return {
+        url     => "http://s.wordpress.org/about/images/wpmini-blue.png",
+        width   => 16,
+        height  => 16,
+    }
+}
+
+
+1;
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org