From 7c110eed4873d7805db304f957278320e5aea0c7 Mon Sep 17 00:00:00 2001 From: "Paul C. Buetow (mars.fritz.box)" Date: Sun, 27 Apr 2014 12:34:02 +0200 Subject: add sitemap.inc.pl --- sitemap.buetow.org/content/sitemap.inc.pl | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 sitemap.buetow.org/content/sitemap.inc.pl (limited to 'sitemap.buetow.org/content/sitemap.inc.pl') diff --git a/sitemap.buetow.org/content/sitemap.inc.pl b/sitemap.buetow.org/content/sitemap.inc.pl new file mode 100644 index 0000000..37740e7 --- /dev/null +++ b/sitemap.buetow.org/content/sitemap.inc.pl @@ -0,0 +1,36 @@ +my $hostroot = $config->get_hostroot(); + +sub getf ($) { + open my $f, $_[0] or die "$!: $_[0]\n"; + my @slurp = <$f>; + close $f; + @slurp; +} + +sub nl () { "
\n" } + +sub list (*) { + my $tag = shift; + my @found = sort `find $hostroot -name $tag`; + my $ret = ''; + + + for my $found (@found) { + $found =~ /.*hosts.(.*?).$tag/; + my $host = $1; + + my @content = getf $found; + + $ret .= "$host" . nl;; + + if (@content) { + $ret .= join " ", @content; + $ret .= nl; + } + $ret .= nl; + } + + $ret; +} + +list SITEMAP; -- cgit v1.2.3 From 4f1da9553943f9c2e6c9dd2790b3ff739b5f372f Mon Sep 17 00:00:00 2001 From: "Paul C. Buetow (mars.fritz.box)" Date: Sun, 27 Apr 2014 13:41:37 +0200 Subject: new sitemap --- sitemap.buetow.org/content/sitemap.inc.pl | 45 +++++++++++++++---------------- 1 file changed, 21 insertions(+), 24 deletions(-) (limited to 'sitemap.buetow.org/content/sitemap.inc.pl') diff --git a/sitemap.buetow.org/content/sitemap.inc.pl b/sitemap.buetow.org/content/sitemap.inc.pl index 37740e7..6b08b82 100644 --- a/sitemap.buetow.org/content/sitemap.inc.pl +++ b/sitemap.buetow.org/content/sitemap.inc.pl @@ -1,36 +1,33 @@ my $hostroot = $config->get_hostroot(); -sub getf ($) { - open my $f, $_[0] or die "$!: $_[0]\n"; - my @slurp = <$f>; - close $f; - @slurp; -} - +sub space () { " " x 10 } sub nl () { "
\n" } sub list (*) { my $tag = shift; - my @found = sort `find $hostroot -name $tag`; - my $ret = ''; - - - for my $found (@found) { - $found =~ /.*hosts.(.*?).$tag/; - my $host = $1; - - my @content = getf $found; - - $ret .= "$host" . nl;; - - if (@content) { - $ret .= join " ", @content; - $ret .= nl; + my @homepages = sort `find $hostroot -name $tag`; + my @ret = (); + + for my $homepage (sort @homepages) { + my ($host) = $homepage =~ /.*hosts.(.*?).$tag/; + push @ret, "$host", nl; + + my $sitepath = "$hostroot/$host"; + + my @pages = sort `find $sitepath -name \*.xml`; + for my $page (sort @pages) { + my ($site) = $page =~ m#$host/content/(.*)\.xml$#; + $site =~ s#\.sub/#/#g; + $site =~ s#\d\d\.##g; + next if $site eq 'home'; + my $sitelink = "http://$host?site=$site"; + push @ret, space, "$site", nl; } - $ret .= nl; + + push @ret, nl; } - $ret; + join '', @ret; } list SITEMAP; -- cgit v1.2.3