get PPA template from file
authorJean-Philippe Orsini <jeanfi@gmail.com>
Mon, 7 May 2012 13:58:36 +0000 (13:58 +0000)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Mon, 7 May 2012 13:58:36 +0000 (13:58 +0000)
po/Makefile
po/Makefile.in
po/fr.po
po/ppastats.pot
src/html.c
src/ppastats.1
tests/Makefile.am
tests/Makefile.in
www/Makefile.am
www/Makefile.in
www/ppa.tpl [new file with mode: 0644]

index 69bf449..b5acc35 100644 (file)
@@ -22,7 +22,7 @@ srcdir = .
 top_srcdir = ..
 
 
-prefix = /usr
+prefix = /tmp/p
 exec_prefix = ${prefix}
 datarootdir = ${prefix}/share
 datadir = ${datarootdir}
index cbbdd55..9fdca0c 100644 (file)
@@ -22,7 +22,7 @@ srcdir = .
 top_srcdir = ..
 
 
-prefix = /usr
+prefix = /tmp/p
 exec_prefix = ${prefix}
 datarootdir = ${prefix}/share
 datadir = ${datarootdir}
index 8950d02..7e6d31f 100644 (file)
--- 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:  <jeanfi@gmail.com>\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 ""
index 405355a..7be056b 100644 (file)
@@ -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 <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\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 ""
index 07945f6..f4e2790 100644 (file)
@@ -37,6 +37,7 @@
 #include "ppastats.h"
 
 static char *footer;
+static char *ppa_body;
 
 #define HTML_PKG_TEMPLATE \
 "      <h1><span id=\"pkg_name\">N/A</span></h1>\n\
@@ -124,18 +125,6 @@ src=\"js/excanvas.js\"></script><![endif]-->\n\
        </head>\n\
        <body>\n"
 
-#define HTML_INDEX_TEMPLATE \
-"      <h1><span id=\"ppa_name\">N/A</span></h1>\n\
-       <div id=\"details\">\n\
-               <div class=\"pkgs\">\n\
-                       <em>Packages</em>:\n\
-                       <ul id=\"pkgs\"></ul>\n\
-               </div>\n\
-       </div>\n\
-       <div  id=\"charts\">\n\
-               <div id=\"chart\"></div>\n\
-       </div>\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);
 }
index b74c034..e54943d 100644 (file)
@@ -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
index c305cb9..9753322 100644 (file)
@@ -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 
index c4bc474..55ae8f6 100644 (file)
@@ -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.
index aea4cc5..1d08d7b 100644 (file)
@@ -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)
index 1b3f3db..0c2cc3c 100644 (file)
@@ -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 (file)
index 0000000..0b6d9af
--- /dev/null
@@ -0,0 +1,10 @@
+<h1><span id="ppa_name">N/A</span></h1>
+<div id="details">
+  <div class="pkgs">
+    <em>Packages</em>:
+    <ul id="pkgs"></ul>
+  </div>
+</div>
+<div id="charts">
+  <div id="chart"></div>
+</div>