offer reload instead of remove for changed files
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 18 Sep 2011 20:49:49 +0000 (22:49 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 18 Sep 2011 20:49:49 +0000 (22:49 +0200)
lib/MojoFacets/Data.pm
templates/data/index.html.ep

index d0ee485..eb36419 100644 (file)
@@ -1335,6 +1335,14 @@ sub __loaded_paths {
                keys %$loaded;
 }
 
+sub reload {
+       my $self = shift;
+       $self->stash( reload => 1 );
+       $self->remove;
+#      $self->_load_path( $self->param('path') );
+       $self->redirect_to('/data/load?path=' . $self->param('path') );
+}
+
 sub remove {
        my $self = shift;
        my $path = $self->param('path');
@@ -1348,6 +1356,7 @@ sub remove {
        } else {
                warn "WARNING: $path unlink ignored";
        }
+       return if $self->stash('reload');
        return $self->redirect_to( '/data/load' );
 }
 
index d118e83..473cc89 100644 (file)
@@ -19,7 +19,8 @@
 </td><td class=bytes><%= $size->{$n} %>
 </td><td class=bytes>
 % if ( my $size = -s $dump_path->{$n} ) {
-<a class="remove" title="remove" href="/data/remove?path=<%= $dump_path->{$n} %>;name=<%= $n %>"><%= $size %></a>
+%  my $action = -M $dump_path->{$n} > -M "data/$n" ? 'reload' : 'remove';
+<a class="<%= $action %>" title="<%= $action %>" href="/data/<%= $action %>?path=<%= $dump_path->{$n} %>;name=<%= $n %>"><%= $size %></a>
 % }
 </td><td align=right><%= defined $loaded->{$n}->{data} ? $#{ $loaded->{$n}->{data}->{items} } + 1 : '' %>
 </td><td align=right><%= defined $changes->{$n} ? $#{ $changes->{$n} } + 1 : '' %>