Files
oddmuse/stuff/wikiimg
Alex Schroeder 72cd669bf0 Changed nearly remaining code from GPLv2 to GPLv3
There were some files that did not offer "or (at your option) any later
version" in their license and these had to be left alone. This should
solve the incorrect FSF address issue #4 on GitHub.
2016-08-16 18:01:26 +02:00

61 lines
1.8 KiB
Bash
Executable File

#!/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.
#
# 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.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
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
# make sure both are accepted
IMG=`basename "$2" Image`Image
wget -O $F $WIKI/$IMG
;;
put)
# make sure all are accepted
PAGE=$2
PAGE=`basename $PAGE .svg`
PAGE=`basename $PAGE .png`
for f in "$PAGE.svg" "$PAGE.png"; do
if [ ! -f "$f" ]; then
echo There is no file called $f
exit
fi
done
wikiupload -u "$WIKIUSER" "$PAGE.png" "$WIKI/${PAGE}Image"
wikiupload -t "image/svg+xml" -u "$WIKIUSER" \
"$PAGE.svg" "$WIKI/${PAGE}Source"
;;
*)
echo You must use either get or put as first parameter.
exit
esac