diff --git a/.env.example b/.env.example deleted file mode 100644 index d2b3d15..0000000 --- a/.env.example +++ /dev/null @@ -1,7 +0,0 @@ -# NODE_ENV=development -HOST=0.0.0.0 -PORT=8080 - -# this is only the default value if non is give in /id -LANYARD_USER_ID=id-here -LANYARD_INSTANCE=https://lanyard.rest diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..25117cc --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "github-enterprise.uri": "https://git.creations.works" +} diff --git a/logs/2025-4-6.log b/logs/2025-4-6.log new file mode 100644 index 0000000..d3457ef --- /dev/null +++ b/logs/2025-4-6.log @@ -0,0 +1,16 @@ +2025-04-06 21:35:30.351 [INFO] (server.ts:40:10) Server running at http://0.0.0.0:8080 +2025-04-06 21:35:30.402 [INFO] (server.ts:49:10) Available routes: +2025-04-06 21:35:30.410 [INFO] (server.ts:58:11) Route: /[id], File: C:/Users/exode/Documents/profilePage/src/routes/[id].ts +2025-04-06 21:35:30.409 [INFO] (server.ts:58:11) Route: /, File: C:/Users/exode/Documents/profilePage/src/routes/index.ts +2025-04-06 21:36:00.076 [INFO] (server.ts:40:10) Server running at http://0.0.0.0:8080 +2025-04-06 21:36:00.081 [INFO] (server.ts:58:11) Route: /[id], File: C:/Users/exode/Documents/profilePage/src/routes/[id].ts +2025-04-06 21:36:00.080 [INFO] (server.ts:49:10) Available routes: +2025-04-06 21:36:00.081 [INFO] (server.ts:58:11) Route: /, File: C:/Users/exode/Documents/profilePage/src/routes/index.ts +2025-04-06 21:36:35.063 [INFO] (server.ts:40:10) Server running at http://0.0.0.0:8080 +2025-04-06 21:36:35.066 [INFO] (server.ts:49:10) Available routes: +2025-04-06 21:36:35.067 [INFO] (server.ts:58:11) Route: /[id], File: C:/Users/exode/Documents/profilePage/src/routes/[id].ts +2025-04-06 21:36:35.067 [INFO] (server.ts:58:11) Route: /, File: C:/Users/exode/Documents/profilePage/src/routes/index.ts +2025-04-06 21:37:16.785 [INFO] (server.ts:40:10) Server running at http://0.0.0.0:8080 +2025-04-06 21:37:16.789 [INFO] (server.ts:58:11) Route: /[id], File: C:/Users/exode/Documents/profilePage/src/routes/[id].ts +2025-04-06 21:37:16.789 [INFO] (server.ts:58:11) Route: /, File: C:/Users/exode/Documents/profilePage/src/routes/index.ts +2025-04-06 21:37:16.788 [INFO] (server.ts:49:10) Available routes: diff --git a/public/css/index.css b/public/css/index.css index 7c8c2e7..da470b9 100644 --- a/public/css/index.css +++ b/public/css/index.css @@ -224,6 +224,38 @@ ul { color: #f0b232; } +.activity-buttons { + display: flex; + flex-wrap: wrap; + gap: 0.5rem; + margin-top: 0.75rem; +} + +.activity-button { + background-color: #5865f2; + color: white; + border: none; + border-radius: 3px; + padding: 0.5rem 1rem; + font-size: 0.9rem; + cursor: pointer; + text-decoration: none; + transition: background-color 0.2s ease; + display: inline-block; +} + +.activity-button:hover { + background-color: #4752c4; + text-decoration: none; +} + +.activity-button.disabled { + background-color: #4e5058; + cursor: default; + pointer-events: none; + opacity: 0.8; +} + @media (max-width: 600px) { html { font-size: clamp(14px, 2vw, 16px); @@ -338,6 +370,17 @@ ul { margin-top: 0.25rem; width: 100%; } + + .activity-buttons { + justify-content: center; + margin-top: 0.5rem; + width: 100%; + } + + .activity-button { + font-size: 0.85rem; + padding: 0.4rem 0.8rem; + } } /* readme :p */ diff --git a/public/js/index.js b/public/js/index.js index 1c54724..6feec74 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -156,6 +156,26 @@ function buildActivityHTML(activity) { ` : ""; + const activityButtons = activity.buttons && activity.buttons.length > 0 + ? `
+ ${activity.buttons.map((button, index) => { + const buttonLabel = typeof button === 'string' ? button : button.label; + let buttonUrl = null; + if (typeof button === 'object' && button.url) { + buttonUrl = button.url; + } + else if (index === 0 && activity.url) { + buttonUrl = activity.url; + } + if (buttonUrl) { + return `${buttonLabel}`; + } else { + return `${buttonLabel}`; + } + }).join('')} +
` + : ''; + return `
  • ${art ? `Art` : ""} @@ -166,6 +186,7 @@ function buildActivityHTML(activity) { ${activity.details ? `
    ${activity.details}
    ` : ""} ${activity.state ? `
    ${activity.state}
    ` : ""} + ${activityButtons} ${progressBar}
  • diff --git a/src/server.ts b/src/server.ts index 3f78cb5..13ae2ba 100644 --- a/src/server.ts +++ b/src/server.ts @@ -34,13 +34,23 @@ class ServerHandler { open: webSocketHandler.handleOpen.bind(webSocketHandler), message: webSocketHandler.handleMessage.bind(webSocketHandler), close: webSocketHandler.handleClose.bind(webSocketHandler), + error(error) { + logger.error(`Server error: ${error.message}`); + return new Response(`Server Error: ${error.message}`, { + status: 500, + }); + }, }, }); - logger.info( - `Server running at http://${server.hostname}:${server.port}`, - true, - ); + const accessUrls = [ + `http://${server.hostname}:${server.port}`, + `http://localhost:${server.port}`, + `http://127.0.0.1:${server.port}`, + ]; + + logger.info(`Server running at ${accessUrls[0]}`, true); + logger.info(`Access via: ${accessUrls[1]} or ${accessUrls[2]}`, true); this.logRoutes(); } diff --git a/src/views/index.ejs b/src/views/index.ejs index a77b12a..6790bb5 100644 --- a/src/views/index.ejs +++ b/src/views/index.ejs @@ -102,6 +102,27 @@
    <%= activity.state %>
    <% } %> + <% if (activity.buttons && activity.buttons.length > 0) { %> +
    + <% activity.buttons.forEach((button, index) => { + const buttonLabel = typeof button === 'string' ? button : button.label; + let buttonUrl = null; + if (typeof button === 'object' && button.url) { + buttonUrl = button.url; + } + else if (index === 0 && activity.url) { + buttonUrl = activity.url; + } + %> + <% if (buttonUrl) { %> + <%= buttonLabel %> + <% } else { %> + <%= buttonLabel %> + <% } %> + <% }); %> +
    + <% } %> + <% if (progress !== null) { %>
    >