From 7afce3562e838213b17d8d928b8232f0113f62c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20B=C3=B6hmer?= Date: Thu, 31 Dec 2020 08:54:45 +0100 Subject: [PATCH 1/9] Rename files --- lib/Coocook/Controller/{ => Project}/Article.pm | 0 lib/Coocook/Controller/{ => Project}/Dish.pm | 0 lib/Coocook/Controller/{ => Project}/Item.pm | 0 lib/Coocook/Controller/{ => Project}/Meal.pm | 0 lib/Coocook/Controller/{ => Project}/Permission.pm | 0 lib/Coocook/Controller/{ => Project}/Print.pm | 0 lib/Coocook/Controller/{ => Project}/PurchaseList.pm | 0 lib/Coocook/Controller/{ => Project}/Quantity.pm | 0 lib/Coocook/Controller/{ => Project}/Recipe.pm | 0 lib/Coocook/Controller/{ => Project}/Recipe/Import.pm | 0 lib/Coocook/Controller/{ => Project}/ShopSection.pm | 0 lib/Coocook/Controller/{ => Project}/Tag.pm | 0 lib/Coocook/Controller/{ => Project}/Unit.pm | 0 13 files changed, 0 insertions(+), 0 deletions(-) rename lib/Coocook/Controller/{ => Project}/Article.pm (100%) rename lib/Coocook/Controller/{ => Project}/Dish.pm (100%) rename lib/Coocook/Controller/{ => Project}/Item.pm (100%) rename lib/Coocook/Controller/{ => Project}/Meal.pm (100%) rename lib/Coocook/Controller/{ => Project}/Permission.pm (100%) rename lib/Coocook/Controller/{ => Project}/Print.pm (100%) rename lib/Coocook/Controller/{ => Project}/PurchaseList.pm (100%) rename lib/Coocook/Controller/{ => Project}/Quantity.pm (100%) rename lib/Coocook/Controller/{ => Project}/Recipe.pm (100%) rename lib/Coocook/Controller/{ => Project}/Recipe/Import.pm (100%) rename lib/Coocook/Controller/{ => Project}/ShopSection.pm (100%) rename lib/Coocook/Controller/{ => Project}/Tag.pm (100%) rename lib/Coocook/Controller/{ => Project}/Unit.pm (100%) diff --git a/lib/Coocook/Controller/Article.pm b/lib/Coocook/Controller/Project/Article.pm similarity index 100% rename from lib/Coocook/Controller/Article.pm rename to lib/Coocook/Controller/Project/Article.pm diff --git a/lib/Coocook/Controller/Dish.pm b/lib/Coocook/Controller/Project/Dish.pm similarity index 100% rename from lib/Coocook/Controller/Dish.pm rename to lib/Coocook/Controller/Project/Dish.pm diff --git a/lib/Coocook/Controller/Item.pm b/lib/Coocook/Controller/Project/Item.pm similarity index 100% rename from lib/Coocook/Controller/Item.pm rename to lib/Coocook/Controller/Project/Item.pm diff --git a/lib/Coocook/Controller/Meal.pm b/lib/Coocook/Controller/Project/Meal.pm similarity index 100% rename from lib/Coocook/Controller/Meal.pm rename to lib/Coocook/Controller/Project/Meal.pm diff --git a/lib/Coocook/Controller/Permission.pm b/lib/Coocook/Controller/Project/Permission.pm similarity index 100% rename from lib/Coocook/Controller/Permission.pm rename to lib/Coocook/Controller/Project/Permission.pm diff --git a/lib/Coocook/Controller/Print.pm b/lib/Coocook/Controller/Project/Print.pm similarity index 100% rename from lib/Coocook/Controller/Print.pm rename to lib/Coocook/Controller/Project/Print.pm diff --git a/lib/Coocook/Controller/PurchaseList.pm b/lib/Coocook/Controller/Project/PurchaseList.pm similarity index 100% rename from lib/Coocook/Controller/PurchaseList.pm rename to lib/Coocook/Controller/Project/PurchaseList.pm diff --git a/lib/Coocook/Controller/Quantity.pm b/lib/Coocook/Controller/Project/Quantity.pm similarity index 100% rename from lib/Coocook/Controller/Quantity.pm rename to lib/Coocook/Controller/Project/Quantity.pm diff --git a/lib/Coocook/Controller/Recipe.pm b/lib/Coocook/Controller/Project/Recipe.pm similarity index 100% rename from lib/Coocook/Controller/Recipe.pm rename to lib/Coocook/Controller/Project/Recipe.pm diff --git a/lib/Coocook/Controller/Recipe/Import.pm b/lib/Coocook/Controller/Project/Recipe/Import.pm similarity index 100% rename from lib/Coocook/Controller/Recipe/Import.pm rename to lib/Coocook/Controller/Project/Recipe/Import.pm diff --git a/lib/Coocook/Controller/ShopSection.pm b/lib/Coocook/Controller/Project/ShopSection.pm similarity index 100% rename from lib/Coocook/Controller/ShopSection.pm rename to lib/Coocook/Controller/Project/ShopSection.pm diff --git a/lib/Coocook/Controller/Tag.pm b/lib/Coocook/Controller/Project/Tag.pm similarity index 100% rename from lib/Coocook/Controller/Tag.pm rename to lib/Coocook/Controller/Project/Tag.pm diff --git a/lib/Coocook/Controller/Unit.pm b/lib/Coocook/Controller/Project/Unit.pm similarity index 100% rename from lib/Coocook/Controller/Unit.pm rename to lib/Coocook/Controller/Project/Unit.pm -- GitLab From 1c6bba05f93e473066e7fa4750f2070c457754e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20B=C3=B6hmer?= Date: Thu, 31 Dec 2020 09:04:41 +0100 Subject: [PATCH 2/9] Change package names for c in Article Dish Item Meal Permission Print PurchaseList Quantity Recipe ShopSection Tag Unit do echo "s/Controller::$c/Controller::Project::$c/;" done \ | sed -f- -i $( git ls-files lib/ t/ ) --- lib/Coocook/Controller/Project/Article.pm | 4 ++-- lib/Coocook/Controller/Project/Dish.pm | 4 ++-- lib/Coocook/Controller/Project/Item.pm | 4 ++-- lib/Coocook/Controller/Project/Meal.pm | 4 ++-- lib/Coocook/Controller/Project/Permission.pm | 2 +- lib/Coocook/Controller/Project/Print.pm | 4 ++-- lib/Coocook/Controller/Project/PurchaseList.pm | 4 ++-- lib/Coocook/Controller/Project/Quantity.pm | 4 ++-- lib/Coocook/Controller/Project/Recipe.pm | 4 ++-- lib/Coocook/Controller/Project/Recipe/Import.pm | 2 +- lib/Coocook/Controller/Project/ShopSection.pm | 4 ++-- lib/Coocook/Controller/Project/Tag.pm | 4 ++-- lib/Coocook/Controller/Project/Unit.pm | 4 ++-- 13 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/Coocook/Controller/Project/Article.pm b/lib/Coocook/Controller/Project/Article.pm index b98997c9..9b32587d 100644 --- a/lib/Coocook/Controller/Project/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 diff --git a/lib/Coocook/Controller/Project/Dish.pm b/lib/Coocook/Controller/Project/Dish.pm index 5b589739..6879635b 100644 --- a/lib/Coocook/Controller/Project/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 diff --git a/lib/Coocook/Controller/Project/Item.pm b/lib/Coocook/Controller/Project/Item.pm index 43694323..6859401b 100644 --- a/lib/Coocook/Controller/Project/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 diff --git a/lib/Coocook/Controller/Project/Meal.pm b/lib/Coocook/Controller/Project/Meal.pm index ea37d8dc..0bf0d5a9 100644 --- a/lib/Coocook/Controller/Project/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/Project/Permission.pm b/lib/Coocook/Controller/Project/Permission.pm index 45fb319a..570217f4 100644 --- a/lib/Coocook/Controller/Project/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/Project/Print.pm b/lib/Coocook/Controller/Project/Print.pm index 58495b51..2c9595c5 100644 --- a/lib/Coocook/Controller/Project/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 diff --git a/lib/Coocook/Controller/Project/PurchaseList.pm b/lib/Coocook/Controller/Project/PurchaseList.pm index 7366c8f9..db4afd15 100644 --- a/lib/Coocook/Controller/Project/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; @@ -10,7 +10,7 @@ __PACKAGE__->config( namespace => 'purchase_list' ); =head1 NAME -Coocook::Controller::PurchaseList - Catalyst Controller +Coocook::Controller::Project::PurchaseList - Catalyst Controller =head1 DESCRIPTION diff --git a/lib/Coocook/Controller/Project/Quantity.pm b/lib/Coocook/Controller/Project/Quantity.pm index fd541649..95e2ce8f 100644 --- a/lib/Coocook/Controller/Project/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 diff --git a/lib/Coocook/Controller/Project/Recipe.pm b/lib/Coocook/Controller/Project/Recipe.pm index a4fb400c..0e320e3d 100644 --- a/lib/Coocook/Controller/Project/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 diff --git a/lib/Coocook/Controller/Project/Recipe/Import.pm b/lib/Coocook/Controller/Project/Recipe/Import.pm index 35ae6569..3b86a176 100644 --- a/lib/Coocook/Controller/Project/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; diff --git a/lib/Coocook/Controller/Project/ShopSection.pm b/lib/Coocook/Controller/Project/ShopSection.pm index 561858ea..5b398be5 100644 --- a/lib/Coocook/Controller/Project/ShopSection.pm +++ b/lib/Coocook/Controller/Project/ShopSection.pm @@ -1,4 +1,4 @@ -package Coocook::Controller::ShopSection; +package Coocook::Controller::Project::ShopSection; use Moose; use MooseX::MarkAsMethods autoclean => 1; @@ -9,7 +9,7 @@ __PACKAGE__->config( namespace => 'shop_section' ); =head1 NAME -Coocook::Controller::ShopSection - Catalyst Controller +Coocook::Controller::Project::ShopSection - Catalyst Controller =head1 DESCRIPTION diff --git a/lib/Coocook/Controller/Project/Tag.pm b/lib/Coocook/Controller/Project/Tag.pm index c34e6c55..c48fa1da 100644 --- a/lib/Coocook/Controller/Project/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 diff --git a/lib/Coocook/Controller/Project/Unit.pm b/lib/Coocook/Controller/Project/Unit.pm index b62f9e53..6c5be6da 100644 --- a/lib/Coocook/Controller/Project/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 -- GitLab From c2848680f6ff5e9044f95588be34a942de1d7726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20B=C3=B6hmer?= Date: Thu, 31 Dec 2020 09:19:02 +0100 Subject: [PATCH 3/9] Change action paths for c in article dish item meal permission print purchase_list quantity recipe shop_section tag unit do perl -pe 's{ \W \K /'$c' }{/project/'$c'}x' -i $( git ls-files lib/ ) done --- lib/Coocook/Controller/Browse/Recipe.pm | 4 +-- lib/Coocook/Controller/Project.pm | 34 +++++++++---------- lib/Coocook/Controller/Project/Article.pm | 6 ++-- lib/Coocook/Controller/Project/Dish.pm | 12 +++---- lib/Coocook/Controller/Project/Item.pm | 6 ++-- lib/Coocook/Controller/Project/Print.pm | 22 ++++++------ .../Controller/Project/PurchaseList.pm | 6 ++-- lib/Coocook/Controller/Project/Quantity.pm | 2 +- lib/Coocook/Controller/Project/Recipe.pm | 10 +++--- .../Controller/Project/Recipe/Import.pm | 2 +- lib/Coocook/Controller/Project/ShopSection.pm | 2 +- lib/Coocook/Controller/Project/Tag.pm | 6 ++-- lib/Coocook/Controller/Project/Unit.pm | 2 +- lib/Coocook/Helpers.pm | 2 +- 14 files changed, 58 insertions(+), 58 deletions(-) diff --git a/lib/Coocook/Controller/Browse/Recipe.pm b/lib/Coocook/Controller/Browse/Recipe.pm index da7552b9..61a9c80c 100644 --- a/lib/Coocook/Controller/Browse/Recipe.pm +++ b/lib/Coocook/Controller/Browse/Recipe.pm @@ -124,7 +124,7 @@ sub import : GET HEAD Chained('base') PathPart('import') Args(0) for my $project (@projects) { $project->{import_url} = - $c->uri_for_action( '/recipe/import/preview', + $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 +170,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 acdf4333..6b5eba1c 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'), @@ -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/Project/Article.pm b/lib/Coocook/Controller/Project/Article.pm index 9b32587d..ad9c650c 100644 --- a/lib/Coocook/Controller/Project/Article.pm +++ b/lib/Coocook/Controller/Project/Article.pm @@ -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/Project/Dish.pm b/lib/Coocook/Controller/Project/Dish.pm index 6879635b..fa3aec5f 100644 --- a/lib/Coocook/Controller/Project/Dish.pm +++ b/lib/Coocook/Controller/Project/Dish.pm @@ -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/Project/Item.pm b/lib/Coocook/Controller/Project/Item.pm index 6859401b..89eed134 100644 --- a/lib/Coocook/Controller/Project/Item.pm +++ b/lib/Coocook/Controller/Project/Item.pm @@ -18,7 +18,7 @@ Catalyst Controller. =cut -sub unassigned : GET HEAD Chained('/purchase_list/submenu') PathPart('items/unassigned') Args(0) +sub unassigned : GET HEAD Chained('/project/purchase_list/submenu') PathPart('items/unassigned') Args(0) RequiresCapability('view_project') { my ( $self, $c ) = @_; @@ -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/Project/Print.pm b/lib/Coocook/Controller/Project/Print.pm index 2c9595c5..3c495343 100644 --- a/lib/Coocook/Controller/Project/Print.pm +++ b/lib/Coocook/Controller/Project/Print.pm @@ -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,20 @@ 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 +117,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,7 +129,7 @@ sub project : GET HEAD Chained('/purchase_list/submenu') PathPart('print/project ); } -sub purchase_list : GET HEAD Chained('/purchase_list/submenu') PathPart('print/purchase_list') +sub purchase_list : GET HEAD Chained('/project/purchase_list/submenu') PathPart('print/purchase_list') Args(1) RequiresCapability('view_project') { my ( $self, $c, $id ) = @_; diff --git a/lib/Coocook/Controller/Project/PurchaseList.pm b/lib/Coocook/Controller/Project/PurchaseList.pm index db4afd15..c37f2c83 100644 --- a/lib/Coocook/Controller/Project/PurchaseList.pm +++ b/lib/Coocook/Controller/Project/PurchaseList.pm @@ -98,13 +98,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/Project/Quantity.pm b/lib/Coocook/Controller/Project/Quantity.pm index 95e2ce8f..c0ff8576 100644 --- a/lib/Coocook/Controller/Project/Quantity.pm +++ b/lib/Coocook/Controller/Project/Quantity.pm @@ -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/Project/Recipe.pm b/lib/Coocook/Controller/Project/Recipe.pm index 0e320e3d..46d137af 100644 --- a/lib/Coocook/Controller/Project/Recipe.pm +++ b/lib/Coocook/Controller/Project/Recipe.pm @@ -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 @@ -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/Project/Recipe/Import.pm b/lib/Coocook/Controller/Project/Recipe/Import.pm index 3b86a176..ebfb931a 100644 --- a/lib/Coocook/Controller/Project/Recipe/Import.pm +++ b/lib/Coocook/Controller/Project/Recipe/Import.pm @@ -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/Project/ShopSection.pm b/lib/Coocook/Controller/Project/ShopSection.pm index 5b398be5..f4f28521 100644 --- a/lib/Coocook/Controller/Project/ShopSection.pm +++ b/lib/Coocook/Controller/Project/ShopSection.pm @@ -23,7 +23,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/Project/Tag.pm b/lib/Coocook/Controller/Project/Tag.pm index c48fa1da..c1da6d17 100644 --- a/lib/Coocook/Controller/Project/Tag.pm +++ b/lib/Coocook/Controller/Project/Tag.pm @@ -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/Project/Unit.pm b/lib/Coocook/Controller/Project/Unit.pm index 6c5be6da..fd02e62b 100644 --- a/lib/Coocook/Controller/Project/Unit.pm +++ b/lib/Coocook/Controller/Project/Unit.pm @@ -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 782c09ea..6affc2cc 100644 --- a/lib/Coocook/Helpers.pm +++ b/lib/Coocook/Helpers.pm @@ -190,7 +190,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' } ); -- GitLab From cd0f35cca5e9fec859fcd178c9e2fba42706ea73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20B=C3=B6hmer?= Date: Thu, 31 Dec 2020 09:31:40 +0100 Subject: [PATCH 4/9] Fix Carp config in Coocook::Helper->uri_for() override Never got @CARP_NOT to work like I expected. %Carp::Internal is not as internal as it sounds. --- lib/Coocook/Helpers.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Coocook/Helpers.pm b/lib/Coocook/Helpers.pm index 6affc2cc..ae671a43 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? ) @@ -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 ); } -- GitLab From 6f0b5d39c888490a872997d9134bb22df2c5e602 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20B=C3=B6hmer?= Date: Thu, 31 Dec 2020 09:54:10 +0100 Subject: [PATCH 5/9] Fix custom controller namespaces --- lib/Coocook/Controller/Project/PurchaseList.pm | 3 ++- lib/Coocook/Controller/Project/ShopSection.pm | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Coocook/Controller/Project/PurchaseList.pm b/lib/Coocook/Controller/Project/PurchaseList.pm index c37f2c83..3ecebc8f 100644 --- a/lib/Coocook/Controller/Project/PurchaseList.pm +++ b/lib/Coocook/Controller/Project/PurchaseList.pm @@ -6,7 +6,8 @@ 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 diff --git a/lib/Coocook/Controller/Project/ShopSection.pm b/lib/Coocook/Controller/Project/ShopSection.pm index f4f28521..364d1d53 100644 --- a/lib/Coocook/Controller/Project/ShopSection.pm +++ b/lib/Coocook/Controller/Project/ShopSection.pm @@ -5,7 +5,8 @@ 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 -- GitLab From e903a626212ce460d9dd91cc19c73d132ad16c4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20B=C3=B6hmer?= Date: Thu, 31 Dec 2020 10:01:47 +0100 Subject: [PATCH 6/9] Fix action paths of submenu lists for c in article dish item meal permission print purchase_list quantity recipe shop_section tag unit do perl -pe 's{ action \s* => \s* \K '\'$c"}{'project/"$c'}x' -i $( git ls-files lib/Coocook/Controller/ ) done --- lib/Coocook/Controller/Project.pm | 2 +- lib/Coocook/Controller/Project/PurchaseList.pm | 8 ++++---- lib/Coocook/Controller/Project/Recipe.pm | 6 +++--- lib/Coocook/Controller/Project/Tag.pm | 8 ++++---- lib/Coocook/Controller/Project/Unit.pm | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/Coocook/Controller/Project.pm b/lib/Coocook/Controller/Project.pm index 6b5eba1c..bde5b889 100644 --- a/lib/Coocook/Controller/Project.pm +++ b/lib/Coocook/Controller/Project.pm @@ -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' }, ], ); diff --git a/lib/Coocook/Controller/Project/PurchaseList.pm b/lib/Coocook/Controller/Project/PurchaseList.pm index 3ecebc8f..ed37875b 100644 --- a/lib/Coocook/Controller/Project/PurchaseList.pm +++ b/lib/Coocook/Controller/Project/PurchaseList.pm @@ -26,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' }, ] ); } diff --git a/lib/Coocook/Controller/Project/Recipe.pm b/lib/Coocook/Controller/Project/Recipe.pm index 46d137af..a25830ea 100644 --- a/lib/Coocook/Controller/Project/Recipe.pm +++ b/lib/Coocook/Controller/Project/Recipe.pm @@ -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' }, ] ); } diff --git a/lib/Coocook/Controller/Project/Tag.pm b/lib/Coocook/Controller/Project/Tag.pm index c1da6d17..b8c4279b 100644 --- a/lib/Coocook/Controller/Project/Tag.pm +++ b/lib/Coocook/Controller/Project/Tag.pm @@ -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' }, ], ); } diff --git a/lib/Coocook/Controller/Project/Unit.pm b/lib/Coocook/Controller/Project/Unit.pm index fd02e62b..79fb2881 100644 --- a/lib/Coocook/Controller/Project/Unit.pm +++ b/lib/Coocook/Controller/Project/Unit.pm @@ -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' }, ] ); } -- GitLab From 1bdfad09cb499fb1a65d8fec24511d6c0b4e5b0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20B=C3=B6hmer?= Date: Thu, 31 Dec 2020 10:06:00 +0100 Subject: [PATCH 7/9] Move template files for c in article dish item meal permission print purchase_list quantity recipe shop_section tag unit do git mv -v root/templates/{,project/}$c/ done --- root/templates/{ => project}/article/edit.tt | 0 root/templates/{ => project}/article/index.tt | 0 root/templates/{ => project}/dish/edit.tt | 0 root/templates/{ => project}/item/unassigned.tt | 0 root/templates/{ => project}/print/day.tt | 0 root/templates/{ => project}/print/index.tt | 0 root/templates/{ => project}/print/project.tt | 0 root/templates/{ => project}/print/purchase_list.tt | 0 root/templates/{ => project}/purchase_list/edit.tt | 0 root/templates/{ => project}/purchase_list/index.tt | 0 root/templates/{ => project}/quantity/index.tt | 0 root/templates/{ => project}/recipe/edit.tt | 0 root/templates/{ => project}/recipe/import/preview.tt | 0 root/templates/{ => project}/recipe/importable_recipes.tt | 0 root/templates/{ => project}/recipe/index.tt | 0 root/templates/{ => project}/recipe/new.tt | 0 root/templates/{ => project}/shop_section/index.tt | 0 root/templates/{ => project}/tag/edit.tt | 0 root/templates/{ => project}/tag/edit_group.tt | 0 root/templates/{ => project}/tag/index.tt | 0 root/templates/{ => project}/tag/index_tag_group.tt | 0 root/templates/{ => project}/tag/new_tag.tt | 0 root/templates/{ => project}/tag/new_tag_group.tt | 0 root/templates/{ => project}/unit/edit.tt | 0 root/templates/{ => project}/unit/index.tt | 0 root/templates/{ => project}/unit/new.tt | 0 26 files changed, 0 insertions(+), 0 deletions(-) rename root/templates/{ => project}/article/edit.tt (100%) rename root/templates/{ => project}/article/index.tt (100%) rename root/templates/{ => project}/dish/edit.tt (100%) rename root/templates/{ => project}/item/unassigned.tt (100%) rename root/templates/{ => project}/print/day.tt (100%) rename root/templates/{ => project}/print/index.tt (100%) rename root/templates/{ => project}/print/project.tt (100%) rename root/templates/{ => project}/print/purchase_list.tt (100%) rename root/templates/{ => project}/purchase_list/edit.tt (100%) rename root/templates/{ => project}/purchase_list/index.tt (100%) rename root/templates/{ => project}/quantity/index.tt (100%) rename root/templates/{ => project}/recipe/edit.tt (100%) rename root/templates/{ => project}/recipe/import/preview.tt (100%) rename root/templates/{ => project}/recipe/importable_recipes.tt (100%) rename root/templates/{ => project}/recipe/index.tt (100%) rename root/templates/{ => project}/recipe/new.tt (100%) rename root/templates/{ => project}/shop_section/index.tt (100%) rename root/templates/{ => project}/tag/edit.tt (100%) rename root/templates/{ => project}/tag/edit_group.tt (100%) rename root/templates/{ => project}/tag/index.tt (100%) rename root/templates/{ => project}/tag/index_tag_group.tt (100%) rename root/templates/{ => project}/tag/new_tag.tt (100%) rename root/templates/{ => project}/tag/new_tag_group.tt (100%) rename root/templates/{ => project}/unit/edit.tt (100%) rename root/templates/{ => project}/unit/index.tt (100%) rename root/templates/{ => project}/unit/new.tt (100%) 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/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 -- GitLab From 3d1b4dc5c92cdcd730b18b0c1e7ea3c2a27c724e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20B=C3=B6hmer?= Date: Thu, 31 Dec 2020 10:13:15 +0100 Subject: [PATCH 8/9] Change template paths for c in article dish item meal permission print purchase_list quantity recipe shop_section tag unit do perl -pe 's{ [^\w/] \K '$c' (?= [\w/]+ \.tt ) }{project/'$c'}x' -i $( git ls-files lib/ root/templates/ ) done --- lib/Coocook/Controller/Project/Article.pm | 2 +- lib/Coocook/Controller/Project/Recipe.pm | 2 +- lib/Coocook/Controller/Project/Recipe/Import.pm | 2 +- lib/Coocook/Controller/Project/Unit.pm | 2 +- root/templates/project/show.tt | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Coocook/Controller/Project/Article.pm b/lib/Coocook/Controller/Project/Article.pm index ad9c650c..70a4982c 100644 --- a/lib/Coocook/Controller/Project/Article.pm +++ b/lib/Coocook/Controller/Project/Article.pm @@ -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') ), ); } diff --git a/lib/Coocook/Controller/Project/Recipe.pm b/lib/Coocook/Controller/Project/Recipe.pm index a25830ea..9fdc5811 100644 --- a/lib/Coocook/Controller/Project/Recipe.pm +++ b/lib/Coocook/Controller/Project/Recipe.pm @@ -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') ), ); } diff --git a/lib/Coocook/Controller/Project/Recipe/Import.pm b/lib/Coocook/Controller/Project/Recipe/Import.pm index ebfb931a..9c7e9f31 100644 --- a/lib/Coocook/Controller/Project/Recipe/Import.pm +++ b/lib/Coocook/Controller/Project/Recipe/Import.pm @@ -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'); } diff --git a/lib/Coocook/Controller/Project/Unit.pm b/lib/Coocook/Controller/Project/Unit.pm index 79fb2881..93a189b3 100644 --- a/lib/Coocook/Controller/Project/Unit.pm +++ b/lib/Coocook/Controller/Project/Unit.pm @@ -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 ], diff --git a/root/templates/project/show.tt b/root/templates/project/show.tt index 4f3a80b8..fac9b9c2 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 %]

-- GitLab From 0061496ce3c097c6d5e2b34e26e1112d5bb316d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20B=C3=B6hmer?= Date: Thu, 31 Dec 2020 10:50:59 +0100 Subject: [PATCH 9/9] Apply perltidy --- lib/Coocook/Controller/Browse/Recipe.pm | 3 +-- lib/Coocook/Controller/Project/Item.pm | 4 ++-- lib/Coocook/Controller/Project/Print.pm | 7 ++++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/Coocook/Controller/Browse/Recipe.pm b/lib/Coocook/Controller/Browse/Recipe.pm index 61a9c80c..3c59a85d 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( '/project/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} ] ); diff --git a/lib/Coocook/Controller/Project/Item.pm b/lib/Coocook/Controller/Project/Item.pm index 89eed134..56769db3 100644 --- a/lib/Coocook/Controller/Project/Item.pm +++ b/lib/Coocook/Controller/Project/Item.pm @@ -18,8 +18,8 @@ Catalyst Controller. =cut -sub unassigned : GET HEAD Chained('/project/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; diff --git a/lib/Coocook/Controller/Project/Print.pm b/lib/Coocook/Controller/Project/Print.pm index 3c495343..1d6ddd29 100644 --- a/lib/Coocook/Controller/Project/Print.pm +++ b/lib/Coocook/Controller/Project/Print.pm @@ -105,7 +105,8 @@ sub day : GET HEAD Chained('/project/purchase_list/submenu') PathPart('print/day my $meal = $dish->{meal}; - $meal->{url} ||= $c->project_uri( '/project/print/day', map { $meal->{date}->$_ } qw< year month day > ); + $meal->{url} ||= + $c->project_uri( '/project/print/day', map { $meal->{date}->$_ } qw< year month day > ); } } @@ -129,8 +130,8 @@ sub project : GET HEAD Chained('/project/purchase_list/submenu') PathPart('print ); } -sub purchase_list : GET HEAD Chained('/project/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); -- GitLab