Module: JekyllHighlightCards::ArchiveHelper
- Included in:
- 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.
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) ⇒ 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 |
Instance Method Details
#archive_enabled? ⇒ Boolean
Check if archiving is enabled via environment variables
40 41 42 |
# File 'lib/jekyll-highlight-cards/archive_helper.rb', line 40 def archive_enabled? ENV["JEKYLL_HIGHLIGHT_CARDS_ARCHIVE"] == "1" || archive_save_enabled? end |
#archive_save_enabled? ⇒ Boolean
Check if SavePageNow submission is enabled
47 48 49 |
# File 'lib/jekyll-highlight-cards/archive_helper.rb', line 47 def archive_save_enabled? ENV["JEKYLL_HIGHLIGHT_CARDS_ARCHIVE_SAVE"] == "1" end |
#archive_url_for(url) ⇒ String?
Get archive URL for a given URL, with caching and optional submission
27 28 29 30 31 32 33 34 35 |
# File 'lib/jekyll-highlight-cards/archive_helper.rb', line 27 def archive_url_for(url) 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
54 55 56 57 |
# File 'lib/jekyll-highlight-cards/archive_helper.rb', line 54 def archive_user_agent ENV["JEKYLL_HIGHLIGHT_CARDS_ARCHIVE_UA"] || "jekyll:highlight-cards (+#{ENV.fetch("JEKYLL_HIGHLIGHT_CARDS_ARCHIVE_CONTACT", "mailto:unknown")})" end |