diff --git a/lib/Coocook/Controller/Browse/Recipe.pm b/lib/Coocook/Controller/Browse/Recipe.pm index da7552b9226d8ad2799b682564a154f27455fd0f..3c59a85d10c51cfee3388fba5dc52bf471fd25f0 100644 --- a/lib/Coocook/Controller/Browse/Recipe.pm +++ b/lib/Coocook/Controller/Browse/Recipe.pm @@ -123,8 +123,7 @@ sub import : GET HEAD Chained('base') PathPart('import') Args(0) my @projects = $projects->hri->all; for my $project (@projects) { - $project->{import_url} = - $c->uri_for_action( '/recipe/import/preview', + $project->{import_url} = $c->uri_for_action( '/project/recipe/import/preview', [ $project->{id}, $project->{url_name}, $recipe->id ] ); $project->{url} = $c->uri_for_action( '/project/show', [ $project->{id}, $project->{url_name} ] ); @@ -170,7 +169,7 @@ sub show : GET HEAD Chained('base') PathPart('') Args(0) RequiresCapability('vie prepared_ingredients => $ingredients{prepared}, not_prepared_ingredients => $ingredients{not_prepared}, project_url => $c->uri_for_action_if_permitted( - '/recipe/edit', + '/project/recipe/edit', { project => $project }, [ $project->id, $project->url_name, $recipe->id ] ), diff --git a/lib/Coocook/Controller/Project.pm b/lib/Coocook/Controller/Project.pm index acdf433378c926e2626db25543fb4e9cf66c36fe..bde5b889e1348dca629e938eebf8aa20df43eb18 100644 --- a/lib/Coocook/Controller/Project.pm +++ b/lib/Coocook/Controller/Project.pm @@ -82,15 +82,15 @@ sub base : Chained('/base') PathPart('project') CaptureArgs(2) { project_urls => { project => $c->project_uri('/project/show'), edit => $c->project_uri('/project/edit'), - recipes => $c->project_uri('/recipe/index'), - articles => $c->project_uri('/article/index'), - tags => $c->project_uri('/tag/index'), - unassigned_items => $c->project_uri('/item/unassigned'), - purchase_lists => $c->project_uri('/purchase_list/index'), - print => $c->project_uri('/print/index'), - shop_sections => $c->project_uri('/shop_section/index'), - units => $c->project_uri('/unit/index'), - quantities => $c->project_uri('/quantity/index'), + recipes => $c->project_uri('/project/recipe/index'), + articles => $c->project_uri('/project/article/index'), + tags => $c->project_uri('/project/tag/index'), + unassigned_items => $c->project_uri('/project/item/unassigned'), + purchase_lists => $c->project_uri('/project/purchase_list/index'), + print => $c->project_uri('/project/print/index'), + shop_sections => $c->project_uri('/project/shop_section/index'), + units => $c->project_uri('/project/unit/index'), + quantities => $c->project_uri('/project/quantity/index'), import => $c->project_uri('/project/get_import'), archive => $c->project_uri('/project/archive'), unarchive => $c->project_uri('/project/unarchive'), @@ -105,7 +105,7 @@ sub submenu : Chained('base') PathPart('') CaptureArgs(0) { submenu_items => [ { text => "Show project", action => 'project/show' }, { text => "Meals & Dishes", action => 'project/edit' }, - { text => "Permissions", action => 'permission/index' }, + { text => "Permissions", action => 'project/permission/index' }, { text => "Settings", action => 'project/settings' }, ], ); @@ -119,7 +119,7 @@ sub show : GET HEAD Chained('submenu') PathPart('') Args(0) RequiresCapability(' for my $day (@$days) { for my $meal ( @{ $day->{meals} } ) { for my $dish ( @{ $meal->{dishes} } ) { - $dish->{url} = $c->project_uri( '/dish/edit', $dish->{id} ); + $dish->{url} = $c->project_uri( '/project/dish/edit', $dish->{id} ); } } } @@ -147,18 +147,18 @@ sub edit : GET HEAD Chained('submenu') PathPart('edit') Args(0) RequiresCapabili my $dishes = $meal->{dishes}; for my $dish (@$dishes) { - $dish->{url} = $c->project_uri( '/dish/edit', $dish->{id} ); + $dish->{url} = $c->project_uri( '/project/dish/edit', $dish->{id} ); } $day->{dishes} += @$dishes; - $meal->{update_url} = $c->project_uri( '/meal/update', $meal->{id} ); + $meal->{update_url} = $c->project_uri( '/project/meal/update', $meal->{id} ); if ( $meal->{deletable} ) { - $meal->{delete_url} = $c->project_uri( '/meal/delete', $meal->{id} ); + $meal->{delete_url} = $c->project_uri( '/project/meal/delete', $meal->{id} ); } elsif ( @{ $meal->{dishes} } > 0 ) { - $meal->{delete_dishes_url} = $c->project_uri( '/meal/delete_dishes', $meal->{id} ); + $meal->{delete_dishes_url} = $c->project_uri( '/project/meal/delete_dishes', $meal->{id} ); } elsif ( @{ $meal->{prepared_dishes} } > 0 ) { $meal->{prepared_dishes_exist} = 1; @@ -171,9 +171,9 @@ sub edit : GET HEAD Chained('submenu') PathPart('edit') Args(0) RequiresCapabili default_date => $default_date, recipes => [ $c->project->recipes->sorted->all ], days => $days, - dish_create_url => $c->project_uri('/dish/create'), - dish_from_recipe_url => $c->project_uri('/dish/from_recipe'), - meal_create_url => $c->project_uri('/meal/create'), + dish_create_url => $c->project_uri('/project/dish/create'), + dish_from_recipe_url => $c->project_uri('/project/dish/from_recipe'), + meal_create_url => $c->project_uri('/project/meal/create'), ); } diff --git a/lib/Coocook/Controller/Article.pm b/lib/Coocook/Controller/Project/Article.pm similarity index 95% rename from lib/Coocook/Controller/Article.pm rename to lib/Coocook/Controller/Project/Article.pm index b98997c9473bd1f7ec89530f1820184c6b6027ad..70a4982ce2e3052f1e05b994c6a9357fcce5810b 100644 --- a/lib/Coocook/Controller/Article.pm +++ b/lib/Coocook/Controller/Project/Article.pm @@ -1,4 +1,4 @@ -package Coocook::Controller::Article; +package Coocook::Controller::Project::Article; use utf8; @@ -9,7 +9,7 @@ BEGIN { extends 'Coocook::Controller' } =head1 NAME -Coocook::Controller::Article - Catalyst Controller +Coocook::Controller::Project::Article - Catalyst Controller =head1 DESCRIPTION @@ -75,7 +75,7 @@ sub new_article : GET HEAD Chained('/project/base') PathPart('articles/new') $c->forward('fetch_project_data'); $c->stash( - template => 'article/edit.tt', + template => 'project/article/edit.tt', submit_url => $c->project_uri( $self->action_for('create') ), ); } @@ -187,7 +187,7 @@ sub dishes_recipes : Private { my %recipes = map { $_->{recipe}{id} => $_ } @recipes; # by recipe ID for my $r (@recipes) { - $r->{recipe}{url} = $c->project_uri( '/recipe/edit', $r->{recipe}{id} ); + $r->{recipe}{url} = $c->project_uri( '/project/recipe/edit', $r->{recipe}{id} ); } my @dishes; @@ -197,7 +197,7 @@ sub dishes_recipes : Private { my $meal = $dish->meal; $dish = $dish->as_hashref; - $dish->{url} = $c->project_uri( '/dish/edit', $dish->{id} ); + $dish->{url} = $c->project_uri( '/project/dish/edit', $dish->{id} ); $dish->{meal} = $meal; if ( defined $recipe and exists $recipes{$recipe} ) { @@ -224,7 +224,7 @@ sub update_or_insert : Private { if ( !defined $name or $name !~ m/\S/ ) { $c->messages->error("Name must not be empty"); - $c->redirect_detach( $c->project_uri( '/article/edit', $article->id ) ); + $c->redirect_detach( $c->project_uri( '/project/article/edit', $article->id ) ); } my @tags = $c->project->tags->from_names( $c->req->params->get('tags') )->only_id_col->all; diff --git a/lib/Coocook/Controller/Dish.pm b/lib/Coocook/Controller/Project/Dish.pm similarity index 92% rename from lib/Coocook/Controller/Dish.pm rename to lib/Coocook/Controller/Project/Dish.pm index 5b589739944e39eb90735ca0ee5157236607f14b..fa3aec5f75bd665580508843fd1b786133e3a9a8 100644 --- a/lib/Coocook/Controller/Dish.pm +++ b/lib/Coocook/Controller/Project/Dish.pm @@ -1,4 +1,4 @@ -package Coocook::Controller::Dish; +package Coocook::Controller::Project::Dish; use Moose; use MooseX::MarkAsMethods autoclean => 1; @@ -7,7 +7,7 @@ BEGIN { extends 'Coocook::Controller' } =head1 NAME -Coocook::Controller::Dish - Catalyst Controller +Coocook::Controller::Project::Dish - Catalyst Controller =head1 DESCRIPTION @@ -60,7 +60,7 @@ sub edit : GET HEAD Chained('base') PathPart('') Args(0) RequiresCapability('vie recipe => $dish->recipe ? { name => $dish->recipe->name, - url => $c->project_uri( '/recipe/edit', $dish->recipe->id ), + url => $c->project_uri( '/project/recipe/edit', $dish->recipe->id ), } : undef, @@ -74,12 +74,12 @@ sub edit : GET HEAD Chained('base') PathPart('') Args(0) RequiresCapability('vie articles => $ingredients->all_articles, units => $ingredients->all_units, prepare_meals => [ $prepare_meals->all ], - add_ingredient_url => $c->project_uri( '/dish/add', $dish->id ), - delete_url => $c->project_uri( '/dish/delete', $dish->id ), + add_ingredient_url => $c->project_uri( '/project/dish/add', $dish->id ), + delete_url => $c->project_uri( '/project/dish/delete', $dish->id ), ); for my $ingredient ( @{ $c->stash->{ingredients} } ) { - $ingredient->{reposition_url} = $c->project_uri( '/dish/reposition', $ingredient->{id} ); + $ingredient->{reposition_url} = $c->project_uri( '/project/dish/reposition', $ingredient->{id} ); } } @@ -108,7 +108,7 @@ sub create : POST Chained('/project/base') PathPart('dishes/create') Args(0) } ); - $c->response->redirect( $c->project_uri( '/dish/edit', $dish->id ) ); + $c->response->redirect( $c->project_uri( '/project/dish/edit', $dish->id ) ); } sub from_recipe : POST Chained('/project/base') PathPart('dishes/from_recipe') Args(0) @@ -127,7 +127,7 @@ sub from_recipe : POST Chained('/project/base') PathPart('dishes/from_recipe') A ) ); - $c->response->redirect( $c->project_uri( '/dish/edit', $dish->id ) ); + $c->response->redirect( $c->project_uri( '/project/dish/edit', $dish->id ) ); } sub recalculate : POST Chained('base') Args(0) RequiresCapability('edit_project') { diff --git a/lib/Coocook/Controller/Item.pm b/lib/Coocook/Controller/Project/Item.pm similarity index 88% rename from lib/Coocook/Controller/Item.pm rename to lib/Coocook/Controller/Project/Item.pm index 436943231ff340c1af4277fcce2d1b9f5d79e398..56769db34f52d05d4730e7d10867205fad699464 100644 --- a/lib/Coocook/Controller/Item.pm +++ b/lib/Coocook/Controller/Project/Item.pm @@ -1,4 +1,4 @@ -package Coocook::Controller::Item; +package Coocook::Controller::Project::Item; use DateTime; use Moose; @@ -8,7 +8,7 @@ BEGIN { extends 'Coocook::Controller' } =head1 NAME -Coocook::Controller::Items - Catalyst Controller +Coocook::Controller::Project::Items - Catalyst Controller =head1 DESCRIPTION @@ -18,8 +18,8 @@ Catalyst Controller. =cut -sub unassigned : GET HEAD Chained('/purchase_list/submenu') PathPart('items/unassigned') Args(0) - RequiresCapability('view_project') { +sub unassigned : GET HEAD Chained('/project/purchase_list/submenu') PathPart('items/unassigned') + Args(0) RequiresCapability('view_project') { my ( $self, $c ) = @_; my $project = $c->project; @@ -100,7 +100,7 @@ sub convert : POST Chained('/project/base') PathPart('items/convert') Args(1) $item->convert($unit); - $c->response->redirect( $c->project_uri( '/purchase_list/edit', $item->purchase_list_id ) ); + $c->response->redirect( $c->project_uri( '/project/purchase_list/edit', $item->purchase_list_id ) ); } sub update_offset : POST Chained('/project/base') PathPart('items/update_offset') Args(1) @@ -124,7 +124,7 @@ sub update_offset : POST Chained('/project/base') PathPart('items/update_offset' } else { die 'Code broken' } - $c->response->redirect( $c->project_uri( '/purchase_list/edit', $item->purchase_list_id ) ); + $c->response->redirect( $c->project_uri( '/project/purchase_list/edit', $item->purchase_list_id ) ); } __PACKAGE__->meta->make_immutable; diff --git a/lib/Coocook/Controller/Meal.pm b/lib/Coocook/Controller/Project/Meal.pm similarity index 94% rename from lib/Coocook/Controller/Meal.pm rename to lib/Coocook/Controller/Project/Meal.pm index ea37d8dcfba91f5ff98aa51d89198857a0baa842..0bf0d5a94134090c30c079631ae83d2dbff3ed5e 100644 --- a/lib/Coocook/Controller/Meal.pm +++ b/lib/Coocook/Controller/Project/Meal.pm @@ -1,4 +1,4 @@ -package Coocook::Controller::Meal; +package Coocook::Controller::Project::Meal; use Moose; use MooseX::MarkAsMethods autoclean => 1; @@ -7,7 +7,7 @@ BEGIN { extends 'Coocook::Controller' } =head1 NAME -Coocook::Controller::Meal - Catalyst Controller +Coocook::Controller::Project::Meal - Catalyst Controller =head1 DESCRIPTION diff --git a/lib/Coocook/Controller/Permission.pm b/lib/Coocook/Controller/Project/Permission.pm similarity index 99% rename from lib/Coocook/Controller/Permission.pm rename to lib/Coocook/Controller/Project/Permission.pm index 45fb319a3ed25375d4e2478b90cc7f0bc7b47061..570217f430f3308a84de636aa153ed5b3b5144dd 100644 --- a/lib/Coocook/Controller/Permission.pm +++ b/lib/Coocook/Controller/Project/Permission.pm @@ -1,4 +1,4 @@ -package Coocook::Controller::Permission; +package Coocook::Controller::Project::Permission; use Moose; use MooseX::MarkAsMethods autoclean => 1; diff --git a/lib/Coocook/Controller/Print.pm b/lib/Coocook/Controller/Project/Print.pm similarity index 71% rename from lib/Coocook/Controller/Print.pm rename to lib/Coocook/Controller/Project/Print.pm index 58495b5117f8297d97b0adca29836b9bb7cc186d..1d6ddd2993575c6f62a3a3e221bf5a8fe4faca26 100644 --- a/lib/Coocook/Controller/Print.pm +++ b/lib/Coocook/Controller/Project/Print.pm @@ -1,4 +1,4 @@ -package Coocook::Controller::Print; +package Coocook::Controller::Project::Print; use DateTime; use Moose; @@ -9,7 +9,7 @@ BEGIN { extends 'Coocook::Controller' } =head1 NAME -Coocook::Controller::Print - Catalyst Controller +Coocook::Controller::Project::Print - Catalyst Controller =head1 DESCRIPTION @@ -29,7 +29,7 @@ sub auto : Private { push @{ $c->stash->{css} }, '/css/print.css'; } -sub index : GET HEAD Chained('/purchase_list/submenu') PathPart('print') Args(0) +sub index : GET HEAD Chained('/project/purchase_list/submenu') PathPart('print') Args(0) RequiresCapability('view_project') { my ( $self, $c ) = @_; @@ -49,7 +49,7 @@ sub index : GET HEAD Chained('/purchase_list/submenu') PathPart('print') Args(0) push @days, { date => $date, - url => $c->project_uri( '/print/day', $date->year, $date->month, $date->day ), + url => $c->project_uri( '/project/print/day', $date->year, $date->month, $date->day ), }; } } @@ -63,7 +63,7 @@ sub index : GET HEAD Chained('/purchase_list/submenu') PathPart('print') Args(0) { date => $list->date, name => $list->name, - url => $c->project_uri( '/print/purchase_list', $list->id ), + url => $c->project_uri( '/project/print/purchase_list', $list->id ), }; } } @@ -74,11 +74,11 @@ sub index : GET HEAD Chained('/purchase_list/submenu') PathPart('print') Args(0) days => \@days, lists => \@lists, projects => \@projects, - project_url => $c->project_uri('/print/project'), + project_url => $c->project_uri('/project/print/project'), ); } -sub day : GET HEAD Chained('/purchase_list/submenu') PathPart('print/day') Args(3) +sub day : GET HEAD Chained('/project/purchase_list/submenu') PathPart('print/day') Args(3) RequiresCapability('view_project') { my ( $self, $c, $year, $month, $day ) = @_; @@ -92,20 +92,21 @@ sub day : GET HEAD Chained('/purchase_list/submenu') PathPart('print/day') Args( for my $meal (@$meals) { for my $dish ( @{ $meal->{dishes} } ) { - $dish->{url} = $c->project_uri( '/dish/edit', $dish->{id} ); + $dish->{url} = $c->project_uri( '/project/dish/edit', $dish->{id} ); if ( my $prep_meal = $dish->{prepare_at_meal} ) { $prep_meal->{url} = - $c->project_uri( '/print/day', map { $prep_meal->{date}->$_ } qw< year month day > ); + $c->project_uri( '/project/print/day', map { $prep_meal->{date}->$_ } qw< year month day > ); } } for my $dish ( @{ $meal->{prepared_dishes} } ) { - $dish->{url} ||= $c->project_uri( '/dish/edit', $dish->{id} ); + $dish->{url} ||= $c->project_uri( '/project/dish/edit', $dish->{id} ); my $meal = $dish->{meal}; - $meal->{url} ||= $c->project_uri( '/print/day', map { $meal->{date}->$_ } qw< year month day > ); + $meal->{url} ||= + $c->project_uri( '/project/print/day', map { $meal->{date}->$_ } qw< year month day > ); } } @@ -117,7 +118,7 @@ sub day : GET HEAD Chained('/purchase_list/submenu') PathPart('print/day') Args( ); } -sub project : GET HEAD Chained('/purchase_list/submenu') PathPart('print/project') Args(0) +sub project : GET HEAD Chained('/project/purchase_list/submenu') PathPart('print/project') Args(0) RequiresCapability('view_project') { my ( $self, $c, $id ) = @_; @@ -129,8 +130,8 @@ sub project : GET HEAD Chained('/purchase_list/submenu') PathPart('print/project ); } -sub purchase_list : GET HEAD Chained('/purchase_list/submenu') PathPart('print/purchase_list') - Args(1) RequiresCapability('view_project') { +sub purchase_list : GET HEAD Chained('/project/purchase_list/submenu') + PathPart('print/purchase_list') Args(1) RequiresCapability('view_project') { my ( $self, $c, $id ) = @_; my $list = $c->stash->{list} = $c->project->purchase_lists->find($id); diff --git a/lib/Coocook/Controller/PurchaseList.pm b/lib/Coocook/Controller/Project/PurchaseList.pm similarity index 84% rename from lib/Coocook/Controller/PurchaseList.pm rename to lib/Coocook/Controller/Project/PurchaseList.pm index 7366c8f9178dc42f89a3e65e26ad256b24839fcd..ed37875b0236ea5264cfbe4341da0c7ad1e77613 100644 --- a/lib/Coocook/Controller/PurchaseList.pm +++ b/lib/Coocook/Controller/Project/PurchaseList.pm @@ -1,4 +1,4 @@ -package Coocook::Controller::PurchaseList; +package Coocook::Controller::Project::PurchaseList; use DateTime; use Moose; @@ -6,11 +6,12 @@ use MooseX::MarkAsMethods autoclean => 1; BEGIN { extends 'Coocook::Controller' } -__PACKAGE__->config( namespace => 'purchase_list' ); +# Catalyst compiles PurchaseList into purchaselist +__PACKAGE__->config( namespace => 'project/purchase_list' ); =head1 NAME -Coocook::Controller::PurchaseList - Catalyst Controller +Coocook::Controller::Project::PurchaseList - Catalyst Controller =head1 DESCRIPTION @@ -25,10 +26,10 @@ sub submenu : Chained('/project/base') PathPart('') CaptureArgs(0) { $c->stash( submenu_items => [ - { text => "Purchase lists", action => 'purchase_list/index' }, - { text => "Unassigned items", action => 'item/unassigned' }, - { text => "Shop sections", action => 'shop_section/index' }, - { text => "Printing", action => 'print/index' }, + { text => "Purchase lists", action => 'project/purchase_list/index' }, + { text => "Unassigned items", action => 'project/item/unassigned' }, + { text => "Shop sections", action => 'project/shop_section/index' }, + { text => "Printing", action => 'project/print/index' }, ] ); } @@ -98,13 +99,13 @@ sub edit : GET HEAD Chained('base') PathPart('') Args(0) RequiresCapability('vie for my $sections ( @{ $c->stash->{sections} } ) { for my $item ( @{ $sections->{items} } ) { - $item->{convert_url} = $c->project_uri( '/item/convert', $item->{id} ); + $item->{convert_url} = $c->project_uri( '/project/item/convert', $item->{id} ); - $item->{update_offset_url} = $c->project_uri( '/item/update_offset', $item->{id} ); + $item->{update_offset_url} = $c->project_uri( '/project/item/update_offset', $item->{id} ); for my $ingredient ( @{ $item->{ingredients} } ) { $ingredient->{remove_url} = - $c->project_uri( '/purchase_list/remove_ingredient', $ingredient->{id} ); + $c->project_uri( '/project/purchase_list/remove_ingredient', $ingredient->{id} ); } } } diff --git a/lib/Coocook/Controller/Quantity.pm b/lib/Coocook/Controller/Project/Quantity.pm similarity index 93% rename from lib/Coocook/Controller/Quantity.pm rename to lib/Coocook/Controller/Project/Quantity.pm index fd541649a37bd2884f13a507c50e2bc06436ade1..c0ff8576be146ad164c3e318241767639e823f16 100644 --- a/lib/Coocook/Controller/Quantity.pm +++ b/lib/Coocook/Controller/Project/Quantity.pm @@ -1,4 +1,4 @@ -package Coocook::Controller::Quantity; +package Coocook::Controller::Project::Quantity; use Moose; use MooseX::MarkAsMethods autoclean => 1; @@ -7,7 +7,7 @@ BEGIN { extends 'Coocook::Controller' } =head1 NAME -Coocook::Controller::Quantity - Catalyst Controller +Coocook::Controller::Project::Quantity - Catalyst Controller =head1 DESCRIPTION @@ -21,7 +21,7 @@ Catalyst Controller. =cut -sub index : GET HEAD Chained('/unit/submenu') PathPart('quantities') Args(0) +sub index : GET HEAD Chained('/project/unit/submenu') PathPart('quantities') Args(0) RequiresCapability('view_project') { my ( $self, $c ) = @_; diff --git a/lib/Coocook/Controller/Recipe.pm b/lib/Coocook/Controller/Project/Recipe.pm similarity index 92% rename from lib/Coocook/Controller/Recipe.pm rename to lib/Coocook/Controller/Project/Recipe.pm index a4fb400c3220312177efebfe5c292704e239bf19..9fdc58114a60fd8c28d0d7a5e4c91db50aeb9422 100644 --- a/lib/Coocook/Controller/Recipe.pm +++ b/lib/Coocook/Controller/Project/Recipe.pm @@ -1,4 +1,4 @@ -package Coocook::Controller::Recipe; +package Coocook::Controller::Project::Recipe; use Moose; use MooseX::MarkAsMethods autoclean => 1; @@ -11,7 +11,7 @@ BEGIN { extends 'Coocook::Controller' } =head1 NAME -Coocook::Controller::Recipe - Catalyst Controller +Coocook::Controller::Project::Recipe - Catalyst Controller =head1 DESCRIPTION @@ -26,9 +26,9 @@ sub submenu : Chained('/project/base') PathPart('') CaptureArgs(0) { $c->stash( submenu_items => [ - { text => "All recipes", action => 'recipe/index' }, - { text => "Add recipe", action => 'recipe/new_recipe' }, - { text => "Import recipes", action => 'recipe/importable_recipes' }, + { text => "All recipes", action => 'project/recipe/index' }, + { text => "Add recipe", action => 'project/recipe/new_recipe' }, + { text => "Import recipes", action => 'project/recipe/importable_recipes' }, ] ); } @@ -84,7 +84,7 @@ sub edit : GET HEAD Chained('base') PathPart('') Args(0) RequiresCapability('vie name => $dish->name, meal => $dish->meal->name, date => $dish->meal->date, - url => $c->project_uri( '/dish/edit', $dish->id ), + url => $c->project_uri( '/project/dish/edit', $dish->id ), }; } } @@ -100,7 +100,7 @@ sub edit : GET HEAD Chained('base') PathPart('') Args(0) RequiresCapability('vie ); for my $ingredient ( @{ $c->stash->{ingredients} } ) { - $ingredient->{reposition_url} = $c->project_uri( '/recipe/reposition', $ingredient->{id} ); + $ingredient->{reposition_url} = $c->project_uri( '/project/recipe/reposition', $ingredient->{id} ); } $c->user @@ -114,7 +114,7 @@ sub new_recipe : GET HEAD Chained('submenu') PathPart('recipes/new') my ( $self, $c ) = @_; $c->stash( - template => 'recipe/new.tt', + template => 'project/recipe/new.tt', create_url => $c->project_uri( $self->action_for('create') ), ); } @@ -141,7 +141,7 @@ sub create : POST Chained('submenu') Args(0) RequiresCapability('edit_project') my ( $self, $c ) = @_; my $name = $c->req->params->get('name'); - my $input_okay = $self->check_name( $c, { name => $name, current_page => "/recipes" } ); + my $input_okay = $self->check_name( $c, { name => $name, current_page => "/project/recipes" } ); if ($input_okay) { my $recipe = $c->project->create_related( recipes => { @@ -177,7 +177,7 @@ sub update : POST Chained('base') Args(0) RequiresCapability('edit_project') { my $recipe = $c->stash->{recipe}; my $name = $c->req->params->get('name'); my $input_okay = - $self->check_name( $c, { name => $name, current_page => "/recipe/" . $recipe->id } ); + $self->check_name( $c, { name => $name, current_page => "/project/recipe/" . $recipe->id } ); if ($input_okay) { $recipe->txn_do( sub { @@ -271,7 +271,7 @@ sub importable_recipes : GET HEAD Chained('submenu') PathPart('recipes/import') $recipe->project->owner->{url} ||= $c->uri_for_action( '/user/show', [ $recipe->project->owner->name ] ); - $recipe->{import_url} = $c->project_uri( '/recipe/import/preview', $recipe->id ); + $recipe->{import_url} = $c->project_uri( '/project/recipe/import/preview', $recipe->id ); } $c->stash( recipes => \@recipes ); diff --git a/lib/Coocook/Controller/Recipe/Import.pm b/lib/Coocook/Controller/Project/Recipe/Import.pm similarity index 95% rename from lib/Coocook/Controller/Recipe/Import.pm rename to lib/Coocook/Controller/Project/Recipe/Import.pm index 35ae6569acf1f5c93c99e819a9fa14b601881bcb..9c7e9f31ca02c10fbf05eb8b8e88e4f4351cf842 100644 --- a/lib/Coocook/Controller/Recipe/Import.pm +++ b/lib/Coocook/Controller/Project/Recipe/Import.pm @@ -1,4 +1,4 @@ -package Coocook::Controller::Recipe::Import; +package Coocook::Controller::Project::Recipe::Import; use Moose; @@ -94,7 +94,7 @@ sub post : POST Chained('base') PathPart('') Args(0) RequiresCapability('import_ # when going back in browser history and sending the form again. if ( $c->project->recipes->results_exist( { name => $c->req->params->get('name') } ) ) { $c->messages->error("A recipe with that name does already exist"); - $c->stash( template => 'recipe/import/preview.tt' ); + $c->stash( template => 'project/recipe/import/preview.tt' ); $c->detach('preview'); } @@ -122,7 +122,7 @@ sub post : POST Chained('base') PathPart('') Args(0) RequiresCapability('import_ ingredients => \%ingredients, ); - $c->redirect_detach( $c->project_uri( '/recipe/edit', $new_recipe->id ) ); + $c->redirect_detach( $c->project_uri( '/project/recipe/edit', $new_recipe->id ) ); } 1; diff --git a/lib/Coocook/Controller/ShopSection.pm b/lib/Coocook/Controller/Project/ShopSection.pm similarity index 88% rename from lib/Coocook/Controller/ShopSection.pm rename to lib/Coocook/Controller/Project/ShopSection.pm index 561858ea559ce77fc1ec8917607689dce33a4822..364d1d5364a6523f649f872ad33ba73b8d4de02a 100644 --- a/lib/Coocook/Controller/ShopSection.pm +++ b/lib/Coocook/Controller/Project/ShopSection.pm @@ -1,15 +1,16 @@ -package Coocook::Controller::ShopSection; +package Coocook::Controller::Project::ShopSection; use Moose; use MooseX::MarkAsMethods autoclean => 1; BEGIN { extends 'Coocook::Controller' } -__PACKAGE__->config( namespace => 'shop_section' ); +# Catalyst compiles ShopSection into shopsection +__PACKAGE__->config( namespace => 'project/shop_section' ); =head1 NAME -Coocook::Controller::ShopSection - Catalyst Controller +Coocook::Controller::Project::ShopSection - Catalyst Controller =head1 DESCRIPTION @@ -23,7 +24,7 @@ Catalyst Controller. =cut -sub index : GET HEAD Chained('/purchase_list/submenu') PathPart('shop_sections') Args(0) +sub index : GET HEAD Chained('/project/purchase_list/submenu') PathPart('shop_sections') Args(0) RequiresCapability('view_project') { my ( $self, $c ) = @_; diff --git a/lib/Coocook/Controller/Tag.pm b/lib/Coocook/Controller/Project/Tag.pm similarity index 92% rename from lib/Coocook/Controller/Tag.pm rename to lib/Coocook/Controller/Project/Tag.pm index c34e6c5566ad82bcb12cdee5ac5b8c1ec75940e7..b8c4279b77b2f850f21b74f965bd66d6efcf9daa 100644 --- a/lib/Coocook/Controller/Tag.pm +++ b/lib/Coocook/Controller/Project/Tag.pm @@ -1,4 +1,4 @@ -package Coocook::Controller::Tag; +package Coocook::Controller::Project::Tag; use Moose; use MooseX::MarkAsMethods autoclean => 1; @@ -7,7 +7,7 @@ BEGIN { extends 'Coocook::Controller' } =head1 NAME -Coocook::Controller::Tag - Catalyst Controller +Coocook::Controller::Project::Tag - Catalyst Controller =head1 DESCRIPTION @@ -22,10 +22,10 @@ sub submenu : Chained('/project/base') PathPart('') CaptureArgs(0) { $c->stash( submenu_items => [ - { text => "All tags", action => 'tag/index' }, - { text => "Add tag", action => 'tag/new_tag' }, - { text => "All tag groups", action => 'tag/index_tag_group' }, - { text => "Add tag group", action => 'tag/new_tag_group' }, + { text => "All tags", action => 'project/tag/index' }, + { text => "Add tag", action => 'project/tag/new_tag' }, + { text => "All tag groups", action => 'project/tag/index_tag_group' }, + { text => "Add tag group", action => 'project/tag/new_tag_group' }, ], ); } @@ -116,9 +116,9 @@ sub edit : GET HEAD Chained('tag') PathPart('') Args(0) RequiresCapability('view $c->stash( groups => [ $c->project->tag_groups->sorted->all ] ); my %relationships = ( - articles => '/article/edit', - dishes => '/dish/edit', - recipes => '/recipe/edit', + articles => '/project/article/edit', + dishes => '/project/dish/edit', + recipes => '/project/recipe/edit', ); while ( my ( $rel => $path ) = each %relationships ) { diff --git a/lib/Coocook/Controller/Unit.pm b/lib/Coocook/Controller/Project/Unit.pm similarity index 93% rename from lib/Coocook/Controller/Unit.pm rename to lib/Coocook/Controller/Project/Unit.pm index b62f9e53661a818da797795cba77baf902553f02..93a189b38fa23fad99c437009ff73d6bf817a385 100644 --- a/lib/Coocook/Controller/Unit.pm +++ b/lib/Coocook/Controller/Project/Unit.pm @@ -1,4 +1,4 @@ -package Coocook::Controller::Unit; +package Coocook::Controller::Project::Unit; use utf8; @@ -10,7 +10,7 @@ BEGIN { extends 'Coocook::Controller' } =head1 NAME -Coocook::Controller::Unit - Catalyst Controller +Coocook::Controller::Project::Unit - Catalyst Controller =head1 DESCRIPTION @@ -25,9 +25,9 @@ sub submenu : Chained('/project/base') PathPart('') CaptureArgs(0) { $c->stash( submenu_items => [ - { text => "All units", action => 'unit/index' }, - { text => "Add unit", action => 'unit/new_unit' }, - { text => "Quantities", action => 'quantity/index' }, + { text => "All units", action => 'project/unit/index' }, + { text => "Add unit", action => 'project/unit/new_unit' }, + { text => "Quantities", action => 'project/quantity/index' }, ] ); } @@ -114,7 +114,7 @@ sub new_unit : GET HEAD Chained('submenu') PathPart('units/new') RequiresCapabil my ( $self, $c ) = @_; $c->stash( - template => 'unit/new.tt', + template => 'project/unit/new.tt', create_url => $c->project_uri( $self->action_for('create') ), quantities => [ $c->project->quantities->sorted->search( undef, { prefetch => 'default_unit' } )->all ], @@ -135,7 +135,7 @@ sub edit : GET HEAD Chained('base') PathPart('') Args(0) RequiresCapability('edi my @articles = $unit->articles->sorted->hri->all; for my $article (@articles) { - $article->{url} = $c->project_uri( '/article/edit', $article->{id} ); + $article->{url} = $c->project_uri( '/project/article/edit', $article->{id} ); } $c->stash( diff --git a/lib/Coocook/Helpers.pm b/lib/Coocook/Helpers.pm index 782c09ea9b032fc23a4cba7fa6da26d9cde6c89a..ae671a43529ef7c34509173efc64d528e8c764db 100644 --- a/lib/Coocook/Helpers.pm +++ b/lib/Coocook/Helpers.pm @@ -57,8 +57,10 @@ around uri_for => sub { return $uri if $uri; - local @Coocook::Helpers::CARP_NOT = 'Class::MOP::Method::Wrapped'; - croak 'Catalyst->uri_for() returned undef'; + local $Carp::Internal{'Catalyst'} = 1; + local $Carp::Internal{'Class::MOP::Method::Wrapped'} = 1; + + croak "Catalyst->uri_for() returned undef for path '$_[0]'"; }; =head2 uri_for_action_if_permitted( $action, \%input?, @args? ) @@ -190,7 +192,7 @@ sub messages { return shift->stash->{messages} } Return URI for project-specific Catalyst action with the current project's C and C plus any number of C<@arguments> and possibly C<\%query_params>. - my $uri = $c->project_uri( '/article/edit', $article->id, { key => 'value' } ); + my $uri = $c->project_uri( '/project/article/edit', $article->id, { key => 'value' } ); # http://localhost/project/MyProject/article/42?key=value my $uri = $c->project_uri( $self->action_for('edit'), $article->id, { key => 'value' } ); @@ -208,6 +210,8 @@ sub project_uri { # if last argument is hashref that's the \%query_values argument my @query = ref $_[-1] eq 'HASH' ? pop @_ : (); + local $Carp::Internal{ __PACKAGE__() } = 1; + return $c->uri_for_action( $action, [ $project->id, $project->url_name, @_ ], @query ); } diff --git a/root/templates/article/edit.tt b/root/templates/project/article/edit.tt similarity index 100% rename from root/templates/article/edit.tt rename to root/templates/project/article/edit.tt diff --git a/root/templates/article/index.tt b/root/templates/project/article/index.tt similarity index 100% rename from root/templates/article/index.tt rename to root/templates/project/article/index.tt diff --git a/root/templates/dish/edit.tt b/root/templates/project/dish/edit.tt similarity index 100% rename from root/templates/dish/edit.tt rename to root/templates/project/dish/edit.tt diff --git a/root/templates/item/unassigned.tt b/root/templates/project/item/unassigned.tt similarity index 100% rename from root/templates/item/unassigned.tt rename to root/templates/project/item/unassigned.tt diff --git a/root/templates/print/day.tt b/root/templates/project/print/day.tt similarity index 100% rename from root/templates/print/day.tt rename to root/templates/project/print/day.tt diff --git a/root/templates/print/index.tt b/root/templates/project/print/index.tt similarity index 100% rename from root/templates/print/index.tt rename to root/templates/project/print/index.tt diff --git a/root/templates/print/project.tt b/root/templates/project/print/project.tt similarity index 100% rename from root/templates/print/project.tt rename to root/templates/project/print/project.tt diff --git a/root/templates/print/purchase_list.tt b/root/templates/project/print/purchase_list.tt similarity index 100% rename from root/templates/print/purchase_list.tt rename to root/templates/project/print/purchase_list.tt diff --git a/root/templates/purchase_list/edit.tt b/root/templates/project/purchase_list/edit.tt similarity index 100% rename from root/templates/purchase_list/edit.tt rename to root/templates/project/purchase_list/edit.tt diff --git a/root/templates/purchase_list/index.tt b/root/templates/project/purchase_list/index.tt similarity index 100% rename from root/templates/purchase_list/index.tt rename to root/templates/project/purchase_list/index.tt diff --git a/root/templates/quantity/index.tt b/root/templates/project/quantity/index.tt similarity index 100% rename from root/templates/quantity/index.tt rename to root/templates/project/quantity/index.tt diff --git a/root/templates/recipe/edit.tt b/root/templates/project/recipe/edit.tt similarity index 100% rename from root/templates/recipe/edit.tt rename to root/templates/project/recipe/edit.tt diff --git a/root/templates/recipe/import/preview.tt b/root/templates/project/recipe/import/preview.tt similarity index 100% rename from root/templates/recipe/import/preview.tt rename to root/templates/project/recipe/import/preview.tt diff --git a/root/templates/recipe/importable_recipes.tt b/root/templates/project/recipe/importable_recipes.tt similarity index 100% rename from root/templates/recipe/importable_recipes.tt rename to root/templates/project/recipe/importable_recipes.tt diff --git a/root/templates/recipe/index.tt b/root/templates/project/recipe/index.tt similarity index 100% rename from root/templates/recipe/index.tt rename to root/templates/project/recipe/index.tt diff --git a/root/templates/recipe/new.tt b/root/templates/project/recipe/new.tt similarity index 100% rename from root/templates/recipe/new.tt rename to root/templates/project/recipe/new.tt diff --git a/root/templates/shop_section/index.tt b/root/templates/project/shop_section/index.tt similarity index 100% rename from root/templates/shop_section/index.tt rename to root/templates/project/shop_section/index.tt diff --git a/root/templates/project/show.tt b/root/templates/project/show.tt index 4f3a80b831b925a092a86a36d754a7bda5a43075..fac9b9c28fb9a5c83942ce1a3ae8d6029fa31c67 100644 --- a/root/templates/project/show.tt +++ b/root/templates/project/show.tt @@ -72,7 +72,7 @@ [% END %] -[% INCLUDE 'print/project.tt' %] +[% INCLUDE 'project/print/project.tt' %]

Created at [% project.created %]

diff --git a/root/templates/tag/edit.tt b/root/templates/project/tag/edit.tt similarity index 100% rename from root/templates/tag/edit.tt rename to root/templates/project/tag/edit.tt diff --git a/root/templates/tag/edit_group.tt b/root/templates/project/tag/edit_group.tt similarity index 100% rename from root/templates/tag/edit_group.tt rename to root/templates/project/tag/edit_group.tt diff --git a/root/templates/tag/index.tt b/root/templates/project/tag/index.tt similarity index 100% rename from root/templates/tag/index.tt rename to root/templates/project/tag/index.tt diff --git a/root/templates/tag/index_tag_group.tt b/root/templates/project/tag/index_tag_group.tt similarity index 100% rename from root/templates/tag/index_tag_group.tt rename to root/templates/project/tag/index_tag_group.tt diff --git a/root/templates/tag/new_tag.tt b/root/templates/project/tag/new_tag.tt similarity index 100% rename from root/templates/tag/new_tag.tt rename to root/templates/project/tag/new_tag.tt diff --git a/root/templates/tag/new_tag_group.tt b/root/templates/project/tag/new_tag_group.tt similarity index 100% rename from root/templates/tag/new_tag_group.tt rename to root/templates/project/tag/new_tag_group.tt diff --git a/root/templates/unit/edit.tt b/root/templates/project/unit/edit.tt similarity index 100% rename from root/templates/unit/edit.tt rename to root/templates/project/unit/edit.tt diff --git a/root/templates/unit/index.tt b/root/templates/project/unit/index.tt similarity index 100% rename from root/templates/unit/index.tt rename to root/templates/project/unit/index.tt diff --git a/root/templates/unit/new.tt b/root/templates/project/unit/new.tt similarity index 100% rename from root/templates/unit/new.tt rename to root/templates/project/unit/new.tt