show changes
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 22 May 2010 12:46:57 +0000 (14:46 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 22 May 2010 12:46:57 +0000 (14:46 +0200)
lib/MojoFacets/Changes.pm
templates/changes/index.html.ep
templates/changes/view.html.ep [new file with mode: 0644]

index f754060..ad8ce60 100644 (file)
@@ -5,13 +5,15 @@ use warnings;
 
 use base 'Mojolicious::Controller';
 
+use Storable;
+
 sub index {
        my $self = shift;
 
        my $changes;
        foreach my $path ( glob '/tmp/changes/*' ) {
-               if ( $path =~ m{/(\d+\.\d+)\.(.+)$} ) {
-                       push @$changes, [ $1, split(/\./, $2) ];
+               if ( $path =~ m{/((\d+\.\d+)\.data\.(.+))$} ) {
+                       push @$changes, { uid => $1, t => $2, action => $3 };
                } else {
                        warn "ignore: $path\n";
                }
@@ -21,4 +23,11 @@ sub index {
        $self->render(message => 'Latest Changes', changes => $changes );
 }
 
+
+sub view {
+       my $self = shift;
+       my $uid = $self->param('uid');
+       $self->render( change => retrieve( "/tmp/changes/$uid" ) );
+}
+
 1;
index 4e037df..d55f2c8 100644 (file)
@@ -4,8 +4,7 @@
 <ul>
 % foreach my $change ( @$changes ) {
 <li>
-<a href="<%= url_for( controller => $change->[1], action => $change->[2] ) %>">
-<%= $change->[0] %> <%= $change->[2] %>
-</a>
+<%= $change->{t} %>
+<a href="<%= url_for( controller => 'changes', action => 'view' )->query( uid => $change->{uid} ) %>"><%= $change->{action} %></a>
 % }
 </ul>
diff --git a/templates/changes/view.html.ep b/templates/changes/view.html.ep
new file mode 100644 (file)
index 0000000..8076e6d
--- /dev/null
@@ -0,0 +1,2 @@
+%# layout 'default';
+<pre class=debug><%= dumper $change %></pre>