X-Git-Url: http://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Fhtml.c;h=d96942406c1443d23c8634f6def904dc7c30abd6;hb=c32ae4d8a044e8444d0c132e5ea6e3b5b9230198;hp=931b1f2315d187a7c0da7ee1b285b4b8318317dd;hpb=935baee7cf1924b19a914c6aea11d29dad0a189e;p=ppastats.git diff --git a/src/html.c b/src/html.c index 931b1f2..d969424 100644 --- a/src/html.c +++ b/src/html.c @@ -1,21 +1,24 @@ /* - Copyright (C) 2011 jeanfi@gmail.com - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301 USA -*/ + * Copyright (C) 2011-2012 jeanfi@gmail.com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#include +#define _(String) gettext(String) #include #include @@ -28,6 +31,7 @@ #include "html.h" #include "io.h" +#include "log.h" #include "lp.h" #include "lp_ws.h" #include "ppastats.h" @@ -65,6 +69,10 @@ \n\ \n\ +\n\ \n\ \n\ @@ -108,7 +116,7 @@ \n\ +src=\"js/excanvas.js\">\n\ \n\ \n\ static char *path_new(const char *dir, const char *file, const char *suffixe) { - char *path = malloc(strlen(dir)+1+ - strlen(file)+ - strlen(".html")+ - (suffixe ? strlen(suffixe) : 0) + - 1); + char *path; + + /* [dir]/[file][suffixe] */ + path = malloc(strlen(dir)+1+ + strlen(file)+ + (suffixe ? strlen(suffixe) : 0) + + 1); strcpy(path, dir); strcat(path, "/"); @@ -381,7 +391,7 @@ version_to_html(struct ppa_stats *ppa, f = fopen(path, "w"); if (!f) { - fprintf(stderr, "ERROR: failed to open: %s\n", path); + log_err(_("failed to open: %s"), path); return ; } @@ -406,7 +416,7 @@ create_html(const char *path, f = fopen(path, "w"); if (!f) { - fprintf(stderr, "ERROR: failed to open: %s\n", path); + log_err(_("failed to open: %s"), path); return ; } @@ -436,8 +446,8 @@ index_to_html(struct ppa_stats *ppa, const char *dir) json = ppa_to_json(ppa); json_path = path_new(dir, "index", ".json"); - if (debug) - printf("DEBUG: generating %s\n", json_path); + + log_debug(_("generating %s"), json_path); json_object_to_file(json_path, json); json_object_put(json); free(json_path); @@ -457,8 +467,8 @@ pkg_to_html(struct ppa_stats *ppa, struct package_stats *pkg, const char *dir) json_path = path_new(dir, pkg->name, ".json"); json = pkg_to_json(ppa, pkg); - if (debug) - printf("DEBUG: generating %s\n", json_path); + log_debug(_("generating %s"), json_path); + json_object_to_file(json_path, json); json_object_put(json); free(json_path); @@ -470,8 +480,7 @@ pkg_to_html(struct ppa_stats *ppa, struct package_stats *pkg, const char *dir) 1); sprintf(script, "ppastats_pkg(\"%s%s\");", pkg->name, ".json"); - if (debug) - printf("DEBUG: generating %s\n", path); + log_debug(_("generating %s"), path); create_html(path, pkg->name, HTML_PKG_TEMPLATE, script); free(path); @@ -507,7 +516,6 @@ ppa_to_html(const char *owner, const int install_static_files) { struct ppa_stats *ppastats; - struct daily_download_total **totals; char *path, *f_dst; char *css_dir, *js_dir; int i; @@ -518,6 +526,7 @@ ppa_to_html(const char *owner, "js/jqplot.dateAxisRenderer.min.js", DEFAULT_WWW_DIR"/jquery.jqplot.min.js", "js/jquery.jqplot.min.js", + DEFAULT_WWW_DIR"/excanvas.js", "js/excanvas.js", DEFAULT_WWW_DIR"/ppastats.css", "css/ppastats.css", DEFAULT_WWW_DIR"/jquery.jqplot.min.css", "css/jquery.jqplot.min.css" }; @@ -531,12 +540,10 @@ ppa_to_html(const char *owner, mkdir(css_dir, 0777); mkdir(js_dir, 0777); - for (i = 0; i < 6; i++) { + for (i = 0; i < 7; i++) { f_dst = path_append(output_dir, www_files[2*i+1]); - if (debug) - printf("DEBUG: copying %s %s\n", - www_files[2*i], f_dst); + log_debug(_("copying %s %s"), www_files[2*i], f_dst); fcopy(www_files[2*i], f_dst); free(f_dst); @@ -546,7 +553,6 @@ ppa_to_html(const char *owner, } ppastats = create_ppa_stats(owner, ppa, package_status); - totals = ppastats->daily_download_totals; path = path_new(output_dir, "ppa", ".html");