mirror of https://github.com/dyne/webnomad.git
231 lines
4.8 KiB
Bash
Executable File
231 lines
4.8 KiB
Bash
Executable File
#!/usr/bin/env zsh
|
|
|
|
DIR=`dirname $0`
|
|
CMD=`basename $0`
|
|
{ test -r $DIR } || {
|
|
echo "error: launch webnomad commands from your project directory"
|
|
echo "i.e: ./$DIR/$CMD"
|
|
return 1
|
|
}
|
|
|
|
source ${DIR}/utils
|
|
|
|
{ test -r config.zsh } || {
|
|
error "Directory not configured for WebNomad. First use ./webnomad/init"
|
|
exit 1 }
|
|
|
|
source config.zsh
|
|
|
|
notice "Rendering $BRAND website"
|
|
act "Title: $TITLE"
|
|
|
|
|
|
source ${DIR}/render source
|
|
|
|
# Main
|
|
|
|
mkdir -p test
|
|
mkdir -p test/css
|
|
# side menu stylesheet
|
|
cp $DIR/css/jquery.sidr.dark.css test/css
|
|
|
|
fonts=('Arial' 'Arial Black' 'Comic Sans MS' 'Courier New' 'Georgia' 'Impact' 'Monaco' 'Lucida Grande')
|
|
fonts+=('Book Antiqua' 'Tahoma' 'Times New Roman' 'Trebuchet MS' 'Verdana' 'Geneva' 'New York')
|
|
custom_fonts=()
|
|
total_fonts=${#fonts}
|
|
# string match case insensitive
|
|
unsetopt CASE_GLOB
|
|
|
|
# if there are custom fonts add them
|
|
{ test -d fonts } && {
|
|
notice "Indexing custom fonts"
|
|
rm -f test/css/custom.fonts.css
|
|
mkdir -p test/fonts
|
|
ttf=`find -L fonts -iname '*.ttf'`
|
|
for f in ${(f)ttf}; do
|
|
ffile=`basename "$f"`
|
|
cp "$f" test/css/"$ffile"
|
|
custom_fonts+=("${ffile%.ttf}")
|
|
cat <<EOF >> test/css/custom.fonts.css
|
|
@font-face { font-family: '${ffile%.ttf}';
|
|
src: url('$ffile') format('truetype'); }
|
|
EOF
|
|
total_fonts=$(( $total_fonts + 1 ))
|
|
done
|
|
otf=`find -L fonts -iname '*.otf'`
|
|
for f in ${(f)otf}; do
|
|
ffile=`basename "$f"`
|
|
cp "$f" test/css/"$ffile"
|
|
custom_fonts+=("${ffile%.otf}")
|
|
cat <<EOF >> test/css/custom.fonts.css
|
|
@font-face { font-family: '${ffile%.otf}';
|
|
src: url('$ffile') format('opentype'); }
|
|
EOF
|
|
total_fonts=$(( $total_fonts + 1 ))
|
|
done
|
|
|
|
|
|
act "$total_fonts custom fonts indexed"
|
|
}
|
|
|
|
fonts=($custom_fonts $fonts)
|
|
|
|
# render all HTML views
|
|
htmls=(`find views -type f -name '*.html'`)
|
|
for src in $htmls; do
|
|
# read meta commands
|
|
cat ${src} | read_meta
|
|
|
|
# compute destination file
|
|
dst="test/`basename ${src%.*}`$EXTENSION"
|
|
|
|
render_header > $dst
|
|
|
|
# close <head> as nothing else is needed
|
|
cat <<EOF >> $dst
|
|
|
|
<link rel="stylesheet" href="css/jquery.sidr.dark.css">
|
|
<link rel="stylesheet" href="css/custom.fonts.css">
|
|
|
|
</head> <!-- end of <head> -->
|
|
|
|
<body>
|
|
<div class="container">
|
|
EOF
|
|
|
|
# navbar
|
|
cat tmpl/navbar.html >> $dst
|
|
|
|
# start the body of article
|
|
cat <<EOF >> $dst
|
|
<p> </p>
|
|
<a id="menu" href="#sidr">Design test</a>
|
|
|
|
<article>
|
|
EOF
|
|
|
|
# render html
|
|
act -n "Html rendering: $dst "
|
|
cat $src | render_html >> $dst
|
|
|
|
cat <<EOF >> $dst
|
|
</article>
|
|
<p> </p>
|
|
|
|
<script type="text/javascript" src="js/jquery.min.js"></script>
|
|
<script type="text/javascript" src="js/jquery.sidr.js"></script>
|
|
|
|
|
|
<div id="sidr">
|
|
<h3>Design test</h3>
|
|
EOF
|
|
|
|
|
|
# Font size selector
|
|
|
|
font-size_select() {
|
|
cat <<EOF
|
|
<select id="$1" name="$1-font-size">
|
|
EOF
|
|
c=.5
|
|
while [[ $c -le 8 ]]; do
|
|
cat <<EOF
|
|
<option value="${c%.}">${c%.} em</option>
|
|
EOF
|
|
c=$(( $c + .5 ))
|
|
done
|
|
cat <<EOF
|
|
</select>
|
|
EOF
|
|
}
|
|
|
|
print "<h4>H1 font size</h3>" >> $dst
|
|
font-size_select h1size >> $dst
|
|
|
|
print "<h4>H2 font size</h3>" >> $dst
|
|
font-size_select h2size >> $dst
|
|
|
|
|
|
|
|
# font family selector
|
|
|
|
font-family_select() {
|
|
cat <<EOF
|
|
<select id="$1" name="$1-font-family">
|
|
EOF
|
|
for f in $fonts; do
|
|
cat <<EOF
|
|
<option value="$f">$f</option>
|
|
EOF
|
|
done
|
|
print "</select>"
|
|
}
|
|
|
|
|
|
cat <<EOF >> $dst
|
|
<h3>Brand font family</h3>
|
|
EOF
|
|
font-family_select brand-font-family >> $dst
|
|
|
|
cat <<EOF >> $dst
|
|
<h3>Header font family</h3>
|
|
EOF
|
|
font-family_select header-font-family >> $dst
|
|
|
|
cat <<EOF >> $dst
|
|
<h3>Body font family</h3>
|
|
EOF
|
|
font-family_select body-font-family >> $dst
|
|
|
|
cat <<EOF >> $dst
|
|
<h3>Navigation Font family</h3>
|
|
EOF
|
|
font-family_select nav-font-family >> $dst
|
|
|
|
|
|
cat <<EOF >> $dst
|
|
|
|
</div>
|
|
|
|
<script>
|
|
\$(document).ready(function() {
|
|
\$('#menu').sidr({
|
|
name: 'sidr',
|
|
side: 'right',
|
|
displace: false
|
|
});
|
|
});
|
|
\$('#h1size').change(function() { \$('h1').css('font-size', \$('#h1size').val() + "em" ); })
|
|
\$('#h2size').change(function() { \$('h2').css('font-size', \$('#h2size').val() + "em" ); })
|
|
|
|
\$('#brand-font-family').change(function(){ \$('.navbar .brand').css('font-family', \$('#brand-font-family').val() ); })
|
|
|
|
\$('#header-font-family').change(function(){ \$('h1').css('font-family', \$('#header-font-family').val() ); })
|
|
\$('#header-font-family').change(function(){ \$('h2').css('font-family', \$('#header-font-family').val() ); })
|
|
|
|
\$('#body-font-family').change(function(){ \$('body').css('font-family', \$('#body-font-family').val() ); })
|
|
|
|
\$('#nav-font-family').change(function(){ \$('nav div div ul li a').css('font-family', \$('#nav-font-family').val() ); })
|
|
|
|
</script>
|
|
|
|
EOF
|
|
|
|
render_footer >> $dst
|
|
|
|
act "done"
|
|
|
|
done
|
|
|
|
|
|
for m in `find views -mindepth 1 -type d `; do
|
|
act -n "publishing $m... "
|
|
rsync -r $m test/
|
|
print "done"
|
|
done
|
|
|
|
# add design test libs
|
|
mkdir -p test/js
|
|
cp $DIR/js/jquery.min.js test/js
|
|
cp $DIR/js/jquery.sidr.js test/js
|