Compare commits

..

3 commits

Author SHA1 Message Date
Benjamin Renard
e77a96066d
CI: clean debian sid build step artifacts 2023-10-08 23:53:37 +02:00
Benjamin Renard
c0e388f09b
doc: clean all-in-one HTML file 2023-10-08 23:34:13 +02:00
Benjamin Renard
cfa2ff1e6d
doc: use mike to keep old released doc 2023-10-08 21:49:14 +02:00
5 changed files with 51 additions and 4 deletions

View file

@ -99,6 +99,7 @@ build:debian-sid:
- master - master
script: script:
- ./build-deb.sh --install-build-deps --sid - ./build-deb.sh --install-build-deps --sid
- rm -fr dist/ldapsaisie-*
artifacts: artifacts:
paths: paths:
- dist/* - dist/*
@ -138,8 +139,8 @@ build:doc:html:
- make LdapSaisie.html - make LdapSaisie.html
- test -n "$CI_COMMIT_TAG" && DOC_TAG=stable || DOC_TAG=dev - test -n "$CI_COMMIT_TAG" && DOC_TAG=stable || DOC_TAG=dev
- source venv/bin/activate # We must have to activate the venv to use mike (direct call not supported) - source venv/bin/activate # We must have to activate the venv to use mike (direct call not supported)
- mike deploy --rebase --prefix doc/dist --remote $DOC_REMOTE --push --branch $DOC_BRANCH --update-aliases $VERSION $DOC_TAG - mike deploy --branch $DOC_BRANCH --remote $DOC_REMOTE --push --update-aliases $VERSION $DOC_TAG
- mike set-default --rebase --prefix doc/dist --remote $DOC_REMOTE --push --branch $DOC_BRANCH $DOC_TAG - mike set-default --branch $DOC_BRANCH --remote $DOC_REMOTE --push $DOC_TAG
artifacts: artifacts:
paths: paths:
- doc/LdapSaisie.html - doc/LdapSaisie.html

View file

@ -4,7 +4,9 @@ public_html: venv
venv/bin/mkdocs build -s venv/bin/mkdocs build -s
LdapSaisie.html: venv public_html LdapSaisie.html: venv public_html
venv/bin/htmlark public_html/print_page/index.html -o LdapSaisie.html venv/bin/htmlark public_html/print_page/index.html -o LdapSaisie.tmp.html
venv/bin/python clean-all-in-one-html-file.py LdapSaisie.tmp.html LdapSaisie.html
rm -f LdapSaisie.tmp.html
LdapSaisie.pdf: LdapSaisie.html LdapSaisie.pdf: LdapSaisie.html
docker run -v $(CURDIR):/workspace pink33n/html-to-pdf --url file:///workspace/LdapSaisie.html --pdf LdapSaisie.pdf docker run -v $(CURDIR):/workspace pink33n/html-to-pdf --url file:///workspace/LdapSaisie.html --pdf LdapSaisie.pdf

View file

@ -0,0 +1,40 @@
import sys
import os.path
from bs4 import BeautifulSoup
# Check & handle arguments
if len(sys.argv) < 2:
print(f'Usage: {sys.argv[0]} [/path/to/input.html] [/path/to/output.html]')
sys.exit(1)
input_path = sys.argv[1]
if not os.path.exists(input_path):
print(f'{input_path} not found')
sys.exit(1)
output_path = sys.argv[2] if len(sys.argv) > 2 else input_path
# Open & parse HTML input file
with open(input_path, 'r') as fp:
soup = BeautifulSoup(fp, 'html.parser')
# Delete some useless elements
to_delete = [
(['div'], {'class': 'md-sidebar'}),
(['div'], {'class': 'md-search'}),
(['label'], {'for': '__search'}),
(['div'], {'id': 'print-site-banner'}),
(['div'], {'class': 'md-header__source'}),
]
for args, kwargs in to_delete:
for el in soup.find_all(*args, **kwargs):
el.decompose()
# Change LdapSaisie logo header link to JS scroll top action
soup.find('a', attrs={'class': 'md-logo'})['href'] = 'javascript:window.scrollTo(0,0)'
# Store resulting HTML document in output file
with open(output_path, 'w') as fp:
fp.write(str(soup))

View file

@ -27,7 +27,9 @@ plugins:
- search: - search:
lang: fr # Set language for search lang: fr # Set language for search
- mike: - mike:
canonical_version: null alias_type: symlink
deploy_prefix: doc/dist
canonical_version: dev
version_selector: true version_selector: true
css_dir: css css_dir: css
javascript_dir: js javascript_dir: js

View file

@ -7,3 +7,5 @@ html5lib
requests requests
htmlark htmlark
mike mike
git+https://github.com/jimporter/mike.git@master
beautifulsoup4