Skip to content

Commit 61db23f

Browse files
committed
Add old personal site to browser links when available
1 parent 7e8f93f commit 61db23f

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

components/apps/Browser/config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { type ProxyState } from "components/apps/Browser/useProxyMenu";
2+
import { get9pModifiedTime } from "contexts/fileSystem/core";
23
import { FAVICON_BASE_PATH } from "utils/constants";
34

45
type Bookmark = {
@@ -19,6 +20,14 @@ export const DINO_GAME = {
1920
url: "chrome://dino",
2021
};
2122

23+
export const SURF_TO_MISC = {
24+
icon: "/Users/Public/Documents/OldSite/favicon.ico",
25+
name: "The Ultimate Misc Page",
26+
path: "/Users/Public/Documents/OldSite/index.html",
27+
// eslint-disable-next-line sonarjs/no-clear-text-protocols
28+
url: "http://surf.to/misc",
29+
};
30+
2231
export const bookmarks: Bookmark[] = [
2332
{
2433
icon: FAVICON_BASE_PATH,
@@ -30,6 +39,7 @@ export const bookmarks: Bookmark[] = [
3039
name: "Index of /",
3140
url: "http://localhost/",
3241
},
42+
...(get9pModifiedTime(SURF_TO_MISC.path) === -1 ? [] : [SURF_TO_MISC]),
3343
DINO_GAME,
3444
{
3545
icon: "/System/Icons/Favicons/google.webp",

components/apps/Browser/index.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
HOME_PAGE,
2323
NOT_FOUND,
2424
PROXIES,
25+
SURF_TO_MISC,
2526
bookmarks,
2627
} from "components/apps/Browser/config";
2728
import { type ComponentProcessProps } from "components/system/Apps/RenderComponent";
@@ -134,13 +135,23 @@ const Browser: FC<ComponentProcessProps> = ({ id }) => {
134135
if (isHtml) setSrcDoc((await readFile(addressInput)).toString());
135136
setIcon(id, processDirectory.Browser.icon);
136137

137-
if (addressInput.toLowerCase().startsWith(DINO_GAME.url)) {
138+
const loadLocalSite = (localPath: string, localTitle: string): void => {
139+
iframeRef.current?.removeAttribute("sandbox");
138140
changeIframeWindowLocation(
139-
`${window.location.origin}${DINO_GAME.path}`,
141+
`${window.location.origin}${localPath}`,
140142
contentWindow
141143
);
142-
prependFileToTitle(`${DINO_GAME.url}/`);
144+
prependFileToTitle(localTitle);
145+
};
146+
const lowerAddressInput = addressInput.toLowerCase();
147+
148+
if (lowerAddressInput.startsWith(SURF_TO_MISC.url)) {
149+
loadLocalSite(SURF_TO_MISC.path, SURF_TO_MISC.name);
150+
} else if (lowerAddressInput.startsWith(DINO_GAME.url)) {
151+
loadLocalSite(DINO_GAME.path, `${DINO_GAME.url}/`);
143152
} else if (!isHtml) {
153+
iframeRef.current?.setAttribute("sandbox", IFRAME_CONFIG.sandbox);
154+
144155
const processedUrl = await getUrlOrSearch(addressInput);
145156

146157
if (

0 commit comments

Comments
 (0)