Skip to content

Commit

Permalink
Merge branch '1.x' into SUP-192--media-caption
Browse files Browse the repository at this point in the history
  • Loading branch information
rebeccahongsf committed May 2, 2024
2 parents e6986a2 + d4623d7 commit 93c17b2
Show file tree
Hide file tree
Showing 76 changed files with 3,942 additions and 2,360 deletions.
62 changes: 27 additions & 35 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

additionalRepositories:
- url: https://github.com/SU-SWS/acsf-cardinalsites-public
- url: https://github.com/SU-SWS/ace-stanfordlagunita/
checkoutLocation: back
checkoutLocation: front
ports:
Expand Down Expand Up @@ -30,68 +30,60 @@ tasks:
init: >
eval $(gp env -e APACHE_DOCROOT_IN_REPO=../back/docroot) &&
cd /workspace/back &&
rm -rf config/default &&
mkdir -p config/default &&
touch config/default/core.extension.yml &&
git checkout 2.x &&
composer install --no-interaction &&
mkdir -p blt &&
cp .gitpod/blt.yml blt/local.blt.yml &&
find docroot/sites/ -name 'local*' | xargs rm -rf &&
cp .gitpod/global.settings.php docroot/sites/settings/global.settings.php &&
cp .gitpod/default.local.services.yml docroot/sites/local.services.yml &&
export NEXT_PUBLIC_DRUPAL_BASE_URL=`gp url 8001` &&
export PREVIEW_URL=${NEXT_PUBLIC_DRUPAL_BASE_URL#"https://"} &&
blt blt:telemetry:disable --no-interaction &&
blt settings &&
blt drupal:install -n &&
drush cset system.theme default claro -y &&
blt drupal:install --site=supress -n &&
drush @supress.local cset system.theme default stanford_profile_admin_theme -y &&
cd /workspace/front &&
cp .env.example .env.local &&
sed -i 's/#DRUPAL_REVALIDATE_SECRET/DRUPAL_REVALIDATE_SECRET/' .env.local &&
sed -i 's/#DRUPAL_PREVIEW_SECRET/DRUPAL_PREVIEW_SECRET/' .env.local &&
yarn install
command: |
cd /workspace/back &&
echo 'Restarting Apache' &&
gp ports await 3306 &&
eval $(gp env -e APACHE_DOCROOT_IN_REPO=../back/docroot) &&
apache2ctl restart &&
gp ports await 8001 &&
cd /workspace/back &&
find docroot -name 'local.drush.yml' | xargs rm &&
export NEXT_PUBLIC_DRUPAL_BASE_URL=`gp url 8001` &&
export PREVIEW_URL=${NEXT_PUBLIC_DRUPAL_BASE_URL#"https://"} &&
blt blt:telemetry:disable --no-interaction &&
echo 'Establishing Settings' &&
echo "<?php \$sites['$PREVIEW_URL'] = 'supress';" > docroot/sites/local.sites.php &&
blt settings &&
echo 'Logging Into Drupal' &&
drush uli --uri=$NEXT_PUBLIC_DRUPAL_BASE_URL &&
drush uli --uri=$NEXT_PUBLIC_DRUPAL_BASE_URL | xargs gp preview --external &&
apache2ctl restart &&
gp ports await 8001 &&
drush @supress.local uli --uri=$NEXT_PUBLIC_DRUPAL_BASE_URL &&
drush @supress.local uli --uri=$NEXT_PUBLIC_DRUPAL_BASE_URL | xargs gp preview --external &&
git config core.fileMode false &&
echo 'Connecting Drupal to Frontend' &&
drush su-next-connect "$(gp url 3000)" --preview-secret=DRUPAL_PREVIEW_SECRET --revalidation-secret=DRUPAL_REVALIDATION_SECRET &&
drush @supress.local su-next-connect "$(gp url 3000)" --preview-secret=DRUPAL_PREVIEW_SECRET --revalidation-secret=DRUPAL_REVALIDATION_SECRET &&
cd /workspace/front &&
yarn install &&
yarn config set --home enableTelemetry 0 &&
yarn next telemetry disable &&
sed -i -r "s|NEXT_PUBLIC_DRUPAL_BASE_URL.*|NEXT_PUBLIC_DRUPAL_BASE_URL=$NEXT_PUBLIC_DRUPAL_BASE_URL|g" .env.local &&
yarn dev &
gp ports await 3000 &&
gp url 3000 | xargs gp preview --external
- name: SSH Keys
command: |
rm -rf ~/.ssh/id_rsa &&
rm -rf ~/.ssh/id_rsa.pub &&
eval $(command gp env -e) &&
mkdir -p ~/.ssh &&
[[ ! -z $SSH_PUBLIC_KEY ]] &&
echo $SSH_PUBLIC_KEY | base64 -d > ~/.ssh/id_rsa.pub &&
chmod 644 ~/.ssh/id_rsa.pub &&
[[ ! -z $SSH_PRIVATE_KEY ]] &&
echo $SSH_PRIVATE_KEY | base64 -d > ~/.ssh/id_rsa &&
chmod 600 ~/.ssh/id_rsa &&
cd /workspace/front &&
[[ ! -z $GITCONFIG ]] &&
echo $GITCONFIG | base64 -d > ~/.gitconfig &&
chmod 644 ~/.gitconfig
git remote set-url origin $(echo $GITPOD_WORKSPACE_CONTEXT | jq -r .repository.cloneUrl | sed -E 's|^.*.com/(.*)$|git@github.com:\1|')
before: |
mkdir -p ~/.ssh
if [[ ! -z $SSH_PUBLIC_KEY ]]; then
echo $SSH_PUBLIC_KEY | base64 -d > ~/.ssh/id_rsa.pub && chmod 644 ~/.ssh/id_rsa.pub
git remote set-url origin $(echo $GITPOD_WORKSPACE_CONTEXT | jq -r .repository.cloneUrl | sed -E 's|^.*.com/(.*)$|git@github.com:\1|')
fi
if [[ ! -z $SSH_PRIVATE_KEY ]]; then
echo $SSH_PRIVATE_KEY | base64 -d > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa
fi
if [[ ! -z $GITCONFIG ]]; then
echo $GITCONFIG | base64 -d > ~/.gitconfig && chmod 644 ~/.gitconfig
fi
vscode:
extensions:
- bradlc.vscode-tailwindcss
- bradlc.vscode-tailwindcss
37 changes: 6 additions & 31 deletions .storybook/stories/config-pages/LocalFooter.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ const meta: Meta<ComponentStoryProps> = {
component: LocalFooter,
tags: ['autodocs'],
argTypes: {
suLocalFootLocOp: {
description: "Lockup Options",
options: ['a', 'b', 'd', 'e', 'h', 'i', 'm', 'o', 'p', 'r', 's', 't', 'none'],
control: {type: "select"}
},
suFooterEnabled: {control: "boolean"}
}
};
Expand All @@ -31,49 +26,29 @@ export const LocalFooterDisplay: Story = {
{title: "Action link 1", url: "https://localhost", internal: false},
{title: "Action link 2", url: "https://localhost", internal: false}
],
suLocalFootAddress: {
additionalName: "additional_name",
addressLine1: "address_line1",
addressLine2: "address_line2",
administrativeArea: "administrative_area",
country: {code: "country_code"},
familyName: "family_name",
givenName: "given_name",
locality: "locality",
organization: "organization",
postalCode: "postal_code",
sortingCode: "sorting_code",
},
suLocalFootFButton: "suLocalFoot_f_button",
suLocalFootFIntro: {processed: "suLocalFoot_f_intro"},
suLocalFootFMethod: "suLocalFoot_f_method",
suLocalFootFUrl: {title: "Form Action url", url: "https://localhost", internal: false},
suLocalFootLine1: "suLocalFoot_line_1",
suLocalFootLine2: "suLocalFoot_line_2",
suLocalFootLine3: "suLocalFoot_line_3",
suLocalFootLine4: "suLocalFoot_line_4",
suLocalFootLine5: "suLocalFoot_line_5",
suLocalFootLocImg: null,
suLocalFootLocLink: {title: "suLocalFoot_loc_link", url: "https://localhost", internal: false},
suLocalFootPrCo: {processed: "suLocalFoot_pr_co"},
suLocalFootPrCo: {processed: "First Content Block"},
suLocalFootPrimary: [
{title: "Primary link 1", url: "https://localhost", internal: false},
{title: "Primary link 2", url: "https://localhost", internal: false}
],
suLocalFootPrimeH: "suLocalFoot_prime_h",
suLocalFootSeCo: {processed: "suLocalFoot_se_co"},
suLocalFootPrimeH: "Primary Links Header",
suLocalFootSeCo: {processed: "Second Content Block"},
suLocalFootSecond: [
{title: "Second Link 1", url: "https://localhost", internal: false},
{title: "Second Link 2", url: "https://localhost", internal: false}
],
suLocalFootSecondH: "suLocalFoot_second_h",
suLocalFootSecondH: "Secondary Links Header",
suLocalFootSocial: [
{title: "Facebook", url: "https://localhost", internal: false},
{title: "YouTube", url: "https://localhost", internal: false}
],
suLocalFootSunetT: "suLocalFoot_sunet_t",
suLocalFootTr2Co: {processed: "suLocalFoot_tr2_co"},
suLocalFootTrCo: {processed: "suLocalFoot_tr_co"},
suLocalFootTr2Co: {processed: "Third Content Block"},
suLocalFootTrCo: {processed: "Fourth Content Block"},
suLocalFootUseLoc: true,
suLocalFootUseLogo: true,
suLocalFootLocOp: "suLocalFoot_loc_op",
Expand Down
4 changes: 2 additions & 2 deletions .storybook/stories/storybook-entities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export const getStoryBookImage = (imageUrl?: string): MediaImage => {
width: 1500,
alt: "Placeholder Image",
size: 123,
focalY: 50,
focalX: 50,
focalY: 50
}
}
}
Expand Down Expand Up @@ -61,8 +61,8 @@ export const getStoryBookGalleryImage = (imageUrl?: string, imageCaption?: strin
width: 1500,
alt: "kittens",
size: 123,
focalY: 50,
focalX: 50,
focalY: 50
}
}
}
Expand Down
33 changes: 30 additions & 3 deletions app/[...slug]/metadata.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {Maybe, NodeStanfordEvent, NodeStanfordNews, NodeStanfordPage, NodeStanfordPerson, NodeStanfordPolicy, NodeUnion, ParagraphStanfordWysiwyg, ParagraphUnion} from "@lib/gql/__generated__/drupal.d";
import {Maybe, NodeStanfordEvent, NodeStanfordNews, NodeStanfordPage, NodeStanfordPerson, NodeStanfordPolicy, NodeSupBook, NodeUnion, ParagraphStanfordWysiwyg, ParagraphUnion} from "@lib/gql/__generated__/drupal.d";
import {Metadata} from "next";
import {decode} from "html-entities";

export const getNodeMetadata = (node: NodeUnion): Metadata => {
const defaultData = {
title: node.title,
title: node.title + " | Stanford University Press",
other: {}
}
switch (node.__typename) {
Expand Down Expand Up @@ -37,11 +37,38 @@ export const getNodeMetadata = (node: NodeUnion): Metadata => {
...getPolicyMetaData(node),
...defaultData
}

case "NodeSupBook":
return {
...getBookMetaData(node),
...defaultData
}
}

return defaultData;
}

const getBookMetaData = (node: NodeSupBook) => {
const image = node.supBookImage?.mediaImage;
const description = getCleanDescription(node.supBookDescription?.processed);

return {
description: description,
openGraph: {
type: "book",
title: node.title,
isbn: node.supBookIsbn13Isw || node.supBookIsbn13Paper || node.supBookIsbn13Cloth || node.supBookIsbn13Alt,
authors: node.supBookAuthors?.map(author => ({
"profile:first_name": author.given,
"profile:last_name": author.family
})),
releaseDate: node.supBookPubYearFirst,
description: description,
images: image ? getOpenGraphImage(image.url, image.alt || "") : []
}
}
}

const getBasicPageMetaData = (node: NodeStanfordPage) => {
const pageTitleBannerImage = node.suPageBanner?.__typename === "ParagraphStanfordPageTitleBanner" && node.suPageBanner.suTitleBannerImage.mediaImage;
const bannerImage = node.suPageBanner?.__typename === "ParagraphStanfordBanner" && node.suPageBanner.suBannerImage?.mediaImage;
Expand Down Expand Up @@ -141,7 +168,7 @@ const getFirstText = (components?: Maybe<ParagraphUnion[]>) => {

const getCleanDescription = (description: string | undefined): string | undefined => {
if (description) {
const text: string = description.replace(/(<([^>]+)>)/gi, " ").replace("/ +/", " ").split(".").slice(0, 1).join(".") + ".";
const text: string = description.replace(/(<([^>]+)>)/gi, " ").replace("/ +/", " ").split(".").slice(0, 2).join(".") + ".";
return text?.length > 1 ? decode(text) : undefined;
}
}
Expand Down
6 changes: 3 additions & 3 deletions app/[...slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import NodePage from "@components/nodes/pages/node-page";
import {Metadata} from "next";
import {NodeUnion} from "@lib/gql/__generated__/drupal.d";
import {getAllNodePaths, getEntityFromPath} from "@lib/gql/gql-queries";
import {getAllNodes, getEntityFromPath} from "@lib/gql/gql-queries";
import {getNodeMetadata} from "./metadata";
import {notFound, redirect} from "next/navigation";
import {getPathFromContext, PageProps} from "@lib/drupal/utils";
Expand All @@ -28,8 +28,8 @@ export const generateMetadata = async ({params}: PageProps): Promise<Metadata> =

export const generateStaticParams = async (): Promise<PageProps["params"][]> => {
if (process.env.BUILD_COMPLETE !== "true") return []
const nodePaths = await getAllNodePaths();
return nodePaths.map(path => ({slug: path.split("/").filter(part => !!part)}));
const nodePaths = await getAllNodes();
return nodePaths.map(node => ({slug: node.path.split("/").filter(part => !!part)}));
}

export default Page;
27 changes: 27 additions & 0 deletions app/books/title/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {BooksQuery} from "@lib/gql/__generated__/drupal";
import {graphqlClient} from "@lib/gql/gql-client";
import {notFound, redirect} from "next/navigation";

const LegacyBookPage = async ({searchParams}: { searchParams?: { [_key: string]: string } }) => {
// Fetch all the books, sort by authors, and then build pagination and side alpha selection.
let fetchMore = true;
let query: BooksQuery;
let afterCursor = null;
let destinationUrl: string | undefined;

if (!searchParams || !searchParams.id) notFound();
const workId = parseInt(searchParams.id);

while (fetchMore) {
query = await graphqlClient({next: {tags: ["views:sup_books"]}}).Books({after: afterCursor})

destinationUrl = query.nodeSupBooks.nodes.find(node => node.supBookWorkIdNumber && node.supBookWorkIdNumber === workId)?.path;

fetchMore = query.nodeSupBooks.pageInfo.hasNextPage && !destinationUrl
afterCursor = query.nodeSupBooks.pageInfo.endCursor;
}
if (destinationUrl) redirect(destinationUrl);
notFound();
}

export default LegacyBookPage;
8 changes: 4 additions & 4 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import BackToTop from "@components/elements/back-to-top";
import PageFooter from "@components/global/page-footer";
import PageHeader from "@components/global/page-header";
import {Icon} from "next/dist/lib/metadata/types/metadata-types";
import {sourceSans3} from "../src/styles/fonts";
import {montserrat} from "../src/styles/fonts";
import DrupalWindowSync from "@components/elements/drupal-window-sync";
import {isPreviewMode} from "@lib/drupal/utils";
import UserAnalytics from "@components/elements/user-analytics";
Expand All @@ -27,8 +27,8 @@ export const metadata = {
openGraph: {
type: "website",
locale: "en_IE",
url: "https://somesite.stanford.edu",
siteName: "[Stanford University]",
url: "https://sup.org",
siteName: "Stanford University Press",
},
twitter: {
card: "summary_large_image",
Expand All @@ -45,7 +45,7 @@ export const revalidate = false;
const RootLayout = ({children, modal}: { children: React.ReactNode, modal: React.ReactNode }) => {
const isPreview = isPreviewMode();
return (
<html lang="en" className={sourceSans3.className}>
<html lang="en" className={montserrat.className}>
{/* Add Google Analytics and SiteImprove when not in preview mode. */}
{!isPreview &&
<UserAnalytics/>
Expand Down
Loading

0 comments on commit 93c17b2

Please sign in to comment.