fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2010-07-02 06:15 am

[dw-free] AO3 showing up in the crosspost list (dev servers only)

[commit: http://hg.dwscoalition.org/dw-free/rev/77110236993c]

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

Get a list of supported sites to crosspost to, instead of a list of all
external sites.

Patch by [personal profile] kareila.

Files modified:
  • cgi-bin/DW/External/Site.pm
  • htdocs/manage/externalaccount.bml
--------------------------------------------------------------------------------
diff -r 5fc9fcab5cc5 -r 77110236993c cgi-bin/DW/External/Site.pm
--- a/cgi-bin/DW/External/Site.pm	Fri Jul 02 01:14:37 2010 +0800
+++ b/cgi-bin/DW/External/Site.pm	Fri Jul 02 14:21:44 2010 +0800
@@ -20,14 +20,10 @@ package DW::External::Site;
 
 use strict;
 use Carp qw/ croak /;
-use DW::External::Site::InsaneJournal;
-use DW::External::Site::LiveJournal;
-use DW::External::Site::JournalFen;
-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;
+use DW::External::XPostProtocol;
+
+use LJ::ModuleLoader;
+LJ::ModuleLoader->require_subclasses( "DW::External::Site" );
 
 my %domaintosite;
 my %idtosite;
@@ -83,11 +79,14 @@ sub get_site {
 }
 
 
-# returns a list of all supported sites
-sub get_sites {
-    my ($class) = @_;
+# returns a list of all supported sites for linking
+sub get_sites { return values %domaintosite; }
 
-    return values %domaintosite;
+# returns a list of all supported sites for crossposting
+sub get_xpost_sites {
+    my %protocols = DW::External::XPostProtocol->get_all_protocols;
+    return grep { exists $protocols{ $_->{servicetype} } }
+           values %domaintosite;
 }
 
 # returns the appropriate site by site_id
diff -r 5fc9fcab5cc5 -r 77110236993c htdocs/manage/externalaccount.bml
--- a/htdocs/manage/externalaccount.bml	Fri Jul 02 01:14:37 2010 +0800
+++ b/htdocs/manage/externalaccount.bml	Fri Jul 02 14:21:44 2010 +0800
@@ -77,7 +77,7 @@ use strict;
     }
 
     my @sitevalues;
-    my @sites = DW::External::Site->get_sites;
+    my @sites = DW::External::Site->get_xpost_sites;
 
     foreach my $site (sort { $a->{sitename} cmp $b->{sitename} } @sites) {
         push @sitevalues, $site->{siteid},  $site->{sitename};
--------------------------------------------------------------------------------
kareila: "PERL!" (perl)

[personal profile] kareila 2010-07-02 08:29 am (UTC)(link)
200th resolved bug! \o/
ninetydegrees: Art: cowboy lassoing on a horse (rodeo)

[personal profile] ninetydegrees 2010-07-02 11:20 am (UTC)(link)
Awesome! Bravo!