mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-14 15:02:51 +03:00
A basic 'latest apps' widget'
This commit is contained in:
parent
771fe181f1
commit
ae25a82f2f
3 changed files with 27 additions and 3 deletions
18
update.py
18
update.py
|
@ -469,7 +469,7 @@ if repo_keyalias != None:
|
||||||
iconfilename = os.path.join(icon_dir, os.path.basename(repo_icon))
|
iconfilename = os.path.join(icon_dir, os.path.basename(repo_icon))
|
||||||
shutil.copyfile(repo_icon, iconfilename)
|
shutil.copyfile(repo_icon, iconfilename)
|
||||||
|
|
||||||
#Update known apks info...
|
# Update known apks info...
|
||||||
knownapks = common.KnownApks()
|
knownapks = common.KnownApks()
|
||||||
for apk in apks:
|
for apk in apks:
|
||||||
knownapks.recordapk(apk['apkname'], apk['id'])
|
knownapks.recordapk(apk['apkname'], apk['id'])
|
||||||
|
@ -501,6 +501,22 @@ for apk in apks:
|
||||||
|
|
||||||
knownapks.writeifchanged()
|
knownapks.writeifchanged()
|
||||||
|
|
||||||
|
# Generate latest apps HTML for widget
|
||||||
|
html = '<p>'
|
||||||
|
for line in file(os.path.join('stats', 'latestapps.txt')):
|
||||||
|
appid = line.rstrip()
|
||||||
|
html += '<a href="/repository/browse/?fdid=' + appid + '">'
|
||||||
|
for app in apps:
|
||||||
|
if app['id'] == appid:
|
||||||
|
html += app['Name'] + '</a><br>'
|
||||||
|
break
|
||||||
|
html += '</p>'
|
||||||
|
f = open('repo/latestapps.html', 'w')
|
||||||
|
f.write(html)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
print "Finished."
|
print "Finished."
|
||||||
print str(apps_inrepo) + " apps in repo"
|
print str(apps_inrepo) + " apps in repo"
|
||||||
print str(apps_disabled) + " disabled"
|
print str(apps_disabled) + " disabled"
|
||||||
|
|
|
@ -135,7 +135,7 @@ for line in sorted(lst):
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
# Write list of latest apps added to the repo...
|
# Write list of latest apps added to the repo...
|
||||||
latest = knownapks.getlatest(10)
|
latest = knownapks.getlatest(5)
|
||||||
f = open('stats/latestapps.txt', 'w')
|
f = open('stats/latestapps.txt', 'w')
|
||||||
for app in latest:
|
for app in latest:
|
||||||
f.write(app + '\n')
|
f.write(app + '\n')
|
||||||
|
|
|
@ -29,6 +29,7 @@ class FDroid
|
||||||
add_filter('query_vars',array($this, 'queryvars'));
|
add_filter('query_vars',array($this, 'queryvars'));
|
||||||
$this->inited=false;
|
$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);
|
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();
|
$wp_fdroid = new FDroid();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue