Skip to content

Commit

Permalink
Merge pull request #700 from waynestate/release/8.9.0
Browse files Browse the repository at this point in the history
Release/8.9.0 - Site layout option, extend promo repository framework
  • Loading branch information
breakdancingcat committed Feb 28, 2024
2 parents 2d0013e + d5e9704 commit 02374e0
Show file tree
Hide file tree
Showing 52 changed files with 540 additions and 63 deletions.
2 changes: 2 additions & 0 deletions app/Http/Controllers/ChildpageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public function index(Request $request): View

$request->data['base']['hero'] = $components['components'][$hero_key]['data'];

config(['base.hero_full_controllers' => ['ChildpageController']]);

unset($components['components'][$hero_key]);
}

Expand Down
4 changes: 4 additions & 0 deletions app/Http/Middleware/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public function handle(Request $request, Closure $next): Response|null
// Merge server and page data so global repositories can use them
$request->data = merge($data, $page);

// Get the site layout and merge
$layout['layout'] = config('base.layout');
$request->data = merge($request->data, $layout);

// Get the global data config
$config = config('base.global');

Expand Down
67 changes: 56 additions & 11 deletions app/Repositories/PromoRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,22 @@ public function getBackToPromoPage($referer = null, $scheme = null, $host = null
*/
public function getRequestData(array $data)
{
/*
|--------------------------------------------------------------------------
| Do not edit this file!
|--------------------------------------------------------------------------
|
| Add to config/base.app Global Data => $global['all']['promos']['new_promo']
| - or -
| Extend this repository; copy and edit these stubs:
| stubs/extend-repository.stub => app/Repositories/PromosExtendedRepository.php
| stubs/extend-repository-styleguide.stub => styleguide/Repositories/PromosExtendedRepository.php
|
| Update config/base.app Global Data 'callbacks' and replace:
| '\Repositories\PromoRepository@getRequestData' => '\Repositories\PromosExtendedRepository@getRequestData'
|
*/

// Get the global promos config
$config = config('base.global');

Expand All @@ -84,14 +100,7 @@ public function getRequestData(array $data)
$groups = array_merge($groups, $config['sites'][$data['site']['id']]['promos']);
}

// Setup the group reference
$group_reference = collect($groups)->reject(function ($group) {
return empty($group['id']);
})->mapWithKeys(function ($group, $name) {
$group_reference[$group['id']] = $name;

return [$group['id'] => $name];
})->toArray();
$group_reference = $this->createGlobalPromoGroupReference($data, $config, $groups);

$params = [
'method' => 'cms.promotions.listing',
Expand All @@ -104,7 +113,38 @@ public function getRequestData(array $data)
return $this->wsuApi->sendRequest($params['method'], $params);
});

// Setup the group reference array for this site
$group_config = $this->createGlobalPromoGroupConfig($data, $config, $groups);

$promos = $this->parsePromos->parse($promos, $group_reference, $group_config);

$global_promos = $this->manipulateGlobalPromos($promos, $groups);

return $global_promos;
}

/**
* {@inheritdoc}
*/
public function createGlobalPromoGroupReference(array $data, array $config, array $groups)
{
// Setup the group reference of promo group IDs
$group_reference = collect($groups)->reject(function ($group) {
return empty($group['id']);
})->mapWithKeys(function ($group, $name) {
$group_reference[$group['id']] = $name;

return [$group['id'] => $name];
})->toArray();

return $group_reference;
}

/**
* {@inheritdoc}
*/
public function createGlobalPromoGroupConfig(array $data, array $config, array $groups)
{
// Inject global promo config
$group_config = collect($groups)->mapWithKeys(function ($group, $name) use ($config, $data) {
$value = !empty($group['config']) ? $group['config'] : null;

Expand All @@ -118,9 +158,14 @@ public function getRequestData(array $data)
$group_config = str_replace('|limit:1', '|limit:'.config('base.hero_rotating_limit'), $group_config);
}

// Parsed promotions
$promos = $this->parsePromos->parse($promos, $group_reference, $group_config);
return $group_config;
}

/**
* {@inheritdoc}
*/
public function manipulateGlobalPromos(array $promos, array $groups)
{
// Override the site's social icons if it doesn't have any
if (empty($promos['social']) && !empty($promos['main_social'])) {
$promos['social'] = $promos['main_social'];
Expand Down
26 changes: 26 additions & 0 deletions config/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@
*/
'gtm_code' => 'GTM-NCBVKQ2',

/*
|--------------------------------------------------------------------------
| Site layout
|--------------------------------------------------------------------------
|
| Create a new layout when adjustments to the content area are needed.
| Layouts are stored in resources/layouts
|
*/
'layout' => 'main',

/*
|--------------------------------------------------------------------------
| Top Menu Enabled
Expand Down Expand Up @@ -76,6 +87,21 @@
*/
'homepage_menu_enabled' => true,

/*
|--------------------------------------------------------------------------
| Hero Full Width
|--------------------------------------------------------------------------
|
| This enables hero images to span 100% across the top of the site. You
| can specify which controllers you want this to work on by adding to
| the array. If a controller is not listed it will be contained
| within the content-area. If a page isn't in the menu and top
| menu is enabled then the controller will automatically act
| as if it was in this array.
|
*/
'hero_full_controllers' => ['HomepageController'],

/*
|--------------------------------------------------------------------------
| Hero Rotating
Expand Down
25 changes: 25 additions & 0 deletions contracts/Repositories/PromoRepositoryContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,33 @@

interface PromoRepositoryContract
{
/**
* {@inheritdoc}
*/
public function getPromoView($id);

/**
* {@inheritdoc}
*/
public function getBackToPromoPage($referer = null, $scheme = null, $host = null, $uri = null);

/**
* {@inheritdoc}
*/
public function getRequestData(array $data);

/**
* {@inheritdoc}
*/
public function createGlobalPromoGroupReference(array $data, array $config, array $groups);

/**
* {@inheritdoc}
*/
public function createGlobalPromoGroupConfig(array $data, array $config, array $groups);

/**
* {@inheritdoc}
*/
public function manipulateGlobalPromos(array $promos, array $groups);
}
8 changes: 4 additions & 4 deletions factories/HeroImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ public function create($limit = 1, $flatten = false, $options = [])
'title' => $this->faker->sentence(3),
'description' => '<p>' . $this->faker->text(100) . ' <a href="https://wayne.edu">'. $this->faker->sentence(3) .'</a></p>',
'link' => 'https://wayne.edu',
'relative_url' => '/styleguide/image/1600x580?text=1600x580%20('.$i.')',
'filename_url' => '/styleguide/image/1600x580?text=1600x580%20('.$i.')',
'relative_url' => '/styleguide/image/3200x600?text=3200x600+('.$i.')',
'filename_url' => '/styleguide/image/3200x600?text=3200x600+('.$i.')',
'filename_alt_text' => 'Example background image',
'secondary_filename_url' => '/styleguide/image/1600x580?text=Secondary%201600x580%20('.$i.')',
'secondary_relative_url' => '/styleguide/image/1600x580?text=Secondary%201600x580%20('.$i.')',
'secondary_filename_url' => '/styleguide/image/3200x1160?text=Secondary+3200x1160+('.$i.')',
'secondary_relative_url' => '/styleguide/image/3200x1160?text=Secondary+3200x1160+('.$i.')',
'secondary_alt_text' => 'Example secondary image',
];

Expand Down
8 changes: 4 additions & 4 deletions factories/HeroImageRotate.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ public function create($limit = 1, $flatten = false, $options = [])
'title' => $this->faker->sentence(3),
'description' => '<p>' . $this->faker->text(100) . ' <a href="https://wayne.edu">'. $this->faker->sentence(3) .'</a></p>',
'link' => 'https://wayne.edu',
'relative_url' => '/styleguide/image/1600x580?text=Primary%20image%20('.$i.')',
'filename_url' => '/styleguide/image/1600x580?text=Primary%20image%20('.$i.')',
'relative_url' => '/styleguide/image/3200x1160?text=Primary+image+('.$i.')',
'filename_url' => '/styleguide/image/3200x1160?text=Primary+image+('.$i.')',
'filename_alt_text' => 'Example background image',
'secondary_filename_url' => '/styleguide/image/400x250?text=Secondary%20image%20('.$i.')',
'secondary_relative_url' => '/styleguide/image/400x250?text=Secondary%20image%20('.$i.')',
'secondary_filename_url' => '/styleguide/image/400x250?text=Secondary+image+('.$i.')',
'secondary_relative_url' => '/styleguide/image/400x250?text=Secondary+image+('.$i.')',
'secondary_alt_text' => 'Example secondary image',
'option' => $this->faker->randomElement(['Text Overlay', 'Half', 'Logo Overlay', 'Banner large']),
];
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "base",
"private": true,
"version": "8.8.4",
"version": "8.9.0",
"description": "",
"scripts": {
"dev": "npm run development",
Expand Down
2 changes: 1 addition & 1 deletion resources/views/article.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@extends('components.content-area')
@extends('layouts.' . (!empty($base['layout']) ? $base['layout'] : 'main'))

@section('content')
@include('components.page-title', ['title' => $article['data']['title']])
Expand Down
2 changes: 1 addition & 1 deletion resources/views/articles.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@extends('components.content-area')
@extends('layouts.' . (!empty($base['layout']) ? $base['layout'] : 'main'))

@section('content')
@include('components.page-title', ['title' => $base['page']['title']])
Expand Down
4 changes: 2 additions & 2 deletions resources/views/childpage.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@extends('components.content-area')

@extends('layouts.' . (!empty($base['layout']) ? $base['layout'] : 'main'))
@section('content')
@include('components.page-title', ['title' => $base['page']['title']])

Expand Down
10 changes: 9 additions & 1 deletion resources/views/components/hero.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@
@if(!empty($hero['option']))
@include('components/hero/'.Str::slug($hero['option']))
@else
@include('components/hero/banner-small')
@if(!empty($base['layout']) && $base['layout'] === 'contained-hero')
@include('components/hero/banner-large')
@else
@if(config('base.layout') === 'contained-hero')
@include('components/hero/banner-large')
@else
@include('components/hero/banner-small')
@endif
@endif
@endif
@endif
@endforeach
Expand Down
6 changes: 6 additions & 0 deletions resources/views/components/hero/banner-contained.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{--
$hero => array // ['relative_url', 'title']
--}}
<div class="hero__wrapper w-full">
<div class="hero__bg aspect-hero max-h-hero w-full bg-cover bg-center relative{{ $loop->first !== true ? ' lazy' : '' }}" @if($loop->first === true) style="background-image: url('{{ $hero['relative_url'] }}')" @else data-src="{{ $hero['relative_url'] }}"@endif></div>
</div>
2 changes: 1 addition & 1 deletion resources/views/components/hero/banner-large.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
$hero => array // ['relative_url', 'title']
--}}
<div class="hero__wrapper w-full">
<div class="hero__bg h-hero max-h-hero w-full bg-cover bg-center relative{{ $loop->first !== true ? ' lazy' : '' }}" @if($loop->first === true) style="background-image: url('{{ $hero['relative_url'] }}')" @else data-src="{{ $hero['relative_url'] }}"@endif></div>
<div class="hero__bg aspect-hero max-h-hero w-full bg-cover bg-center relative{{ $loop->first !== true ? ' lazy' : '' }}" @if($loop->first === true) style="background-image: url('{{ $hero['relative_url'] }}')" @else data-src="{{ $hero['relative_url'] }}"@endif></div>
</div>
10 changes: 6 additions & 4 deletions resources/views/components/hero/text-overlay.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,26 @@
--}}

<div class="hero__wrapper w-full relative">
<div class="hero__primary-image h-hero max-h-hero w-full bg-cover bg-center relative{{ $loop->first !== true ? ' lazy' : '' }}" @if($loop->first === true) style="background-image: url('{{ $hero['relative_url'] }}')" @else data-src="{{ $hero['relative_url'] }}"@endif></div>
<div class="hero__primary-image aspect-hero max-h-hero w-full bg-cover bg-center relative{{ $loop->first !== true ? ' lazy' : '' }}" @if($loop->first === true) style="background-image: url('{{ $hero['relative_url'] }}')" @else data-src="{{ $hero['relative_url'] }}"@endif></div>
<div class="hero__content-position relative lg:absolute print:relative p-6 lg:p-0 lg:bottom-0 lg:inset-x-0 lg:bg-gradient-darkest lg:pt-20">
<div class="row">
<{{ !empty($hero['link']) ? 'a href='.$hero['link'] : 'div' }} class="hero__content relative block {{ !empty($hero['link']) ? 'group no-underline ' : '' }} p-4 lg:pb-2 pl-6 lg:pl-4 pb-8 border-l-12 border-gold border-solid lg:border-0 text-green-900 lg:text-white lg:white-links">
<div class="hero__title lg:drop-shadow-px leading-tight mt-4 text-3xl mb-3 lg:text-5xl group-hover:underline">
<div class="hero__title lg:drop-shadow-px leading-tight mt-4 text-3xl mb-4 lg:text-5xl group-hover:underline">
{!! strip_tags($hero['title'], ['em', 'strong']) !!}
</div>
@if(!empty($hero['description']))
<div class="hero__description text-lg content">
<div class="hero__description text-lg content -mt-2">
@if(!empty($hero['link']))
{!! preg_replace(array('"<a href(.*?)>"', '"</a>"'), array('',''), $hero['description']) !!}
@else
{!! $hero['description'] !!}
@endif
</div>
@endif
{!! !empty($hero['link']) ? '</a>' : '</div>' !!}
<div class="relative px-4 -mt-4 mb-4">
@yield('hero-buttons')
<{{ !empty($hero['link']) ? '/a' : '/div' }}>
</div>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion resources/views/components/promo/grid-item.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@
</div>
</div>
</div>
<{{ !empty($item['link']) ? '/a' : '/div' }}>
{!! !empty($item['link']) ? '</a>' : '</div>' !!}
2 changes: 1 addition & 1 deletion resources/views/components/promo/list-item.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@
@endif
</div>
</div>
<{{ !empty($item['link']) ? '/a' : '/div' }}>
{!! !empty($item['link']) ? '</a>' : '</div>' !!}
2 changes: 1 addition & 1 deletion resources/views/contact-tables.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@extends('components.content-area')
@extends('layouts.' . (!empty($base['layout']) ? $base['layout'] : 'main'))

@section('content')
@include('components.page-title', ['title' => $base['page']['title']])
Expand Down
2 changes: 1 addition & 1 deletion resources/views/directory.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@extends('components.content-area')
@extends('layouts.' . (!empty($base['layout']) ? $base['layout'] : 'main'))

@section('content')
@include('components.page-title', ['title' => $base['page']['title']])
Expand Down
2 changes: 1 addition & 1 deletion resources/views/homepage.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@extends('components.content-area')
@extends('layouts.' . (!empty($base['layout']) ? $base['layout'] : 'main'))

@section('content')
@include('components.page-title', ['title' => $base['page']['title']])
Expand Down
Loading

0 comments on commit 02374e0

Please sign in to comment.