From c54d959e7e97c38cef9048e3b581d6a93271ae8e Mon Sep 17 00:00:00 2001 From: creations Date: Wed, 9 Apr 2025 18:35:08 -0400 Subject: [PATCH] fix issue with rain and snow, fix ejs formatting --- src/routes/index.ts | 9 ++- src/views/index.ejs | 152 +++++++++++++++++++++++--------------------- 2 files changed, 85 insertions(+), 76 deletions(-) diff --git a/src/routes/index.ts b/src/routes/index.ts index 7f12f0a..d4c8d97 100644 --- a/src/routes/index.ts +++ b/src/routes/index.ts @@ -37,6 +37,8 @@ async function handler(): Promise { status = presence.discord_status; } + console.log(presence.kv.rain); + const ejsTemplateData: EjsTemplateData = { title: presence.discord_user.global_name || presence.discord_user.username, username: @@ -51,10 +53,13 @@ async function handler(): Promise { }, instance, readme, - allowSnow: presence.kv.snow || false, - allowRain: presence.kv.rain || false, + allowSnow: presence.kv.snow === "true", + allowRain: presence.kv.rain === "true", }; + console.log("allowSnow", presence.kv.snow); + console.log("allowRain", presence.kv.rain); + return await renderEjsTemplate("index", ejsTemplateData); } diff --git a/src/views/index.ejs b/src/views/index.ejs index d4f2be3..2d15947 100644 --- a/src/views/index.ejs +++ b/src/views/index.ejs @@ -1,5 +1,6 @@ + @@ -13,29 +14,31 @@ + <%= typeof allowSnow %> <%= allowSnow %> <% if (allowSnow) { %> - + <% } %> <% if(allowRain) { %> - + <% } %> +
Avatar <% if (user.avatar_decoration_data) { %> - Decoration + Decoration <% } %> <% if (platform.mobile) { %> - - - + + + <% } else { %> -
+
<% } %>
@@ -121,51 +124,51 @@ ? "Listening to TIDAL" : activityTypeMap[activity.type] || "Playing"; %> -
  • -
    -
    - <%= activityType %> - <% if (start && progress === null) { %> -
    - <% const started = new Date(start); %> - - Since: <%= started.toLocaleTimeString('en-GB', { hour: '2-digit', minute: '2-digit', second: '2-digit' }) %> - -
    +
  • +
    +
    + <%= activityType %> + <% if (start && progress === null) { %> +
    + <% const started = new Date(start); %> + + Since: <%= started.toLocaleTimeString('en-GB', { hour: '2-digit', minute: '2-digit', second: '2-digit' }) %> + +
    + <% } %> +
    +
    + <% if (art) { %> +
    + Art> + <% if (smallArt) { %> + Small Art> <% } %>
    -
    - <% if (art) { %> -
    - Art> - <% if (smallArt) { %> - Small Art> - <% } %> -
    - <% } %> -
    -
    - <% + <% } %> +
    +
    + <% const isMusic = activity.type === 2 || activity.type === 3; const primaryLine = isMusic ? activity.details : activity.name; const secondaryLine = isMusic ? activity.state : activity.details; const tertiaryLine = isMusic ? activity.assets?.large_text : activity.state; %> -
    -
    - <%= primaryLine %> -
    - <% if (secondaryLine) { %> -
    <%= secondaryLine %>
    - <% } %> - <% if (tertiaryLine) { %> -
    <%= tertiaryLine %>
    - <% } %> +
    +
    + <%= primaryLine %>
    -
    - <% if (activity.buttons && activity.buttons.length > 0) { %> -
    - <% activity.buttons.forEach((button, index) => { + <% if (secondaryLine) { %> +
    <%= secondaryLine %>
    + <% } %> + <% if (tertiaryLine) { %> +
    <%= tertiaryLine %>
    + <% } %> +
    +
    + <% 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) { @@ -174,36 +177,37 @@ buttonUrl = activity.url; } %> - <% if (buttonUrl) { %> - <%= buttonLabel %> - <% } %> - <% }) %> -
    + <% if (buttonUrl) { %> + <%= buttonLabel %> <% } %> + <% }) %>
    + <% } %>
    - <% if (progress !== null) { %> -
    -
    >
    -
    - <% if (start && end) { %> -
    - - <%= Math.floor((end - start) / 60000) %>:<%= String(Math.floor(((end - start) % 60000) / 1000)).padStart(2, "0") %> -
    - <% } %> - <% } %>
    -
  • + <% if (progress !== null) { %> +
    +
    >
    +
    + <% if (start && end) { %> +
    + + <%= Math.floor((end - start) / 60000) %>:<%= String(Math.floor(((end - start) % 60000) / 1000)).padStart(2, "0") %> +
    + <% } %> + <% } %> +
    + <% }); %> <% if (readme) { %> -
    -
    <%- readme %>
    -
    +
    +
    <%- readme %>
    +
    <% } %> +