Типа я (zilogic) wrote in changelog,
Типа я
zilogic
changelog

[livejournal] r22225: LJSUP-12232: Enable pingback mechanism f...

Committer: amyshkin
LJSUP-12232: Enable pingback mechanism for gazeta.ru and championat.com
U   trunk/bin/upgrading/en.dat
U   trunk/cgi-bin/LJ/Text.pm
Modified: trunk/bin/upgrading/en.dat
===================================================================
--- trunk/bin/upgrading/en.dat	2012-06-13 09:03:01 UTC (rev 22224)
+++ trunk/bin/upgrading/en.dat	2012-06-13 09:19:38 UTC (rev 22225)
@@ -4445,6 +4445,8 @@
 pingback.ljping.comment.text|staleness=1
 pingback.ljping.comment.text=User <lj user="[[poster]]"> referenced to your post from <a href="[[sourceURI]]">[[subject]]</a> saying: [...] [[context]] [...]
 
+pingback.external.comment.text=Your post has been referenced on [[partner.site.name]] in <a href="[[link]]">[[partner.post.title]]</a> saying: [...] [[pre]] [[context]] [[post]] [...]
+
 pingback.option.disabled|staleness=1
 pingback.option.disabled=Disabled
 

Modified: trunk/cgi-bin/LJ/Text.pm
===================================================================
--- trunk/cgi-bin/LJ/Text.pm	2012-06-13 09:03:01 UTC (rev 22224)
+++ trunk/cgi-bin/LJ/Text.pm	2012-06-13 09:19:38 UTC (rev 22225)
@@ -41,6 +41,8 @@
 
 package LJ::Text;
 use HTML::Parser;
+use URI;
+use URI::QueryParam;
 use Encode qw(encode_utf8 decode_utf8 is_utf8);
 use Carp qw(confess cluck);
 use UNIVERSAL qw(isa);
@@ -631,5 +633,23 @@
     return $res;
 }
 
+sub canonical_uri {
+    my( $raw_uri ) = @_;
+    my $uri = URI->new($raw_uri)->canonical;
 
+    # regexp from https://metacpan.org/module/URI#PARSING-URIs-WITH-REGEXP
+    my( $scheme, $authority, $path, $query, $fragment ) =
+        $uri->as_string =~ m|(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?|;
+
+    $query = '';
+    my @query = ();
+
+    for my $key ( sort $uri->query_param ) {
+        push @query, map { "$key=$_" } sort $uri->query_param($key);
+    }
+
+    $query = join( '&', @query );
+    return ( $scheme ? "$scheme://" : '' ) . ( $authority ? $authority : '') . ( $path ? $path : '' ) . ( $query ? "?$query" : '' ) . ( $fragment ? $fragment : '' );
+}
+
 1;

Tags: amyshkin, dat, livejournal, pm, zilogic
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments