From: Ciaran Gultnieks Date: Thu, 26 Jan 2012 21:35:40 +0000 (+0000) Subject: A basic 'latest apps' widget' X-Git-Tag: 0.1~1042 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=ae25a82f2f2f08e0e62ef5efa2deb0a80460c791;p=fdroidserver.git A basic 'latest apps' widget' --- diff --git a/update.py b/update.py index e1d11103..e34c6ca7 100755 --- a/update.py +++ b/update.py @@ -469,7 +469,7 @@ if repo_keyalias != None: iconfilename = os.path.join(icon_dir, os.path.basename(repo_icon)) shutil.copyfile(repo_icon, iconfilename) -#Update known apks info... +# Update known apks info... knownapks = common.KnownApks() for apk in apks: knownapks.recordapk(apk['apkname'], apk['id']) @@ -501,6 +501,22 @@ for apk in apks: knownapks.writeifchanged() +# Generate latest apps HTML for widget +html = '

' +for line in file(os.path.join('stats', 'latestapps.txt')): + appid = line.rstrip() + html += '' + for app in apps: + if app['id'] == appid: + html += app['Name'] + '
' + break +html += '

' +f = open('repo/latestapps.html', 'w') +f.write(html) +f.close() + + + print "Finished." print str(apps_inrepo) + " apps in repo" print str(apps_disabled) + " disabled" diff --git a/updatestats.py b/updatestats.py index 892c20bc..11f0983c 100755 --- a/updatestats.py +++ b/updatestats.py @@ -135,7 +135,7 @@ for line in sorted(lst): f.close() # Write list of latest apps added to the repo... -latest = knownapks.getlatest(10) +latest = knownapks.getlatest(5) f = open('stats/latestapps.txt', 'w') for app in latest: f.write(app + '\n') diff --git a/wp-fdroid/wp-fdroid.php b/wp-fdroid/wp-fdroid.php index 33cb4838..7d486034 100644 --- a/wp-fdroid/wp-fdroid.php +++ b/wp-fdroid/wp-fdroid.php @@ -28,7 +28,8 @@ class FDroid add_shortcode('fdroidrepo',array($this, 'do_shortcode')); add_filter('query_vars',array($this, 'queryvars')); $this->inited=false; - $this->site_path=getenv('DOCUMENT_ROOT'); + $this->site_path=getenv('DOCUMENT_ROOT'); + register_sidebar_widget('FDroid Latest', 'widget_fdroidlatest'); } @@ -705,6 +706,13 @@ function linkify($vars) { return substr($retvar,0,-1); } +function widget_fdroidlatest($args) { + extract($args); + echo $before_widget; + echo $before_title . 'Latest Apps' . $after_title; + readfile(getenv('DOCUMENT_ROOT').'/repo/latestapps.html'); + echo $after_widget; +} $wp_fdroid = new FDroid();