mirror of https://github.com/dyne/webnomad.git
enhancements in navbar
This commit is contained in:
parent
85b6039c03
commit
351c569864
29
init
29
init
|
|
@ -20,8 +20,10 @@
|
|||
|
||||
source jaroweb/utils
|
||||
|
||||
mkdir -p views
|
||||
cat <<EOF > views/index.html
|
||||
|
||||
mkdir -p views
|
||||
{ test -r views/index.html } || {
|
||||
cat <<EOF > views/index.html
|
||||
<h1>Hello world</h1>
|
||||
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
|
||||
|
|
@ -33,9 +35,11 @@ pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
|
|||
culpa qui officia deserunt mollit anim id est laborum.</p>
|
||||
|
||||
EOF
|
||||
mkdir -p tmpl
|
||||
}
|
||||
|
||||
cat <<EOF > tmpl/header.html
|
||||
mkdir -p tmpl
|
||||
{ test -r tmpl/header.html } || {
|
||||
cat <<EOF > tmpl/header.html
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="Generator" content="Jaro Web http://jaroweb.dyne.org" />
|
||||
<meta name="MSSmartTagsPreventParsing" content="True" />
|
||||
|
|
@ -66,8 +70,10 @@ cat <<EOF > tmpl/header.html
|
|||
<body>
|
||||
<div class="container">
|
||||
EOF
|
||||
}
|
||||
|
||||
cat <<EOF > tmpl/footer.html
|
||||
{ test -r tmpl/footer.html } || {
|
||||
cat <<EOF > tmpl/footer.html
|
||||
<hr>
|
||||
<footer style="padding: 1em;">
|
||||
<div class="pull-left">
|
||||
|
|
@ -89,6 +95,7 @@ cat <<EOF > tmpl/footer.html
|
|||
</html>
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
notice "Downloading and installing Bootstrap"
|
||||
curl http://twitter.github.com/bootstrap/assets/bootstrap.zip -o bootstrap.zip
|
||||
|
|
@ -99,7 +106,8 @@ rsync -r bootstrap/img views/
|
|||
rm -rf bootstrap bootstrap.zip
|
||||
act "Bootstrap installed"
|
||||
|
||||
cat <<EOF > config.zsh
|
||||
{ test -r config.zsh } || {
|
||||
cat <<EOF > config.zsh
|
||||
TITLE="A new website made with Jaro Web."
|
||||
BRAND="Jaro Web"
|
||||
DESCRIPTION="Jaro Web, your slick and static website publisher, powered by HTML5, Zsh and Bootstrap"
|
||||
|
|
@ -108,10 +116,11 @@ KEYWORDS="web, design, html"
|
|||
# Sections must be matching existing files in views/
|
||||
typeset -al sections
|
||||
sections=(contact)
|
||||
|
||||
|
||||
EOF
|
||||
cat <<EOF > Makefile
|
||||
}
|
||||
|
||||
{ test -r Makefile } || {
|
||||
cat <<EOF > Makefile
|
||||
all:
|
||||
@./jaroweb/render
|
||||
|
||||
|
|
@ -120,3 +129,5 @@ clean:
|
|||
|
||||
upload:
|
||||
@scp -r pub/.htaccess pub/* online.server.org:/var/www
|
||||
EOF
|
||||
}
|
||||
116
render
116
render
|
|
@ -26,7 +26,7 @@ source jaroweb/utils
|
|||
|
||||
|
||||
####################################
|
||||
|
||||
|
||||
source config.zsh
|
||||
|
||||
notice "Rendering $BRAND website"
|
||||
|
|
@ -38,12 +38,27 @@ DirectoryIndex index index.html index.php
|
|||
DefaultType text/html
|
||||
EOF
|
||||
|
||||
render_header() {
|
||||
cat <<EOF
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>$TITLE</title>
|
||||
<meta name="description" content="$DESCRIPTION">
|
||||
<meta name="keywords" content="$KEYWORDS">
|
||||
EOF
|
||||
cat tmpl/header.html
|
||||
echo "<nav>"
|
||||
render_navbar ${sec}
|
||||
echo "</nav>"
|
||||
}
|
||||
|
||||
render_html() {
|
||||
|
||||
src=`find views -type f -name "${1}.html"`
|
||||
|
||||
{ test -r "${src}" } || {
|
||||
print "${1} html not found";
|
||||
print "${1} section not found";
|
||||
return 1 }
|
||||
|
||||
|
||||
|
|
@ -60,18 +75,7 @@ render_html() {
|
|||
sec=${sec[(ws:/:)2]}
|
||||
fi
|
||||
|
||||
cat <<EOF > $dst
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>$TITLE</title>
|
||||
<meta name="description" content="$DESCRIPTION">
|
||||
<meta name="keywords" content="$KEYWORDS">
|
||||
EOF
|
||||
cat tmpl/header.html >> $dst
|
||||
echo "<nav>" >> $dst
|
||||
render_navbar ${sec} >> $dst
|
||||
echo "</nav>" >> $dst
|
||||
render_header > $dst
|
||||
|
||||
echo "<article>" >> $dst
|
||||
grep -v '^#' ${src} >> $dst
|
||||
|
|
@ -81,6 +85,9 @@ EOF
|
|||
print "done."
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
read_meta() {
|
||||
tmp=`awk '
|
||||
!/^#/ { next }
|
||||
|
|
@ -88,6 +95,7 @@ read_meta() {
|
|||
/description/ { printf "description=\""; for(i=3;i<=NF;i++) printf "%s ", $i; printf "\";" }
|
||||
/keywords/ { printf "keywords=\""; for(i=3;i<=NF;i++) printf "%s ", $i; printf "\";" }
|
||||
/link/ { printf "link=\""; for(i=3;i<=NF;i++) printf "%s ", $i; printf "\";" }
|
||||
/icon/ { printf "icon=\""; for(i=3;i<=NF;i++) printf "%s ", $i; printf "\";" }
|
||||
/image/ { printf "image=\""; for(i=3;i<=NF;i++) printf "%s ", $i; printf "\";" }
|
||||
' ${1}`
|
||||
eval "$tmp"
|
||||
|
|
@ -96,24 +104,24 @@ read_meta() {
|
|||
render_section() {
|
||||
sname=${1}
|
||||
spath=views/${sname}
|
||||
|
||||
|
||||
|
||||
|
||||
{ test -d ${spath} } && {
|
||||
# the section is a directory containing files
|
||||
# so we generate its html
|
||||
|
||||
pages=`find ${spath} -type f`
|
||||
{ test ${#pages} = 0 } && {
|
||||
{ test ${#pages} = 0 } && {
|
||||
print "${sname} section is an empty directory"
|
||||
return 1 }
|
||||
|
||||
print "${sname} section"
|
||||
print "<h1>${sname//_/ }</h1>" > ${spath}.html
|
||||
|
||||
|
||||
for p in ${(f)pages}; do
|
||||
pp=`basename $p`
|
||||
case ${pp[(ws:.:)2]} in
|
||||
|
||||
|
||||
html)
|
||||
read_meta $p
|
||||
# fill in entry into section page
|
||||
|
|
@ -126,7 +134,7 @@ EOF
|
|||
# print "Keywords: $keywords"
|
||||
render_html ${pp[(ws:.:)1]}
|
||||
;;
|
||||
|
||||
|
||||
link)
|
||||
print -n "rendering $pp... "
|
||||
read_meta $p
|
||||
|
|
@ -139,9 +147,9 @@ EOF
|
|||
*)
|
||||
print "${p}: page type unknown"
|
||||
;;
|
||||
|
||||
|
||||
esac
|
||||
|
||||
|
||||
done # pages
|
||||
|
||||
}
|
||||
|
|
@ -157,51 +165,60 @@ EOF
|
|||
}
|
||||
|
||||
render_navbar() {
|
||||
active=${1}
|
||||
active="$1"
|
||||
|
||||
cat <<EOF
|
||||
<!-- BEGIN NAVIGATION BAR -->
|
||||
<div class="navbar navbar-fixed-top">
|
||||
<div class="navbar ${NAVCLASS}">
|
||||
<div class="navbar-inner">
|
||||
EOF
|
||||
# first section: overview
|
||||
|
||||
# defaults
|
||||
nav_active="brand"
|
||||
nav_icon=" "
|
||||
icon=""
|
||||
# first section: overview
|
||||
if [ "$active" = "views" ]; then
|
||||
cat <<EOF
|
||||
<div class="brand active"> ${BRAND}</div>
|
||||
EOF
|
||||
nav_active+=" active"
|
||||
current="index"
|
||||
else
|
||||
cat <<EOF
|
||||
<a href="index">
|
||||
<div class="brand"> ${BRAND}</div>
|
||||
</a>
|
||||
EOF
|
||||
current="$1"
|
||||
fi
|
||||
cat <<EOF
|
||||
<ul class="nav">
|
||||
<li class="divider-vertical"></li>
|
||||
|
||||
|
||||
cat <<EOF
|
||||
<a href="index">
|
||||
<div class="$nav_active">
|
||||
${nav_icon} ${BRAND}
|
||||
</div>
|
||||
</a>
|
||||
<ul class="nav">
|
||||
EOF
|
||||
|
||||
|
||||
# other sections
|
||||
for sec in ${sections}; do
|
||||
ssec=`basename $sec`
|
||||
if [ "$ssec" = "$active" ]; then
|
||||
cat <<EOF
|
||||
<li class="active"><a href="${ssec}">${ssec//_/ }</a></li>
|
||||
icon=""; nav_icon=" "
|
||||
nav_active=""
|
||||
read_meta views/$ssec.html
|
||||
{ test "$icon" = "" } || {
|
||||
nav_icon="<i class=\"icon-${icon}\"></i>" }
|
||||
{ test "$ssec" = "$active" } && {
|
||||
nav_active=" class=\"active\"" }
|
||||
cat <<EOF
|
||||
<li${nav_active}><a href="${ssec}">${nav_icon} ${ssec//_/ }</a></li>
|
||||
EOF
|
||||
else
|
||||
cat <<EOF
|
||||
<li><a href="${ssec}">${ssec//_/ }</a></li>
|
||||
EOF
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
unset active
|
||||
|
||||
# complete navbar with static entries if present
|
||||
{ test -r tmpl/navbar.html } && { cat tmpl/navbar.html }
|
||||
|
||||
cat <<EOF
|
||||
</ul>
|
||||
</div>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<!-- END NAVIGATION BAR -->
|
||||
EOF
|
||||
|
|
@ -217,15 +234,12 @@ act "${#sections} sections configured"
|
|||
if [ ${#sections} = 0 ]; then
|
||||
act "No sections configured"
|
||||
else
|
||||
|
||||
for s in ${sections}; do
|
||||
|
||||
render_section ${s}
|
||||
|
||||
done
|
||||
|
||||
fi
|
||||
|
||||
|
||||
for m in `find views -mindepth 1 -type d `; do
|
||||
rsync -r $m pub/
|
||||
notice "$m published"
|
||||
|
|
|
|||
Loading…
Reference in New Issue