Changed loading of the JQuery libraries into the speeddial page so that a system wide library is loaded in case the internal one has been removed (e.g. by distro package maintainers). eric7

Wed, 04 Jan 2023 12:33:48 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 04 Jan 2023 12:33:48 +0100
branch
eric7
changeset 9672
335f695d59e7
parent 9671
5039f53f68c2
child 9673
f4b3d2485baa

Changed loading of the JQuery libraries into the speeddial page so that a system wide library is loaded in case the internal one has been removed (e.g. by distro package maintainers).

src/eric7/WebBrowser/Network/EricSchemeHandler.py file | annotate | diff | comparison | revisions
src/eric7/WebBrowser/Tools/WebBrowserTools.py file | annotate | diff | comparison | revisions
--- a/src/eric7/WebBrowser/Network/EricSchemeHandler.py	Tue Jan 03 17:13:24 2023 +0100
+++ b/src/eric7/WebBrowser/Network/EricSchemeHandler.py	Wed Jan 04 12:33:48 2023 +0100
@@ -14,7 +14,7 @@
 from eric7.EricWidgets.EricApplication import ericApp
 from eric7.WebBrowser.WebBrowserWindow import WebBrowserWindow
 
-from ..Tools.WebBrowserTools import getHtmlPage, getJavascript, pixmapFileToDataUrl
+from ..Tools.WebBrowserTools import getHtmlPage, getJquery, pixmapFileToDataUrl
 
 _SupportedPages = [
     "adblock",  # error page for URLs blocked by AdBlock
@@ -244,8 +244,8 @@
                 "@BOX-BORDER@", pixmapFileToDataUrl("box-border-small.png", True)
             )
 
-            page = page.replace("@JQUERY@", getJavascript("jquery.js"))
-            page = page.replace("@JQUERY-UI@", getJavascript("jquery-ui.js"))
+            page = page.replace("@JQUERY@", getJquery("jquery"))
+            page = page.replace("@JQUERY-UI@", getJquery("jquery-ui"))
 
             page = page.replace("@SITE-TITLE@", self.tr("Speed Dial"))
             page = page.replace("@URL@", self.tr("URL"))
--- a/src/eric7/WebBrowser/Tools/WebBrowserTools.py	Tue Jan 03 17:13:24 2023 +0100
+++ b/src/eric7/WebBrowser/Tools/WebBrowserTools.py	Wed Jan 04 12:33:48 2023 +0100
@@ -14,6 +14,8 @@
 from PyQt6.QtCore import QBuffer, QByteArray, QCoreApplication, QIODevice, QUrl
 from PyQt6.QtGui import QPixmap
 
+from eric7.SystemUtilities import OSUtilities
+
 WebBrowserDataDirectory = {
     "html": os.path.join(os.path.dirname(__file__), "..", "data", "html"),
     "icons": os.path.join(os.path.dirname(__file__), "..", "data", "icons"),
@@ -285,3 +287,27 @@
         jsFileName = os.path.join(WebBrowserDataDirectory["js"], jsFileName)
 
     return readAllFileContents(jsFileName)
+
+
+def getJquery(jqName):
+    """
+    Module function to load a JQuery source file.
+
+    Note: If the JQuery file is not found in the javascript data directory and
+    the platform is Linux, it is assumed that it is installed system wide in the
+    '/usr/share/javascript' directory (e.g. as packaged by Debian).
+
+    @param jqName name of the JQuery library to be loaded (one of 'jquery' or
+        'jquery-ui')
+    @type str
+    @return JQuery source
+    @rtype str
+    """
+    jsFileName = os.path.join(WebBrowserDataDirectory["js"], jqName + ".js")
+    if not os.path.exists(jsFileName) and OSUtilities.isLinuxPlatform():
+        if jqName == "jquery":
+            jsFileName = "/usr/share/javascript/jquery/jquery.min.js"
+        elif jqName == "jquery-ui":
+            jsFileName = "/usr/share/javascript/jquery-ui/jquery-ui.min.js"
+
+    return readAllFileContents(jsFileName)

eric ide

mercurial