diff --git a/core/profiles/demo_umami/modules/demo_umami_content/default_content/articles.csv b/core/profiles/demo_umami/modules/demo_umami_content/default_content/articles.csv index 74ae81fd7e..d33d4ad82e 100644 --- a/core/profiles/demo_umami/modules/demo_umami_content/default_content/articles.csv +++ b/core/profiles/demo_umami/modules/demo_umami_content/default_content/articles.csv @@ -1,8 +1,8 @@ -title,body,author,slug,image,alt,tags -Give it a go and grow your own herbs,give-it-a-go-and-grow-your-own-herbs.html,Holly Foat,articles/give-it-a-go-and-grow-your-own-herbs,home-grown-herbs.jpg,"Fresh cut herbs including mint, parsley, thyme and dill","Grow your own,Seasonal,Herbs" -The real deal for supermarket savvy shopping,the-real-deal-for-supermarket-savvy-shopping.html,Megan Collins Quinlan,articles/the-real-deal-for-supermarket-savvy-shopping,supermarket-savvy-umami.jpg,Products presented on supermarket shelving.,"Supermarkets,Shopping" -The umami guide to our favorite mushrooms,the-umami-guide-to-our-favourite-mushrooms.html,Umami,articles/the-umami-guide-to-our-favourite-mushrooms,mushrooms-umami.jpg,A delightful selection of mushroom varieties laid out on a simple wooden plate.,"Mushrooms,Vegetarian" -Let's hear it for carrots,lets-hear-it-for-carrots.html,Umami,articles/lets-hear-it-for-carrots,heritage-carrots.jpg,"Purple, orange, yellow and white heritage carrots.","Carrots,Vegetarian,Healthy" -Baking mishaps - our troubleshooting tips,baking-mishaps-our-troubleshooting-tips.html,"Umami",articles/baking-mishaps-our-troubleshooting-tips,chocolate-brownie-umami.jpg,"A delicious chocolate brownie","Baking,Learn to cook" -Skip the spirits with delicious mocktails,skip-the-spirits-with-delicious-mocktails.html,Megan Collins Quinlan,articles/skip-the-spirits-with-delicious-mocktails,mojito-mocktail.jpg,"Fresh mojito mocktail with garnish of mint leaves, ice, and sliced lime","Alcohol free,Drinks,Party,Cocktail party,Dinner party" -Give your oatmeal the ultimate makeover,give-your-oatmeal-the-ultimate-makeover.html,Umami,articles/give-your-oatmeal-the-ultimate-makeover,oatmeal-fruit-syrup-topping.jpg,"Oatmeal topped with a vibrant mix of berries, nuts, and seeds","Vegan,Vegetarian,Oats,Breakfast,Dessert" +title,body,author,slug,image,alt,tags,date_offset +Give it a go and grow your own herbs,give-it-a-go-and-grow-your-own-herbs.html,Holly Foat,articles/give-it-a-go-and-grow-your-own-herbs,home-grown-herbs.jpg,"Fresh cut herbs including mint, parsley, thyme and dill","Grow your own,Seasonal,Herbs",0 +The real deal for supermarket savvy shopping,the-real-deal-for-supermarket-savvy-shopping.html,Megan Collins Quinlan,articles/the-real-deal-for-supermarket-savvy-shopping,supermarket-savvy-umami.jpg,Products presented on supermarket shelving.,"Supermarkets,Shopping",1 +The umami guide to our favorite mushrooms,the-umami-guide-to-our-favourite-mushrooms.html,Umami,articles/the-umami-guide-to-our-favourite-mushrooms,mushrooms-umami.jpg,A delightful selection of mushroom varieties laid out on a simple wooden plate.,"Mushrooms,Vegetarian",3 +Let's hear it for carrots,lets-hear-it-for-carrots.html,Umami,articles/lets-hear-it-for-carrots,heritage-carrots.jpg,"Purple, orange, yellow and white heritage carrots.","Carrots,Vegetarian,Healthy",5 +Baking mishaps - our troubleshooting tips,baking-mishaps-our-troubleshooting-tips.html,Umami,articles/baking-mishaps-our-troubleshooting-tips,chocolate-brownie-umami.jpg,A delicious chocolate brownie,"Baking,Learn to cook",7 +Skip the spirits with delicious mocktails,skip-the-spirits-with-delicious-mocktails.html,Megan Collins Quinlan,articles/skip-the-spirits-with-delicious-mocktails,mojito-mocktail.jpg,"Fresh mojito mocktail with garnish of mint leaves, ice, and sliced lime","Alcohol free,Drinks,Party,Cocktail party,Dinner party",9 +Give your oatmeal the ultimate makeover,give-your-oatmeal-the-ultimate-makeover.html,Umami,articles/give-your-oatmeal-the-ultimate-makeover,oatmeal-fruit-syrup-topping.jpg,"Oatmeal topped with a vibrant mix of berries, nuts, and seeds","Vegan,Vegetarian,Oats,Breakfast,Dessert",11 \ No newline at end of file diff --git a/core/profiles/demo_umami/modules/demo_umami_content/default_content/recipes.csv b/core/profiles/demo_umami/modules/demo_umami_content/default_content/recipes.csv index 6c9d6db290..e43c001d2f 100644 --- a/core/profiles/demo_umami/modules/demo_umami_content/default_content/recipes.csv +++ b/core/profiles/demo_umami/modules/demo_umami_content/default_content/recipes.csv @@ -1,10 +1,10 @@ -title,image,alt,summary,author,recipe_category,preparation_time,cooking_time,total_time,difficulty,ingredients,recipe_instruction,number_of_servings,tags,slug -Deep mediterranean quiche,mediterranean-quiche-umami.jpg,"A delicious deep layered Mediterranean quiche with basil garnish.",An Italian inspired quiche with sun dried tomatoes and courgette. A perfect light meal for a summer's day.,Umami,Main course,40,30,70,medium,"For the pastry:,280g plain flour,140g butter,Cold water,For the filling:,1 onion,2 garlic cloves,Half a courgette,450ml soya milk,500g grated parmesan,2 eggs,200g sun dried tomatoes,100g feta",mediterranean-quiche-umami.html,8,"Pastry,Egg",recipes/deep-mediterranean-quiche -Vegan chocolate brownies,chocolate-brownie-umami.jpg,A white plate with a vegan chocolate brownie covered in dark vegan chocolate,These sumptuous brownies should be gooey on the inside and crisp on the outside. A perfect indulgence!,Umami,Snack,20,20,40,,"170g self-raising flour, 3 tbsp cocoa powder, 170g caster sugar, 5 tbsp vegetable oil, 1 tsp vanilla extract, 1 pinch salt, 230ml soy milk",chocolate-brownie-umami.html,8,,recipes/vegan-chocolate-brownies -Super easy vegetarian pasta bake,veggie-pasta-bake-umami.jpg,Cheesy pasta dish with vegetarian sausages and topped with mozzarella cheese and basil,A wholesome pasta bake is the ultimate comfort food. This delicious bake is super quick to prepare and an ideal midweek meal for all the family.,Umami,Main course,5,20,25,easy,"400g wholewheat pasta, 1 onion, 2 garlic cloves, 1 pack vegetarian sausages, 400g chopped tomatoes, 50g sliced sun dried tomatoes, 1 pinch sugar, 3 tbsp red pesto, 50g cheddar cheese, Basil or mixed herbs, 100g mozzarella",veggie-pasta-bake-umami.html,4,"Vegetarian,Pasta,Baked",recipes/super-easy-vegetarian-pasta-bake -Watercress soup,watercress-soup-umami.jpg,Watercress soup with a sprig of coriander as garnish in a white bowl with green trim.,"A wonderfully simple and light soup, making the most of seasonal, local produce. ",Umami,Starter,10,20,30,easy,"3 bunches watercress,3 potatoes,3 onions,2 leeks,800ml stock,5 tbsp crème fraîche",watercress-soup-umami.html,4,"Soup,Vegetarian",recipes/watercress-soup -Victoria sponge cake,victoria-sponge-umami.jpg,"A classic, uncut Victoria sponge with a deep filling of butter cream and jam","A traditional Victoria sponge cake, perfect for any afternoon with a cup of tea.",Umami,Dessert,20,20,40,easy,"225g butter or margarine,225g caster sugar,225g self-raising flour,4 eggs,1 tsp baking powder,3 tbsp of jam for the filling,Icing sugar to dust the top,Cream to serve",victoria-sponge-umami.html,10,Cake,recipes/victoria-sponge-cake -Gluten free pizza,pizza-umami.jpg,"Olives, basil, and mozzarella top a gluten free pizza crust with marinara sauce.","A gorgeous and simple gluten free pizza, with deliciously indulgent mozzarella and Parma ham. Can easily be vegetarian by leaving out the ham.",Umami,Main course,15,15,30,,"400g gluten free flour, 125ml warm water, 125ml milk, 1 sachet dried yeast, 2 tsp sugar, 1 tsp salt, 2 tbsp olive oil, 4 tbsp tomato puree, 1 garlic clove, Fresh basil, 200g mozzarella, 100g rocket, 5 slices Parma ham",pizza-umami.html,4,,recipes/gluten-free-pizza -Thai green curry,thai-green-curry-umami.jpg,"A traditional bowl of creamy, aromatic Thai green curry with chunks of chicken in a small bowl with jasmine rice.",A quick and easy version of the classic Thai green curry. Perfect for a midweek meal!,Umami,Main course,10,15,25,,"400g coconut milk, 400g chicken or tofu, 1 tbsp Thai green curry paste, 1 garlic clove, 2 tsp fish sauce, 400g mushrooms, 200g green beans, Fresh coriander leaves, Jasmine rice",thai-green-curry-umami.html,4,,recipes/thai-green-curry -Crema catalana,crema-catalana-umami.jpg,"Typical Catalan dessert made from cream and egg yolks, covered with a traditional layer of caramelized sugar to provide a crispy contrast.",Enjoy this sweet recipe for one of the oldest desserts in Europe. It requires very few ingredients!,Umami,Dessert,10,20,30,,"1l milk, 200g sugar, 6 egg yolks, 30g cornstarch, 1 cinnamon stick, 1 piece lemon peel",crema-catalana-umami.html,8,"Egg, Vegetarian",recipes/crema-catalana -Fiery chili sauce,chili-sauce-umami.jpg,"An iridescent array of chilies, onions, and garlic, slowly sweating over a low heat","A rich and fiery chili sauce. Take care when handling chili peppers. And serve sparingly!",Umami,Accompaniment,10,50,60,easy,"2 red onions, 1 lemon, 2 limes, 250ml malt vinegar, 7 garlic cloves, 1 green bell pepper, 1 red bell pepper, 800g cherry tomatoes, 30 mixed chilies, Olive oil, 1 tbsp ground black pepper, 1 tbsp brown sugar",chili-sauce-umami.html,60,Vegetarian,recipes/fiery-chili-sauce +title,image,alt,summary,author,recipe_category,preparation_time,cooking_time,total_time,difficulty,ingredients,recipe_instruction,number_of_servings,tags,slug,date_offset +Deep mediterranean quiche,mediterranean-quiche-umami.jpg,"A delicious deep layered Mediterranean quiche with basil garnish.",An Italian inspired quiche with sun dried tomatoes and courgette. A perfect light meal for a summer's day.,Umami,Main course,40,30,70,medium,"For the pastry:,280g plain flour,140g butter,Cold water,For the filling:,1 onion,2 garlic cloves,Half a courgette,450ml soya milk,500g grated parmesan,2 eggs,200g sun dried tomatoes,100g feta",mediterranean-quiche-umami.html,8,"Pastry,Egg",recipes/deep-mediterranean-quiche,0 +Vegan chocolate brownies,chocolate-brownie-umami.jpg,A white plate with a vegan chocolate brownie covered in dark vegan chocolate,These sumptuous brownies should be gooey on the inside and crisp on the outside. A perfect indulgence!,Umami,Snack,20,20,40,,"170g self-raising flour, 3 tbsp cocoa powder, 170g caster sugar, 5 tbsp vegetable oil, 1 tsp vanilla extract, 1 pinch salt, 230ml soy milk",chocolate-brownie-umami.html,8,,recipes/vegan-chocolate-brownies,2 +Super easy vegetarian pasta bake,veggie-pasta-bake-umami.jpg,Cheesy pasta dish with vegetarian sausages and topped with mozzarella cheese and basil,A wholesome pasta bake is the ultimate comfort food. This delicious bake is super quick to prepare and an ideal midweek meal for all the family.,Umami,Main course,5,20,25,easy,"400g wholewheat pasta, 1 onion, 2 garlic cloves, 1 pack vegetarian sausages, 400g chopped tomatoes, 50g sliced sun dried tomatoes, 1 pinch sugar, 3 tbsp red pesto, 50g cheddar cheese, Basil or mixed herbs, 100g mozzarella",veggie-pasta-bake-umami.html,4,"Vegetarian,Pasta,Baked",recipes/super-easy-vegetarian-pasta-bake,4 +Watercress soup,watercress-soup-umami.jpg,Watercress soup with a sprig of coriander as garnish in a white bowl with green trim.,"A wonderfully simple and light soup, making the most of seasonal, local produce. ",Umami,Starter,10,20,30,easy,"3 bunches watercress,3 potatoes,3 onions,2 leeks,800ml stock,5 tbsp crème fraîche",watercress-soup-umami.html,4,"Soup,Vegetarian",recipes/watercress-soup,6 +Victoria sponge cake,victoria-sponge-umami.jpg,"A classic, uncut Victoria sponge with a deep filling of butter cream and jam","A traditional Victoria sponge cake, perfect for any afternoon with a cup of tea.",Umami,Dessert,20,20,40,easy,"225g butter or margarine,225g caster sugar,225g self-raising flour,4 eggs,1 tsp baking powder,3 tbsp of jam for the filling,Icing sugar to dust the top,Cream to serve",victoria-sponge-umami.html,10,Cake,recipes/victoria-sponge-cake,8 +Gluten free pizza,pizza-umami.jpg,"Olives, basil, and mozzarella top a gluten free pizza crust with marinara sauce.","A gorgeous and simple gluten free pizza, with deliciously indulgent mozzeralla and Parma ham. Can easily be vegetarian by leaving out the ham.",Umami,Main course,15,15,30,,"400g gluten free flour, 125ml warm water, 125ml milk, 1 sachet dried yeast, 2 tsp sugar, 1 tsp salt, 2 tbsp olive oil, 4 tbsp tomato puree, 1 garlic clove, Fresh basil, 200g mozzarella, 100g rocket, 5 slices Parma ham",pizza-umami.html,4,,recipes/gluten-free-pizza,10 +Thai green curry,thai-green-curry-umami.jpg,"A traditional bowl of creamy, aromatic Thai green curry with chunks of chicken in a small bowl with jasmine rice.",A quick and easy version of the classic Thai green curry. Perfect for a midweek meal!,Umami,Main course,10,15,25,,"400g coconut milk, 400g chicken or tofu, 1 tbsp Thai green curry paste, 1 garlic clove, 2 tsp fish sauce, 400g mushrooms, 200g green beans, Fresh coriander leaves, Jasmine rice",thai-green-curry-umami.html,4,,recipes/thai-green-curry,12 +Crema catalana,crema-catalana-umami.jpg,"Typical Catalan dessert made from cream and egg yolks, covered with a traditional layer of caramelized sugar to provide a crispy contrast.",Enjoy this sweet recipe for one of the oldest desserts in Europe. It requires very few ingredients!,Umami,Dessert,10,20,30,,"1l milk, 200g sugar, 6 egg yolks, 30g cornstarch, 1 cinnamon stick, 1 piece lemon peel",crema-catalana-umami.html,8,"Egg, Vegetarian",recipes/crema-catalana,14 +Fiery chili sauce,chili-sauce-umami.jpg,"An iridescent array of chilies, onions, and garlic, slowly sweating over a low heat","A rich and fiery chili sauce. Take care when handling chili peppers. And serve sparingly!",Umami,Accompaniment,10,50,60,easy,"2 red onions, 1 lemon, 2 limes, 250ml malt vinegar, 7 garlic cloves, 1 green bell pepper, 1 red bell pepper, 800g cherry tomatoes, 30 mixed chilies, Olive oil, 1 tbsp ground black pepper, 1 tbsp brown sugar",chili-sauce-umami.html,60,Vegetarian,recipes/fiery-chili-sauce,16 \ No newline at end of file diff --git a/core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php b/core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php index 01e998e9b3..9e5218c321 100644 --- a/core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php +++ b/core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php @@ -168,6 +168,16 @@ protected function importArticles() { 'alt' => $data['alt'], ]; } + // Set the create and modified date, offset by the value from the + // articles csv. This is to give a consistent sort order by spacing out + // the nodes creation time, rather than using install time. The + // advantage of this is it allows for easier A/B testing and checking + // for visual regressions. + if (!empty($data['date_offset'])) { + $offset_date = $this->getOffsetDate($data['date_offset']); + $values['created'] = $offset_date; + $values['changed'] = $offset_date; + } // Create Node. $node = $this->entityTypeManager->getStorage('node')->create($values); @@ -267,6 +277,12 @@ protected function importRecipes() { $values['field_tags'][] = ['target_id' => $this->getTerm($term)]; } } + // Set the create and modified date offset. + if (!empty($data['date_offset'])) { + $offset_date = $this->getOffsetDate($data['date_offset']); + $values['created'] = $offset_date; + $values['changed'] = $offset_date; + } $node = $this->entityTypeManager->getStorage('node')->create($values); $node->save(); @@ -526,4 +542,23 @@ protected function fileUnmanagedCopy($path) { return file_unmanaged_copy($path, 'public://' . $filename, FILE_EXISTS_REPLACE); } + /** + * A function to calculate the offset date we wish to use. + * + * @param string $daysToOffset + * The number of days to offset. + * + * @return string + * The offset date as a string. Use current timestamp on error. + */ + protected function getOffsetDate($daysToOffset) { + if (empty($daysToOffset)) { + $daysToOffset = 0; + } + $date = new \DateTime(); + $interval = new \DateInterval('P' . $daysToOffset . 'D'); + $offset_date = $date->sub($interval); + return $offset_date->format('U'); + } + }