holyandrew (holyandrew) wrote in changelog,
holyandrew
holyandrew
changelog

[livejournal] r22515: LJSUP-13039: olympics2012.lenta.ru heade...

Committer: akanashin
LJSUP-13039: olympics2012.lenta.ru header
U   trunk/cgi-bin/LJ/SiteScheme.pm
Modified: trunk/cgi-bin/LJ/SiteScheme.pm
===================================================================
--- trunk/cgi-bin/LJ/SiteScheme.pm	2012-07-27 08:04:50 UTC (rev 22514)
+++ trunk/cgi-bin/LJ/SiteScheme.pm	2012-07-30 07:34:20 UTC (rev 22515)
@@ -366,6 +366,19 @@
             stc/widgets/olympics.css
             templates/Widgets/olympics/olympics_bubble.tmpl
         });
+
+        my $json = LJ::MemCache::get('lentaru_olympics_json');
+        if ($json) {
+            LJ::need_var(lentaRu => {result => $json});
+        } else {    
+            my $browser = LWP::UserAgent->new;
+            my $response = $browser->get( 'http://olympic2012.lenta.ru/export/medals-top.json' );
+            if ($response->is_success) {
+                $json = eval { LJ::JSON->from_json($response->decoded_content) };
+                LJ::MemCache::set('lentaru_olympics_json', $json, 1800);
+                LJ::need_var(lentaRu => {result => $json});
+            }
+        }
     }
 
     return {

Tags: akanashin, holyandrew, livejournal, pm
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