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

[dw-free] Etsy: user name link and profile external service

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

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

Enable Etsy user name linking <user name="username" site="etsy.com">

Patch by [personal profile] ninetydegrees.

Files modified:
  • cgi-bin/DW/External/Site.pm
  • cgi-bin/DW/External/Site/Etsy.pm
--------------------------------------------------------------------------------
diff -r f219e6157450 -r 667d15045007 cgi-bin/DW/External/Site.pm
--- a/cgi-bin/DW/External/Site.pm	Tue Aug 02 18:06:15 2011 +0800
+++ b/cgi-bin/DW/External/Site.pm	Tue Aug 02 18:13:50 2011 +0800
@@ -38,6 +38,7 @@
 $domaintosite{"archiveofourown.org"} = DW::External::Site->new("8", "www.archiveofourown.org", "archiveofourown.org", "ArchiveofOurOwn", "AO3");
 $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");
 
 foreach my $value (values %domaintosite) {
     $idtosite{$value->{siteid}} = $value;
diff -r f219e6157450 -r 667d15045007 cgi-bin/DW/External/Site/Etsy.pm
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cgi-bin/DW/External/Site/Etsy.pm	Tue Aug 02 18:13:50 2011 +0800
@@ -0,0 +1,74 @@
+#!/usr/bin/perl
+#
+# DW::External::Site::Etsy
+#
+# Class to support Etsy linking.
+#
+# Authors:
+#      Mark Smith <mark@dreamwidth.org>
+#      NinetyD <ninetydtoo@gmail.com>
+#
+# 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::Etsy;
+
+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 shop
+sub journal_url {
+    my ( $self, $u ) = @_;
+    croak 'need a DW::External::User'
+        unless $u && ref $u eq 'DW::External::User';
+
+    return 'http://' . $self->{hostname} . '/shop/' . $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} . '/people/' . $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.etsy.com/favicon.ico";
+}
+
+
+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