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

chore: remove sw #199

Merged
merged 2 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
40 changes: 0 additions & 40 deletions web/app/entry.worker.ts

This file was deleted.

731 changes: 730 additions & 1 deletion web/app/licenses.json

Large diffs are not rendered by default.

259 changes: 18 additions & 241 deletions web/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,254 +3,23 @@ import {
Link,
Links,
Meta,
MetaFunction,
Outlet,
Scripts,
ScrollRestoration,
useMatches,
useRevalidator,
useRouteLoaderData,
} from "@remix-run/react";
import type { LinksFunction } from "@remix-run/node";
import { Footer } from "./modules/footer";
import "./tailwind.css";
import { ENV } from "./data/env";
import { BASE_URL } from "./modules/app";
import { useEffect } from "react";
import { unregisterServiceWorker } from "@remix-pwa/sw";
import { rootLinks, rootMeta } from "./route.meta";
import { clog } from "./modules/observability";

export const meta: MetaFunction = ({ location }) => {
// Pseudo-randomly select a cover image based on the length
// of the current path (= stable index per site) and add
// the current day of the week as a seed so that the cover
// changes daily.
const dayOfWeek = new Date().getDay();
const coverIndex = ((location.pathname.length + dayOfWeek) & 9) + 1;
export const meta = rootMeta;

return [
{ title: "CRAN/E" },
{ name: "description", content: "The R package search engine, enhanced" },
{ property: "og:type", content: "website" },
{ property: "og:url", content: BASE_URL },
{
property: "og:image",
content: BASE_URL + `/images/og/cover-${coverIndex}.jpg`,
},
];
};

export const links: LinksFunction = () => {
return [
{
rel: "manifest",
href: "/manifest.webmanifest",
},
{
rel: "icon",
href: "/icons/favicon.ico",
},
{
rel: "icon",
type: "image/png",
sizes: "32x32",
href: "/icons/favicon-32x32.png",
},
{
rel: "icon",
type: "image/png",
sizes: "16x16",
href: "/icons/favicon-16x16.png",
},
{
rel: "mask-icon",
href: "/icons/safari-pinned-tab.svg",
color: "#5bbad5",
},
{
rel: "apple-touch-icon",
href: "/icons/apple-icon-180.png",
},
{
rel: "apple-touch-startup-image",
href: "/icons/apple-splash-2048-2732.jpg",
media:
"(device-width: 1024px) and (device-height: 1366px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)",
},
{
rel: "apple-touch-startup-image",
href: "/icons/apple-splash-2732-2048.jpg",
media:
"(device-width: 1024px) and (device-height: 1366px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)",
},
{
rel: "apple-touch-startup-image",
href: "/icons/apple-splash-1668-2388.jpg",
media:
"(device-width: 834px) and (device-height: 1194px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)",
},
{
rel: "apple-touch-startup-image",
href: "/icons/apple-splash-2388-1668.jpg",
media:
"(device-width: 834px) and (device-height: 1194px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)",
},
{
rel: "apple-touch-startup-image",
href: "/icons/apple-splash-1536-2048.jpg",
media:
"(device-width: 768px) and (device-height: 1024px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)",
},
{
rel: "apple-touch-startup-image",
href: "/icons/apple-splash-2048-1536.jpg",
media:
"(device-width: 768px) and (device-height: 1024px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)",
},
{
rel: "apple-touch-startup-image",
href: "/icons/apple-splash-1668-2224.jpg",
media:
"(device-width: 834px) and (device-height: 1112px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)",
},
{
rel: "apple-touch-startup-image",
href: "/icons/apple-splash-2224-1668.jpg",
media:
"(device-width: 834px) and (device-height: 1112px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)",
},
{
rel: "apple-touch-startup-image",
href: "/icons/apple-splash-1620-2160.jpg",
media:
"(device-width: 810px) and (device-height: 1080px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)",
},
{
rel: "apple-touch-startup-image",
href: "/icons/apple-splash-2160-1620.jpg",
media:
"(device-width: 810px) and (device-height: 1080px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)",
},
{
rel: "apple-touch-startup-image",
href: "/icons/apple-splash-1290-2796.jpg",
media:
"(device-width: 430px) and (device-height: 932px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)",
},
{
rel: "apple-touch-startup-image",
href: "/icons/apple-splash-2796-1290.jpg",
media:
"(device-width: 430px) and (device-height: 932px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)",
},
{
rel: "apple-touch-startup-image",
href: "/icons/apple-splash-1179-2556.jpg",
media:
"(device-width: 393px) and (device-height: 852px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)",
},
{
rel: "apple-touch-startup-image",
href: "/icons/apple-splash-2556-1179.jpg",
media:
"(device-width: 393px) and (device-height: 852px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)",
},
{
rel: "apple-touch-startup-image",
href: "/icons/apple-splash-1284-2778.jpg",
media:
"(device-width: 428px) and (device-height: 926px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)",
},
{
rel: "apple-touch-startup-image",
href: "/icons/apple-splash-2778-1284.jpg",
media:
"(device-width: 428px) and (device-height: 926px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)",
},
{
rel: "apple-touch-startup-image",
href: "/icons/apple-splash-1170-2532.jpg",
media:
"(device-width: 390px) and (device-height: 844px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)",
},
{
rel: "apple-touch-startup-image",
href: "/icons/apple-splash-2532-1170.jpg",
media:
"(device-width: 390px) and (device-height: 844px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)",
},
{
rel: "apple-touch-startup-image",
href: "/icons/apple-splash-1125-2436.jpg",
media:
"(device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)",
},
{
rel: "apple-touch-startup-image",
href: "/icons/apple-splash-2436-1125.jpg",
media:
"(device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)",
},
{
rel: "apple-touch-startup-image",
href: "/icons/apple-splash-1242-2688.jpg",
media:
"(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)",
},
{
rel: "apple-touch-startup-image",
href: "/icons/apple-splash-2688-1242.jpg",
media:
"(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)",
},
{
rel: "apple-touch-startup-image",
href: "/icons/apple-splash-828-1792.jpg",
media:
"(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)",
},
{
rel: "apple-touch-startup-image",
href: "/icons/apple-splash-1792-828.jpg",
media:
"(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)",
},
{
rel: "apple-touch-startup-image",
href: "/icons/apple-splash-1242-2208.jpg",
media:
"(device-width: 414px) and (device-height: 736px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)",
},
{
rel: "apple-touch-startup-image",
href: "/icons/apple-splash-2208-1242.jpg",
media:
"(device-width: 414px) and (device-height: 736px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)",
},
{
rel: "apple-touch-startup-image",
href: "/icons/apple-splash-750-1334.jpg",
media:
"(device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)",
},
{
rel: "apple-touch-startup-image",
href: "/icons/apple-splash-1334-750.jpg",
media:
"(device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)",
},
{
rel: "apple-touch-startup-image",
href: "/icons/apple-splash-640-1136.jpg",
media:
"(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)",
},
{
rel: "apple-touch-startup-image",
href: "/icons/apple-splash-1136-640.jpg",
media:
"(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)",
},
];
};
export const links = rootLinks;

export const loader = async () => {
return json({
Expand All @@ -271,10 +40,10 @@ export default function App() {
return handle?.hasFooter;
});

const revalidator = useRevalidator();
useEffect(() => {
revalidator.revalidate();
// eslint-disable-next-line react-hooks/exhaustive-deps
unregisterServiceWorker().catch(error => {
clog.error("Failed to unregister service worker", error);
});
}, []);

return (
Expand All @@ -283,8 +52,16 @@ export default function App() {
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="msapplication-TileColor" content="#111111" />
<meta name="theme-color" content="#fff" media="(prefers-color-scheme: light)" />
<meta name="theme-color" content="#000" media="(prefers-color-scheme: dark)" />
<meta
name="theme-color"
content="#fff"
media="(prefers-color-scheme: light)"
/>
<meta
name="theme-color"
content="#000"
media="(prefers-color-scheme: dark)"
/>
<meta name="mobile-web-app-capable" content="yes" />
<Meta />
<Links />
Expand Down
Loading