Skip to content

Commit

Permalink
baseUrl change plus levelsofday combine
Browse files Browse the repository at this point in the history
  • Loading branch information
k2xl committed Dec 17, 2023
1 parent 93658c6 commit 4d71c10
Show file tree
Hide file tree
Showing 16 changed files with 66 additions and 57 deletions.
5 changes: 3 additions & 2 deletions components/gameLogo.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { GameId } from '@root/constants/GameId';
import { AppContext } from '@root/contexts/appContext';
import { getGameFromId } from '@root/helpers/getGameIdFromReq';
import Image from 'next/image';
import React from 'react';
import React, { useContext } from 'react';
import StyledTooltip from './page/styledTooltip';

interface GameLogoProps {
Expand All @@ -21,7 +22,7 @@ export default function GameLogo({ gameId, id, size = 24, tooltip = false }: Gam
data-tooltip-content={game.displayName}
data-tooltip-id={tooltipId}
height={size}
src={game.logo}
src={game.baseUrl + game.logo}
style={{
width: size,
height: size,
Expand Down
4 changes: 2 additions & 2 deletions components/modal/postGameModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ export default function PostGameModal({ chapter, closeModal, collection, dontSho
setQueryParams(new URLSearchParams(window.location.search));
}, []);

const url = `https://${game.baseUrl}/level/${level.slug}`;
const quote = 'Just completed ' + game.baseUrl + ' puzzle "' + level.name + '" (Difficulty: ' + getDifficultyFromValue(level.calc_difficulty_estimate).name + ')';
const url = `${game.baseUrl}/level/${level.slug}`;
const quote = 'Just completed ' + game.displayName + ' puzzle "' + level.name + '" (Difficulty: ' + getDifficultyFromValue(level.calc_difficulty_estimate).name + ')';

function nextActionCard() {
if (nextLevel) {
Expand Down
6 changes: 3 additions & 3 deletions constants/Games.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export enum GameType {
export const Games: Record<GameId, Game> = {
[GameId.THINKY]: {
id: GameId.THINKY,
baseUrl: 'thinky.gg',
baseUrl: process.env.NODE_ENV !== 'development' ? 'https://thinky.gg' : 'http://localhost:3000',
defaultTheme: Theme.Dark,
displayName: 'Thinky.gg',
disableCampaign: true,
Expand All @@ -35,7 +35,7 @@ export const Games: Record<GameId, Game> = {
},
[GameId.PATHOLOGY]: {
id: GameId.PATHOLOGY,
baseUrl: 'pathology.gg',
baseUrl: process.env.NODE_ENV !== 'development' ? 'https://pathology.thinky.gg' : 'http://pathology.localhost:3000',
defaultTheme: Theme.Modern,
displayName: 'Pathology',
favicon: '/logos/pathology/logo.svg',
Expand All @@ -51,7 +51,7 @@ export const Games: Record<GameId, Game> = {
},
[GameId.SOKOBAN]: {
id: GameId.SOKOBAN,
baseUrl: 'sokoban.pathology.gg',
baseUrl: process.env.NODE_ENV !== 'development' ? 'https://sokoban.thinky.gg' : 'http://sokoban.localhost:3000',
disableCampaign: true,
disableCommunityCampaigns: true,
disableMultiplayer: true,
Expand Down
74 changes: 41 additions & 33 deletions helpers/getEmailBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ export default function getEmailBody({
padding: 20,
textAlign: 'center',
}}>
<a href={`https://${game.baseUrl}`}>
<a href={`${game.baseUrl}`}>
{/* eslint-disable-next-line @next/next/no-img-element */}
<img src='https://i.imgur.com/fD1SUrZ.png' alt={game.displayName} />
</a>
<h1>Hi {user.name},</h1>
<p>{title}</p>
{notificationsCount > 0 && (
<p>You have <a href={'https://' + game.baseUrl + '/notifications?source=email-digest&filter=unread'} style={{
<p>You have <a href={game.baseUrl + '/notifications?source=email-digest&filter=unread'} style={{
color: '#4890ce',
textDecoration: 'none',
}}>{notificationsCount} unread notification{notificationsCount !== 1 ? 's' : ''}</a></p>
Expand All @@ -101,40 +101,48 @@ export default function getEmailBody({
{featuredLevels &&
<div>
<h2>{featuredLevelsLabel}</h2>
{featuredLevels.filter(level => level).map((level) => (
<div key={level._id.toString()} style={{
textAlign: 'center',
}}>
<GameLogoAndLabel id={level._id.toString()} gameId={level.gameId} /> {getGameFromId(level.gameId).displayName} {level.userId.name}
<a href={`https://${getGameFromId(level.gameId).baseUrl}/level/${level.slug}`} style={{
color: '#4890ce',
textDecoration: 'none',
}}>
{level.name}
</a>
{' by '}
<a href={`https://${getGameFromId(level.gameId).baseUrl}/profile/${encodeURI(level.userId.name)}`} style={{
color: '#4890ce',
textDecoration: 'none',
}} />
<div style={{
padding: 20,
}}>
<a href={`https://${getGameFromId(level.gameId).baseUrl}/level/${level.slug}`} style={{
color: '#4890ce',
textDecoration: 'none',
}}>
{/* eslint-disable-next-line @next/next/no-img-element */}
<img src={`https://${getGameFromId(level.gameId).baseUrl}/api/level/image/${level._id}.png`} width='100%' alt={level.name} />
</a>
</div>
</div>
))}
<table role='presentation' cellPadding='0' cellSpacing='0' style={{
width: '100%',
}}>
<tr>
{featuredLevels.filter(level => level).map((level) => (
<td key={level._id.toString()}>
<div style={{
textAlign: 'center',
}}>
<GameLogoAndLabel id={level._id.toString()} gameId={level.gameId} />
<a href={`${getGameFromId(level.gameId).baseUrl}/level/${level.slug}`} style={{
color: '#4890ce',
textDecoration: 'none',
}}>
{level.name}
</a>
{' by '}
<a href={`${getGameFromId(level.gameId).baseUrl}/profile/${encodeURI(level.userId.name)}`} style={{
color: '#4890ce',
textDecoration: 'none',
}} />
<div style={{
padding: 20,
}}>
<a href={`${getGameFromId(level.gameId).baseUrl}/level/${level.slug}`} style={{
color: '#4890ce',
textDecoration: 'none',
}}>
{/* eslint-disable-next-line @next/next/no-img-element */}
<img src={`${getGameFromId(level.gameId).baseUrl}/api/level/image/${level._id}.png`} width='100%' alt={level.name} />
</a>
</div>
</div>
</td>
))}
</tr>
</table>
</div>

}
<p>
Thanks for playing <a href={`https://${game.baseUrl}`} style={{
Thanks for playing <a href={`${game.baseUrl}`} style={{
color: '#4890ce',
textDecoration: 'none',
}}>{game.displayName}</a>!
Expand All @@ -148,7 +156,7 @@ export default function getEmailBody({
color: '#4890ce',
textDecoration: 'none',
}}>{game.displayName} Discord</a> to chat with other players and the developers!</p>
<p><a href={`https://${game.baseUrl}/settings/notifications`} style={{
<p><a href={`${game.baseUrl}/settings/notifications`} style={{
color: '#4890ce',
textDecoration: 'none',
}}>Manage your email notification settings</a></p>
Expand Down
2 changes: 1 addition & 1 deletion helpers/getMobileNotification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function getNewReviewOnYourLevelBody(message?: string) {
/* notification must be populated using getEnrichNotificationPipelineStages */
export default function getMobileNotification(gameId: GameId, notification: Notification) {
const game = Games[gameId];
const host = 'https://' + game.baseUrl;
const host = game.baseUrl;
const mobileNotification = {
badgeCount: 1,
title: game.displayName + ' - New Notification',
Expand Down
4 changes: 2 additions & 2 deletions helpers/refreshAchievements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ export async function refreshAchievements(gameId: GameId, userId: Types.ObjectId
if (achievementInfo.discordNotification) {
// Should be "<User.name> just unlocked <Achievement.name> achievement!" where <User.name> is a link to the user's profile and <Achievement.name> is a link to the achievement's page
const userName = user?.name;
const userHref = 'https://' + game.baseUrl + '/profile/' + userName;
const userHref = game.baseUrl + '/profile/' + userName;
const userLinkDiscord = `[${userName}](${userHref})`;
const achievementHref = 'https://' + game.baseUrl + '/achievement/' + achievementType;
const achievementHref = game.baseUrl + '/achievement/' + achievementType;
const achievementLinkDiscord = `[${achievementInfo.name}](${achievementHref})`;
// message should also include emoji
const message = `**${game.displayName}** - ${userLinkDiscord} just unlocked the ${achievementLinkDiscord} ${achievementInfo.emoji} achievement!`;
Expand Down
2 changes: 1 addition & 1 deletion pages/[subdomain]/collection/[username]/[slugName].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export default function CollectionPage({ collection }: CollectionProps) {
<NextSeo
title={`${collection.name} - ${game.displayName}`}
description={collection.authorNote}
canonical={`https://${game.baseUrl}/collection/${collection.slug}`}
canonical={`${game.baseUrl}/collection/${collection.slug}`}
openGraph={{
title: `${collection.name} - ${game.displayName}`,
description: collection.authorNote,
Expand Down
2 changes: 1 addition & 1 deletion pages/[subdomain]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export default function HomePage({ user }: HomePageProps) {
description: game.SEODescription,
images: [
{
url: 'https://' + game.baseUrl + game.logo,
url: '' + game.baseUrl + game.logo,
width: 128,
height: 128,
alt: game.displayName + ' Logo',
Expand Down
6 changes: 3 additions & 3 deletions pages/[subdomain]/level/[username]/[slugName].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,9 @@ export default function LevelPage({ _collection, _level, reqUser }: LevelProps)

// subtitle is only useful when a level is within a collection created by a different user
const showSubtitle = collection && (collection.userId._id !== level.userId._id);
const ogImageUrl = `https://${game.baseUrl}/api/level/image/${level._id.toString()}.png${ts ? `?ts=${ts}` : ''}`;
const ogUrl = `https://${game.baseUrl}/level/${level.slug}`;
const ogFullUrl = `https://${game.baseUrl}${ogUrl}`;
const ogImageUrl = `${game.baseUrl}/api/level/image/${level._id.toString()}.png${ts ? `?ts=${ts}` : ''}`;
const ogUrl = `${game.baseUrl}/level/${level.slug}`;
const ogFullUrl = `${game.baseUrl}${ogUrl}`;
const authorNote = level.authorNote ? level.authorNote : `${level.name} by ${level.userId.name}`;

return (
Expand Down
2 changes: 1 addition & 1 deletion pages/[subdomain]/multiplayer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function MultiplayerPage() {
<NextSeo
title={'Multiplayer - ' + game.displayName}
description={'Play ' + game.displayName + ' in real time against other players'}
canonical={`https://${game.baseUrl}/multiplayer`}
canonical={`${game.baseUrl}/multiplayer`}
/>
<Multiplayer />
</>
Expand Down
2 changes: 1 addition & 1 deletion pages/[subdomain]/profile/[name]/[[...tab]]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ export default function ProfilePage({
<NextSeo
title={`${user.name} - ${game.displayName}`}
description={`${user.name}'s profile`}
canonical={'https://' + game.baseUrl + getProfileSlug(user) + '/' + profileTab}
canonical={game.baseUrl + getProfileSlug(user) + '/' + profileTab}
openGraph={{
title: `${user.name} - ${game.displayName}}`,
description: `${user.name}'s profile`,
Expand Down
2 changes: 1 addition & 1 deletion pages/[subdomain]/search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ export default function Search({ enrichedLevels, reqUser, searchAuthor, searchQu
return (<>
<NextSeo
title={'Search - ' + game.displayName}
canonical={'https://' + game.baseUrl + '/search'}
canonical={game.baseUrl + '/search'}
openGraph={{
title: 'Search - ' + game.displayName,
type: 'article',
Expand Down
2 changes: 1 addition & 1 deletion pages/[subdomain]/tutorial/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function TutorialPage() {
return (<>
<NextSeo
title={'Tutorial - ' + game.displayName}
canonical={`https://${game.baseUrl}/tutorial`}
canonical={`${game.baseUrl}/tutorial`}
openGraph={{
title: 'Tutorial - ' + game.displayName,
description: 'Learn how to play ' + game.displayName + ' - The sokoban style mind-bending puzzle game',
Expand Down
2 changes: 1 addition & 1 deletion pages/[subdomain]/users/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ export default function PlayersPage({ searchQuery, totalRows, users }: PlayersPr
return (<>
<NextSeo
title={'Users - ' + game.displayName}
canonical={`https://${game.baseUrl}/users`}
canonical={`${game.baseUrl}/users`}
openGraph={{
title: 'Users - ' + game.displayName,
type: 'article',
Expand Down
6 changes: 3 additions & 3 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -413,15 +413,15 @@ export default function MyApp({ Component, pageProps, userAgent, initGame }: App
<DefaultSeo
defaultTitle={selectedGame.displayName + ' - Shortest Path Puzzle Game'}
description={selectedGame.SEODescription}
canonical={`https://${selectedGame.baseUrl}'`}
canonical={`${selectedGame.baseUrl}'`}
openGraph={{
type: 'website',
url: `https://${selectedGame.baseUrl}'`,
url: `${selectedGame.baseUrl}'`,
siteName: selectedGame.displayName,
}}
twitter={{
handle: '@pathologygame',
site: 'https://' + selectedGame.baseUrl,
site: '' + selectedGame.baseUrl,
cardType: 'summary_large_image'
}}
/>
Expand Down
2 changes: 1 addition & 1 deletion tests/pages/api/notification/notification.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ describe('Notifications', () => {

expect(data.title).toBe(Games[DEFAULT_GAME_ID].displayName + ' - New Review');
expect(data.body).toBe('BBB gave a 4 star rating on your level test level 1');
expect(data.url).toEqual('https://' + Games[DEFAULT_GAME_ID].baseUrl + '/level/test/test-level-1');
expect(data.url).toEqual( Games[DEFAULT_GAME_ID].baseUrl + '/level/test/test-level-1');
},
});
});
Expand Down

0 comments on commit 4d71c10

Please sign in to comment.