Mercurial > org-tools
comparison auto-weave.pl @ 13:be73e58d4b24 v0.1
cleanup
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 25 Oct 2011 08:09:06 -0700 |
parents | 24ff8a9c76c4 |
children | 6ef9ccf7a17e |
comparison
equal
deleted
inserted
replaced
12:737c903fc815 | 13:be73e58d4b24 |
---|---|
4 use WWW::Mechanize::Firefox; | 4 use WWW::Mechanize::Firefox; |
5 my $mech = WWW::Mechanize::Firefox->new(); | 5 my $mech = WWW::Mechanize::Firefox->new(); |
6 | 6 |
7 my $inotify = new Linux::Inotify2 | 7 my $inotify = new Linux::Inotify2 |
8 or die "unable to create new inotify object: $!"; | 8 or die "unable to create new inotify object: $!"; |
9 | |
10 | 9 |
11 @org_files = glob("./org/*.org"); | 10 @org_files = glob("./org/*.org"); |
12 | 11 |
13 $" = "\n"; | 12 $" = "\n"; |
14 print "@org_files\n"; | 13 print "@org_files\n"; |
26 # so ignore every other invocation. | 25 # so ignore every other invocation. |
27 if ($ignore_next) { | 26 if ($ignore_next) { |
28 $ignore_next = 0; | 27 $ignore_next = 0; |
29 return; | 28 return; |
30 } | 29 } |
30 $ignore_next = 1; | |
31 | 31 |
32 my $e = shift; | 32 my $e = shift; |
33 my $name = $e->fullname; | 33 my $name = $e->fullname; |
34 print "$name was modified\n" if $e->IN_MODIFY; | 34 print "$name was modified\n" if $e->IN_MODIFY; |
35 $output = `weave $name`; | 35 $output = `weave $name`; |
36 print ("$name\n"); | |
37 $path = `readlink -f $name`; | 36 $path = `readlink -f $name`; |
38 $path =~ s|/home/r/proj|http://aurellem.localhost|; | 37 $path =~ s|/home/r/proj|http://aurellem.localhost|; |
39 print ("$path\n"); | |
40 $path =~ s|org|html|g; | 38 $path =~ s|org|html|g; |
41 print ("$path\n"); | |
42 #system ("firefox $path"); | |
43 $mech->get($path); | 39 $mech->get($path); |
44 $ignore_next = 1; | |
45 | |
46 }); | 40 }); |
47 } | 41 } |
48 | 42 |
49 | 43 |
50 | 44 # manual event loop |
51 | |
52 # integration into AnyEvent (works with EV, Glib, Tk, POE...) | |
53 #my $inotify_w = AnyEvent->io | |
54 # ( | |
55 # fh => $inotify->fileno, poll => 'r', cb => sub { $inotify->poll } | |
56 # ); | |
57 | |
58 # manual event loop | |
59 1 while $inotify->poll; | 45 1 while $inotify->poll; |