Commits

Anonymous committed 21d909d

Add the SQLite generation to the makefile.

Comments (0)

Files changed (2)

 FORTUNES_TEXTS = $(patsubst %.xml,%,$(FORTUNES_XMLS_SRC))
 FORTUNES_ATOM_FEED = $(T2_FORTUNES_DIR)/fortunes-shlomif-all.atom
 FORTUNES_RSS_FEED = $(T2_FORTUNES_DIR)/fortunes-shlomif-all.rss
+FORTUNES_SQLITE_DB = $(T2_FORTUNES_DIR)/fortunes-shlomif-lookup.sqlite3
 
-fortunes-compile-xmls: $(FORTUNES_XHTMLS) $(FORTUNES_TEXTS) $(FORTUNES_ATOM_FEED) $(FORTUNES_RSS_FEED) 
+fortunes-compile-xmls: $(FORTUNES_XHTMLS) $(FORTUNES_TEXTS) $(FORTUNES_ATOM_FEED) $(FORTUNES_RSS_FEED) $(FORTUNES_SQLITE_DB)
 
 # The touch is to make sure we compile the .html.wml again.
 
 $(FORTUNES_ATOM_FEED) $(FORTUNES_RSS_FEED): $(T2_FORTUNES_DIR)/generate-web-feeds.pl $(FORTUNES_XMLS_SRC)
 	perl $< --atom $(FORTUNES_ATOM_FEED) --rss $(FORTUNES_RSS_FEED) --dir $(T2_FORTUNES_DIR)
 
+$(FORTUNES_SQLITE_DB): $(T2_FORTUNES_DIR)/populate-sqlite-database.pl $(FORTUNES_XHTMLS)
+	perl $<
+
 $(DOCBOOK4_INSTALLED_INDIVIDUAL_XHTMLS_CSS): %: $(DOCMAKE_STYLE_CSS)
 	cp -f $< $@
 

t2/humour/fortunes/populate-sqlite-database.pl

 
 $dbh->do("CREATE TABLE fortune_cookies (id INTEGER PRIMARY KEY ASC, str_id VARCHAR(255), text TEXT)");
 
+$dbh->do("CREATE UNIQUE INDEX fortune_strings ON fortune_cookies ( str_id )");
+
 my $insert_sth = $dbh->prepare("INSERT INTO fortune_cookies (str_id, text) VALUES(?, ?)");
 
 my @lines = io->file("$script_dir/fortunes-list.mak")->getlines();
 
 foreach my $basename (@file_bases)
 {
-    my $tree = HTML::TreeBuilder::LibXML->new_from_file("./dest/t2-homepage/humour/fortunes/$basename.html");
+    my $tree = HTML::TreeBuilder::LibXML->new_from_file("./lib/fortunes/xhtmls/$basename.xhtml");
 
     my $nodes_list = $tree->findnodes(q{//div[@class = "fortune"]});
 
     while (defined(my $node = shift(@$nodes_list)))
     {
         printf ("%-70s\r", "$basename $idx/$count");
-        my $id = $node->findnodes(q{//h3[@id]})->[0]->id;
+        my $id = $node->findnodes(q{descendant::h3[@id]})->[0]->id;
 
         if (! $id)
         {