# HG changeset patch # User Robert McIntyre # Date 1320251094 25200 # Node ID 993b8d7d9bec98895b11c8bf87059dc3d36cb11b # Parent 6da973a6b93d51f14b9b899727d27539d834e675 buggy garbage diff -r 6da973a6b93d -r 993b8d7d9bec auto-weave.pl --- a/auto-weave.pl Wed Nov 02 05:14:21 2011 -0700 +++ b/auto-weave.pl Wed Nov 02 09:24:54 2011 -0700 @@ -1,21 +1,16 @@ #!/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 @@ -26,30 +21,18 @@ # 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; - $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); - } + system "weave $name &"; + }); } - # manual event loop 1 while $inotify->poll; diff -r 6da973a6b93d -r 993b8d7d9bec watch-org.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/watch-org.pl Wed Nov 02 09:24:54 2011 -0700 @@ -0,0 +1,50 @@ +#!/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: $!"; + +$html_files = `find /home/r/proj/{cortex,aurellem,pokemon-types} -name "*.html" -print0`; +@html_files = split /\0/, $html_files; + + +#@org_files = glob("./org/*.org"); + + +for $file(@html_files){print "$file\n";} + +$last_page = ""; + +foreach(@html_files){ +$inotify->watch ($_, IN_MODIFY, sub +{ + my $e = shift; + my $name = $e->fullname; + print "**************************\n"; + print "$name was modified\n";## if $e->IN_MODIFY; + + $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 +while (1){ + print "I'm pollin'!"; + $inotify->poll; + +} diff -r 6da973a6b93d -r 993b8d7d9bec weave-time!.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/weave-time!.pl Wed Nov 02 09:24:54 2011 -0700 @@ -0,0 +1,6 @@ +#!/usr/bin/perl + +system "perl /home/r/proj/org-tools/watch-org.pl &"; +system "perl /home/r/proj/org-tools/auto-weave.pl &"; + + diff -r 6da973a6b93d -r 993b8d7d9bec weave.sh --- a/weave.sh Wed Nov 02 05:14:21 2011 -0700 +++ b/weave.sh Wed Nov 02 09:24:54 2011 -0700 @@ -36,11 +36,15 @@ :auto-preamble t) ))" \ \ -2>&1 #| pcregrep 'Wrote' +2>&1 +#| pcregrep 'Wrote' + + +