/[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 495 - (show annotations)
Mon Nov 24 20:58:02 2008 UTC (15 years, 5 months ago) by dpavlin
File size: 688 byte(s)
we really prefer target before href
1 package Frey::Editor;
2 use Moose;
3
4 extends 'Frey::ClassLoader';
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 command {
27 my ( $self, $url ) = @_;
28 $url =~ url_regex;
29 my ( $path, $line ) = ( $1, $2 );
30 # FIXME SECURITY path verification for $path
31 my $editor = $ENV{VISUAL} || $ENV{EDITOR} || 'vi';
32 $path = $self->class_path( $path ) || $path if ! -e $path;
33 my $cmd = "$editor $path +$line";
34 warn "# $url -> system $cmd";
35 return $cmd;
36 }
37
38 1;

  ViewVC Help
Powered by ViewVC 1.1.26