[Jifty-commit] r545 - in jifty/trunk: lib/Jifty
lib/Jifty/Action/Devel lib/Jifty/Web/Form/Field
share/web/templates/__jifty
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Fri Feb 3 09:09:20 EST 2006
Author: alexmv
Date: Fri Feb 3 09:09:18 2006
New Revision: 545
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/Action/Devel/FileEditor.pm
jifty/trunk/lib/Jifty/Web.pm
jifty/trunk/lib/Jifty/Web/Form/Field/Textarea.pm
jifty/trunk/share/web/templates/__jifty/edit_file
Log:
r8886 at zoq-fot-pik: chmrr | 2006-02-03 09:08:36 -0500
* Tweaks to make halo editing work a bit happier
Modified: jifty/trunk/lib/Jifty/Action/Devel/FileEditor.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Action/Devel/FileEditor.pm (original)
+++ jifty/trunk/lib/Jifty/Action/Devel/FileEditor.pm Fri Feb 3 09:09:18 2006
@@ -6,6 +6,7 @@
sub new {
my $class = shift; my $self = $class->SUPER::new(@_);
+ $self->sticky_on_success(1);
$self->get_default_content;
return($self);
@@ -44,8 +45,8 @@
foreach my $item (@{$cfg{comp_root}}) {
$local_template_base = $item->[1] if ($item->[0] eq 'application');
my $qualified_path = File::Spec->catfile($item->[1],$path);
- if (-f $qualified_path and -r $qualified_path) {
- $self->argument_value(source_path => $qualified_path);
+ if (-f $qualified_path and -r $qualified_path) {
+ $self->argument_value(qualified_path => $qualified_path);
my $filehandle;
open ($filehandle, "<$qualified_path")||die "Couldn't read $qualified_path: $!";
$out = join('',<$filehandle>);
@@ -60,36 +61,29 @@
sub validate_destination_path {
my $self = shift;
my $value = shift;
- $self->{'write_to'} = ($value or $self->argument_value('source_path'));
+ $self->{'write_to'} = ($value or $self->argument_value('qualified_path'));
unless ($self->{'write_to'}) {
return $self->validation_error( destination_path => "No destination path set. Where should I write this file?");
}
if (-f $self->{'write_to'} and not -w $self->{'write_to'}) {
return $self->validation_error( destination_path => "Can't save the file to ".$self->{'write_to'});
-
}
return $self->validation_ok;
}
sub take_action {
my $self = shift;
-
my $dest = $self->{'write_to'};
- warn "Making directory $dest";
$self->_make_path($dest);
my $writehandle = IO::File->new();
$writehandle->open(">$dest") || die "Couldn't open $dest for writing: ".$!;
- warn YAML::Dump($self);
$writehandle->print( $self->argument_value('content')) || die " Couldn't write to $dest: ".$!;
$writehandle->close() || die "Couldn't close filehandle $dest ".$!;
$self->result->message("Updated $dest");
- $self->redirect('/=/edit/component/'.$dest);
-
}
sub _make_path {
-
my $self = shift;
my $whole_path = shift;
my @dirs = File::Spec->splitdir( $whole_path );
@@ -106,6 +100,4 @@
}
-
-
1;
Modified: jifty/trunk/lib/Jifty/Web.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web.pm (original)
+++ jifty/trunk/lib/Jifty/Web.pm Fri Feb 3 09:09:18 2006
@@ -862,6 +862,17 @@
return ( join( ';', @params ) );
}
+=head3 escape STRING
+
+HTML-escapes the given string and returns it
+
+=cut
+
+sub escape {
+ my $self = shift;
+ return join '', map {$self->mason->interp->apply_escapes( $_, 'h' )} @_;
+}
+
=head3 navigation
Returns the L<Jifty::Web::Menu> for this web request; one is
Modified: jifty/trunk/lib/Jifty/Web/Form/Field/Textarea.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/Form/Field/Textarea.pm (original)
+++ jifty/trunk/lib/Jifty/Web/Form/Field/Textarea.pm Fri Feb 3 09:09:18 2006
@@ -32,7 +32,7 @@
$field .= qq! cols="@{[$self->cols || 60]}"!;
$field .= $self->_widget_class;
$field .= qq! >!;
- $field .= $self->current_value if $self->current_value;
+ $field .= Jifty->web->escape($self->current_value) if $self->current_value;
$field .= qq!</textarea>\n!;
Jifty->web->out($field);
'';
Modified: jifty/trunk/share/web/templates/__jifty/edit_file
==============================================================================
--- jifty/trunk/share/web/templates/__jifty/edit_file (original)
+++ jifty/trunk/share/web/templates/__jifty/edit_file Fri Feb 3 09:09:18 2006
@@ -1,16 +1,15 @@
<%args>
$path=> undef
$editor => undef
-$next => undef
</%args>
<%init>
my $title = "Editing file ".$editor->argument_value('source_path');
</%init>
<&|/_elements/wrapper, title => $title &>
-<%Jifty->web->form->start( call => $next, moniker => 'edit')%>
+<% Jifty->web->form->start %>
<%$editor->form_field('file_type')%>
<%$editor->form_field('destination_path')%>
<%$editor->form_field('content')%>
-<% Jifty->web->form->submit(label => 'Save changes')%>
-<%Jifty->web->form->end()%>
+<% Jifty->web->return(label => 'Save and return', submit => $editor )%>
+<% Jifty->web->form->end %>
</&>
More information about the Jifty-commit
mailing list