INN commit: trunk (3 files)

INN Commit Russ_Allbery at isc.org
Mon Jun 9 18:10:32 UTC 2008


    Date: Monday, June 9, 2008 @ 11:10:32
  Author: iulius
Revision: 7867

Add support for XSL and the choice of the extension for generated pages.
Patch by Alexander Bartolich

Modified:
  trunk/CONTRIBUTORS
  trunk/samples/innreport.conf.in
  trunk/scripts/innreport.in

---------------------------+
 CONTRIBUTORS              |    2 -
 samples/innreport.conf.in |   13 +++++++++---
 scripts/innreport.in      |   45 +++++++++++++++++++++++++++++++-------------
 3 files changed, 43 insertions(+), 17 deletions(-)

Modified: CONTRIBUTORS
===================================================================
--- CONTRIBUTORS	2008-06-09 17:58:48 UTC (rev 7866)
+++ CONTRIBUTORS	2008-06-09 18:10:32 UTC (rev 7867)
@@ -267,4 +267,4 @@
 Ray Miller, Andreas M. Kirchwitz, Andrey Yakovlev, Christoph Biedl,
 Kai Gallasch, Ollivier Robert, Ivan Shmakov, Kachun Lee, Kirill Berezin,
 D. Stussy, Alan Schwartz, Shalon Wood, Nick Couchman, Jakub Bogusz,
-J. Thomas Halliley, Matija Nalis, Geraint A. Edwards
+J. Thomas Halliley, Matija Nalis, Geraint A. Edwards, Alexander Bartolich

Modified: samples/innreport.conf.in
===================================================================
--- samples/innreport.conf.in	2008-06-09 17:58:48 UTC (rev 7866)
+++ samples/innreport.conf.in	2008-06-09 18:10:32 UTC (rev 7867)
@@ -22,12 +22,16 @@
 	graph           true;        # need 'html'
 	archive		true;  # use false to keep only the latest HTML report.
 	index		"index.html"; # name of the HTML index file.
+
+      # Change to .xhtml to let Apache server correct MIME type.
+      # html_file_extension    ".html";
+
       # html_dir     "/var/www/News/stats"; # default to pathhttp in inn.conf
 	img_dir         "pics";      # images will go to ${html_dir}/${img_dir}
 	cycle		none;        # use a number or 'none'.
         separator       ".";         # use a valid filename character.
 	title		"Daily Usenet report";
-      # title	     "Daily Usenet report for <A HREF=\"/News/stats/\">news.y.z</A>";
+      # title	        "Daily Usenet report for <A HREF=\"/News/stats/\">news.y.z</A>";
       # footer		"Local contact: <A HREF=\"mailto:x at y.z\">x at y.z</A>";
       # html_body	"BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"";
       # html_header_file "header.html";  # ${html_dir}/${html_header_file}
@@ -38,9 +42,12 @@
       # Character set used in XML and Content-Type declaration.
       # html_encoding	"ISO-8859-1";
 
-      # URL to CSS file.  If undefined a style sheet is embedded in HTML instead.
-      # html_css_url	"/innreport.css";
+      # URL to CSS file.  If undefined, a style sheet is embedded in HTML instead.
+      # html_css_url    "";
 
+      # URL to XSL file.  See <http://www.w3.org/MarkUp/2004/xhtml-faq#ie>.
+      # html_xsl_url    "";
+
         graph_width	550;         # graph width (in pixels)
         transparent	true;        # graph background transparent ?
         graph_fg        "#000000";   # graph foreground color.

Modified: scripts/innreport.in
===================================================================
--- scripts/innreport.in	2008-06-09 17:58:48 UTC (rev 7866)
+++ scripts/innreport.in	2008-06-09 18:10:32 UTC (rev 7867)
@@ -275,6 +275,11 @@
 my $CLASS   = &GetValue ($output{'default'}{'module'});
 my $LIBPATH = &GetValue ($output{'default'}{'libpath'});
 
+my $HTML_EXTENSION = $output{'default'}{'html_file_extension'};
+$HTML_EXTENSION = defined($HTML_EXTENSION)
+? &GetValue ($HTML_EXTENSION)
+: '.html';
+
 umask 022;
 
 BEGIN {
@@ -491,7 +496,7 @@
   else {
     $suffix = '';
   }
-  $HTML_output = "$HTML_dir" . "/news-notice" . "$suffix" . ".html";
+  $HTML_output = $HTML_dir . '/news-notice' . $suffix . $HTML_EXTENSION;
   $HTML_output =~ s|/+|/|g;
   if (defined $output{'default'}{'html_header_file'}) {
     my $file = &GetValue ($output{'default'}{'html_header_file'});
@@ -515,14 +520,17 @@
 
 &Write_all_results ($HTML_output, \%output);
 
-&Make_Index ($HTML_dir, $index, "news-notice$suffix.html", \%output)
-  if $HTML && $index;
+if ($HTML && $index)
+{
+  &Make_Index ($HTML_dir, $index,
+    'news-notice' . $suffix . $HTML_EXTENSION, \%output);
+}
 
 #====================================================================
 
 if ($ARCHIVE) {
   # rotate html files
-  &Rotate ($CYCLE, $HTML_dir, "news-notice", ".html");
+  &Rotate ($CYCLE, $HTML_dir, 'news-notice', $HTML_EXTENSION);
 
   # rotate pictures
   my $report;
@@ -717,6 +725,15 @@
   my $encoding = $output{'default'}{'encoding'};
   $encoding = defined($encoding) ? &GetValue($encoding) : 'ISO-8859-1';
 
+  my $xsl = '';
+  {
+    my $v = $output{'default'}{'html_xsl_url'};
+    if (defined($v)) {
+      $v = &GetValue($v);
+      $xsl = "\n<?xml-stylesheet type=\"text/xsl\" href=\"$v\"?>";
+    }
+  }
+
   my $style_sheet = '';
   my $css_url = $output{'default'}{'html_css_url'};
   if (defined($css_url)) {
@@ -728,7 +745,7 @@
   }
   else {
     $style_sheet = <<EOF;
-<style type="text/css"><!--
+<style type="text/css"><!--/*--><![CDATA[/*><!--*/
   div.ir-pageTitle {
     border-bottom:4px double black;
     border-top:4px double black;
@@ -808,20 +825,22 @@
   td.ir-primaryKey {
     background-color:#F8E0E0;
   }
---></style>
+/*]]>*/--></style>
 EOF
   }
 
   my $body = '';
-  my $v = $output{'default'}{'html_body'};
-  if (defined($v)) {
-    $v = &GetValue($v);
-    $v =~ s/\\\"/\"/go;
-    $body = ' ' . $v;
+  {
+    my $v = $output{'default'}{'html_body'};
+    if (defined($v)) {
+      $v = &GetValue($v);
+      $v =~ s/\\\"/\"/go;
+      $body = ' ' . $v;
+    }
   }
 
   return <<EOF;
-<?xml version="1.0" encoding="$encoding"?>
+<?xml version="1.0" encoding="$encoding"?>$xsl
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
   "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
@@ -960,7 +979,7 @@
       my (%in, %out, %dates, $k);
       foreach $k (keys (%data)) {
 	my @res = split /\|/, $data{$k};
-	my ($year) = $k =~ m/^news-notice\.(\d+)\.\d+\.\d+-\d+.\d+.\d+\.html/;
+	my ($year) = $k =~ m/^news-notice\.(\d+)\.\d+\.\d+-\d+.\d+.\d+$HTML_EXTENSION/;
 	next unless $year; # bad filename.. strange.
 	my ($start, $end) =
 	  $res[$date_idx - 1] =~ m/^(\w+\s+\d+ \S+) -- (\w+\s+\d+ \S+)$/o;



More information about the inn-committers mailing list