utime $mtime, $mtime, $dump_path;
warn $dump_path, ' ', -s $dump_path, " bytes\n";
+ return $dump_path;
}
sub _load_path {
}
$status = 201; # created
+ $self->session('save_path' => $path);
} else {
warn "# unchanged $path $i $old\n";
);
}
+
+sub save {
+ my $self = shift;
+ my $path = $self->param('path');
+ $path ||= $self->session('path');
+
+ my $dump_path = $self->_save( $path );
+ $self->session('save_path' => 0);
+
+ $self->redirect_to( '/data/items' );
+}
+
1;
path: document.title, _row_id: _row_id,
name: name, content: content
} , function(data, textStatus) {
- if ( data.length == 0 ) data = content; // 304 doesn't return content
console.debug( 'data:', data, 'status:', textStatus );
+ if ( ! data ) {
+ data = content; // fallback to submited data for 304
+ } else {
+ $('a.changes').before('<a class=save_changes href="/data/save">save</a>')
+ }
var vals = data.split('¶');
data = vals.join('<span class=d>¶</span>');
update.replaceWith( data );
float: right;
}
+.admin .save_changes {
+ float: right;
+ color: #f00;
+ padding-left: 1em;
+}
+
.debug {
color: #aaa;
}
<a href="<%= url_for( controller => 'data', action => 'items' )->query( show => $show ) %>" <%= $class %>><%= $show %></a>
% }
+% if ( my $path = session('save_path') ) {
+<a class=save_changes title="<%= $path %>" href="<%= url_for( controller => 'data', action => 'save', path => $path ) %>">save</a>
+% }
<a class=changes href="<%= url_for( controller => 'changes', action => 'index' ) %>">changes</a>
</div>