Commits

Anonymous committed 2cdc1c3

r5458@telaviv1: shlomi | 2008-06-08 20:33:09 +0300
Added the conversion to text.

Comments (0)

Files changed (2)

 FORTUNES_XMLS_BASE = $(addsuffix .xml,$(FORTUNES_FILES_BASE))
 FORTUNES_XMLS_SRC = $(patsubst %,$(T2_FORTUNES_DIR)/%,$(FORTUNES_XMLS_BASE))
 FORTUNES_XHTMLS = $(patsubst $(T2_FORTUNES_DIR)/%.xml,$(FORTUNES_XHTMLS_DIR)/%.xhtml,$(FORTUNES_XMLS_SRC))
+FORTUNES_TEXTS = $(patsubst %.xml,%,$(FORTUNES_XMLS_SRC))
 
-fortunes-compile-xmls: $(FORTUNES_XHTMLS)
+fortunes-compile-xmls: $(FORTUNES_XHTMLS) $(FORTUNES_TEXTS)
 
 # The touch is to make sure we compile the .html.wml again.
 
 	perl $(T2_FORTUNES_DIR)/convert-to-xhtml.pl $< $@ && \
 	touch $(patsubst %.xml,%.html.wml,$<)
 
+$(FORTUNES_TEXTS): $(T2_FORTUNES_DIR)/%: $(T2_FORTUNES_DIR)/%.xml
+	bash $(T2_FORTUNES_DIR)/run-validator.bash $< && \
+	perl $(T2_FORTUNES_DIR)/convert-to-plaintext.pl $< $@
+
 $(DOCBOOK_INSTALLED_INDIVIDUAL_XHTMLS_CSS):: %: $(DOCMAKE_STYLE_CSS)
 	cp -f $< $@

t2/humour/fortunes/convert-to-plaintext.pl

+use Cwd;
+use File::Spec;
+use String::ShellQuote;
+use strict;
+use warnings;
+
+### Definitions:
+
+my $fortune_xml_base_dir = "$ENV{HOME}/progs/perl/cpan/XML/Grammar/Fortune/trunk/XML-Grammar-Fortune/module";
+
+my $good_perl_path = "$ENV{HOME}/apps/perl/perl-5.8.8-debug/bin/perl";
+
+##########################################################################
+
+my $xml_fn = shift(@ARGV);
+my $out_fn = shift(@ARGV);
+
+my $html_fn = $xml_fn;
+
+
+my $abs_xml_fn = File::Spec->rel2abs($xml_fn);
+
+my $abs_out_fn = File::Spec->rel2abs($out_fn);
+
+my $xml_data_gen_cmd = "cd " . shell_quote($fortune_xml_base_dir) . 
+    q# ; perl -Mblib -MXML::Grammar::Fortune::ToText -e 'my ($in_fn, $out_fn) = @ARGV; open my $out, ">", $out_fn; binmode($out, ":utf8"); XML::Grammar::Fortune::ToText->new({input => shift(@ARGV), output => $out})->run();close($out)' # .  shell_quote($abs_xml_fn, $abs_out_fn);
+
+# print STDERR $xml_data_gen_cmd; exit(0);
+system($xml_data_gen_cmd);
+