From 617d236f005538be4a53b4a4cb88aac0ad6bf14b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20D=C3=ADaz=20Gonz=C3=A1lez?= <dgonzalez@suse.de>
Date: Mon, 13 Jun 2022 20:05:21 +0100
Subject: [PATCH] Load custom CSS

In order to override Cockpit's default styling, another CSS file is
loaded in every HTML page. It works, but as a workaround already
discussed with upstream [1].

We will revert this patch when Cockpit provides better technique [2]. For
now, it fulfills the requirements of [3].

[1] https://github.com/cockpit-project/cockpit/pull/17437
[2] https://github.com/cockpit-project/cockpit/issues/16359
[3] https://en.opensuse.org/openSUSE:ALP/Workgroups/SysMngmnt
---
 pkg/apps/index.html                    |  1 +
 pkg/kdump/index.html                   |  1 +
 pkg/metrics/index.html                 |  1 +
 pkg/networkmanager/firewall.html       |  1 +
 pkg/networkmanager/index.html          |  1 +
 pkg/packagekit/index.html              |  1 +
 pkg/playground/index.html              |  1 +
 pkg/playground/journal.html            |  1 +
 pkg/playground/metrics.html            |  1 +
 pkg/playground/plot.html               |  1 +
 pkg/playground/react-patterns.html     |  1 +
 pkg/playground/speed.html              |  1 +
 pkg/playground/test.html               |  1 +
 pkg/selinux/setroubleshoot.html        |  1 +
 pkg/shell/index.html                   |  1 +
 pkg/shell/shell.html                   |  1 +
 pkg/sosreport/index.html               |  1 +
 pkg/storaged/index.html                |  1 +
 pkg/systemd/hwinfo.html                |  1 +
 pkg/systemd/index.html                 |  1 +
 pkg/systemd/logs.html                  |  1 +
 pkg/systemd/services.html              |  1 +
 pkg/systemd/terminal.html              |  1 +
 pkg/users/index.html                   |  1 +
 src/branding/default/css-overrides.css | 12 ++++++++++++
 25 files changed, 36 insertions(+)
 create mode 100644 src/branding/default/css-overrides.css

Index: cockpit/pkg/apps/index.html
===================================================================
--- cockpit.orig/pkg/apps/index.html
+++ cockpit/pkg/apps/index.html
@@ -23,6 +23,7 @@ along with Cockpit; If not, see <http://
     <title translate="yes">Applications</title>
     <meta charset="utf-8" />
     <link href="apps.css" type="text/css" rel="stylesheet" />
+    <link href="../../static/css-overrides.css" type="text/css" rel="stylesheet">
     <script type="text/javascript" src="../base1/cockpit.js"></script>
     <script type="text/javascript" src="../base1/po.js"></script>
     <script type="text/javascript" src="po.js"></script>
Index: cockpit/pkg/kdump/index.html
===================================================================
--- cockpit.orig/pkg/kdump/index.html
+++ cockpit/pkg/kdump/index.html
@@ -25,6 +25,7 @@ along with Cockpit; If not, see <http://
     <meta name="viewport" content="width=device-width, initial-scale=1" />
 
     <link rel="stylesheet" href="kdump.css" />
+    <link href="../../static/css-overrides.css" type="text/css" rel="stylesheet" />
 
     <script type="text/javascript" src="kdump.js"></script>
     <script type="text/javascript" src="../base1/po.js"></script>
Index: cockpit/pkg/metrics/index.html
===================================================================
--- cockpit.orig/pkg/metrics/index.html
+++ cockpit/pkg/metrics/index.html
@@ -23,6 +23,7 @@ along with this package; If not, see <ht
     <meta name="viewport" content="width=device-width, initial-scale=1" />
 
     <link rel="stylesheet" href="index.css" />
+    <link href="../../static/css-overrides.css" type="text/css" rel="stylesheet" />
 
     <script type="text/javascript" src="../base1/cockpit.js"></script>
     <script type="text/javascript" src="../manifests.js"></script>
Index: cockpit/pkg/networkmanager/firewall.html
===================================================================
--- cockpit.orig/pkg/networkmanager/firewall.html
+++ cockpit/pkg/networkmanager/firewall.html
@@ -23,6 +23,7 @@ along with Cockpit; If not, see <http://
     <meta charset="utf-8" />
 
     <link href="firewall.css" type="text/css" rel="stylesheet" />
+    <link href="../../static/css-overrides.css" type="text/css" rel="stylesheet" />
 
     <script src="../base1/cockpit.js"></script>
     <script src="../base1/po.js"></script>
Index: cockpit/pkg/networkmanager/index.html
===================================================================
--- cockpit.orig/pkg/networkmanager/index.html
+++ cockpit/pkg/networkmanager/index.html
@@ -24,6 +24,7 @@
   <meta charset="utf-8" />
   <meta name="viewport" content="width=device-width, initial-scale=1.0" />
   <link href="networkmanager.css" type="text/css" rel="stylesheet" />
+  <link href="../../static/css-overrides.css" type="text/css" rel="stylesheet" />
   <script src="../base1/cockpit.js"></script>
   <script src="../manifests.js"></script>
   <script src="../base1/po.js"></script>
Index: cockpit/pkg/packagekit/index.html
===================================================================
--- cockpit.orig/pkg/packagekit/index.html
+++ cockpit/pkg/packagekit/index.html
@@ -24,6 +24,7 @@ along with Cockpit; If not, see <http://
   <meta charset="utf-8" />
 
   <link href="updates.css" rel="stylesheet" />
+  <link href="../../static/css-overrides.css" type="text/css" rel="stylesheet" />
 
   <script src="../base1/cockpit.js"></script>
   <script src="../base1/po.js"></script>
Index: cockpit/pkg/playground/index.html
===================================================================
--- cockpit.orig/pkg/playground/index.html
+++ cockpit/pkg/playground/index.html
@@ -5,6 +5,7 @@
     <title>Cockpit Development Playground</title>
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <link href="index.css" type="text/css" rel="stylesheet" />
+    <link href="../../static/css-overrides.css" type="text/css" rel="stylesheet" />
     <script src="../base1/cockpit.js"></script>
     <script src="../manifests.js"></script>
     <script src="index.js"></script>
Index: cockpit/pkg/playground/journal.html
===================================================================
--- cockpit.orig/pkg/playground/journal.html
+++ cockpit/pkg/playground/journal.html
@@ -5,6 +5,7 @@
     <title>Cockpit Journal Box</title>
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <link href="journal.css" type="text/css" rel="stylesheet" />
+    <link href="../../static/css-overrides.css" type="text/css" rel="stylesheet" />
     <script src="../base1/cockpit.js"></script>
     <script src="journal.js"></script>
 </head>
Index: cockpit/pkg/playground/metrics.html
===================================================================
--- cockpit.orig/pkg/playground/metrics.html
+++ cockpit/pkg/playground/metrics.html
@@ -5,6 +5,7 @@
     <title>Cockpit Monitoring</title>
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <link href="metrics.css" type="text/css" rel="stylesheet" />
+    <link href="../../static/css-overrides.css" type="text/css" rel="stylesheet" />
     <script src="../base1/cockpit.js"></script>
     <script src="metrics.js"></script>
 </head>
Index: cockpit/pkg/playground/plot.html
===================================================================
--- cockpit.orig/pkg/playground/plot.html
+++ cockpit/pkg/playground/plot.html
@@ -5,6 +5,7 @@
     <title>Cockpit Plots</title>
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <link href="plot.css" type="text/css" rel="stylesheet" />
+    <link href="../../static/css-overrides.css" type="text/css" rel="stylesheet" />
     <script src="../base1/cockpit.js"></script>
     <script src="plot.js"></script>
 </head>
Index: cockpit/pkg/playground/react-patterns.html
===================================================================
--- cockpit.orig/pkg/playground/react-patterns.html
+++ cockpit/pkg/playground/react-patterns.html
@@ -5,6 +5,7 @@
     <title>Cockpit React Patterns Usage</title>
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <link href="react-patterns.css" type="text/css" rel="stylesheet" />
+    <link href="../../static/css-overrides.css" type="text/css" rel="stylesheet" />
     <script src="../base1/cockpit.js"></script>
     <script src="react-patterns.js"></script>
 </head>
Index: cockpit/pkg/playground/speed.html
===================================================================
--- cockpit.orig/pkg/playground/speed.html
+++ cockpit/pkg/playground/speed.html
@@ -5,6 +5,7 @@
     <title>Cockpit Speed Tests</title>
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <link href="speed.css" type="text/css" rel="stylesheet" />
+    <link href="../../static/css-overrides.css" type="text/css" rel="stylesheet" />
     <script src="../base1/cockpit.js"></script>
     <script src="speed.js"></script>
 </head>
Index: cockpit/pkg/playground/test.html
===================================================================
--- cockpit.orig/pkg/playground/test.html
+++ cockpit/pkg/playground/test.html
@@ -5,6 +5,7 @@
     <title>Cockpit playground</title>
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <link href="test.css" type="text/css" rel="stylesheet" />
+    <link href="../../static/css-overrides.css" type="text/css" rel="stylesheet" />
     <script src="../base1/cockpit.js"></script>
     <script src="test.js"></script>
 </head>
Index: cockpit/pkg/shell/index.html
===================================================================
--- a/pkg/shell/index.html
+++ b/pkg/shell/index.html
@@ -6,6 +6,7 @@
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <link href="shell.css" rel="stylesheet" />
     <link href="../../static/branding.css" rel="stylesheet" />
+    <link href="../../static/css-overrides.css" type="text/css" rel="stylesheet" />
     <script src="../base1/cockpit.js"></script>
     <script src="../manifests-i18n.js"></script>
     <script src="po.js"></script>
Index: cockpit/pkg/shell/shell.html
===================================================================
--- cockpit.orig/pkg/shell/shell.html
+++ cockpit/pkg/shell/shell.html
@@ -5,6 +5,7 @@
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <link rel="stylesheet" href="index.css" />
+    <link href="../../static/css-overrides.css" type="text/css" rel="stylesheet" />
 </head>
 <body class="pf-v5-m-tabular-nums">
     <div class="curtains-ct">
Index: cockpit/pkg/sosreport/index.html
===================================================================
--- cockpit.orig/pkg/sosreport/index.html
+++ cockpit/pkg/sosreport/index.html
@@ -22,6 +22,7 @@ along with Cockpit; If not, see <http://
     <title translate="yes">Diagnostic reports</title>
     <meta charset="utf-8" />
     <link href="sosreport.css" rel="stylesheet" />
+    <link href="../../static/css-overrides.css" type="text/css" rel="stylesheet" />
     <script type="text/javascript" src="../base1/cockpit.js"></script>
     <script type="text/javascript" src="../base1/po.js"></script>
     <script type="text/javascript" src="po.js"></script>
Index: cockpit/pkg/systemd/hwinfo.html
===================================================================
--- cockpit.orig/pkg/systemd/hwinfo.html
+++ cockpit/pkg/systemd/hwinfo.html
@@ -4,6 +4,7 @@
     <title translate="yes">Hardware information</title>
     <meta charset="utf-8" />
     <link href="hwinfo.css" type="text/css" rel="stylesheet" />
+    <link href="../../static/css-overrides.css" type="text/css" rel="stylesheet" />
     <script src="../base1/cockpit.js"></script>
     <script src="../base1/po.js"></script>
     <script src="po.js"></script>
Index: cockpit/pkg/systemd/index.html
===================================================================
--- cockpit.orig/pkg/systemd/index.html
+++ cockpit/pkg/systemd/index.html
@@ -6,6 +6,7 @@
   <meta name="description" content="" />
   <meta name="viewport" content="width=device-width, initial-scale=1" />
   <link rel="stylesheet" href="overview.css" />
+  <link href="../../static/css-overrides.css" type="text/css" rel="stylesheet"/>
   <script type="text/javascript" src="../base1/cockpit.js"></script>
   <script type="text/javascript" src="../base1/po.js"></script>
   <script type="text/javascript" src="overview.js"></script>
Index: cockpit/pkg/systemd/logs.html
===================================================================
--- cockpit.orig/pkg/systemd/logs.html
+++ cockpit/pkg/systemd/logs.html
@@ -23,6 +23,7 @@ along with Cockpit; If not, see <http://
   <title translate="yes">Journal</title>
   <meta charset="utf-8" />
   <link href="logs.css" rel="stylesheet" />
+  <link href="../../static/css-overrides.css" type="text/css" rel="stylesheet" />
   <script type="text/javascript" src="../base1/cockpit.js"></script>
   <script src="../base1/po.js"></script>
   <script src="po.js"></script>
Index: cockpit/pkg/systemd/services.html
===================================================================
--- cockpit.orig/pkg/systemd/services.html
+++ cockpit/pkg/systemd/services.html
@@ -5,6 +5,7 @@
     <meta charset="utf-8" />
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <link href="services.css" type="text/css" rel="stylesheet" />
+    <link href="../../static/css-overrides.css" type="text/css" rel="stylesheet" />
     <script src="../base1/cockpit.js"></script>
     <script src="../base1/po.js"></script>
     <script src="services.js"></script>
Index: cockpit/pkg/systemd/terminal.html
===================================================================
--- cockpit.orig/pkg/systemd/terminal.html
+++ cockpit/pkg/systemd/terminal.html
@@ -5,6 +5,7 @@
     <meta charset="utf-8" />
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <link href="terminal.css" type="text/css" rel="stylesheet" />
+    <link href="../../static/css-overrides.css" type="text/css" rel="stylesheet" />
     <script src="../base1/cockpit.js"></script>
     <script src="../base1/po.js"></script>
     <script src="po.js"></script>
Index: cockpit/pkg/users/index.html
===================================================================
--- cockpit.orig/pkg/users/index.html
+++ cockpit/pkg/users/index.html
@@ -24,6 +24,7 @@
     <meta charset="utf-8" />
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <link href="users.css" type="text/css" rel="stylesheet" />
+    <link href="../../static/css-overrides.css" type="text/css" rel="stylesheet" />
     <script src="../base1/cockpit.js"></script>
     <script src="../base1/po.js"></script>
     <script src="po.js"></script>
Index: cockpit/pkg/static/css-overrides.css
===================================================================
--- /dev/null
+++ cockpit/pkg/static/css-overrides.css
@@ -0,0 +1,12 @@
+/**
+ * PLEASE, DO NOT CHANGE THIS FILE.
+ *
+ * It is here to avoid 404 errors on openSUSE Cockpit patched version when no
+ * package for overriding the default style is installed. If a better
+ * alternative becomes available, it will be removed.
+ *
+ * To know more, please follow below links
+ *
+ *   - https://github.com/cockpit-project/cockpit/pull/17437
+ *   - https://github.com/cockpit-project/cockpit/issues/16359
+ */
