From 04fee4fe50c459b77f51e702a0cc2322268e8baf Mon Sep 17 00:00:00 2001 From: Jean-Philippe Orsini Date: Mon, 7 May 2012 13:58:36 +0000 Subject: [PATCH] get PPA template from file --- po/Makefile | 2 +- po/Makefile.in | 2 +- po/fr.po | 8 ++++---- po/ppastats.pot | 8 ++++---- src/html.c | 40 +++++++++++++++++++++++++--------------- src/ppastats.1 | 4 ++-- tests/Makefile.am | 4 ++-- tests/Makefile.in | 4 ++-- www/Makefile.am | 3 ++- www/Makefile.in | 3 ++- www/ppa.tpl | 10 ++++++++++ 11 files changed, 55 insertions(+), 33 deletions(-) create mode 100644 www/ppa.tpl diff --git a/po/Makefile b/po/Makefile index 69bf449..b5acc35 100644 --- a/po/Makefile +++ b/po/Makefile @@ -22,7 +22,7 @@ srcdir = . top_srcdir = .. -prefix = /usr +prefix = /tmp/p exec_prefix = ${prefix} datarootdir = ${prefix}/share datadir = ${datarootdir} diff --git a/po/Makefile.in b/po/Makefile.in index cbbdd55..9fdca0c 100644 --- a/po/Makefile.in +++ b/po/Makefile.in @@ -22,7 +22,7 @@ srcdir = . top_srcdir = .. -prefix = /usr +prefix = /tmp/p exec_prefix = ${prefix} datarootdir = ${prefix}/share datadir = ${datarootdir} diff --git a/po/fr.po b/po/fr.po index 8950d02..7e6d31f 100644 --- a/po/fr.po +++ b/po/fr.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: ppastats 0.0.x\n" "Report-Msgid-Bugs-To: jeanfi@gmail.com\n" -"POT-Creation-Date: 2012-05-07 13:30+0200\n" +"POT-Creation-Date: 2012-05-07 14:22+0200\n" "PO-Revision-Date: 2012-05-05 23:45+0200\n" "Last-Translator: \n" "Language-Team: French\n" @@ -31,17 +31,17 @@ msgstr "" msgid "exceed cache capacity" msgstr "" -#: src/html.c:408 src/html.c:437 +#: src/html.c:407 src/html.c:436 #, c-format msgid "failed to open: %s" msgstr "" -#: src/html.c:471 src/html.c:491 src/html.c:504 +#: src/html.c:470 src/html.c:490 src/html.c:503 #, c-format msgid "generating %s" msgstr "" -#: src/html.c:567 +#: src/html.c:566 #, c-format msgid "copying %s %s" msgstr "" diff --git a/po/ppastats.pot b/po/ppastats.pot index 405355a..7be056b 100644 --- a/po/ppastats.pot +++ b/po/ppastats.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: ppastats 0.0.x\n" "Report-Msgid-Bugs-To: jeanfi@gmail.com\n" -"POT-Creation-Date: 2012-05-07 13:30+0200\n" +"POT-Creation-Date: 2012-05-07 14:22+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -31,17 +31,17 @@ msgstr "" msgid "exceed cache capacity" msgstr "" -#: src/html.c:408 src/html.c:437 +#: src/html.c:407 src/html.c:436 #, c-format msgid "failed to open: %s" msgstr "" -#: src/html.c:471 src/html.c:491 src/html.c:504 +#: src/html.c:470 src/html.c:490 src/html.c:503 #, c-format msgid "generating %s" msgstr "" -#: src/html.c:567 +#: src/html.c:566 #, c-format msgid "copying %s %s" msgstr "" diff --git a/src/html.c b/src/html.c index 07945f6..f4e2790 100644 --- a/src/html.c +++ b/src/html.c @@ -37,6 +37,7 @@ #include "ppastats.h" static char *footer; +static char *ppa_body; #define HTML_PKG_TEMPLATE \ "

N/A

\n\ @@ -124,18 +125,6 @@ src=\"js/excanvas.js\">\n\ \n\ \n" -#define HTML_INDEX_TEMPLATE \ -"

N/A

\n\ -
\n\ -
\n\ - Packages:\n\ -
    \n\ -
    \n\ -
    \n\ -
    \n\ -
    \n\ -
    \n" - static char *path_new(const char *dir, const char *file, const char *suffixe) { char *path; @@ -154,8 +143,6 @@ static char *path_new(const char *dir, const char *file, const char *suffixe) return path; } - - static const char *get_footer() { const char *path; @@ -171,6 +158,22 @@ static const char *get_footer() return footer; } +static const char *get_ppa_body() +{ + const char *path; + + if (!ppa_body) { + path = DEFAULT_WWW_DIR"/ppa.tpl"; + ppa_body = file_get_content(path); + + if (!ppa_body) + log_err("Failed to read PPA template: %s", path); + } + + return ppa_body; +} + + static struct json_object *date_to_json(struct tm *tm) { json_object *json; @@ -463,6 +466,13 @@ index_to_html(struct ppa_stats *ppa, const char *dir) { char *path, *json_path, *dname; json_object *json; + const char *body; + + body = get_ppa_body(); + if (!body) { + log_err("Failed to create PPA page"); + return ; + } json = ppa_to_json(ppa); json_path = path_new(dir, "index", ".json"); @@ -474,7 +484,7 @@ index_to_html(struct ppa_stats *ppa, const char *dir) path = path_new(dir, "index", ".html"); dname = ppa_display_name(ppa); - create_html(path, dname, HTML_INDEX_TEMPLATE, "ppastats_ppa();"); + create_html(path, dname, body, "ppastats_ppa();"); free(path); free(dname); } diff --git a/src/ppastats.1 b/src/ppastats.1 index b74c034..e54943d 100644 --- a/src/ppastats.1 +++ b/src/ppastats.1 @@ -19,12 +19,12 @@ display this help and exit display version information and exit .TP \fB\-o\fR, \fB\-\-output\-dir\fR=\fI[PATH]\fR -generates HTML pages into 'PATH'. +generates HTML pages into 'PATH' .TP \fB\-s\fR, \fB\-\-status\fR=\fI[STATUS]\fR retrieves only package of the given status (possible values are: Pending, Published, -Superseded, Deleted or Obsolete). +Superseded, Deleted or Obsolete) .TP \fB\-S\fR, \fB\-\-skip\-js\-css\fR skip installation of js and css files diff --git a/tests/Makefile.am b/tests/Makefile.am index c305cb9..9753322 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,5 +1,5 @@ check-local: checkpatch.pl - find $(top_srcdir)/src -name \*.c -exec $(srcdir)/checkpatch.pl -q --no-tree -emacs -f {} \; - find $(top_srcdir)/src -name \*.h -exec $(srcdir)/checkpatch.pl -q --no-tree -emacs -f {} \; + find $(top_srcdir)/src -name \*.c -exec $(srcdir)/checkpatch.pl --show-types -q --no-tree -emacs -f {} \; + find $(top_srcdir)/src -name \*.h -exec $(srcdir)/checkpatch.pl --show-types -q --no-tree -emacs -f {} \; EXTRA_DIST = checkpatch.pl diff --git a/tests/Makefile.in b/tests/Makefile.in index c4bc474..55ae8f6 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -358,8 +358,8 @@ uninstall-am: uninstall-am check-local: checkpatch.pl - find $(top_srcdir)/src -name \*.c -exec $(srcdir)/checkpatch.pl -q --no-tree -emacs -f {} \; - find $(top_srcdir)/src -name \*.h -exec $(srcdir)/checkpatch.pl -q --no-tree -emacs -f {} \; + find $(top_srcdir)/src -name \*.c -exec $(srcdir)/checkpatch.pl --show-types -q --no-tree -emacs -f {} \; + find $(top_srcdir)/src -name \*.h -exec $(srcdir)/checkpatch.pl --show-types -q --no-tree -emacs -f {} \; # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/www/Makefile.am b/www/Makefile.am index aea4cc5..1d08d7b 100644 --- a/www/Makefile.am +++ b/www/Makefile.am @@ -7,6 +7,7 @@ defaultwww_DATA = \ js/jqplot.dateAxisRenderer.min.js\ js/jquery.jqplot.min.js\ css/ppastats.css\ - css/jquery.jqplot.min.css + css/jquery.jqplot.min.css\ + ppa.tpl EXTRA_DIST=$(defaultwww_DATA) diff --git a/www/Makefile.in b/www/Makefile.in index 1b3f3db..0c2cc3c 100644 --- a/www/Makefile.in +++ b/www/Makefile.in @@ -212,7 +212,8 @@ defaultwww_DATA = \ js/jqplot.dateAxisRenderer.min.js\ js/jquery.jqplot.min.js\ css/ppastats.css\ - css/jquery.jqplot.min.css + css/jquery.jqplot.min.css\ + ppa.tpl EXTRA_DIST = $(defaultwww_DATA) all: all-am diff --git a/www/ppa.tpl b/www/ppa.tpl new file mode 100644 index 0000000..0b6d9af --- /dev/null +++ b/www/ppa.tpl @@ -0,0 +1,10 @@ +

    N/A

    +
    +
    + Packages: +
      +
      +
      +
      +
      +
      -- 2.7.4