/[suikacvs]/test/html-webhacc/mkcatalog.pl
Suika

Contents of /test/html-webhacc/mkcatalog.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Mon Jul 16 08:38:48 2007 UTC (17 years, 4 months ago) by wakaba
Branch: MAIN
File MIME type: text/plain
++ ChangeLog	16 Jul 2007 08:38:44 -0000
	* Makefile (all): |cc-msg.en.txt| is added to the list of
	dependency.
	(cc-msg.en.txt): New rule.

	* mkcatalog.pl: New Perl script.

	* cc-msg.en.txt: Now this file is generated by
	the rule described in |Makefile|.

	* cc.cgi (HTML mode): Set |charset| as |ISO-8859-1|
	if not specified, for now.
	(get_text): Replace |<var>$/n/</var>|, not just |$/n/|,
	to variable.

	* error-description-source.xml: All entries
	in |cc-msg.en.txt| are now described as XML data.

	* mkdescription.pl: Print the result by |inner_html| DOM
	attribute.  Put |level| attribute value, if any, before |name|
	attribute value.  Allow missing of |desc| attribute.
	Ignore any |catalog| element.

2007-07-16  Wakaba  <wakaba@suika.fam.cx>

1 wakaba 1.1 #!/usr/bin/perl
2     use strict;
3     use encoding 'us-ascii', STDOUT => 'utf-8';
4    
5     use lib qw[/home/httpd/html/www/markup/html/whatpm
6     /home/wakaba/work/manakai/lib
7     /home/wakaba/public_html/-temp/wiki/lib];
8    
9     my $HTML_NS = q<http://www.w3.org/1999/xhtml>;
10     my $SRC_NS = q<http://suika.fam.cx/~wakaba/archive/2007/wdcc-desc/>;
11     my $XML_NS = q<http://www.w3.org/XML/1998/namespace>;
12    
13     require Message::DOM::DOMImplementation;
14     my $dom = Message::DOM::DOMImplementation->new;
15    
16     my $doc;
17     {
18     my $source_file_name = shift or die "$0: No source file specified\n";
19     open my $source_file, '<', $source_file_name
20     or die "$0: $source_file_name: $!";
21     require Message::DOM::XMLParserTemp;
22     $doc = Message::DOM::XMLParserTemp->parse_byte_stream
23     ($source_file => $dom, undef, charset => 'utf-8');
24     $doc->manakai_is_html (1);
25     }
26    
27     my $target_lang = 'en';
28     my @node = (@{$doc->child_nodes});
29     while (@node) {
30     my $node = shift @node;
31     if ($node->node_type == $node->ELEMENT_NODE) {
32     if ($node->namespace_uri eq $HTML_NS) {
33     unshift @node, @{$node->child_nodes};
34     } elsif ($node->namespace_uri eq $SRC_NS) {
35     if ($node->manakai_local_name eq 'item') {
36     my $message;
37     for (@{$node->child_nodes}) {
38     if ($_->node_type == $_->ELEMENT_NODE and
39     $_->namespace_uri eq $SRC_NS) {
40     if ($_->manakai_local_name eq 'message') {
41     if ($_->get_attribute_ns ($XML_NS, 'lang') eq $target_lang) {
42     $message = $_;
43     next;
44     } else {
45     $message ||= $_;
46     }
47     }
48     }
49     }
50    
51     my $entry = [];
52     push @$entry, $node->get_attribute_ns (undef, 'name');
53     my $level = $node->get_attribute_ns (undef, 'level');
54     $entry->[-1] = $level . ':' . $entry->[-1] if defined $level;
55     push @$entry, $node->get_attribute_ns (undef, 'class');
56     push @$entry, $message->inner_html;
57     s/\s+/ /g for @$entry;
58     print join ';', @$entry;
59     print "\n";
60     } elsif ($node->manakai_local_name eq 'catalog') {
61     print $node->text_content, "\n";
62     } else {
63     warn "$0: ", $node->manakai_local_name, " is not supported\n";
64     }
65     }
66     }
67     }

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24