diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8d5a5b4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM oven/bun:alpine + +ENV HOSTNAME localhost + +WORKDIR /startpage + +COPY assets ./assets +COPY src ./src +COPY package.json ./ + +HEALTHCHECK --interval=5s --timeout=5s --retries=3 CMD wget --spider -q http://0.0.0.0/healthcheck || exit 1 + +ENTRYPOINT [ "bun", "start" ] diff --git a/README.md b/README.md index 3c222e7..68cc221 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,27 @@ -# startpage -My startpage, edited from github.com/kencx +
+ +

Startpage

+
-# How to use? +# Getting Started -1. git clone this repo -2. copy the path to the index.html file -3. set the path as your default startpage in your desired browser +## Using bun.sh -# Customization +``` +bun start +``` -### Image(s) -i have included a few vaporwave/retro styled gifs in this repo, you can edit it on the line 22 in the index.html the ```src="clouds.gif"``` to something like ```src="plane.gif"``` or your own image/gif +## Using docker-compose -### URLs -you can edit all of the URLs to your desired, starting on line **44** in ```index.html``` -
**Example:**
-**line 45:** ```
  • github
  • ```
    can be changed to
    **line 45:** ```
  • your url
  • ``` +``` +docker-compose up --build +``` -### Categories +# Customize -i think you get it, starting on line **44** you can change the names of the categories etc. etc. i believe you're not dumb and understand +Everything is static, just modify the content as you want in `src/` or `assets`. -# Screenshot -![image](https://user-images.githubusercontent.com/76164598/170824479-5918fe82-18df-4549-8b20-c2b1595a27d0.png) +# Contributors + +- [Siklos/Hydroxycarbamide](https://git.siklos-chaneru.dev/Siklos) +- [Woox](https://github.com/nwvh) diff --git a/fonts/Ubuntu-Regular.ttf b/assets/fonts/Ubuntu-Regular.ttf similarity index 100% rename from fonts/Ubuntu-Regular.ttf rename to assets/fonts/Ubuntu-Regular.ttf diff --git a/bike.gif b/assets/img/bike.gif similarity index 100% rename from bike.gif rename to assets/img/bike.gif diff --git a/cat.gif b/assets/img/cat.gif similarity index 100% rename from cat.gif rename to assets/img/cat.gif diff --git a/clouds.gif b/assets/img/clouds.gif similarity index 100% rename from clouds.gif rename to assets/img/clouds.gif diff --git a/plane.gif b/assets/img/plane.gif similarity index 100% rename from plane.gif rename to assets/img/plane.gif diff --git a/rest.webp b/assets/img/rest.webp similarity index 100% rename from rest.webp rename to assets/img/rest.webp diff --git a/vapor.gif b/assets/img/vapor.gif similarity index 100% rename from vapor.gif rename to assets/img/vapor.gif diff --git a/vaporwave.gif b/assets/img/vaporwave.gif similarity index 100% rename from vaporwave.gif rename to assets/img/vaporwave.gif diff --git a/waves.gif b/assets/img/waves.gif similarity index 100% rename from waves.gif rename to assets/img/waves.gif diff --git a/bun.lockb b/bun.lockb index 5c52b96..812ea43 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..e31e179 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,7 @@ +services: + app: + image: startpage + build: . + restart: unless-stopped + ports: + - "8080:80" diff --git a/index.ts b/index.ts deleted file mode 100644 index 20e2cc4..0000000 --- a/index.ts +++ /dev/null @@ -1,48 +0,0 @@ -console.log("Hello World!"); - -const fetch = (req: Request) => { - const url = new URL(req.url); - const path = url.pathname; - - if (path === "/") { - return new Response(Bun.file("./index.html"), { - headers: { - "Content-Type": "text/html" - } - }); - } else if (path === "/style.css") { - return new Response(Bun.file("./style.css"), { - headers: { - "Content-Type": "text/css" - } - }); - } else if (path === "/cat.gif") { - return new Response(Bun.file("./cat.gif"), { - headers: { - "Content-Type": "image/gif" - } - }); - } else if (path === "/favicon.ico") { - return new Response(Bun.file("./favicon.ico"), { - headers: { - "Content-Type": "image/x-icon" - } - }) - } else if (path.startsWith('/fonts/')) { - const fontPath = path.slice('/fonts/'.length); - return new Response(Bun.file(`./fonts/${fontPath}`), { - headers: { - "Content-Type": "application/octet-stream" - } - }) - } - - return new Response("404!"); -} - -Bun.serve({ - port: Bun.env.PORT || 80, - hostname: Bun.env.HOSTNAME || "localhost", - fetch -}); - diff --git a/package.json b/package.json index 96710f6..ef1b5ed 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,14 @@ { "name": "startpage", - "module": "index.ts", + "module": "./src/index.ts", "type": "module", + "scripts": { + "start": "bun run ./src/index.ts" + }, "devDependencies": { - "bun-types": "latest" + "bun-types": "^1.1.31" }, "peerDependencies": { - "typescript": "^5.0.0" + "typescript": "^5.6.3" } -} \ No newline at end of file +} diff --git a/index.html b/src/index.html similarity index 100% rename from index.html rename to src/index.html diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..37cf779 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,38 @@ +const fetch = (req: Request) => { + const url = new URL(req.url); + const path = url.pathname; + + if (path.startsWith('/fonts/')) { + const fontPath = path.slice('/fonts/'.length); + return new Response(Bun.file(`./assets/fonts/${fontPath}`), { + headers: { + "Content-Type": "application/octet-stream" + } + }) + } + + return new Response("404!"); +}; + +Bun.serve({ + port: Bun.env.PORT || 80, + static: { + "/healthcheck": new Response("All good!"), + "/": new Response(await Bun.file("./src/index.html").bytes(), { + headers: { + "Content-Type": "text/html", + }, + }), + "/style.css": new Response(await Bun.file("./src/style.css").bytes(), { + headers: { + "Content-Type": "text/css" + }, + }), + "/cat.gif": new Response(await Bun.file("./assets/img/cat.gif").bytes(), { + headers: { + "Content-Type": "image/gif", + }, + }), + }, + fetch, +}); diff --git a/style.css b/src/style.css similarity index 100% rename from style.css rename to src/style.css