mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Merge pull request #856 from hgiesel/jquery
Update jQuery from 1.12.4 to 3.5.1, include in Bazel build process
This commit is contained in:
commit
666d847a0a
17 changed files with 110 additions and 50 deletions
|
@ -308,7 +308,7 @@ class CardLayout(QDialog):
|
|||
qconnect(pform.preview_settings.clicked, self.on_preview_settings)
|
||||
|
||||
jsinc = [
|
||||
"js/vendor/jquery.js",
|
||||
"js/vendor/jquery.min.js",
|
||||
"js/vendor/browsersel.js",
|
||||
"js/mathjax.js",
|
||||
"js/vendor/mathjax/tex-chtml.js",
|
||||
|
|
20
qt/aqt/data/web/js/vendor/BUILD.bazel
vendored
20
qt/aqt/data/web/js/vendor/BUILD.bazel
vendored
|
@ -1,5 +1,23 @@
|
|||
load("//ts:jquery.bzl", "copy_jquery")
|
||||
|
||||
copy_jquery(
|
||||
name = "jquery",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
|
||||
files = [
|
||||
"jquery",
|
||||
]
|
||||
|
||||
directories = [
|
||||
"mathjax",
|
||||
]
|
||||
|
||||
filegroup(
|
||||
name = "vendor",
|
||||
srcs = glob(["*.js"]) + ["//qt/aqt/data/web/js/vendor/mathjax"],
|
||||
srcs = glob(["*.js"])
|
||||
+ ["//qt/aqt/data/web/js/vendor:{}".format(file) for file in files]
|
||||
+ ["//qt/aqt/data/web/js/vendor/{}".format(dir) for dir in directories],
|
||||
visibility = ["//qt:__subpackages__"],
|
||||
)
|
||||
|
|
5
qt/aqt/data/web/js/vendor/jquery.js
vendored
5
qt/aqt/data/web/js/vendor/jquery.js
vendored
File diff suppressed because one or more lines are too long
|
@ -123,7 +123,11 @@ class DeckBrowser:
|
|||
self.web.stdHtml(
|
||||
self._body % content.__dict__,
|
||||
css=["css/deckbrowser.css"],
|
||||
js=["js/vendor/jquery.js", "js/vendor/jquery-ui.js", "js/deckbrowser.js"],
|
||||
js=[
|
||||
"js/vendor/jquery.min.js",
|
||||
"js/vendor/jquery-ui.js",
|
||||
"js/deckbrowser.js",
|
||||
],
|
||||
context=self,
|
||||
)
|
||||
self.web.key = "deckBrowser"
|
||||
|
|
|
@ -217,7 +217,7 @@ class Editor:
|
|||
self.web.stdHtml(
|
||||
_html % (bgcol, bgcol, topbuts, tr(TR.EDITING_SHOW_DUPLICATES)),
|
||||
css=["css/editor.css"],
|
||||
js=["js/vendor/jquery.js", "js/editor.js"],
|
||||
js=["js/vendor/jquery.min.js", "js/editor.js"],
|
||||
context=self,
|
||||
)
|
||||
|
||||
|
|
|
@ -190,10 +190,17 @@ def _redirectWebExports(path):
|
|||
else:
|
||||
addprefix = "js/"
|
||||
|
||||
if addprefix:
|
||||
oldpath = path
|
||||
path = f"{targetPath}{addprefix}{filename}"
|
||||
print(f"legacy {oldpath} remapped to {path}")
|
||||
elif dirname == "_anki/js/vendor":
|
||||
base, ext = os.path.splitext(filename)
|
||||
|
||||
if base == "jquery":
|
||||
base = "jquery.min"
|
||||
addprefix = "js/vendor/"
|
||||
|
||||
if addprefix:
|
||||
oldpath = path
|
||||
path = f"{targetPath}{addprefix}{base}{ext}"
|
||||
print(f"legacy {oldpath} remapped to {path}")
|
||||
|
||||
return _exportFolder, path[len(targetPath) :]
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ class Overview:
|
|||
self.web.stdHtml(
|
||||
self._body % content.__dict__,
|
||||
css=["css/overview.css"],
|
||||
js=["js/vendor/jquery.js", "js/overview.js"],
|
||||
js=["js/vendor/jquery.min.js", "js/overview.js"],
|
||||
context=self,
|
||||
)
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ class Previewer(QDialog):
|
|||
|
||||
def _setup_web_view(self):
|
||||
jsinc = [
|
||||
"js/vendor/jquery.js",
|
||||
"js/vendor/jquery.min.js",
|
||||
"js/vendor/browsersel.js",
|
||||
"js/mathjax.js",
|
||||
"js/vendor/mathjax/tex-chtml.js",
|
||||
|
|
|
@ -158,7 +158,7 @@ class Reviewer:
|
|||
self.revHtml(),
|
||||
css=["css/reviewer.css"],
|
||||
js=[
|
||||
"js/vendor/jquery.js",
|
||||
"js/vendor/jquery.min.js",
|
||||
"js/vendor/browsersel.js",
|
||||
"js/mathjax.js",
|
||||
"js/vendor/mathjax/tex-chtml.js",
|
||||
|
@ -171,7 +171,7 @@ class Reviewer:
|
|||
self.bottom.web.stdHtml(
|
||||
self._bottomHTML(),
|
||||
css=["css/toolbar-bottom.css", "css/reviewer-bottom.css"],
|
||||
js=["js/vendor/jquery.js", "js/reviewer-bottom.js"],
|
||||
js=["js/vendor/jquery.min.js", "js/reviewer-bottom.js"],
|
||||
context=ReviewerBottomBar(self),
|
||||
)
|
||||
|
||||
|
|
|
@ -177,7 +177,7 @@ class DeckStats(QDialog):
|
|||
self.form.web.title = "deck stats"
|
||||
self.form.web.stdHtml(
|
||||
"<html><body>" + self.report + "</body></html>",
|
||||
js=["js/vendor/jquery.js", "js/vendor/plot.js"],
|
||||
js=["js/vendor/jquery.min.js", "js/vendor/plot.js"],
|
||||
context=self,
|
||||
)
|
||||
self.mw.progress.finish()
|
||||
|
|
|
@ -48,7 +48,7 @@ class Toolbar:
|
|||
self.web.stdHtml(
|
||||
self._body % self._centerLinks(),
|
||||
css=["css/toolbar.css"],
|
||||
js=["js/webview.js", "js/vendor/jquery.js", "js/toolbar.js"],
|
||||
js=["js/webview.js", "js/vendor/jquery.min.js", "js/toolbar.js"],
|
||||
context=web_context,
|
||||
)
|
||||
self.web.adjustHeightToFit()
|
||||
|
|
|
@ -439,7 +439,7 @@ body {{ zoom: {zoom}; background: {background}; direction: {lang_dir}; {font} }}
|
|||
web_content = WebContent(
|
||||
body=body,
|
||||
head=head,
|
||||
js=["js/webview.js"] + (["js/vendor/jquery.js"] if js is None else js),
|
||||
js=["js/webview.js"] + (["js/vendor/jquery.min.js"] if js is None else js),
|
||||
css=["css/webview.css"] + ([] if css is None else css),
|
||||
)
|
||||
|
||||
|
|
28
ts/copy.bzl
Normal file
28
ts/copy.bzl
Normal file
|
@ -0,0 +1,28 @@
|
|||
def copy_files(ctx, files):
|
||||
cmds = []
|
||||
inputs = []
|
||||
outputs = []
|
||||
for (src, dst) in files:
|
||||
inputs.append(src)
|
||||
dst = ctx.actions.declare_file(dst)
|
||||
outputs.append(dst)
|
||||
cmds.append("cp -f {} {}".format(src.path, dst.path))
|
||||
|
||||
shell_fname = ctx.label.name + "-cp.sh"
|
||||
shell_file = ctx.actions.declare_file(shell_fname)
|
||||
ctx.actions.write(
|
||||
output = shell_file,
|
||||
content = "#!/bin/bash\nset -e\n" + "\n".join(cmds),
|
||||
is_executable = True,
|
||||
)
|
||||
ctx.actions.run(
|
||||
inputs = inputs,
|
||||
executable = "bash",
|
||||
tools = [shell_file],
|
||||
arguments = [shell_file.path],
|
||||
outputs = outputs,
|
||||
mnemonic = "CopyFile",
|
||||
use_default_shell_env = True,
|
||||
)
|
||||
|
||||
return [DefaultInfo(files = depset(outputs))]
|
29
ts/jquery.bzl
Normal file
29
ts/jquery.bzl
Normal file
|
@ -0,0 +1,29 @@
|
|||
load("//ts:copy.bzl", "copy_files")
|
||||
|
||||
"Rule to copy jquery subset from node_modules to vendor folder."
|
||||
|
||||
_include = [
|
||||
"dist/jquery.min.js"
|
||||
]
|
||||
|
||||
_unwanted_prefix = "external/npm/node_modules/jquery/dist/"
|
||||
|
||||
def _copy_jquery_impl(ctx):
|
||||
wanted = []
|
||||
for f in ctx.attr.jquery.files.to_list():
|
||||
path = f.path
|
||||
want = True
|
||||
|
||||
for substr in _include:
|
||||
if substr in path:
|
||||
output = path.replace(_unwanted_prefix, "")
|
||||
wanted.append((f, output))
|
||||
|
||||
return copy_files(ctx, wanted)
|
||||
|
||||
copy_jquery = rule(
|
||||
implementation = _copy_jquery_impl,
|
||||
attrs = {
|
||||
"jquery": attr.label(default = "@npm//jquery:jquery__files"),
|
||||
},
|
||||
)
|
|
@ -1,3 +1,5 @@
|
|||
load("//ts:copy.bzl", "copy_files")
|
||||
|
||||
"Rule to copy mathjax subset from node_modules to vendor folder."
|
||||
|
||||
_exclude = [
|
||||
|
@ -14,35 +16,6 @@ _include = [
|
|||
|
||||
_unwanted_prefix = "external/npm/node_modules/mathjax/es5/"
|
||||
|
||||
def _copy_files(ctx, files):
|
||||
cmds = []
|
||||
inputs = []
|
||||
outputs = []
|
||||
for (src, dst) in files:
|
||||
inputs.append(src)
|
||||
dst = ctx.actions.declare_file(dst)
|
||||
outputs.append(dst)
|
||||
cmds.append("cp -f {} {}".format(src.path, dst.path))
|
||||
|
||||
shell_fname = ctx.label.name + "-cp.sh"
|
||||
shell_file = ctx.actions.declare_file(shell_fname)
|
||||
ctx.actions.write(
|
||||
output = shell_file,
|
||||
content = "#!/bin/bash\nset -e\n" + "\n".join(cmds),
|
||||
is_executable = True,
|
||||
)
|
||||
ctx.actions.run(
|
||||
inputs = inputs,
|
||||
executable = "bash",
|
||||
tools = [shell_file],
|
||||
arguments = [shell_file.path],
|
||||
outputs = outputs,
|
||||
mnemonic = "CopyFile",
|
||||
use_default_shell_env = True,
|
||||
)
|
||||
|
||||
return [DefaultInfo(files = depset(outputs))]
|
||||
|
||||
def _copy_mathjax_impl(ctx):
|
||||
wanted = []
|
||||
for f in ctx.attr.mathjax.files.to_list():
|
||||
|
@ -60,7 +33,7 @@ def _copy_mathjax_impl(ctx):
|
|||
output = path.replace(_unwanted_prefix, "")
|
||||
wanted.append((f, output))
|
||||
|
||||
return _copy_files(ctx, wanted)
|
||||
return copy_files(ctx, wanted)
|
||||
|
||||
copy_mathjax = rule(
|
||||
implementation = _copy_mathjax_impl,
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
"intl-pluralrules": "^1.2.2",
|
||||
"lodash.debounce": "^4.0.8",
|
||||
"lodash.throttle": "^4.1.1",
|
||||
"jquery": "^3.5.1",
|
||||
"mathjax": "^3.1.2",
|
||||
"protobufjs": "^6.10.1"
|
||||
},
|
||||
|
|
|
@ -1622,6 +1622,11 @@ jest-worker@^26.2.1:
|
|||
merge-stream "^2.0.0"
|
||||
supports-color "^7.0.0"
|
||||
|
||||
jquery@^3.5.1:
|
||||
version "3.5.1"
|
||||
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.5.1.tgz#d7b4d08e1bfdb86ad2f1a3d039ea17304717abb5"
|
||||
integrity sha512-XwIBPqcMn57FxfT+Go5pzySnm4KWkT1Tv7gjrpT1srtf8Weynl6R273VJ5GjkRb51IzMp5nbaPjJXMWeju2MKg==
|
||||
|
||||
js-tokens@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
|
||||
|
|
Loading…
Reference in a new issue