File dev-helper/update.sh
Last commit: Sat Jan 28 19:10:47 2023 +0100 Jan Dankert New: Templates may be rendered as Mustache, Script and Script template.
1 #!/bin/bash 2 3 cd "$(dirname "$0")" 4 5 # Calling the template compiler if a template or a component was modified. 6 # 7 # Need for: 8 # - inotify-tools 9 # - curl 10 # - getopt 11 # 12 # On Ubuntu/Debian install them with 'apt-get install inotify-tools curl'. 13 # 14 15 16 usage() { 17 echo "Usage: $0 [-t <theme>] [-w] [-x <type>] [-u <host/path>]" 1>&2; 18 exit 1; 19 } 20 21 url="http://localhost:8000/" 22 watch= 23 type= 24 theme="default" 25 26 while getopts "wt:x:hu:" o; do 27 case "${o}" in 28 t) 29 theme=${OPTARG} 30 ;; 31 w) 32 watch=true 33 ;; 34 h) 35 usage; exit 1; 36 ;; 37 u) 38 url=${OPTARG} 39 ;; 40 x) 41 type=${OPTARG} 42 ;; 43 *) 44 usage 45 ;; 46 esac 47 done 48 shift $((OPTIND-1)) 49 50 if [ -z "${type}" ]; then 51 echo "Select a type" 52 select type in "tpl" "xsd" "css" "js" "lang" "all"; do 53 break; 54 done 55 fi 56 57 if [ "${type}" == "all" ]; then 58 types=(tpl xsd css js lang) 59 else 60 types=($type) 61 fi 62 63 function update { 64 url=$1 65 type=$2 66 echo "update started at $(date)" 67 curl --fail -X POST -d "type=$type" $url/dev-helper/update.php 68 retVal=$? 69 if [ $retVal -ne 0 ]; then 70 echo "An error occured! Returncode was $retVal" 71 exit 4; 72 else 73 echo "Sucessful update." 74 fi 75 echo "update ended at $(date)" 76 } 77 78 function make_writable { 79 type=$1 80 theme=$2 81 case $type in 82 lang ) chmod -v a+w ../modules/language ../modules/language/Language_*.php ../modules/language/Messages*;; 83 xsd ) chmod -v a+w ../modules/template_engine/components/template.xsd ../modules/template_engine/components/components.ini;; 84 css ) chmod -v a+w ../modules/cms/ui/themes/$theme/style/openrat*.css;; 85 js ) find ../modules/cms/ui/themes/$theme/script/ -type f -name "*.min.js" -exec chmod -v a+w {} \; ; find ../modules/template_engine/components/html/ -type f -name "*.min.js" -exec chmod -v a+w {} \; ;; 86 tpl ) find ../modules/cms/ui/themes/$theme/html/views/ -type f -name "*.php" -exec chmod -v a+w {} \; ;; 87 * ) echo "unknown type";exit;; 88 esac 89 } 90 91 92 function get_file_to_watch { 93 type=$1 94 theme=$2 95 case $type in 96 lang ) 97 watchfiles+=' ../modules/language/';; 98 xsd ) 99 watchfiles+=' ../modules/template_engine/components/html';; 100 css ) 101 watchfiles+=" ../modules/cms/ui/themes/$theme/style";; 102 js ) 103 watchfiles+=" ../modules/cms/ui/themes/$theme/script";; 104 tpl ) 105 watchfiles+=" ../modules/template_engine/components/html ../modules/cms/ui/themes/$theme/html/views";; 106 107 * ) echo "unknown type";exit;; 108 esac 109 } 110 111 112 for type in ${types[*]}; do 113 make_writable $type $theme 114 done 115 116 while true; do 117 118 # Calling update first 119 for type in ${types[*]}; do 120 update $url $type 121 done 122 123 124 if [ -z "${watch}" ]; then 125 echo "not watching, exiting." 126 exit 0; # Exit, because watching is not enabled 127 fi; 128 129 watchfiles= 130 for type in ${types[*]}; do 131 get_file_to_watch $type $theme 132 done 133 134 echo "Watching for files in $watchfiles" 135 inotifywait --event modify -r $watchfiles & 136 137 echo "Watching ..." 138 wait 139 echo "File change detected, updating ..." 140 done 141 142
Downloaddev-helper/update.sh
History Sat, 28 Jan 2023 19:10:47 +0100 Jan Dankert New: Templates may be rendered as Mustache, Script and Script template. Sat, 18 Dec 2021 03:47:23 +0100 dankert New: Every ES6-Module should have a minified version for performance reasons. Bad: The Minifier "Jsqueeze" is unable to minify ES6-modules, so we had to implement a simple JS-Minifier which strips out all comments. Sat, 24 Oct 2020 00:22:18 +0200 Jan Dankert Refactoring: Language files as classes Tue, 20 Oct 2020 00:34:04 +0200 Jan Dankert New: update.sh is now able to accept the type 'all'. The script watch-all.sh is not necessary any more. Sun, 18 Oct 2020 01:30:49 +0200 Jan Dankert New component "fieldset" for better form layout. Sat, 17 Oct 2020 01:10:24 +0200 Jan Dankert New: A helper script for setting up all watches for frontend development. Thu, 10 Sep 2020 17:47:47 +0200 Jan Dankert Language Compiler is generating a Messages class which contains all language keys. Applicaton code should use this constants where possible. Sat, 22 Aug 2020 02:38:58 +0200 Jan Dankert Documentation is a good thing. Sat, 22 Aug 2020 02:27:48 +0200 Jan Dankert Recatoring: New script 'update.sh' for a more comfortable way to update the internal ui elements.