# HG changeset patch # User Robert McIntyre # Date 1330608792 25200 # Node ID c14f3a4af7fd59634857edf2b2df7f28279e2873 # Parent 993b8d7d9bec98895b11c8bf87059dc3d36cb11b make weave-all check for existence of org directory diff -r 993b8d7d9bec -r c14f3a4af7fd auto-weave.pl --- a/auto-weave.pl Wed Nov 02 09:24:54 2011 -0700 +++ b/auto-weave.pl Thu Mar 01 06:33:12 2012 -0700 @@ -1,16 +1,21 @@ #!/usr/bin/perl use Linux::Inotify2; +use WWW::Mechanize::Firefox; +my $mech = WWW::Mechanize::Firefox->new(); my $inotify = new Linux::Inotify2 or die "unable to create new inotify object: $!"; + $org_files = `find /home/r/proj -name "*.org" -print0`; @org_files = split /\0/, $org_files; +#@org_files = glob("./org/*.org"); + for $file(@org_files){print "$file\n";} $ignore_next = 0; - +$last_page = ""; foreach(@org_files){ # add watchers @@ -21,18 +26,30 @@ # twice every time the file is saved from emacs. # so ignore every other invocation. if ($ignore_next) { - $ignore_next = 0; - return; + $ignore_next = 0; + return; } $ignore_next = 1; my $e = shift; my $name = $e->fullname; print "$name was modified\n" if $e->IN_MODIFY; - system "weave $name &"; - + $output = `weave $name`; + $path = `readlink -f $name`; + $path =~ s|/home/r/proj|http://aurellem.localhost|; + $path =~ s|org|html|g; + if ($last_page eq $path){ + print "reloading current page : $path\n"; + $mech->reload(); + } + else { + print "moving to new page : $path\n"; + $last_page = $path; + $mech->get($path); + } }); } + # manual event loop 1 while $inotify->poll; diff -r 993b8d7d9bec -r c14f3a4af7fd weave-all.sh --- a/weave-all.sh Wed Nov 02 09:24:54 2011 -0700 +++ b/weave-all.sh Thu Mar 01 06:33:12 2012 -0700 @@ -5,6 +5,12 @@ #target=$(readlink -f $1) +if [ ! -d "./org" ]; then + echo "no org directory" + exit +fi + + dir=`pwd` emacs \