rendering enhancements and fixes to css inclusion

This commit is contained in:
Jaromil 2015-06-08 00:48:37 +02:00
parent 7f66a90231
commit 7090daef99
2 changed files with 52 additions and 31 deletions

2
fonts
View File

@ -1,3 +1,5 @@
#!/usr/bin/env zsh
# prepare fonts
custom_fonts=()

81
render
View File

@ -112,25 +112,33 @@ render_header() {
<link href="${baseurl}/css/bootstrap-responsive.css" rel="stylesheet" />
EOF
[[ -r "$DIR"/views/css/custom.css ]] && {
cat <<EOF
<link href="${baseurl}/css/custom.css" rel="stylesheet" />
EOF
}
# add css needed for internal functions
# include all css files found in views/css
cssfound=`find $DIR/views/css -name '*.css'`
for c in ${(f)cssfound}; do
includecss+=(${c##*/})
done
# include also generated css for fonts if present
[[ -f "${destination}"/css/custom.fonts.css ]] && includecss+=(custom.fonts.css)
# add all css needed
for c in $includecss; do
act "+ css: $c"
func "<link href=\"${baseurl}/css/${c}\" rel=\"stylesheet\" />"
cat <<EOF
<link href="${baseurl}/css/${c}" rel="stylesheet" />
EOF
cp "$SYS"/css/${c} "${destination}"/css/
done
if [[ -r "$DIR"/views/css/$c ]]; then
cp -a $DIR/views/css/$c "${destination}"/css/
elif [[ -r "$SYS"/css/${c} ]]; then
cp -a "$SYS"/css/${c} "${destination}"/css/
fi
[[ -f "${destination}"/css/custom.fonts.css ]] && {
cat <<EOF
<link href="${baseurl}/css/custom.fonts.css" rel="stylesheet" />
EOF
}
done
# add any argument string to header
[[ "$1" = "" ]] || { print "${@}"; print }
@ -148,19 +156,29 @@ EOF
render_file "$DIR"/tmpl/footer.html
# add any string argument to the footer
{ test "$1" = "" } || { print "${@}"; print }
[[ "$1" = "" ]] || { print "${@}"; print }
# insert and copy all js files
for i in $includejs; do
cat <<EOF
<script type="text/javascript" src="${baseurl}/js/$i"></script>
EOF
{ test -r "$SYS"/js/$i } && {
cp "$SYS"/js/$i "$destination"/js }
# include all css files found in views/css
jsfound=`find $DIR/views/js -name '*.js'`
for j in ${(f)jsfound}; do
includejs+=(${j##*/})
done
# insert and copy all js files
for j in $includejs; do
act "+ js: $j"
cat <<EOF
<script type="text/javascript" src="${baseurl}/js/$j"></script>
EOF
if [[ -r "$DIR"/views/js/$j ]]; then
cp -a "$DIR"/views/js/$j "$destination"/js
elif [[ -r "$SYS"/js/$i ]]; then
cp -a "$SYS"/js/$i "$destination"/js
fi
done
# if test mode then render the test footer
{ test "$CMD" = "test" } && { render_test_footer }
[[ "$CMD" = "test" ]] && render_test_footer
[[ "$FLOWTYPE" = "" ]] || { # if there is flowtype.js then use it
@ -274,11 +292,11 @@ render_html() {
cat $tmp
# extra js for html pages
# extra js for html pages
[[ "$FLOWTYPE" = "" ]] || {
includejs+=(jquery.min.js)
includejs+=(flowtype.js)
}
includejs+=(jquery.min.js)
includejs+=(flowtype.js)
}
# clean up from temporary files
rm -f tmp.*
@ -352,7 +370,8 @@ cp "$SYS"/js/html5.js "$destination"/js/
# prepare all fonts
source $SYS/fonts
[[ ${#fonts} -gt 0 ]] && {
rsync -a -W "$DIR/fonts/*" "$DIR/" }
act -n "Clean up all temp files ... "
temps=(`find "$destination" -type f -name 'temp-*'`)
@ -378,8 +397,10 @@ for src in $htmls; do
dst=`calc_dest "$src"`
[[ "$FLOWTYPE" = "" ]] || {
includecss+=(flowtype.css) }
[[ "$FLOWTYPE" = "" ]] || includecss+=(flowtype.css)
# render html
act "Html rendering: $B $dst $r"
render_header > $dst
@ -399,8 +420,6 @@ EOF
<article>
EOF
# render html
act -n "Html rendering: $B $dst $r"
cat $src | render_html >> $dst
cat <<EOF >> $dst