Add support for AO3 to offsite user links.
Patch by chemicallace.
diffs (94 lines):
diff -r de76dd13ff5c -r 995f96748492 cgi-bin/DW/External/Site.pm
--- a/cgi-bin/DW/External/Site.pm Tue Jun 15 00:11:38 2010 +0800
+++ b/cgi-bin/DW/External/Site.pm Mon Jun 14 15:43:53 2010 -0500
@@ -26,6 +26,7 @@ use DW::External::Site::Inksome;
use DW::External::Site::Inksome;
use DW::External::Site::DeadJournal;
use DW::External::Site::Dreamwidth;
+use DW::External::Site::ArchiveofOurOwn;
use DW::External::Site::Unknown;
my %domaintosite;
@@ -38,7 +39,7 @@ my %idtosite;
$domaintosite{"inksome.com"} = DW::External::Site->new("5", "www.inksome.com",
"inksome.com", "Inksome", "lj");
$domaintosite{"journalfen.net"} = DW::External::Site->new("6",
"www.journalfen.net", "journalfen.net", "JournalFen", "lj");
$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");
foreach my $value (values %domaintosite) {
$idtosite{$value->{siteid}} = $value;
diff -r de76dd13ff5c -r 995f96748492 cgi-bin/DW/External/Site/ArchiveofOurOwn.pm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cgi-bin/DW/External/Site/ArchiveofOurOwn.pm Mon Jun 14 15:43:53
2010 -0500
@@ -0,0 +1,70 @@
+#!/usr/bin/perl
+#
+# DW::External::Site::ArchiveofOurOwn
+#
+# Class to support the ArchiveofOurOwn.org (AO3) site.
+#
+# Authors:
+# Allyson Sgro <[email protected]>
+# Mark Smith <[email protected]>
+#
+# Copyright (c) 2010 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::ArchiveofOurOwn;
+
+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 1/0 if we allow this domain
+sub accepts {
+ my ( $class, $parts ) = @_;
+
+ # allows anything at archiveofourown.org
+ return 0 unless $parts->[-1] eq 'org' &&
+ $parts->[-2] eq 'archiveofourown';
+
+ return bless { hostname => 'archiveofourown.org' }, $class;
+}
+
+
+# argument: DW::External::User
+# returns URL to this user's account
+sub journal_url {
+ my ( $self, $u ) = @_;
+ croak 'need a DW::External::User'
+ unless $u && ref $u eq 'DW::External::User';
+ return 'http://www.archiveofourown.org/users/' . $u->user . '/';
+}
+
+
+# argument: DW::External::User
+# returns URL to this user's profile
+sub profile_url {
+ my ( $self, $u ) = @_;
+ croak 'need a DW::External::User'
+ unless $u && ref $u eq 'DW::External::User';
+ return 'http://www.archiveofourown.org/users/' . $u->user . '/profile';
+}
+
+
+# argument: DW::External::User
+# returns URL to the badge image (head 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';
+ return 'http://archiveofourown.org/favicon.ico';
+}
+
+1;
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog