From 88f36e93420390b7e3d42a3fdba2fd05abf720c4 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sun, 23 May 2010 19:59:03 +0200 Subject: [PATCH] implement changes filter --- lib/MojoFacets/Changes.pm | 15 +++++++++++---- public/mojo_facets.css | 4 ++++ templates/changes/index.html.ep | 14 ++++++++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/lib/MojoFacets/Changes.pm b/lib/MojoFacets/Changes.pm index 752b709..9c07764 100644 --- a/lib/MojoFacets/Changes.pm +++ b/lib/MojoFacets/Changes.pm @@ -10,20 +10,27 @@ use Storable; sub index { my $self = shift; - my $max = $self->param('max') || 10; + my $max = $self->param('max') || 50; + my $action_regex = join('|', $self->param('action_filter')); + warn "# action_regex $action_regex\n"; + + my $actions; my $changes; foreach my $path ( sort { $b cmp $a } glob '/tmp/changes/*' ) { if ( $path =~ m{/((\d+\.\d+)\.data\.(.+))$} ) { - push @$changes, { uid => $1, t => $2, action => $3 }; - last if $#$changes >= $max; + my ( $uid, $t, $action ) = ( $1, $2, $3 ); + $actions->{$action}++; + next if $action_regex && $action !~ m/^($action_regex)$/; + push @$changes, { uid => $uid, t => $t, action => $action } + if $#$changes < $max; } else { warn "ignore: $path\n"; } } # Render template "changes/index.html.ep" with message - $self->render(message => 'Latest Changes', changes => $changes ); + $self->render(message => 'Latest Changes', changes => $changes, actions => $actions ); } diff --git a/public/mojo_facets.css b/public/mojo_facets.css index 6a1a959..ab09c72 100644 --- a/public/mojo_facets.css +++ b/public/mojo_facets.css @@ -140,3 +140,7 @@ span.d { .saved { background: #ffe; } + +form.action_filter { + float: right; +} diff --git a/templates/changes/index.html.ep b/templates/changes/index.html.ep index 464d0d4..1550bbf 100644 --- a/templates/changes/index.html.ep +++ b/templates/changes/index.html.ep @@ -1,6 +1,19 @@ % layout 'default';

<%= $message %>

+
+ + + +
+