Subject: smb2www: Add support for changing the output style
Package: smb2www
Version: 980804-26
Severity: normal
Tags: patch
smb2www is ancient code by now, but it is still useful. However, the
pages it renders are dead ugly - I came up with this simple patch to
allow for externally creating suitable template files for the header
and footer. Of course, it would be cleaner to rewrite a good deal of
the code using, say, the Template Toolkit... But this is much simpler
and gives the user at least an option to configure how the output
looks like.
Greetings,
-- System Information:
Debian Release: testing/unstable
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.12-mosca
Locale: LANG=en_US, LC_CTYPE=en_US (charmap=ISO-8859-1)
Versions of packages smb2www depends on:
ii apache2-mpm-prefork [httpd-cg 2.0.55-3 traditional model for Apache2
ii cherokee [httpd-cgi] 0.4.29-1 extremely fast and flexible web se
ii debconf [debconf-2.0] 1.4.59 Debian configuration management sy
ii perl [libmime-base64-perl] 5.8.7-8 Larry Wall's Practical Extraction
ii smbclient 3.0.20b-2 a LanManager-like simple client fo
smb2www recommends no packages.
-- debconf information:
smb2www/need_reconfigure: true
* smb2www/master_browser: lafa
* smb2www/set_link: true
* smb2www/language: English
* smb2www/security:
smb2www/replace_config: true
diff -ruN smb2www-980804/cgi-bin/smb2www.pm
smb2www-980804+header_footer/cgi-bin/smb2www.pm
--- smb2www-980804/cgi-bin/smb2www.pm 2005-11-16 20:46:28.000000000 -0600
+++ smb2www-980804+header_footer/cgi-bin/smb2www.pm 2005-11-16
20:46:40.000000000 -0600
@@ -26,6 +26,7 @@
package smb2www;
use Exporter ();
+use IO::File;
use MIME::Base64;
use Time::Local; # for lmtime
use strict;
@@ -250,6 +251,32 @@
Expires: $exp
Content-type: text/html; charset=$charset
+EOF
+
+ if (defined $cfg{html_header_file} and -f $cfg{html_header_file}) {
+ my ($head_file, $head_data, %head_conf);
+ $head_file = IO::File->new($cfg{html_header_file}, 'r') or
+ die "Could not open $cfg{html_head_file}: $!";
+ $head_data = join("\n", $head_file->getlines);
+ $head_file->close;
+
+ %head_conf = (TITLE => $_[0],
+ REFRESH => (not $_[1] =~ /norefresh/) ?
+ "<META HTTP-EQUIV=\"refresh\" content=\"$cfg{refresh}\">\n" :
+ '',
+ CHARSET => $charset,
+ IMGROOT => $cfg{imgroot},
+ BACKGROUND => $cfg{background},
+ LINK => $cfg{link},
+ VLINK => $cfg{vlink});
+
+ for my $key (keys %head_conf) {
+ $head_data =~ s/%$key%/$head_conf{$key}/g;
+ }
+
+ print $head_data;
+ } else {
+ print << "EOF";
<HTML>
<HEAD>
@@ -261,10 +288,10 @@
More information about SMB2WWW is at http://samba.anu.edu.au/samba/smb2www
//-->
EOF
-if (not $_[1] =~ /norefresh/ ) {
- print "<META HTTP-EQUIV=\"refresh\" content=\"$cfg{refresh}\">\n";
-}
-print << "EOF";
+ if (not $_[1] =~ /norefresh/ ) {
+ print "<META HTTP-EQUIV=\"refresh\" content=\"$cfg{refresh}\">\n";
+ }
+ print << "EOF";
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$charset">
</HEAD>
<BODY background="$cfg{imgroot}/$cfg{background}" LINK="$cfg{"link"}"
VLINK="$cfg{vlink}">
@@ -272,13 +299,26 @@
<HR WIDTH=\"75%\">
<TABLE>
EOF
-};
+ }
+}
# Finishing the page
sub trailer {
my $help = href("$cfg{cgiroot}/smbhelp.pl", image
($cfg{icon_help},"$text{help}")."<H3>$text{help2}</H3>");
- print << "EOF";
+
+ if (defined $cfg{html_trailer_file} and -f $cfg{html_trailer_file}) {
+ my ($trailer_file, $trailer_data);
+ $trailer_file = IO::File->new($cfg{html_trailer_file}, 'r') or
+ die "Could not open $cfg{html_trailer_file}: $!";
+ $trailer_data = join("\n", $trailer_file->getlines);
+ $trailer_file->close;
+
+ $trailer_data =~ s/%HELP%/$help/g;
+
+ print $trailer_data;
+ } else {
+ print << "EOF";
</TABLE>
<HR WIDTH="75%">
<CENTER>
@@ -288,6 +328,7 @@
</BODY>
</HTML>
EOF
+ }
};
## Interfacing perl with smbclient
diff -ruN smb2www-980804/debian/rules smb2www-980804+header_footer/debian/rules
--- smb2www-980804/debian/rules 2005-11-16 20:46:28.000000000 -0600
+++ smb2www-980804+header_footer/debian/rules 2005-11-16 20:46:40.000000000
-0600
@@ -51,7 +51,8 @@
install -p -m644 debian/smb2www.default $(prefix)/usr/share/smb2www/
install -p -m644 debian/lintian
$(prefix)/usr/share/lintian/overrides/smb2www
-
+ install -p -m644 header.html $(prefix)/usr/share/smb2www/
+ install -p -m644 trailer.html $(prefix)/usr/share/smb2www/
# Build architecture-independent files here.
binary-indep: build install
diff -ruN smb2www-980804/header.html smb2www-980804+header_footer/header.html
--- smb2www-980804/header.html 1969-12-31 18:00:00.000000000 -0600
+++ smb2www-980804+header_footer/header.html 2005-11-16 20:46:40.000000000
-0600
@@ -0,0 +1,17 @@
+<HTML>
+
+<HEAD>
+<TITLE>%TITLE%</TITLE>
+<!--
+This page has been produced by SMB2WWW.
+SMB2WWW is (C) Remco van Mook 1997,1998.
+You can contact the author at: [EMAIL PROTECTED]
+More information about SMB2WWW is at http://samba.anu.edu.au/samba/smb2www
+//-->
+%REFRESH%
+<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=%CHARSET%">
+</HEAD>
+<BODY background="%IMGROOT%/%BACKGROUND%" LINK="%LINK%" VLINK="%VLINK%">
+<CENTER><H1>%TITLE%</H1></CENTER>
+<HR WIDTH=\"75%\">
+<TABLE>
diff -ruN smb2www-980804/Install.pl smb2www-980804+header_footer/Install.pl
--- smb2www-980804/Install.pl 2005-11-16 20:46:28.000000000 -0600
+++ smb2www-980804+header_footer/Install.pl 2005-11-16 20:46:40.000000000
-0600
@@ -157,6 +157,8 @@
mimetype = /etc/mime.types
### language = ### Must be set in $fcfg ###
### key = ### Must be set in $fcfg ###
+html_header_file = /usr/share/smb2www/header.html
+html_trailer_file = /usr/share/smb2www/trailer.html
EOF
=debian
diff -ruN smb2www-980804/trailer.html smb2www-980804+header_footer/trailer.html
--- smb2www-980804/trailer.html 1969-12-31 18:00:00.000000000 -0600
+++ smb2www-980804+header_footer/trailer.html 2005-11-16 20:46:40.000000000
-0600
@@ -0,0 +1,8 @@
+</TABLE>
+<HR WIDTH="75%">
+<CENTER>
+%HELP%
+Comments/remarks/kudos to:<i>[EMAIL PROTECTED]</i>
+</CENTER>
+</BODY>
+</HTML>