Files
oddmuse/stuff/wikiimg

61 lines
1.8 KiB
Plaintext
Raw Normal View History

2006-03-15 20:44:00 +00:00
#!/bin/bash
# wikiimg --- Get and put SVG and PNG files to Oddmuse wikis
#
# Copyright (C) 2006 Alex Schroeder <alex@emacswiki.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
2006-03-15 20:44:00 +00:00
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
2006-03-15 20:44:00 +00:00
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
2006-03-15 20:44:00 +00:00
if [ -z "$2" ]; then
echo Usage:
echo
echo image get PageName -- gets PageName from the wiki and saves
echo it as PageName.svg in the current directory.
echo
echo image put PageName -- saves PageName.svg as PageNameSource
echo and PageName.png as PageNameImage. You are responsible for
echo exporting the SVG file as PNG when you are done.
exit
fi
WIKI=http://www.communitywiki.org/en
USER=`id -un`
WIKIUSER=${WIKIUSER:-USER}
case $1 in
get)
F=`basename "$2" Image`.svg
2006-03-15 20:55:59 +00:00
# make sure both are accepted
IMG=`basename "$2" Image`Image
wget -O $F $WIKI/$IMG
2006-03-15 20:44:00 +00:00
;;
put)
2006-03-15 20:55:59 +00:00
# make sure all are accepted
PAGE=$2
PAGE=`basename $PAGE .svg`
PAGE=`basename $PAGE .png`
for f in "$PAGE.svg" "$PAGE.png"; do
2006-03-15 20:44:00 +00:00
if [ ! -f "$f" ]; then
echo There is no file called $f
exit
fi
done
2006-03-15 20:55:59 +00:00
wikiupload -u "$WIKIUSER" "$PAGE.png" "$WIKI/${PAGE}Image"
2006-03-15 20:44:00 +00:00
wikiupload -t "image/svg+xml" -u "$WIKIUSER" \
2006-03-15 20:55:59 +00:00
"$PAGE.svg" "$WIKI/${PAGE}Source"
2006-03-15 20:44:00 +00:00
;;
*)
echo You must use either get or put as first parameter.
exit
esac