Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/8.8.5 - Layout config option, created option to extend promo repository #699

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
04e7bd5
Not ready for release yet
breakdancingcat Feb 1, 2024
5e5211f
Merge pull request #693 from waynestate/feature/refactor-4
breakdancingcat Feb 1, 2024
d11379c
Merge tag '8.8.1' into develop
chrispelzer Feb 5, 2024
43cfd9f
Merge tag '8.8.2' into develop
chrispelzer Feb 12, 2024
a7fd866
Merge tag '8.8.3' into develop
breakdancingcat Feb 15, 2024
c6c3e80
Created the ability to use a different layout for instances when the …
breakdancingcat Feb 16, 2024
736caed
Accidentally committed all these bak files
breakdancingcat Feb 16, 2024
7ea5b46
Broke apart get request data function to allow for extending when add…
breakdancingcat Feb 16, 2024
01955dd
Updating promo repo contract
breakdancingcat Feb 16, 2024
2cd5a02
Adding a framework for extending a repository to avoid editing app files
breakdancingcat Feb 19, 2024
7e0ec5f
Merge pull request #697 from waynestate/feature/layout
breakdancingcat Feb 22, 2024
e6008d5
Adding framework to extend on the global repository
breakdancingcat Feb 22, 2024
76b7778
Adding framework to extend on the global repository
breakdancingcat Feb 22, 2024
44a2f56
Merge branch 'develop' into feature/extending-repository-framework
breakdancingcat Feb 24, 2024
55183ff
Additional hero logic
breakdancingcat Feb 26, 2024
dffde4b
Adding default hero to childpage to see if we are using contained her…
breakdancingcat Feb 26, 2024
fc89cb6
Merge pull request #698 from waynestate/feature/extending-repository-…
breakdancingcat Feb 26, 2024
d4b3e53
V 8.8.5
breakdancingcat Feb 26, 2024
08453de
Merge branch 'master' into release/8.8.5
breakdancingcat Feb 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
25 changes: 25 additions & 0 deletions config/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@
*/
'gtm_code' => 'GTM-NCBVKQ2',

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

/*
|--------------------------------------------------------------------------
| Top Menu Enabled
Expand Down Expand Up @@ -76,6 +86,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);
}
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.8.5",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would put this to 8.9.0 rather than patch version bump, just due to the overall layout changes that happened

"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
2 changes: 1 addition & 1 deletion resources/views/childpage.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
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-contained')
@else
@include('components/hero/banner-small')
@endif
@endif
@endif
@endif
@endforeach
Expand Down
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
Original file line number Diff line number Diff line change
@@ -1,9 +1,44 @@
@extends('layouts.' . (!empty($layout) ? $layout : 'main'))
<!DOCTYPE html>
<html class="bg-white antialiased" lang="en">
<head>
@include('components.meta')

@section('content-area')
<title>{{ $base['meta']['title'] ?? 'Wayne State University' }}</title>

<link rel="icon" type="image/x-icon" href="https://wayne.edu/favicon.ico">
<link rel="stylesheet" href="{{ mix('_resources/css/main.css') }}">

<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Lato:wght@400;700&display=swap" rel="stylesheet">

@if(!empty($base['page']['canonical']))<link rel="canonical" href="{{ $base['page']['canonical'] }}">@endif

@include('components.gtm-head')

@yield('head')
</head>
<body class="font-sans font-normal text-black leading-normal text-base">

@include('components.gtm-body')
@include('components.skip')

<header>
@include('components.header')

@if(!empty($base['site']))
@include('components.menu-top', ['site' => $base['site'], 'top_menu_output' => $base['top_menu_output']])
@endif

@if(!empty($base['flag']))
@include('components.flag', ['flag' => $base['flag']])
@endif
</header>

<div id="panel" class="site-theme">
@yield('top')

@if(!empty($base['hero']))
@if(!empty($base['hero']) && in_array($base['page']['controller'], config('base.hero_full_controllers')))
@include('components.hero', ['data' => $base['hero']])

@yield('under-hero')
Expand Down Expand Up @@ -47,6 +82,12 @@

<main class="w-full {{$base['show_site_menu'] === true ? 'mt:w-3/4' : '' }} content-area mb-8 print:w-full" tabindex="-1">

@if(!empty($base['hero']) && !in_array($base['page']['controller'], config('base.hero_full_controllers')))
@include('components.hero', ['data' => $base['hero']])

@yield('under-hero')
@endif

@if(!empty($base['breadcrumbs']))
@include('components.breadcrumbs', ['breadcrumbs' => $base['breadcrumbs']])
@endif
Expand All @@ -58,4 +99,20 @@
@if(!in_array($base['page']['controller'], config('base.full_width_controllers')))</div>@endif

@yield('bottom')
@endsection
</div>

<footer>
@if(!empty($base['social']))
@include('components.footer-social', ['social' => $base['social']])
@endif

@if(!empty($base['contact']))
@include('components.footer-contact', ['contact' => $base['contact']])
@endif

@include('components.footer')
</footer>

<script src="{{ mix('_resources/js/main.js') }}"></script>
</body>
</html>
Loading
Loading