From 1675ca4721614067f8ad493d6958e2ea1d8a51e0 Mon Sep 17 00:00:00 2001
From: Gianni Ceccarelli
Date: Tue, 19 Nov 2013 12:55:24 +0000
Subject: make output a bit more stable
---
fixdates.sh | 12 ++++++++++++
lib/WebCoso/XSLT.pm | 19 ++++++++++---------
t/test-site-output/bar/baz/document.en.html | 18 +++++++++---------
t/test-site-output/bar/baz/document.it.html | 18 +++++++++---------
t/test-site-output/bar/document.en.html | 18 +++++++++---------
t/test-site-output/bar/document.it.html | 18 +++++++++---------
t/test-site-output/document.en.html | 18 +++++++++---------
t/test-site-output/document.it.html | 18 +++++++++---------
t/test-site-output/en-only/document.en.html | 18 +++++++++---------
t/test-site-output/feed.it.xml | 9 ++++++++-
t/test-site-output/foo/document.en.html | 18 +++++++++---------
t/test-site-output/foo/document.it.html | 18 +++++++++---------
t/test-site-output/tags/one/document.en.html | 22 +++++++++++-----------
t/test-site-output/tags/one/document.it.html | 22 +++++++++++-----------
t/test-site-output/tags/one/feed.en.xml | 8 ++++----
t/test-site-output/tags/three/bis/document.en.html | 18 +++++++++---------
t/test-site-output/tags/three/bis/document.it.html | 18 +++++++++---------
t/test-site-output/tags/three/document.en.html | 18 +++++++++---------
t/test-site-output/tags/three/document.it.html | 18 +++++++++---------
t/test-site-output/tags/two/document.en.html | 22 +++++++++++-----------
t/test-site-output/tags/two/document.it.html | 22 +++++++++++-----------
21 files changed, 195 insertions(+), 175 deletions(-)
create mode 100755 fixdates.sh
diff --git a/fixdates.sh b/fixdates.sh
new file mode 100755
index 0000000..fc7f32a
--- /dev/null
+++ b/fixdates.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+thisdir="$(cd "$(dirname "$0")";pwd)"
+cd "$thisdir"
+git ls-files -z | \
+while read -d $'\0' filename; do
+ date="$(git log -n 1 --pretty='format:%ct' -- "$filename")"
+ if [[ -n "$date" ]]; then
+ echo "updating <$filename> to date <$date>"
+ touch -d @"$date" "$filename"
+ fi
+done
diff --git a/lib/WebCoso/XSLT.pm b/lib/WebCoso/XSLT.pm
index e5ca549..36c22f3 100644
--- a/lib/WebCoso/XSLT.pm
+++ b/lib/WebCoso/XSLT.pm
@@ -125,15 +125,15 @@ sub getTagsXML {
$doc->setDocumentElement($de);
return $doc unless defined $self->{tags_source};
- my ($tagname,$doclist);
- while (($tagname,$doclist)=each %{$self->{tags_source}}) {
+ for my $tagname (sort keys %{$self->{tags_source}}) {
+ my $doclist = $self->{tags_source}{$tagname};
my $te=$doc->createElementNS($NS,'wc:tag');
$te->setAttribute('name',$tagname);
$de->appendChild($te);
my %docs;
push @{$docs{WebCoso::Common::dstUriFor($_)}},WebCoso::Common::langOf($_) for @$doclist;
- my ($docurl,$langs);
- while (($docurl,$langs)=each %docs) {
+ for my $docurl (sort keys %docs) {
+ my $langs = $docs{$docurl};
my $dle=$doc->createElementNS($NS,'wc:doc');
$dle->setAttribute('uri',$docurl||'ERRORE');
$te->appendChild($dle);
@@ -170,15 +170,15 @@ sub getChangesXML {
$doc->setDocumentElement($de);
return $doc unless defined $self->{changes_source};
- my ($docpath,$dates);
- while (($docpath,$dates)=each %{$self->{changes_source}}) {
+ for my $docpath (sort keys %{$self->{changes_source}}) {
+ my $dates = $self->{changes_source}{$docpath};
my $te=$doc->createElementNS($NS,'wc:document');
$te->setAttribute('path',$docpath);
$te->setAttribute('uri',WebCoso::Common::dstUriFor($docpath));
$te->setAttribute('lang',WebCoso::Common::langOf($docpath));
$de->appendChild($te);
- my ($type,$value);
- while (($type,$value)=each %$dates) {
+ for my $type (sort keys %$dates) {
+ my $value = $dates->{$type};
my $dle=$doc->createElementNS($NS,$name_map{$type});
$dle->appendTextNode($format->format_datetime($value));
$te->appendChild($dle);
@@ -194,7 +194,8 @@ sub getDatesXML {
my $de=$doc->createElementNS($NS,'wc:dates');
$doc->setDocumentElement($de);
- while (my ($k,$v)=each %$dates) {
+ for my $k (sort keys %$dates) {
+ my $v = $dates->{$k};
my $d=$doc->createElementNS($NS,$name_map{$k});
$d->appendTextNode($format->format_datetime($v));
$de->appendChild($d);
diff --git a/t/test-site-output/bar/baz/document.en.html b/t/test-site-output/bar/baz/document.en.html
index ae0aa6f..c9f5424 100644
--- a/t/test-site-output/bar/baz/document.en.html
+++ b/t/test-site-output/bar/baz/document.en.html
@@ -6,24 +6,24 @@
- Category 'one'
- Category 'three/bis'
- Category 'two'
-
Creato: 1970-01-01 00:00:00
- Ultima modifica: 2009-01-08 16:41:12