summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2009-08-18 15:58:34 +0200
committerdakkar <dakkar@thenautilus.net>2009-08-18 15:58:34 +0200
commitf3e2a9cb7be8e4e58637ec51985223b10960defe (patch)
tree5bc2c2f4394376dd59b12844be294b588a246ef0
parentcreation date is UTC, not local (diff)
downloadthenautilus-f3e2a9cb7be8e4e58637ec51985223b10960defe.tar.gz
thenautilus-f3e2a9cb7be8e4e58637ec51985223b10960defe.tar.bz2
thenautilus-f3e2a9cb7be8e4e58637ec51985223b10960defe.zip
better feeds
- create feeds for news tags - don't use namespace prefixes in feeds - create good Ids for everything
-rwxr-xr-xnew-doc49
-rw-r--r--templates/base-feed.tt2
-rw-r--r--templates/fillFeed.xsl51
3 files changed, 63 insertions, 39 deletions
diff --git a/new-doc b/new-doc
index 1eeff27..23fdadb 100755
--- a/new-doc
+++ b/new-doc
@@ -1,6 +1,22 @@
#!/bin/bash
-
cd "$(dirname "$0")"/src
+
+if [[ $# -eq 0 ]]; then
+ cat <<EOF
+new-doc - create new documents for WebCoso
+
+Usage:
+
+ new-doc <document path> <tag>...
+
+The <document path> will be taken relative to
+$(pwd)
+
+Non-existent tags will be created
+EOF
+exit 1
+fi
+
shopt -s extglob
now="$(TZ=UTC date +'%F %T')"
@@ -24,12 +40,12 @@ langs="${LANGS:-en it}"
for lang in $langs; do
{
cat <<EOF
-================
-..
-================
+${docname//?/=}
+$docname
+${docname//?/=}
+:CreationDate: $now
+:Id: $docname
EOF
- echo ':CreationDate: '"$now"
- echo ':Id: '"$docname"
if [[ ${#tags[@]} -gt 0 ]]; then
i=0
for tag in "${tags[@]}"; do
@@ -38,7 +54,7 @@ EOF
else
echo -n ' '
fi
- echo "$tag"
+ echo "- $tag"
i=$(( $i + 1 ))
done
fi
@@ -53,16 +69,23 @@ for tag in "${tags[@]}"; do
mkdir -p "tags/$tag"
for lang in $langs; do
{
- echo "$tag"
- echo "${tag//?/=}"
- echo ':CreationDate: '"$now"
cat <<EOF
+${tag//?/=}
+$tag
+${tag//?/=}
+:CreationDate: $now
[% PROCESS 'document-listing.tt' %]
EOF
- } > "tags/$tag/document.${lang}.rest.txt"
+ } > "tags/$tag/document.${lang}.rest.tt"
+ {
+ cat <<EOF
+[% INCLUDE 'base-feed.tt' %]
+EOF
+ } > "tags/$tag/feed.${lang}.tt"
+ done
+ for f in document-listing.tt du2html.xsl fillFeed.xsl base-feed.tt; do
+ ln -s "${tag//+([^\/])/../..}"/../templates/"$f" "tags/$tag/"
done
- ln -s "${docname//+([^\/])/..}"/../templates/document-listing.tt "$docname"/
- ln -s "${docname//+([^\/])/..}"/../templates/du2html.xsl "$docname"/
fi
done
diff --git a/templates/base-feed.tt b/templates/base-feed.tt
index a7b34a3..2911d71 100644
--- a/templates/base-feed.tt
+++ b/templates/base-feed.tt
@@ -7,7 +7,7 @@
[% tag='';IF (matches = path.match('^(?:.*/)?tags/(.*)$')); tag = matches.0; END -%]
<?xml version="1.0" encoding="utf-8"?>
<a:feed xmlns:a="http://www.w3.org/2005/Atom">
-<a:tag>[% tag %] ( [% path %] )</a:tag>
+<a:id>tag:thenautilus.net,2009-08-18:tags/[% tag %]/feed.[% language %].xml</a:id>
<a:updated>[% l=docs.last;df.format(changed.$l.last_change) %]Z</a:updated>
[% FOR doc IN docs; NEXT UNLESS isLang(language,doc) -%]
[% IF tag;
diff --git a/templates/fillFeed.xsl b/templates/fillFeed.xsl
index 593ff51..a05e630 100644
--- a/templates/fillFeed.xsl
+++ b/templates/fillFeed.xsl
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<x:stylesheet xmlns:x="http://www.w3.org/1999/XSL/Transform"
xmlns:wc="http://webcoso.thenautilus.net/"
+ xmlns="http://www.w3.org/2005/Atom"
xmlns:a="http://www.w3.org/2005/Atom"
- xmlns="http://www.w3.org/1999/xhtml"
- exclude-result-prefixes="wc"
+ exclude-result-prefixes="wc a"
version="1.0">
<x:import href="du2html.xsl"/>
@@ -15,43 +15,44 @@
<x:output method="xml" encoding="utf-8" doctype-public=""/>
<x:template match="a:feed">
- <a:feed xml:lang="{$language}" xml:base="http://www.thenautilus.net/">
- <a:author>
- <a:name>Gianni Ceccarelli</a:name>
- <a:email>dakkar@thenautilus.net</a:email>
- </a:author>
- <a:id>http://www.thenautilus.net/</a:id>
- <a:link rel="alternate" type="text/html" href="http://www.thenautilus.net{wc:dst-uri-for($filename)}"/>
- <a:title type="text">thenautilus.net</a:title>
- <x:copy-of select="a:updated"/>
+ <feed xml:lang="{$language}" xml:base="http://www.thenautilus.net/">
+ <author>
+ <name>Gianni Ceccarelli</name>
+ <email>dakkar@thenautilus.net</email>
+ </author>
+ <id><x:value-of select="a:id"/></id>
+ <link rel="alternate" type="text/html" href="http://www.thenautilus.net{wc:dst-uri-for($filename)}"/>
+ <link rel="self" type="application/atom+xml" href="http://www.thenautilus.net{wc:dst-uri-for($filename)}feed.{$language}.xml"/>
+ <title type="text">thenautilus.net</title>
+ <updated><x:value-of select="a:updated"/></updated>
<x:apply-templates select="a:entry"/>
- </a:feed>
+ </feed>
</x:template>
<x:template match="a:entry">
- <a:entry>
- <x:copy-of select="a:id"/>
- <x:copy-of select="a:published"/>
- <x:copy-of select="a:updated"/>
+ <entry>
+ <id><x:value-of select="a:id"/></id>
+ <published><x:value-of select="a:published"/></published>
+ <updated><x:value-of select="a:updated"/></updated>
<x:apply-templates select="a:PH"/>
- </a:entry>
+ </entry>
</x:template>
<x:template match="a:PH">
- <a:link rel="alternate" type="text/html" href="{.}"/>
- <a:title type="xhtml">
- <div xml:base="{.}">
+ <link rel="alternate" type="text/html" href="{.}"/>
+ <title type="xhtml">
+ <div xml:base="{.}" xmlns="http://www.w3.org/1999/xhtml">
<x:apply-templates select="wc:title-for($language,$filename,.)/node()"/>
</div>
- </a:title>
- <a:content type="xhtml">
- <div xml:base="{.}">
+ </title>
+ <content type="xhtml">
+ <div xml:base="{.}" xmlns="http://www.w3.org/1999/xhtml">
<x:apply-templates select="wc:document($language,$filename,.)/document/node()"/>
</div>
- </a:content>
+ </content>
<x:for-each select="wc:document($language,$filename,.)/document/docinfo/field[field_name='tags']/field_body">
<x:for-each select="*/list_item|paragraph">
- <a:category term="{normalize-space(.)}" label="{normalize-space(string(wc:title-for($language,$filename,concat('/tags/',normalize-space(.),'/'))))}"/>
+ <category term="{normalize-space(.)}" label="{normalize-space(string(wc:title-for($language,$filename,concat('/tags/',normalize-space(.),'/'))))}"/>
</x:for-each>
</x:for-each>
</x:template>