[dw-free] add Tumblr to ExternalSites
[commit: http://hg.dwscoalition.org/dw-free/rev/074b009e0369]
http://bugs.dwscoalition.org/show_bug.cgi?id=3569
Add Tumblr to the list of linkable external sites.
Patch by
metawidget.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=3569
Add Tumblr to the list of linkable external sites.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- cgi-bin/DW/External/Site.pm
- cgi-bin/DW/External/Site/Tumblr.pm
-------------------------------------------------------------------------------- diff -r e31d554aa4fa -r 074b009e0369 cgi-bin/DW/External/Site.pm --- a/cgi-bin/DW/External/Site.pm Thu Jun 02 13:20:25 2011 +0800 +++ b/cgi-bin/DW/External/Site.pm Thu Jun 02 13:23:17 2011 +0800 @@ -37,6 +37,7 @@ $domaintosite{"dreamwidth.org"} = DW::External::Site->new("7", "www.dreamwidth.org", "dreamwidth.org", "Dreamwidth", "lj"); $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"); foreach my $value (values %domaintosite) { $idtosite{$value->{siteid}} = $value; diff -r e31d554aa4fa -r 074b009e0369 cgi-bin/DW/External/Site/Tumblr.pm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgi-bin/DW/External/Site/Tumblr.pm Thu Jun 02 13:23:17 2011 +0800 @@ -0,0 +1,74 @@ +#!/usr/bin/perl +# +# DW::External::Site::Tumblr +# +# Class to support Tumblr linking. +# +# Authors: +# Mark Smith <mark@dreamwidth.org> +# Eric Hortop <ehortop@metawidget.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::Tumblr; + +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 journal +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 +# returns URL to this account's journal (as there is no default profile location I could find) +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 URL to the badge image ("t" 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.tumblr.com/favicon.ico"; +} + + +1; --------------------------------------------------------------------------------