From bf22ed7bdbb4289253a85fe423b99d4f96a57fba Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20M=C3=BCller?= <thomas.mueller@tmit.eu>
Date: Thu, 20 Feb 2014 13:10:56 +0100
Subject: [PATCH] kill old minimizer code

---
 .htaccess                     |  1 -
 core/routes.php               |  3 --
 lib/base.php                  | 26 +++-----------
 lib/private/minimizer.php     | 64 -----------------------------------
 lib/private/minimizer/css.php | 38 ---------------------
 lib/private/minimizer/js.php  | 21 ------------
 6 files changed, 4 insertions(+), 149 deletions(-)
 delete mode 100644 lib/private/minimizer.php
 delete mode 100644 lib/private/minimizer/css.php
 delete mode 100644 lib/private/minimizer/js.php

diff --git a/.htaccess b/.htaccess
index 4ba5095e144..fef8c4fb8d0 100755
--- a/.htaccess
+++ b/.htaccess
@@ -26,7 +26,6 @@ RewriteRule ^.well-known/carddav /remote.php/carddav/ [R]
 RewriteRule ^.well-known/caldav /remote.php/caldav/ [R]	
 RewriteRule ^apps/calendar/caldav.php remote.php/caldav/ [QSA,L]
 RewriteRule ^apps/contacts/carddav.php remote.php/carddav/ [QSA,L]
-RewriteRule ^apps/([^/]*)/(.*\.(php))$ index.php?app=$1&getfile=$2 [QSA,L]
 RewriteRule ^remote/(.*) remote.php [QSA,L]
 </IfModule>
 <IfModule mod_mime.c>
diff --git a/core/routes.php b/core/routes.php
index f8454877e03..aea788bdc6b 100644
--- a/core/routes.php
+++ b/core/routes.php
@@ -100,9 +100,6 @@ $this->create('core_avatar_post_cropped', '/avatar/cropped')
 	->action('OC\Core\Avatar\Controller', 'postCroppedAvatar');
 
 // Not specifically routed
-$this->create('app_css', '/apps/{app}/{file}')
-	->requirements(array('file' => '.*.css'))
-	->action('OC', 'loadCSSFile');
 $this->create('app_index_script', '/apps/{app}/')
 	->defaults(array('file' => 'index.php'))
 	//->requirements(array('file' => '.*.php'))
diff --git a/lib/base.php b/lib/base.php
index a5f064bdb4b..b39a96f331f 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -284,10 +284,10 @@ class OC {
 		if (self::needUpgrade()) {
 			if ($showTemplate && !OC_Config::getValue('maintenance', false)) {
 				OC_Config::setValue('theme', '');
-				$minimizerCSS = new OC_Minimizer_CSS();
-				$minimizerCSS->clearCache();
-				$minimizerJS = new OC_Minimizer_JS();
-				$minimizerJS->clearCache();
+//				$minimizerCSS = new OC_Minimizer_CSS();
+//				$minimizerCSS->clearCache();
+//				$minimizerJS = new OC_Minimizer_JS();
+//				$minimizerJS->clearCache();
 				OC_Util::addScript('config'); // needed for web root
 				OC_Util::addScript('update');
 				$tmpl = new OC_Template('', 'update.admin', 'guest');
@@ -724,11 +724,6 @@ class OC {
 		$app = OC::$REQUESTEDAPP;
 		$file = OC::$REQUESTEDFILE;
 		$param = array('app' => $app, 'file' => $file);
-		// Handle app css files
-		if (substr($file, -3) == 'css') {
-			self::loadCSSFile($param);
-			return;
-		}
 
 		// Handle redirect URL for logged in users
 		if (isset($_REQUEST['redirect_url']) && OC_User::isLoggedIn()) {
@@ -795,19 +790,6 @@ class OC {
 		return false;
 	}
 
-	public static function loadCSSFile($param) {
-		$app = $param['app'];
-		$file = $param['file'];
-		$app_path = OC_App::getAppPath($app);
-		if (file_exists($app_path . '/' . $file)) {
-			$app_web_path = OC_App::getAppWebPath($app);
-			$filepath = $app_web_path . '/' . $file;
-			$minimizer = new OC_Minimizer_CSS();
-			$info = array($app_path, $app_web_path, $file);
-			$minimizer->output(array($info), $filepath);
-		}
-	}
-
 	protected static function handleLogin() {
 		OC_App::loadApps(array('prelogin'));
 		$error = array();
diff --git a/lib/private/minimizer.php b/lib/private/minimizer.php
deleted file mode 100644
index db522de74dc..00000000000
--- a/lib/private/minimizer.php
+++ /dev/null
@@ -1,64 +0,0 @@
-<?php
-
-abstract class OC_Minimizer {
-	public function generateETag($files) {
-		$fullpath_files = array();
-		foreach($files as $file_info) {
-			$fullpath_files[] = $file_info[0] . '/' . $file_info[2];
-		}
-		return OC_Cache::generateCacheKeyFromFiles($fullpath_files);
-	}
-
-	abstract public function minimizeFiles($files);
-
-	public function output($files, $cache_key) {
-		header('Content-Type: '.$this->contentType);
-		OC_Response::enableCaching();
-		$etag = $this->generateETag($files);
-		$cache_key .= '-'.$etag;
-
-		$gzout = false;
-		$cache = OC_Cache::getGlobalCache();
-		if (!OC_Request::isNoCache() && (!defined('DEBUG') || !DEBUG)) {
-			OC_Response::setETagHeader($etag);
-			$gzout = $cache->get($cache_key.'.gz');
-		}
-
-		if (!$gzout) {
-			$out = $this->minimizeFiles($files);
-			$gzout = gzencode($out);
-			$cache->set($cache_key.'.gz', $gzout);
-			OC_Response::setETagHeader($etag);
-		}
-		// on some systems (e.g. SLES 11, but not Ubuntu) mod_deflate and zlib compression will compress the output twice.
-		// This results in broken core.css and  core.js. To avoid it, we switch off zlib compression.
-		// Since mod_deflate is still active, Apache will compress what needs to be compressed, i.e. no disadvantage.
-		if(function_exists('apache_get_modules') && ini_get('zlib.output_compression') && in_array('mod_deflate', apache_get_modules())) {
-			ini_set('zlib.output_compression', 'Off');
-		}
-		if ($encoding = OC_Request::acceptGZip()) {
-			header('Content-Encoding: '.$encoding);
-			$out = $gzout;
-		} else {
-			$out = gzdecode($gzout);
-		}
-		header('Content-Length: '.strlen($out));
-		echo $out;
-	}
-
-	public function clearCache() {
-		$cache = OC_Cache::getGlobalCache();
-		$cache->clear('core.css');
-		$cache->clear('core.js');
-	}
-}
-
-if (!function_exists('gzdecode')) {
-	function gzdecode($data, $maxlength=null, &$filename='', &$error='')
-	{
-		if (strcmp(substr($data, 0, 9),"\x1f\x8b\x8\0\0\0\0\0\0")) {
-			return null;  // Not the GZIP format we expect (See RFC 1952)
-		}
-		return gzinflate(substr($data, 10, -8));
-	}
-}
diff --git a/lib/private/minimizer/css.php b/lib/private/minimizer/css.php
deleted file mode 100644
index 8d130572e2b..00000000000
--- a/lib/private/minimizer/css.php
+++ /dev/null
@@ -1,38 +0,0 @@
-<?php
-
-require_once 'mediawiki/CSSMin.php';
-
-class OC_Minimizer_CSS extends OC_Minimizer
-{
-	protected $contentType = 'text/css';
-
-	public function minimizeFiles($files) {
-		$css_out = '';
-		$webroot = (string) OC::$WEBROOT;
-		foreach($files as $file_info) {
-			$file = $file_info[0] . '/' . $file_info[2];
-			$css_out .= '/* ' . $file . ' */' . "\n";
-			$css = file_get_contents($file);
-
-			$in_root = false;
-			foreach(OC::$APPSROOTS as $app_root) {
-				if(strpos($file, $app_root['path'].'/') === 0) {
-					$in_root = rtrim($webroot.$app_root['url'], '/');
-					break;
-				}
-			}
-			if ($in_root !== false) {
-				$css = str_replace('%appswebroot%', $in_root, $css);
-				$css = str_replace('%webroot%', $webroot, $css);
-			}
-			$remote = $file_info[1];
-			$remote .= '/';
-			$remote .= dirname($file_info[2]);
-			$css_out .= CSSMin::remap($css, dirname($file), $remote, true);
-		}
-		if (!defined('DEBUG') || !DEBUG) {
-			$css_out = CSSMin::minify($css_out);
-		}
-		return $css_out;
-	}
-}
diff --git a/lib/private/minimizer/js.php b/lib/private/minimizer/js.php
deleted file mode 100644
index bd2d836deb0..00000000000
--- a/lib/private/minimizer/js.php
+++ /dev/null
@@ -1,21 +0,0 @@
-<?php
-
-require_once 'mediawiki/JavaScriptMinifier.php';
-
-class OC_Minimizer_JS extends OC_Minimizer
-{
-	protected $contentType = 'application/javascript';
-
-	public function minimizeFiles($files) {
-		$js_out = '';
-		foreach($files as $file_info) {
-			$file = $file_info[0] . '/' . $file_info[2];
-			$js_out .= '/* ' . $file . ' */' . "\n";
-			$js_out .= file_get_contents($file);
-		}
-		if (!defined('DEBUG') || !DEBUG) {
-			$js_out = JavaScriptMinifier::minify($js_out);
-		}
-		return $js_out;
-	}
-}
-- 
GitLab