From 67d1bb5f9caf575e6eb329097cbb5519fd2fa869 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Orsini Date: Sat, 3 Sep 2011 18:58:30 +0000 Subject: [PATCH] Added -S option (patch submitted by Lekensteyn). Fixed patch: indentation and empty line in the cmd help. --- NEWS | 1 + src/html.c | 25 ++++++++++++++----------- src/html.h | 3 ++- src/main.c | 12 ++++++++++-- src/ppastats.1 | 3 +++ 5 files changed, 30 insertions(+), 14 deletions(-) diff --git a/NEWS b/NEWS index eb1dd8a..beb977f 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,7 @@ ** Don't generate manpage if help2man not present. ** Generate html page for the PPA. ** Renamed --output_dir option to --output-dir. +** Added -S option (patch submitted by Lekensteyn). * v0.0.3 ** Generated HTML pages for package versions. diff --git a/src/html.c b/src/html.c index a903009..da02b38 100644 --- a/src/html.c +++ b/src/html.c @@ -507,7 +507,8 @@ void ppa_to_html(const char *owner, const char *ppa, const char *package_status, - const char *output_dir) + const char *output_dir, + const int install_static_files) { struct ppa_stats *ppastats; struct daily_download_total **totals; @@ -525,17 +526,21 @@ ppa_to_html(const char *owner, DEFAULT_WWW_DIR"/jquery.jqplot.min.css", "css/jquery.jqplot.min.css" }; - css_dir = append_path(output_dir, "css"); - js_dir = append_path(output_dir, "js"); + if (install_static_files) { + css_dir = append_path(output_dir, "css"); + js_dir = append_path(output_dir, "js"); - mkdir(css_dir, 0777); - mkdir(js_dir, 0777); + mkdir(css_dir, 0777); + mkdir(js_dir, 0777); - for (i = 0; i < 6; i++) { - f_dst = append_path(output_dir, www_files[2*i+1]); - fcopy(www_files[2*i], f_dst); + for (i = 0; i < 6; i++) { + f_dst = append_path(output_dir, www_files[2*i+1]); + fcopy(www_files[2*i], f_dst); - free(f_dst); + free(f_dst); + } + free(css_dir); + free(js_dir); } ppastats = create_ppa_stats(owner, ppa, package_status); @@ -550,6 +555,4 @@ ppa_to_html(const char *owner, ppa_stats_free(ppastats); free(path); - free(css_dir); - free(js_dir); } diff --git a/src/html.h b/src/html.h index b165f78..9eb89d3 100644 --- a/src/html.h +++ b/src/html.h @@ -25,6 +25,7 @@ void ppa_to_html(const char *owner, const char *ppa, const char *package_status, - const char *output_dir); + const char *output_dir, + const int install_static_files); #endif diff --git a/src/main.c b/src/main.c index 75116e2..c17bc25 100644 --- a/src/main.c +++ b/src/main.c @@ -89,6 +89,7 @@ static struct option long_options[] = { {"output-dir", required_argument, 0, 'o'}, {"debug", no_argument, 0, 'd'}, {"status", required_argument, 0, 's'}, + {"skip-js-css", no_argument, 0, 'S'}, {0, 0, 0, 0} }; @@ -130,6 +131,8 @@ generates HTML pages into 'PATH'."); (possible values are: Pending, Published, \n\ Superseded, Deleted or Obsolete)."); + puts("\ + -S, --skip-js-css skip installation of js and css files"); puts(""); printf("Report bugs to: %s\n", PACKAGE_BUGREPORT); @@ -146,10 +149,11 @@ int main(int argc, char **argv) char *package_status = NULL; int cmdok = 1; char *output_dir = NULL; + int install_static_files = 1; program_name = argv[0]; - while ((optc = getopt_long(argc, argv, "vho:ds:", long_options, + while ((optc = getopt_long(argc, argv, "vho:ds:S", long_options, NULL)) != -1) { switch (optc) { case 'o': @@ -169,6 +173,9 @@ int main(int argc, char **argv) if (optarg) package_status = strdup(optarg); break; + case 'S': + install_static_files = 0; + break; default: cmdok = 0; break; @@ -185,7 +192,8 @@ int main(int argc, char **argv) ppa = argv[optind+1]; if (output_html) - ppa_to_html(owner, ppa, package_status, output_dir); + ppa_to_html(owner, ppa, package_status, output_dir, + install_static_files); else display_published_binaries(owner, ppa, package_status); diff --git a/src/ppastats.1 b/src/ppastats.1 index 9c2162f..8394c5a 100644 --- a/src/ppastats.1 +++ b/src/ppastats.1 @@ -24,6 +24,9 @@ generates HTML pages into 'PATH'. retrieves only package of the given status (possible values are: Pending, Published, Superseded, Deleted or Obsolete). +.TP +\fB\-S\fR, \fB\-\-skip\-js\-css\fR +skip installation of js and css files .SH "REPORTING BUGS" Report bugs to: jeanfi@gmail.com .PP -- 2.7.4