[dw-free] Linking to usernames on fanfiction,net
[commit: http://hg.dwscoalition.org/dw-free/rev/671e6866eb05]
http://bugs.dwscoalition.org/show_bug.cgi?id=4234
Add fanfiction.net and pinboard.in to user tags.
Patch by
ninetydegrees.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=4234
Add fanfiction.net and pinboard.in to user tags.
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/FanFiction.pm
- cgi-bin/DW/External/Site/Pinboard.pm
-------------------------------------------------------------------------------- diff -r 4f247fcff991 -r 671e6866eb05 cgi-bin/DW/External/Site.pm --- a/cgi-bin/DW/External/Site.pm Mon Jan 30 17:04:48 2012 +0800 +++ b/cgi-bin/DW/External/Site.pm Mon Jan 30 17:25:59 2012 +0800 @@ -49,7 +49,8 @@ $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"); - +$domaintosite{"pinboard.in"} = DW::External::Site->new("20", "www.pinboard.in", "pinboard.in", "Pinboard", "Pinboard"); +$domaintosite{"fanfiction.net"} = DW::External::Site->new("21", "www.fanfiction.net", "fanfiction.net", "FanFiction", "FanFiction"); foreach my $value (values %domaintosite) { $idtosite{$value->{siteid}} = $value; diff -r 4f247fcff991 -r 671e6866eb05 cgi-bin/DW/External/Site/FanFiction.pm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgi-bin/DW/External/Site/FanFiction.pm Mon Jan 30 17:25:59 2012 +0800 @@ -0,0 +1,77 @@ +#!/usr/bin/perl +# +# DW::External::Site::FanFiction +# +# Class to support FanFiction.net 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::FanFiction; + +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 archive +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 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} . '/~' . $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://b.fanfiction.net/static/images/favicon_2010_site.ico", + width => 16, + height => 16, + } +} + + +1; diff -r 4f247fcff991 -r 671e6866eb05 cgi-bin/DW/External/Site/Pinboard.pm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgi-bin/DW/External/Site/Pinboard.pm Mon Jan 30 17:25:59 2012 +0800 @@ -0,0 +1,78 @@ +#!/usr/bin/perl +# +# DW::External::Site::Pinboard +# +# Class to support Pinboard 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::Pinboard; + +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} . '/u:' . $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} . '/u:' . $u->user . '/profile/public'; +} + + +# 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://pinboard.in/favicon.ico", + width => 16, + height => 16, + } +} + + +1; --------------------------------------------------------------------------------