fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-07-25 04:29 am

[dw-free] Feed URLs not fetched from journal URLs when journals are marked as having have adult cont

[commit: http://hg.dwscoalition.org/dw-free/rev/7be4f91034e7]

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

Add the Atom and RSS feed links to the adult content interstitial pages.
This patch refactors out some redundant code as it is called from multiple
places.

Patch by [personal profile] fu.

Files modified:
  • bin/upgrading/en.dat
  • cgi-bin/LJ/S2.pm
  • cgi-bin/LJ/User.pm
  • htdocs/misc/adult_concepts.bml
  • htdocs/misc/adult_explicit.bml
  • htdocs/misc/adult_explicit_blocked.bml
--------------------------------------------------------------------------------
diff -r 4ec17899eb96 -r 7be4f91034e7 bin/upgrading/en.dat
--- a/bin/upgrading/en.dat	Thu Jul 21 02:04:56 2011 +0800
+++ b/bin/upgrading/en.dat	Mon Jul 25 12:29:13 2011 +0800
@@ -2319,7 +2319,7 @@
 
 setting.adultcontent.option.select.none=is suitable for everyone
 
-setting.adultcontent.option.self=This journal contains content that
+setting.adultcontent.option.select.concepts=should be viewed with discretion
 
 setting.adultcontent.option.self=This journal contains content that
 
diff -r 4ec17899eb96 -r 7be4f91034e7 cgi-bin/LJ/S2.pm
--- a/cgi-bin/LJ/S2.pm	Thu Jul 21 02:04:56 2011 +0800
+++ b/cgi-bin/LJ/S2.pm	Mon Jul 25 12:29:13 2011 +0800
@@ -2187,33 +2187,17 @@
         $p->{head_content} .= LJ::Hooks::run_hook('s2_head_content_extra', $remote, $opts->{r});
     }
 
-    # Automatic Discovery of RSS/Atom
-    if ($opts && $opts->{'addfeeds'}) {
-        if ( $opts->{'tags'} ) {
-            my $taglist = join( ',', map( { LJ::eurl($_) } @{$opts->{tags}} ) );
-            $p->{'head_content'} .= qq{<link rel="alternate" type="application/rss+xml" title="RSS: filtered by selected tags" href="$p->{'base_url'}/data/rss?tag=$taglist" />\n};
-            $p->{'head_content'} .= qq{<link rel="alternate" type="application/atom+xml" title="Atom: filtered by selected tags" href="$p->{'base_url'}/data/atom?tag=$taglist" />\n};
-        }
-        $p->{'head_content'} .= qq{<link rel="alternate" type="application/rss+xml" title="RSS: all entries" href="$p->{'base_url'}/data/rss" />\n};
-        $p->{'head_content'} .= qq{<link rel="alternate" type="application/atom+xml" title="Atom: all entries" href="$p->{'base_url'}/data/atom" />\n};
-        $p->{'head_content'} .= qq{<link rel="service" type="application/atomsvc+xml" title="AtomAPI service document" href="} . $u->atom_service_document . qq{" />\n};
-    }
-
-    # OpenID information if the caller asked us to include it here.
-    $p->{'head_content'} .= $u->openid_tags if $opts && $opts->{'addopenid'};
+    my %meta_opts = $opts ? (   feeds   => $opts->{addfeeds},
+                                tags    => $opts->{tags},
+                                openid  => $opts->{addopenid},
+                            ) : ();
+    $meta_opts{foaf} = 1;
+    $meta_opts{remote} = $remote;
+    $p->{head_content} .= $u->meta_discovery_links( %meta_opts );
 
     # other useful link rels
     $p->{head_content} .= qq{<link rel="help" href="$LJ::SITEROOT/support/faq" />\n};
 
-    # FOAF autodiscovery
-    my $foafurl = $u->{external_foaf_url} ? LJ::eurl($u->{external_foaf_url}) : "$p->{base_url}/data/foaf";
-    $p->{head_content} .= qq{<link rel="meta" type="application/rdf+xml" title="FOAF" href="$foafurl" />\n};
-
-    if ($u->email_visible($remote)) {
-        my $digest = Digest::SHA1::sha1_hex('mailto:' . $u->email_raw);
-        $p->{head_content} .= qq{<meta name="foaf:maker" content="foaf:mbox_sha1sum '$digest'" />\n};
-    }
-
     # Identity (type I) accounts only have read views
     $p->{views_order} = [ 'read', 'userinfo' ] if $u->is_identity;
     # feed accounts only have recent entries views
diff -r 4ec17899eb96 -r 7be4f91034e7 cgi-bin/LJ/User.pm
--- a/cgi-bin/LJ/User.pm	Thu Jul 21 02:04:56 2011 +0800
+++ b/cgi-bin/LJ/User.pm	Mon Jul 25 12:29:13 2011 +0800
@@ -5617,6 +5617,43 @@
 }
 
 
+sub meta_discovery_links {
+    my ( $u, %opts ) = @_;
+    my $journalbase = $u->journal_base;
+
+    my $ret = "";
+
+    # Automatic Discovery of RSS/Atom
+    if ( $opts{feeds} ) {
+        if ( $opts{tags} && @{$opts{tags}||[]}) {
+            my $taglist = join( ',', map( { LJ::eurl($_) } @{$opts{tags}||[]} ) );
+            $ret .= qq{<link rel="alternate" type="application/rss+xml" title="RSS: filtered by selected tags" href="$journalbase/data/rss?tag=$taglist" />\n};
+            $ret .= qq{<link rel="alternate" type="application/atom+xml" title="Atom: filtered by selected tags" href="$journalbase/data/atom?tag=$taglist" />\n};
+        }
+
+        $ret .= qq{<link rel="alternate" type="application/rss+xml" title="RSS: all entries" href="$journalbase/data/rss" />\n};
+        $ret .= qq{<link rel="alternate" type="application/atom+xml" title="Atom: all entries" href="$journalbase/data/atom" />\n};
+        $ret .= qq{<link rel="service" type="application/atomsvc+xml" title="AtomAPI service document" href="} . $u->atom_service_document . qq{" />\n};
+    }
+
+    # OpenID Server and Yadis
+    $ret .= $u->openid_tags if $opts{openid};
+
+    # FOAF autodiscovery
+    if ( $opts{foaf} ) {
+        my $foafurl = $u->{external_foaf_url} ? LJ::eurl( $u->{external_foaf_url} ) : "$journalbase/data/foaf";
+        $ret .= qq{<link rel="meta" type="application/rdf+xml" title="FOAF" href="$foafurl" />\n};
+
+        if ($u->email_visible($opts{remote})) {
+            my $digest = Digest::SHA1::sha1_hex( 'mailto:' . $u->email_raw );
+            $ret .= qq{<meta name="foaf:maker" content="foaf:mbox_sha1sum '$digest'" />\n};
+        }
+    }
+
+    return $ret;
+}
+
+
 sub opt_ctxpopup {
     my $u = shift;
 
@@ -8708,26 +8745,7 @@
         my $url = "$LJ::SITEROOT/users/$user/";
         $opts->{'status'} = $status if $status;
 
-        my $head;
-        my $journalbase = $u->journal_base;
-
-        # Automatic Discovery of RSS/Atom
-        $head .= qq{<link rel="alternate" type="application/rss+xml" title="RSS" href="$journalbase/data/rss" />\n};
-        $head .= qq{<link rel="alternate" type="application/atom+xml" title="Atom" href="$journalbase/data/atom" />\n};
-        $head .= qq{<link rel="service.feed" type="application/atom+xml" title="AtomAPI-enabled feed" href="$LJ::SITEROOT/interface/atom/feed" />\n};
-        $head .= qq{<link rel="service.post" type="application/atom+xml" title="Create a new post" href="$LJ::SITEROOT/interface/atom/post" />\n};
-
-        # OpenID Server and Yadis
-        $head .= $u->openid_tags;
-
-        # FOAF autodiscovery
-        my $foafurl = $u->{external_foaf_url} ? LJ::eurl($u->{external_foaf_url}) : "$journalbase/data/foaf";
-        $head .= qq{<link rel="meta" type="application/rdf+xml" title="FOAF" href="$foafurl" />\n};
-
-        if ($u->email_visible($remote)) {
-            my $digest = Digest::SHA1::sha1_hex('mailto:' . $u->email_raw);
-            $head .= qq{<meta name="foaf:maker" content="foaf:mbox_sha1sum '$digest'" />\n};
-        }
+        my $head = $u->meta_discovery_links( feeds => 1, openid => 1, foaf => 1, remote => $remote );
 
         return qq{
             <html>
diff -r 4ec17899eb96 -r 7be4f91034e7 htdocs/misc/adult_concepts.bml
--- a/htdocs/misc/adult_concepts.bml	Thu Jul 21 02:04:56 2011 +0800
+++ b/htdocs/misc/adult_concepts.bml	Mon Jul 25 12:29:13 2011 +0800
@@ -44,10 +44,10 @@
         return BML::redirect( $returl );
     }
 
-    # OpenID Server and Yadis
     if ( $journal ) {
         my $u = $journal;
-        $headextra .= $u->openid_tags if $u;
+        $headextra .= $u->meta_discovery_links( feeds => 1, openid => 1 )
+            if $u;
     } else {
         return BML::redirect( $LJ::SITEROOT );
     }
diff -r 4ec17899eb96 -r 7be4f91034e7 htdocs/misc/adult_explicit.bml
--- a/htdocs/misc/adult_explicit.bml	Thu Jul 21 02:04:56 2011 +0800
+++ b/htdocs/misc/adult_explicit.bml	Mon Jul 25 12:29:13 2011 +0800
@@ -44,10 +44,10 @@
         return BML::redirect( $returl );
     }
 
-    # OpenID Server and Yadis
     if ( $journal ) {
         my $u = $journal;
-        $headextra .= $u->openid_tags if $u;
+        $headextra .= $u->meta_discovery_links( feeds => 1, openid => 1 )
+            if $u;
     } else {
         return BML::redirect( $LJ::SITEROOT );
     }
diff -r 4ec17899eb96 -r 7be4f91034e7 htdocs/misc/adult_explicit_blocked.bml
--- a/htdocs/misc/adult_explicit_blocked.bml	Thu Jul 21 02:04:56 2011 +0800
+++ b/htdocs/misc/adult_explicit_blocked.bml	Mon Jul 25 12:29:13 2011 +0800
@@ -25,10 +25,10 @@
     my $journal = $r->pnote( 'user' );
     my $poster = defined $entry  ? $entry->poster : $journal;
 
-    # OpenID Server and Yadis
     if ( $journal ) {
         my $u = $journal;
-        $headextra .= $u->openid_tags if $u;
+        $headextra .= $u->meta_discovery_links( feeds => 1, openid => 1 )
+            if $u;
     } else {
         return BML::redirect( $LJ::SITEROOT );
     }
--------------------------------------------------------------------------------