Class: JekyllHighlightCards::Commands::FreezeArchives
- Inherits:
-
Jekyll::Command
- Object
- Jekyll::Command
- JekyllHighlightCards::Commands::FreezeArchives
- Defined in:
- lib/jekyll-highlight-cards/commands/freeze_archives.rb
Overview
Opt-in Jekyll subcommand: jekyll freeze-archives
Scans site source for archive-eligible linkcard / polaroid tags that
lack an encoded archive, looks up Internet Archive, and surgically inserts
successful hits into source. Does not run during jekyll build.
Defined Under Namespace
Classes: Runner
Class Method Summary collapse
-
.init_with_program(prog) ⇒ void
Register the
freeze-archivesMercenary subcommand. -
.process(options) ⇒ Hash
Run freeze-archives against a configured site.
Class Method Details
.init_with_program(prog) ⇒ void
This method returns an undefined value.
Register the freeze-archives Mercenary subcommand
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/jekyll-highlight-cards/commands/freeze_archives.rb', line 18 def init_with_program(prog) prog.command(:"freeze-archives") do |c| c.syntax "freeze-archives [options]" c.description "Freeze Internet Archive URLs into highlight-card source tags" c.option "dry_run", "--dry-run", "Report planned edits without writing files" c.option "save", "--save", "Enable SavePageNow when CDX has no snapshot" c.option "config", "--config CONFIG_FILE[,CONFIG_FILE2,...]", Array, "Custom configuration file" c.option "source", "-s", "--source SOURCE", "Custom source directory" c.action do |_args, | process() end end end |
.process(options) ⇒ Hash
Run freeze-archives against a configured site
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/jekyll-highlight-cards/commands/freeze_archives.rb', line 39 def process() previous_save = ENV.fetch("JEKYLL_HIGHLIGHT_CARDS_ARCHIVE_SAVE", nil) previous_log_level = Jekyll.logger.level ENV["JEKYLL_HIGHLIGHT_CARDS_ARCHIVE_SAVE"] = "1" if ["save"] site = Jekyll::Site.new(()) # Hand-run tool: keep progress visible even if the site sets quiet: true Jekyll.logger.log_level = :info unless ["quiet"] site.read summary = Runner.new( dry_run: ["dry_run"], logger: Jekyll.logger ).run(site) Jekyll.logger.info "freeze-archives:", "frozen=#{summary[:frozen]} skipped=#{summary[:skipped]} " \ "miss=#{summary[:miss]} written=#{summary[:written]}" summary ensure restore_save_env(previous_save, ) Jekyll.logger.log_level = previous_log_level if previous_log_level end |