| 1 |
wakaba |
1.1 |
#!/usr/bin/perl |
| 2 |
|
|
use strict; |
| 3 |
|
|
use CGI::Carp qw(fatalsToBrowser); |
| 4 |
|
|
|
| 5 |
|
|
my $data_dir_name = q[data/]; |
| 6 |
|
|
|
| 7 |
|
|
my $path = $ENV{PATH_INFO}; |
| 8 |
|
|
|
| 9 |
|
|
sub htescape ($) { |
| 10 |
|
|
my $s = shift; |
| 11 |
|
|
$s =~ s/&/&/g; |
| 12 |
|
|
$s =~ s/</</g; |
| 13 |
|
|
$s =~ s/"/"/g; |
| 14 |
|
|
return $s; |
| 15 |
|
|
} # htescape |
| 16 |
|
|
|
| 17 |
wakaba |
1.6 |
if ($path =~ m[^/(_?[0-9a-z-]+)$]) { |
| 18 |
wakaba |
1.1 |
my $name = $1; |
| 19 |
|
|
my $file_name = $data_dir_name . $name . '.dat'; |
| 20 |
|
|
if (-f $file_name) { |
| 21 |
|
|
if ($ENV{REQUEST_METHOD} eq 'GET') { |
| 22 |
|
|
my $data; |
| 23 |
|
|
{ |
| 24 |
|
|
open my $file, '<:utf8', $file_name or die "$0: $file_name: $!"; |
| 25 |
|
|
local $/ = undef; |
| 26 |
|
|
$data = <$file>; |
| 27 |
|
|
} |
| 28 |
|
|
|
| 29 |
|
|
print qq[Content-Type: text/html; charset=utf-8 |
| 30 |
|
|
|
| 31 |
|
|
<!DOCTYPE HTML> |
| 32 |
|
|
<html lang=en> |
| 33 |
|
|
<head> |
| 34 |
|
|
<title>Edit — @{[htescape ($name)]}</title> |
| 35 |
|
|
<style> |
| 36 |
|
|
textarea { |
| 37 |
|
|
width: 95%; |
| 38 |
|
|
height: 40em; |
| 39 |
|
|
} |
| 40 |
|
|
</style> |
| 41 |
|
|
<link rel=license href="./#license"> |
| 42 |
wakaba |
1.9 |
<link rel=history href="../data/@{[htescape ($name)]}.dat,cvslog"> |
| 43 |
wakaba |
1.1 |
<body> |
| 44 |
|
|
<h1>Edit — @{[htescape ($name)]}</h1> |
| 45 |
|
|
<form action accept-charset=utf-8 method=post> |
| 46 |
|
|
<p><textarea name=data lang>@{[htescape ($data)]}</textarea> |
| 47 |
|
|
<p><input type=submit value=Save> |
| 48 |
|
|
<strong>Important</strong>: See <a href="./#license" rel=license>license</a>. |
| 49 |
|
|
</form> |
| 50 |
|
|
]; |
| 51 |
|
|
exit; |
| 52 |
|
|
} elsif ($ENV{REQUEST_METHOD} eq 'POST') { |
| 53 |
|
|
eval q{ use CGI qw(param) }; |
| 54 |
|
|
my $data = param ('data'); |
| 55 |
|
|
open my $file, '>', $file_name or die "$0: $file_name: $!"; |
| 56 |
|
|
print $file $data; |
| 57 |
|
|
close $file; |
| 58 |
|
|
my $user = $ENV{REMOTE_USER}; |
| 59 |
|
|
$user =~ s/[^0-9A-Za-z_-]/_/g; |
| 60 |
|
|
(system "cvs commit -m \"by remote user \'$user\'\" data > /dev/null") == 0 or die "$0: $?"; |
| 61 |
|
|
|
| 62 |
|
|
print q[Status: 204 Saved; No Content]; |
| 63 |
|
|
exit; |
| 64 |
|
|
} else { |
| 65 |
|
|
print q[Status: 405 Method Not Allowed |
| 66 |
|
|
Content-Type: text/plain ; charset=us-ascii |
| 67 |
|
|
Allow: GET, POST |
| 68 |
|
|
|
| 69 |
|
|
405]; |
| 70 |
|
|
exit; |
| 71 |
|
|
} |
| 72 |
|
|
} |
| 73 |
|
|
} elsif ($path eq '/') { |
| 74 |
|
|
opendir my $data_dir, $data_dir_name or die "$0: $data_dir_name: $!"; |
| 75 |
|
|
print q[Content-Type: text/html; charset=utf-8 |
| 76 |
|
|
|
| 77 |
|
|
<!DOCTYPE HTML> |
| 78 |
|
|
<html lang=en> |
| 79 |
|
|
<title>English-Japanese Data Files</title> |
| 80 |
|
|
<link rel=history href="../data/,cvslog"> |
| 81 |
|
|
<link rel=license href="#license"> |
| 82 |
wakaba |
1.4 |
<link rel=stylesheet href="/www/style/html/xhtml"> |
| 83 |
wakaba |
1.1 |
<h1>English-Japanese Data Files</h1> |
| 84 |
|
|
|
| 85 |
wakaba |
1.7 |
<section id=tools> |
| 86 |
|
|
<h2>Tools</h2> |
| 87 |
wakaba |
1.5 |
|
| 88 |
wakaba |
1.7 |
<ul> |
| 89 |
|
|
<li><a href="../words">English-Japanese word mapping table</a> |
| 90 |
|
|
<li id=find><a href="../find" rel=search>Find</a> |
| 91 |
wakaba |
1.12 |
<!--<li><a href="para/add">Add paragraph</a>--> |
| 92 |
wakaba |
1.7 |
</ul> |
| 93 |
wakaba |
1.5 |
</section> |
| 94 |
|
|
|
| 95 |
wakaba |
1.2 |
<section id=status> |
| 96 |
|
|
<h2>Status of translation</h2> |
| 97 |
|
|
|
| 98 |
|
|
<p>See <a href="../status.png">progress graph</a>. |
| 99 |
|
|
</section> |
| 100 |
|
|
|
| 101 |
wakaba |
1.12 |
<div class=section id=v1-files> |
| 102 |
|
|
<h2>Old data files</h2> |
| 103 |
|
|
|
| 104 |
|
|
<p><em>These files are obsolete and no longer used, except for |
| 105 |
|
|
<code>_mapping</code>, which is the data file for the |
| 106 |
|
|
English-Japanese mapping table.</em> |
| 107 |
|
|
|
| 108 |
|
|
<ul>]; |
| 109 |
|
|
for (sort {$a cmp $b} grep {/\.dat$/} readdir $data_dir) { |
| 110 |
|
|
my $name = $_; |
| 111 |
|
|
$name =~ s/\.dat$//; |
| 112 |
|
|
print qq[<li><a href="@{[htescape ($name)]}"><code class=file>@{[htescape ($name)]}</code></a></li>]; |
| 113 |
|
|
} |
| 114 |
|
|
print q[</ul> |
| 115 |
|
|
</div> |
| 116 |
|
|
|
| 117 |
wakaba |
1.1 |
<section id=license> |
| 118 |
|
|
<h2>License of data files</h2> |
| 119 |
|
|
|
| 120 |
wakaba |
1.3 |
<p><strong>Texts from HTML5 and Web Workers specs</strong>: |
| 121 |
wakaba |
1.1 |
<blockquote cite="http://whatwg.org/html5"> |
| 122 |
|
|
<p class=copyright>© Copyright 2004-2008 Apple Computer, Inc., |
| 123 |
|
|
Mozilla Foundation, and Opera Software ASA.</p> |
| 124 |
|
|
|
| 125 |
|
|
<p class=copyright>You are granted a license to use, reproduce and create |
| 126 |
|
|
derivative works of this document.</p> |
| 127 |
wakaba |
1.3 |
</blockquote> |
| 128 |
|
|
|
| 129 |
wakaba |
1.11 |
<!--<p><strong>Texts from XBL 2.0 spec</strong>: |
| 130 |
wakaba |
1.3 |
<blockquote cite="http://www.mozilla.org/projects/xbl/xbl2.html"> |
| 131 |
|
|
<p class=copyright>Portions of this content are © 1998–2006 by |
| 132 |
|
|
individual mozilla.org contributors; content available under a Creative |
| 133 |
|
|
Commons license. (<a |
| 134 |
|
|
href="http://www.mozilla.org/foundation/licensing/website-content.html">Details</a>)</p> |
| 135 |
wakaba |
1.11 |
</blockquote>--> |
| 136 |
wakaba |
1.1 |
|
| 137 |
|
|
<p><strong>For contributors</strong>: You have to agree that your |
| 138 |
|
|
contributions are licensed under the terms quoted above. |
| 139 |
|
|
</section> |
| 140 |
|
|
]; |
| 141 |
|
|
exit; |
| 142 |
|
|
} |
| 143 |
|
|
|
| 144 |
|
|
print q[Content-Type: text/plain ; charset=us-ascii |
| 145 |
|
|
Status: 404 Not Found |
| 146 |
|
|
|
| 147 |
|
|
404]; |
| 148 |
wakaba |
1.13 |
|
| 149 |
|
|
## Author: Wakaba <w@suika.fam.cx>. |
| 150 |
|
|
## License: Copyright 2008 Wakaba. You are granted a license to use, |
| 151 |
|
|
## reproduce and create derivative works of this script. |
| 152 |
|
|
## $Date: 2008/10/27 04:52:39 $ |