-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload.sh
91 lines (87 loc) · 1.5 KB
/
upload.sh
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/sh
# cheap and cheerful pushing of files to TiddlySpace,
# authorization taken from the variable TIDDLYSPACE_AUTH which for me is:
# export TIDDLYSPACE_AUTH='-u myuser:mypass'
# usage: sts spacename file1 file2 ..
space="$1" ; shift
# public/private
pp=public
for file in "$@"
do
tiddler=$(basename "$file")
case "$file" in
*.tid)
content="text/plain"
tiddler=$(basename "$file" .tid)
;;
*.mf)
content="text/cache-manifest"
;;
*.html)
content="text/html;charset=utf-8"
tiddler=$(basename "$file" .html)
;;
*.svg)
if [ ! -f $file.meta ]
then
content="image/svg+xml"
else
content="text/plain"
o="$file"
meta="$o.meta"
file="/tmp/sts.tid"
(
cat $o.meta
echo
cat $o
)> $file
tiddler=$(basename "$o" .svg)
fi
;;
*.css)
content="text/css"
;;
*.pdf)
content="application/pdf"
;;
*.mov)
content="video/quicktime"
;;
*.ogg)
content="application/ogg"
;;
*.png)
content="image/png"
#tiddler=SiteIcon
;;
*.gif)
content="image/gif"
;;
*.jpg)
content="image/jpeg"
;;
*.js)
if [ ! -f $file.meta ]
then
content="text/javascript"
else
content="text/plain"
o="$file"
meta="$o.meta"
file="/tmp/sts.tid"
(
cat $o.meta
echo
cat $o
)> $file
tiddler=$(basename "$o" .js)
fi
;;
*)
content="text/html"
;;
esac
set -x
curl -X PUT $TIDDLYSPACE_AUTH http://${space}.tiddlyspace.com/bags/${space}_$pp/tiddlers/$tiddler --data-binary @$file -H "Content-type: $content"
set +x
done