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 |
if ($path =~ m[^/([0-9a-z-]+)$]) { |
18 |
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 |
<body> |
43 |
<h1>Edit — @{[htescape ($name)]}</h1> |
44 |
<form action accept-charset=utf-8 method=post> |
45 |
<p><textarea name=data lang>@{[htescape ($data)]}</textarea> |
46 |
<p><input type=submit value=Save> |
47 |
<strong>Important</strong>: See <a href="./#license" rel=license>license</a>. |
48 |
</form> |
49 |
]; |
50 |
exit; |
51 |
} elsif ($ENV{REQUEST_METHOD} eq 'POST') { |
52 |
eval q{ use CGI qw(param) }; |
53 |
my $data = param ('data'); |
54 |
open my $file, '>', $file_name or die "$0: $file_name: $!"; |
55 |
print $file $data; |
56 |
close $file; |
57 |
my $user = $ENV{REMOTE_USER}; |
58 |
$user =~ s/[^0-9A-Za-z_-]/_/g; |
59 |
(system "cvs commit -m \"by remote user \'$user\'\" data > /dev/null") == 0 or die "$0: $?"; |
60 |
|
61 |
print q[Status: 204 Saved; No Content]; |
62 |
exit; |
63 |
} else { |
64 |
print q[Status: 405 Method Not Allowed |
65 |
Content-Type: text/plain ; charset=us-ascii |
66 |
Allow: GET, POST |
67 |
|
68 |
405]; |
69 |
exit; |
70 |
} |
71 |
} |
72 |
} elsif ($path eq '/') { |
73 |
opendir my $data_dir, $data_dir_name or die "$0: $data_dir_name: $!"; |
74 |
print q[Content-Type: text/html; charset=utf-8 |
75 |
|
76 |
<!DOCTYPE HTML> |
77 |
<html lang=en> |
78 |
<title>English-Japanese Data Files</title> |
79 |
<link rel=history href="../data/,cvslog"> |
80 |
<link rel=license href="#license"> |
81 |
<link rel=stylesheet href="/www/style/html/xhtml"> |
82 |
<h1>English-Japanese Data Files</h1> |
83 |
|
84 |
<ul>]; |
85 |
for (sort {$a cmp $b} grep {/\.dat$/} readdir $data_dir) { |
86 |
my $name = $_; |
87 |
$name =~ s/\.dat$//; |
88 |
print qq[<li><a href="@{[htescape ($name)]}"><code class=file>@{[htescape ($name)]}</code></a></li>]; |
89 |
} |
90 |
print q[</ul> |
91 |
|
92 |
<section id=status> |
93 |
<h2>Status of translation</h2> |
94 |
|
95 |
<p>See <a href="../status.png">progress graph</a>. |
96 |
</section> |
97 |
|
98 |
<section id=license> |
99 |
<h2>License of data files</h2> |
100 |
|
101 |
<p><strong>Texts from HTML5 and Web Workers specs</strong>: |
102 |
<blockquote cite="http://whatwg.org/html5"> |
103 |
<p class=copyright>© Copyright 2004-2008 Apple Computer, Inc., |
104 |
Mozilla Foundation, and Opera Software ASA.</p> |
105 |
|
106 |
<p class=copyright>You are granted a license to use, reproduce and create |
107 |
derivative works of this document.</p> |
108 |
</blockquote> |
109 |
|
110 |
<p><strong>Texts from XBL 2.0 spec</strong>: |
111 |
<blockquote cite="http://www.mozilla.org/projects/xbl/xbl2.html"> |
112 |
<p class=copyright>Portions of this content are © 1998–2006 by |
113 |
individual mozilla.org contributors; content available under a Creative |
114 |
Commons license. (<a |
115 |
href="http://www.mozilla.org/foundation/licensing/website-content.html">Details</a>)</p> |
116 |
</blockquote> |
117 |
|
118 |
<p><strong>For contributors</strong>: You have to agree that your |
119 |
contributions are licensed under the terms quoted above. |
120 |
</section> |
121 |
]; |
122 |
exit; |
123 |
} |
124 |
|
125 |
print q[Content-Type: text/plain ; charset=us-ascii |
126 |
Status: 404 Not Found |
127 |
|
128 |
404]; |