compressor.py 1007 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # -*- coding: utf-8 -*-
  2. """
  3. css-js-minify wrapper for Pelican
  4. """
  5. import glob
  6. from .minify import (
  7. process_single_css_file,
  8. process_single_js_file,
  9. )
  10. from pelican import signals
  11. CSS_DIR = '/theme/css'
  12. JS_DIR = '/theme/js'
  13. def main(pelican):
  14. """ Compiler """
  15. for file in glob.iglob(pelican.output_path + CSS_DIR + '/**/*.css', recursive=True):
  16. process_single_css_file(file, overwrite=True)
  17. for file in glob.iglob(pelican.output_path + JS_DIR + '/**/*.js', recursive=True):
  18. process_single_js_file(file, overwrite=True)
  19. def register():
  20. """ Register """
  21. signals.finalized.connect(main)
  22. SUPPORT_JS = """
  23. -----------------------------------------------------------------
  24. COMPRESSOR:
  25. -----------------------------------------------------------------
  26. Future JavaScript support is orphan and not supported!
  27. If you want to make ES6,ES7 work feel free to send pull requests.
  28. -----------------------------------------------------------------
  29. """
  30. print(SUPPORT_JS)