Mercurial > org-tools
changeset 18:993b8d7d9bec
buggy garbage
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Wed, 02 Nov 2011 09:24:54 -0700 |
parents | 6da973a6b93d |
children | c14f3a4af7fd |
files | auto-weave.pl watch-org.pl weave-time!.pl weave.sh |
diffstat | 4 files changed, 66 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
1.1 --- a/auto-weave.pl Wed Nov 02 05:14:21 2011 -0700 1.2 +++ b/auto-weave.pl Wed Nov 02 09:24:54 2011 -0700 1.3 @@ -1,21 +1,16 @@ 1.4 #!/usr/bin/perl 1.5 1.6 use Linux::Inotify2; 1.7 -use WWW::Mechanize::Firefox; 1.8 -my $mech = WWW::Mechanize::Firefox->new(); 1.9 1.10 my $inotify = new Linux::Inotify2 1.11 or die "unable to create new inotify object: $!"; 1.12 1.13 - 1.14 $org_files = `find /home/r/proj -name "*.org" -print0`; 1.15 @org_files = split /\0/, $org_files; 1.16 1.17 -#@org_files = glob("./org/*.org"); 1.18 - 1.19 for $file(@org_files){print "$file\n";} 1.20 $ignore_next = 0; 1.21 -$last_page = ""; 1.22 + 1.23 1.24 foreach(@org_files){ 1.25 # add watchers 1.26 @@ -26,30 +21,18 @@ 1.27 # twice every time the file is saved from emacs. 1.28 # so ignore every other invocation. 1.29 if ($ignore_next) { 1.30 - $ignore_next = 0; 1.31 - return; 1.32 + $ignore_next = 0; 1.33 + return; 1.34 } 1.35 $ignore_next = 1; 1.36 1.37 my $e = shift; 1.38 my $name = $e->fullname; 1.39 print "$name was modified\n" if $e->IN_MODIFY; 1.40 - $output = `weave $name`; 1.41 - $path = `readlink -f $name`; 1.42 - $path =~ s|/home/r/proj|http://aurellem.localhost|; 1.43 - $path =~ s|org|html|g; 1.44 - if ($last_page eq $path){ 1.45 - print "reloading current page : $path\n"; 1.46 - $mech->reload(); 1.47 - } 1.48 - else { 1.49 - print "moving to new page : $path\n"; 1.50 - $last_page = $path; 1.51 - $mech->get($path); 1.52 - } 1.53 + system "weave $name &"; 1.54 + 1.55 }); 1.56 } 1.57 1.58 - 1.59 # manual event loop 1.60 1 while $inotify->poll;
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/watch-org.pl Wed Nov 02 09:24:54 2011 -0700 2.3 @@ -0,0 +1,50 @@ 2.4 +#!/usr/bin/perl 2.5 + 2.6 +use Linux::Inotify2; 2.7 +use WWW::Mechanize::Firefox; 2.8 +my $mech = WWW::Mechanize::Firefox->new(); 2.9 + 2.10 +my $inotify = new Linux::Inotify2 2.11 + or die "unable to create new inotify object: $!"; 2.12 + 2.13 +$html_files = `find /home/r/proj/{cortex,aurellem,pokemon-types} -name "*.html" -print0`; 2.14 +@html_files = split /\0/, $html_files; 2.15 + 2.16 + 2.17 +#@org_files = glob("./org/*.org"); 2.18 + 2.19 + 2.20 +for $file(@html_files){print "$file\n";} 2.21 + 2.22 +$last_page = ""; 2.23 + 2.24 +foreach(@html_files){ 2.25 +$inotify->watch ($_, IN_MODIFY, sub 2.26 +{ 2.27 + my $e = shift; 2.28 + my $name = $e->fullname; 2.29 + print "**************************\n"; 2.30 + print "$name was modified\n";## if $e->IN_MODIFY; 2.31 + 2.32 + $path = `readlink -f $name`; 2.33 + $path =~ s|/home/r/proj|http://aurellem.localhost|; 2.34 + #$path =~ s|org|html|g; 2.35 + 2.36 + if ($last_page eq $path){ 2.37 + print "reloading current page : $path\n"; 2.38 + $mech->reload(); 2.39 + } 2.40 + else { 2.41 + print "moving to new page : $path\n"; 2.42 + $last_page = $path; 2.43 + $mech->get($path); 2.44 + } 2.45 +}); 2.46 +} 2.47 + 2.48 +# manual event loop 2.49 +while (1){ 2.50 + print "I'm pollin'!"; 2.51 + $inotify->poll; 2.52 + 2.53 +}