5 # Copyright (C) 2011-2012 Matteo Nastasi
6 # mailto: nastasi@alternativeoutput.it
7 # matteo.nastasi@milug.org
8 # web: http://www.alternativeoutput.it
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful, but
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 # General Public License for more details. You should have received a
19 # copy of the GNU General Public License along with this program; if
20 # not, write to the Free Software Foundation, Inc, 59 Temple Place -
21 # Suite 330, Boston, MA 02111-1307, USA.
25 IMGPATHBASE="../brisk-img/"
31 # echo 'header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1'
32 # echo 'header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past'
36 function imglist_fla () {
43 # for i in $(find "$pname" -maxdepth 1 -type f -name '*.jpg' -o -name '*.png' -o -name '*.gif' | grep -v '/src_' | sort); do
44 for i in $(find "$pname" -maxdepth 1 -type f -name '[0-9][0-9]*.png' -o -name 'st_*.png' | grep -v '/src_' | sort); do
45 if [ "$rex" != "" ]; then
46 echo "$i" | grep -q "$rex"
48 if [ "$wrex" = "y" -a $rt -ne 0 ]; then
51 if [ "$wrex" = "n" -a $rt -eq 0 ]; then
55 echo "$i" | grep -q '.*\-[a-z][a-z]\....$'
57 # se file con suffisso di lingua
58 suff="$(echo "$i" | sed 's/\(.*\)\-\([a-z][a-z]\)\.\(...\)$/\2/g')"
60 if [ "$lang" = "$suff" ]; then
64 eni="$(echo "$i" | sed 's/\(.*\)\.\(...\)$/\1-en.\2/g')"
66 # esiste la versione _en
67 if [ "$lang" = "it" ]; then
68 # se lingua italiana le img mlang nn hanno estensione quindi va presa
72 # NON esiste la versione _en quindi e' una immagine NON mlang e va comunque presa
81 abspa="${IMGPATHBASE}${1}img"
82 if [ "$1" = "" ]; then
83 ls -Sd $( imglist_fla "$abspa" "$2" ) | grep -v '^\.$'
84 elif [ "$1" = "briskin5/" ]; then
85 rex='/[0-9][0-9][^/]*$'
86 ls -Sd $( imglist_fla "$abspa" "$2" "$rex" "y" ) | grep -v '^\.$'
87 ls -Sd $( imglist_fla "$abspa" "$2" "$rex" "n" ) | grep -v '^\.$'
92 if [ "$lang" = "it" ]; then
98 for dpath in "" briskin5/ ; do
99 OUTFILE="web/${dpath}"preload_img${fsuf}.js
100 echo "creating $OUTFILE ..."
102 IMGPATH="${IMGPATHBASE}${dpath}img"
104 echo "var g_preload_img_arr = new Array( "
107 ltri="$(echo "$IMGPATH" | wc -c)"
108 for i in $(imglist "$dpath" "$lang"); do
109 if [ $first -ne 1 ]; then
111 if [ $((ct % 2)) -eq 0 ]; then
118 outna="img/$(echo "$i" | cut -c $((ltri + 1))-)"
119 if [ $((ct % 2)) -eq 0 ]; then
122 echo -n " \"$outna\""
132 echo "var g_preload_imgsz_arr = new Array( "
137 ltri="$(echo "$IMGPATH" | wc -c)"
138 for i in $(imglist "$dpath" "$lang"); do
139 outna="$(echo "$i" | cut -c $((ltri + 1))-)"
140 sz="$(stat -c '%s' $IMGPATH/$outna)"
144 for i in $(imglist "$dpath" "$lang"); do
145 outna="$(echo "$i" | cut -c $((ltri + 1))-)"
146 if [ $first -ne 1 ]; then
148 if [ $((ct % 8)) -eq 0 ]; then
155 sz="$(stat -c '%s' $IMGPATH/$outna)"
157 cur="$(echo "100.0 * $sum / $tot" | bc -l | sed 's/\(\.[0-9]\)[0-9]*/\1/g')"
158 if [ $((ct % 8)) -eq 0 ]; then