Rakefile 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # -*- coding: utf-8 -*-
  2. # -*- frozen_string_literal: true -*-
  3. task :default => :validate
  4. desc "Run Search & Deploy locally"
  5. task :demo do
  6. SearchAndDeploy.demo
  7. end
  8. desc "Publish Search & Deploy"
  9. task :publish do
  10. SearchAndDeploy.publish "./public"
  11. end
  12. desc "Validate Search & Deploy pages"
  13. task :validate do
  14. ENV["JEKYLL_ENV"] = "testing"
  15. Dir.mktmpdir { |dir|
  16. SearchAndDeploy.publish dir
  17. SearchAndDeploy.validate dir
  18. }
  19. end
  20. require "html-proofer"
  21. class SearchAndDeploy
  22. VALIDATION_POLICY = {
  23. # check_sri: true, # commented out due to google fonts
  24. enforce_https: false, # many references still use http only
  25. check_img_http: true,
  26. check_html: true,
  27. allow_hash_href: true,
  28. check_favicon: true,
  29. disable_external: true
  30. }
  31. def self.publish dir, env=ENV
  32. system(
  33. {"JEKYLL_ENV"=>env.delete("JEKYLL_ENV")},
  34. *%W[
  35. jekyll build
  36. -d #{dir}
  37. --config _config.yml,_config_production.yml
  38. ]
  39. )
  40. end
  41. def self.validate dir, policy=VALIDATION_POLICY
  42. HTMLProofer.check_directory(dir, policy).run
  43. end
  44. def self.demo
  45. system({"JEKYLL_ENV"=>"development"}, *%W[jekyll serve])
  46. end
  47. end