/[Frey]/trunk/lib/Frey/Editor.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/Frey/Editor.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 407 by dpavlin, Tue Nov 18 12:02:57 2008 UTC revision 617 by dpavlin, Sat Nov 29 15:05:55 2008 UTC
# Line 1  Line 1 
1  package Frey::Editor;  package Frey::Editor;
2  use Moose;  use Moose;
3    
4    extends 'Frey::ClassLoader';
5    
6  =head1 DESCRIPTION  =head1 DESCRIPTION
7    
8  Support for local editor invocation from web  Support for local editor invocation from web
9    
10   <a href="/editor+$path+$line" target="editor">$class</a>   <a target="editor" href="/editor+$path+$line">$class</a>
11    
12  =head2 url  =head2 url
13    
# Line 21  sub url_regex { qr{/editor\+?(.+?)\+(\d+ Line 23  sub url_regex { qr{/editor\+?(.+?)\+(\d+
23    
24  =cut  =cut
25    
26    sub switch_screen {
27            my $cmd = 'xdotool key super+Tab';
28            warn "# switch_screen $cmd";
29            system $cmd;
30    }
31    
32  sub command {  sub command {
33          my ( $self, $url ) = @_;          my ( $self, $url ) = @_;
34          $url =~ url_regex;          $url =~ url_regex;
35            my ( $path, $line ) = ( $1, $2 );
36            # FIXME SECURITY path verification for $path
37          my $editor = $ENV{VISUAL} || $ENV{EDITOR} || 'vi';          my $editor = $ENV{VISUAL} || $ENV{EDITOR} || 'vi';
38          # FIXME SECURITY path verification for $1          $path = $self->class_path( $path ) || $path if ! -e $path;
39          my $cmd = "$editor $1 +$2";          my $cmd = "$editor $path +$line";
40          warn "# $url -> system $cmd";          warn "# $url -> system $cmd";
41          return $cmd;          $self->switch_screen;
42            system $cmd;
43            $self->switch_screen;
44  }  }
45    
46  1;  1;

Legend:
Removed from v.407  
changed lines
  Added in v.617

  ViewVC Help
Powered by ViewVC 1.1.26