From c64c72b773473936798c8d034ea3259f02fb309b Mon Sep 17 00:00:00 2001 From: Jon Fuller Date: Mon, 6 Jan 2025 10:02:11 -0800 Subject: [PATCH 1/8] Add timezone and localtime mounts to docker-compose --- docker-compose.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index f74021d82..63f798bb9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,3 +21,5 @@ services: # Unless TRILIUM_DATA_DIR is set, the data will be stored in the "trilium-data" directory in the home directory. # This can also be changed with by replacing the line below with `- /path/of/your/choice:/home/node/trilium-data - ${TRILIUM_DATA_DIR:-~/trilium-data}:/home/node/trilium-data + - /etc/timezone:/etc/timezone:ro + - /etc/localtime:/etc/localtime:ro From 7ca4ed4369a1d1ebfadf73688613ba253386aae6 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Mon, 6 Jan 2025 23:19:15 +0100 Subject: [PATCH 2/8] fix(views/login): fix "flash of unstyled content" move stylesheets to head of HTML to get rid of "FOUC" aka "Flash of unstyled content" --- src/views/login.ejs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/views/login.ejs b/src/views/login.ejs index a17a58909..e7e6a12e5 100644 --- a/src/views/login.ejs +++ b/src/views/login.ejs @@ -6,6 +6,10 @@ <%= t("login.title") %> + + + +
@@ -77,10 +81,5 @@ /\b(Android|Windows Phone|iPad|iPod)\b/i.test(navigator.userAgent); } - - - - - From b44397a6bf0ecc52d06f9dffb5f291b68f0be1c7 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Tue, 7 Jan 2025 08:29:56 +0100 Subject: [PATCH 3/8] refactor(views/login): add getDeviceType function --- src/views/login.ejs | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/views/login.ejs b/src/views/login.ejs index a17a58909..8142b1c1c 100644 --- a/src/views/login.ejs +++ b/src/views/login.ejs @@ -43,20 +43,8 @@ // Required for correct loading of scripts in Electron if (typeof module === 'object') {window.module = module; module = undefined;} - let device; - - if (window.location.search === '?desktop') { - device = "desktop"; - } - else if (window.location.search === '?mobile') { - device = "mobile"; - } - else { - device = isMobile() ? "mobile" : "desktop"; - } - + const device = getDeviceType() console.log("Setting device cookie to:", device); - setCookie("trilium-device", device); function setCookie(name, value) { @@ -66,6 +54,12 @@ document.cookie = name + "=" + (value || "") + expires + "; path=/"; } + function getDeviceType() { + if (window.location.search === '?desktop') return "desktop"; + if (window.location.search === '?mobile') return "mobile"; + return isMobile() ? "mobile" : "desktop"; + } + // https://stackoverflow.com/a/73731646/944162 function isMobile() { const mQ = matchMedia?.('(pointer:coarse)'); From 15faf161b53b80facb8ddc82e1b8e044d7249007 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Tue, 7 Jan 2025 08:37:37 +0100 Subject: [PATCH 4/8] refactor(views/login): simplify userAgent matching MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - there is no need to have the Regexp check done in 2 separate tests – just do it once - I also have ordered the userAgents by order of "popularity", so (in theory) it should match faster for most people this way (although realistically you will not notice this at all) --- src/views/login.ejs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/views/login.ejs b/src/views/login.ejs index 8142b1c1c..af4152df5 100644 --- a/src/views/login.ejs +++ b/src/views/login.ejs @@ -66,9 +66,8 @@ if (mQ?.media === '(pointer:coarse)') return !!mQ.matches; if ('orientation' in window) return true; - - return /\b(BlackBerry|webOS|iPhone|IEMobile)\b/i.test(navigator.userAgent) || - /\b(Android|Windows Phone|iPad|iPod)\b/i.test(navigator.userAgent); + const userAgentsRegEx = /\b(Android|iPhone|iPad|iPod|Windows Phone|BlackBerry|webOS|IEMobile)\b/i + return userAgentsRegEx.test(navigator.userAgent) } From 1bbfa082381b6e2cbc10a76659b37fb389bb3fa9 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Tue, 7 Jan 2025 19:16:43 +0100 Subject: [PATCH 5/8] style(views/login): use bootstrap class for padding --- src/views/login.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/login.ejs b/src/views/login.ejs index a17a58909..920e2f5be 100644 --- a/src/views/login.ejs +++ b/src/views/login.ejs @@ -9,7 +9,7 @@
-
+

<%= t("login.heading") %>

<% if (failedAuth) { %> From fb684604354b685ddbc3c4b0d0511195f8011ed8 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Tue, 7 Jan 2025 19:18:03 +0100 Subject: [PATCH 6/8] style(views/login): add Trilium logo above heading --- src/views/login.ejs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/views/login.ejs b/src/views/login.ejs index 920e2f5be..b2485ff3a 100644 --- a/src/views/login.ejs +++ b/src/views/login.ejs @@ -10,6 +10,7 @@
+

<%= t("login.heading") %>

<% if (failedAuth) { %> From 9c03446a5046ba77d6cee812fffade2b9746eda9 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Tue, 7 Jan 2025 19:20:05 +0100 Subject: [PATCH 7/8] style(views/login): center heading to be in line w/ the logo --- src/views/login.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/login.ejs b/src/views/login.ejs index b2485ff3a..5103c7d0d 100644 --- a/src/views/login.ejs +++ b/src/views/login.ejs @@ -11,7 +11,7 @@
-

<%= t("login.heading") %>

+

<%= t("login.heading") %>

<% if (failedAuth) { %>
From 95165b6460e34666ea7dba49ca66bff76c12585e Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Tue, 7 Jan 2025 19:27:02 +0100 Subject: [PATCH 8/8] style(views/login): capitalize Trilium Login heading --- translations/en/server.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translations/en/server.json b/translations/en/server.json index c04fc52f9..2e16e7f6e 100644 --- a/translations/en/server.json +++ b/translations/en/server.json @@ -94,7 +94,7 @@ }, "login": { "title": "Login", - "heading": "Trilium login", + "heading": "Trilium Login", "incorrect-password": "Password is incorrect. Please try again.", "password": "Password", "remember-me": "Remember me",