Skip to content

Commit

Permalink
Merge branch '11.x' of https://github.com/SU-SWS/stanford_profile int…
Browse files Browse the repository at this point in the history
…o 11.x
  • Loading branch information
pookmish committed Dec 5, 2023
2 parents 24cd334 + 8e6ce05 commit 97b1ab1
Show file tree
Hide file tree
Showing 12 changed files with 138 additions and 67 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
run: |
composer global require su-sws/stanford-caravan:10.x-dev
~/.composer/vendor/bin/sws-caravan phpunit /var/www/html --extension-dir=$GITHUB_WORKSPACE/project --with-coverage
~/.config/composer/vendor/bin/sws-caravan phpunit /var/www/html --extension-dir=$GITHUB_WORKSPACE/project --with-coverage
- name: Save Test Results
uses: actions/upload-artifact@v3
if: failure()
Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
STANFORD_ENCRYPT: ${{ secrets.STANFORD_ENCRYPT }}
run: |
composer global require su-sws/stanford-caravan:10.x-dev
~/.composer/vendor/bin/sws-caravan codeception /var/www/html --extension-dir=$GITHUB_WORKSPACE/project --suites=acceptance
~/.config/composer/vendor/bin/sws-caravan codeception /var/www/html --extension-dir=$GITHUB_WORKSPACE/project --suites=acceptance
- name: Save Test Results
uses: actions/upload-artifact@v3
if: always()
Expand Down Expand Up @@ -108,7 +108,7 @@ jobs:
STANFORD_ENCRYPT: ${{ secrets.STANFORD_ENCRYPT }}=
run: |
composer global require su-sws/stanford-caravan:10.x-dev
~/.composer/vendor/bin/sws-caravan codeception /var/www/html --extension-dir=$GITHUB_WORKSPACE/project --suites=functional
~/.config/composer/vendor/bin/sws-caravan codeception /var/www/html --extension-dir=$GITHUB_WORKSPACE/project --suites=functional
- name: Save Test Results
uses: actions/upload-artifact@v3
if: always()
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# SOE Profile

11.1.0
-------------------------------------------------------------------------------
- D8CORE-7096 Update algolia search results styles and structure (#747)
- D8CORE-7074 Implement Search API Algolia (#743)
- D8CORE-6726: Overrode the colorbox formatter template to remove aria-label (#746)
- Update alert styles (#744)
- D8CORE-2761: reduced padding on filterby menu (#728)

11.0.8
-------------------------------------------------------------------------------
- D8CORE-7066 Adjust site contact fields & language (#741)
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
"drupal/page_cache_query_ignore": "^2.2",
"drupal/page_manager": "^4.0@beta",
"drupal/paragraphs": "^1.11",
"drupal/paragraphs_edit": "^2.0@alpha",
"drupal/paragraphs_edit": "^3.0",
"drupal/paranoia": "^1.0@alpha",
"drupal/path_redirect_import": "^2.0",
"drupal/pathauto": "^1.6",
Expand Down Expand Up @@ -161,7 +161,7 @@
"su-sws/stanford_fields": "^8.2",
"su-sws/stanford_media": "^10.0",
"su-sws/stanford_migrate": "^8.3",
"su-sws/stanford_profile_helper": "9.x-dev",
"su-sws/stanford_profile_helper": "^9.4",
"su-sws/stanford_samlauth": "^1.0"
},
"config": {
Expand Down
47 changes: 21 additions & 26 deletions config/sync/search_api.index.algolia_search.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,23 @@ field_settings:
type: string
configuration:
value: '[node:su_event_date_time:value]'
html:
label: 'Rendered HTML output'
property_path: rendered_item
type: string
configuration:
roles:
- authenticated
view_mode:
'entity:node':
stanford_course: search_indexing
stanford_event: search_indexing
stanford_event_series: search_indexing
stanford_news: search_indexing
stanford_page: search_indexing
stanford_person: search_indexing
stanford_policy: search_indexing
stanford_publication: search_indexing
person_full_title:
label: 'Person Full Title'
property_path: custom_value
Expand All @@ -76,23 +93,6 @@ field_settings:
type: string
configuration:
value: '[node:su_page_image:entity:field_media_image:large|node:su_page_banner:entity:su_banner_image:entity:field_media_image:large|node:su_person_photo:entity:field_media_image:large|node:su_news_featured_media:entity:field_media_image:large|node:su_news_banner:entity:field_media_image:large]'
rendered:
label: 'Rendered HTML output'
property_path: rendered_item
type: string
configuration:
roles:
- authenticated
view_mode:
'entity:node':
stanford_course: search_indexing
stanford_event: search_indexing
stanford_event_series: search_indexing
stanford_news: search_indexing
stanford_page: search_indexing
stanford_person: search_indexing
stanford_policy: search_indexing
stanford_publication: search_indexing
status:
label: status
datasource_id: 'entity:node'
Expand Down Expand Up @@ -166,11 +166,11 @@ processor_settings:
- email
- event_end
- event_start
- html
- person_full_title
- person_short_title
- phone
- photo
- rendered
- subheadline
- summary
- title
Expand All @@ -179,15 +179,10 @@ processor_settings:
tags:
- div
- span
- picture
- source
- br
rendered_item: { }
type_boost:
weights:
preprocess_index: 0
boosts:
'entity:node':
datasource_boost: 0.0
bundle_boosts:
stanford_news: 3.0
tracker_settings:
default:
indexing_order: fifo
Expand Down
2 changes: 1 addition & 1 deletion soe_profile.info.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 'SOE Profile'
description: 'Jumpstart Website Profile'
version: 11.0.8
version: 11.1.0
type: profile
project: Stanford
core_version_requirement: ^9 || ^10
Expand Down

Large diffs are not rendered by default.

16 changes: 11 additions & 5 deletions themes/stanford_basic/algolia-search/src/algolia-search.island.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
import algoliasearch from 'algoliasearch/lite';
import {createIslandWebComponent} from 'preact-island'
import {Hits, InstantSearch} from 'react-instantsearch';
import {Hits, HitsProps, InstantSearch} from 'react-instantsearch';
import SearchBox from "./search-box";
import EventHit from "./hits/events";
import NewsHit from "./hits/news";
import DefaultHit from "./hits/default-hit";
import styled from "styled-components";
import {StanfordHit} from "./hits/hit.types";

const islandName = 'algolia-search'
const appId = window.drupalSettings?.stanfordAlgolia.appId || process.env.ALGOLIA_APP_ID
const key = window.drupalSettings?.stanfordAlgolia.searchKey || process.env.ALGOLIA_SEARCH_KEY

const searchClient = algoliasearch(appId, key);

const Hit = ({hit}) => {
if (hit.type === 'Stanford Event') return <EventHit hit={hit}/>
if (hit.type === 'Stanford News') return <NewsHit hit={hit}/>
const Hit = ({hit}: HitsProps<StanfordHit>) => {
if (hit.type === 'Event') return <EventHit hit={hit}/>
if (hit.type === 'News') return <NewsHit hit={hit}/>

return <DefaultHit hit={hit}/>
}

const Container = styled.div`
li {
margin-bottom: 40px;
margin-bottom: 30px;
border-bottom: 1px solid black;
&:last-child {
border-bottom: none;
}
}
`

Expand Down
39 changes: 23 additions & 16 deletions themes/stanford_basic/algolia-search/src/hits/default-hit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@ import {Highlight, Snippet} from "react-instantsearch";
const HitContainer = styled.article`
display: flex;
flex-direction: column;
gap: 40px;
justify-content: left;
padding: 20px;
margin-bottom: 20px;
justify-content: space-between;
gap: 4rem;
padding: 2rem 2rem 2rem 0;
margin-bottom: 2rem;
@media (min-width: 768px) {
flex-direction: row;
}
img {
max-width: 200px;
max-height: 200px;
max-width: 300px;
max-height: 300px;
object-fit: cover;
aspect-ratio: 1;
}
`

Expand All @@ -28,15 +27,14 @@ const DetailsContainer = styled.div`
`

const DefaultHit = ({hit}) => {
const hitUrl = new URL(hit.url);

return (
<HitContainer className="su-card">
{hit.photo &&
<img src={hit.photo} alt=""/>
}
<HitContainer>
<DetailsContainer>
<div>
<h2>
<a href={hit.url}>
<a href={hit.url.replace(hitUrl.origin, '')}>
{hit.title}
</a>
</h2>
Expand All @@ -46,19 +44,28 @@ const DefaultHit = ({hit}) => {
<Highlight hit={hit} attribute="summary"/>
}

{!hit.summary &&
{(!hit.summary && hit.html) &&
<>
...<Snippet hit={hit} attribute="rendered"/>...
...<Snippet hit={hit} attribute="html"/>...
</>
}
</p>
</div>

{hit.updated &&
<div>Last
Updated: {new Date(hit.updated * 1000).toLocaleDateString('en-us', {month: "long", day: "numeric", year: "numeric"})}</div>
<div>
Last
Updated: {new Date(hit.updated * 1000).toLocaleDateString('en-us', {
month: "long",
day: "numeric",
year: "numeric"
})}
</div>
}
</DetailsContainer>
{hit.photo &&
<img src={hit.photo.replace(hitUrl.origin, '')} alt=""/>
}
</HitContainer>
)
}
Expand Down
42 changes: 42 additions & 0 deletions themes/stanford_basic/algolia-search/src/hits/hit.types.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
export type DefaultHit = {
type: 'Basic Page' | 'Course' | 'Event' | 'Event Series' | 'News' | 'Person' | 'Policy' | 'Publication'
url: string
person_full_title?: string
person_short_title?: string
photo?: string
html: string
summary?: string
created: number
status: boolean
title: string
updated: number
}

export type NewsHit = DefaultHit & {
byline?: string
dek?: string
}

export type PersonHit = DefaultHit & {
type: 'Person'
person_full_title?: string
person_short_title?: string
email?: string
phone?: number
}

export type EventHit = DefaultHit & {
type: 'Event'
event_end: number
event_start: number
dek?: string
email?: string
subheadline?: string
}
export type EventSeries = DefaultHit & {
type: 'Event Series'
dek?: string
subheadline?: string
}

export type StanfordHit = EventHit | PersonHit | NewsHit | EventSeries| DefaultHit;
2 changes: 1 addition & 1 deletion themes/stanford_basic/algolia-search/src/search-box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const SearchBox = (props) => {
autoFocus
/>
</div>
<div style={{display: "flex", gap: "10px"}}>
<div style={{display: "flex", gap: "1rem", marginTop: "1rem"}}>
<button type="submit">Submit</button>
<button
type="reset"
Expand Down
14 changes: 11 additions & 3 deletions themes/stanford_basic/stanford_basic.theme
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
* Preprocess functions for Stanford Basic.
*/

use Drupal\Core\Render\Element;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\layout_builder\Plugin\SectionStorage\DefaultsSectionStorage;
use Drupal\Component\Utility\Html;
use Drupal\Core\Block\BlockPluginInterface;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Render\Element;
use Drupal\Core\Url;
use Drupal\layout_builder\Plugin\SectionStorage\DefaultsSectionStorage;

/**
* Implements hook_library_info_alter().
Expand Down Expand Up @@ -226,6 +227,13 @@ function stanford_basic_preprocess_block(&$variables) {
unset($variables['content']);
}
}

if (
!isset($variables['configuration']['label_display']) ||
$variables['configuration']['label_display'] != BlockPluginInterface::BLOCK_LABEL_VISIBLE
) {
$variables['title_attributes']['aria-hidden'] = 'true';
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
{% if not configuration.label_display %}
{% set title_attributes = title_attributes.addClass('visually-hidden') %}
{% endif %}

{{ title_prefix }}
<h2{{ title_attributes.setAttribute('id', heading_id) }}>{{ configuration.label }}</h2>
{{ title_suffix }}
Expand Down

0 comments on commit 97b1ab1

Please sign in to comment.