mirror of
https://github.com/tcsenpai/Zundler.git
synced 2025-06-06 19:45:27 +00:00
Clean up; update README; rename to zundler
This commit is contained in:
parent
a6e63be6ee
commit
52eb8afc19
81
README.md
Normal file
81
README.md
Normal file
@ -0,0 +1,81 @@
|
||||
Zundler
|
||||
=======
|
||||
|
||||
Bundle assets of distributed HTML docs into one self-contained HTML file.
|
||||
|
||||
Naively building one HTML file out of a directory of HTML files that total
|
||||
dozens of megabytes quickly overwhelm modern browsers. Zundler solves this
|
||||
by taking the following approach:
|
||||
|
||||
* Embed all assets that are referenced in CSS files, such as imports and
|
||||
fonts
|
||||
* Endow all HTML files with extra scripts that embed these resources at run time:
|
||||
* Convert `script` tags with a `src` attribute referencing a JavaScript
|
||||
file to inline scripts
|
||||
* Convert `link` tags with an `href` attribute referencing a CSS file to inline styles
|
||||
* Make all `img` tags with a `src` attribute referencing local images use a data URI
|
||||
* Monkey patch the JavaScript function `fetch` and the class `URLSearchParams`
|
||||
* Create a JSON structure (the "global context") out of all files in the directory (the "virtual file tree") and other data
|
||||
* Gzip this scructure and base64-encode it
|
||||
* Bundle it all into a scuffolding file with this structure:
|
||||
```html
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head><style>{style}</style></head>
|
||||
<body>{body}
|
||||
<script>window.global_context = {global_context}</script>
|
||||
<script>{pako} //# sourceURL=pako.js</script>
|
||||
<script>{init_js} //# sourceURL=init.js</script>
|
||||
</body></html>
|
||||
```
|
||||
The global context is then unzipped, an `iframe` is created and the
|
||||
document is bootstrapped from the virtual file tree.
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
Zundler is a Python package and can be installed like any other Python
|
||||
package.
|
||||
|
||||
The recommended way is to clone this repository and type `pip install .`.
|
||||
If you prefer an alternative like `pipx`, `poetry` or manually handled
|
||||
`venv`s, you probably know what to do.
|
||||
|
||||
An entry point called `zundler` will appear in `~/.local/bin`.
|
||||
|
||||
|
||||
Bundling Sphinx docs
|
||||
--------------------
|
||||
|
||||
Providing a Sphinx extension does not make sense, because it would need to
|
||||
add a new builder. Similar to the `latexpdf`
|
||||
|
||||
Suggested Makefile addition:
|
||||
|
||||
```make
|
||||
.PHONY: latexpdf
|
||||
latexpdf:
|
||||
$(SPHINXBUILD) -b zundler $(ALLSPHINXOPTS) $(BUILDDIR)/html
|
||||
@echo "Bundle asset into one self-contained HTML file..."
|
||||
$(MAKE) -C $(BUILDDIR)/html
|
||||
@echo "Zundler finished; the HTML file is in $(BUILDDIR)/zundler."
|
||||
```
|
||||
|
||||
Demos
|
||||
-----
|
||||
|
||||
...
|
||||
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
|
||||
This approach is quite hacky, but it might work well enough for your
|
||||
purposes.
|
||||
|
||||
|
||||
Copyright
|
||||
---------
|
||||
|
||||
Adrian Vollmer, 2022. MIT licensed; see `LICENSE` for details.
|
19
README.rst
19
README.rst
@ -1,19 +0,0 @@
|
||||
========================================
|
||||
sphinxcontrib-sphinx-self-contained-html
|
||||
========================================
|
||||
|
||||
.. image:: https://travis-ci.org/AdrianVollmer/sphinxcontrib-sphinx-self-contained-html.svg?branch=master
|
||||
:target: https://travis-ci.org/AdrianVollmer/sphinxcontrib-sphinx-self-contained-html
|
||||
|
||||
A Sphinx extension that allows generating completely self-contained HTML documents
|
||||
|
||||
Overview
|
||||
--------
|
||||
|
||||
Add a longer description here.
|
||||
|
||||
Links
|
||||
-----
|
||||
|
||||
- Source: https://github.com/AdrianVollmer/sphinxcontrib-sphinx-self-contained-html
|
||||
- Bugs: https://github.com/AdrianVollmer/sphinxcontrib-sphinx-self-contained-html/issues
|
@ -1 +0,0 @@
|
||||
pbr
|
17
setup.cfg
17
setup.cfg
@ -1,7 +1,7 @@
|
||||
[metadata]
|
||||
name = self-contained-html
|
||||
summary = Convert distributed HTML docs to completely self-contained HTML docs
|
||||
description_file = README.rst
|
||||
name = Zundler
|
||||
summary = Bundle assets of distributed HTML docs into one self-contained HTML file
|
||||
description_file = README.md
|
||||
author = Adrian Vollmer
|
||||
author_email = computerfluesterer@protonmail.com
|
||||
home_page = https://github.com/AdrianVollmer/self-contained-html
|
||||
@ -23,9 +23,18 @@ classifier =
|
||||
Topic :: Documentation :: Sphinx
|
||||
Topic :: Utilities
|
||||
|
||||
[options]
|
||||
zip_safe = False
|
||||
include_package_data = True
|
||||
packages = find:
|
||||
install_requires =
|
||||
sphinx
|
||||
bs4
|
||||
importlib-metadata; python_version<"3.8"
|
||||
|
||||
[options.entry_points]
|
||||
console_scripts =
|
||||
bundle-html = src.__main__:main
|
||||
zundler = src.__main__:main
|
||||
|
||||
[files]
|
||||
packages = src
|
||||
|
@ -10,4 +10,4 @@ def main():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pass
|
||||
main()
|
||||
|
@ -10,7 +10,7 @@ except ImportError:
|
||||
try:
|
||||
__version__ = importlib_metadata.version(__package__ or __name__)
|
||||
# __summary__ = importlib_metadata.metadata(__package__ or __name__)['summary']
|
||||
__summary__ = "Convert distributed HTML docs to completely self-contained HTML docs"
|
||||
__summary__ = "Bundle assets of distributed HTML docs into one self-contained HTML file"
|
||||
except importlib_metadata.PackageNotFoundError:
|
||||
__version__ = "??"
|
||||
__summary__ = "??"
|
||||
|
@ -1,2 +0,0 @@
|
||||
pytest
|
||||
sphinx
|
@ -1,9 +0,0 @@
|
||||
"""
|
||||
pytest config for sphinxcontrib/sphinx-self-contained-html/tests
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
:copyright: Copyright 2017 by Adrian Vollmer <computerfluesterer@protonmail.com>
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
|
||||
pytest_plugins = 'sphinx.testing.fixtures'
|
32
tox.ini
32
tox.ini
@ -1,32 +0,0 @@
|
||||
[tox]
|
||||
minversion = 2.0
|
||||
envlist = py{34,35,36,py},style
|
||||
|
||||
[testenv]
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
commands=
|
||||
pytest
|
||||
|
||||
[testenv:mypy]
|
||||
description =
|
||||
Run type checks.
|
||||
deps =
|
||||
mypy
|
||||
commands=
|
||||
mypy sphinxcontrib
|
||||
|
||||
[testenv:style]
|
||||
description =
|
||||
Run style checks.
|
||||
deps =
|
||||
flake8
|
||||
isort
|
||||
yapf
|
||||
commands =
|
||||
isort -rc -c -df sphinxcontrib tests
|
||||
yapf -rd sphinxcontrib tests
|
||||
flake8 sphinxcontrib tests setup.py
|
||||
|
||||
[travis]
|
||||
python =
|
||||
3.6: py36, mypy, style
|
Loading…
x
Reference in New Issue
Block a user