mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-03-23 09:20:30 +00:00
Except for tests that include non-unicode characters: tests/test_po.py tests/test_strformat.py tests/test_url.py tests/checker/test_error.py tests/checker/test_news.py
39 lines
1,018 B
Python
39 lines
1,018 B
Python
# Hook routines for the wok static site generator.
|
|
# Note that mediacompress is a local module.
|
|
import os
|
|
|
|
|
|
def compress_javascript(config, output_path):
|
|
"""Minify JS files."""
|
|
try:
|
|
from mediacompress import compress_js_files
|
|
except ImportError:
|
|
pass
|
|
else:
|
|
compress_js_files(output_path, excludes=("*.min.js",))
|
|
|
|
|
|
def compress_css(config, output_path):
|
|
"""Minify CSS files."""
|
|
try:
|
|
from mediacompress import compress_css_files
|
|
except ImportError:
|
|
pass
|
|
else:
|
|
compress_css_files(output_path)
|
|
|
|
|
|
def chmod(config):
|
|
"""Set correct file permissions."""
|
|
output_dir = config["output_dir"]
|
|
for dirpath, dirnames, filenames in os.walk(output_dir):
|
|
for dirname in dirnames:
|
|
os.chmod(os.path.join(dirpath, dirname), 0755)
|
|
for filename in filenames:
|
|
os.chmod(os.path.join(dirpath, filename), 0644)
|
|
|
|
|
|
hooks = {
|
|
'site.output.post': [compress_javascript, compress_css],
|
|
'site.done': [chmod],
|
|
}
|