Răsfoiți Sursa

Merge pull request #1547 from Alkarex/CSS-JS-load-order-extensions

Change CSS load order to help CustomCSS extension
Alexandre Alapetite 8 ani în urmă
părinte
comite
8de759477e
4 a modificat fișierele cu 21 adăugiri și 6 ștergeri
  1. 1 0
      CHANGELOG.md
  2. 6 6
      app/FreshRSS.php
  3. 1 0
      data/extensions-data/.gitignore
  4. 13 0
      data/extensions-data/index.html

+ 1 - 0
CHANGELOG.md

@@ -21,6 +21,7 @@
 	* Fix update system via ZIP archive [#1498](https://github.com/FreshRSS/FreshRSS/pull/1498)
 	* Work around for IE / Edge bug in username pattern in version 1.6.3 [#1511](https://github.com/FreshRSS/FreshRSS/issues/1511)
 	* Fix *mark as read* articles when adding a new feed [#1535](https://github.com/FreshRSS/FreshRSS/issues/1535)
+	* Change load order of CSS and JS to help CustomCSS and CustomJS extensions [Extensions#13](https://github.com/FreshRSS/Extensions/issues/13), [#1547](https://github.com/FreshRSS/FreshRSS/pull/1547)
 * UI
 	* New option for not closing the article when clicking outside its area [#1539](https://github.com/FreshRSS/FreshRSS/pull/1539)
 	* Download icon 💾 for other MIME types (e.g. `application/*`) [#1522](https://github.com/FreshRSS/FreshRSS/pull/1522)

+ 6 - 6
app/FreshRSS.php

@@ -80,7 +80,7 @@ class FreshRSS extends Minz_FrontController {
 	public static function loadStylesAndScripts() {
 		$theme = FreshRSS_Themes::load(FreshRSS_Context::$user_conf->theme);
 		if ($theme) {
-			foreach($theme['files'] as $file) {
+			foreach(array_reverse($theme['files']) as $file) {
 				if ($file[0] === '_') {
 					$theme_id = 'base-theme';
 					$filename = substr($file, 1);
@@ -91,13 +91,13 @@ class FreshRSS extends Minz_FrontController {
 				$filetime = @filemtime(PUBLIC_PATH . '/themes/' . $theme_id . '/' . $filename);
 				$url = '/themes/' . $theme_id . '/' . $filename . '?' . $filetime;
 				header('Link: <' . Minz_Url::display($url, '', 'root') . '>;rel=preload', false);	//HTTP2
-				Minz_View::appendStyle(Minz_Url::display($url));
+				Minz_View::prependStyle(Minz_Url::display($url));
 			}
 		}
-
-		Minz_View::appendScript(Minz_Url::display('/scripts/jquery.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/jquery.min.js')));
-		Minz_View::appendScript(Minz_Url::display('/scripts/shortcut.js?' . @filemtime(PUBLIC_PATH . '/scripts/shortcut.js')));
-		Minz_View::appendScript(Minz_Url::display('/scripts/main.js?' . @filemtime(PUBLIC_PATH . '/scripts/main.js')));
+		//Use prepend to insert before extensions. Added in reverse order.
+		Minz_View::prependScript(Minz_Url::display('/scripts/main.js?' . @filemtime(PUBLIC_PATH . '/scripts/main.js')));
+		Minz_View::prependScript(Minz_Url::display('/scripts/shortcut.js?' . @filemtime(PUBLIC_PATH . '/scripts/shortcut.js')));
+		Minz_View::prependScript(Minz_Url::display('/scripts/jquery.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/jquery.min.js')));
 	}
 
 	private static function loadNotifications() {

+ 1 - 0
data/extensions-data/.gitignore

@@ -0,0 +1 @@
+*/

+ 13 - 0
data/extensions-data/index.html

@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB">
+<head>
+<meta charset="UTF-8" />
+<meta http-equiv="Refresh" content="0; url=/" />
+<title>Redirection</title>
+<meta name="robots" content="noindex" />
+</head>
+
+<body>
+<p><a href="/">Redirection</a></p>
+</body>
+</html>