[Jifty-commit] r534 - jifty/trunk/inc/Module
jifty/trunk/lib/Jifty/Action/Devel
jifty/trunk/share/web/templates/__jifty
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Sun Jan 29 23:37:51 EST 2006
Author: jesse
Date: Sun Jan 29 23:37:50 2006
New Revision: 534
Added:
jifty/trunk/lib/Jifty/Action/Devel/
jifty/trunk/lib/Jifty/Action/Devel/FileEditor.pm
jifty/trunk/share/web/templates/__jifty/edit_file
Modified:
/ (props changed)
jifty/trunk/inc/Module/AutoInstall.pm
jifty/trunk/inc/Module/Install.pm
jifty/trunk/inc/Module/Install/AutoInstall.pm
jifty/trunk/inc/Module/Install/Base.pm
jifty/trunk/inc/Module/Install/Can.pm
jifty/trunk/inc/Module/Install/Fetch.pm
jifty/trunk/inc/Module/Install/Include.pm
jifty/trunk/inc/Module/Install/Makefile.pm
jifty/trunk/inc/Module/Install/Metadata.pm
jifty/trunk/inc/Module/Install/Scripts.pm
jifty/trunk/inc/Module/Install/Share.pm
jifty/trunk/inc/Module/Install/Win32.pm
jifty/trunk/inc/Module/Install/WriteAll.pm
Log:
r23017 at truegrounds: jesse | 2006-01-30 05:35:14 +0100
* File edity
Modified: jifty/trunk/inc/Module/AutoInstall.pm
==============================================================================
--- jifty/trunk/inc/Module/AutoInstall.pm (original)
+++ jifty/trunk/inc/Module/AutoInstall.pm Sun Jan 29 23:37:50 2006
@@ -1,4 +1,4 @@
-#line 1 "inc/Module/AutoInstall.pm - /usr/lib/perl5/site_perl/5.8.7/Module/AutoInstall.pm"
+#line 1 "inc/Module/AutoInstall.pm - /usr/local/share/perl/5.8.7/Module/AutoInstall.pm"
package Module::AutoInstall;
$Module::AutoInstall::VERSION = '1.01';
Modified: jifty/trunk/inc/Module/Install.pm
==============================================================================
--- jifty/trunk/inc/Module/Install.pm (original)
+++ jifty/trunk/inc/Module/Install.pm Sun Jan 29 23:37:50 2006
@@ -1,4 +1,4 @@
-#line 1 "/home/chmrr/work/rt/local/jifty/inc/Module/Install.pm - /usr/lib/perl5/site_perl/5.8.7/Module/Install.pm"
+#line 1 "/home/jesse/svk/jifty.org/jifty/trunk/inc/Module/Install.pm - /usr/local/share/perl/5.8.7/Module/Install.pm"
package Module::Install;
use 5.004;
Modified: jifty/trunk/inc/Module/Install/AutoInstall.pm
==============================================================================
--- jifty/trunk/inc/Module/Install/AutoInstall.pm (original)
+++ jifty/trunk/inc/Module/Install/AutoInstall.pm Sun Jan 29 23:37:50 2006
@@ -1,4 +1,4 @@
-#line 1 "inc/Module/Install/AutoInstall.pm - /usr/lib/perl5/site_perl/5.8.7/Module/Install/AutoInstall.pm"
+#line 1 "inc/Module/Install/AutoInstall.pm - /usr/local/share/perl/5.8.7/Module/Install/AutoInstall.pm"
package Module::Install::AutoInstall;
use Module::Install::Base; @ISA = qw(Module::Install::Base);
Modified: jifty/trunk/inc/Module/Install/Base.pm
==============================================================================
--- jifty/trunk/inc/Module/Install/Base.pm (original)
+++ jifty/trunk/inc/Module/Install/Base.pm Sun Jan 29 23:37:50 2006
@@ -1,4 +1,4 @@
-#line 1 "inc/Module/Install/Base.pm - /usr/lib/perl5/site_perl/5.8.7/Module/Install/Base.pm"
+#line 1 "inc/Module/Install/Base.pm - /usr/local/share/perl/5.8.7/Module/Install/Base.pm"
package Module::Install::Base;
# Suspend handler for "redefined" warnings
Modified: jifty/trunk/inc/Module/Install/Can.pm
==============================================================================
--- jifty/trunk/inc/Module/Install/Can.pm (original)
+++ jifty/trunk/inc/Module/Install/Can.pm Sun Jan 29 23:37:50 2006
@@ -1,4 +1,4 @@
-#line 1 "inc/Module/Install/Can.pm - /usr/lib/perl5/site_perl/5.8.7/Module/Install/Can.pm"
+#line 1 "inc/Module/Install/Can.pm - /usr/local/share/perl/5.8.7/Module/Install/Can.pm"
package Module::Install::Can;
use Module::Install::Base; @ISA = qw(Module::Install::Base);
$VERSION = '0.01';
@@ -52,6 +52,7 @@
# Fix Cygwin bug on maybe_command();
if ($^O eq 'cygwin') {
require ExtUtils::MM_Cygwin;
+ require ExtUtils::MM_Win32;
if (!defined(&ExtUtils::MM_Cygwin::maybe_command)) {
*ExtUtils::MM_Cygwin::maybe_command = sub {
my ($self, $file) = @_;
Modified: jifty/trunk/inc/Module/Install/Fetch.pm
==============================================================================
--- jifty/trunk/inc/Module/Install/Fetch.pm (original)
+++ jifty/trunk/inc/Module/Install/Fetch.pm Sun Jan 29 23:37:50 2006
@@ -1,4 +1,4 @@
-#line 1 "inc/Module/Install/Fetch.pm - /usr/lib/perl5/site_perl/5.8.7/Module/Install/Fetch.pm"
+#line 1 "inc/Module/Install/Fetch.pm - /usr/local/share/perl/5.8.7/Module/Install/Fetch.pm"
package Module::Install::Fetch;
use Module::Install::Base; @ISA = qw(Module::Install::Base);
Modified: jifty/trunk/inc/Module/Install/Include.pm
==============================================================================
--- jifty/trunk/inc/Module/Install/Include.pm (original)
+++ jifty/trunk/inc/Module/Install/Include.pm Sun Jan 29 23:37:50 2006
@@ -1,4 +1,4 @@
-#line 1 "inc/Module/Install/Include.pm - /usr/lib/perl5/site_perl/5.8.7/Module/Install/Include.pm"
+#line 1 "inc/Module/Install/Include.pm - /usr/local/share/perl/5.8.7/Module/Install/Include.pm"
package Module::Install::Include;
use Module::Install::Base; @ISA = qw(Module::Install::Base);
@@ -6,5 +6,5 @@
sub include_deps { +shift->admin->include_deps(@_) };
sub auto_include { +shift->admin->auto_include(@_) };
sub auto_include_deps { +shift->admin->auto_include_deps(@_) };
-
+sub auto_include_dependent_dists { +shift->admin->auto_include_dependent_dists(@_) }
1;
Modified: jifty/trunk/inc/Module/Install/Makefile.pm
==============================================================================
--- jifty/trunk/inc/Module/Install/Makefile.pm (original)
+++ jifty/trunk/inc/Module/Install/Makefile.pm Sun Jan 29 23:37:50 2006
@@ -1,4 +1,4 @@
-#line 1 "inc/Module/Install/Makefile.pm - /usr/lib/perl5/site_perl/5.8.7/Module/Install/Makefile.pm"
+#line 1 "inc/Module/Install/Makefile.pm - /usr/local/share/perl/5.8.7/Module/Install/Makefile.pm"
package Module::Install::Makefile;
use Module::Install::Base; @ISA = qw(Module::Install::Base);
Modified: jifty/trunk/inc/Module/Install/Metadata.pm
==============================================================================
--- jifty/trunk/inc/Module/Install/Metadata.pm (original)
+++ jifty/trunk/inc/Module/Install/Metadata.pm Sun Jan 29 23:37:50 2006
@@ -1,4 +1,4 @@
-#line 1 "inc/Module/Install/Metadata.pm - /usr/lib/perl5/site_perl/5.8.7/Module/Install/Metadata.pm"
+#line 1 "inc/Module/Install/Metadata.pm - /usr/local/share/perl/5.8.7/Module/Install/Metadata.pm"
package Module::Install::Metadata;
use strict 'vars';
Modified: jifty/trunk/inc/Module/Install/Scripts.pm
==============================================================================
--- jifty/trunk/inc/Module/Install/Scripts.pm (original)
+++ jifty/trunk/inc/Module/Install/Scripts.pm Sun Jan 29 23:37:50 2006
@@ -1,4 +1,4 @@
-#line 1 "inc/Module/Install/Scripts.pm - /usr/lib/perl5/site_perl/5.8.7/Module/Install/Scripts.pm"
+#line 1 "inc/Module/Install/Scripts.pm - /usr/local/share/perl/5.8.7/Module/Install/Scripts.pm"
package Module::Install::Scripts;
use Module::Install::Base; @ISA = qw(Module::Install::Base);
$VERSION = '0.02';
Modified: jifty/trunk/inc/Module/Install/Share.pm
==============================================================================
--- jifty/trunk/inc/Module/Install/Share.pm (original)
+++ jifty/trunk/inc/Module/Install/Share.pm Sun Jan 29 23:37:50 2006
@@ -1,4 +1,4 @@
-#line 1 "inc/Module/Install/Share.pm - /usr/lib/perl5/site_perl/5.8.7/Module/Install/Share.pm"
+#line 1 "inc/Module/Install/Share.pm - /usr/local/share/perl/5.8.7/Module/Install/Share.pm"
package Module::Install::Share;
use Module::Install::Base;
Modified: jifty/trunk/inc/Module/Install/Win32.pm
==============================================================================
--- jifty/trunk/inc/Module/Install/Win32.pm (original)
+++ jifty/trunk/inc/Module/Install/Win32.pm Sun Jan 29 23:37:50 2006
@@ -1,4 +1,4 @@
-#line 1 "inc/Module/Install/Win32.pm - /usr/lib/perl5/site_perl/5.8.7/Module/Install/Win32.pm"
+#line 1 "inc/Module/Install/Win32.pm - /usr/local/share/perl/5.8.7/Module/Install/Win32.pm"
package Module::Install::Win32;
use Module::Install::Base; @ISA = qw(Module::Install::Base);
Modified: jifty/trunk/inc/Module/Install/WriteAll.pm
==============================================================================
--- jifty/trunk/inc/Module/Install/WriteAll.pm (original)
+++ jifty/trunk/inc/Module/Install/WriteAll.pm Sun Jan 29 23:37:50 2006
@@ -1,4 +1,4 @@
-#line 1 "inc/Module/Install/WriteAll.pm - /usr/lib/perl5/site_perl/5.8.7/Module/Install/WriteAll.pm"
+#line 1 "inc/Module/Install/WriteAll.pm - /usr/local/share/perl/5.8.7/Module/Install/WriteAll.pm"
package Module::Install::WriteAll;
use Module::Install::Base; @ISA = qw(Module::Install::Base);
Added: jifty/trunk/lib/Jifty/Action/Devel/FileEditor.pm
==============================================================================
--- (empty file)
+++ jifty/trunk/lib/Jifty/Action/Devel/FileEditor.pm Sun Jan 29 23:37:50 2006
@@ -0,0 +1,111 @@
+package Jifty::Action::Devel::FileEditor;
+
+use base qw/Jifty::Action/;
+use File::Spec;
+
+
+sub new {
+ my $class = shift; my $self = $class->SUPER::new(@_);
+ $self->get_default_content;
+ return($self);
+
+}
+
+
+sub arguments {
+ my $self = shift;
+
+ { path => { type => 'text', constructor => 1 },
+ file_type => {
+ default => 'mason_component',
+ render_as => 'Select',
+ valid_values => [qw/mason_component library/],
+ constructor => 1
+ },
+ source_path => { type => 'text', constructor => 1 },
+ destination_path => { type => 'text', ajax_validates=> 1, label => 'Save as' },
+ content => { render_as => 'Textarea', cols => 80, rows => 25 },
+
+ }
+
+}
+
+sub get_default_content {
+ my $self = shift;
+
+ # Don't override content we already have
+ return if ($self->argument_value('content'));
+ my $path = $self->argument_value('source_path');
+ my $type = $self->argument_value('file_type');
+ my $out = '';
+ my %cfg = Jifty->handler->mason_config;
+
+ my $local_template_base;
+ 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);
+ my $filehandle;
+ open ($filehandle, "<$qualified_path")||die "Couldn't read $qualified_path: $!";
+ $out = join('',<$filehandle>);
+ close($filehandle);
+ last; # We want the first match
+ }
+ }
+ $self->argument_value(content => $out);
+ $self->argument_value(destination_path => File::Spec->catfile($local_template_base, $path));
+}
+
+sub validate_destination_path {
+ my $self = shift;
+ my $value = shift;
+ $self->{'write_to'} = ($value or $self->argument_value('source_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 );
+ pop @dirs; # get the filename ripped off the directory
+ my $path ='';
+ foreach my $dir ( @dirs) {
+ $path = File::Spec->catdir($path, $dir);
+ if (-d $path) { next }
+ if (-w $path) { die "$path not writable"; }
+
+
+ mkdir($path) || die "Couldn't create directory $path: $!";
+ }
+
+}
+
+
+
+1;
Added: jifty/trunk/share/web/templates/__jifty/edit_file
==============================================================================
--- (empty file)
+++ jifty/trunk/share/web/templates/__jifty/edit_file Sun Jan 29 23:37:50 2006
@@ -0,0 +1,16 @@
+<%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')%>
+<%$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()%>
+</&>
More information about the Jifty-commit
mailing list