summaryrefslogtreecommitdiff
path: root/new-tag
blob: 6b999a8d5722e656fb4d2e0d94135e3cef622a8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash 
cd "$(dirname "$0")"/src/tags
 
if [[ $# -eq 0 ]]; then
    cat <<EOF
new-tag - create new tags for WebCoso
 
Usage:
 
  new-tag <tag>...
 
The <tag> will be created under
$(pwd)
 
EOF
exit 1
fi
 
shopt -s extglob
 
now="$(TZ=UTC date +'%F %T')"
 
langs="${LANGS:-en it}"
 
for tag in "$@"; do
    tag="${tag%/}"
    if [[ -d "$tag" ]]; then
        >&2 echo "tag \"$tag\" already exists"
    else
        mkdir -p "$tag"
        for lang in $langs; do
            {
                cat <<EOF
${tag//?/=}
$tag
${tag//?/=}
:CreationDate: $now
:feed: 
 
[% PROCESS 'document-listing.tt' %]
EOF
            } > "$tag/document.${lang}.rest.tt"
            {
                cat <<EOF
[% INCLUDE 'base-feed.tt' %]
EOF
            } > "$tag/feed.${lang}.tt"
        done
        for f in document-listing.tt du2html.xsl fillFeed.xsl base-feed.tt; do
            ln -s "${tag//+([^\/])/../..}"/../templates/"$f" "$tag/"
        done
    fi
done