- XSLTify the multimedia pages with a slightly different approach than the

earlier one.  It does not any more has per-tag and per-source pages
  but one page for tags and one for sources with anchors.  With the current
  number of entries it will probably be fine for a long time but if once
  we need to divide it into smaller chunks, it will be easier with XSLT.
- Now the documents are also rebuilt if stylesheets or the source XML
  database changes and the build time is drastically decreased.

Reviewed by:	www@
This commit is contained in:
Gabor Kovesdan 2012-09-21 10:02:57 +00:00
parent 124917ccbd
commit 2e69c9e705
Notes: svn2git 2020-12-08 03:00:23 +00:00
svn path=/head/; revision=39589
15 changed files with 5085 additions and 1997 deletions

View file

@ -10,30 +10,11 @@
.include "Makefile.inc"
.endif
#all: build
all: build
cd output && make all DIRPRFX=multimedia/output/
XMLDOCS= multimedia:xsl:multimedia-input.xml:
XMLDOCS+= multimedia-rss:xsl:multimedia-input.xml:multimedia.xml
XMLDOCS+= sources:xsl:multimedia-input.xml:
XMLDOCS+= tags:xsl:multimedia-input.xml:
install:
cd output && make install DIRPRFX=multimedia/output/
TEMPLATES= multimedia.sgml.intro \
multimedia.sgml.post \
multimedia.sgml.pre \
multimedia.html.intro \
multimedia.html.post \
multimedia.html.pre \
multimedia-input.xml
clean:
${RM} -rf output ${CLEANFILES}
build:
${MKDIR} -p output && \
cd output && \
${LN} -fs ../Makefile.output Makefile && \
( for f in ${TEMPLATES}; do ${LN} -fs ../$$f $$f; done ) && \
${PERL} -Tw ../multimedia.pl && \
${RM} -f *.html
INDEXLINK= multimedia.html
.include "${DOC_PREFIX}/share/mk/web.site.mk"

View file

@ -1,18 +0,0 @@
# $FreeBSD$
.if exists(../../Makefile.conf)
.include "../../Makefile.conf"
.endif
.if exists(../../Makefile.inc)
.include "../../Makefile.inc"
.endif
DOCS!= cat multimedia.sgml.created
DATA= multimedia.xml
INDEXLINK= multimedia.html
WEBDIR= multimedia
DOC_PREFIX:= ${DOC_PREFIX}/../
.include "${DOC_PREFIX}/share/mk/web.site.mk"

View file

@ -0,0 +1,111 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE xsl:stylesheet PUBLIC "-//FreeBSD//DTD FreeBSD XSLT 1.0 DTD//EN"
"http://www.FreeBSD.org/XML/www/share/sgml/xslt10-freebsd.dtd">
<!-- $FreeBSD$ -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:str="http://exslt.org/strings"
xmlns="http://www.w3.org/1999/xhtml"
extension-element-prefixes="str">
<xsl:import href="http://www.FreeBSD.org/XML/www/share/sgml/libcommon.xsl"/>
<xsl:template name="multimedia.pre">
<h1>FreeBSD Multimedia Resources List</h1>
<p>Links on this page refer to multimedia resources (podcast, vodcast,
audio recordings, video recordings, photos) related to FreeBSD or
of interest for FreeBSD users.</p>
<p>This list is available as <a href="multimedia.html">chronological
overview</a>, as a <a href="tags.html">tag cloud</a> and
via <a href="sources.html">the sources</a>.</p>
<p>This list is also available as RSS feed <a href="multimedia.xml"><img
src="http://www.freebsd.org/layout/images/ico_rss.png"
alt="RSS Feed"/></a></p>
<p>If you know any resources not listed here, or notice any dead links,
please send details to <a
href="mailto:edwin\@FreeBSD.org">Edwin Groothuis</a> so that
it can be included or updated.</p>
</xsl:template>
<xsl:template match="item">
<xsl:variable name="srcId" select="@source"/>
<xsl:variable name="source" select="//source[@id = $srcId]"/>
<li>
<a href="{overview}"><xsl:value-of select="title"/></a><br/>
Source:
<a>
<xsl:attribute name="href">
<xsl:value-of select="$source/url"/>
</xsl:attribute>
<xsl:value-of select="$source/name"/>
</a>
<br/>
Added:
<xsl:call-template name="misc-format-date-string">
<xsl:with-param name="year" select="substring(@added, 1, 4)"/>
<xsl:with-param name="month" select="substring(@added, 5, 2)"/>
<xsl:with-param name="day" select="substring(@added, 7, 2)"/>
</xsl:call-template>
<br/>
Tags:
<xsl:for-each select="tags/tag">
<a>
<xsl:attribute name="href">
<xsl:value-of select="concat('tags.html#', str:replace(., ' ', '_'))"/>
</xsl:attribute>
<xsl:value-of select="."/>
</a>
<xsl:if test="position() != last()">
<xsl:text>, </xsl:text>
</xsl:if>
</xsl:for-each>
<br/>
<xsl:if test="files/file">
<xsl:text>Files: </xsl:text>
</xsl:if>
<xsl:for-each select="files/file">
<a href="{url}"><xsl:value-of select="desc"/></a>
<xsl:if test="size|length">
<xsl:text>&nbsp;(</xsl:text>
<xsl:for-each select="size|length">
<xsl:value-of select="."/>
<xsl:if test="position() != last()">
<xsl:text>,&nbsp;</xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:text>)</xsl:text>
</xsl:if>
<xsl:if test="position() != last()">
<xsl:text>, </xsl:text>
</xsl:if>
</xsl:for-each>
<br/>
<p>
<xsl:value-of select="desc"/>
</p>
</li>
</xsl:template>
</xsl:stylesheet>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE xsl:stylesheet PUBLIC "-//FreeBSD//DTD FreeBSD XSLT 1.0 DTD//EN"
"http://www.FreeBSD.org/XML/www/share/sgml/xslt10-freebsd.dtd" [
<!ENTITY title "FreeBSD Multimedia Resources List">
]>
<!-- $FreeBSD$ -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:date="http://exslt.org/dates-and-times"
extension-element-prefixes="date">
<xsl:import href="http://www.FreeBSD.org/XML/www/share/sgml/libcommon.xsl"/>
<xsl:output method="xml" indent="yes" encoding="&xml.encoding;"/>
<xsl:template match="/">
<rss version="2.0">
<channel>
<title>&title;</title>
<link>http://www.freebsd.org/multimedia/multimedia.html</link>
<description>FreeBSD Multimedia Resources</description>
<lastBuildDate><xsl:value-of select="date:date-time()"/></lastBuildDate>
<xsl:apply-templates select=".//item"/>
</channel>
</rss>
</xsl:template>
<xsl:template match="item">
<item>
<title><xsl:value-of select="title"/></title>
<guid><xsl:value-of select="overview"/></guid>
<pubdate>
<xsl:call-template name="misc-format-date-string">
<xsl:with-param name="year" select="substring(@added, 1, 4)"/>
<xsl:with-param name="month" select="substring(@added, 5, 2)"/>
<xsl:with-param name="day" select="substring(@added, 7, 2)"/>
</xsl:call-template>
</pubdate>
<xsl:for-each select="files/file">
<enclosure url="{url}" length="1" type="application/octet-stream"/>
</xsl:for-each>
<description>
<xsl:value-of select="desc"/>
</description>
</item>
</xsl:template>
</xsl:stylesheet>

View file

@ -1,26 +0,0 @@
<!-- $FreeBSD$ -->
<h1>FreeBSD Multimedia Resources List</h1>
<p>
Links on this page refer to multimedia resources (podcast, vodcast,
audio recordings, video recordings, photos) related to FreeBSD or
of interest for FreeBSD users.
</p>
<p>
<br/>
This list is available as <a href="multimedia.html">chronological
overview</a>, as a <a href="multimedia-tags.html">tag cloud</a> and
via <a href="multimedia-sources.html">the sources</a>.
<br/>
This list is also available as RSS feed <a href="multimedia.xml"><img
src="http://www.freebsd.org/layout/images/ico_rss.png"/></a>
</p>
<p>
If you know any resources not listed here, or notice any dead links,
please send details to
<a href="mailto:edwin\@FreeBSD.org">Edwin Groothuis</a> so that
it can be included or updated.
</p>

View file

@ -1,5 +0,0 @@
<!-- END -->
</div>
</body>
</html>

View file

@ -1,44 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- $FreeBSD$ -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org" />
<title>FreeBSD Multimedia Resources</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="MSSmartTagsPreventParsing" content="TRUE" />
<link rel="shortcut icon" href="http://www.freebsd.org/favicon.ico" type="image/x-icon" />
<link rel="icon" href="http://www.freebsd.org/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" media="screen" href="http://www.freebsd.org/layout/css/fixed.css?20060509"
type="text/css" title="Normal Text" />
<link rel="alternate stylesheet" media="screen" href="http://www.freebsd.org/layout/css/fixed_large.css"
type="text/css" title="Large Text" />
<script type="text/javascript" src="http://www.freebsd.org/layout/js/styleswitcher.js">
</script>
</head>
<body>
<div id="containerwrap">
<div id="container"><span class="txtoffscreen"><a href="#content"
title="Skip site navigation" accesskey="1">Skip site navigation</a> (1)</span> <span
class="txtoffscreen"><a href="#contentwrap" title="Skip section navigation"
accesskey="2">Skip section navigation</a> (2)</span>
<div id="headercontainer">
<div id="header">
<h2 class="blockhide">Header And Logo</h2>
<div id="headerlogoleft"><a href="http://www.freebsd.org" title="FreeBSD"><img
src="http://www.freebsd.org/layout/images/logo-red.png" width="457" height="75" alt="FreeBSD" /></a></div>
<div id="headerlogoright">
<h2 class="blockhide">Peripheral Links</h2>
</div>
</div>
</div>
<div id="content">
<!-- BEGIN -->

View file

@ -1,791 +0,0 @@
#!/usr/bin/perl -w
#
# $Id: multimedia.pl,v 1.6 2008-12-07 06:12:06 edwin Exp $
# $FreeBSD$
#
use strict;
use XML::Parser;
use Data::Dumper;
use POSIX;
use IO::File;
my @months = (
"", "January", "February", "March",
"April", "May", "June", "July",
"August", "September", "October",
"November", "December"
);
my @createdhtml = ();
my @createdsgml = ();
my @createdxml = ();
my @tree = ();
my @values = ();
my $treeindex = -1;
my @items;
my $ci = -1;
my %sources;
my $sid = "";
my %tags;
my $tag = "";
sub addtags {
my $tags = shift;
if ($tags) {
my @w = split(/,/, $tags);
foreach my $w (@w) {
$tags{$w} = 0 if (!defined $tags{$w});
$tags{$w}++;
}
return;
}
my $array = shift;
my @array = @{$array};
foreach my $w (@array) {
$tags{$w} = 0 if (!defined $tags{$w});
$tags{$w}++;
}
}
sub xml_start {
my $expat = shift;
my $element = shift;
$tree[++$treeindex] = $element;
while (defined (my $attribute = shift)) {
$values[$treeindex]{$attribute} = shift;
}
if ($element eq "item"
&& $treeindex == 2) {
$ci++;
$items[$ci] = ();
$items[$ci]{source} = $values[$treeindex]{source};
$items[$ci]{added} = $values[$treeindex]{added};
$items[$ci]{ci} = $ci;
$items[$ci]{fc} = -1;
}
if ($element eq "source"
&& $treeindex == 2) {
$sid = $values[$treeindex]{id};
$sources{$values[$treeindex]{id}} = ();
}
if ($element eq "url"
&& $treeindex == 5) {
$items[$ci]{fc}++;
}
if (($treeindex == 3 || $treeindex == 5) &&
$element eq "tags") {
$tag = "";
}
}
sub xml_end {
my $expat = shift;
my $element = shift;
if ($treeindex == 3 &&
$element eq "tags") {
@{$items[$ci]{tags}} = split(/,/, $tag);
addtags($tag);
}
if ($treeindex == 5 &&
$element eq "tags") {
@{$items[$ci]{files}{$items[$ci]{fc}}{tags}} = split(/,/, $tag);
addtags($tag);
}
$values[$treeindex] = ();
$treeindex--;
}
sub xml_char {
my $expat = shift;
my $value = shift;
if ($tree[0] eq "multimedia") {
return if ($treeindex == 0);
if ($tree[1] eq "items") {
return if ($treeindex == 1);
if ($tree[2] eq "item") {
return if ($treeindex == 2);
if ($tree[3] eq "title") {
$items[$ci]{title} = "" if (!defined $items[$ci]{title});
$items[$ci]{title} .= htmlentities($value);
return;
}
if ($tree[3] eq "desc") {
$items[$ci]{desc} = "" if (!defined $items[$ci]{desc});
$items[$ci]{desc} .= htmlentities($value);
return;
}
if ($tree[3] eq "overview") {
$items[$ci]{overview} = "" if (!defined $items[$ci]{overview});
$items[$ci]{overview} .= $value;
return;
}
if ($tree[3] eq "link") {
$items[$ci]{link} = "" if (!defined $items[$ci]{link});
$items[$ci]{link} .= $value;
return;
}
if ($tree[3] eq "tags") {
$tag .= $value;
return;
}
if ($tree[3] eq "files") {
return if ($treeindex == 3);
if ($tree[4] eq "prefix") {
$items[$ci]{prefix} = "" if (!defined $items[$ci]{prefix});
$items[$ci]{prefix} .= $value;
return;
}
if ($tree[4] eq "file") {
return if ($treeindex == 4);
if ($tree[5] eq "url") {
# Note that $items[$ci]{fc} gets incremented in xml_start
$items[$ci]{files}{$items[$ci]{fc}}{url} = ""
if (!defined $items[$ci]{files}{$items[$ci]{fc}}{url});
$items[$ci]{files}{$items[$ci]{fc}}{url} .= $value;
return;
}
if ($tree[5] eq "size") {
$items[$ci]{files}{$items[$ci]{fc}}{size} = ""
if (!defined $items[$ci]{files}{$items[$ci]{fc}}{size});
$items[$ci]{files}{$items[$ci]{fc}}{size} .= $value;
return;
}
if ($tree[5] eq "length") {
$items[$ci]{files}{$items[$ci]{fc}}{length} = ""
if (!defined $items[$ci]{files}{$items[$ci]{fc}}{length});
$items[$ci]{files}{$items[$ci]{fc}}{length} .= $value;
return;
}
if ($tree[5] eq "desc") {
$items[$ci]{files}{$items[$ci]{fc}}{desc} = ""
if (!defined $items[$ci]{files}{$items[$ci]{fc}}{desc});
$items[$ci]{files}{$items[$ci]{fc}}{desc} .= htmlentities($value);
return;
}
if ($tree[5] eq "tags") {
$tag .= $value;
return;
}
goto error;
}
goto error;
}
goto error;
}
goto error;
}
if ($tree[1] eq "sources") {
return if ($treeindex == 1);
if ($tree[2] eq "source") {
return if ($treeindex == 2);
if ($tree[3] eq "name") {
$sources{$sid}{name} = $value;
return;
}
if ($tree[3] eq "url") {
$sources{$sid}{url} = $value;
return;
}
goto error;
}
goto error;
}
goto error;
}
error:
print "Unknown item at depth $treeindex: $tree[$treeindex]\n";
}
my $p = new XML::Parser(
Handlers => {
Start => \&xml_start,
End => \&xml_end,
Char => \&xml_char,
}
);
$p->parsefile("multimedia-input.xml");
my @site_order = ();
{
sub site_sort {
my %a = %{$a};
my %b = %{$b};
return $a{source} cmp $b{source}
if ($a{source} ne $b{source});
return $a{title} cmp $b{title};
}
@site_order = sort site_sort @items;
}
my @date_order = ();
{
my %dates = ();
foreach my $item (@items) {
my %item = %{$item};
$dates{$item{ci}} = $item{added};
}
my @dates = keys(%dates);
@date_order = sort { $dates{$b} cmp $dates{$a} } @dates;
}
#
# HTML overview output
#
sub print_htmlitem {
my $fhandle = shift;
my $item = shift;
my %item = %{$item};
my $source = shift;
my %source = %{$source};
print $fhandle "<li><p>";
if (defined $item{overview}) {
print $fhandle "<a href=\"", htmlentities($item{overview}), "\">$item{title}</a>\n";
} else {
my %media = %{$item{files}{0}};
print $fhandle "<a href=\"", htmlentities($media{url}), "\">$item{title}</a>\n";
if (defined $media{size} || defined $media{length}) {
my $s = "";
print $fhandle "(";
if (defined $media{size}) {
print $fhandle "$media{size}";
$s = ", ";
}
if (defined $media{length}) {
print $fhandle "$s$media{length}";
$s = ", ";
}
print $fhandle ")";
}
}
print $fhandle "<br/>Source: <a href=\"", htmlentities($source{url}), "\">",
$source{name}, "</a><br/>\n";
print $fhandle "Added: ",
substr($item{added}, 6, 2), " ",
$months[substr($item{added}, 4, 2)], " ",
substr($item{added}, 0, 4), "<br/>\n";
print $fhandle "Tags: ";
{
my $first = 1;
foreach my $t (@{$item{tags}}) {
print $fhandle ", " if (!$first);
# join(", ", @{$item{$t}}), "<br/>\n";
my $th = $t;
$th =~ s/ /_/g;
print $fhandle "<a href=\"tag-$th.html\">$t</a>";
$first = 0;
}
}
print $fhandle "<br/>\n";
if (defined $item{overview} && defined $item{files}) {
my $c = 0;
foreach my $m (keys(%{$item{files}})) {
my %file = %{$item{files}{$m}};
print $fhandle ", " if ($c++);
if (defined $item{prefix}) {
print $fhandle "<a href=\"" . htmlentities($item{prefix} . "/" . $file{url}) . "\">$file{desc}</a>";
} else {
print $fhandle "<a href=\"" . htmlentities($file{url}) . "\">$file{desc}</a>";
}
if (defined $file{size} || defined $file{length}) {
my $s = "";
print $fhandle " (";
if (defined $file{size}) {
print $fhandle "$file{size}";
$s = ", ";
}
if (defined $file{length}) {
print $fhandle "$s$file{length}";
$s = ", ";
}
print $fhandle ")";
}
}
print $fhandle "<br/>\n";
}
print $fhandle "</p>\n";
print $fhandle "$item{desc}\n";
print $fhandle "</li>\n";
}
{
$createdhtml[$#createdhtml+1] = "multimedia.html";
$createdsgml[$#createdsgml+1] = "multimedia.sgml";
my $fhtml = new IO::File;
my $fsgml = new IO::File;
open($fhtml, ">multimedia.html");
open(FIN, "multimedia.html.pre");
my @lines = <FIN>;
close(FIN);
print $fhtml @lines;
open(FIN, "multimedia.html.intro");
@lines = <FIN>;
close(FIN);
print $fhtml @lines;
print $fhtml "<h2 id=\"latest\">Newest resources</h2>\n";
open($fsgml, ">multimedia.sgml");
open(FIN, "multimedia.sgml.pre");
@lines = <FIN>;
close(FIN);
print $fsgml @lines;
open(FIN, "multimedia.sgml.intro");
@lines = <FIN>;
close(FIN);
print $fsgml @lines;
print $fsgml "<h2 id=\"latest\">Newest resources</h2>\n";
my $month = "";
foreach my $order (@date_order) {
my %item = %{$items[$order]};
my %source = %{$sources{$item{source}}};
if (substr($item{added}, 0, 6) ne $month) {
if ($month ne "") {
print $fhtml "</ul>\n";
print $fsgml "</ul>\n";
}
print $fhtml "<h2>", $months[substr($item{added}, 4, 2)+0], " ", substr($item{added}, 0, 4), "</h2><ul>";
print $fsgml "<h2>", $months[substr($item{added}, 4, 2)+0], " ", substr($item{added}, 0, 4), "</h2><ul>";
$month = substr($item{added}, 0, 6);
}
print_htmlitem($fhtml, \%item, \%source);
print_htmlitem($fsgml, \%item, \%source);
}
print $fhtml "</ul>\n";
open(FIN, "multimedia.html.post");
@lines = <FIN>;
close(FIN);
print $fhtml @lines;
close($fhtml);
print $fsgml "</ul>\n";
open(FIN, "multimedia.sgml.post");
@lines = <FIN>;
close(FIN);
print $fsgml @lines;
close($fsgml);
}
#
# HTML cloud output
#
{
$createdhtml[$#createdhtml+1] = "tags.html";
$createdsgml[$#createdsgml+1] = "tags.sgml";
my $fhtml = new IO::File;
my $fsgml = new IO::File;
open($fhtml, ">tags.html");
open($fsgml, ">tags.sgml");
open(FIN, "multimedia.html.pre");
my @lines = <FIN>;
close(FIN);
print $fhtml @lines;
open(FIN, "multimedia.html.intro");
@lines = <FIN>;
close(FIN);
print $fhtml @lines;
print $fhtml "<h2 id=\"latest\">Tags</h2>\n";
open(FIN, "multimedia.sgml.pre");
@lines = <FIN>;
close(FIN);
print $fsgml @lines;
open(FIN, "multimedia.sgml.intro");
@lines = <FIN>;
close(FIN);
print $fsgml @lines;
print $fsgml "<h2 id=\"latest\">Tags</h2>\n";
my $month = "";
sub size {
return $b cmp $a if ($tags{$b} == $tags{$a});
return $tags{$b} <=> $tags{$a};
}
my $size = 20;
my $c = 0;
foreach my $tag (sort size keys(%tags)) {
my $ftag = $tag;
$ftag =~ s/ /_/g;
print $fhtml "<font style=\"font-size:${size}pt\"><a href=\"tag-$ftag.html\">$tag</a></font>\n";
print $fsgml "<font style=\"font-size:${size}pt\"><a href=\"tag-$ftag.html\">$tag</a></font>\n";
$size-- if ($c++%10 == 0 && $size > 2);
}
open(FIN, "multimedia.html.post");
@lines = <FIN>;
close(FIN);
print $fhtml @lines;
open(FIN, "multimedia.sgml.post");
@lines = <FIN>;
close(FIN);
print $fsgml @lines;
close($fhtml);
close($fsgml);
}
#
# HTML per-tags output
#
{
foreach my $tag (keys(%tags)) {
my $fhtml = new IO::File;
my $fsgml = new IO::File;
my $ftag = $tag;
$ftag =~ s/ /_/g;
$createdhtml[$#createdhtml+1] = "tag-$ftag.html";
$createdsgml[$#createdsgml+1] = "tag-$ftag.sgml";
open($fhtml, ">tag-$ftag.html");
open($fsgml, ">tag-$ftag.sgml");
open(FIN, "multimedia.html.pre");
my @lines = <FIN>;
close(FIN);
print $fhtml @lines;
open(FIN, "multimedia.html.intro");
@lines = <FIN>;
close(FIN);
print $fhtml @lines;
print $fhtml "<h2 id=\"latest\">Tag: $tag</h2>\n";
print $fhtml "<ul>\n";
open(FIN, "multimedia.sgml.pre");
@lines = <FIN>;
close(FIN);
print $fsgml @lines;
open(FIN, "multimedia.sgml.intro");
@lines = <FIN>;
close(FIN);
print $fsgml @lines;
print $fsgml "<h2 id=\"latest\">Tag: $tag</h2>\n";
print $fsgml "<ul>\n";
foreach my $item (@items) {
my %item = %{$item};
my %source = %{$sources{$item{source}}};
my $found = 0;
foreach my $itag (@{$item{tags}}) {
if ($itag eq $tag) {
$found = 1;
last;
}
}
if (!$found) {
foreach my $file (keys(%{$item{files}})) {
my %file = %{$item{files}{$file}};
foreach my $itag (@{$file{tags}}) {
if ($itag eq $tag) {
$found = 1;
last;
}
}
}
}
print_htmlitem($fhtml, \%item, \%source) if ($found);
print_htmlitem($fsgml, \%item, \%source) if ($found);
}
print $fhtml "</ul>\n";
open(FIN, "multimedia.html.post");
@lines = <FIN>;
close(FIN);
print $fhtml @lines;
close($fhtml);
print $fsgml "</ul>\n";
open(FIN, "multimedia.sgml.post");
@lines = <FIN>;
close(FIN);
print $fsgml @lines;
close($fsgml);
}
}
#
# HTML all-sources output
#
{
my $fhtml = new IO::File;
my $fsgml = new IO::File;
$createdhtml[$#createdhtml+1] = "sources.html";
$createdsgml[$#createdsgml+1] = "sources.sgml";
open($fhtml, ">sources.html");
open($fsgml, ">sources.sgml");
open(FIN, "multimedia.html.pre");
my @lines = <FIN>;
close(FIN);
print $fhtml @lines;
open(FIN, "multimedia.html.intro");
@lines = <FIN>;
close(FIN);
print $fhtml @lines;
print $fhtml "<h2 id=\"latest\">Sources</h2>\n";
print $fhtml "<ul>\n";
open(FIN, "multimedia.sgml.pre");
@lines = <FIN>;
close(FIN);
print $fsgml @lines;
open(FIN, "multimedia.sgml.intro");
@lines = <FIN>;
close(FIN);
print $fsgml @lines;
print $fsgml "<h2 id=\"latest\">Sources</h2>\n";
print $fsgml "<ul>\n";
my $lastsource = "";
foreach my $item (@site_order) {
my %item = %{$item};
next if ($lastsource eq $item{source});
$lastsource = $item{source};
print $fhtml "<li><a href=\"source-$lastsource.html\">", $sources{$item{source}}{name}, "</a></li>\n";
print $fsgml "<li><a href=\"source-$lastsource.html\">", $sources{$item{source}}{name}, "</a></li>\n";
}
print $fhtml "</ul>\n";
open(FIN, "multimedia.html.post");
@lines = <FIN>;
close(FIN);
print $fhtml @lines;
close($fhtml);
print $fsgml "</ul>\n";
open(FIN, "multimedia.sgml.post");
@lines = <FIN>;
close(FIN);
print $fsgml @lines;
close($fsgml);
}
#
# HTML per-source output
#
{
my $fhtml = new IO::File;
my $fsgml = new IO::File;
my $lastsource = "";
foreach my $item (@site_order) {
my %item = %{$item};
my %source = %{$sources{$item{source}}};
if ($lastsource ne $item{source}) {
if ($lastsource) {
print $fhtml "</ul>\n";
print $fsgml "</ul>\n";
open(FIN, "multimedia.html.post");
my @lines = <FIN>;
close(FIN);
print $fhtml @lines;
close($fhtml);
open(FIN, "multimedia.sgml.post");
@lines = <FIN>;
close(FIN);
print $fsgml @lines;
close($fsgml);
}
$createdhtml[$#createdhtml+1] = "source-$item{source}.html";
$createdsgml[$#createdsgml+1] = "source-$item{source}.sgml";
open($fhtml, ">source-$item{source}.html");
open($fsgml, ">source-$item{source}.sgml");
open(FIN, "multimedia.html.pre");
my @lines = <FIN>;
close(FIN);
print $fhtml @lines;
open(FIN, "multimedia.html.intro");
@lines = <FIN>;
close(FIN);
print $fhtml @lines;
open(FIN, "multimedia.sgml.pre");
@lines = <FIN>;
close(FIN);
print $fsgml @lines;
open(FIN, "multimedia.sgml.intro");
@lines = <FIN>;
close(FIN);
print $fsgml @lines;
$lastsource = $item{source};
print $fhtml "<h2 id=\"latest\">$source{name}</h2>\n<ul>\n";
print $fsgml "<h2 id=\"latest\">$source{name}</h2>\n<ul>\n";
}
print_htmlitem($fhtml, \%item, \%source);
print_htmlitem($fsgml, \%item, \%source);
}
print $fhtml "</ul>\n";
print $fsgml "</ul>\n";
open(FIN, "multimedia.html.post");
my @lines = <FIN>;
close(FIN);
print $fhtml @lines;
close($fhtml);
open(FIN, "multimedia.sgml.post");
@lines = <FIN>;
close(FIN);
print $fsgml @lines;
close($fsgml);
}
#
# XML output
#
{
sub htmlentities {
my $s = shift;
$s =~ s/&/&amp;/g;
$s =~ s/</&lt;/g;
$s =~ s/>/&gt;/g;
return $s;;
}
sub printxml_multiple {
my $item = shift;
my %item = %{$item};
my $source = shift;
my %source = %{$source};
return if ($item{fc}<0);
for (my $i = 0; $i <= $item{fc}; $i++) {
my %f = %{$item{files}{$i}};
my %tempitem = %item;
$tempitem{title} .= " - $f{desc}";
$f{url} = "$item{prefix}/$f{url}"
if (defined $item{prefix});
printxml_single(\%tempitem, \%source, \%f);
}
}
sub printxml_single {
my $item = shift;
my %item = %{$item};
my $source = shift;
my %source = %{$source};
my $file = shift;
my %file = %{$file};
my $date = POSIX::strftime("%a, %d %b %Y %H:%M:%S %Z",
0, 0, 0, substr($item{added}, 6, 2),
substr($item{added}, 4, 2)-1, substr($item{added}, 0, 4)-1900);
my $tags = join(", ", @{$item{tags}});
foreach my $tag (@{$file{tags}}) {
$tags .= ", $tag";
}
print FOUT "<item>\n";
print FOUT "<title>", htmlentities("$source{name} - $item{title}"), "</title>\n";
print FOUT "<guid>", htmlentities($file{url}), "</guid>\n";
print FOUT "<pubDate>$date</pubDate>\n";
print FOUT "<enclosure url=\"", htmlentities($file{url}), "\" length=\"1\" type=\"application/octet-stream\" />\n";
print FOUT "<description>";
print FOUT htmlentities("$item{title}<br/>From: $source{name}<br/>");
print FOUT htmlentities("Tags: $tags<br/>\n");
print FOUT htmlentities("$item{desc}");
print FOUT "</description>\n";
print FOUT "</item>\n";
}
$createdxml[$#createdxml+1] = "multimedia.xml";
open(FOUT, ">multimedia.xml");
my @s = stat("multimedia-input.xml");
my $date = POSIX::strftime("%a, %d %b %Y %H:%M:%S %Z", localtime($s[9]));
print FOUT <<EOF;
<rss version="2.0">
<channel>
<title>FreeBSD Multimedia Resources List</title>
<description>FreeBSD Multimedia Resources</description>
<link>http://www.FreeBSD.org/docs/multimedia.html</link>
<lastBuildDate>$date</lastBuildDate>
EOF
foreach my $order (@date_order) {
my %item = %{$items[$order]};
my %source = %{$sources{$item{source}}};
if (defined $item{overview}) {
printxml_multiple(\%item, \%source);
} else {
printxml_single(\%item, \%source, $item{files}{0});
}
}
print FOUT <<EOF;
</channel>
</rss>
EOF
close(FOUT);
}
#
# Created files
#
{
open(FOUT, ">multimedia.html.created");
foreach my $f (@createdhtml) {
print FOUT "$f\n";
}
close(FOUT);
open(FOUT, ">multimedia.sgml.created");
foreach my $f (@createdsgml) {
print FOUT "$f\n";
}
close(FOUT);
}

View file

@ -1,26 +0,0 @@
<!-- $FreeBSD$ -->
<h1>FreeBSD Multimedia Resources List</h1>
<p>
Links on this page refer to multimedia resources (podcast, vodcast,
audio recordings, video recordings, photos) related to FreeBSD or
of interest for FreeBSD users.
</p>
<p>
This list is available as <a href="multimedia.html">chronological
overview</a>, as a <a href="tags.html">tag cloud</a> and
via <a href="sources.html">the sources</a>.
</p>
<p>
This list is also available as RSS feed <a href="multimedia.xml"><img
src="http://www.freebsd.org/layout/images/ico_rss.png" alt="RSS Feed"/></a>
</p>
<p>
If you know any resources not listed here, or notice any dead links,
please send details to
<a href="mailto:edwin\@FreeBSD.org">Edwin Groothuis</a> so that
it can be included or updated.
</p>

View file

@ -1,5 +0,0 @@
<!-- $FreeBSD$ -->
</body>
</html>

View file

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//FreeBSD//DTD XHTML 1.0 Transitional-Based Extension//EN"
"http://www.FreeBSD.org/XML/doc/share/sgml/xhtml10-freebsd.dtd" [
<!ENTITY title "FreeBSD Multimedia">
]>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>&title;</title>
<cvs:keyword xmlns:cvs="http://www.FreeBSD.org/XML/CVS">$FreeBSD$</cvs:keyword>
</head>
<body class="navinclude.about">

View file

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE xsl:stylesheet PUBLIC "-//FreeBSD//DTD FreeBSD XSLT 1.0 DTD//EN"
"http://www.FreeBSD.org/XML/www/share/sgml/xslt10-freebsd.dtd" [
<!ENTITY title "FreeBSD Multimedia">
]>
<!-- $FreeBSD$ -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:date="http://exslt.org/dates-and-times"
xmlns="http://www.w3.org/1999/xhtml"
extension-element-prefixes="date">
<xsl:import href="http://www.FreeBSD.org/XML/www/share/sgml/xhtml.xsl"/>
<xsl:import href="include.xsl"/>
<xsl:key name="date" match="item" use="substring(@added, 1, 6)" />
<xsl:variable name="title">&title;</xsl:variable>
<xsl:template name="process.sidewrap">&nav.about;</xsl:template>
<xsl:template name="process.contentwrap">
<xsl:call-template name="multimedia.pre"/>
<h1>Newest Resources</h1>
<xsl:for-each select="//item[count(. | key('date', substring(@added, 1, 6))[1]) = 1]">
<xsl:sort select="@added" order="descending"/>
<h2>
<xsl:value-of select="date:month-name(concat('--', substring(@added, 5, 2), '--'))"/>
<xsl:text> </xsl:text>
<xsl:value-of select="substring(@added, 1, 4)"/>
</h2>
<ul>
<xsl:for-each select="key('date', substring(@added, 1, 6))">
<xsl:sort select="@added" order="descending"/>
<xsl:apply-templates select="."/>
</xsl:for-each>
</ul>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

View file

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE xsl:stylesheet PUBLIC "-//FreeBSD//DTD FreeBSD XSLT 1.0 DTD//EN"
"http://www.FreeBSD.org/XML/www/share/sgml/xslt10-freebsd.dtd" [
<!ENTITY title "FreeBSD Multimedia">
]>
<!-- $FreeBSD$ -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:import href="http://www.FreeBSD.org/XML/www/share/sgml/xhtml.xsl"/>
<xsl:import href="include.xsl"/>
<xsl:variable name="title">&title;</xsl:variable>
<xsl:template name="process.sidewrap">&nav.about;</xsl:template>
<xsl:template name="process.contentwrap">
<xsl:call-template name="multimedia.pre"/>
<h1>Source List</h1>
<ul>
<xsl:for-each select="//source">
<xsl:sort select="name"/>
<li>
<a>
<xsl:attribute name="href">
<xsl:value-of select="concat('#', @id)"/>
</xsl:attribute>
<xsl:value-of select="name"/>
</a>
</li>
</xsl:for-each>
</ul>
<h1>Multimedia Resources</h1>
<xsl:for-each select="//source">
<xsl:sort select="name"/>
<xsl:variable name="sourceId" select="@id"/>
<h2 id="{@id}"><xsl:value-of select="name"/></h2>
<ul>
<xsl:apply-templates select="/multimedia/items/item[@source = $sourceId]"/>
</ul>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

View file

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE xsl:stylesheet PUBLIC "-//FreeBSD//DTD FreeBSD XSLT 1.0 DTD//EN"
"http://www.FreeBSD.org/XML/www/share/sgml/xslt10-freebsd.dtd" [
<!ENTITY title "FreeBSD Multimedia">
]>
<!-- $FreeBSD$ -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:set="http://exslt.org/sets"
xmlns="http://www.w3.org/1999/xhtml"
extension-element-prefixes="set">
<xsl:import href="http://www.FreeBSD.org/XML/www/share/sgml/xhtml.xsl"/>
<xsl:import href="include.xsl"/>
<xsl:variable name="title">&title;</xsl:variable>
<xsl:template name="process.sidewrap">&nav.about;</xsl:template>
<xsl:template name="process.contentwrap">
<xsl:param name="nodes" select="//tag"/>
<xsl:call-template name="multimedia.pre"/>
<h1>Tag Cloud</h1>
<xsl:for-each select="set:distinct(//tag)">
<xsl:sort select="."/>
<xsl:variable name="tagName" select="./text()"/>
<a>
<xsl:attribute name="style">
<xsl:text>font-size:</xsl:text>
<xsl:value-of select="count(//tag[. = $tagName]) div 3 + 6"/>
<xsl:text>pt;</xsl:text>
</xsl:attribute>
<xsl:attribute name="href">
<xsl:value-of select="concat('#', translate($tagName, ' ', '_'))"/>
</xsl:attribute>
<xsl:value-of select="translate($tagName, ' ', '&nbsp;')"/>
</a>
</xsl:for-each>
<br/>
<h1 style="margin-top: 32pt">Multimedia Resources</h1>
<xsl:for-each select="set:distinct(//tag)">
<xsl:sort select="."/>
<xsl:variable name="tagName" select="./text()"/>
<h2 id="{translate($tagName, ' ', '_')}"><xsl:value-of select="."/></h2>
<ul>
<xsl:apply-templates select="/multimedia/items/item[tags/tag = $tagName]"/>
</ul>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>