From: Frédéric Marchal Date: Thu, 27 May 2010 18:04:45 +0000 (+0000) Subject: Add an option to make sarg generates the css template X-Git-Tag: v2.3-pre5~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d183fb7f636bf2798607b1a678d6f1cbb2a83ab1;p=thirdparty%2Fsarg.git Add an option to make sarg generates the css template --- diff --git a/ChangeLog b/ChangeLog index 35831d0..31c3275 100644 --- a/ChangeLog +++ b/ChangeLog @@ -44,6 +44,7 @@ May-27-2009 Version 2.3-pre4 - Change the CSS template file and cleanup of the hardcoded styles (thanks to Maxim Britov). - Accept unlimited line length when converting or splitting the log file. - Use long options on the command line. + - Sarg can output the internal css inlined in the reports. It replaces the css.tpl distributed with the sources. Feb-10-2010 Version 2.2.7.1 - Fixed compilation error reported by some compilers due to an sizeof in a fprintf (thanks to Maxim Britov and Renato Botelho). diff --git a/css.c b/css.c index a5507d0..87281c2 100644 --- a/css.c +++ b/css.c @@ -27,15 +27,8 @@ #include "include/conf.h" #include "include/defs.h" -void css(FILE *fp_css) +void css_content(FILE *fp_css) { - if(ExternalCSSFile[0] != '\0') { - fprintf(fp_css,"\n",ExternalCSSFile); - return; - } - - fprintf(fp_css,"\n",fp_css); } diff --git a/css.tpl b/css.tpl index 37b913c..9043b69 100644 --- a/css.tpl +++ b/css.tpl @@ -1,19 +1,28 @@ -.body {font-family:Verdana,Tahoma,Arial;color:#000000;background-color:#ffffff;} -.info {font-family:Verdana,Tahoma,Arial;font-size:9px;} -.info a:link,a:visited {font-family:Verdana,Tahoma,Arial;color:#0000ff;font-size:9px;text-decoration:none;} -.title_c {font-family:Verdana,Tahoma,Arial;font-size:11px;color:darkblue;background-color:#ffffff;text-align:center;} -.title_l {font-family:Verdana,Tahoma,Arial;font-size:11px;color:darkblue;background-color:#ffffff;text-align:left;} -.title_r {font-family:Verdana,Tahoma,Arial;font-size:11px;color:darkblue;background-color:#ffffff;text-align:right;} -.header_c {font-family:Verdana,Tahoma,Arial;font-size:9px;color:darkblue;background-color:#dddddd;text-align:center;border-right:1px solid #666666;border-bottom:1px solid #666666;} -.header_l {font-family:Verdana,Tahoma,Arial;font-size:9px;color:darkblue;background-color:#dddddd;text-align:left;border-right:1px solid #666666;border-bottom:1px solid #666666;} -.header_r {font-family:Verdana,Tahoma,Arial;font-size:9px;color:darkblue;background-color:#dddddd;text-align:right;border-right:1px solid #666666;border-bottom:1px solid #666666;} -.text {font-family:Verdana,Tahoma,Arial;color:#000000;font-size:9px;text-align:right;} -.data {font-family:Verdana,Tahoma,Arial;color:#000000;font-size:9px;background-color:lavender;text-align:right;border-right:1px solid #6a5acd;border-bottom:1px solid #6a5acd;} -.data a:link,a:visited {font-family:Verdana,Tahoma,Arial;color:#0000ff;font-size:9px;background-color:lavender;text-align:right;text-decoration:none;} -.data2 {font-family:Verdana,Tahoma,Arial;color:#000000;font-size:9px;background-color:lavender;text-align:left;border-right:1px solid #6a5acd;border-bottom:1px solid #6a5acd;} -.data2 a:link,a:visited {font-family:Verdana,Tahoma,Arial;color:#0000ff;font-size:9px;text-align:left;background-color:lavender;text-decoration:none;} -.data3 {font-family:Verdana,Tahoma,Arial;color:#000000;font-size:9px,text-align:center;background-color:lavender;border-right:1px solid #6a5acd;border-bottom:1px solid #6a5acd;} -.data3 a:link,a:visited {font-family:Verdana,Tahoma,Arial;color:#0000ff;font-size:9px;text-align:center;background-color:lavender;text-decoration:none;} -.text {font-family:Verdana,Tahoma,Arial;color:#000000;font-size:9px;text-align:right;} -.link {font-family:Verdana,Tahoma,Arial;font-size:9px;color:#0000ff;} -.link a:link,a:visited {font-family:Verdana,Tahoma,Arial;font-size:9px;color:#0000ff;text-decoration:none;} +.logo {font-family:Verdana,Tahoma,Arial;font-size:11px;color:#006699;text-align:center;vertical-align:middle;border:none;padding:0px;margin-bottom:5px;} +.logo th {padding:0px;} +.logo img {vertical-align:middle;padding:0px;border:0px none;} +.body {font-family:Tahoma,Verdana,Arial;font-size:11px;color:#000000;background-color:white;background-image:url();} +.info {font-family:Tahoma,Verdana,Arial;font-size:10px;text-align:center;margin-top:1em;margin-bottom:1em;} +.info a:link,a:visited {font-family:Tahoma,Verdana,Arial;color:#0000FF;font-size:10px;text-decoration:none;} +.title {width:100%;text-align:center;margin-bottom:1em;} +div.title > table {margin:auto;} +.title_c {font-family:Tahoma,Verdana,Arial;font-size:11px;color:green;background-color:white;text-align:center;} +.title_l {font-family:Tahoma,Verdana,Arial;font-size:11px;color:green;background-color:white;text-align:left;} +.title_r {font-family:Tahoma,Verdana,Arial;font-size:11px;color:green;background-color:white;text-align:right;} +.index {width:100%;text-align:center;} +div.index > table {margin:auto;} +.report {width:100%;text-align:center;} +div.report > table {margin:auto;} +.header_l {font-family:Tahoma,Verdana,Arial;font-size:9px;color:darkblue;background-color:blanchedalmond;text-align:left;border-right:1px solid #666666;border-bottom:1px solid #666666;} +.header_r {font-family:Tahoma,Verdana,Arial;font-size:9px;color:darkblue;background-color:blanchedalmond;text-align:right;border-right:1px solid #666666;border-bottom:1px solid #666666;} +.header_c {font-family:Tahoma,Verdana,Arial;font-size:9px;color:darkblue;background-color:blanchedalmond;text-align:center;border-right:1px solid #666666;border-bottom:1px solid #666666;} +.data {font-family:Tahoma,Verdana,Arial;color:#000000;font-size:9px;background-color:lavender;text-align:right;border-right:1px solid #6A5ACD;border-bottom:1px solid #6A5ACD;} +.data a:link,a:visited {font-family:Tahoma,Verdana,Arial;color:#0000FF;font-size:9px;background-color:lavender;text-align:right;text-decoration:none;} +.data2 {font-family:Tahoma,Verdana,Arial;color:#000000;font-size:9px;background-color:lavender;text-align:left;border-right:1px solid #6A5ACD;border-bottom:1px solid #6A5ACD;} +.data2 a:link,a:visited {font-family:Tahoma,Verdana,Arial;color:#0000FF;font-size:9px;text-align:left;background-color:lavender;text-decoration:none;} +.data3 {font-family:Tahoma,Verdana,Arial;color:#000000;font-size:9px;background-color:lavender;text-align:center;border-right:1px solid #6A5ACD;border-bottom:1px solid #6A5ACD;} +.data3 a:link,a:visited {font-family:Tahoma,Verdana,Arial;color:#0000FF;font-size:9px;text-align:center;background-color:lavender;text-decoration:none;} +.text {font-family:Tahoma,Verdana,Arial;color:#000000;font-size:9px;background-color:lavender;text-align:right;} +.link {font-family:Tahoma,Verdana,Arial;font-size:9px;color:#0000FF;} +.link a:link,a:visited {font-family:Tahoma,Verdana,Arial;font-size:9px;color:#0000FF;text-decoration:none;} +a > img {border:none;} diff --git a/documentation/css.txt b/documentation/css.txt new file mode 100644 index 0000000..01f839c --- /dev/null +++ b/documentation/css.txt @@ -0,0 +1,20 @@ +/*!\file css.c +\brief Write the Content Style Sheet of the HTML reports. +*/ + + +/*! \fn void css_content(FILE *fp_css) +Write the content of the CSS in the file. + +\param fp_css The file to write the CSS to. +*/ + + + + +/*! \fn void css(FILE *fp_css) +Write the CSS in the file either as a link to an external file whose name is in +::ExternalCSSFile or as an inline text. + +\param fp_css The file to write the CSS to. +*/ diff --git a/include/defs.h b/include/defs.h index f518953..3d74dfd 100755 --- a/include/defs.h +++ b/include/defs.h @@ -62,6 +62,7 @@ void ccharset(char *CharSet); void convlog(const char *arq, char *df, int dfrom, int duntil); // css.c +void css_content(FILE *fp_css); void css(FILE *fp_css); // dansguardian_log.c diff --git a/log.c b/log.c index aab96c6..344fc3b 100644 --- a/log.c +++ b/log.c @@ -160,10 +160,12 @@ int main(int argc,char *argv[]) struct userfilestruct *first_user_file, *ufile, *ufile1, *prev_ufile; static int split=0; static int convert=0; + static int output_css=0; int option_index; static struct option long_options[]= { {"convert",no_argument,&convert,1}, + {"css",no_argument,&output_css,1}, {"split",no_argument,&split,1}, {0,0,0,0} }; @@ -536,6 +538,10 @@ int main(int argc,char *argv[]) NAccessLog++; } + if(output_css) { + css_content(stdout); + exit(EXIT_SUCCESS); + } if(split) { splitlog(AccessLog[0], df, dfrom, duntil, convert); exit(EXIT_SUCCESS); diff --git a/po/fr.po b/po/fr.po index c0affa9..09a80cf 100644 --- a/po/fr.po +++ b/po/fr.po @@ -9,7 +9,7 @@ msgstr "" "Project-Id-Version: sarg 2.3-pre3\n" "Report-Msgid-Bugs-To: fmarchal@users.sourceforge.net\n" "POT-Creation-Date: 2010-05-27 14:44+0200\n" -"PO-Revision-Date: 2010-05-24 17:40+0200\n" +"PO-Revision-Date: 2010-05-27 20:01+0200\n" "Last-Translator: Frédéric Marchal \n" "Language-Team: French \n" "MIME-Version: 1.0\n" @@ -144,14 +144,14 @@ msgid "Failed to close file %s - %s\n" msgstr "Erreur à la fermeture du fichier %s - %s\n" #: convlog.c:46 -#, fuzzy, c-format +#, c-format msgid "(convlog) Cannot open log file %s - %s\n" -msgstr "(log) Impossible d'ouvrir le fichier: %s - %s\n" +msgstr "(convlog) Impossible d'ouvrir le journal %s - %s\n" #: convlog.c:51 splitlog.c:51 -#, fuzzy, c-format +#, c-format msgid "Not enough memory to read the log file %s\n" -msgstr "Pas assez de mémoire pour lire le journal\n" +msgstr "Pas assez de mémoire pour lire le journal %s\n" #: convlog.c:58 #, c-format @@ -519,8 +519,7 @@ msgstr "Valeur «%s» inconnue pour le paramètre «%s»\n" #: getconf.c:319 #, c-format -msgid "" -"Value \"%s\" conflicts with other selected values for parameter \"%s\"\n" +msgid "Value \"%s\" conflicts with other selected values for parameter \"%s\"\n" msgstr "" "La valeur «%s» entre en conflit avec les autres valeurs sélectionnées pour le " "paramètre «%s»\n" @@ -532,8 +531,7 @@ msgstr "SARG: OPTION: %s\n" #: getconf.c:386 #, c-format -msgid "" -"Maybe you have a broken record or garbage in \"date_format\" parameter\n" +msgid "Maybe you have a broken record or garbage in \"date_format\" parameter\n" msgstr "" "Vous avez probablement un enregistrement erroné ou inattendu dans le " "paramètre «date_format»\n" @@ -659,9 +657,9 @@ msgid "User: %s" msgstr "Utilisateur: %s" #: grepday.c:617 grepday.c:719 -#, fuzzy, c-format +#, c-format msgid "user name too long for %s/%s/%s\n" -msgstr "Le nom d'utilisateur est trop long pour %s/%s.day\n" +msgstr "Le nom d'utilisateur est trop long pour %s/%s/%s\n" #: grepday.c:621 grepday.c:680 #, c-format @@ -704,14 +702,13 @@ msgid "Invalid elapsed time in file %s\n" msgstr "Temps écoulé incorrect dans le fichier %s\n" #: grepday.c:723 -#, fuzzy, c-format +#, c-format msgid "(grepday) Cannot open output file %s\n" -msgstr "(grepday) Impossible d'ouvrir le journal %s\n" +msgstr "(grepday) Impossible d'ouvrir le fichier de sortie %s\n" #: grepday.c:726 -#, fuzzy msgid "Graph report" -msgstr "Rapport journalier" +msgstr "Rapport graphique" #: grepday.c:733 grepday.c:746 index.c:252 msgid "DAYS" @@ -1560,8 +1557,7 @@ msgstr "(getusers) Impossible d'ouvrir le fichier %s - %s\n" #: log.c:1687 #, c-format msgid "Failed to move till the end of the users file %s: %s\n" -msgstr "" -"La fin du fichier des utilisateurs (%s) ne peut pas être atteinte: %s\n" +msgstr "La fin du fichier des utilisateurs (%s) ne peut pas être atteinte: %s\n" #: log.c:1697 #, c-format @@ -1576,8 +1572,7 @@ msgstr "erreur d'allocation mémoire (%ld)\n" #: log.c:1712 #, c-format msgid "You have an invalid user in your %s file\n" -msgstr "" -"Vous avez probablement un utilisateur incorrect dans votre fichier %s\n" +msgstr "Vous avez probablement un utilisateur incorrect dans votre fichier %s\n" #: longline.c:113 longline.c:126 #, c-format @@ -1906,12 +1901,12 @@ msgid "user name too long for %s/%s.unsort\n" msgstr "le nom d'utilisateur est trop long pour %s/%s.unsort\n" #: splitlog.c:46 -#, fuzzy, c-format +#, c-format msgid "(splitlog) Cannot open log file %s - %s\n" -msgstr "(splitlog) Impossible d'ouvrir le fichier %s\n" +msgstr "(splitlog) Impossible d'ouvrir le fichier %s - %s\n" #: splitlog.c:58 -#, fuzzy, c-format +#, c-format msgid "Invalid date found in file %s\n" msgstr "Mauvaise date dans le fichier %s\n" @@ -2152,8 +2147,7 @@ msgstr " -d Date de-à jj/mm/aaaa-jj/mm/aaaa" #: usage.c:37 msgid " -e Email address to send reports (stdout for console)" -msgstr "" -" -e Adresse e-mail où envoyer les rapports (stdout pour la console)" +msgstr " -e Adresse e-mail où envoyer les rapports (stdout pour la console)" #: usage.c:38 #, c-format @@ -2356,8 +2350,7 @@ msgstr "Tampon inacceptable passé à getword_ptr\n" #: util.c:294 #, c-format msgid "Invalid path (%s). Please, use absolute paths only.\n" -msgstr "" -"Chemin erroné (%s). Veuillez utiliser des chemins absolus uniquement.\n" +msgstr "Chemin erroné (%s). Veuillez utiliser des chemins absolus uniquement.\n" #: util.c:295 util.c:310 util.c:322 #, c-format diff --git a/sarg.1 b/sarg.1 index afba7d5..5ca38e5 100644 --- a/sarg.1 +++ b/sarg.1 @@ -21,7 +21,7 @@ sarg \- Squid Analysis Report Generator .B sarg .RI [ options ] .SH DESCRIPTION -\fBsarg\fP is a logfile parser and anylizer for the \fBSquid Web Proxy Cache\fP, +\fBsarg\fP is a logfile parser and analyzer for the \fBSquid Web Proxy Cache\fP, which can be found at \fBhttp://www.squid-cache.org/\fP. This manual page documents briefly the .B sarg @@ -59,6 +59,15 @@ Uses .IR "filename" as the exclude files to select records that are not counted. .TP +.B \-\-convert +Convert a squid log file date/time field to a human-readable format. All the log files are read and output as one text on the standard output. +.TP +.B \-\-css +Output, on the standard output, the internal css inlined in the reports by sarg. You can redirect the output to a file of your +choice and edit it. Then you can override the internal css with +.B external_css_file +in sarg.conf. +.TP .B \-d date Uses .I date @@ -124,6 +133,12 @@ Limits report to the site specified by .IR "string [eg. www.debian.org] .TP +.B \-\-split +Split the squid log file and output it as text on the standard output omitting the dates outside of the range specified by the \fB-d\fP parameter. +If it is combined with +.B \-\-convert +the dates are also converted to a human-readable format. +.TP .B \-t string Limits records counted in statistics based on time-of-day. Format for \fIstring\fP is \fBHH\fP or \fBHH:MM\fP or \fBHH:MM:SS\fP. @@ -139,12 +154,6 @@ Writes debug messages to \fBSTDOUT\fP .TP .B \-z Writes messages on processes to \fBSTDOUT\fP -.TP -.B \-convert -Convert the logfile's date/time field to human-readable. -.TP -.B \-split -Split the log file by date in \fB-d\fP parameter. .SH FILES .BR /usr/local/sarg/sarg.conf .br diff --git a/sarg.conf b/sarg.conf index 6ebb09f..e007776 100644 --- a/sarg.conf +++ b/sarg.conf @@ -583,14 +583,14 @@ #block_it none # TAG: external_css_file path -# This tag allow internal sarg css override by providing the name of -# the css file to link into each HTML page. +# Provide the path to an external css file to link into the HTML reports instead of +# the inline css written by sarg when this option is not set. # # In versions prior to 2.3, this used to be an absolute file name to -# a file to include verbatim in each HTML but as it takes a lot of -# spaces, version 2.3 switched to a link to an external css file. -# Therefore, it must be the HTTP server path on which a client browser -# may find the css file. +# a file to include verbatim in each HTML page but, as it takes a lot of +# space, version 2.3 switched to a link to an external css file. +# Therefore, this option must contain the HTTP server path on which a client +# browser may find the css file. # # Sarg use theses style classes: # .logo logo class @@ -605,7 +605,13 @@ # .data3 table text class, align:center # .link link class # -# There is a sample in /usr/local/sarg/etc/css.tpl +# Sarg can be instructed to output the internal css it inline +# into the reports with this command: +# +# sarg --css +# +# You can redirect the output to a file of your choice and edit +# it to your liking. # #external_css_file none