|
1 | 1 | #!/usr/bin/python3
|
2 | 2 |
|
3 |
| -import argparse, yaml, tempfile, os, subprocess, json, jinja2, datetime, copy, re, dnf, pprint, urllib.request, sys, koji |
| 3 | +import argparse, yaml, tempfile, os, subprocess, json, jinja2, datetime, copy, re, dnf, pprint, urllib.request, sys, koji, htmlmin |
4 | 4 | import concurrent.futures
|
5 | 5 | import rpm_showme as showme
|
6 | 6 | from functools import lru_cache
|
@@ -159,11 +159,13 @@ def load_settings(argv=None):
|
159 | 159 | parser.add_argument("--use-cache", dest="use_cache", action='store_true', help="Use local data instead of pulling Content Resolver. Saves a lot of time! Needs a 'cache_data.json' file at the same location as the script is at.")
|
160 | 160 | parser.add_argument("--dev-buildroot", dest="dev_buildroot", action='store_true', help="Buildroot grows pretty quickly. Use a fake one for development.")
|
161 | 161 | parser.add_argument("--dnf-cache-dir", dest="dnf_cache_dir_override", help="Override the dnf cache_dir.")
|
| 162 | + parser.add_argument("--htmlmin", dest="htmlmin", action='store_true', help="Run html minimiser while producing the pages.") |
162 | 163 | args = parser.parse_args(argv)
|
163 | 164 |
|
164 | 165 | settings["configs"] = args.configs
|
165 | 166 | settings["output"] = args.output
|
166 | 167 | settings["use_cache"] = args.use_cache
|
| 168 | + settings["htmlmin"] = args.htmlmin |
167 | 169 | settings["dev_buildroot"] = args.dev_buildroot
|
168 | 170 | settings["dnf_cache_dir_override"] = args.dnf_cache_dir_override
|
169 | 171 |
|
@@ -5721,6 +5723,13 @@ def _generate_html_page(template_name, template_data, page_name, settings):
|
5721 | 5723 |
|
5722 | 5724 | page = template.render(**template_data)
|
5723 | 5725 |
|
| 5726 | + if settings["htmlmin"]: |
| 5727 | + try: |
| 5728 | + page = htmlmin.minify(page, remove_empty_space=True) |
| 5729 | + except Exception as e: |
| 5730 | + log(" Minification failed for... ({})".format(filename)) |
| 5731 | + |
| 5732 | + |
5724 | 5733 | filename = ("{page_name}.html".format(
|
5725 | 5734 | page_name=page_name.replace(":", "--")
|
5726 | 5735 | ))
|
|
0 commit comments