Андрей (andy) wrote in changelog,
Андрей
andy
changelog

[ljcom] r9816: LJINT-362 (Comments for side projects): ...

Committer: ailyin
LJINT-362 (Comments for side projects): disable flag + cleanup
U   trunk/htdocs/tools/endpoints/comments.bml
Modified: trunk/htdocs/tools/endpoints/comments.bml
===================================================================
--- trunk/htdocs/tools/endpoints/comments.bml	2010-12-09 09:41:00 UTC (rev 9815)
+++ trunk/htdocs/tools/endpoints/comments.bml	2010-12-09 10:15:34 UTC (rev 9816)
@@ -1,12 +1,15 @@
 <?_code {
     ## return a comments to journal entry based on external uniq id
-    ## 
+    ##
     use strict;
     use Data::Dumper;
     use LJ::ExternalComments;
 
     use vars qw/%GET/;
 
+    return 'This feature is disabled'
+        unless LJ::is_enabled('external_comments');
+
     my $url     = $GET{url};
     my $rskey   = $GET{rsk};
     my $page    = int $GET{page}    || 0;
@@ -40,11 +43,9 @@
 
     ## convert article's uri on partners site to entryid on LJ.com
     my $jitemid = LJ::ExternalComments->url_to_jitemid($journal, $url);
-    return $answer->({ comments => [] }) 
+    return $answer->({ comments => [] })
         unless $jitemid; ## url that has no mapping to entry has no comments too.
 
-    # my $ditemid = 17604;
-
     my $entry = LJ::Entry->new($journal, jitemid => $jitemid);
 
     my $userpics = {};
@@ -56,7 +57,6 @@
         page       => $page,
         userpicref => $userpics,
         userref    => \%user,
-        #up         => $up,
         init_comobj => 0,
     };
 
@@ -70,8 +70,8 @@
     my $to_export_format = sub {
         my ($self, $comments) = @_;
         return unless ref $comments eq 'ARRAY';
-        return 
-            map { 
+        return
+            map {
                 my $comment = $_;
                 ##
                 my $text = $comment->{body};
@@ -89,7 +89,7 @@
 
                 $data->{username}       = $comment->{userpost} || '';
                 if ($pu){
-                    $data->{usericon}      = "$LJ::USERPIC_ROOT/$comment->{picid}/" . $pu->userid 
+                    $data->{usericon}      = "$LJ::USERPIC_ROOT/$comment->{picid}/" . $pu->userid
                         if $comment->{picid};
                     $data->{display_name}  = $pu->display_name;
                     $data->{journal_url}   = $pu->journal_base . "/";
@@ -105,7 +105,7 @@
                 $data->{state}          = $comment->{state};
 
                 ## Provide identity info
-                if ($pu and my $ident = $pu->identity){
+                if ($pu and my $ident = $pu->identity) {
                     $data->{identity} = {};
                     $data->{identity}->{typeid}     = $ident->typeid;
                     $data->{identity}->{short_code} = $ident->short_code;
@@ -121,7 +121,7 @@
     };
 
     my @result = $to_export_format->($to_export_format, \@comments);
-    return $answer->({ 
+    return $answer->({
         'comments' => \@result,
         'pages'    => $opts->{'out_pages'},
         'page'     => $opts->{'out_page'},

Tags: andy, bml, ljcom
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