lib.sh 746 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/sh
  2. get_lib_file() {
  3. if [ -f "sites/$SITE/_wesh/lib/$1" ]; then
  4. echo "sites/$SITE/_wesh/lib/$1"
  5. else
  6. echo "lib/$1"
  7. fi
  8. }
  9. render_page() {
  10. echo "Content-Type: text/html"
  11. echo
  12. handler "$(get_lib_file master.tpl)"
  13. }
  14. static_file() {
  15. printf "Content-Type: "
  16. select_mime "$1"
  17. echo
  18. cat "$1"
  19. }
  20. select_mime() {
  21. m='text/plain'
  22. case "$1" in
  23. *.css)
  24. m='text/css'
  25. ;;
  26. *.ico)
  27. m='image/x-icon'
  28. ;;
  29. *.png)
  30. m='image/png'
  31. ;;
  32. *.jpg)
  33. m='image/jpeg'
  34. ;;
  35. *.jpeg)
  36. m='image/jpeg'
  37. ;;
  38. *.gif)
  39. m='image/gif'
  40. ;;
  41. *.pdf)
  42. m='application/pdf'
  43. ;;
  44. esac
  45. echo $m
  46. }