The following commit has been merged in the master branch:
commit 597347c0fe994954d5e5168368fb21e743a39def
Author: Frank Lichtenheld <[email protected]>
Date: Sat Jul 4 22:30:21 2009 +0200
Make static pages translatable via templates.pot and convert homepage to
use it
This is currently only for the benefit of every site except packages.d.o
since
that uses a page on www.d.o instead which is translated there.
diff --git a/bin/translate_static_page b/bin/translate_static_page
new file mode 100755
index 0000000..e62bbb9
--- /dev/null
+++ b/bin/translate_static_page
@@ -0,0 +1,42 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use POSIX;
+use File::Basename;
+
+use lib './lib';
+
+use Packages::CommonCode qw(:all);
+use Packages::Config qw( $TOPDIR $DBDIR @ARCHIVES @SUITES @LANGUAGES );
+use Packages::Template;
+use Packages::I18N::Locale;
+&Packages::Config::init( './' );
+
+my $template = new Packages::Template( "$TOPDIR/templates", 'html');
+
+if( @ARGV % 2 ){
+ die "usage: translate_static_page [[template outputfile]...]\n";
+}
+my %pages = @ARGV;
+print "translate static pages ...\n";
+while( my ($tmpl, $output) = each %pages ) {
+ my $outdir = dirname($output);
+ my $outfile = basename($output);
+ mkdirp ( $outdir );
+ foreach my $lang (@LANGUAGES) {
+ my $charset = 'UTF-8';
+ my $cat = Packages::I18N::Locale->get_handle($lang)
+ or die "get_handle failed for $lang";
+ print "writing $outfile (lang=$lang)...\n";
+
+ my %content = ( po_lang => $lang, ddtp_lang => $lang,
+ charset => $charset, cat => $cat,
+ used_langs => \...@languages );
+
+ $template->page( $tmpl, \%content,
+ "$TOPDIR/$output.$lang.html.new");
+ activate( "$TOPDIR/$output.$lang.html" );
+ }
+}
diff --git a/cron.d/500update_po b/cron.d/500update_po
index 9950b8a..5a84ea9 100755
--- a/cron.d/500update_po
+++ b/cron.d/500update_po
@@ -31,6 +31,7 @@ templates/html/error.tmpl
templates/html/filelist.tmpl
templates/html/foot.tmpl
templates/html/head.tmpl
+templates/html/homepage.tmpl
templates/html/index_head.tmpl
templates/html/index_foot.tmpl
templates/html/messages.tmpl
diff --git a/cron.d/700install_static b/cron.d/700install_static
index 933fb21..05723a4 100755
--- a/cron.d/700install_static
+++ b/cron.d/700install_static
@@ -6,5 +6,8 @@ set -e
test -d "$htmldir" || mkdir -p "$htmldir"
-cd "$topdir" && ttree --perl5lib=${libdir} --load_perl --eval_perl \
- -f ./conf/ttreerc
+cd "$topdir"
+ttree --perl5lib=${libdir} --load_perl --eval_perl \
+ -f ./conf/ttreerc
+
+./bin/translate_static_page homepage www/index
diff --git a/static/index.tmpl b/static/index.tmpl
deleted file mode 100644
index 524dff3..0000000
--- a/static/index.tmpl
+++ /dev/null
@@ -1,129 +0,0 @@
-[%- PROCESS 'html/head.tmpl'
- title_tag = "$organisation Packages Search"
- page_title = "$organisation Packages Search"
- keywords = "$organisation, Packages"
--%]
-[%-
- all_suites = [ 'etch', 'etch-m68k', 'etch-volatile', 'etch-backports',
- 'lenny', 'lenny-volatile', 'lenny-backports', 'squeeze',
'sid' ]
- version_numbers = { sarge => '3.1',
- etch => '4.0',
- lenny => '5.0' }
- current_release = 'lenny'
- all_sections = [ 'main', 'contrib', 'non-free' ]
- all_architectures = [ 'alpha', 'arm', 'armel', 'amd64', 'avr32', 'hppa',
'i386',
- 'ia64', 'kfreebsd-amd64', 'kfreebsd-i386', 'mips',
- 'mipsel', 'm68k', 'powerpc', 's390', 'sparc' ]
--%]
-
-<p>This site provides you with information about all the packages
-available in the <a href="[% project_homepage %]">[% organisation %]</a>
-Package archive.
-
-<p><em>Please contact <a href="mailto:[% admin.mail %]">[% admin.name %]</a>
-if you encounter any problems!</em></p>
-
-<h2>Browse through the lists of packages:</h2>
-
-<ul style="font-size:large">
-[% FOREACH s IN all_suites %]
-<li><a href="[% s %]/">[% s %]</a>
-[% IF version_numbers.$s %]([% version_numbers.$s %])[% END %]</li>
-[% END %]
-</ul>
-
-<p>There is also a list of <a href="[% all_suites.-1 %]/main/newpkg">packages
-recently added to [% all_suites.-1 %]</a>.</p>
-
-<h2>Search</h2>
-
-<h3>Search package directories</h3>
-
-<form method="GET" action="/search">
-<label for="kw">Keyword:</label>
-<input type="text" size="30" name="keywords" id="kw">
-<input type="submit" value="Search"> <input type="reset" value="Reset">
-<br>
-Search on:
-<input type="radio" name="searchon" value="names" id="onlynames"
checked="checked">
-<label for="onlynames">Package names only</label>
-<input type="radio" name="searchon" value="all" id="descs">
-<label for="descs">Descriptions</label>
-
-<input type="radio" name="searchon" value="sourcenames" id="src">
-<label for="src">Source package names</label>
-<br>
-Only show exact matches:
-<input type="checkbox" name="exact" value="1">
-<br>
-Distribution:
-<select name="suite">
-[% FOREACH s IN all_suites %]
- <option value="[% s %]" [% 'selected="selected"' IF s == current_release
%]>[% s %]</option>
-[% END %]
- <option value="all">any</option>
-</select>
-Section:
-<select name="section">
-[% FOREACH s IN all_sections %]
- <option value="[% s %]">[% s %]</option>
-[% END %]
- <option value="all" selected="selected">any</option>
-</select>
-</form>
-<p>There are shortcuts for some searches available:</p>
-<ul>
- <li><code>[% packages_homepage %]<var>name</var></code> for
- the search on package names.</li>
-
- <li><code>[% packages_homepage %]src:<var>name</var></code>
- for the search on source package names.</li>
-</ul>
-<hr>
-
-<h3><a name="search_contents">Search the contents of packages</a></h3>
-
-<P>This search engine allows you to search the contents of [% organisation %]
-distributions for any files (or just parts of file names) that are
-part of packages.
-You can also get a full list of files in a given package.
-<br>
-<form method="GET" action="/search">
-<input type="hidden" name="searchon" value="contents">
-
-<label for="keyword">Keyword:</label>
-<input type="text" size="30" name="keywords" id="keyword">
-
-<input type="submit" value="Search">
- <input type="reset" value="Reset">
-<br>
-Display:
-<br>
-<input type="radio" name="mode" value="exactfilename" id="exactfilename"
checked="checked">
- <label for="exactfilename">packages that contain files named like
this</label>
-<br>
-<input type="radio" name="mode" value="" id="suffixpathname">
- <label for="suffixpathname">packages that contain files whose names end with
the keyword</label>
-<br>
-<input type="radio" name="mode" value="filename" id="filename">
- <label for="filename">packages that contain files whose names contain the
keyword</label>
-<br>
-<label for="distro">Distribution:</label>
-
-<select name="suite" id="distro">
-[% FOREACH s IN all_suites %]
- <option value="[% s %]" [% 'selected="selected"' IF s == current_release
%]>[% s %]</option>
-[% END %]
-</select>
-<label for="architecture">Architecture:</label>
-<select name="arch" id="architecture">
-[% FOREACH a IN all_architectures %]
- <option value="[% a %]">[% a %]</option>
-[% END %]
- <option value="any" selected="selected">any</option>
-</select>
-</form>
-
-[% PROCESS 'html/foot.tmpl'
- langs.size = 0
- copyright.years = '1997 - 2008' %]
diff --git a/templates/html/foot.tmpl b/templates/html/foot.tmpl
index 5a98997..7944c67 100644
--- a/templates/html/foot.tmpl
+++ b/templates/html/foot.tmpl
@@ -5,7 +5,7 @@ Total page evaluation took [% benchmark %]<br>
<div id="footer">
-[% IF langs.size > 0 %]
+[% IF langs && langs.size > 0 %]
<hr class="hidecss">
<!--UdmComment-->
<p>[% g('This page is also available in the following languages (How to set <a
href="%s">the default document language</a>):', cn_help_url) %]</p>
diff --git a/templates/html/homepage.tmpl b/templates/html/homepage.tmpl
new file mode 100644
index 0000000..40764e7
--- /dev/null
+++ b/templates/html/homepage.tmpl
@@ -0,0 +1,116 @@
+[%- PROCESS 'html/head.tmpl'
+ title_tag = "$organisation Packages Search"
+ page_title = "$organisation Packages Search"
+ keywords = "$organisation, Packages"
+-%]
+[%-
+ all_suites = [ 'etch', 'etch-m68k', 'etch-volatile', 'etch-backports',
+ 'lenny', 'lenny-volatile', 'lenny-backports', 'squeeze',
'sid' ]
+ version_numbers = { sarge => '3.1',
+ etch => '4.0',
+ lenny => '5.0' }
+ current_release = 'lenny'
+ all_sections = [ 'main', 'contrib', 'non-free' ]
+ all_architectures = [ 'alpha', 'arm', 'armel', 'amd64', 'avr32', 'hppa',
'i386',
+ 'ia64', 'kfreebsd-amd64', 'kfreebsd-i386', 'mips',
+ 'mipsel', 'm68k', 'powerpc', 's390', 'sparc' ]
+-%]
+
+<p>[% g('This site provides you with information about all the packages
available in the <a href="%s">%s</a> Package archive.', project_homepage,
organisation) %]</p>
+
+<p><em>[% g('Please contact <a href="mailto:%s">%s</a> if you encounter any
problems!', admin.mail, admin.name) %]</em></p>
+
+<h2>[% g('Browse through the lists of packages:') %]</h2>
+
+<ul style="font-size:large">
+[% FOREACH s IN all_suites %]
+<li><a href="[% s %]/">[% s %]</a>
+[% IF version_numbers.$s %]([% version_numbers.$s %])[% END %]</li>
+[% END %]
+</ul>
+
+<p>[% g('There is also a list of <a href="%s/main/newpkg">packages recently
added to %s</a>.', all_suites.-1, all_suites.-1) %]</p>
+
+<h2>[% g('Search') %]</h2>
+
+<h3>[% g('Search package directories') %]</h3>
+
+<form method="GET" action="/search">
+<label for="kw">[% g('Keyword:') %]</label>
+<input type="text" size="30" name="keywords" id="kw">
+<input type="submit" value="[% g('Search') %]"> <input type="reset" value="[%
g('Reset') %]">
+<br>
+[% g('Search on:') %]
+<input type="radio" name="searchon" value="names" id="onlynames"
checked="checked">
+<label for="onlynames">[% g('Package names only') %]</label>
+<input type="radio" name="searchon" value="all" id="descs">
+<label for="descs">[% g('Descriptions') %]</label>
+<input type="radio" name="searchon" value="sourcenames" id="src">
+<label for="src">[% g('Source package names') %]</label>
+<br>
+[% g('Only show exact matches:') %]
+<input type="checkbox" name="exact" value="1">
+<br>
+Distribution:
+<select name="suite">
+[% FOREACH s IN all_suites %]
+ <option value="[% s %]" [% 'selected="selected"' IF s == current_release
%]>[% s %]</option>
+[% END %]
+ <option value="all">[% g('any') %]</option>
+</select>
+[% g('Section:') %]
+<select name="section">
+[% FOREACH s IN all_sections %]
+ <option value="[% s %]">[% s %]</option>
+[% END %]
+ <option value="all" selected="selected">[% g('any') %]</option>
+</select>
+</form>
+<p>[% g('There are shortcuts for some searches available:') %]</p>
+<ul>
+ <li>[% g('<code>%s<var>name</var></code> for the search on package
names.', packages_homepage_abs) %]</li>
+
+ <li>[% g('<code>%ssrc:<var>name</var></code> for the search on source
package names.', packages_homepage_abs) %]</li>
+</ul>
+<hr>
+
+<h3><a name="search_contents">[% g('Search the contents of packages')
%]</a></h3>
+
+<p>[% g('This search engine allows you to search the contents of %s
distributions for any files (or just parts of file names) that are part of
packages. You can also get a full list of files in a given package.',
organisation) %]<br>
+<form method="GET" action="/search">
+<input type="hidden" name="searchon" value="contents">
+
+<label for="keyword">[% g('Keyword:') %]</label>
+<input type="text" size="30" name="keywords" id="keyword">
+
+<input type="submit" value="[% g('Search') %]">
+ <input type="reset" value="[% g('Reset') %]">
+<br>
+[% g('Display:') %]
+<br>
+<input type="radio" name="mode" value="exactfilename" id="exactfilename"
checked="checked">
+ <label for="exactfilename">[% g('packages that contain files named like
this') %]</label>
+<br>
+<input type="radio" name="mode" value="" id="suffixpathname">
+ <label for="suffixpathname">[% g('packages that contain files whose names
end with the keyword') %]</label>
+<br>
+<input type="radio" name="mode" value="filename" id="filename">
+ <label for="filename">[% g('packages that contain files whose names contain
the keyword') %]</label>
+<br>
+<label for="distro">[% g('Distribution:') %]</label>
+
+<select name="suite" id="distro">
+[% FOREACH s IN all_suites %]
+ <option value="[% s %]" [% 'selected="selected"' IF s == current_release
%]>[% s %]</option>
+[% END %]
+</select>
+<label for="architecture">[% g('Architecture:') %]</label>
+<select name="arch" id="architecture">
+[% FOREACH a IN all_architectures %]
+ <option value="[% a %]">[% a %]</option>
+[% END %]
+ <option value="any" selected="selected">[% g('any') %]</option>
+</select>
+</form>
+
+[% PROCESS 'html/foot.tmpl' copyright.years = '1997 - 2009' %]
--
APT Archive Web-Frontend (Alioth repository)
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]