Commits

Shlomi Fish  committed 706e7b2

Add the .htaccess for the fortunes directory.

For the link rel=canonical stuff.

  • Participants
  • Parent commits 0f704fd

Comments (0)

Files changed (5)

 t2/humour/fortunes/fortunes-shlomif.spec
 t2/humour/fortunes/friends
 t2/humour/fortunes/joel-on-software
+t2/humour/fortunes/my_htaccess.conf
 t2/humour/fortunes/nyh-sigs
 t2/humour/fortunes/osp_rules
 t2/humour/fortunes/paul-graham
 T2_SRC_FORTUNE_SHOW_SCRIPT = $(T2_SRC_DIR)/$(FORTUNES_DIR)/show.cgi
 T2_DEST_FORTUNE_SHOW_SCRIPT_TXT = $(T2_DEST_FORTUNES_DIR)/show-cgi.txt
 
-fortunes-target: $(FORTUNES_TARGET) fortunes-compile-xmls $(T2_DEST_SHOW_CGI) $(T2_DEST_FORTUNE_SHOW_SCRIPT_TXT)
+T2_FORTUNES_DIR_HTACCESS = $(T2_DEST_FORTUNES_DIR)/.htaccess
+
+fortunes-target: $(FORTUNES_TARGET) fortunes-compile-xmls $(T2_DEST_SHOW_CGI) $(T2_DEST_FORTUNE_SHOW_SCRIPT_TXT) $(T2_FORTUNES_DIR_HTACCESS)
+
+$(T2_FORTUNES_DIR_HTACCESS): $(T2_FORTUNES_DIR)/my_htaccess.conf
+	cp -f $< $@
 
 # t2 macros
 

File t2/humour/fortunes/Makefile

 
 .PHONY: all test html distdir upload list_files
 
-all: dist test
+all: dist test gen_htaccess
 
 $(DATS):: %.dat : %
 	PATH="$$PATH:/usr/sbin" strfile $<
 %.show:
 	@echo "$* = $($*)"
 
+gen_htaccess: my_htaccess.conf
 
+my_htaccess.conf: gen-htaccess.pl fortunes-list.mak
+	perl $< -o $@ $(FILES)

File t2/humour/fortunes/gen-htaccess.pl

+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use IO::Handle;
+use Getopt::Long qw(GetOptions);
+
+my $output_filename;
+GetOptions
+(
+    'o=s' => \$output_filename,
+);
+
+if (! $output_filename )
+{
+    die "Output filename not specified.";
+}
+
+my @basenames = @ARGV;
+
+open my $o, '>', $output_filename;
+
+$o->print("AddType text/plain .txt\n");
+foreach my $base (@basenames)
+{
+    foreach my $ext ('', '.xml', '.xhtml')
+    {
+    $o->print(<<"EOF");
+<Files "$base$ext">
+        Header add Link "<http://www.shlomifish.org/humour/fortunes/$base.html>; rel=\"canonical\""
+</Files>
+EOF
+    }
+}

File t2/humour/fortunes/ver.txt

-0.18.42
+0.18.43