testing bread crumbs based on tags
svn path=/branches/test/; revision=20573
This commit is contained in:
parent
037372aa7f
commit
3fb5f72c90
2
fsfe.sources
Normal file
2
fsfe.sources
Normal file
@ -0,0 +1,2 @@
|
||||
tags/tags:global
|
||||
projects/*/project:global
|
51
fsfe.xsl
51
fsfe.xsl
@ -103,10 +103,11 @@
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- Modify H1 -->
|
||||
<xsl:template match="h1">
|
||||
|
||||
<!-- Apply news page PRE-rules -->
|
||||
<!-- Apply news page PRE-h1 rules -->
|
||||
<xsl:if test="string(/buildinfo/document/@newsdate) and
|
||||
(not(string(/buildinfo/document/@type)) or
|
||||
/buildinfo/document/@type != 'newsletter')">
|
||||
@ -122,7 +123,7 @@
|
||||
|
||||
</xsl:if>
|
||||
|
||||
<!-- Apply newsletter page PRE-rules -->
|
||||
<!-- Apply newsletter page PRE-h1 rules -->
|
||||
<xsl:if test="string(/buildinfo/document/@newsdate) and /buildinfo/document/@type = 'newsletter'">
|
||||
<xsl:element name="p">
|
||||
<xsl:attribute name="id">category</xsl:attribute>
|
||||
@ -134,6 +135,52 @@
|
||||
</xsl:if>
|
||||
|
||||
|
||||
<!-- tag-based bread crumbs -->
|
||||
<xsl:if test="/buildinfo/document/tags/tag">
|
||||
<xsl:element name="p">
|
||||
|
||||
<xsl:attribute name="id">category</xsl:attribute>
|
||||
|
||||
|
||||
<!-- add *project* information
|
||||
name and link of the projects are fetched from projects/*/project:global (see fsfe.sources) -->
|
||||
|
||||
<xsl:variable name="projectid" select="/buildinfo/document/tags/tag[ . = /buildinfo/set/project[./link]/@id ]" />
|
||||
|
||||
<xsl:if test="$projectid != ''">
|
||||
|
||||
<xsl:element name="a">
|
||||
<xsl:attribute name="href"><xsl:value-of select="/buildinfo/set/project[@id = $projectid]/link" /></xsl:attribute>
|
||||
<xsl:value-of select="/buildinfo/set/project[@id = $projectid]/title" />
|
||||
</xsl:element>
|
||||
|
||||
<xsl:text> > </xsl:text>
|
||||
|
||||
</xsl:if>
|
||||
|
||||
|
||||
<!-- add location information -->
|
||||
|
||||
<xsl:for-each select="/buildinfo/document/tags/tag[ . = /buildinfo/set/tag[@type='country' and @link]/@id ]">
|
||||
|
||||
<xsl:variable name="countryid" select="node()" />
|
||||
|
||||
<xsl:if test="$countryid != ''">
|
||||
|
||||
<xsl:element name="a">
|
||||
<xsl:attribute name="href"><xsl:value-of select="/buildinfo/set/tag[@id = $countryid]/@link" /></xsl:attribute>
|
||||
<xsl:value-of select="/buildinfo/set/tag[@id = $countryid]/@name" />
|
||||
</xsl:element>
|
||||
|
||||
</xsl:if>
|
||||
|
||||
</xsl:for-each>
|
||||
|
||||
|
||||
</xsl:element> <!-- </p> -->
|
||||
</xsl:if>
|
||||
|
||||
|
||||
<!-- copy original <h1> -->
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="node()"/>
|
||||
|
110
projects/os/bt-open-letter.en.xhtml
Normal file
110
projects/os/bt-open-letter.en.xhtml
Normal file
@ -0,0 +1,110 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Open letter to BT</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>British Telecom: please include freedom in your new music service</h1>
|
||||
|
||||
<p>Dear BT,</p>
|
||||
|
||||
<p>
|
||||
British Telecom is a leader of telecommunication and digital
|
||||
content markets, and has a reputation for product innovation.
|
||||
Plans recently reported for a new not-for-profit music download
|
||||
service<a class="fn" href="#fn-1">1</a> for BT's 5.5 million
|
||||
broadband customers have sparked much discussion, and once again
|
||||
placed BT at the fore of the future of digital content delivery in
|
||||
the UK.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Amongst those speculating about the nature of the new service are
|
||||
the growing number of BT customers who use Free Software<a
|
||||
class="fn" href="#fn-2">2</a> web-browsers, operating systems, and
|
||||
multimedia players. Currently these and other Free Software users
|
||||
are unable to enjoy many popular content delivery systems such as
|
||||
Spotify, Steam, and iTunes, because they are not compatible with
|
||||
Free Software, or require the waiving of users' rights and freedoms
|
||||
in order to use them<a class="fn" href="#fn-3">3</a> <a class="fn"
|
||||
href="#fn-4">4</a> <a class="fn" href="#fn-5">5</a>. The nature of
|
||||
BT's new service, and the extent to which it respects the freedom of
|
||||
it's users, are therefore of particular concern.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Powerful new Open Standards<a class="fn" hreF="#fn-6">6</a> like
|
||||
HTML5 and CSS3, combined with widely used Free Software codecs for
|
||||
rich multimedia like VP8 and Ogg Vorbis, make it easier than ever
|
||||
to build powerful cross-platform applications which respect user
|
||||
freedom whilst maintaining long term accessibility. Recent
|
||||
adoption of these technologies by established content providers
|
||||
such as YouTube, the Norwegian Broadcasting Corporation,
|
||||
Dailymotion, and Deutschlandradio, reflect a growing industry
|
||||
trend towards platform independence through use of Free Software
|
||||
and Open Standards<a class="fn" href="#fn-7">7</a> <a class="fn"
|
||||
href="#fn-8">8</a> <a class="fn" href="#fn-9">9</a> <a
|
||||
class="fn" href="#fn-10">10</a>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
In addition to these web-based technologies exists Free Software
|
||||
tools like Qt and Gtk, which continue to be used by thousands of
|
||||
companies<a class="fn" href="#fn-11">11</a> to develop world-class
|
||||
desktop applications compatible with all major operating systems.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
BT already makes wide use of Free Software<a class="fn"
|
||||
href="#fn-12">12</a>, and “recognises,
|
||||
and welcomes the use of open source software”<a class="fn"
|
||||
href="#fn-13">13</a>. Therefore we
|
||||
ask that you recognise the value of your customer's freedom as you
|
||||
design and deploy your new subscription service, and take the
|
||||
opportunity to benefit from one of the many Free Software
|
||||
technologies which will allow you to achieve this.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The Free Software Foundation Europe is happy to assist you with
|
||||
any questions regarding this issue or Free Software and Open
|
||||
Standards in general.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Yours Sincerely,
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong><a href="/uk/">UK Team</a>, Free Software Foundation
|
||||
Europe</strong>
|
||||
</p>
|
||||
|
||||
<h2 id="fn">Footnotes</h2>
|
||||
|
||||
<ol>
|
||||
<li id="fn-1"><a href="http://www.guardian.co.uk/technology/pda/2011/mar/28/bt-illegal-filesharing-music">http://www.guardian.co.uk/technology/pda/2011/mar/28/bt-illegal-filesharing-music</a></li>
|
||||
<li id="fn-2"><a href="/about/basics/freesoftware.en.html">http://fsfe.org/about/basics/freesoftware.en.html</a></li>
|
||||
<li id="fn-3"><a href="http://www.spotify.com/int/legal/end-user-agreement/#section-12">http://www.spotify.com/int/legal/end-user-agreement/#section-12</a></li>
|
||||
<li id="fn-4"><a href="http://www.gamesindustry.biz/articles/2010-08-12-valve-on-steam-part-two-interview">http://www.gamesindustry.biz/articles/2010-08-12-valve-on-steam-part-two-interview</a></li>
|
||||
<li id="fn-5"><a href="http://images.apple.com/legal/sla/docs/itunes.pdf">http://images.apple.com/legal/sla/docs/itunes.pdf</a></li>
|
||||
<li id="fn-6"><a href="/projects/os/os.html">http://fsfe.org/projects/os/os.html</a></li>
|
||||
<li id="fn-7"><a href="http://www.youtube.com/html5">http://www.youtube.com/html5</a></li>
|
||||
<li id="fn-8"><a href="http://www.fsf.org/campaigns/playogg/sites/norway">http://www.fsf.org/campaigns/playogg/sites/norway</a></li>
|
||||
<li id="fn-9"><a href="http://www.dailymotion.com/html5">http://www.dailymotion.com/html5</a></li>
|
||||
<li id="fn-10"><a href="http://www.dradio.de/wir/ogg/">http://www.dradio.de/wir/ogg/</a></li>
|
||||
<li id="fn-11"><a href="http://www.digia.com/C2256FEF0043E9C1/0/405002251">http://www.digia.com/C2256FEF0043E9C1/0/405002251</a></li>
|
||||
<li id="fn-12"><a href="http://opensource.bt.com/ under 'products and projects'">http://opensource.bt.com/ under "products and projects"</a></li>
|
||||
<li id="fn-13"><a href="http://www.selling2bt.bt.com/Downloads/BTOpenSourcePolicyextractsforsuppliersIssue1.pdf">http://www.selling2bt.bt.com/Downloads/BTOpenSourcePolicyextractsforsuppliersIssue1.pdf</a> ("Open source software" and "Free Software" refer to the same thing <a href="/documents/whyfs.en.html">with different connotations</a>)</li>
|
||||
</ol>
|
||||
</body>
|
||||
|
||||
<tags>
|
||||
<tag>uk</tag>
|
||||
<tag>os</tag>
|
||||
</tags>
|
||||
|
||||
<timestamp>$Date$ $Author$</timestamp>
|
||||
<translator></translator>
|
||||
</html>
|
46
projects/os/guardian-open-letter.en.xhtml
Normal file
46
projects/os/guardian-open-letter.en.xhtml
Normal file
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Open letter to The Guardian</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Please use Open Standards for your newspaper's educational resources</h1>
|
||||
|
||||
<p>Dear Graham,</p>
|
||||
|
||||
<p>On 11th February the Guardian published an interesting article entitled "How to teach ... space travel" <a class="fn" href="#refs">1</a>, which explained how to teach students about the history of space travel, and included a downloadable lesson plan and presentation.</p>
|
||||
|
||||
<p>Members of our organisation, the Free Software Foundation Europe, who wished to read the files that you provided have contacted us concerning the formats which you used. The only versions of the educational resources which were made available were Microsoft Office files; a proprietary format which does not conform to international standards. Although these file formats can be successfully read by a few applications other than Microsoft Office, they carry an inalienable association with one company and their products. Was it really your intention to advertise Microsoft software when you made your presentations available in their proprietary format?</p>
|
||||
|
||||
<p>Open Standards affect all aspects of society, but are especially important in education. Unfortunately the use of non-Free Software <a class="fn" href="#refs">2</a> and its closed standards in schools often results in non-transferable skills, and technical competency which extends only to a small number of proprietary applications. This problem has been recognised at home and abroad. As the Guardian recently reported, the trade body for the UK's technology sector has called on the Government to drop ICT classes altogether; not least because "the current ICT curriculum is too focused on teaching pupils how to use a limited number of software packages" <a class="fn" href="#refs">3</a>.</p>
|
||||
|
||||
<p>Fortunately many tools are available for working with standards based file formats such as Open Document Format. These include Libre Office, which can create, edit and convert a variety of formats, including most Microsoft Office files, on all major operating systems. Libre Office is also Free Software, and free of charge.
|
||||
As someone who invests in the learning of young people, and as an employee of an organisation which has on numerous occasions recognised the importance of Free Software and Open Standards <a class="fn" href="#refs">4</a> <a class="fn" href="#refs">5</a> <a class="fn" href="#refs">6</a>, we ask that you consider using Open Standards for learning materials that you publish in future, and refer to a presentation as just that, and not "the PowerPoint" (this actually breaches Microsoft's own trademark requirements <a class="fn" href="#refs">7</a>).</p>
|
||||
|
||||
<p>FSFE's UK Team is available if we can help in any way with matters relating to Free Software or Open Standards.</p>
|
||||
|
||||
<p>Yours Sincerely,</p>
|
||||
|
||||
<p>UK Team<br />
|
||||
Free Software Foundation Europe</p>
|
||||
|
||||
<h2 id="fn">Footnotes</h2>
|
||||
|
||||
<ol id="refs">
|
||||
|
||||
<li><a href="http://www.guardian.co.uk/education/2011/apr/11/space-travel-guardian-teacher-network">http://www.guardian.co.uk/education/2011/apr/11/space-travel-guardian-teacher-network</a></li>
|
||||
<li><a href="http://fsfe.org/about/basics/freesoftware.html">http://fsfe.org/about/basics/freesoftware.html</a></li>
|
||||
<li><a href="http://www.guardian.co.uk/government-computing-network/2011/apr/21/intellect-crticises-ict-curriculum-schools?">http://www.guardian.co.uk/government-computing-network/2011/apr/21/intellect-crticises-ict-curriculum-schools?</a></li>
|
||||
<li><a href="http://www.guardian.co.uk/technology/opensource">http://www.guardian.co.uk/technology/opensource</a></li>
|
||||
<li><a href="http://www.guardian.co.uk/media/2009/mar/10/guardian-open-platform">http://www.guardian.co.uk/media/2009/mar/10/guardian-open-platform</a></li>
|
||||
<li><a href="http://www.guardian.co.uk/technology/2009/mar/12/open-source-apps">http://www.guardian.co.uk/technology/2009/mar/12/open-source-apps</a></li>
|
||||
<li><a href="http://www.microsoft.com/about/legal/en/us/IntellectualProperty/Trademarks/Usage/PowerPoint.aspx">http://www.microsoft.com/about/legal/en/us/IntellectualProperty/Trademarks/Usage/PowerPoint.aspx</a></li>
|
||||
|
||||
</ol>
|
||||
|
||||
</body>
|
||||
|
||||
<timestamp>$Date$ $Author$</timestamp>
|
||||
<translator></translator>
|
||||
</html>
|
22
tags/tags.en.xml
Normal file
22
tags/tags.en.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<tags>
|
||||
|
||||
|
||||
<!-- geographical locations -->
|
||||
|
||||
<tag id="de" name="Germany" type="country"/>
|
||||
<tag id="berlin" name="Berlin" parent-region="de" type="city"/>
|
||||
|
||||
<tag id="uk" name="United Kingdom" type="country" link="/uk/index" />
|
||||
<tag id="manchester" name="Manchester" type="city" link="/uk/index" />
|
||||
|
||||
<!-- projects -->
|
||||
|
||||
<!-- there should be no need to redefine tags corresponding to projects
|
||||
let's use the project ids that can be found in projects/*/project.xx.xml files -->
|
||||
|
||||
|
||||
</tags>
|
||||
|
||||
|
@ -12,3 +12,4 @@ es/events/*/event:es
|
||||
fr/events/*/event:fr
|
||||
it/events/*/event:it
|
||||
se/events/*/event:se
|
||||
tags/tags:global
|
||||
|
@ -19,6 +19,8 @@
|
||||
<xsl:apply-templates select="node()"/>
|
||||
</xsl:template>
|
||||
|
||||
<!-- TODO: add tags that correspond to project ids -->
|
||||
|
||||
<!--display dynamic list of news items-->
|
||||
<xsl:template match="all-tags-news">
|
||||
|
||||
|
@ -325,12 +325,6 @@ sub process {
|
||||
my ($file, $langs) = @_;
|
||||
|
||||
#print "$file\n";
|
||||
|
||||
#if (not $file eq "index") {
|
||||
|
||||
#return;
|
||||
|
||||
#}
|
||||
|
||||
print STDERR "Building $file.. \n" unless $opts{q};
|
||||
# Create the root note for the above mentioned XML file (used to feed the XSL
|
||||
@ -411,37 +405,37 @@ sub process {
|
||||
#
|
||||
while (my ($lang, undef) = each %languages) {
|
||||
$root->setAttribute("language", $lang);
|
||||
|
||||
#
|
||||
# This finds the source file to use. If we can't find a translation
|
||||
# into the language, it uses the english version instead, or that in
|
||||
# the local language. Or the first version it finds. This should be
|
||||
# made prettier.
|
||||
#
|
||||
my $document = $dom->createElement("document");
|
||||
$document->setAttribute("language", $lang);
|
||||
$root->appendChild($document);
|
||||
|
||||
my $source = "$opts{i}/$file.$lang.xhtml";
|
||||
unless (-f $source) {
|
||||
my $missingsource = $source;
|
||||
if (-f "$opts{i}/$file.en.xhtml") {
|
||||
$document->setAttribute("language", "en");
|
||||
$source = "$opts{i}/$file.en.xhtml";
|
||||
} elsif (-f "$opts{i}/$file.".$root->getAttribute("original").".xhtml") {
|
||||
$document->setAttribute("language", $root->getAttribute("original"));
|
||||
$source = "$opts{i}/$file.".$root->getAttribute("original").".xhtml";
|
||||
} else {
|
||||
my $l = (keys %{$bases{$file}})[0];
|
||||
$document->setAttribute("language", $l);
|
||||
$source = "$opts{i}/$file.$l.xhtml";
|
||||
}
|
||||
if ($dir eq "global") {
|
||||
lock(*TRANSLATIONS);
|
||||
print TRANSLATIONS "$lang $missingsource $source\n";
|
||||
unlock(*TRANSLATIONS);
|
||||
}
|
||||
}
|
||||
#
|
||||
# This finds the source file to use. If we can't find a translation
|
||||
# into the language, it uses the english version instead, or that in
|
||||
# the local language. Or the first version it finds. This should be
|
||||
# made prettier.
|
||||
#
|
||||
my $document = $dom->createElement("document");
|
||||
$document->setAttribute("language", $lang);
|
||||
$root->appendChild($document);
|
||||
|
||||
my $source = "$opts{i}/$file.$lang.xhtml";
|
||||
unless (-f $source) {
|
||||
my $missingsource = $source;
|
||||
if (-f "$opts{i}/$file.en.xhtml") {
|
||||
$document->setAttribute("language", "en");
|
||||
$source = "$opts{i}/$file.en.xhtml";
|
||||
} elsif (-f "$opts{i}/$file.".$root->getAttribute("original").".xhtml") {
|
||||
$document->setAttribute("language", $root->getAttribute("original"));
|
||||
$source = "$opts{i}/$file.".$root->getAttribute("original").".xhtml";
|
||||
} else {
|
||||
my $l = (keys %{$bases{$file}})[0];
|
||||
$document->setAttribute("language", $l);
|
||||
$source = "$opts{i}/$file.$l.xhtml";
|
||||
}
|
||||
if ($dir eq "global") {
|
||||
lock(*TRANSLATIONS);
|
||||
print TRANSLATIONS "$lang $missingsource $source\n";
|
||||
unlock(*TRANSLATIONS);
|
||||
}
|
||||
}
|
||||
|
||||
if ( (stat("$opts{o}/$dir/$file.$lang.html"))[9] >
|
||||
(stat($source))[9] && $opts{u} && ! -f "$opts{i}/$file.xsl" ) {
|
||||
@ -453,132 +447,137 @@ sub process {
|
||||
# assemble other sets of informations for first (automatically
|
||||
# updated pages).
|
||||
#
|
||||
if (-f "$opts{i}/$file.xsl") {
|
||||
#
|
||||
# Settle down please, children. First we remove all previous
|
||||
# document leftovers.
|
||||
#
|
||||
foreach ($root->getElementsByTagName("document")) {
|
||||
$root->removeChild($_);
|
||||
}
|
||||
$root->appendChild($document);
|
||||
if (-f "$opts{i}/$file.xsl") {
|
||||
#
|
||||
# Settle down please, children. First we remove all previous
|
||||
# document leftovers.
|
||||
#
|
||||
foreach ($root->getElementsByTagName("document")) {
|
||||
$root->removeChild($_);
|
||||
}
|
||||
$root->appendChild($document);
|
||||
|
||||
# Create the <timestamp> tag automatically for these documents
|
||||
my $timestamp = $dom->createElement("timestamp");
|
||||
$timestamp->appendText("\$"."Date: ".$current_time." \$ \$"."Author: automatic \$");
|
||||
$document->appendChild($timestamp);
|
||||
# Create the <timestamp> tag automatically for these documents
|
||||
my $timestamp = $dom->createElement("timestamp");
|
||||
$timestamp->appendText("\$"."Date: ".$current_time." \$ \$"."Author: automatic \$");
|
||||
$document->appendChild($timestamp);
|
||||
|
||||
#
|
||||
# Get the list of sources and create the files hash. The files
|
||||
# hash contains the base name for each file we want to use, and
|
||||
# then the language for it as a value. It prefers a file in the
|
||||
# language we're building into, but will accept an English file as
|
||||
# a substitute.
|
||||
#
|
||||
# "Learn all that is learnable and return that information
|
||||
# to the Creator."
|
||||
#
|
||||
open(IN, '<', "$opts{i}/$file.sources");
|
||||
my @auto_sources = <IN>;
|
||||
close IN;
|
||||
my %files;
|
||||
foreach (@auto_sources) {
|
||||
if (/(.*):[a-z,]*global/ || /(.*):[a-z,]*$dir/) {
|
||||
foreach my $f (glob("$1*")) {
|
||||
if ($f =~ /(.*)\.([a-z][a-z])\.xml$/) {
|
||||
if (!$files{$1}) {
|
||||
$files{$1} = $2;
|
||||
} elsif ($2 eq $lang) {
|
||||
$files{$1} = $2;
|
||||
} elsif (($2 eq "en") &&
|
||||
($files{$1} ne $lang)) {
|
||||
$files{$1} = $2;
|
||||
}
|
||||
}
|
||||
}
|
||||
#
|
||||
# Get the list of sources and create the files hash. The files
|
||||
# hash contains the base name for each file we want to use, and
|
||||
# then the language for it as a value. It prefers a file in the
|
||||
# language we're building into, but will accept an English file as
|
||||
# a substitute.
|
||||
#
|
||||
# "Learn all that is learnable and return that information
|
||||
# to the Creator."
|
||||
#
|
||||
open(IN, '<', "$opts{i}/$file.sources");
|
||||
my @auto_sources = <IN>;
|
||||
close IN;
|
||||
my %files;
|
||||
foreach (@auto_sources) {
|
||||
if (/(.*):[a-z,]*global/ || /(.*):[a-z,]*$dir/) {
|
||||
foreach my $f (glob("$1*")) {
|
||||
if ($f =~ /(.*)\.([a-z][a-z])\.xml$/) {
|
||||
if (!$files{$1}) {
|
||||
$files{$1} = $2;
|
||||
} elsif ($2 eq $lang) {
|
||||
$files{$1} = $2;
|
||||
} elsif (($2 eq "en") &&
|
||||
($files{$1} ne $lang)) {
|
||||
$files{$1} = $2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
# With that information, we load the source document and create
|
||||
# a new element in it, called <set>, which will hold the combined
|
||||
# knowledge of all the sets in the source files.
|
||||
#
|
||||
my $sourcedoc = $parser->parse_file($source);
|
||||
$sourcedoc->documentElement->setAttribute("date", $current_date);
|
||||
$sourcedoc->documentElement->setAttribute("lang", $lang);
|
||||
my $auto_data = $sourcedoc->createElement("set");
|
||||
#
|
||||
# With that information, we load the source document and create
|
||||
# a new element in it, called <set>, which will hold the combined
|
||||
# knowledge of all the sets in the source files.
|
||||
#
|
||||
my $sourcedoc = $parser->parse_file($source);
|
||||
$sourcedoc->documentElement->setAttribute("date", $current_date);
|
||||
$sourcedoc->documentElement->setAttribute("lang", $lang);
|
||||
my $auto_data = $sourcedoc->createElement("set");
|
||||
|
||||
while (my ($base, $l) = each %files) {
|
||||
if (($dir eq "global") && ($l ne $lang)) {
|
||||
lock(*TRANSLATIONS);
|
||||
print TRANSLATIONS "$lang $base.$lang.xml $base.$l.xml\n";
|
||||
unlock(*TRANSLATIONS);
|
||||
}
|
||||
print STDERR "Loading $base.$l.xml\n" if $opts{d};
|
||||
my $source_data = $parser->parse_file("$base.$l.xml");
|
||||
foreach ($source_data->documentElement->childNodes) {
|
||||
my $c = $_->cloneNode(1);
|
||||
$auto_data->appendChild($c);
|
||||
}
|
||||
}
|
||||
$sourcedoc->documentElement->appendChild($auto_data);
|
||||
|
||||
#
|
||||
# Get the appropriate textset for this language. If one can't be
|
||||
# found, use the English. (I hope this never happens)
|
||||
#
|
||||
my $textlang = $lang;
|
||||
unless (-f $opts{i}."/tools/texts-content-$textlang.xml") {
|
||||
$textlang = "en";
|
||||
}
|
||||
|
||||
my $textdoc = $sourcedoc->createElement("textset-content");
|
||||
$auto_data->appendChild($textdoc);
|
||||
clone_document($textdoc, $opts{i}."/tools/texts-content-$textlang.xml");
|
||||
|
||||
# Get also backup texts from the English file
|
||||
my $textdocbak = $sourcedoc->createElement("textset-content-backup");
|
||||
$auto_data->appendChild($textdocbak);
|
||||
clone_document($textdocbak, $opts{i}."/tools/texts-content-en.xml");
|
||||
|
||||
# TODO: optimise getting texts-content-xx.xml and texts-content-en.xml,
|
||||
# since it does not depend on the xsl file being treated, we should do it only once!
|
||||
|
||||
#
|
||||
# Transform the document using the XSL file and then push the
|
||||
# result into the <document> element of the document we're building.
|
||||
#
|
||||
my $style_doc = $parser->parse_file("$opts{i}/$file.xsl");
|
||||
my $stylesheet = $xslt_parser->parse_stylesheet($style_doc);
|
||||
my $results = $stylesheet->transform($sourcedoc);
|
||||
|
||||
foreach ($results->documentElement->childNodes) {
|
||||
my $c = $_->cloneNode(1);
|
||||
$document->appendChild($c);
|
||||
}
|
||||
while (my ($base, $l) = each %files) {
|
||||
if (($dir eq "global") && ($l ne $lang)) {
|
||||
lock(*TRANSLATIONS);
|
||||
print TRANSLATIONS "$lang $base.$lang.xml $base.$l.xml\n";
|
||||
unlock(*TRANSLATIONS);
|
||||
}
|
||||
print STDERR "Loading $base.$l.xml\n" if $opts{d};
|
||||
my $source_data = $parser->parse_file("$base.$l.xml");
|
||||
foreach ($source_data->documentElement->childNodes) {
|
||||
my $c = $_->cloneNode(1);
|
||||
# add the filename to nodes (news, events, …) so that we can use it as an identifier (e.g. for RSS)
|
||||
if (ref($c) eq "XML::LibXML::Element") {
|
||||
$base =~ /.*[\/_]([^\/_]*$)/;
|
||||
$c->setAttribute( "filename", $1 );
|
||||
}
|
||||
$auto_data->appendChild($c);
|
||||
}
|
||||
}
|
||||
$sourcedoc->documentElement->appendChild($auto_data);
|
||||
|
||||
#
|
||||
# Get the appropriate textset for this language. If one can't be
|
||||
# found, use the English. (I hope this never happens)
|
||||
#
|
||||
my $textlang = $lang;
|
||||
unless (-f $opts{i}."/tools/texts-content-$textlang.xml") {
|
||||
$textlang = "en";
|
||||
}
|
||||
|
||||
my $textdoc = $sourcedoc->createElement("textset-content");
|
||||
$auto_data->appendChild($textdoc);
|
||||
clone_document($textdoc, $opts{i}."/tools/texts-content-$textlang.xml");
|
||||
|
||||
# Get also backup texts from the English file
|
||||
my $textdocbak = $sourcedoc->createElement("textset-content-backup");
|
||||
$auto_data->appendChild($textdocbak);
|
||||
clone_document($textdocbak, $opts{i}."/tools/texts-content-en.xml");
|
||||
|
||||
# TODO: optimise getting texts-content-xx.xml and texts-content-en.xml,
|
||||
# since it does not depend on the xsl file being treated, we should do it only once!
|
||||
|
||||
#
|
||||
# Transform the document using the XSL file and then push the
|
||||
# result into the <document> element of the document we're building.
|
||||
#
|
||||
my $style_doc = $parser->parse_file("$opts{i}/$file.xsl");
|
||||
my $stylesheet = $xslt_parser->parse_stylesheet($style_doc);
|
||||
my $results = $stylesheet->transform($sourcedoc);
|
||||
|
||||
#
|
||||
# Now, while we're just at it, we create the RSS feeds if we want any
|
||||
#
|
||||
if (-f "$opts{i}/$file.rss.xsl") {
|
||||
my $style_doc = $parser->parse_file("$opts{i}/$file.rss.xsl");
|
||||
my $stylesheet = $xslt_parser->parse_stylesheet($style_doc);
|
||||
my $results = $stylesheet->transform($sourcedoc);
|
||||
$stylesheet->output_file($results, "$opts{o}/$dir/$file.$lang.rss")
|
||||
unless $opts{n};
|
||||
}
|
||||
foreach ($results->documentElement->childNodes) {
|
||||
my $c = $_->cloneNode(1);
|
||||
$document->appendChild($c);
|
||||
}
|
||||
|
||||
#
|
||||
# and possibly the corresponding iCal (ics) file
|
||||
#
|
||||
if (-f "$opts{i}/$file.ics.xsl") {
|
||||
my $style_doc = $parser->parse_file("$opts{i}/$file.ics.xsl");
|
||||
my $stylesheet = $xslt_parser->parse_stylesheet($style_doc);
|
||||
my $results = $stylesheet->transform($sourcedoc);
|
||||
$stylesheet->output_file($results, "$opts{o}/$dir/$file.$lang.ics")
|
||||
unless $opts{n};
|
||||
}
|
||||
#
|
||||
# Now, while we're just at it, we create the RSS feeds if we want any
|
||||
#
|
||||
if (-f "$opts{i}/$file.rss.xsl") {
|
||||
my $style_doc = $parser->parse_file("$opts{i}/$file.rss.xsl");
|
||||
my $stylesheet = $xslt_parser->parse_stylesheet($style_doc);
|
||||
my $results = $stylesheet->transform($sourcedoc);
|
||||
$stylesheet->output_file($results, "$opts{o}/$dir/$file.$lang.rss")
|
||||
unless $opts{n};
|
||||
}
|
||||
|
||||
#
|
||||
# and possibly the corresponding iCal (ics) file
|
||||
#
|
||||
if (-f "$opts{i}/$file.ics.xsl") {
|
||||
my $style_doc = $parser->parse_file("$opts{i}/$file.ics.xsl");
|
||||
my $stylesheet = $xslt_parser->parse_stylesheet($style_doc);
|
||||
my $results = $stylesheet->transform($sourcedoc);
|
||||
$stylesheet->output_file($results, "$opts{o}/$dir/$file.$lang.ics")
|
||||
unless $opts{n};
|
||||
}
|
||||
|
||||
} else {
|
||||
#
|
||||
@ -692,9 +691,85 @@ sub process {
|
||||
$menuroot->appendChild($m);
|
||||
}
|
||||
$root->appendChild($menuroot);
|
||||
|
||||
|
||||
|
||||
# <start addendum> (TODO: transform this into a function)
|
||||
|
||||
#
|
||||
# Do the actual transformation.
|
||||
# Get the list of sources and create the files hash. The files
|
||||
# hash contains the base name for each file we want to use, and
|
||||
# then the language for it as a value. It prefers a file in the
|
||||
# language we're building into, but will accept an English file as
|
||||
# a substitute.
|
||||
#
|
||||
# "Learn all that is learnable and return that information
|
||||
# to the Creator."
|
||||
#
|
||||
open(IN, '<', "$opts{i}/fsfe.sources");
|
||||
my @auto_sources = <IN>;
|
||||
close IN;
|
||||
my %files;
|
||||
foreach (@auto_sources) {
|
||||
if (/(.*):[a-z,]*global/ || /(.*):[a-z,]*$dir/) {
|
||||
foreach my $f (glob("$1*")) {
|
||||
if ($f =~ /(.*)\.([a-z][a-z])\.xml$/) {
|
||||
if (!$files{$1}) {
|
||||
$files{$1} = $2;
|
||||
} elsif ($2 eq $lang) {
|
||||
$files{$1} = $2;
|
||||
} elsif (($2 eq "en") &&
|
||||
($files{$1} ne $lang)) {
|
||||
$files{$1} = $2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
# With that information, we load the source document and create
|
||||
# a new element in it, called <set>, which will hold the combined
|
||||
# knowledge of all the sets in the source files.
|
||||
#
|
||||
foreach ($root->getElementsByTagName("set")) {
|
||||
$root->removeChild($_);
|
||||
}
|
||||
my $auto_data = $dom->createElement("set");
|
||||
|
||||
while (my ($base, $l) = each %files) {
|
||||
if (($dir eq "global") && ($l ne $lang)) {
|
||||
lock(*TRANSLATIONS);
|
||||
print TRANSLATIONS "$lang $base.$lang.xml $base.$l.xml\n";
|
||||
unlock(*TRANSLATIONS);
|
||||
}
|
||||
print STDERR "Loading $base.$l.xml\n" if $opts{d};
|
||||
my $source_data = $parser->parse_file("$base.$l.xml");
|
||||
foreach ($source_data->documentElement->childNodes) {
|
||||
my $c = $_->cloneNode(1);
|
||||
# add the filename to nodes (news, events, …) so that we can use it as an identifier (e.g. for RSS)
|
||||
if (ref($c) eq "XML::LibXML::Element") {
|
||||
$base =~ /.*[\/_]([^\/_]*$)/;
|
||||
$c->setAttribute( "filename", $1 );
|
||||
}
|
||||
$auto_data->appendChild($c);
|
||||
}
|
||||
}
|
||||
$root->appendChild($auto_data);
|
||||
|
||||
# <end addendum>
|
||||
|
||||
|
||||
if ( $lang eq "fr" and $file eq $file_to_treat ) {
|
||||
|
||||
print "--->outputting test2.xml\n";
|
||||
open (TEST, '>', "/home/nicolas/FSFE/fsfe-web-out/test2.xml");
|
||||
print TEST $dom->toString();
|
||||
close (TEST);
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# Do the actual transformation. (through fsfe.xsl)
|
||||
#
|
||||
my $results = $global_stylesheet->transform($dom);
|
||||
|
||||
@ -710,14 +785,14 @@ sub process {
|
||||
}
|
||||
}
|
||||
if (($href !~ /^http/) && ($href !~ /^#/)) {
|
||||
# Save possible anchor and remove it from URL
|
||||
my $anchor = $href;
|
||||
if (!($anchor =~ s/.*#/#/)) {
|
||||
$anchor = "";
|
||||
}
|
||||
$href =~ s/#.*//;
|
||||
# proces URL
|
||||
if (($href =~ /\.html$/) && ($href !~ /\.[a-z][a-z]\.html$/)) {
|
||||
# Save possible anchor and remove it from URL
|
||||
my $anchor = $href;
|
||||
if (!($anchor =~ s/.*#/#/)) {
|
||||
$anchor = "";
|
||||
}
|
||||
$href =~ s/#.*//;
|
||||
# proces URL
|
||||
if (($href =~ /\.html$/) && ($href !~ /\.[a-z][a-z]\.html$/)) {
|
||||
$href =~ s/\.html$/\.$lang.html/;
|
||||
} elsif (($href =~ /\.rss$/) && ($href !~ /\.[a-z][a-z]\.rss$/)) {
|
||||
$href =~ s/\.rss$/\.$lang.rss/;
|
||||
|
@ -18,12 +18,8 @@ sub areEqual {
|
||||
|
||||
my ($file1, $file2) = @_;
|
||||
|
||||
#my $dom = XML::LibXML->load_xml(location => $file1); # the load_xml() function is not part of libxml 1.66 which is used on the server
|
||||
#my $don = XML::LibXML->load_xml(location => $file2);
|
||||
|
||||
my $parser = XML::LibXML->new();
|
||||
my $dom = $parser->parse_file($file1);
|
||||
my $don = $parser->parse_file($file2);
|
||||
my $dom = XML::LibXML->load_xml(location => $file1);
|
||||
my $don = XML::LibXML->load_xml(location => $file2);
|
||||
|
||||
my $root = $dom->documentElement();
|
||||
my $roon = $don->documentElement();
|
||||
@ -104,7 +100,7 @@ sub nodesAreEqual {
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
return 1;
|
||||
|
||||
|
||||
|
||||
|
@ -131,42 +131,37 @@
|
||||
|
||||
##<xsl:value-of select="$nbtags" />##<xsl:value-of select="$average" />## -->
|
||||
|
||||
<xsl:element name="ul">
|
||||
<xsl:call-template name="append-children-tags" />
|
||||
|
||||
<xsl:attribute name="class">taglist</xsl:attribute>
|
||||
|
||||
<xsl:for-each select="/html/set/news/tags/tag">
|
||||
<xsl:sort select="." order="ascending" />
|
||||
|
||||
<xsl:variable name="thistag" select="node()" />
|
||||
<xsl:variable name="nb" select="count( /html/set/news/tags/tag[text() = $thistag]) " />
|
||||
|
||||
<!-- fontsize = (MAXFONT-MINFONT) * (count-MINCOUNT) / (MAXCOUNT-MINCOUNT) + MINFONT
|
||||
→ to finish this calculation, we need to find out how many min and max tag occurrences there are -->
|
||||
<!-- <xsl:variable name="font" select="(40-16) * ($nb-16) / (MAXCOUNT-MINCOUNT) + 16" /> -->
|
||||
|
||||
<xsl:if test="generate-id() = generate-id(key('news-tags-by-value', normalize-space(.)))">
|
||||
<!--
|
||||
<xsl:for-each select="/html/set/news/tags/tag">
|
||||
<xsl:sort select="." order="ascending" />
|
||||
|
||||
<xsl:variable name="thistag" select="node()" />
|
||||
<xsl:variable name="nb" select="count( /html/set/news/tags/tag[text() = $thistag]) " />
|
||||
|
||||
<xsl:if test="generate-id() = generate-id(key('news-tags-by-value', normalize-space(.)))">
|
||||
|
||||
<xsl:element name="li">
|
||||
|
||||
<xsl:element name="li">
|
||||
<xsl:element name="a">
|
||||
|
||||
<xsl:attribute name="href">
|
||||
<xsl:text>/tags/tagged.</xsl:text>
|
||||
<xsl:value-of select="/html/@lang" />
|
||||
<xsl:text>.html#n</xsl:text>
|
||||
<xsl:value-of select="translate($thistag,' ','')" />
|
||||
</xsl:attribute>
|
||||
|
||||
<xsl:value-of select="."/>
|
||||
|
||||
<xsl:element name="a">
|
||||
|
||||
<xsl:attribute name="href">
|
||||
<xsl:text>/tags/tagged.</xsl:text>
|
||||
<xsl:value-of select="/html/@lang" />
|
||||
<xsl:text>.html#n</xsl:text>
|
||||
<xsl:value-of select="translate($thistag,' ','')" />
|
||||
</xsl:attribute>
|
||||
|
||||
<xsl:value-of select="."/>
|
||||
|
||||
</xsl:element>
|
||||
</xsl:element>
|
||||
|
||||
</xsl:if>
|
||||
|
||||
</xsl:for-each>
|
||||
</xsl:element>
|
||||
</xsl:element>
|
||||
|
||||
</xsl:if>
|
||||
|
||||
</xsl:for-each>
|
||||
-->
|
||||
|
||||
</xsl:template>
|
||||
|
||||
@ -210,6 +205,55 @@
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- recursive, nested list of parent-region children tags -->
|
||||
<xsl:template name="append-children-tags">
|
||||
<xsl:param name="parent-region" select="''" />
|
||||
|
||||
<xsl:element name="ul">
|
||||
|
||||
<xsl:if test="$parent-region=''">
|
||||
<xsl:attribute name="class">taglist</xsl:attribute>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:attribute name="parent-region"><xsl:value-of select="$parent-region" /></xsl:attribute>
|
||||
|
||||
<xsl:for-each select="/html/set/tag[ (not(@parent-region) and $parent-region='') or
|
||||
@parent-region = $parent-region ]">
|
||||
|
||||
<xsl:variable name="id" select="@id" />
|
||||
<!-- <xsl:variable name="nb" select="count( /html/set/news/tags/tag[text() = $id]) " /> -->
|
||||
|
||||
<xsl:element name="li">
|
||||
|
||||
<xsl:element name="a">
|
||||
|
||||
<xsl:attribute name="href">
|
||||
<xsl:text>/tags/tagged.</xsl:text>
|
||||
<xsl:value-of select="/html/@lang" />
|
||||
<xsl:text>.html#n</xsl:text>
|
||||
<xsl:value-of select="translate($id,' ','')" />
|
||||
</xsl:attribute>
|
||||
|
||||
<xsl:value-of select="@name"/>
|
||||
|
||||
</xsl:element>
|
||||
|
||||
<!-- if there are children, add them as a sublist -->
|
||||
<xsl:for-each select="/html/set/tag[ @parent-region = $id ]">
|
||||
<xsl:call-template name="append-children-tags">
|
||||
<xsl:with-param name="parent-region" select="$id" />
|
||||
</xsl:call-template>
|
||||
</xsl:for-each>
|
||||
|
||||
</xsl:element> <!-- </li> -->
|
||||
|
||||
</xsl:for-each>
|
||||
|
||||
</xsl:element> <!-- </ul> -->
|
||||
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="fetch-links">
|
||||
<xsl:element name="ul">
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user