chiark / gitweb /
Changed latest apps from being rendered by update.py to wp-fdroid.php.
authorHans-Emil Skogh <hansemil@gmail.com>
Sat, 11 Feb 2012 21:14:28 +0000 (22:14 +0100)
committerCiaran Gultnieks <ciaran@ciarang.com>
Wed, 22 Feb 2012 14:58:57 +0000 (14:58 +0000)
This also adds icons to the latest app widget listing.

update.py
wp-fdroid/wp-fdroid.php

index a77faa2cf1eea642a542a419dc3ddee189eaef9e..539485bd309f80d50760485fc9b527e29e498946 100755 (executable)
--- a/update.py
+++ b/update.py
@@ -494,18 +494,18 @@ for apk in apks:
     knownapks.recordapk(apk['apkname'], apk['id'])
 knownapks.writeifchanged()
 
-# Generate latest apps HTML for widget
-html = '<p>'
+# Generate latest apps data for widget
+data = ''
 for line in file(os.path.join('stats', 'latestapps.txt')):
     appid = line.rstrip()
-    html += '<a href="/repository/browse/?fdid=' + appid + '">'
+    data += appid + "\t"
     for app in apps:
         if app['id'] == appid:
-            html += app['Name'] + '</a><br>'
+            data += app['Name'] + "\t"
+                       data += app['icon'] + "\n"
             break
-html += '</p>'
-f = open('repo/latestapps.html', 'w')
-f.write(html)
+f = open('repo/latestapps.dat', 'w')
+f.write(data)
 f.close()
 
 
index a4f63b1ea1008f6a50fc2b2a910e1d04dcc4ae9b..6b7e829d3d3d67173f9b677482a01a7d10f3ff10 100644 (file)
@@ -722,7 +722,21 @@ function widget_fdroidlatest($args) {
        extract($args);
        echo $before_widget;
        echo $before_title . 'Latest Apps' . $after_title;
-       readfile(getenv('DOCUMENT_ROOT').'/repo/latestapps.html');
+       
+       $handle = fopen(getenv('DOCUMENT_ROOT').'/repo/latestapps.dat', 'r');
+       if ($handle) {
+               while (($buffer = fgets($handle, 4096)) !== false) {
+                       $app = explode("\t", $buffer);
+                       echo '<a href="/repository/browse/?fdid='.$app[0].'">';
+                       if(trim($app[2])) {
+                               echo '<img src="http://f-droid.org/repo/icons/'.$app[2].'" style="width:32px;border:none;float:right;" />';
+                       }
+                       echo $app[1].'<br />';
+                       echo '</a><br style="clear:both;" />';
+               }
+               fclose($handle);
+       }
+       
        echo $after_widget;
 }