From: short <> Date: Fri, 26 Sep 2003 08:26:17 +0000 (+0000) Subject: modperl bootstrap X-Git-Url: http://git.jankratochvil.net/?p=www.jankratochvil.net.git;a=commitdiff_plain;h=87881612a38624ab579efed6e93749b0e2b42fc7 modperl bootstrap --- diff --git a/.htaccess b/.htaccess index ad263f7..f815410 100644 --- a/.htaccess +++ b/.htaccess @@ -1,4 +1,4 @@ -DirectoryIndex index.html +DirectoryIndex Index.html.pl AddType text/html .shtml AddHandler server-parsed .shtml @@ -42,3 +42,13 @@ php_flag magic_quotes_runtime off RewriteEngine on RewriteRule ^(/home/short/www/www.jankratochvil.net/)?sw/*(.*)$ http://www.jankratochvil.net/project/ [R=301] [L] + + + + RewriteEngine on + RewriteRule ^.*?/www[.]jankratochvil[.]net/(.*)$ http://localhost:7680/$1 [P] + + + + Options +ExecCGI + diff --git a/project/Islet/index.html.pl b/CV.html.pl similarity index 73% rename from project/Islet/index.html.pl rename to CV.html.pl index 5ef85ab..c512858 100755 --- a/project/Islet/index.html.pl +++ b/CV.html.pl @@ -1,7 +1,7 @@ #! /usr/bin/perl # # $Id$ -# Main page of 'My::Project::icp' +# Main page Perl template. # Copyright (C) 2003 Jan Kratochvil # # This program is free software; you can redistribute it and/or modify @@ -18,6 +18,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +package Index; require 5.6.0; # at least 'use warnings;' but we need some 5.6.0+ modules anyway use vars qw($VERSION $CVS_ID); $VERSION=do { my @r=(q$Revision$=~/\d+/g); sprintf "%d.".("%03d"x$#r),@r; }; @@ -25,20 +26,21 @@ $CVS_ID=q$Id$; use strict; use warnings; +BEGIN{ open F,"Makefile"; our $top_dir=pop @{[split /\s/,(grep /^top_srcdir/,)[0]]}; eval "use lib '$top_dir'"; close F; } use My::Web; -use project::icp::ListItem; +require 'CGI'; +require 'My::Project'; -My::Web->init_project( - "ListItem"=>\%My::Project::icp::ListItem, +my $W=My::Web->init( + "__PACKAGE__"=>__PACKAGE__, + "title"=>'CV - Jan Kratochvil', + "footer_ids"=>0, ); +My::Web->heading(); -print <<'HERE'; - -HERE -print '
'.My::Web::img("Islet.png","Applet demo screen").'
'."\n"; +print "

Nothing to see here, move along.

\n"; + My::Web->footer(); diff --git a/Makefile-head.am b/Makefile-head.am index 4f4aa18..c3ea56a 100644 --- a/Makefile-head.am +++ b/Makefile-head.am @@ -28,12 +28,21 @@ noinst_DATA= # Generally better behaviour but it requires GNU make. Harmless otherwise. .DELETE_ON_ERROR: -%.html: %.html.pl $(top_srcdir)/My/Web.pm $(top_srcdir)/WebConfig.pm - perl -I$(top_srcdir) >$@ $< - %.ppm: %.fig Makefile fig2dev -L ppm -S4 -b10 $< $@ %.gif: %.ppm - ppmtogif -sort $< >$@ + ppmtogif -quiet -sort $< >$@ + +%.ppm: %.gif + giftopnm $< >$@ + +%.png: %.ppm + pnmtopng $< >$@ + +%.ppm: %.png + pngtopnm $< >$@ + +%.png: %.dia $(top_srcdir)/dia-w.sh + $(top_srcdir)/dia-w.sh --nosplash --export $@ $< diff --git a/Makefile.am b/Makefile.am index 00a170c..ec18d28 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,7 +19,7 @@ include $(top_srcdir)/Makefile-head.am AUTOMAKE_OPTIONS=foreign -SUBDIRS=macros project +SUBDIRS=macros My project ## to automatically rebuild aclocal.m4 if any of the macros in ## `macros/' change @MAINT@include macros/macros.dep @@ -33,13 +33,15 @@ EXTRA_DIST+= \ Makefile-head.am \ autogen.pl \ .vimrc \ - ChangeLog + ChangeLog \ + dia-w.sh.in MAINTAINERCLEANFILES+= \ ChangeLog CLEANFILES+= \ - ChangeLog.bak + ChangeLog.bak \ + dia-w.sh if MAINTAINER_MODE ChangeLog: @@ -52,7 +54,9 @@ ChangeLog: endif EXTRA_DIST+= \ - index.html.pl - -noinst_DATA+= \ - index.html + Index.html.pl \ + WebConfig.pm \ + redirect.pl \ + have_js.js.pl \ + robots.txt \ + CV.html.pl diff --git a/WebConfig.pm b/WebConfig.pm index 1e5db17..a156212 100644 --- a/WebConfig.pm +++ b/WebConfig.pm @@ -30,9 +30,19 @@ use vars qw(@ISA @EXPORT); @ISA=qw(Exporter); @EXPORT=qw(%WebConfig); +require CGI; + + our %WebConfig=( "admin_mail"=>'web-www.jankratochvil.net@jankratochvil.net', - "viewcvs"=>map({ (!$_ ? $_ : s#^/#http://cvs.jankratochvil.net/viewcvs/energie/#); } $ENV{"SCRIPT_NAME"}), + "cvs_id_author"=>sub { + my($name)=@_; + return My::Web::a_href("http://www.jankratochvil.net/","Jan Kratochvil") if 0 + || $name eq "short" + || $name eq "lace"; + return CGI::escapeHTML($name); + }, + "viewcvs"=>"http://cvs.jankratochvil.net/viewcvs/www/www.jankratochvil.net/", "title_prefix"=>"Jan Kratochvil", ); diff --git a/autogen.pl b/autogen.pl index 9355b62..7f0bc73 100755 --- a/autogen.pl +++ b/autogen.pl @@ -30,6 +30,8 @@ use AutoGen; use Carp qw(cluck confess); +die if $ENV{"SERVER_SOFTWARE"}; # SECURITY: CGI misuse! + AutoGen->run( "name"=>"www.jankratochvil.net", "COPYRIGHT_HOLDER"=>'Jan Kratochvil ', @@ -37,9 +39,15 @@ AutoGen->run( "clean"=>[qw( ./ChangeLog.bak ./INSTALL + ./dia-w.sh ./project/Nokia61/Nokia61 ./project/Nokia61/Nokia61_23.cache + ./project/surprise/surprise-gnome-0.gif + ./project/line9k/line9k.png ./project/line9k/line9k.gif - *.html + ./project/captive/doc/fig/*.png + ./project/captive/doc/fig/*.gif + ./project/captive/doc/dia/*.png + ./project/captive/doc/dia/*.gif )], ); diff --git a/configure.in b/configure.ac similarity index 88% rename from configure.in rename to configure.ac index e10d54f..9f278b4 100644 --- a/configure.in +++ b/configure.ac @@ -20,10 +20,16 @@ AC_INIT(./Makefile-head.am) AM_INIT_AUTOMAKE(www.jankratochvil.net,1.0cvs) AM_MAINTAINER_MODE +AC_PATH_PROG(PATH_XVNC,Xvnc) +AC_PATH_PROG(PATH_BC,bc) +AC_PATH_PROG(PATH_DIA,dia) + dnl "Makefile" output files MUST have pathnames incl./excl. "./" prefix as specified! AC_OUTPUT([ Makefile +./dia-w.sh ./macros/Makefile +./My/Makefile ./project/Makefile ./project/step/Makefile ./project/icp/Makefile @@ -62,6 +68,11 @@ Makefile ./project/ppp9k/Makefile ./project/LaceMail/Makefile ./project/line9k/Makefile +./project/captive/Makefile +./project/captive/apiref/Makefile +./project/captive/doc/Makefile +./project/captive/doc/fig/Makefile +./project/captive/doc/dia/Makefile ]) echo done. diff --git a/dia-w.sh.in b/dia-w.sh.in new file mode 100755 index 0000000..899f18c --- /dev/null +++ b/dia-w.sh.in @@ -0,0 +1,93 @@ +#! /bin/bash +# $Id$ +# Try to run "dia" with '-e' option, Xvnc wrapping if needed. +# Copyright (C) 2000,2003 Jan Kratochvil +# +# 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; exactly version 2 of June 1991 is required +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +empty= +if test "x@PATH_XVNC@" != "x@PATH_XVNC$empty@" +then + PATH_XVNC="@PATH_XVNC@" +fi +if test "x@PATH_BC@" != "x@PATH_BC$empty@" +then + PATH_BC="@PATH_BC@" +fi +if test "x@PATH_DIA@" != "x@PATH_DIA$empty@" +then + PATH_DIA="@PATH_DIA@" +else + PATH_DIA=dia +fi + +unset xpid +if test "x$PATH_XVNC" != "x" +then + xport=$[($$%4096)+2000] + notdone=true + run=true + while $notdone + do + if test -r /proc/net/tcp -a "x$PATH_BC" != "x" + then + loop=true + while $loop + do + hex="`echo "obase=16;$[$xport+5900]"|$PATH_BC`" + if grep -q ":`echo "000$hex"|tail -c5` " /proc/net/tcp + then + if $run + then + xport=$[$xport+1] + else + notdone=false + loop=false + fi + else + if $run + then + loop=false + else + echo -n . + sleep 1 + fi + fi + done + else + notdone=$run + fi + if $run + then + export DISPLAY=":$xport" + $PATH_XVNC $DISPLAY & xpid=$! + run=false + fi + done +else + if test "x$DISPLAY" = "x" + then + export DISPLAY=":0" + fi +fi + +$PATH_DIA --disable-crash-dialog "$@";r=$? + +if test "x$xpid" != "x" +then + kill $xpid +fi + +exit $r diff --git a/have_js.js.pl b/have_js.js.pl new file mode 100755 index 0000000..3ae375d --- /dev/null +++ b/have_js.js.pl @@ -0,0 +1,65 @@ +#! /usr/bin/perl +# +# $Id$ +# JavaScript detection scriptlet Perl template. +# Copyright (C) 2003 Jan Kratochvil +# +# 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; exactly version 2 of June 1991 is required +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +package Index; +require 5.6.0; # at least 'use warnings;' but we need some 5.6.0+ modules anyway +use vars qw($VERSION $CVS_ID); +$VERSION=do { my @r=(q$Revision$=~/\d+/g); sprintf "%d.".("%03d"x$#r),@r; }; +$CVS_ID=q$Id$; +use strict; +use warnings; + +BEGIN{ open F,"Makefile"; our $top_dir=pop @{[split /\s/,(grep /^top_srcdir/,)[0]]}; eval "use lib '$top_dir'"; close F; } +use My::Web; + + +my $W=My::Web->init( + "__PACKAGE__"=>__PACKAGE__, + "title"=>'Homepage of Jan Kratochvil', + ); +# Do not: My::Web->heading(); +$W->{"r"}->send_http_header("text/javascript"); + +# Prevent redirection of some top (referring) foreign webpage as it +# may not pass "have_js=1" to us anyway. (for example Google cache) +print "" + .'if (0'."\n" + ."\t\t".'|| window.location.hostname=="'.$W->{"r"}->hostname().'" && window.location.port== 80'."\n" + ."\t\t".'|| window.location.hostname=="'.'localhost' .'" && window.location.port==7680)'."\n"; +print <<'HERE'; + { + var searchN=window.location.search; + if (searchN=="" || searchN=="?") + searchN="?"; + else + searchN+="&"; + searchN+="have_js=1"; + + window.location.href + =window.location.protocol+"//" + +window.location.hostname + +(window.location.port==80 ? "" : ":"+window.location.port) + +window.location.pathname + +window.location.hash + +searchN; + } +HERE + +# Do not: My::Web->footer(); diff --git a/index.html.pl b/index.html.pl deleted file mode 100755 index 2ab5986..0000000 --- a/index.html.pl +++ /dev/null @@ -1,58 +0,0 @@ -#! /usr/bin/perl -# -# $Id$ -# Main page Perl template. -# Copyright (C) 2003 Jan Kratochvil -# -# 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; exactly version 2 of June 1991 is required -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -require 5.6.0; # at least 'use warnings;' but we need some 5.6.0+ modules anyway -use vars qw($VERSION $CVS_ID); -$VERSION=do { my @r=(q$Revision$=~/\d+/g); sprintf "%d.".("%03d"x$#r),@r; }; -$CVS_ID=q$Id$; -use strict; -use warnings; - -use My::Web; -use Carp qw(cluck confess); - - -My::Web->init( - "title"=>'Homepage of Jan Kratochvil alias Lace', - ); -My::Web->heading(); - -print <<'HERE'; -

Jan Kratochvil

-
- -

Software projects

-
-

List of my software projects

-
- -

ViewCVS of my CVS repository

-
-

My public CVSROOT; Accessible storage of all of my projects, config files, webs and more.

-
- -

Contact

-
-

e-mail: web-www.jankratochvil.net@jankratochvil.net

-
- -HERE - -My::Web->footer(); diff --git a/project/.htaccess b/project/.htaccess deleted file mode 100644 index 311399d..0000000 --- a/project/.htaccess +++ /dev/null @@ -1,2 +0,0 @@ -Options +ExecCGI -DirectoryIndex list.cgi.pl index.html diff --git a/project/FordFulk/index.html.pl b/project/FordFulk/Index.html.pl similarity index 74% rename from project/FordFulk/index.html.pl rename to project/FordFulk/Index.html.pl index 5134e2c..79bc547 100755 --- a/project/FordFulk/index.html.pl +++ b/project/FordFulk/Index.html.pl @@ -18,19 +18,22 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +package project::FordFulk::Index; require 5.6.0; # at least 'use warnings;' but we need some 5.6.0+ modules anyway -use vars qw($VERSION $CVS_ID); -$VERSION=do { my @r=(q$Revision$=~/\d+/g); sprintf "%d.".("%03d"x$#r),@r; }; -$CVS_ID=q$Id$; +our $VERSION=do { my @r=(q$Revision$=~/\d+/g); sprintf "%d.".("%03d"x$#r),@r; }; +our $CVS_ID=q$Id$; use strict; use warnings; +BEGIN{ open F,"Makefile"; our $top_dir=pop @{[split /\s/,(grep /^top_srcdir/,)[0]]}; eval "use lib '$top_dir'"; close F; } use My::Web; +use My::Project; use project::FordFulk::ListItem; -My::Web->init_project( - "ListItem"=>\%My::Project::FordFulk::ListItem, +My::Project->init_project( + "__PACKAGE__"=>__PACKAGE__, + "ListItem"=>\@project::FordFulk::ListItem::ListItem, ); print <<'HERE'; diff --git a/project/FordFulk/ListItem.pm b/project/FordFulk/ListItem.pm index 055e13e..5e5f66e 100755 --- a/project/FordFulk/ListItem.pm +++ b/project/FordFulk/ListItem.pm @@ -18,16 +18,15 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -package My::Project::FordFulk; +package project::FordFulk::ListItem; require 5.6.0; # at least 'use warnings;' but we need some 5.6.0+ modules anyway -use vars qw($VERSION $CVS_ID); -$VERSION=do { my @r=(q$Revision$=~/\d+/g); sprintf "%d.".("%03d"x$#r),@r; }; -$CVS_ID=q$Id$; +our $VERSION=do { my @r=(q$Revision$=~/\d+/g); sprintf "%d.".("%03d"x$#r),@r; }; +our $CVS_ID=q$Id$; use strict; use warnings; -our %ListItem=( +our @ListItem=( "name"=>"Ford-Fulkenson Algorithm Demonstration", "priority"=>5, "download"=>"FordFulk/FordFulk.zip", diff --git a/project/FordFulk/Makefile.am b/project/FordFulk/Makefile.am index b063480..0c1658b 100644 --- a/project/FordFulk/Makefile.am +++ b/project/FordFulk/Makefile.am @@ -20,7 +20,4 @@ include $(top_srcdir)/Makefile-head.am EXTRA_DIST+= \ ListItem.pm \ - index.html.pl - -noinst_DATA+= \ - index.html + Index.html.pl diff --git a/project/Heat/index.html.pl b/project/Heat/Index.html.pl similarity index 74% rename from project/Heat/index.html.pl rename to project/Heat/Index.html.pl index 4fd1ad1..61ed75e 100755 --- a/project/Heat/index.html.pl +++ b/project/Heat/Index.html.pl @@ -18,19 +18,22 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +package project::Heat::Index; require 5.6.0; # at least 'use warnings;' but we need some 5.6.0+ modules anyway -use vars qw($VERSION $CVS_ID); -$VERSION=do { my @r=(q$Revision$=~/\d+/g); sprintf "%d.".("%03d"x$#r),@r; }; -$CVS_ID=q$Id$; +our $VERSION=do { my @r=(q$Revision$=~/\d+/g); sprintf "%d.".("%03d"x$#r),@r; }; +our $CVS_ID=q$Id$; use strict; use warnings; +BEGIN{ open F,"Makefile"; our $top_dir=pop @{[split /\s/,(grep /^top_srcdir/,)[0]]}; eval "use lib '$top_dir'"; close F; } use My::Web; +use My::Project; use project::Heat::ListItem; -My::Web->init_project( - "ListItem"=>\%My::Project::Heat::ListItem, +My::Project->init_project( + "__PACKAGE__"=>__PACKAGE__, + "ListItem"=>\@project::Heat::ListItem::ListItem, ); print <<'HERE'; diff --git a/project/Heat/ListItem.pm b/project/Heat/ListItem.pm index 8781cff..5440adf 100755 --- a/project/Heat/ListItem.pm +++ b/project/Heat/ListItem.pm @@ -18,16 +18,15 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -package My::Project::Heat; +package project::Heat::ListItem; require 5.6.0; # at least 'use warnings;' but we need some 5.6.0+ modules anyway -use vars qw($VERSION $CVS_ID); -$VERSION=do { my @r=(q$Revision$=~/\d+/g); sprintf "%d.".("%03d"x$#r),@r; }; -$CVS_ID=q$Id$; +our $VERSION=do { my @r=(q$Revision$=~/\d+/g); sprintf "%d.".("%03d"x$#r),@r; }; +our $CVS_ID=q$Id$; use strict; use warnings; -our %ListItem=( +our @ListItem=( "name"=>"Heat Distribution Simulation", "priority"=>5, "download"=>"Heat/Heat.zip", diff --git a/project/Heat/Makefile.am b/project/Heat/Makefile.am index b25e8c7..88d647c 100644 --- a/project/Heat/Makefile.am +++ b/project/Heat/Makefile.am @@ -20,7 +20,4 @@ include $(top_srcdir)/Makefile-head.am EXTRA_DIST+= \ ListItem.pm \ - index.html.pl - -noinst_DATA+= \ - index.html + Index.html.pl diff --git a/project/list.cgi.pl b/project/Index.html.pl similarity index 87% rename from project/list.cgi.pl rename to project/Index.html.pl index eeadeef..2e42b10 100755 --- a/project/list.cgi.pl +++ b/project/Index.html.pl @@ -18,24 +18,24 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +package project::Index; require 5.6.0; # at least 'use warnings;' but we need some 5.6.0+ modules anyway -use vars qw($VERSION $CVS_ID); -$VERSION=do { my @r=(q$Revision$=~/\d+/g); sprintf "%d.".("%03d"x$#r),@r; }; -$CVS_ID=q$Id$; +our $VERSION=do { my @r=(q$Revision$=~/\d+/g); sprintf "%d.".("%03d"x$#r),@r; }; +our $CVS_ID=q$Id$; use strict; use warnings; -use lib qw(/home/short/lib/perl5/site_perl/5.6.0/i386-linux /home/short/lib/perl5/site_perl/5.6.0 /home/short/lib/perl5/site_perl/i386-linux /home/short/lib/perl5/site_perl /home/short/lib/perl5/5.6.0/i386-linux /home/short/lib/perl5/5.6.0 /home/short/lib/perl5/i386-linux /home/short/lib/perl5); - -use lib "../"; +BEGIN{ open F,"Makefile"; our $top_dir=pop @{[split /\s/,(grep /^top_srcdir/,)[0]]}; eval "use lib '$top_dir'"; close F; } use My::Web; -require CGI; +require 'CGI'; +require 'My::Project'; use constant ENTRIES=>"CVS/Entries"; use constant ENTRIES_LOG=>"CVS/Entries.Log"; My::Web->init( + "__PACKAGE__"=>__PACKAGE__, "title"=>'Project List', ); My::Web->heading(); @@ -45,7 +45,7 @@ my $CGI=CGI->new(); print <<'HERE';

Project List of Jan Kratochvil

-

+