diff auto-weave.pl @ 18:993b8d7d9bec

buggy garbage
author Robert McIntyre <rlm@mit.edu>
date Wed, 02 Nov 2011 09:24:54 -0700
parents 6da973a6b93d
children c14f3a4af7fd
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;