<% autofocus = false %><%= rendered "components/search_box" %>
From 5d265094133ca646020300a2273ad1188ab68bd8 Mon Sep 17 00:00:00 2001
From: mooleshacat <43627985+mooleshacat@users.noreply.github.com>
Date: Sun, 20 Oct 2024 12:02:14 -0400
Subject: [PATCH 02/15] fix require
---
src/invidious/views/template.ecr | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/invidious/views/template.ecr b/src/invidious/views/template.ecr
index 9dba5a13..2e224ef1 100644
--- a/src/invidious/views/template.ecr
+++ b/src/invidious/views/template.ecr
@@ -1,4 +1,5 @@
<%
+ Require "../uptime.cr"
locale = env.get("preferences").as(Preferences).locale
dark_mode = env.get("preferences").as(Preferences).dark_mode
str_uptime = UpTime.get_uptime
From 064307ba5fcee228f9706643f5ad2902ae77a531 Mon Sep 17 00:00:00 2001
From: mooleshacat <43627985+mooleshacat@users.noreply.github.com>
Date: Sun, 20 Oct 2024 12:05:05 -0400
Subject: [PATCH 03/15] fix
---
src/invidious/views/template.ecr | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/invidious/views/template.ecr b/src/invidious/views/template.ecr
index 2e224ef1..fd261c8f 100644
--- a/src/invidious/views/template.ecr
+++ b/src/invidious/views/template.ecr
@@ -1,8 +1,7 @@
<%
- Require "../uptime.cr"
locale = env.get("preferences").as(Preferences).locale
dark_mode = env.get("preferences").as(Preferences).dark_mode
- str_uptime = UpTime.get_uptime
+ str_uptime = Invidious::UpTime.get_uptime
%>
From 9fc3332ddb15f15e3de0c9907632898e4d7a558b Mon Sep 17 00:00:00 2001
From: mooleshacat <43627985+mooleshacat@users.noreply.github.com>
Date: Sun, 20 Oct 2024 12:16:05 -0400
Subject: [PATCH 04/15] fix
---
src/invidious/views/template.ecr | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/invidious/views/template.ecr b/src/invidious/views/template.ecr
index fd261c8f..9dba5a13 100644
--- a/src/invidious/views/template.ecr
+++ b/src/invidious/views/template.ecr
@@ -1,7 +1,7 @@
<%
locale = env.get("preferences").as(Preferences).locale
dark_mode = env.get("preferences").as(Preferences).dark_mode
- str_uptime = Invidious::UpTime.get_uptime
+ str_uptime = UpTime.get_uptime
%>
From faa639c03143ad518930c70c326f695ba4486072 Mon Sep 17 00:00:00 2001
From: mooleshacat <43627985+mooleshacat@users.noreply.github.com>
Date: Sun, 20 Oct 2024 12:26:32 -0400
Subject: [PATCH 05/15] fix
---
src/invidious/views/template.ecr | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/invidious/views/template.ecr b/src/invidious/views/template.ecr
index 9dba5a13..0d27951d 100644
--- a/src/invidious/views/template.ecr
+++ b/src/invidious/views/template.ecr
@@ -1,7 +1,7 @@
<%
locale = env.get("preferences").as(Preferences).locale
dark_mode = env.get("preferences").as(Preferences).dark_mode
- str_uptime = UpTime.get_uptime
+ str_uptime = Invidious::Uptime.get_uptime
%>
From a47fb1f23412f32a7c458200573e744549d02b60 Mon Sep 17 00:00:00 2001
From: mooleshacat <43627985+mooleshacat@users.noreply.github.com>
Date: Sun, 20 Oct 2024 12:29:38 -0400
Subject: [PATCH 06/15] fix
---
src/invidious/helpers/uptime.cr | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
create mode 100644 src/invidious/helpers/uptime.cr
diff --git a/src/invidious/helpers/uptime.cr b/src/invidious/helpers/uptime.cr
new file mode 100644
index 00000000..1408ecbd
--- /dev/null
+++ b/src/invidious/helpers/uptime.cr
@@ -0,0 +1,19 @@
+class Invidious::Uptime
+
+ def self.get_uptime
+
+ str_uptime = "error"
+
+ # get the uptime
+ uptime_cmd = "/usr/bin/uptime"
+ uptime_args = "-p"
+
+ process = Process.new(uptime_cmd, [uptime_args], output: Process::Redirect::Pipe)
+
+ str_uptime = process.output.gets_to_end
+
+ return str_uptime
+
+ end
+
+end
\ No newline at end of file
From b6a1fdd7d2a2156d7c8575a839f342c35cea87ad Mon Sep 17 00:00:00 2001
From: mooleshacat <43627985+mooleshacat@users.noreply.github.com>
Date: Sun, 20 Oct 2024 13:09:47 -0400
Subject: [PATCH 07/15] fixing fontsize
---
src/invidious/helpers/uptime.cr | 1 -
src/invidious/views/template.ecr | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/invidious/helpers/uptime.cr b/src/invidious/helpers/uptime.cr
index 1408ecbd..c26d948e 100644
--- a/src/invidious/helpers/uptime.cr
+++ b/src/invidious/helpers/uptime.cr
@@ -7,7 +7,6 @@ class Invidious::Uptime
# get the uptime
uptime_cmd = "/usr/bin/uptime"
uptime_args = "-p"
-
process = Process.new(uptime_cmd, [uptime_args], output: Process::Redirect::Pipe)
str_uptime = process.output.gets_to_end
diff --git a/src/invidious/views/template.ecr b/src/invidious/views/template.ecr
index 0d27951d..3f75778b 100644
--- a/src/invidious/views/template.ecr
+++ b/src/invidious/views/template.ecr
@@ -34,7 +34,7 @@
<% if navbar_search %>
- server <%= str_uptime %>
+ server <%= str_uptime %>
<% autofocus = false %><%= rendered "components/search_box" %>
From 029ed9ce60c797e0068695a3fc12f1aa2a7da8b8 Mon Sep 17 00:00:00 2001
From: mooleshacat <43627985+mooleshacat@users.noreply.github.com>
Date: Sun, 20 Oct 2024 13:13:55 -0400
Subject: [PATCH 08/15] fixing fontsize again :/
---
src/invidious/views/template.ecr | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/invidious/views/template.ecr b/src/invidious/views/template.ecr
index 3f75778b..a7b9b701 100644
--- a/src/invidious/views/template.ecr
+++ b/src/invidious/views/template.ecr
@@ -33,8 +33,9 @@
<% if navbar_search %>
-
- server <%= str_uptime %>
+
+
+ server <%= str_uptime %>
<% autofocus = false %><%= rendered "components/search_box" %>
From 6d4069fe9ee36f9c826ef5117339f0f00bd53e49 Mon Sep 17 00:00:00 2001
From: mooleshacat <43627985+mooleshacat@users.noreply.github.com>
Date: Sun, 20 Oct 2024 13:15:50 -0400
Subject: [PATCH 09/15] fixing fontsize again :/
---
src/invidious/views/template.ecr | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/invidious/views/template.ecr b/src/invidious/views/template.ecr
index a7b9b701..6ed420df 100644
--- a/src/invidious/views/template.ecr
+++ b/src/invidious/views/template.ecr
@@ -35,7 +35,7 @@
- server <%= str_uptime %>
+ server <%= str_uptime %>
<% autofocus = false %><%= rendered "components/search_box" %>
From ac114a45aafe0c80577aacb424a44765b2cfa1fa Mon Sep 17 00:00:00 2001
From: mooleshacat <43627985+mooleshacat@users.noreply.github.com>
Date: Sun, 20 Oct 2024 13:20:06 -0400
Subject: [PATCH 10/15] fixing alignment
---
src/invidious/views/template.ecr | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/invidious/views/template.ecr b/src/invidious/views/template.ecr
index 6ed420df..5dc89c84 100644
--- a/src/invidious/views/template.ecr
+++ b/src/invidious/views/template.ecr
@@ -34,8 +34,8 @@
<% if navbar_search %>
-
- server <%= str_uptime %>
+
+ server <%= str_uptime %>
<% autofocus = false %><%= rendered "components/search_box" %>
From 3026b09fd46beb73c2adbf4581b814338ab00e61 Mon Sep 17 00:00:00 2001
From: mooleshacat <43627985+mooleshacat@users.noreply.github.com>
Date: Sun, 20 Oct 2024 13:22:07 -0400
Subject: [PATCH 11/15] changed color
---
src/invidious/views/template.ecr | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/invidious/views/template.ecr b/src/invidious/views/template.ecr
index 5dc89c84..9c9a1efb 100644
--- a/src/invidious/views/template.ecr
+++ b/src/invidious/views/template.ecr
@@ -35,7 +35,7 @@
- server <%= str_uptime %>
+ server <%= str_uptime %>
<% autofocus = false %><%= rendered "components/search_box" %>
From e071349fb2ea189dca3982f5c067075793dd9595 Mon Sep 17 00:00:00 2001
From: mooleshacat <43627985+mooleshacat@users.noreply.github.com>
Date: Sun, 20 Oct 2024 13:32:22 -0400
Subject: [PATCH 12/15] changed color again
---
src/invidious/views/template.ecr | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/invidious/views/template.ecr b/src/invidious/views/template.ecr
index 9c9a1efb..ba3315d8 100644
--- a/src/invidious/views/template.ecr
+++ b/src/invidious/views/template.ecr
@@ -35,7 +35,7 @@
- server <%= str_uptime %>
+ server <%= str_uptime %>
<% autofocus = false %><%= rendered "components/search_box" %>
From e2d9e1aaf75fe13b1ca342cfa1e4f11e24c59c9f Mon Sep 17 00:00:00 2001
From: mooleshacat <43627985+mooleshacat@users.noreply.github.com>
Date: Sun, 20 Oct 2024 13:40:51 -0400
Subject: [PATCH 13/15] alignment
---
src/invidious/views/template.ecr | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/invidious/views/template.ecr b/src/invidious/views/template.ecr
index ba3315d8..23234f59 100644
--- a/src/invidious/views/template.ecr
+++ b/src/invidious/views/template.ecr
@@ -35,7 +35,7 @@
- server <%= str_uptime %>
+ server <%= str_uptime %>
<% autofocus = false %><%= rendered "components/search_box" %>
From cc4b3bf888096f1e41563761a369998af48200bd Mon Sep 17 00:00:00 2001
From: mooleshacat <43627985+mooleshacat@users.noreply.github.com>
Date: Mon, 21 Oct 2024 22:20:20 -0400
Subject: [PATCH 14/15] added config variable
---
config/config.example.yml | 8 ++++++++
src/invidious/config.cr | 1 +
src/invidious/helpers/uptime.cr | 19 ++++++++++++-------
src/invidious/views/template.ecr | 6 ++++--
4 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/config/config.example.yml b/config/config.example.yml
index 759b81e0..a9ef777a 100644
--- a/config/config.example.yml
+++ b/config/config.example.yml
@@ -238,6 +238,14 @@ http_proxy:
# Features
# -----------------------------
+##
+## Enable/Disable showing the uptime on the main page.
+##
+## Accepted values: true, false
+## Default: false
+##
+#uptime_enabled: true
+
##
## Enable/Disable the "Popular" tab on the main page.
##
diff --git a/src/invidious/config.cr b/src/invidious/config.cr
index 45efc3ff..a5fc0aca 100644
--- a/src/invidious/config.cr
+++ b/src/invidious/config.cr
@@ -102,6 +102,7 @@ class Config
# Subscribe to channels using PubSubHubbub (requires domain, hmac_key)
property use_pubsub_feeds : Bool | Int32 = false
property popular_enabled : Bool = true
+ property uptime_enabled : Bool = false
property captcha_enabled : Bool = true
property login_enabled : Bool = true
property registration_enabled : Bool = true
diff --git a/src/invidious/helpers/uptime.cr b/src/invidious/helpers/uptime.cr
index c26d948e..f406cc48 100644
--- a/src/invidious/helpers/uptime.cr
+++ b/src/invidious/helpers/uptime.cr
@@ -1,15 +1,20 @@
class Invidious::Uptime
def self.get_uptime
-
+
str_uptime = "error"
- # get the uptime
- uptime_cmd = "/usr/bin/uptime"
- uptime_args = "-p"
- process = Process.new(uptime_cmd, [uptime_args], output: Process::Redirect::Pipe)
-
- str_uptime = process.output.gets_to_end
+ if CONFIG.uptime_enabled
+
+ # get the uptime
+ uptime_cmd = "/usr/bin/uptime"
+ uptime_args = "-p"
+ process = Process.new(uptime_cmd, [uptime_args], output: Process::Redirect::Pipe)
+ str_uptime = process.output.gets_to_end
+
+ else
+ str_uptime = ""
+ end
return str_uptime
diff --git a/src/invidious/views/template.ecr b/src/invidious/views/template.ecr
index 23234f59..45f78a43 100644
--- a/src/invidious/views/template.ecr
+++ b/src/invidious/views/template.ecr
@@ -1,7 +1,7 @@
<%
locale = env.get("preferences").as(Preferences).locale
dark_mode = env.get("preferences").as(Preferences).dark_mode
- str_uptime = Invidious::Uptime.get_uptime
+ uptime_enabled = CONFIG.uptime_enabled
%>
@@ -34,8 +34,10 @@
<% if navbar_search %>
+ <% if uptime_enabled %>
- server <%= str_uptime %>
+ server <%= Invidious::Uptime.get_uptime %>
+ <% end %>
<% autofocus = false %><%= rendered "components/search_box" %>
From b8083c34c8b761223358ff36d630294e68a7288c Mon Sep 17 00:00:00 2001
From: mooleshacat <43627985+mooleshacat@users.noreply.github.com>
Date: Mon, 21 Oct 2024 22:31:47 -0400
Subject: [PATCH 15/15] added uptime status readme
---
README.md | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/README.md b/README.md
index 7f7ea6a3..0bed7848 100644
--- a/README.md
+++ b/README.md
@@ -77,6 +77,7 @@
- add redis patch
- add proxy patch
- sig helper reconnect patch
+- uptime status patch (mooleshacat)
- token monitor patch (mooleshacat)
**User features**
@@ -155,6 +156,11 @@ This branch has the token monitor patch from myself (mooleshacat) which will che
This patch is a temporary workaround until inv_sig_helper itself can get the tokens for us. unixfox (invidious dev) raised this idea to techmetx11 (inv_sig_helper dev) and they are working on an implementation that will eventually make this patch useless. This is OK, as it is only a patch and that setup would be better performance wise than my current implementations. You can read about it here https://github.com/iv-org/inv_sig_helper/issues/10
+## uptime status patch
+
+This fork has the uptime patch made by myself (mooleshacat) which if enabled in the config, will show the uptime on the page. Please note, if everyone can see your uptime, so could a theoretical attacker. This may or may not be a good idea, you be the judge.
+
+
## Documentation
The full documentation can be accessed online at https://docs.invidious.io/