Module: JekyllHighlightCards::ArchiveHelper
- Included in:
- Commands::FreezeArchives::Runner, FreezeArchives::MarkupAnalyzer, LinkcardTag, PolaroidTag
- Defined in:
- lib/jekyll-highlight-cards/archive_helper.rb
Overview
Internet Archive integration for automatic URL archival
Provides methods for looking up existing archives and submitting URLs to the Internet Archive's Wayback Machine. Results are cached per-site-build to avoid redundant API calls.
Class Attribute Summary collapse
-
.archive_cache ⇒ Object
Returns the value of attribute archive_cache.
-
.noarchive_regexp_cache ⇒ Object
Returns the value of attribute noarchive_regexp_cache.
Instance Method Summary collapse
-
#archive_enabled? ⇒ Boolean
Check if archiving is enabled via environment variables.
-
#archive_save_enabled? ⇒ Boolean
Check if SavePageNow submission is enabled.
-
#archive_url_for(url, site: nil) ⇒ String?
Get archive URL for a given URL, with caching and optional submission.
-
#archive_user_agent ⇒ String
Get User-Agent string for archive HTTP requests.
Class Attribute Details
.archive_cache ⇒ Object
Returns the value of attribute archive_cache.
20 21 22 |
# File 'lib/jekyll-highlight-cards/archive_helper.rb', line 20 def archive_cache @archive_cache end |
.noarchive_regexp_cache ⇒ Object
Returns the value of attribute noarchive_regexp_cache.
20 21 22 |
# File 'lib/jekyll-highlight-cards/archive_helper.rb', line 20 def noarchive_regexp_cache @noarchive_regexp_cache end |
Instance Method Details
#archive_enabled? ⇒ Boolean
Check if archiving is enabled via environment variables
43 44 45 |
# File 'lib/jekyll-highlight-cards/archive_helper.rb', line 43 def archive_enabled? ENV["JEKYLL_HIGHLIGHT_CARDS_ARCHIVE"] == "1" || archive_save_enabled? end |
#archive_save_enabled? ⇒ Boolean
Check if SavePageNow submission is enabled
50 51 52 |
# File 'lib/jekyll-highlight-cards/archive_helper.rb', line 50 def archive_save_enabled? ENV["JEKYLL_HIGHLIGHT_CARDS_ARCHIVE_SAVE"] == "1" end |
#archive_url_for(url, site: nil) ⇒ String?
Get archive URL for a given URL, with caching and optional submission
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/jekyll-highlight-cards/archive_helper.rb', line 28 def archive_url_for(url, site: nil) return nil unless archiveable_url?(url, site: site) ArchiveHelper.archive_cache[url] ||= begin archive_url = lookup_archive(url) archive_url = submit_archive(url) || archive_url if archive_save_enabled? archive_url end end |
#archive_user_agent ⇒ String
Get User-Agent string for archive HTTP requests
57 58 59 60 |
# File 'lib/jekyll-highlight-cards/archive_helper.rb', line 57 def archive_user_agent ENV["JEKYLL_HIGHLIGHT_CARDS_ARCHIVE_UA"] || "jekyll:highlight-cards (+#{ENV.fetch("JEKYLL_HIGHLIGHT_CARDS_ARCHIVE_CONTACT", "mailto:unknown")})" end |