Browse Source

Syncing from test branch

svn path=/trunk/; revision=20944
tags/stw2018
cri 8 years ago
parent
commit
1211257e70
2 changed files with 517 additions and 141 deletions
  1. 295
    138
      tools/build-test.pl
  2. 222
    3
      tools/build.pl.test.patch

+ 295
- 138
tools/build-test.pl View File

@@ -1,6 +1,6 @@
#! /usr/bin/perl
#
# build.pl - a tool for building FSFE web pages
# build.pl - a tool for building FSF Europe web pages
#
# Copyright (C) 2003 Jonas Öberg
#
@@ -32,6 +32,12 @@ use IO::Select;
use Socket;
use Fcntl ':flock';

use FindBin;
use lib "$FindBin::Bin";


require "comptree.pl";

# This defines the focuses and their respective preferred / original
# language. For example, it says that we should have a focus called
# "se" (Sweden) which has the preferred language "sv" (Swedish).
@@ -92,6 +98,13 @@ our %languages = (
our $current_date = strftime "%Y-%m-%d", localtime;
our $current_time = strftime "%Y-%m-%d %H:%M:%S", localtime;


# This static array contains files that can't be out of date
our %cant_be_outdated = (
"news/news" => 1
);


#
# Parse the command line options. We need two; where to put the finished
# pages and what to use as base for the input.
@@ -312,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
@@ -331,7 +338,7 @@ sub process {
# Set the current date, to use for comparision in the XSLT.
#
$root->setAttribute("date", $current_date);
#
# Find original language. It's en, unless we're in the country specific
# se/, fr/, de/ and so on, directories.
@@ -342,9 +349,9 @@ sub process {
$srcfocus = "$1";
$root->setAttribute("original", $countries{$1});
}
$root->setAttribute("filename", "/$file");
#
# Set the directory name attribute
#
@@ -387,6 +394,7 @@ sub process {
# Transform it, once for every focus!
#
while (my ($dir, undef) = each %countries) {
# If we handle a focus specific file, only process it in that focus
next if (("$srcfocus" ne "global") && ("$dir" ne "$srcfocus"));

@@ -396,38 +404,38 @@ sub process {
# And once for every language!
#
while (my ($lang, undef) = each %languages) {
$root->setAttribute("language", $lang);
$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
# 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);
}
}
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" ) {
@@ -439,13 +447,13 @@ sub process {
# assemble other sets of informations for first (automatically
# updated pages).
#
if (-f "$opts{i}/$file.xsl") {
if (-f "$opts{i}/$file.xsl") {
#
# Settle down please, children. First we remove all previous
# document leftovers.
#
foreach ($root->getElementsByTagName("document")) {
$root->removeChild($_);
$root->removeChild($_);
}
$root->appendChild($document);

@@ -505,6 +513,11 @@ sub process {
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);
}
}
@@ -519,12 +532,18 @@ sub process {
$textlang = "en";
}
# TODO: backup texts?
my $textdoc = $sourcedoc->createElement("textset-content");
$sourcedoc->documentElement->appendChild($textdoc);
$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.
@@ -541,106 +560,232 @@ sub process {
#
# Now, while we're just at it, we create the RSS feeds if we want any
#
if (-f "$opts{i}/$file.rss.xsl") {
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};
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") {
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};
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 {
} else {
#
# If this wasn't an automatically updating document, we simply
# clone the contents of the source file into the document.
#
clone_document($document, $source);
}

#
# If this wasn't an automatically updating document, we simply
# clone the contents of the source file into the document.
# Find out if this translation is to be regarded as outdated or not.
# A translation is deemed outdated if it is more than 2 hours older
# than the original. This makes sure a translation committed together
# with the original (but maybe a second earlier) isn't marked outdated.
#
clone_document($document, $source);
}

#
# Find out if this translation is to be regarded as outdated or not.
# A translation is deemed outdated if it is more than 2 hours older
# than the original. This makes sure a translation committed together
# with the original (but maybe a second earlier) isn't marked outdated.
#
my $originalsource = "$file.".$root->getAttribute("original").".xhtml";
if ((stat("$opts{i}/$originalsource"))[9] > (stat($source))[9] + 7200) {
$root->setAttribute("outdated", "yes");
if ($dir eq "global") {
lock(*TRANSLATIONS);
print TRANSLATIONS "$lang $source $originalsource\n";
unlock(*TRANSLATIONS);
my $originalsource = "$file.".$root->getAttribute("original").".xhtml";
my $comment;
my $old_outdated = 0;
if (( stat("$opts{i}/$originalsource"))[9] > (stat($source))[9] + 7200
and not $cant_be_outdated{$file} ) {
$old_outdated = 1;
} else {
}
my $new_outdated = 0;
if ( not -e "$opts{i}/$originalsource" ) {
# TODO: do something
} else {
my ($equal, $err) = areEqual( "$opts{i}/$originalsource", $source );
if ( not $equal and not $cant_be_outdated{$file} ) {
#print "$err\n";
$root->setAttribute("outdated", "yes");
$new_outdated = 1;
# register information about the outdated status
my $info = $dom->createElement("outdated-info");
my $code = $dom->createElement("code");
$code->appendChild($dom->createElement("br"));
foreach $line (split(/\n/, $err)) {
$code->appendText($line);
$code->appendChild($dom->createElement("br"));
}
$info->appendChild($code);
$document->appendChild($info);
} else {
$root->setAttribute("outdated", "no");
}
} else {
$root->setAttribute("outdated", "no");
}
}
if ($dir eq "global" and $new_outdated != $old_outdated ) {
if ( $new_outdated == 0 and $old_outdated == 1 ) {
$comment = "timestamp-OUT,structure-OK";
} elsif ( $new_outdated == 1 and $old_outdated == 0 ) {
$comment = "timestamp-OK,structure-OUT";
} else {
$comment = "-";
}
lock(*TRANSLATIONS);
print TRANSLATIONS "$lang $source $originalsource $comment\n";
unlock(*TRANSLATIONS);
}
#
# 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-$textlang.xml") {
$textlang = "en";
}

#
# 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-$textlang.xml") {
$textlang = "en";
}
my $textdoc = $dom->createElement("textset");
$root->appendChild($textdoc);
clone_document($textdoc, $opts{i}."/tools/texts-$textlang.xml");

my $textdoc = $dom->createElement("textset");
$root->appendChild($textdoc);
clone_document($textdoc, $opts{i}."/tools/texts-$textlang.xml");

#
# Read the fundraising text, if it exists.
#
if (-f $opts{i}."/fundraising.$lang.xml") {
my $fundraisingdoc = $dom->createElement("fundraising");
$root->appendChild($fundraisingdoc);
clone_document($fundraisingdoc, $opts{i}."/fundraising.$lang.xml");
} elsif (-f $opts{i}."/fundraising.en.xml") {
my $fundraisingdoc = $dom->createElement("fundraising");
$root->appendChild($fundraisingdoc);
clone_document($fundraisingdoc, $opts{i}."/fundraising.en.xml");
}


#
# And then we do the same thing for the menues. But first we take the
# global menu here, then we add any information that is specific to
# the focus.
#
foreach ($root->getElementsByTagName("menuset")) {
$root->removeChild($_);
}

my %menu;
foreach ('global', $dir) {
if (-f $opts{i}."/tools/menu-$_.xml") {
my $menudoc = $parser->parse_file($opts{i}."/tools/menu-$_.xml");
foreach my $n ($menudoc->documentElement->getElementsByTagName("menu")) {
$menu{$n->getAttribute("id")} = $n;
}
}
}
my $menuroot = $dom->createElement("menuset");
while (my ($id, $n) = each %menu) {
my $m = $n->cloneNode(1);
$menuroot->appendChild($m);
}
$root->appendChild($menuroot);
# <start addendum> (TODO: transform this into a function)
#
# 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.
#
# Read the fundraising text, if it exists.
# "Learn all that is learnable and return that information
# to the Creator."
#
if (-f $opts{i}."/fundraising.$lang.xml") {
my $fundraisingdoc = $dom->createElement("fundraising");
$root->appendChild($fundraisingdoc);
clone_document($fundraisingdoc, $opts{i}."/fundraising.$lang.xml");
} elsif (-f $opts{i}."/fundraising.en.xml") {
my $fundraisingdoc = $dom->createElement("fundraising");
$root->appendChild($fundraisingdoc);
clone_document($fundraisingdoc, $opts{i}."/fundraising.en.xml");
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;
}
}
}
}
}


#
# And then we do the same thing for the menues. But first we take the
# global menu here, then we add any information that is specific to
# the focus.
#
foreach ($root->getElementsByTagName("menuset")) {
$root->removeChild($_);
}

my %menu;
foreach ('global', $dir) {
if (-f $opts{i}."/tools/menu-$_.xml") {
my $menudoc = $parser->parse_file($opts{i}."/tools/menu-$_.xml");
foreach my $n ($menudoc->documentElement->getElementsByTagName("menu")) {
$menu{$n->getAttribute("id")} = $n;
}
}
}
my $menuroot = $dom->createElement("menuset");
while (my ($id, $n) = each %menu) {
my $m = $n->cloneNode(1);
$menuroot->appendChild($m);
}
$root->appendChild($menuroot);
# 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.
# Do the actual transformation. (through fsfe.xsl)
#
my $results = $global_stylesheet->transform($dom);

@@ -656,14 +801,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/;
@@ -739,23 +884,35 @@ foreach (grep(!/\.sources$/, grep(!/\.xsl$/, grep(!/\.xml$/, grep(!/\.xhtml$/,
sub clone_document {
my ($doc, $source) = @_;
my $root = $doc->parentNode;
print "Source: $source\n" if $opts{d};
foreach ($root->getElementsByTagName($doc->nodeName)) {
$root->removeChild($_);
$root->removeChild($_);
}
$root->appendChild($doc);
my $parser = XML::LibXML->new();
$parser->load_ext_dtd(0);
$parser->recover(1);
my $sourcedoc = $parser->parse_file($source);
foreach ($sourcedoc->documentElement->childNodes) {
$_->unbindNode();
my $n = $_->cloneNode(1);
$doc->appendChild($n);
$_->unbindNode();
my $n = $_->cloneNode(1);
$doc->appendChild($n);
}
if ($sourcedoc->documentElement->getAttribute("external")) {
$doc->setAttribute("external", "yes");
}
if ($sourcedoc->documentElement->getAttribute("newsdate")) {
# necessary for xhtml news files
$doc->setAttribute("newsdate", $sourcedoc->documentElement->getAttribute("newsdate"));
}
if ($sourcedoc->documentElement->getAttribute("type")) {
# necessary to differentiate news and newsletter pages
# TODO: find a way to copy all such attributes!
$doc->setAttribute("type", $sourcedoc->documentElement->getAttribute("type"));
}
}


+ 222
- 3
tools/build.pl.test.patch View File

@@ -1,6 +1,214 @@
--- build.pl 2011-01-15 13:20:06.000000000 +0100
+++ build-test.pl 2011-01-15 14:31:46.000000000 +0100
@@ -650,9 +650,9 @@
--- build.pl 2011-08-17 12:54:16.000000000 +0200
+++ build-test.pl 2011-08-17 12:54:47.000000000 +0200
@@ -1,6 +1,6 @@
#! /usr/bin/perl
#
-# build.pl - a tool for building FSFE web pages
+# build.pl - a tool for building FSF Europe web pages
#
# Copyright (C) 2003 Jonas Öberg
#
@@ -32,6 +32,12 @@
use Socket;
use Fcntl ':flock';
+use FindBin;
+use lib "$FindBin::Bin";
+
+
+require "comptree.pl";
+
# This defines the focuses and their respective preferred / original
# language. For example, it says that we should have a focus called
# "se" (Sweden) which has the preferred language "sv" (Swedish).
@@ -95,8 +101,7 @@
# This static array contains files that can't be out of date
our %cant_be_outdated = (
- "news/news" => 1,
- "index" => 1
+ "news/news" => 1
);
@@ -319,6 +324,8 @@
sub process {
my ($file, $langs) = @_;
+ #print "$file\n";
+
print STDERR "Building $file.. \n" unless $opts{q};
# Create the root note for the above mentioned XML file (used to feed the XSL
# transformation).
@@ -387,9 +394,9 @@
# Transform it, once for every focus!
#
while (my ($dir, undef) = each %countries) {
+
# If we handle a focus specific file, only process it in that focus
- # -> we don't handle focus-specific files anymore, commenting next line out, since it's causing errors
- #next if (("$srcfocus" ne "global") && ("$dir" ne "$srcfocus"));
+ next if (("$srcfocus" ne "global") && ("$dir" ne "$srcfocus"));
print STDERR "$dir " unless $opts{q};
@@ -587,16 +594,65 @@
# with the original (but maybe a second earlier) isn't marked outdated.
#
my $originalsource = "$file.".$root->getAttribute("original").".xhtml";
+
+ my $comment;
+
+ my $old_outdated = 0;
if (( stat("$opts{i}/$originalsource"))[9] > (stat($source))[9] + 7200
and not $cant_be_outdated{$file} ) {
+
+ $old_outdated = 1;
+
+ } else {
+
+ }
+
+ my $new_outdated = 0;
+ if ( not -e "$opts{i}/$originalsource" ) {
+
+ # TODO: do something
+
+ } else {
+
+ my ($equal, $err) = areEqual( "$opts{i}/$originalsource", $source );
+ if ( not $equal and not $cant_be_outdated{$file} ) {
+ #print "$err\n";
$root->setAttribute("outdated", "yes");
- if ($dir eq "global") {
- lock(*TRANSLATIONS);
- print TRANSLATIONS "$lang $source $originalsource\n";
- unlock(*TRANSLATIONS);
+ $new_outdated = 1;
+
+ # register information about the outdated status
+ my $info = $dom->createElement("outdated-info");
+ my $code = $dom->createElement("code");
+ $code->appendChild($dom->createElement("br"));
+ foreach $line (split(/\n/, $err)) {
+ $code->appendText($line);
+ $code->appendChild($dom->createElement("br"));
}
+ $info->appendChild($code);
+ $document->appendChild($info);
+
} else {
+
$root->setAttribute("outdated", "no");
+
+ }
+
+ }
+
+ if ($dir eq "global" and $new_outdated != $old_outdated ) {
+
+ if ( $new_outdated == 0 and $old_outdated == 1 ) {
+ $comment = "timestamp-OUT,structure-OK";
+ } elsif ( $new_outdated == 1 and $old_outdated == 0 ) {
+ $comment = "timestamp-OK,structure-OUT";
+ } else {
+ $comment = "-";
+ }
+
+ lock(*TRANSLATIONS);
+ print TRANSLATIONS "$lang $source $originalsource $comment\n";
+ unlock(*TRANSLATIONS);
+
}
#
@@ -652,8 +708,84 @@
}
$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);
@@ -663,9 +795,9 @@
#
foreach ($results->documentElement->getElementsByTagName("a")) {
my $href = $_->getAttribute("href");
@@ -12,3 +220,14 @@
}
}
if (($href !~ /^http/) && ($href !~ /^#/)) {
@@ -691,10 +823,6 @@
}
# replace anchor
$href .= $anchor;
- # For pages running on an external server, use full URL
- if ($document->getAttribute("external")) {
- $href = "http://www.fsfe.org$href";
- }
$_->setAttribute("href", $href);
}
}

Loading…
Cancel
Save