svg2oddmuse.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/bash
  2. #
  3. # Export image to Oddmuse wiki
  4. #
  5. # Use with wikiupload.py, svgattrs.py, and odd_output.inx
  6. INK_SVG="$1"
  7. EXEC_DIR=`dirname "$0"`
  8. cat "$INK_SVG" | "$EXEC_DIR/svgattrs.py" > "$INK_SVG.attrs"
  9. DOCNAME=`grep -e "^sodipodi:docname" "$INK_SVG.attrs" | cut -d" " -f2`
  10. DOCBASE=`grep -e "^sodipodi:docbase" "$INK_SVG.attrs" | cut -d" " -f2`
  11. PAGENAME="${DOCNAME%.odd}"
  12. mv "$INK_SVG.attrs" "$DOCBASE/$PAGENAME.attrs" # debug info
  13. cp "$INK_SVG" "$DOCBASE/$PAGENAME.svg"
  14. NOTES="$DOCBASE/notes.txt"
  15. if [[ ! -f "$NOTES" ]]; then
  16. echo "notes.txt, describing wiki, not found" 1>&2
  17. exit 1
  18. fi
  19. USERNAME=`cat "$NOTES" | grep -e "^username" | cut -d" " -f2`
  20. SUMMARY="Inkscape-to-Oddmuse"
  21. URLBASE=`cat "$NOTES" | grep -e "^urlbase" | cut -d" " -f2`
  22. SRC="$DOCBASE/$PAGENAME.svg"
  23. TARGET="${URLBASE}${PAGENAME}Source"
  24. "$EXEC_DIR/oddmuse-upload.py" -u "$USERNAME" -s "$SUMMARY" "$SRC" "$TARGET" 1>&2
  25. inkscape --export-area-drawing --file="$DOCBASE/$PAGENAME.svg" --export-png="$DOCBASE/$PAGENAME.png"
  26. SRC="$DOCBASE/$PAGENAME.png"
  27. TARGET="${URLBASE}${PAGENAME}Image"
  28. "$EXEC_DIR/oddmuse-upload.py" -u "$USERNAME" -s "$SUMMARY" "$SRC" "$TARGET" 1>&2