Commits

Anonymous committed 93f6bb7

Moved to show.cgi.

  • Participants
  • Parent commits 5caf1af

Comments (0)

Files changed (4)

 include lib/make/docbook/sf-homepage-docbooks-generated.mak
 
 SITE_SOURCE_INSTALL_TARGET = $(T2_DEST)/meta/site-source/INSTALL
-FORTUNES_TARGET =  $(T2_DEST)/$(FORTUNES_DIR)/index.html
+T2_DEST_FORTUNES_DIR = $(T2_DEST)/$(FORTUNES_DIR)
+FORTUNES_TARGET =  $(T2_DEST_FORTUNES_DIR)/index.html
 
 site-source-install: $(SITE_SOURCE_INSTALL_TARGET)
 
-fortunes-target: $(FORTUNES_TARGET) fortunes-compile-xmls
+T2_DEST_SHOW_CGI = $(T2_DEST_FORTUNES_DIR)/show.cgi
+
+fortunes-target: $(FORTUNES_TARGET) fortunes-compile-xmls $(T2_DEST_SHOW_CGI)
 
 # t2 macros
 
 RSYNC = rsync --progress --verbose --rsh=ssh
 
-T2_DEST_FORTUNES = $(patsubst %,$(T2_DEST)/$(FORTUNES_DIR)/%,$(FORTUNES_ARCS_LIST))
+T2_DEST_FORTUNES = $(patsubst %,$(T2_DEST_FORTUNES_DIR)/%,$(FORTUNES_ARCS_LIST))
 
 $(T2_DEST_FORTUNES): $(T2_DEST)/%: $(T2_SRC_DIR)/%
 	cp -f $< $@
 
+$(T2_DEST_SHOW_CGI): $(T2_DEST)/%: $(T2_SRC_DIR)/%
+	cp -f $< $@
+	chmod +x $@
+
 copy_fortunes: $(T2_DEST_FORTUNES)
 
 upload_deps: all
 lib/presentations/spork/Vim/beginners/Spork.slides: lib/presentations/spork/Vim/beginners/Spork.slides.source
 	cat $< | perl -pe 's!^\+!!' > $@
 
-GEN_STYLE_CSS_FILES = style.css style-2008.css
+GEN_STYLE_CSS_FILES = style.css style-2008.css fortunes.css
 
 T2_CSS_TARGETS = $(patsubst %,$(T2_DEST)/%,$(GEN_STYLE_CSS_FILES))
 VIPE_CSS_TARGETS = $(patsubst %,$(VIPE_DEST)/%,$(GEN_STYLE_CSS_FILES))
 use IO::All;
 
 my $text = io("include.mak")->slurp();
-$text =~ s!^(T2_DOCS = .*)humour/fortunes/index.html!$1!m;
+$text =~ s!^(T2_DOCS = .*)humour/fortunes/index\.html!$1!m;
+$text =~ s!^(T2_IMAGES = .*)humour/fortunes/show\.cgi!$1!m;
 $text =~ s{ *humour/fortunes/\S+\.tar\.gz}{}g;
 io("include.mak")->print($text);
 

t2/humour/fortunes/display-fortune.cgi

-#!/usr/bin/perl
-
-use strict;
-use warnings;
-
-use CGI;
-
-use File::Spec::Functions qw( catpath splitpath rel2abs );
-
-# The Directory containing the script.
-my $script_dir = catpath( ( splitpath( rel2abs $0 ) )[ 0, 1 ] );
-
-my $db_base_name = "fortunes-shlomif-lookup.sqlite3";
-
-my $dbh = DBI->connect("dbi:SQLite:dbname=$full_db_path","","");
-
-my $select_sth = $dbh->prepare(
-    q{SELECT text FROM fortune_cookies WHERE str_id = ?}
-);
-
-my $cgi = CGI->new;
-
-my $str_id = $cgi->param('id');
-
-sub _main
-{
-    if (! $str_id)
-    {
-        print $cgi->header();
-        print <<"EOF";
-<?xml version="1.0" encoding="utf-8"?>
-<!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-US">
-<head>
-<title>Unknown fortune ID</title>
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-</head>
-<body>
-
-<h1>Error! Must specify id parameter</h1>
-
-<p>
-The ID parameter must be specified.
-</p>
-</body>
-</html>
-EOF
-        return;
-    }
-
-    my $rv = $select_sth->execute($str_id);
-
-    my ($html_text) = $select_sth->fetchrow_array;
-
-    if (! $html_text)
-    {
-        print $cgi->header();
-
-        print <<"EOF";
-<?xml version="1.0" encoding="utf-8"?>
-<!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-US">
-<head>
-<title>Unknown fortune ID</title>
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-</head>
-<body>
-
-<h1>URL not found</h1>
-
-<p>
-The fortune ID @{[CGI::escapeHTML($str_id)]} is not recognised.
-If you've reached this URL and think it should
-be defined please contact <a href="mailto:shlomif\@shlomifish.org">Shlomi
-Fish (the Webmaster)</a> and let him know of this problem.
-</p>
-</body>
-</html>
-EOF
-        return;
-    }
-
-    print <<"EOF";
-<?xml version="1.0" encoding="utf-8"?>
-<!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-US">
-<head>
-<title>Unknown fortune ID</title>
-<link rel="stylesheet" href="/fortunes.css" type="text/css" media="screen, projection" />
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-</head>
-<body>
-
-<div class="fortunes_list">
-$html_text
-</div>
-
-</body>
-</html>
-EOF
-
-    return;
-}
-
-_main();

t2/humour/fortunes/show.cgi

+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use CGI;
+
+use File::Spec::Functions qw( catpath splitpath rel2abs );
+
+# The Directory containing the script.
+my $script_dir = catpath( ( splitpath( rel2abs $0 ) )[ 0, 1 ] );
+
+my $db_base_name = "fortunes-shlomif-lookup.sqlite3";
+
+my $dbh = DBI->connect("dbi:SQLite:dbname=$full_db_path","","");
+
+my $select_sth = $dbh->prepare(
+    q{SELECT text FROM fortune_cookies WHERE str_id = ?}
+);
+
+my $cgi = CGI->new;
+
+my $str_id = $cgi->param('id');
+
+sub _main
+{
+    if (! $str_id)
+    {
+        print $cgi->header();
+        print <<"EOF";
+<?xml version="1.0" encoding="utf-8"?>
+<!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-US">
+<head>
+<title>Unknown fortune ID</title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+</head>
+<body>
+
+<h1>Error! Must specify id parameter</h1>
+
+<p>
+The ID parameter must be specified.
+</p>
+</body>
+</html>
+EOF
+        return;
+    }
+
+    my $rv = $select_sth->execute($str_id);
+
+    my ($html_text) = $select_sth->fetchrow_array;
+
+    if (! $html_text)
+    {
+        print $cgi->header();
+
+        print <<"EOF";
+<?xml version="1.0" encoding="utf-8"?>
+<!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-US">
+<head>
+<title>Unknown fortune ID</title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+</head>
+<body>
+
+<h1>URL not found</h1>
+
+<p>
+The fortune ID @{[CGI::escapeHTML($str_id)]} is not recognised.
+If you've reached this URL and think it should
+be defined please contact <a href="mailto:shlomif\@shlomifish.org">Shlomi
+Fish (the Webmaster)</a> and let him know of this problem.
+</p>
+</body>
+</html>
+EOF
+        return;
+    }
+
+    print <<"EOF";
+<?xml version="1.0" encoding="utf-8"?>
+<!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-US">
+<head>
+<title>Unknown fortune ID</title>
+<link rel="stylesheet" href="/fortunes.css" type="text/css" media="screen, projection" />
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+</head>
+<body>
+
+<div class="fortunes_list">
+$html_text
+</div>
+
+</body>
+</html>
+EOF
+
+    return;
+}
+
+_main();