From 136f45adf13ec642fbb42de4eead8fe4f0a46b17 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Wed, 16 Jun 2010 21:38:41 +0200 Subject: [PATCH] use /data/items/:show This allows nicer REST API and at the same time, skips recording of action because I re-used :id as show, so request doesn't have parameters and isn't recorderd in actions to reduce clutter --- lib/MojoFacets.pm | 2 +- lib/MojoFacets/Data.pm | 5 +++++ templates/admin.html.ep | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/MojoFacets.pm b/lib/MojoFacets.pm index 9a5b315..fb45ed5 100644 --- a/lib/MojoFacets.pm +++ b/lib/MojoFacets.pm @@ -47,7 +47,7 @@ sub startup { my $r = $self->routes; # Default route - $r->route('/:controller/:action/:id')->to('data#index', id => 1); + $r->route('/:controller/:action/:id')->to('data#index', id => 0); # $self->plugin( 'request_timer' ); diff --git a/lib/MojoFacets/Data.pm b/lib/MojoFacets/Data.pm index 30429bc..373e9a1 100644 --- a/lib/MojoFacets/Data.pm +++ b/lib/MojoFacets/Data.pm @@ -531,6 +531,11 @@ sub _data_sorted_by { sub items { my $self = shift; + if ( my $show = $self->param('id') ) { + $self->param('show', $show); + warn "show $show\n"; + } + my $path = $self->session('path'); $self->redirect_to('/data/index') unless defined $loaded->{ $path }; diff --git a/templates/admin.html.ep b/templates/admin.html.ep index 8190794..e9b953c 100644 --- a/templates/admin.html.ep +++ b/templates/admin.html.ep @@ -7,7 +7,7 @@ items: % foreach my $show ( glob 'templates/data/items/*.html.ep' ) { % $show =~ s{^.+/([^/]+)\.html\.ep$}{$1}; % my $class = session('show') eq $show ? 'class=active' : ''; -><%= $show %> +><%= $show %> % } % if ( $self->can('_export_path') && glob $self->_export_path('*') ) { -- 2.20.1