|
40 | 40 | # normally this is just used by the `conf.py` file for building a runestone book |
41 | 41 | def runestone_static_dirs(): |
42 | 42 | basedir = os.path.dirname(__file__) |
43 | | - module_paths = [ |
44 | | - x for x in os.listdir(basedir) if os.path.isdir(os.path.join(basedir, x)) |
45 | | - ] |
46 | 43 | module_static_js = [os.path.join(basedir, "dist")] |
47 | | - module_static_js.append(os.path.join(basedir, "common", "js")) |
48 | 44 | module_static_js.append(os.path.join(basedir, "animation", "js")) |
49 | 45 | module_static_js.append(os.path.join(basedir, "codelens", "js")) |
50 | 46 | module_static_js.append(os.path.join(basedir, "webgldemo", "js")) |
51 | 47 | module_static_js.append(os.path.join(basedir, "matrixeq", "js")) |
52 | | - module_static_css = [os.path.join(basedir, "common", "css")] |
53 | | - module_static_css.append(os.path.join(basedir, "codelens", "css")) |
| 48 | + module_static_css = [os.path.join(basedir, "common", "css", "sphinx")] |
54 | 49 | module_static_css.append(os.path.join(basedir, "accessibility", "css")) |
55 | 50 | module_static_css.append(os.path.join(basedir, "webgldemo", "css")) |
56 | 51 | module_static_css.append(os.path.join(basedir, "matrixeq", "css")) |
57 | 52 | module_static_css.append(os.path.join(basedir, "lp", "css")) |
58 | | - module_static_image = [ |
59 | | - "%s/images" % os.path.join(basedir, x) |
60 | | - for x in module_paths |
61 | | - if os.path.exists("%s/images" % os.path.join(basedir, x)) |
62 | | - ] |
63 | | - module_static_bootstrap = [ |
64 | | - "%s/bootstrap" % os.path.join(basedir, x) |
65 | | - for x in module_paths |
66 | | - if os.path.exists("%s/bootstrap" % os.path.join(basedir, x)) |
67 | | - ] |
68 | | - |
69 | 53 | return ( |
70 | 54 | module_static_js |
71 | 55 | + module_static_css |
72 | | - + module_static_image |
73 | | - + module_static_bootstrap |
74 | | - + [os.path.join(basedir, "common/project_template/_static")] |
75 | 56 | + CodeChat.CodeToRest.html_static_path() |
76 | 57 | ) |
77 | 58 |
|
@@ -105,16 +86,18 @@ def setup(app): |
105 | 86 | This could be expanded if there is additional initialization or customization |
106 | 87 | we wanted to do for all projects. |
107 | 88 | """ |
108 | | - # Include JS produced by webpack. See `webpack static imports <webpack_static_imports>`_. |
| 89 | + # Include JS and CSS produced by webpack. See `webpack static imports <webpack_static_imports>`_. |
109 | 90 | with open(pkg_resources.resource_filename("runestone", "dist/webpack_static_imports.json"), "r", encoding="utf-8") as f: |
110 | | - _script_files = script_files + json.load(f) |
| 91 | + wb_imports = json.load(f) |
| 92 | + script_files = wb_imports["js"] |
| 93 | + _css_files = css_files + wb_imports["css"] |
111 | 94 |
|
112 | | - for jsfile in _script_files: |
| 95 | + for jsfile in script_files: |
113 | 96 | try: |
114 | 97 | app.add_autoversioned_javascript(jsfile) |
115 | 98 | except ExtensionError: |
116 | 99 | app.add_js_file(jsfile) |
117 | | - for cssfile in css_files: |
| 100 | + for cssfile in _css_files: |
118 | 101 | try: |
119 | 102 | app.add_autoversioned_stylesheet(cssfile) |
120 | 103 | except ExtensionError: |
@@ -190,33 +173,10 @@ def build(options): |
190 | 173 | # ---------------- |
191 | 174 | runestone_version = version = pkg_resources.get_distribution("runestone").version |
192 | 175 |
|
193 | | -script_files = [ |
194 | | - "https://cdnjs.cloudflare.com/ajax/libs/jquery.i18n/1.0.5/jquery.i18n.js", |
195 | | - "https://cdnjs.cloudflare.com/ajax/libs/jquery.i18n/1.0.5/jquery.i18n.emitter.bidi.js", |
196 | | - "https://cdnjs.cloudflare.com/ajax/libs/jquery.i18n/1.0.5/jquery.i18n.emitter.js", |
197 | | - "https://cdnjs.cloudflare.com/ajax/libs/jquery.i18n/1.0.5/jquery.i18n.fallbacks.js", |
198 | | - "https://cdnjs.cloudflare.com/ajax/libs/jquery.i18n/1.0.5/jquery.i18n.messagestore.js", |
199 | | - "https://cdnjs.cloudflare.com/ajax/libs/jquery.i18n/1.0.5/jquery.i18n.parser.js", |
200 | | - "https://cdnjs.cloudflare.com/ajax/libs/jquery.i18n/1.0.5/jquery.i18n.language.js", |
201 | | - "https://cdn.jsdelivr.net/npm/vega@4.0.0-rc.2/build/vega.js", |
202 | | - "https://cdn.jsdelivr.net/npm/vega-lite@2.5.0/build/vega-lite.js", |
203 | | - "https://cdn.jsdelivr.net/npm/vega-embed@3.14.0/build/vega-embed.js", |
204 | | - |
205 | | - "jquery-ui-1.10.3.custom.min.js", |
206 | | - "bootstrap-3.4.1/js/bootstrap.min.js", |
207 | | - "jquery-fix.js", # required by bootstrap theme |
208 | | - "bootstrap-sphinx.js", |
209 | | - "jquery.idle-timer.js", |
210 | | - "presenter_mode.js", |
211 | | - "theme.js", |
212 | | -] |
213 | | - |
214 | 176 | css_files = [ |
215 | | - "bootstrap-3.4.1/css/bootstrap.min.css", |
216 | | - "presenter_mode.css", |
217 | | - "jquery-ui-1.10.3.custom.min.css", |
| 177 | + # Generated from a template, so it can't be directly included in the webpack. |
218 | 178 | "bootstrap-sphinx.css", |
219 | | - "runestone-custom-sphinx-bootstrap.css?v=" + runestone_version, |
| 179 | + # Deliberately excluded, so it can be overridden by a user-supplied CSs file. |
220 | 180 | "theme-overrides.css", |
221 | 181 | ] |
222 | 182 |
|
|
0 commit comments