Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3c77edc5 authored by Arnau Vàzquez's avatar Arnau Vàzquez
Browse files

Merge branch 'theme-svg-patches' into 'master'

Added patches for IconsCacher and SvgController

See merge request !31
parents 3c65ddf2 d65b74fd
Loading
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -83,6 +83,9 @@ RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/005-autocomplete-user-leak-co
RUN cd ${BASE_DIR}/custom_apps && patch -p0 < ${TMP_PATCH_DIR}/005-autocomplete-user-leak-custom-app.patch
RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/006-recovery-email-changes.patch
RUN patch -u ${BASE_DIR}/apps/settings/lib/Settings/Personal/ServerDevNotice.php -i ${TMP_PATCH_DIR}/007-remove-dev-notice.patch
RUN patch -u ${BASE_DIR}/lib/private/Template/IconsCacher.php -i ${TMP_PATCH_DIR}/008-icons-cacher-theme-svgs.patch
RUN patch -u ${BASE_DIR}/core/Controller/SvgController.php -i ${TMP_PATCH_DIR}/008-svg-controller-theme-svgs.patch
RUN patch -u ${BASE_DIR}/lib/private/TemplateLayout.php -i ${TMP_PATCH_DIR}/009-remove-external-sites-from-navigation.patch
RUN rm -rf ${TMP_PATCH_DIR}

# autocomplete leak tweak apps frontend with sed, disable group suggestion
+45 −0
Original line number Diff line number Diff line
From: Akhil <akhil@e.email>
Date: Tue, 22 Jul 2021 18:15:00 +0530
Subject: [PATCH] Caches SVGs added via theme

This patch modifies Icons Cacher to check theme for icons and if they exist, 
cache them instead of the icons in core or apps directories

diff --git ./lib/private/Template/IconsCacher.php ./lib/private/Template/IconsCacher-new.php
--- ./lib/private/Template/IconsCacher.php	2021-07-22 18:05:40.133856200 +0530
+++ ./lib/private/Template/IconsCacher-new.php	2021-07-27 20:43:14.122338212 +0530
@@ -161,20 +161,27 @@
 		$location = '';
 		$color = '';
 		$base = $this->getRoutePrefix() . '/svg/';
-		$cleanUrl = \substr($url, \strlen($base));
+        $cleanUrl = \substr($url, \strlen($base));
+        $theme = \OC::$server->getConfig()->getSystemValue("theme");
 		if (\strpos($url, $base . 'core') === 0) {
 			$cleanUrl = \substr($cleanUrl, \strlen('core'));
 			if (\preg_match('/\/([a-zA-Z0-9-_\~\/\.\=\:\;\+\,]+)\?color=([0-9a-fA-F]{3,6})/', $cleanUrl, $matches)) {
-				list(,$cleanUrl,$color) = $matches;
-				$location = \OC::$SERVERROOT . '/core/img/' . $cleanUrl . '.svg';
+                list(,$cleanUrl,$color) = $matches;
+                $location = \OC::$SERVERROOT . '/themes/'. $theme . '/core/img/' . $cleanUrl . '.svg';
+                if(!file_exists($location)){ 
+                        $location = \OC::$SERVERROOT . '/core/img/' . $cleanUrl . '.svg';
+                }
 			}
 		} elseif (\strpos($url, $base) === 0) {
 			if (\preg_match('/([A-z0-9\_\-]+)\/([a-zA-Z0-9-_\~\/\.\=\:\;\+\,]+)\?color=([0-9a-fA-F]{3,6})/', $cleanUrl, $matches)) {
 				list(,$app,$cleanUrl, $color) = $matches;
-				$location = \OC_App::getAppPath($app) . '/img/' . $cleanUrl . '.svg';
-				if ($app === 'settings') {
-					$location = \OC::$SERVERROOT . '/settings/img/' . $cleanUrl . '.svg';
-				}
+                $location = \OC::$SERVERROOT . '/themes/' . $theme . '/apps/' . $app . '/img/' . $cleanUrl . '.svg';
+				if(!file_exists($location)) {
+                        $location = \OC_App::getAppPath($app) . '/img/' . $cleanUrl . '.svg';
+						if ($app === 'settings') {
+							$location = \OC::$SERVERROOT . '/settings/img/' . $cleanUrl . '.svg';
+						}
+					}
 			}
 		}
 		return [
+38 −0
Original line number Diff line number Diff line
From: Akhil <akhil@e.email>
Date: Tue, 22 Jul 2021 18:15:00 +0530
Subject: [PATCH] Serves SVGs added via theme through SVG Controller

This patch modifies SVG Controllers to check theme for icons and if they exist, return them before checking
app or core directories in their respective methods

diff --git ./lib/private/Template/IconsCacher.php ./lib/private/Template/IconsCacher-new.php
--- ./core/Controller/SvgController.php	2021-07-22 18:00:30.575284496 +0530
+++ ./core/Controller/SvgController-new.php	2021-07-22 18:07:55.927091362 +0530
@@ -81,7 +81,13 @@
 	 * @return DataDisplayResponse|NotFoundResponse
 	 */
 	public function getSvgFromCore(string $folder, string $fileName, string $color = 'ffffff') {
-		$path = $this->serverRoot . "/core/img/$folder/$fileName.svg";
+        $theme = \OC::$server->getConfig()->getSystemValue("theme");
+        $path = $this->serverRoot . '/themes/' . $theme .'/core/img/' . $folder . '/' . $fileName . '.svg';
+        if(file_exists($path)) {
+            return $this->getSvg($path, $color, $fileName);
+        }
+
+        $path = $this->serverRoot . "/core/img/$folder/$fileName.svg";
 		return $this->getSvg($path, $color, $fileName);
 	}
 
@@ -103,7 +109,11 @@
 		} catch (AppPathNotFoundException $e) {
 			return new NotFoundResponse();
 		}
-
+        $theme = \OC::$server->getConfig()->getSystemValue("theme");
+        $path = $this->serverRoot . '/themes/' . $theme .'/apps/' . $app .  '/img/'. $fileName . '.svg';
+        if(file_exists($path)) {
+                return $this->getSvg($path, $color, $fileName);
+        }
 		$path = $appPath . "/img/$fileName.svg";
 		return $this->getSvg($path, $color, $fileName);
 	}
+24 −0
Original line number Diff line number Diff line
From: Akhil <akhil@e.email>
Date: Tue, 28 Jul 2021 21:25:00 +0530
Subject: [PATCH] Removes external results from navigation

This patch removes external link results from navigation. External link results are those coming from the
"external sites" app

diff --git ./lib/private/TemplateLayout.php ./lib/private/TemplateLayout-new.php
--- ./lib/private/TemplateLayout.php	2021-07-29 00:10:10.515495166 +0530
+++ ./lib/private/TemplateLayout-new.php	2021-07-29 00:10:27.873160383 +0530
@@ -105,7 +105,12 @@
 			$this->assign('application', '');
 			$this->assign('appid', $appId);
 
-			$navigation = $this->navigationManager->getAll();
+                        $navigation = $this->navigationManager->getAll();
+                        $navigation = array_filter($navigation, function($entry) {
+                                if (strpos($entry["id"], "external_index") !== 0) {
+                                    return true;
+                                }
+                        });
 			$this->assign('navigation', $navigation);
 			$settingsNavigation = $this->navigationManager->getAll('settings');
 			$this->assign('settingsnavigation', $settingsNavigation);