mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-10-08 15:01:20 +00:00
prune unused local theme assets
This commit is contained in:
Vendored
+2
@@ -135,7 +135,9 @@
|
|||||||
{{ js_tag(scriptfile) }}
|
{{ js_tag(scriptfile) }}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
{%- if theme_theme_preview|tobool %}
|
||||||
<script type="text/javascript" src="{{ pathto('_static/js/jquery.cookie.min.js', 1) }}"></script>
|
<script type="text/javascript" src="{{ pathto('_static/js/jquery.cookie.min.js', 1) }}"></script>
|
||||||
|
{%- endif %}
|
||||||
<script type="text/javascript" src="{{ pathto('_static/js/basicstrap.js', 1) }}"></script>
|
<script type="text/javascript" src="{{ pathto('_static/js/basicstrap.js', 1) }}"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
DOCUMENTATION_OPTIONS.FILE_SUFFIX = DOCUMENTATION_OPTIONS.FILE_SUFFIX || '.html';
|
DOCUMENTATION_OPTIONS.FILE_SUFFIX = DOCUMENTATION_OPTIONS.FILE_SUFFIX || '.html';
|
||||||
|
|||||||
@@ -6,6 +6,35 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def prune_unused_local_assets(output_dir):
|
||||||
|
index_path = os.path.join(output_dir, "index.html")
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open(index_path, "r", encoding="utf-8") as index_file:
|
||||||
|
index_html = index_file.read()
|
||||||
|
except OSError:
|
||||||
|
return
|
||||||
|
|
||||||
|
if "bootswatch-" not in index_html:
|
||||||
|
for bootstrap_version in ("bootstrap2", "bootstrap3"):
|
||||||
|
css_dir = os.path.join(
|
||||||
|
output_dir, "_static", "css", bootstrap_version
|
||||||
|
)
|
||||||
|
if not os.path.isdir(css_dir):
|
||||||
|
continue
|
||||||
|
|
||||||
|
for filename in os.listdir(css_dir):
|
||||||
|
if filename.startswith("bootswatch-") and filename.endswith(".css"):
|
||||||
|
os.remove(os.path.join(css_dir, filename))
|
||||||
|
|
||||||
|
if "jquery.cookie.min.js" not in index_html:
|
||||||
|
js_dir = os.path.join(output_dir, "_static", "js")
|
||||||
|
for filename in ("jquery.cookie.min.js", "jquery.cookie-1.4.1.min.js"):
|
||||||
|
path = os.path.join(js_dir, filename)
|
||||||
|
if os.path.isfile(path):
|
||||||
|
os.remove(path)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if len(sys.argv) != 4:
|
if len(sys.argv) != 4:
|
||||||
raise SystemExit("usage: build-docs.py SOURCE_DIR OUTPUT_DIR STAMP_FILE")
|
raise SystemExit("usage: build-docs.py SOURCE_DIR OUTPUT_DIR STAMP_FILE")
|
||||||
@@ -34,6 +63,8 @@ def main():
|
|||||||
check=True,
|
check=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
prune_unused_local_assets(output_dir)
|
||||||
|
|
||||||
with open(stamp_file, "w", encoding="utf-8") as stamp:
|
with open(stamp_file, "w", encoding="utf-8") as stamp:
|
||||||
stamp.write("built\n")
|
stamp.write("built\n")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user