gen.sh 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/sh
  2. # STRING STRING --> NIL
  3. # Replaces the `ml.sh` shorthand w real thing, replace LL with langcode
  4. function process_file
  5. {
  6. local file="$1"
  7. local lang="$2"
  8. sed -i 's%<!--ml.sh LL%<!--#exec cmd="bash /htdocs/libertybsd.net/http/res/bin/ml.sh LL%g' $file
  9. sed -i 's%<!--header.sh LL%<!--#exec cmd="sh /htdocs/libertybsd.net/http/res/bin/header.sh LL%g' $file
  10. sed -i 's%<!--footer.sh LL%<!--#exec cmd="sh /htdocs/libertybsd.net/http/res/bin/footer.sh LL%g' $file
  11. sed -i 's% LL % '"$lang"' %g' $file
  12. }
  13. # STRING --> NIL
  14. # Generate a language's SHTML in public/$LANG
  15. function gen_lang_ver
  16. {
  17. local lang="$1"
  18. mkdir public 2>/dev/null
  19. mkdir public/$lang
  20. cp -r base/* public/$lang/
  21. cp -r res/ public/$lang/
  22. rm -rf public/$lang/res/bin
  23. for file in ./public/$lang/*.shtml
  24. do
  25. process_file "$file" "$lang"
  26. done
  27. }
  28. # NIL --> NIL
  29. # Generate all langauages' SHTML
  30. function gen_all_langs
  31. {
  32. for file in ./res/lang/*.sh
  33. do
  34. local lang_script="$file"
  35. local lang="$(basename "$lang_script" ".sh")"
  36. gen_lang_ver "$lang"
  37. done
  38. }
  39. gen_all_langs