From c33c985f1221d4bff5db158a992e64c4a21923b2 Mon Sep 17 00:00:00 2001 From: Jaromil Date: Mon, 8 Jun 2015 00:49:02 +0200 Subject: [PATCH] automatic preview reload on modifications in views/ and tmpl/ --- preview | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 preview diff --git a/preview b/preview new file mode 100755 index 0000000..994ac51 --- /dev/null +++ b/preview @@ -0,0 +1,44 @@ +#!/usr/bin/env zsh +# +# WebNomad, your slick and static website publisher +# +# Copyright (C) 2012-2015 Denis Roio +# +# 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. + +# full path to webnomad's system +R="`pwd`" +SYS="$R/webnomad" +source $SYS/utils + +BROWSER=${1:-firefox} +TIME_FORMAT='%F %H:%M' +OUTPUT_FORMAT='%T Event: %e fired for file: %w. Refreshing.' + +$SYS/render test +$BROWSER $R/test/index.html & + +views=" +$R/views +$R/tmpl +$R/config.zsh +" +while print - $views | inotifywait --fromfile - -q -r \ + -e modify -e create -e move -e delete \ + --timefmt "${TIME_FORMAT}" --format "${OUTPUT_FORMAT}"; do + $SYS/render test + BROWSER_WINDOW_ID=$(xdotool search --onlyvisible --class $BROWSER) + xdotool key --window $BROWSER_WINDOW_ID 'CTRL+r' +done