mirror of https://github.com/dyne/webnomad.git
code refactoring, fixes to gallery
This commit is contained in:
parent
25130fbdf7
commit
6ac2ed3cb4
|
|
@ -0,0 +1,40 @@
|
|||
# prepare fonts
|
||||
|
||||
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}
|
||||
|
||||
# if there are custom fonts add them
|
||||
{ test -d fonts } && {
|
||||
notice "Indexing custom fonts"
|
||||
rm -f ${destination}/css/custom.fonts.css
|
||||
mkdir -p ${destination}/fonts
|
||||
ttf=`find -L fonts -iname '*.ttf'`
|
||||
for f in ${(f)ttf}; do
|
||||
ffile=`basename "$f"`
|
||||
cp "$f" ${destination}/css/"$ffile"
|
||||
custom_fonts+=("${ffile%.ttf}")
|
||||
cat <<EOF >> ${destination}/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" ${destination}/css/"$ffile"
|
||||
custom_fonts+=("${ffile%.otf}")
|
||||
cat <<EOF >> ${destination}/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)
|
||||
|
|
@ -0,0 +1,139 @@
|
|||
#!/usr/bin/env zsh
|
||||
#
|
||||
# WebNomad, your slick and static website publisher
|
||||
#
|
||||
# Copyright (C) 2012-2014 Denis Roio <jaromil@dyne.org>
|
||||
#
|
||||
# This source code is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This source code is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# Please refer to the GNU Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Public License along with
|
||||
# this source code; if not, write to:
|
||||
# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
|
||||
includejs+=(jquery.min.js)
|
||||
includejs+=(blueimp-gallery.min.js)
|
||||
|
||||
includecss+=(blueimp-gallery.min.css)
|
||||
|
||||
render_gallery() {
|
||||
|
||||
render_header
|
||||
|
||||
# close <head> with gallery specific styles
|
||||
cat <<EOF
|
||||
]
|
||||
</head> <!-- end of <head> -->
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
EOF
|
||||
|
||||
# don't forget the navbar
|
||||
cat tmpl/navbar.html
|
||||
|
||||
cat <<EOF
|
||||
<!-- The Gallery as lightbox dialog, should be a child element of the document body -->
|
||||
<div id="blueimp-gallery" class="blueimp-gallery">
|
||||
<div class="slides"></div>
|
||||
<h3 class="title"></h3>
|
||||
<a class="prev">‹</a>
|
||||
<a class="next">›</a>
|
||||
<a class="close">×</a>
|
||||
<a class="play-pause"></a>
|
||||
<ol class="indicator"></ol>
|
||||
</div>
|
||||
|
||||
EOF
|
||||
|
||||
# put a notice for non-javascript browsers
|
||||
cat <<EOF
|
||||
<noscript>
|
||||
<p> </p>
|
||||
<div class="alert">
|
||||
<button type="button" class="close" data-dismiss="alert">×</button>
|
||||
<strong>Javascript missing</strong>.
|
||||
You either have JavaScript turned off or your browser doesn't support JavaScript.
|
||||
This website mostly consists of image galleries and needs JavaScript.
|
||||
</div>
|
||||
</noscript>
|
||||
EOF
|
||||
|
||||
# if a file was specified as argument, include it
|
||||
{ test -r "$1" } && { cat "$1" | render_html }
|
||||
|
||||
# generate the gallery's javascript
|
||||
dst_js="temp-${RANDOM}-gallery.js"
|
||||
|
||||
cat <<EOF > ${destination}/js/${dst_js}
|
||||
var slides= [];
|
||||
EOF
|
||||
|
||||
# parse gallery entries
|
||||
pics=`grep -v '^#'`
|
||||
for p in ${(f)pics}; do
|
||||
file=${p[(ws: :)1]}
|
||||
desc=`print $p | awk '{ for(c=2;c<=NF;c++) printf("%s ",$c) }'`
|
||||
cat << EOF >> ${destination}/js/$dst_js
|
||||
slides.push({
|
||||
href: '${file}',
|
||||
title: '${desc}'
|
||||
});
|
||||
EOF
|
||||
done
|
||||
|
||||
cat <<EOF >> ${destination}/js/$dst_js
|
||||
|
||||
function shuffle(array) {
|
||||
var m = array.length, t, i;
|
||||
|
||||
// While there remain elements to shuffle…
|
||||
while (m) {
|
||||
|
||||
// Pick a remaining element…
|
||||
i = Math.floor(Math.random() * m--);
|
||||
|
||||
// And swap it with the current element.
|
||||
t = array[m];
|
||||
array[m] = array[i];
|
||||
array[i] = t;
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
slides = shuffle(slides);
|
||||
|
||||
blueimp.Gallery(slides, {
|
||||
container: '#blueimp-gallery',
|
||||
carousel: true,
|
||||
fullscreen: true,
|
||||
closeOnEscape: true,
|
||||
closeOnSwipeUpOrDown: true,
|
||||
startSlideshow: true,
|
||||
slideshowInterval: 4500,
|
||||
});
|
||||
EOF
|
||||
# closeOnSlideClick: true,
|
||||
|
||||
|
||||
|
||||
# not really needed
|
||||
# includejs+=(js/blueimp-helper.js)
|
||||
# includejs+=(js/blueimp-gallery-indicator.js)
|
||||
# includejs+=(js/blueimp-gallery-fullscreen.js)
|
||||
# includejs+=(js/jquery.blueimp-gallery.min.js)
|
||||
|
||||
includejs+=($dst_js)
|
||||
|
||||
render_footer
|
||||
|
||||
}
|
||||
198
index
198
index
|
|
@ -18,59 +18,23 @@
|
|||
# this source code; if not, write to:
|
||||
# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
|
||||
VERSION=0.1
|
||||
|
||||
QUIET=0
|
||||
RECURSIVE=0
|
||||
PARAM=()
|
||||
|
||||
autoload colors; colors
|
||||
|
||||
# standard output message routines
|
||||
# it's always useful to wrap them, in case we change behaviour later
|
||||
notice() { if [[ $QUIET == 0 ]]; then print "$fg_bold[green][*]$fg_no_bold[default] $1" >&2; fi }
|
||||
error() { if [[ $QUIET == 0 ]]; then print "$fg[red][!]$fg[default] $1" >&2; fi }
|
||||
func() { if [[ $DEBUG == 1 ]]; then print "$fg[blue][D]$fg[default] $1" >&2; fi }
|
||||
act() {
|
||||
if [[ $QUIET == 0 ]]; then
|
||||
if [ "$1" = "-n" ]; then
|
||||
print -n "$fg_bold[white] . $fg_no_bold[default] $2" >&2;
|
||||
else
|
||||
print "$fg_bold[white] . $fg_no_bold[default] $1" >&2;
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# quick bold
|
||||
B="$fg_bold[white]"
|
||||
r="$reset_color"
|
||||
|
||||
# honor quiet and debug flags as early as possible
|
||||
if [[ ${@} == *-q* ]]; then QUIET=1; fi
|
||||
if [[ ${@} == *-D* ]]; then DEBUG=1; fi
|
||||
|
||||
# what operating system are we in? use os_detect()
|
||||
# simplifying modes of operation: GNU or MAC
|
||||
case $(uname) in
|
||||
Linux) OS=GNU
|
||||
notice "ZShelf v$VERSION running on GNU/Linux" ;;
|
||||
|
||||
Darwin) OS=MAC
|
||||
notice "ZShelf v$VERSION running on Mac/OSX" ;;
|
||||
|
||||
*) OS=GNU # default
|
||||
error "Running on an unknown operating system, assuming GNU" ;;
|
||||
esac
|
||||
|
||||
if [[ ${@} == *-r* ]]; then RECURSIVE=1; fi
|
||||
# API in brief:
|
||||
#
|
||||
# filetype_icon() - takes a filename as arg (can be file only or real path)
|
||||
# - returns a filename for the icon to be used from icons/
|
||||
#
|
||||
# index_dir() - indexes a directory into an html file linking all its contents
|
||||
#
|
||||
# preview_file() - takes a filename as arg
|
||||
# renders the file in a usable format (thumb if image, html if markdown, etc.)
|
||||
# returns the filename of the rendered result
|
||||
#
|
||||
|
||||
# file list map for current dir
|
||||
# format: filename;size;date
|
||||
typeset -alU files
|
||||
|
||||
# TODO
|
||||
usage() { act "no help ATM sry" }
|
||||
|
||||
filetype_icon() {
|
||||
|
||||
{ test "$1" = "" } && { error "filetype_icon called without argument"; return 1 }
|
||||
|
|
@ -294,142 +258,4 @@ preview_file() {
|
|||
done
|
||||
return 0
|
||||
}
|
||||
autostart() {
|
||||
if [ -d "$1" ]; then
|
||||
index_dir "$1"
|
||||
elif [ -f "$1" ]; then
|
||||
preview_file "$1"
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
return $?
|
||||
}
|
||||
|
||||
typeset -A subcommands_opts
|
||||
|
||||
### Options configuration
|
||||
#Hi, dear developer! Are you trying to add a new subcommand, or to add some options?
|
||||
#Well, keep in mind that:
|
||||
# 1. An option CAN'T have differente meanings/behaviour in different subcommands.
|
||||
# For example, "-s" means "size" and accept an argument. If you are tempted to add
|
||||
# an option "-s" (that means, for example "silent", and doesn't accept an argument)
|
||||
# DON'T DO IT!
|
||||
# There are two reasons for that:
|
||||
# I. usability; user expect that "-s" is "size
|
||||
# II. Option parsing WILL EXPLODE if you do this kind of bad things
|
||||
# (it will say "option defined more than once, and he's right)
|
||||
|
||||
|
||||
|
||||
# recursive, quiet, Debug, help, verbose, n=dryrun
|
||||
main_opts=(r q D h v n)
|
||||
|
||||
# p: prefix (string arg) = <a href> link prefix
|
||||
subcommands_opts[index]="p: "
|
||||
subcommands_opts[preview]=""
|
||||
|
||||
option_is_set() {
|
||||
#First argument, the option (something like "-s")
|
||||
#Second (optional) argument: if it's "out", command will print it out 'set'/'unset'
|
||||
# This is useful for if conditions
|
||||
#Return 0 if is set, 1 otherwise
|
||||
[[ -n ${(k)opts[$1]} ]];
|
||||
r=$?
|
||||
if [[ $2 == out ]]; then
|
||||
if [[ $r == 0 ]]; then print 'set'
|
||||
else print 'unset'; fi
|
||||
fi
|
||||
return $r;
|
||||
}
|
||||
option_value() { #First argument, the option (something like "-s")
|
||||
<<< ${opts[$1]}
|
||||
}
|
||||
|
||||
### Detect subcommand
|
||||
local -aU every_opts #every_opts behave like a set; that is, an array with unique elements
|
||||
for optspec in $subcommands_opts$main_opts; do
|
||||
for opt in ${=optspec}; do
|
||||
every_opts+=${opt}
|
||||
done
|
||||
done
|
||||
local -a oldstar
|
||||
oldstar=($argv)
|
||||
zparseopts -M -E -D -Adiscardme ${every_opts}
|
||||
unset discardme
|
||||
subcommand=$1
|
||||
{ test "$subcommand" = "" } && { subcommand="__default" }
|
||||
|
||||
argv=(${oldstar})
|
||||
unset oldstar
|
||||
|
||||
### Parsing global + command-specific options
|
||||
# zsh magic: ${=string} will split to multiple arguments when spaces occur
|
||||
set -A cmd_opts ${main_opts} ${=subcommands_opts[$subcommand]}
|
||||
if [[ -n $cmd_opts ]]; then #if there is no option, we don't need parsing
|
||||
zparseopts -M -E -D -Aopts ${cmd_opts}
|
||||
if [[ $? != 0 ]]; then
|
||||
error "Some error occurred during option processing."
|
||||
exitcode=1
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
#build PARAM (array of arguments) and check if there are unrecognized options
|
||||
local ok=0
|
||||
for arg in $*; do
|
||||
if [[ $arg == '--' || $arg == '-' ]]; then
|
||||
ok=1
|
||||
continue #it shouldnt be appended to PARAM
|
||||
elif [[ $arg[1] == '-' ]]; then
|
||||
if [[ $ok == 0 ]]; then
|
||||
error "unrecognized option $arg"
|
||||
exitcode=1
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
PARAM+=$arg
|
||||
done
|
||||
|
||||
# if 1st parameter is a known subcommand omit it from params
|
||||
{ test "$subcommand" = "__default" } || { PARAM[1]=(); shift }
|
||||
|
||||
### End parsing command-specific options
|
||||
|
||||
{ option_is_set -v } && {
|
||||
cat $ZSHELFEXEC | awk '/^#/ {print $0 } !/^#/ {exit}'
|
||||
echo }
|
||||
{ option_is_set -h } && { usage; return 0 }
|
||||
{ option_is_set -v } && { CLEANEXIT=0
|
||||
cat $JAROMAILEXEC | awk 'BEGIN { v=1 } !/^#/ { exit }'
|
||||
return 0 }
|
||||
{ option_is_set -q } && { QUIET=1 }
|
||||
{ option_is_set -D } && { DEBUG=1; QUIET=0; func "All debug messages ON" }
|
||||
{ option_is_set -n } && { DRYRUN=1; act "Dry run, show operations without executing them." }
|
||||
{ option_is_set -r } && { RECURSIVE=1 }
|
||||
{ option_is_set -p } && { LINK_PREFIX="`option_value -p`" }
|
||||
|
||||
# we take a file or directory as the only one parameter
|
||||
ARG=${PARAM[1]}
|
||||
case "$subcommand" in
|
||||
index)
|
||||
index_dir "$ARG"
|
||||
{ test -r "${ARG}/README.md" } && {
|
||||
res=`preview_file "${ARG}/README.md"`
|
||||
print "<hr>"
|
||||
cat "$res"
|
||||
}
|
||||
;;
|
||||
preview) preview_file ${PARAM} ;;
|
||||
help) usage ;;
|
||||
'source') return 0 ;;
|
||||
*) # unknown command, pass it to autostart
|
||||
func "unknown command, using autostart"
|
||||
autostart ${=PARAM}
|
||||
exitcode=$?
|
||||
{ test $exitcode = 0 } || {
|
||||
error "command \"$subcommand\" not recognized"
|
||||
act "try -h for help"
|
||||
}
|
||||
;;
|
||||
esac
|
||||
exitcode=$?
|
||||
return $exitcode
|
||||
|
|
|
|||
16
init
16
init
|
|
@ -68,10 +68,24 @@ mkdir -p tmpl
|
|||
{ test -r config.zsh } || {
|
||||
cat <<EOF > config.zsh
|
||||
TITLE="A new website made with WebNomad."
|
||||
BRAND="WebNomad"
|
||||
DESCRIPTION="WebNomad, your slick and static website publisher, powered by HTML5, Zsh and Bootstrap"
|
||||
KEYWORDS="web, design, html"
|
||||
|
||||
#
|
||||
# Anything below is safe to leave untouched
|
||||
#
|
||||
|
||||
# what file extension to use for html files
|
||||
EXTENSION=".html"
|
||||
|
||||
# what is the root of this website url, after the domain
|
||||
# leave blank if relative, or for instance /blog/
|
||||
WEB_ROOT=""
|
||||
|
||||
# where on the server filesystem are the indexed files located
|
||||
# this directory should be aliased by apache
|
||||
INDEX_PREFIX=""
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
|
|
|
|||
211
render
211
render
|
|
@ -2,7 +2,7 @@
|
|||
#
|
||||
# WebNomad, your slick and static website publisher
|
||||
#
|
||||
# Copyright (C) 2012-2013 Denis Roio <jaromil@dyne.org>
|
||||
# Copyright (C) 2012-2014 Denis Roio <jaromil@dyne.org>
|
||||
#
|
||||
# This source code is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Public License as published by
|
||||
|
|
@ -18,10 +18,14 @@
|
|||
# this source code; if not, write to:
|
||||
# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
VERSION=0.5
|
||||
|
||||
QUIET=0
|
||||
|
||||
SYS=`dirname $0`
|
||||
source $SYS/utils
|
||||
|
||||
|
||||
CMD="$1"
|
||||
|
||||
{ test -r config.zsh } || {
|
||||
error "Directory not configured for WebNomad. First use /webnomad/init"
|
||||
|
|
@ -30,10 +34,6 @@ source $SYS/utils
|
|||
|
||||
####################################
|
||||
# Base configuration
|
||||
notice "Rendering $B $BRAND $r website"
|
||||
act "Title: $B $TITLE $r"
|
||||
|
||||
typeset -a includejs
|
||||
|
||||
# base to be added to all urls
|
||||
# used by test to have all css and js in place
|
||||
|
|
@ -47,6 +47,7 @@ destination="pub"
|
|||
WEB_ROOT=""
|
||||
|
||||
# prefix to all indexed files
|
||||
# this can be a full path on the filesystem
|
||||
INDEX_PREFIX=""
|
||||
|
||||
# thumbnail size
|
||||
|
|
@ -55,6 +56,17 @@ THUMB_SIZE=256
|
|||
source config.zsh
|
||||
####################################
|
||||
|
||||
typeset -h dst # full path to destination for render_ functions
|
||||
typeset -alU includecss # array of css files to include
|
||||
typeset -alU includejs # array of js files to include
|
||||
typeset -alU fonts # array of available fonts
|
||||
|
||||
# string match case insensitive
|
||||
unsetopt CASE_GLOB
|
||||
|
||||
notice "Rendering your website"
|
||||
act "Title: $B $TITLE $r"
|
||||
|
||||
|
||||
render_header() {
|
||||
cat <<EOF
|
||||
|
|
@ -82,14 +94,29 @@ render_header() {
|
|||
|
||||
EOF
|
||||
{ test -r views/css/custom.css } && {
|
||||
cat <<EOF
|
||||
cat <<EOF
|
||||
<link href="${baseurl}css/custom.css" rel="stylesheet" />
|
||||
|
||||
EOF
|
||||
}
|
||||
}
|
||||
|
||||
{ test "$1" = "" } || { echo "${@}"; echo }
|
||||
# add css needed for internal functions
|
||||
for c in $includecss; do
|
||||
cat <<EOF
|
||||
<link href="${baseurl}css/${c}" rel="stylesheet" />
|
||||
EOF
|
||||
cp $SYS/css/${c} ${destination}/css/
|
||||
done
|
||||
|
||||
{ test -f ${destination}/css/custom.fonts.css } && {
|
||||
cat <<EOF
|
||||
<link href="${baseurl}css/custom.fonts.css" rel="stylesheet" />
|
||||
EOF
|
||||
}
|
||||
|
||||
# add any argument string to header
|
||||
{ test "$1" = "" } || { print "${@}"; print }
|
||||
|
||||
# add the user configured header
|
||||
cat tmpl/header.html
|
||||
|
||||
}
|
||||
|
|
@ -101,12 +128,22 @@ render_footer() {
|
|||
</div><!--/.container-->
|
||||
EOF
|
||||
|
||||
{ test "$1" = "" } || { echo "${@}"; echo }
|
||||
# add any string argument to the footer
|
||||
{ test "$1" = "" } || { print "${@}"; print }
|
||||
|
||||
# insert and copy all js files
|
||||
for i in $includejs; do
|
||||
echo "<script src=\"${baseurl}$i\"></script>"
|
||||
cat <<EOF
|
||||
<script type="text/javascript" src="${baseurl}/js/$i"></script>
|
||||
EOF
|
||||
{ test -r $SYS/js/$i } && {
|
||||
cp $SYS/js/$i $destination/js }
|
||||
done
|
||||
|
||||
# if test mode then render the test footer
|
||||
{ test "$destination" = "test" } && {
|
||||
render_test_footer }
|
||||
|
||||
cat <<EOF
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -115,7 +152,6 @@ EOF
|
|||
|
||||
render_html() {
|
||||
|
||||
|
||||
#######################################
|
||||
## we support the <markdown> tag inline
|
||||
|
||||
|
|
@ -160,128 +196,10 @@ render_html() {
|
|||
|
||||
}
|
||||
|
||||
render_gallery() {
|
||||
|
||||
render_header
|
||||
|
||||
# close <head> with gallery specific styles
|
||||
cat <<EOF >> $dst
|
||||
<link rel="stylesheet" href="${baseurl}css/blueimp-gallery.min.css" />
|
||||
|
||||
</head> <!-- end of <head> -->
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
EOF
|
||||
|
||||
# don't forget the navbar
|
||||
cat tmpl/navbar.html
|
||||
|
||||
cat <<EOF
|
||||
<!-- The Gallery as lightbox dialog, should be a child element of the document body -->
|
||||
<div id="blueimp-gallery" class="blueimp-gallery">
|
||||
<div class="slides"></div>
|
||||
<h3 class="title"></h3>
|
||||
<a class="prev">‹</a>
|
||||
<a class="next">›</a>
|
||||
<a class="close">×</a>
|
||||
<a class="play-pause"></a>
|
||||
<ol class="indicator"></ol>
|
||||
</div>
|
||||
|
||||
EOF
|
||||
|
||||
# put a notice for non-javascript browsers
|
||||
cat <<EOF
|
||||
<noscript>
|
||||
<p> </p>
|
||||
<div class="alert">
|
||||
<button type="button" class="close" data-dismiss="alert">×</button>
|
||||
<strong>Javascript missing</strong>.
|
||||
You either have JavaScript turned off or your browser doesn't support JavaScript.
|
||||
This website mostly consists of image galleries and needs JavaScript.
|
||||
</div>
|
||||
</noscript>
|
||||
EOF
|
||||
|
||||
# if a file was specified as argument, include it
|
||||
{ test -r "$1" } && { cat "$1" | render_html }
|
||||
|
||||
# generate the gallery's javascript
|
||||
dst_js="js/temp-${RANDOM}-gallery.js"
|
||||
|
||||
cat <<EOF > ${destination}/${dst_js}
|
||||
var slides= [];
|
||||
EOF
|
||||
|
||||
# parse gallery entries
|
||||
pics=`grep -v '^#'`
|
||||
for p in ${(f)pics}; do
|
||||
file=${p[(ws: :)1]}
|
||||
desc=`pecho $p | awk '{ for(c=2;c<=NF;c++) printf("%s ",$c) }'`
|
||||
cat << EOF >> ${destination}/$dst_js
|
||||
slides.push({
|
||||
href: '${file}',
|
||||
title: '${desc}'
|
||||
});
|
||||
EOF
|
||||
done
|
||||
|
||||
cat <<EOF >> ${destination}/$dst_js
|
||||
|
||||
function shuffle(array) {
|
||||
var m = array.length, t, i;
|
||||
|
||||
// While there remain elements to shuffle…
|
||||
while (m) {
|
||||
|
||||
// Pick a remaining element…
|
||||
i = Math.floor(Math.random() * m--);
|
||||
|
||||
// And swap it with the current element.
|
||||
t = array[m];
|
||||
array[m] = array[i];
|
||||
array[i] = t;
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
slides = shuffle(slides);
|
||||
|
||||
blueimp.Gallery(slides, {
|
||||
container: '#blueimp-gallery',
|
||||
carousel: true,
|
||||
fullscreen: true,
|
||||
closeOnEscape: true,
|
||||
closeOnSwipeUpOrDown: true,
|
||||
startSlideshow: true,
|
||||
slideshowInterval: 4500,
|
||||
});
|
||||
EOF
|
||||
# closeOnSlideClick: true,
|
||||
|
||||
includejs=(js/jquery.min.js)
|
||||
includejs+=(js/bootstrap.min.js)
|
||||
includejs+=(js/blueimp-gallery.min.js)
|
||||
|
||||
|
||||
# not really needed
|
||||
# includejs+=(js/blueimp-helper.js)
|
||||
# includejs+=(js/blueimp-gallery-indicator.js)
|
||||
# includejs+=(js/blueimp-gallery-fullscreen.js)
|
||||
# includejs+=(js/jquery.blueimp-gallery.min.js)
|
||||
|
||||
includejs+=($dst_js)
|
||||
|
||||
render_footer
|
||||
|
||||
}
|
||||
|
||||
index() {
|
||||
# render_header "<link rel=\"stylesheet\" href=\"css/blueimp-gallery.min.css\" />"
|
||||
{ test -d "$1" } || { error "cannot index directory not found: $1"; return 1 }
|
||||
source $SYS/index source
|
||||
source $SYS/index
|
||||
dirs=`find "$1" -type d`
|
||||
basedir=`dirname "$1"`
|
||||
|
||||
|
|
@ -336,18 +254,24 @@ read_meta() {
|
|||
|
||||
|
||||
{ test "$1" = "source" } && { return 0 }
|
||||
{ test "$1" = "test" } && {
|
||||
act "Local test rendering inside test/"
|
||||
source $SYS/test }
|
||||
|
||||
# prepare all fonts
|
||||
source $SYS/fonts
|
||||
|
||||
# Main
|
||||
mkdir -p ${destination}/css
|
||||
mkdir -p ${destination}/js
|
||||
|
||||
mkdir -p pub
|
||||
cat << EOF > ${destination}/.htaccess
|
||||
DirectoryIndex index index.html index.php
|
||||
DefaultType text/html
|
||||
EOF
|
||||
|
||||
act -n "Clean up all temp files ... "
|
||||
temps=(`find pub -type f -name 'temp-*'`)
|
||||
temps=(`find "$destination" -type f -name 'temp-*'`)
|
||||
for t in $temps; do rm -f $t; done
|
||||
print "done"
|
||||
|
||||
|
|
@ -400,7 +324,7 @@ cat <<EOF >> $dst
|
|||
|
||||
EOF
|
||||
|
||||
includejs=(js/bootstrap.min.js)
|
||||
# includejs=(js/bootstrap.min.js)
|
||||
render_footer >> $dst
|
||||
|
||||
act "done"
|
||||
|
|
@ -408,6 +332,7 @@ EOF
|
|||
done
|
||||
|
||||
# render all image galleries
|
||||
source $SYS/gallery
|
||||
gals=(`find views -type f -name '*.gal'`)
|
||||
gals+=(`find views -type f -name '*.gallery'`)
|
||||
for src in $gals; do
|
||||
|
|
@ -422,19 +347,23 @@ done
|
|||
# render all directory indexes
|
||||
idxs=(`find views -type f -name '*.idx'`)
|
||||
idxs+=(`find views -type f -name '*.index'`)
|
||||
for idx in $idxs; do
|
||||
notice "Directory index rendering: $idx"
|
||||
source ${idx}
|
||||
done
|
||||
|
||||
{ test ${#idxs} = 0 } || {
|
||||
for idx in $idxs; do
|
||||
notice "Directory index rendering: $idx"
|
||||
source ${idx}
|
||||
done
|
||||
# copy icons only if needed
|
||||
rsync -rlt "$SYS/icons" "${destination}/"
|
||||
}
|
||||
|
||||
# copy to destination all subdirs in views/
|
||||
for m in `find views -mindepth 1 -type d `; do
|
||||
act -n "publishing $B $m $r ... "
|
||||
rsync -r $m ${destination}/
|
||||
print "done"
|
||||
done
|
||||
|
||||
# if the whole website is a "slideshow" typology then we start with
|
||||
# if the whole website is a "slideshow" (set in config.zsh) then we start with
|
||||
# a full screen slideshow of all uploaded photos, cycling random every time.
|
||||
# galleries are supported and can be linked in menu and pages.
|
||||
{ test "$WEBSITE" = "slideshow" } && {
|
||||
|
|
|
|||
194
test
194
test
|
|
@ -1,129 +1,13 @@
|
|||
#!/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
|
||||
|
||||
# make it work to browse results on file://
|
||||
baseurl="file://`pwd`/test/"
|
||||
|
||||
destination="test"
|
||||
|
||||
# Main
|
||||
|
||||
mkdir -p ${destination}/css
|
||||
# side menu stylesheet
|
||||
cp $DIR/css/jquery.sidr.dark.css ${destination}/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 ${destination}/css/custom.fonts.css
|
||||
mkdir -p ${destination}/fonts
|
||||
ttf=`find -L fonts -iname '*.ttf'`
|
||||
for f in ${(f)ttf}; do
|
||||
ffile=`basename "$f"`
|
||||
cp "$f" ${destination}/css/"$ffile"
|
||||
custom_fonts+=("${ffile%.ttf}")
|
||||
cat <<EOF >> ${destination}/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" ${destination}/css/"$ffile"
|
||||
custom_fonts+=("${ffile%.otf}")
|
||||
cat <<EOF >> ${destination}/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="${destination}/`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
|
||||
includejs+=(jquery.min.js jquery.sidr.js)
|
||||
|
||||
includecss+=(jquery.sidr.dark.css)
|
||||
|
||||
# Font size selector
|
||||
|
||||
|
|
@ -142,15 +26,8 @@ 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() {
|
||||
|
|
@ -164,30 +41,42 @@ EOF
|
|||
done
|
||||
print "</select>"
|
||||
}
|
||||
|
||||
|
||||
cat <<EOF >> $dst
|
||||
|
||||
render_test_footer() {
|
||||
cat <<EOF
|
||||
<div id="sidr">
|
||||
<h3>Design test</h3>
|
||||
EOF
|
||||
|
||||
print "<h4>H1 font size</h3>"
|
||||
font-size_select h1size
|
||||
|
||||
print "<h4>H2 font size</h3>"
|
||||
font-size_select h2size
|
||||
|
||||
cat <<EOF
|
||||
<h3>Brand font family</h3>
|
||||
EOF
|
||||
font-family_select brand-font-family >> $dst
|
||||
|
||||
cat <<EOF >> $dst
|
||||
font-family_select brand-font-family
|
||||
|
||||
cat <<EOF
|
||||
<h3>Header font family</h3>
|
||||
EOF
|
||||
font-family_select header-font-family >> $dst
|
||||
font-family_select header-font-family
|
||||
|
||||
cat <<EOF >> $dst
|
||||
cat <<EOF
|
||||
<h3>Body font family</h3>
|
||||
EOF
|
||||
font-family_select body-font-family >> $dst
|
||||
font-family_select body-font-family
|
||||
|
||||
cat <<EOF >> $dst
|
||||
cat <<EOF
|
||||
<h3>Navigation Font family</h3>
|
||||
EOF
|
||||
font-family_select nav-font-family >> $dst
|
||||
font-family_select nav-font-family
|
||||
|
||||
|
||||
cat <<EOF >> $dst
|
||||
cat <<EOF
|
||||
|
||||
</div>
|
||||
|
||||
|
|
@ -215,33 +104,4 @@ cat <<EOF >> $dst
|
|||
|
||||
EOF
|
||||
|
||||
render_footer >> $dst
|
||||
|
||||
act "done"
|
||||
|
||||
done
|
||||
|
||||
|
||||
for m in `find views -mindepth 1 -type d `; do
|
||||
act -n "publishing $m... "
|
||||
rsync -r $m ${destination}/
|
||||
print "done"
|
||||
done
|
||||
|
||||
# add design test libs
|
||||
mkdir -p ${destination}/js
|
||||
cp $DIR/js/jquery.min.js ${destination}/js
|
||||
cp $DIR/js/jquery.sidr.js ${destination}/js
|
||||
|
||||
|
||||
|
||||
#### directory index
|
||||
idxs=(`find views -type f -name '*.idx'`)
|
||||
idxs+=(`find views -type f -name '*.index'`)
|
||||
{ test ${#idxs} = 0 } || {
|
||||
for idx in $idxs; do
|
||||
notice "Directory index rendering: $idx"
|
||||
source ${idx}
|
||||
done
|
||||
rsync -rlt "$DIR/icons" "${destination}/"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@
|
|||
|
||||
<li>
|
||||
<small><span itemprop="copyrightHolder">
|
||||
All information found on this page is free to copy
|
||||
All information found on this page is free to copy.
|
||||
</li>
|
||||
|
||||
<div class="pull-right">
|
||||
<li>
|
||||
<small class="pull-right">
|
||||
Website made<br />with <a href="http://jaroweb.dyne.org" target="_blank">Jaro Web</a>
|
||||
Website made<br />with <a href="http://www.dyne.org/software/webnomad" target="_blank">WebNomad</a>
|
||||
</small>
|
||||
</li>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue