/[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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1133 - (show annotations)
Tue Jun 30 15:10:55 2009 UTC (14 years, 10 months ago) by dpavlin
File size: 885 byte(s)
make classes immutable and remove moose droppings to make Perl::Critic::Moose happy
1 package Frey::Editor;
2 use Moose;
3
4 extends 'Frey::Class::Loader';
5
6 =head1 DESCRIPTION
7
8 Support for local editor invocation from web
9
10 <a target="editor" href="/editor+$path+$line">$class</a>
11
12 =head2 url
13
14 $path =~ $editor->url_regex
15
16 =cut
17
18 sub url_regex { qr{/editor\+?(.+?)\+(\d+)} }
19
20 =head2 command
21
22 my $system = $editor->command( $path );
23
24 =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 {
33 my ( $self, $url ) = @_;
34 $url =~ url_regex;
35 my ( $path, $line ) = ( $1, $2 );
36 # FIXME SECURITY path verification for $path
37 my $editor = $ENV{VISUAL} || $ENV{EDITOR} || 'vi';
38 $path = $self->class_path( $path ) || $path if ! -e $path;
39 my $cmd = "$editor $path +$line";
40 warn "# $url -> system $cmd";
41 $self->switch_screen;
42 system $cmd;
43 $self->switch_screen;
44 }
45
46 __PACKAGE__->meta->make_immutable;
47 no Moose;
48
49 1;

  ViewVC Help
Powered by ViewVC 1.1.26