• R/O
  • SSH
  • HTTPS

sotp: Commit


Commit MetaInfo

Revision107 (tree)
Time2009-08-30 17:15:33
Authormiyabe

Log Message

(empty log message)

Change Summary

Incremental Difference

--- reiki/trunk/tools/make-pdf.pl (revision 106)
+++ reiki/trunk/tools/make-pdf.pl (revision 107)
@@ -4,10 +4,13 @@
44 use utf8;
55 use XML::SAX::ParserFactory;
66 use XML::LibXSLT;
7+use htdocs::lib::Ajino;
78
8-my $dir = $ARGV[0];
99 my $xslt = XML::LibXSLT->new();
10+$xslt->register_function("urn:perl", "filter", \&aj_xslt_filter);
1011 my $stylesheet = $xslt->parse_stylesheet_file('htdocs/style/pdf-statute.xsl');
12+
13+my $dir = $ARGV[0];
1114 my $pdfWorkDir = "$dir/_pdf";
1215 my $pdfDir = "$dir/pdf";
1316 mkdir($pdfWorkDir);
@@ -21,11 +24,11 @@
2124 use htdocs::lib::Ajino;
2225 require 'htdocs/lib/PDF.pm';
2326
24- my $chapterHead = 0;
25-
2627 sub new {
2728 my $class = shift;
2829 my $self = new XML::SAX::Base;
30+ $self->{partHead} = 0;
31+ $self->{chapterHead} = 0;
2932 return bless $self;
3033 }
3134
@@ -32,21 +35,83 @@
3235 sub start_element {
3336 my ( $self, $elem ) = @_;
3437 my $attrs = $elem->{Attributes};
35- if ($elem->{Name} eq "r:chapter") {
38+
39+ if ($self->{partHead}) {
40+ if ($elem->{Name} eq "r:marker") {
41+ $self->{inMarker} = 1;
42+ }
43+ elsif ($elem->{Name} eq "r:text") {
44+ $self->{inText} = 1;
45+ }
46+ }
47+
48+ if ($elem->{Name} eq "r:part") {
3649 # 編
37- $chapterHead = 1;
50+ $self->{partHead} = 1;
3851 }
52+ elsif ($elem->{Name} eq "r:chapter") {
53+ # 章
54+ $self->{chapterHead} = 1;
55+ }
3956 elsif ($elem->{Name} eq "r:statute") {
4057 my $file = $attrs->{'{}file'}->{Value};
4158 print "$dir/content/$file\n";
4259
43- if ($chapterHead) {
60+ my %params = (file => "'$file'");
61+ if ($self->{partHead}) {
4462 # 編の扉
45- $chapterHead = 0;
63+ $self->{partHead} = 0;
64+
65+ my $session = get_cssj_session();
66+ $file =~ /(.*)-/;
67+ open(CONTENT, ">$pdfWorkDir/$1.pdf");
68+ $session->set_output(*CONTENT);
69+ $session->start_main(*STDOUT, '.', 'text/html', 'UTF-8');
70+ binmode(STDOUT);
71+my $html = "
72+<html>
73+ <head>
74+ <title>$self->{partMarker} $self->{partTitle}</title>
75+ <style type='text/css'>
76+\@page {
77+ margin: 0;
78+}
79+h1 {
80+ text-align: center;
81+ margin-top: 23mm;
82+}
83+body {
84+ background-color: -cssj-gray(80%);
85+ margin: -3mm;
86+ padding-top: 25mm 19mm 25mm 31mm;
87+ page-break-after: left;
88+}
89+ </style>
90+ </head>
91+ <body>
92+ <h1>$self->{partMarker} $self->{partTitle}</h1>
93+ </body>
94+</html>
95+";
96+ utf8::encode($html);
97+ print $html;
98+ $session->end_main(*STDOUT);
99+ $session->close();
100+ close(CONTENT);
46101 }
102+ if ($self->{chapterHead}) {
103+ # 章の扉
104+ $self->{chapterHead} = 0;
105+ $params{chapterHead} = 1;
106+ }
47107
108+ # 加除しやすくするためのページ隅のマーク
109+ # TODO ノ項
110+ $file =~ /.*-(.*)$/;
111+ $params{'markerOffset'} = $1 % 20 * 10 - 22;
112+
48113 # 例規
49- my $results = $stylesheet->transform_file("$dir/content/$file.xml", file => "'$file'");
114+ my $results = $stylesheet->transform_file("$dir/content/$file.xml", %params);
50115
51116 my $session = get_cssj_session();
52117 open(CONTENT, ">$pdfWorkDir/$file.pdf");
@@ -73,7 +138,6 @@
73138 binmode(STDOUT);
74139 $stylesheet->output_fh( $results, *STDOUT );
75140 $session->end_main(*STDOUT);
76-
77141 $session->close();
78142 print META "<number-of-pages>$pageNumber</number-of-pages>\n";
79143 print META "</meta>\n";
@@ -81,6 +145,22 @@
81145 close(CONTENT);
82146 }
83147 }
148+
149+ sub characters {
150+ my ( $self, $text ) = @_;
151+ $text = $text->{Data};
152+ utf8::decode($text);
153+ if ($self->{partHead}) {
154+ if ($self->{inMarker}) {
155+ $self->{partMarker} = $text;
156+ $self->{inMarker} = 0;
157+ }
158+ elsif ($self->{inText}) {
159+ $self->{partTitle} = $text;
160+ $self->{inText} = 0;
161+ }
162+ }
163+ }
84164 }
85165
86166 my $parser = XML::SAX::ParserFactory->parser();
--- reiki/trunk/htdocs/style/common-statute.xsl (revision 106)
+++ reiki/trunk/htdocs/style/common-statute.xsl (revision 107)
@@ -2,7 +2,8 @@
22 <xsl:stylesheet version="1.0"
33 xmlns:html="http://www.w3.org/1999/xhtml"
44 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5- xmlns:r="http://www.cssj.jp/ns/reiki">
5+ xmlns:r="http://www.cssj.jp/ns/reiki"
6+ xmlns:perl="urn:perl">
67 <xsl:param name="file" />
78 <xsl:param name="referer" />
89 <xsl:output method="html"
@@ -49,15 +50,18 @@
4950 <div class="date"><xsl:value-of select="$date"/>現在</div>
5051 <hr/>
5152 <div class="navigator">
52- <a href="index.html">体系目次</a>
53- <a href="aiueo.html">五十音目次</a>
53+ <a href="index.html#{$file}">体系目次</a>
54+ <a href="aiueo.html#{$file}">五十音目次</a><br/>
55+ <form action="../search/" class="search">
56+ <input type="text" name="q" /><button type="submit">検索</button>
57+ </form>
5458 </div>
5559 <hr/>
5660 </xsl:template>
5761
5862 <xsl:template match="r:revision">
59- <xsl:value-of select="@date" />
60- <xsl:value-of select="text()" />
63+ <xsl:apply-templates select="@date" mode="att-text" />
64+ <xsl:apply-templates mode="html" />
6165 </xsl:template>
6266
6367 <!-- 体系リンク -->
@@ -68,10 +72,8 @@
6872 </xsl:template>
6973 <xsl:template match="r:part|r:chapter|r:section|r:subsection|r:division" mode="navigation">
7074 <xsl:if test="position()&gt;=2"> &gt; </xsl:if>
71- <a href="index.html#{$file}">
72- <b><xsl:value-of select="r:marker/text()" /></b>
73- <xsl:value-of select="r:text/text()" />
74- </a>
75+ <b><xsl:value-of select="r:marker/text()" /></b>
76+ <xsl:value-of select="r:text/text()" />
7577 </xsl:template>
7678 <xsl:template match="node()" mode="navigation" priority="-1"/>
7779
@@ -309,8 +311,8 @@
309311 <!-- 制定 -->
310312 <xsl:template match="r:revision" mode="established">
311313 <div class="date">
312- <xsl:value-of select="@date" /><br />
313- <xsl:value-of select="text()" />
314+ <xsl:apply-templates select="@date" mode="att-text" /><br/>
315+ <xsl:apply-templates mode="html" />
314316 </div>
315317 </xsl:template>
316318
@@ -370,5 +372,14 @@
370372 <xsl:value-of select="document(concat('../data/pdf/',$file,'.pdf.meta.xml'))/meta/number-of-pages/text()" />頁
371373 </div>
372374 </xsl:template>
375+
376+ <!-- テキスト処理 -->
377+ <xsl:template match="text()" mode="html" priority="1">
378+ <xsl:value-of select="perl:filter(.)" disable-output-escaping="yes"/>
379+ </xsl:template>
380+
381+ <xsl:template match="@*" mode="att-text" priority="1">
382+ <xsl:value-of select="perl:filter(.)" disable-output-escaping="yes"/>
383+ </xsl:template>
373384
374385 </xsl:stylesheet>
--- reiki/trunk/htdocs/style/pdf-statute.css (revision 106)
+++ reiki/trunk/htdocs/style/pdf-statute.css (revision 107)
@@ -13,6 +13,11 @@
1313 margin-right: 28mm;
1414 }
1515
16+/* 最終ページは常に左に来させるため。 */
17+body {
18+ page-break-after: left;
19+}
20+
1621 body,td {
1722 font: normal 8pt/1.35 IPAPMincho;
1823 text-align: justify;
@@ -48,6 +53,12 @@
4853 text-decoration: none;
4954 color: Black;
5055 }
56+span.number {
57+ display: inline-block;
58+ min-width: 1.2em;
59+ text-align: center;
60+ text-indent: 0;
61+}
5162
5263 #nombre-left, #nombre-right {
5364 bottom: -10mm;
@@ -90,6 +101,21 @@
90101 -cssj-page-content: header-right right;
91102 text-align: right;
92103 }
104+#marker-left,
105+#marker-right {
106+ width: 10mm;
107+ height: 10mm;
108+ background-color: -cssj-gray(80%);
109+}
110+#marker-left {
111+ -cssj-page-content: marker-left left;
112+ left: -19mm;
113+}
114+
115+#marker-right {
116+ -cssj-page-content: marker-right right;
117+ right: -19mm;
118+}
93119 span.h1 {
94120 padding-left: 1em;
95121 }
@@ -118,11 +144,11 @@
118144 }
119145
120146 img.lb {
121- left: -.3em;
147+ left: -.5em;
122148 }
123149
124150 img.rb {
125- right: -.3em;
151+ right: -.5em;
126152 }
127153
128154 span.h2:before {
@@ -130,13 +156,11 @@
130156 }
131157
132158 div.established {
133- width: 10em;
134- text-align: justify;
135- -cssj-text-align-last: justify;
136- margin-left: auto;
159+ float: right;
137160 position: relative;
138161 }
139162 table.revisions {
163+ clear: both;
140164 float: right;
141165 margin: 1em 2em 0 1em;
142166 border-spacing: .25em;
@@ -149,11 +173,6 @@
149173 font-size: 6pt;
150174 border: none;
151175 }
152-span.revision span {
153- display: inline-block;
154- width: 1.2em;
155- text-align: center;
156-}
157176 div.main ul {
158177 clear: both;
159178 margin: 0;
@@ -176,9 +195,7 @@
176195 }
177196 div.main h1 {
178197 white-space: nowrap;
179- height: 0;
180- margin: 0;
181- visibility: hidden;
198+ margin: 5mm 0;
182199 }
183200 div.main h2 {
184201 font-size: 12pt;
--- reiki/trunk/htdocs/style/pdf-statute.xsl (revision 106)
+++ reiki/trunk/htdocs/style/pdf-statute.xsl (revision 107)
@@ -6,6 +6,8 @@
66 xmlns:cssj="http://www.cssj.jp/ns/cssjml">
77 <xsl:import href="common-statute.xsl" />
88 <xsl:param name="file" />
9+ <xsl:param name="chapterHead" />
10+ <xsl:param name="markerOffset" />
911
1012 <xsl:template match="/r:statute">
1113 <html>
@@ -12,6 +14,10 @@
1214 <head>
1315 <style type="text/css">
1416 @import 'style/pdf-statute.css';
17+ #marker-left,
18+ #marker-right {
19+ top: <xsl:value-of select="$markerOffset"/>mm;
20+ }
1521 </style>
1622 <xsl:call-template name="head" />
1723 </head>
@@ -26,11 +32,13 @@
2632 <div id="nombre-right"><xsl:value-of select="$page"/>-</div>
2733 <div id="header-left"><span class="h1"></span><span class="h2"><img src="style/pdf/lb.svgz" class="lb"/><img src="style/pdf/rb.svgz" class="rb"/></span></div>
2834 <div id="header-right"><span class="h1"></span><span class="h2"><img src="style/pdf/lb.svgz" class="lb"/><img src="style/pdf/rb.svgz" class="rb"/></span></div>
35+<div id="marker-left"></div>
36+<div id="marker-right"></div>
37+<xsl:if test="$chapterHead">
2938 <h1>
30-<xsl:apply-templates select="r:statutes/r:part/r:marker/node()" mode="html"/>
31- 
32-<xsl:apply-templates select="r:statutes/r:part/r:text/node()" mode="html"/>
39+<xsl:apply-templates select="r:statutes/r:chapter/r:marker/node()" mode="html"/> <xsl:apply-templates select="r:statutes/r:chapter/r:text/node()" mode="html"/>
3340 </h1>
41+</xsl:if>
3442 <h2>○<xsl:apply-templates select="r:title/node()" mode="html"/></h2>
3543 <xsl:apply-templates select="r:revisions/r:revision[@date][1]" mode="established"/>
3644 <xsl:apply-templates select="r:revisions" mode="revisions"/>
@@ -50,8 +58,8 @@
5058 <div class="established">
5159 <img src="style/pdf/lb.svgz" class="lb"/>
5260 <img src="style/pdf/rb.svgz" class="rb"/>
53- <xsl:value-of select="@date" /><br />
54- <xsl:value-of select="text()" />
61+ <xsl:apply-templates select="@date" mode="att-text" /><br/>
62+ <xsl:apply-templates mode="html" />
5563 </div>
5664 </xsl:template>
5765
@@ -78,19 +86,4 @@
7886 </xsl:if>
7987 </xsl:template>
8088
81- <!-- 日付を分解して整える -->
82- <xsl:template match="r:revision">
83- <span class="revision">
84- <xsl:choose>
85- <xsl:when test="contains(@date,'年')">
86- <xsl:value-of select="substring(substring-before(@date,'年'),1,2)" /><span><xsl:value-of select="substring(substring-before(@date,'年'),3)" /></span>年<span><xsl:value-of select="substring-after(substring-before(@date,'月'),'年')" /></span>月<span><xsl:value-of select="substring-after(substring-before(@date,'日'),'月')" /></span>日
87- </xsl:when>
88- <xsl:otherwise>
89- <xsl:value-of select="@date" />
90- </xsl:otherwise>
91- </xsl:choose>
92- <xsl:value-of select="text()" />
93- </span>
94- </xsl:template>
95-
9689 </xsl:stylesheet>
--- reiki/trunk/htdocs/style/browse-aiueo.xsl (revision 106)
+++ reiki/trunk/htdocs/style/browse-aiueo.xsl (revision 107)
@@ -392,7 +392,7 @@
392392 </xsl:template>
393393
394394 <xsl:template match="r:statute" mode="main">
395- <tr>
395+ <tr id="{@file}">
396396 <td class="title">
397397 <div class="kana"><xsl:apply-templates select="r:title/r:kana/node()" mode="html"/></div>
398398 <a href="{@file}.html"><xsl:apply-templates select="r:title/node()" mode="html"/></a>
--- reiki/trunk/htdocs/style/common-statute.css (revision 106)
+++ reiki/trunk/htdocs/style/common-statute.css (revision 107)
@@ -44,7 +44,7 @@
4444 margin: 0;
4545 }
4646 div.sidebar .date {
47- font-size: 12pt;
47+ font-size: 10pt;
4848 }
4949 div.sidebar .navigation {
5050 margin-bottom: .5em;
@@ -55,9 +55,6 @@
5555 div.sidebar .navigation b {
5656 margin-right: 1em;
5757 }
58-div.sidebar table.date {
59- float: right;
60-}
6158 div.sidebar table.date td.date {
6259 text-align: right;
6360 }
@@ -91,6 +88,9 @@
9188 div.sidebar div.outline a:visited {
9289 color: Blue;
9390 }
91+div.sidebar form.search {
92+ margin-top: .25em;
93+}
9494
9595 div.main {
9696 margin-left: 290px;
--- reiki/trunk/htdocs/style/browse-toc.css (revision 106)
+++ reiki/trunk/htdocs/style/browse-toc.css (revision 107)
@@ -6,9 +6,6 @@
66 div.sidebar b {
77 margin-right: 1em;
88 }
9-div.sidebar form.search {
10- margin-top: .25em;
11-}
129
1310 div.main {
1411 font-size: 12pt;
--- reiki/trunk/htdocs/lib/Ajino.pm (revision 106)
+++ reiki/trunk/htdocs/lib/Ajino.pm (revision 107)
@@ -13,4 +13,10 @@
1313 return DBI->connect('dbi:mysql:dbname=reiki', 'root');
1414 }
1515
16+sub aj_xslt_filter {
17+ my $node = shift;
18+ $node =~ s/([0-9]+)/<span class="number">$1<\/span>/g;
19+ return $node;
20+}
21+
1622 1;
\ No newline at end of file
--- reiki/trunk/dev/docs/memo.txt (revision 106)
+++ reiki/trunk/dev/docs/memo.txt (nonexistent)
@@ -1 +0,0 @@
1-・半角数字は2emのインラインブロックでくくる
Show on old repository browser