$self->render( change => retrieve( "/tmp/actions/$uid" ), uid => $uid );
}
-sub _edit_path {
+sub _changes_path {
my $self = shift;
my $path = $self->param('path') || $self->session('path');
- $self->app->home->rel_dir('data') . '/' . $path . '.edits';
+ $self->app->home->rel_dir('data') . '/' . $path . '.changes';
}
-sub edits {
+sub changes {
my ( $self ) = @_;
my $path = $self->param('path') || $self->session('path');
my $commit = $self->param('commit');
die "no $apply_on_path" unless $items;
warn "using $items for $apply_on_path\n";
}
- my $edits;
+ my $changes;
my $stats;
- my $glob = $self->_edit_path . '/*';
+ my $glob = $self->_changes_path . '/*';
foreach my $t ( sort { $a cmp $b } glob $glob ) {
my $e = retrieve($t);
if ( $items ) {
$e->{_status} = $status;
$stats->{$status}++;
}
- push @$edits, $e;
+ push @$changes, $e;
}
my @loaded = MojoFacets::Data::__loaded_paths();
warn "# loaded paths ",dump @loaded;
- $self->render( edits => $edits, loaded => \@loaded, stats => $stats );
+ $self->render( changes => $changes, loaded => \@loaded, stats => $stats );
}
-sub edit {
+sub remove {
my $self = shift;
- if ( my $t = $self->param('remove') ) {
- unlink $self->_edit_path . '/' . $t;
+ if ( my $t = $self->param('time') ) {
+ unlink $self->_changes_path . '/' . $t;
}
- $self->redirect_to('/actions/edits');
+ $self->redirect_to('/actions/changes');
}
1;
die "no data dir $data_dir" unless -d $data_dir;
my @files;
- my $edits;
+ my $changes;
find( sub {
my $file = $File::Find::name;
if ( -f $file && $file =~ m/\.(js(on)?|txt)$/ ) {
$file =~ s/$data_dir\/*//;
push @files, $file;
- } elsif ( -f $file && $file =~ m/([^\/]+)\.edits\/(\d+\.\d+.+)/ ) {
- push @{ $edits->{$1} }, $2
+ } elsif ( -f $file && $file =~ m/([^\/]+)\.changes\/(\d+\.\d+.+)/ ) {
+ push @{ $changes->{$1} }, $2
} elsif ( -d $file && $file =~ m/\.html$/ ) {
$file =~ s/$data_dir\/*//;
push @files, $file;
loaded => $loaded,
filters => $filters,
dump_path => { map { $_ => $self->_dump_path($_) } @files },
- edits => $edits,
+ changes => $changes,
);
}
if ( $old ne $new
&& ! ( $old eq 'undef' && length($new_content) == 0 ) # new value empty, previous undef
) {
- my $edit = {
+ my $change = {
path => $path,
column => $name,
pos => $i,
keys %{ $loaded->{$path}->{stats} }
},
};
- my $edit_path = $self->_permanent_path( 'edits' );
- mkdir $edit_path unless -d $edit_path;
- $edit_path .= '/' . $edit->{time};
- store $edit, $edit_path;
- utime $edit->{time}, $edit->{time}, $edit_path;
- warn "# $edit_path ", dump($edit);
-
- warn "# edit $path $i $old -> $new\n";
+ my $change_path = $self->_permanent_path( 'changes' );
+ mkdir $change_path unless -d $change_path;
+ $change_path .= '/' . $change->{time};
+ store $change, $change_path;
+ utime $change->{time}, $change->{time}, $change_path;
+ warn "# $change_path ", dump($change);
+
+ warn "# change $path $i $old -> $new\n";
$loaded->{$path}->{data}->{items}->[$i]->{$name} = $v;
if ( defined $loaded->{$path}->{sorted}->{$name} ) {
--- /dev/null
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+use Storable;
+use Mojo::Client;
+use Data::Dump qw(dump);
+
+my $url = 'http://localhost:3000/data/edit';
+my $max = 1;
+
+my @changes = @ARGV;
+
+my $t = Mojo::Client->new;
+$t->max_redirects( 1 );
+
+foreach my $c ( @changes ) {
+
+ print "# $c\n";
+
+ my $params = retrieve $c;
+ my $hash = $params->to_hash;
+ $hash->{time} = $1 if $c =~ m{/(\d+\.\d+)\.data\.edit};
+
+ warn "# hash ",dump($hash);
+
+ my $tx = $t->post_form( $url => $hash );
+ if ( my $res = $tx->success) { print $res->body }
+ else {
+ my ($code, $message) = $tx->error;
+ die "Error: $message";
+ }
+
+# last if $max-- == 0;
+}
+++ /dev/null
-#!/usr/bin/env perl
-
-use strict;
-use warnings;
-
-use Storable;
-use Mojo::Client;
-use Data::Dump qw(dump);
-
-my $url = 'http://localhost:3000/data/edit';
-my $max = 1;
-
-my @changes = @ARGV;
-
-my $t = Mojo::Client->new;
-$t->max_redirects( 1 );
-
-foreach my $c ( @changes ) {
-
- print "# $c\n";
-
- my $params = retrieve $c;
- my $hash = $params->to_hash;
- $hash->{time} = $1 if $c =~ m{/(\d+\.\d+)\.data\.edit};
-
- warn "# hash ",dump($hash);
-
- my $tx = $t->post_form( $url => $hash );
- if ( my $res = $tx->success) { print $res->body }
- else {
- my ($code, $message) = $tx->error;
- die "Error: $message";
- }
-
-# last if $max-- == 0;
-}
--- /dev/null
+% layout 'ui';
+
+
+% my $dump = param('dump');
+% my $apply_on_path = param('apply_on_path');
+
+<form method=post>
+<input type=submit value="Apply"> on
+<select name=apply_on_path>
+% foreach my $p ( @$loaded ) {
+<option<%= $p eq $apply_on_path ? ' selected' : '' %>><%= $p %></option>
+% }
+</select>
+<label><input type=checkbox name=dump <%= $dump ? 'checked' : '' %>>dump</label>
+
+% if ( $apply_on_path ) {
+<ul id=status>
+% foreach my $status ( keys %$stats ) {
+<li><label>
+<input name=show type=checkbox value="<%= $status %>" checked>
+<%= $status %>
+<span class=count><%= $stats->{$status} %></span>
+</label>
+% }
+</ul>
+
+<input type=submit name=commit value="Commit changes">
+
+% }
+
+</form>
+
+<table>
+<tr><th></th><th>old</th><th>new</th></tr>
+
+% foreach my $e ( @$changes ) {
+<tr class="change <%= $e->{_status} || 'unknown' %>">
+<td>
+<%= $e->{time} %>
+<tt><%= $e->{column} %></tt>
+% if ( my $status = $e->{_status} ) {
+% my ( $pk, $id ) = %{ $e->{unique} };
+<a href="<%= url_for( controller => 'data', action => 'filter' )->query( filter_name => $pk, filter_vals => $id ) %>"><%= $id %></a>
+<%= $status %>
+% } else {
+<a href="<%= url_for( action => 'remove' )->query( time => $e->{time} ) %>">remove</a>
+% }
+
+</td><td><%== defined $e->{old} && join('<span class=d>¶</span>', @{$e->{old}}) %>
+</td><td><%== defined $e->{new} && join('<span class=d>¶</span>', @{$e->{new}}) %>
+
+% if ( $dump ) {
+</td><td><pre class=debug><%= dumper $e %></pre>
+% }
+</tr>
+% }
+
+</table>
+
+<pre class=debug>
+<%= dumper( $stats ) %>
+</pre>
+
+<script type="text/javascript">
+
+$(document).ready( function(){
+ console.debug('ready');
+ $('ul#status > li input[type=checkbox]').click( function(){
+ var toggle = this.value;
+ console.debug('click',this,toggle);
+ $('tr.'+toggle).toggleClass('hidden');
+ });
+});
+
+</script>
+++ /dev/null
-% layout 'ui';
-
-
-% my $dump = param('dump');
-% my $apply_on_path = param('apply_on_path');
-
-<form method=post>
-<input type=submit value="Apply"> on
-<select name=apply_on_path>
-% foreach my $p ( @$loaded ) {
-<option<%= $p eq $apply_on_path ? ' selected' : '' %>><%= $p %></option>
-% }
-</select>
-<label><input type=checkbox name=dump <%= $dump ? 'checked' : '' %>>dump</label>
-
-% if ( $apply_on_path ) {
-<ul id=status>
-% foreach my $status ( keys %$stats ) {
-<li><label>
-<input name=show type=checkbox value="<%= $status %>" checked>
-<%= $status %>
-<span class=count><%= $stats->{$status} %></span>
-</label>
-% }
-</ul>
-
-<input type=submit name=commit value="Commit changes">
-
-% }
-
-</form>
-
-<table>
-<tr><th></th><th>old</th><th>new</th></tr>
-
-% foreach my $e ( @$edits ) {
-<tr class="edit <%= $e->{_status} || 'unknown' %>">
-<td>
-<%= $e->{time} %>
-<tt><%= $e->{column} %></tt>
-% if ( my $status = $e->{_status} ) {
-% my ( $pk, $id ) = %{ $e->{unique} };
-<a href="<%= url_for( controller => 'data', action => 'filter' )->query( filter_name => $pk, filter_vals => $id ) %>"><%= $id %></a>
-<%= $status %>
-% } else {
-<a href="<%= url_for( action => 'edit' )->query( remove => $e->{time} ) %>">remove</a>
-% }
-
-</td><td><%== defined $e->{old} && join('<span class=d>¶</span>', @{$e->{old}}) %>
-</td><td><%== defined $e->{new} && join('<span class=d>¶</span>', @{$e->{new}}) %>
-
-% if ( $dump ) {
-</td><td><pre class=debug><%= dumper $e %></pre>
-% }
-</tr>
-% }
-
-</table>
-
-<pre class=debug>
-<%= dumper( $stats ) %>
-</pre>
-
-<script type="text/javascript">
-
-$(document).ready( function(){
- console.debug('ready');
- $('ul#status > li input[type=checkbox]').click( function(){
- var toggle = this.value;
- console.debug('click',this,toggle);
- $('tr.'+toggle).toggleClass('hidden');
- });
-});
-
-</script>
% if ( $self->can('_export_path') && glob $self->_export_path('*') ) {
<a href="<%= url_for( controller => 'data', action => 'export' ) %>">export</a>
% }
-<a href="<%= url_for( controller => 'actions', action => 'edits' ) %>">edits</a>
+<a href="<%= url_for( controller => 'actions', action => 'changes' ) %>">changes</a>
<a href="<%= url_for( controller => 'actions', action => 'index' ) %>">actions</a>
</span>
<input type=submit value="Load">
<table>
-<tr><th rowspan=2>name</th><th colspan=2>size</th><th rowspan=2>items</th><th rowspan=2>edits</th><th rowspan=2 title="loaded in memory">m</th><th colspan=2>columns</th></tr>
+<tr><th rowspan=2>name</th><th colspan=2>size</th><th rowspan=2>items</th><th rowspan=2>changes</th><th rowspan=2 title="loaded in memory">m</th><th colspan=2>columns</th></tr>
<tr><th>disk</th><th>storable</th></tr>
% foreach my $n ( @$files ) {
<tr><td>
</td><td class=bytes><%= $size->{$n} %>
</td><td class=bytes><%= -s $dump_path->{$n} %>
</td><td align=right><%= defined $loaded->{$n}->{data} ? $#{ $loaded->{$n}->{data}->{items} } + 1 : '' %>
-</td><td align=right><%= defined $edits->{$n} ? $#{ $edits->{$n} } + 1 : '' %>
+</td><td align=right><%= defined $changes->{$n} ? $#{ $changes->{$n} } + 1 : '' %>
</td><td><input name=paths type=checkbox value="<%= $n %>" <%= defined $loaded->{$n}->{stats} ? 'checked' : '' %>>
</td><td>
% if ( defined $loaded->{$n}->{columns} ) {
</form>
-<pre class=debug><%= dumper $edits %></pre>
+<pre class=debug><%= dumper $changes %></pre>
<pre class=debug><%= dumper $loaded %></pre>
<pre class=debug><%= dumper $filters %></pre>
<pre class=debug><%= dumper $dump_path %></pre>