From 91119f38b1102166475467dc0cee470bac61f01c Mon Sep 17 00:00:00 2001 From: Jean-Philippe Orsini Date: Sat, 3 Sep 2011 10:09:41 +0000 Subject: [PATCH] Added distro/arch information in package version page --- NEWS | 1 + configure | 20 ++++++++++---------- configure.ac | 2 +- src/html.c | 44 +++++++++++++++++++++++++++++++++++++++++++- src/ppastats.c | 2 -- src/ppastats.h | 2 -- www/css/ppastats.css | 15 ++++++++++++++- www/js/ppastats.js | 10 +++++++++- 8 files changed, 78 insertions(+), 18 deletions(-) diff --git a/NEWS b/NEWS index 9323cbc..c3c953a 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,6 @@ * v0.0.3 ** Generated HTML pages for package versions. +** Added distro/arch information in package version page. * v0.0.2 ** Generated HTML pages are now using JQuery+JQPlout instead of Google Chart. diff --git a/configure b/configure index 5936c42..4768a41 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.67 for ppastats 0.0.2. +# Generated by GNU Autoconf 2.67 for ppastats 0.0.3. # # Report bugs to . # @@ -552,8 +552,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='ppastats' PACKAGE_TARNAME='ppastats' -PACKAGE_VERSION='0.0.2' -PACKAGE_STRING='ppastats 0.0.2' +PACKAGE_VERSION='0.0.3' +PACKAGE_STRING='ppastats 0.0.3' PACKAGE_BUGREPORT='jeanfi@gmail.com' PACKAGE_URL='http://wpitchoune.net/ppastats' @@ -1253,7 +1253,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures ppastats 0.0.2 to adapt to many kinds of systems. +\`configure' configures ppastats 0.0.3 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1323,7 +1323,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of ppastats 0.0.2:";; + short | recursive ) echo "Configuration of ppastats 0.0.3:";; esac cat <<\_ACEOF @@ -1426,7 +1426,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -ppastats configure 0.0.2 +ppastats configure 0.0.3 generated by GNU Autoconf 2.67 Copyright (C) 2010 Free Software Foundation, Inc. @@ -1728,7 +1728,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by ppastats $as_me 0.0.2, which was +It was created by ppastats $as_me 0.0.3, which was generated by GNU Autoconf 2.67. Invocation command line was $ $0 $@ @@ -2544,7 +2544,7 @@ fi # Define the identity of the package. PACKAGE='ppastats' - VERSION='0.0.2' + VERSION='0.0.3' cat >>confdefs.h <<_ACEOF @@ -5270,7 +5270,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by ppastats $as_me 0.0.2, which was +This file was extended by ppastats $as_me 0.0.3, which was generated by GNU Autoconf 2.67. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -5337,7 +5337,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -ppastats config.status 0.0.2 +ppastats config.status 0.0.3 configured by $0, generated by GNU Autoconf 2.67, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 1caffa4..e11923f 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ([2.64]) -AC_INIT([ppastats], [0.0.2],[jeanfi@gmail.com],[ppastats],[http://wpitchoune.net/ppastats]) +AC_INIT([ppastats], [0.0.3],[jeanfi@gmail.com],[ppastats],[http://wpitchoune.net/ppastats]) AM_INIT_AUTOMAKE([-Wall -Werror gnu]) diff --git a/src/html.c b/src/html.c index 9a35c14..6ae462d 100644 --- a/src/html.c +++ b/src/html.c @@ -98,6 +98,10 @@ enum file_copy_error { N/A/N/A\n\

\n\
\n\ +
\n\ + Distros:\n\ +
    \n\ +
    \n\ \n\ " @@ -255,8 +259,10 @@ static char *version_to_json(struct ppa_stats *ppa, struct package_stats *pkg, struct version_stats *ver) { - json_object *json; char *ret; + struct distro_stats **distros, *distro; + json_object *json, *json_distros, *json_distro, *json_archs, *json_arch; + struct arch_stats **archs; json = json_object_new_object(); @@ -274,6 +280,42 @@ static char *version_to_json(struct ppa_stats *ppa, json_add_ddts(json, ver->daily_download_totals); + distros = ver->distros; + json_distros = json_object_new_array(); + json_object_object_add(json, "distros", json_distros); + while (*distros) { + distro = *distros; + json_distro = json_object_new_object(); + + json_object_array_add(json_distros, json_distro); + + json_object_object_add(json_distro, + "name", + json_object_new_string(distro->name)); + + archs = distro->archs; + json_archs = json_object_new_array(); + json_object_object_add(json_distro, "archs", json_archs); + while (*archs) { + json_arch = json_object_new_object(); + + json_object_object_add + (json_arch, + "name", + json_object_new_string((*archs)->name)); + + json_object_object_add + (json_arch, + "count", + json_object_new_int((*archs)->download_count)); + + json_object_array_add(json_archs, json_arch); + archs++; + } + + distros++; + } + ret = strdup(json_object_to_json_string(json)); json_object_put(json); diff --git a/src/ppastats.c b/src/ppastats.c index 032a537..1fa0e81 100644 --- a/src/ppastats.c +++ b/src/ppastats.c @@ -100,7 +100,6 @@ static struct distro_stats *get_distro_stats(struct version_stats *version, d->name = strdup(name); d->archs = NULL; d->download_count = 0; - d->daily_download_totals = NULL; version->distros = (struct distro_stats **)list_add((void **)version->distros, @@ -126,7 +125,6 @@ static struct arch_stats *get_arch_stats(struct distro_stats *distro, a = malloc(sizeof(struct arch_stats)); a->name = strdup(name); - a->daily_download_totals = NULL; a->download_count = 0; distro->archs diff --git a/src/ppastats.h b/src/ppastats.h index 615e2c2..0c1a90f 100644 --- a/src/ppastats.h +++ b/src/ppastats.h @@ -27,7 +27,6 @@ extern int debug; struct arch_stats { char *name; - struct daily_download_total *daily_download_totals; int download_count; }; @@ -36,7 +35,6 @@ struct distro_stats { struct arch_stats **archs; int download_count; - struct daily_download_total *daily_download_totals; }; struct version_stats { diff --git a/www/css/ppastats.css b/www/css/ppastats.css index 1d3f636..d266644 100644 --- a/www/css/ppastats.css +++ b/www/css/ppastats.css @@ -28,8 +28,21 @@ a:hover { font-size: 0.75em; } -#versions { +#versions, div.distros { width: 20%; float: left; } +li { + list-style: none; + padding: 0em 0em 0em 1em; +} + +h1 { + text-transform: uppercase; +} + +ul { + margin: 0 0 0 0; + padding: 0 0 0; +} \ No newline at end of file diff --git a/www/js/ppastats.js b/www/js/ppastats.js index 4a1e5b8..43c75be 100644 --- a/www/js/ppastats.js +++ b/www/js/ppastats.js @@ -53,10 +53,12 @@ function ppastats_ver() { var ddts = data["ddts"]; var max_date = null; var min_date = null; + var pkg_url = data["pkg_name"]+".html"; $("#ppa_owner").html(data["ppa_owner"]); $("#ppa_name").html(data["ppa_name"]); - $("#pkg_name").html(data["name"]); + $("#pkg_name").html(""+data["pkg_name"]+""); + $("#version").append(" "+data["name"]); $.each(ddts, function(i, item) { var tm = item["time"]; @@ -72,6 +74,12 @@ function ppastats_ver() { min_date = d; } }); + + $.each(data["distros"], function(i, distro) { + $.each(distro["archs"], function(i, arch) { + $("#distros").append("
  • "+distro["name"]+"_"+arch["name"]+": "+arch["count"]+"