jekyll-archive_link 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/main.yml +18 -0
- data/.gitignore +14 -0
- data/.rspec +3 -0
- data/.rubocop.yml +29 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +139 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +12 -0
- data/bin/console +16 -0
- data/bin/setup +8 -0
- data/jekyll-archive_link.gemspec +47 -0
- data/lib/jekyll/archive_link/invalid_url.rb +8 -0
- data/lib/jekyll/archive_link/logger.rb +8 -0
- data/lib/jekyll/archive_link/tag.rb +28 -0
- data/lib/jekyll/archive_link/tmp_dir_cache.rb +47 -0
- data/lib/jekyll/archive_link/url.rb +73 -0
- data/lib/jekyll/archive_link/version.rb +7 -0
- data/lib/jekyll/archive_link.rb +30 -0
- data/lib/jekyll-archive_link.rb +3 -0
- metadata +223 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4f892e18cde2a535f384b06d5456a7237e1dbaba2d56d412de0975c08caf0024
|
4
|
+
data.tar.gz: 4efc52a78dc5550383dc13ab578d23a1d5e8e5e082d7ace39d773382b7c9f9ab
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5ef6970a861340a9c6db7694434f54dd13ea6281e77c72d5f44ce43a9cf3e75f18fa931d9c0a435ff94fde5e53ee44993ef5472c2b91f3daa6556b9d3987cb3b
|
7
|
+
data.tar.gz: e8125274b9da424bbba72d61b52beab47888a9220a557b8cfe1f17700f4b8f359397d23f7bd0ae3d5ed7bc29614d23bfcb1531da8d13e2437f9a89db9f214c54
|
@@ -0,0 +1,18 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on: [push,pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
steps:
|
9
|
+
- uses: actions/checkout@v2
|
10
|
+
- name: Set up Ruby
|
11
|
+
uses: ruby/setup-ruby@v1
|
12
|
+
with:
|
13
|
+
ruby-version: 3.1.0
|
14
|
+
- name: Run the default task
|
15
|
+
run: |
|
16
|
+
gem install bundler -v 2.2.6
|
17
|
+
bundle install
|
18
|
+
bundle exec rake
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 3.0
|
3
|
+
NewCops: enable
|
4
|
+
|
5
|
+
Style/Documentation:
|
6
|
+
Enabled: false
|
7
|
+
|
8
|
+
Style/StringLiterals:
|
9
|
+
Enabled: true
|
10
|
+
EnforcedStyle: double_quotes
|
11
|
+
|
12
|
+
Style/StringLiteralsInInterpolation:
|
13
|
+
Enabled: true
|
14
|
+
EnforcedStyle: double_quotes
|
15
|
+
|
16
|
+
Style/PercentLiteralDelimiters:
|
17
|
+
PreferredDelimiters:
|
18
|
+
default: "[]"
|
19
|
+
|
20
|
+
Layout/LineLength:
|
21
|
+
Max: 80
|
22
|
+
|
23
|
+
Metrics/BlockLength:
|
24
|
+
Exclude:
|
25
|
+
- spec/**/*_spec.rb
|
26
|
+
- jekyll-archive_link.gemspec
|
27
|
+
|
28
|
+
Naming/FileName:
|
29
|
+
Exclude: [lib/jekyll-archive_link.rb]
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
jekyll-archive_link (0.1.0)
|
5
|
+
faraday (~> 2.3)
|
6
|
+
faraday-http-cache (~> 2.4)
|
7
|
+
jekyll (~> 4.0)
|
8
|
+
liquid (~> 4.0)
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
addressable (2.8.0)
|
14
|
+
public_suffix (>= 2.0.2, < 5.0)
|
15
|
+
ast (2.4.2)
|
16
|
+
colorator (1.1.0)
|
17
|
+
concurrent-ruby (1.1.10)
|
18
|
+
crack (0.4.5)
|
19
|
+
rexml
|
20
|
+
diff-lcs (1.5.0)
|
21
|
+
em-websocket (0.5.3)
|
22
|
+
eventmachine (>= 0.12.9)
|
23
|
+
http_parser.rb (~> 0)
|
24
|
+
eventmachine (1.2.7)
|
25
|
+
faraday (2.3.0)
|
26
|
+
faraday-net_http (~> 2.0)
|
27
|
+
ruby2_keywords (>= 0.0.4)
|
28
|
+
faraday-http-cache (2.4.0)
|
29
|
+
faraday (>= 0.8)
|
30
|
+
faraday-net_http (2.0.3)
|
31
|
+
ffi (1.15.5)
|
32
|
+
forwardable-extended (2.6.0)
|
33
|
+
hashdiff (1.0.1)
|
34
|
+
http_parser.rb (0.8.0)
|
35
|
+
i18n (1.10.0)
|
36
|
+
concurrent-ruby (~> 1.0)
|
37
|
+
jekyll (4.2.2)
|
38
|
+
addressable (~> 2.4)
|
39
|
+
colorator (~> 1.0)
|
40
|
+
em-websocket (~> 0.5)
|
41
|
+
i18n (~> 1.0)
|
42
|
+
jekyll-sass-converter (~> 2.0)
|
43
|
+
jekyll-watch (~> 2.0)
|
44
|
+
kramdown (~> 2.3)
|
45
|
+
kramdown-parser-gfm (~> 1.0)
|
46
|
+
liquid (~> 4.0)
|
47
|
+
mercenary (~> 0.4.0)
|
48
|
+
pathutil (~> 0.9)
|
49
|
+
rouge (~> 3.0)
|
50
|
+
safe_yaml (~> 1.0)
|
51
|
+
terminal-table (~> 2.0)
|
52
|
+
jekyll-sass-converter (2.2.0)
|
53
|
+
sassc (> 2.0.1, < 3.0)
|
54
|
+
jekyll-watch (2.2.1)
|
55
|
+
listen (~> 3.0)
|
56
|
+
json (2.6.2)
|
57
|
+
kramdown (2.4.0)
|
58
|
+
rexml
|
59
|
+
kramdown-parser-gfm (1.1.0)
|
60
|
+
kramdown (~> 2.0)
|
61
|
+
liquid (4.0.3)
|
62
|
+
listen (3.7.1)
|
63
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
64
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
65
|
+
mercenary (0.4.0)
|
66
|
+
parallel (1.22.1)
|
67
|
+
parser (3.1.2.0)
|
68
|
+
ast (~> 2.4.1)
|
69
|
+
pathutil (0.16.2)
|
70
|
+
forwardable-extended (~> 2.6)
|
71
|
+
public_suffix (4.0.7)
|
72
|
+
rainbow (3.1.1)
|
73
|
+
rake (13.0.6)
|
74
|
+
rb-fsevent (0.11.1)
|
75
|
+
rb-inotify (0.10.1)
|
76
|
+
ffi (~> 1.0)
|
77
|
+
regexp_parser (2.5.0)
|
78
|
+
rexml (3.2.5)
|
79
|
+
rouge (3.29.0)
|
80
|
+
rspec (3.11.0)
|
81
|
+
rspec-core (~> 3.11.0)
|
82
|
+
rspec-expectations (~> 3.11.0)
|
83
|
+
rspec-mocks (~> 3.11.0)
|
84
|
+
rspec-core (3.11.0)
|
85
|
+
rspec-support (~> 3.11.0)
|
86
|
+
rspec-expectations (3.11.0)
|
87
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
88
|
+
rspec-support (~> 3.11.0)
|
89
|
+
rspec-mocks (3.11.1)
|
90
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
91
|
+
rspec-support (~> 3.11.0)
|
92
|
+
rspec-support (3.11.0)
|
93
|
+
rubocop (1.31.2)
|
94
|
+
json (~> 2.3)
|
95
|
+
parallel (~> 1.10)
|
96
|
+
parser (>= 3.1.0.0)
|
97
|
+
rainbow (>= 2.2.2, < 4.0)
|
98
|
+
regexp_parser (>= 1.8, < 3.0)
|
99
|
+
rexml (>= 3.2.5, < 4.0)
|
100
|
+
rubocop-ast (>= 1.18.0, < 2.0)
|
101
|
+
ruby-progressbar (~> 1.7)
|
102
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
103
|
+
rubocop-ast (1.19.0)
|
104
|
+
parser (>= 3.1.1.0)
|
105
|
+
rubocop-performance (1.14.3)
|
106
|
+
rubocop (>= 1.7.0, < 2.0)
|
107
|
+
rubocop-ast (>= 0.4.0)
|
108
|
+
rubocop-rake (0.6.0)
|
109
|
+
rubocop (~> 1.0)
|
110
|
+
rubocop-rspec (2.12.1)
|
111
|
+
rubocop (~> 1.31)
|
112
|
+
ruby-progressbar (1.11.0)
|
113
|
+
ruby2_keywords (0.0.5)
|
114
|
+
safe_yaml (1.0.5)
|
115
|
+
sassc (2.4.0)
|
116
|
+
ffi (~> 1.9)
|
117
|
+
terminal-table (2.0.0)
|
118
|
+
unicode-display_width (~> 1.1, >= 1.1.1)
|
119
|
+
unicode-display_width (1.8.0)
|
120
|
+
webmock (3.14.0)
|
121
|
+
addressable (>= 2.8.0)
|
122
|
+
crack (>= 0.3.2)
|
123
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
124
|
+
|
125
|
+
PLATFORMS
|
126
|
+
x86_64-darwin-21
|
127
|
+
|
128
|
+
DEPENDENCIES
|
129
|
+
jekyll-archive_link!
|
130
|
+
rake (~> 13.0)
|
131
|
+
rspec (~> 3.11)
|
132
|
+
rubocop (~> 1.31)
|
133
|
+
rubocop-performance (~> 1.14)
|
134
|
+
rubocop-rake (~> 0.6)
|
135
|
+
rubocop-rspec (~> 2.12)
|
136
|
+
webmock (~> 3.14)
|
137
|
+
|
138
|
+
BUNDLED WITH
|
139
|
+
2.3.12
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 Bodacious
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Jekyll::Archive::Link
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/jekyll/archive/link`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'jekyll-archive-link'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install jekyll-archive-link
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/jekyll-archive-link.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "jekyll"
|
6
|
+
require "jekyll/archive_link"
|
7
|
+
|
8
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
9
|
+
# with your gem easier. You can also use a different console, if you like.
|
10
|
+
|
11
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
12
|
+
# require "pry"
|
13
|
+
# Pry.start
|
14
|
+
|
15
|
+
require "irb"
|
16
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
$LOAD_PATH << File.expand_path("lib", __dir__)
|
4
|
+
|
5
|
+
require "jekyll/archive_link/version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "jekyll-archive_link"
|
9
|
+
spec.version = Jekyll::ArchiveLink::VERSION
|
10
|
+
spec.authors = ["Bodacious"]
|
11
|
+
spec.email = ["gavin@gavinmorrice.com"]
|
12
|
+
|
13
|
+
spec.summary = "Adds a link to Archive.org's wayback machine"
|
14
|
+
spec.description = <<~DESC
|
15
|
+
Adds a link to Archive.org's wayback machine's latest capture
|
16
|
+
DESC
|
17
|
+
spec.homepage = "https://github.com/bodacious/jekyll-archive_link"
|
18
|
+
spec.license = "MIT"
|
19
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 3.0 ")
|
20
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
21
|
+
spec.metadata["source_code_uri"] = "https://github.com/bodacious/jekyll-archive_link"
|
22
|
+
spec.metadata["changelog_uri"] = "https://github.com/bodacious/jekyll-archive_link/blob/main/History.md"
|
23
|
+
|
24
|
+
# Specify which files should be added to the gem when it is released.
|
25
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added
|
26
|
+
# into git.
|
27
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
28
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
29
|
+
f.match(%r{\A(?:spec)/})
|
30
|
+
end
|
31
|
+
end
|
32
|
+
spec.require_paths = ["lib"]
|
33
|
+
|
34
|
+
# Uncomment to register a new dependency of your gem
|
35
|
+
spec.add_dependency "faraday", "~> 2.3"
|
36
|
+
spec.add_dependency "faraday-http-cache", "~> 2.4"
|
37
|
+
spec.add_dependency "jekyll", "~> 4.0"
|
38
|
+
spec.add_dependency "liquid", "~> 4.0"
|
39
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
40
|
+
spec.add_development_dependency "rspec", "~> 3.11"
|
41
|
+
spec.add_development_dependency "rubocop", "~> 1.31"
|
42
|
+
spec.add_development_dependency "rubocop-performance", "~> 1.14"
|
43
|
+
spec.add_development_dependency "rubocop-rake", "~> 0.6"
|
44
|
+
spec.add_development_dependency "rubocop-rspec", "~> 2.12"
|
45
|
+
spec.add_development_dependency "webmock", "~> 3.14"
|
46
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
47
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module ArchiveLink
|
5
|
+
require "liquid"
|
6
|
+
require_relative "url"
|
7
|
+
class Tag < Liquid::Block
|
8
|
+
attr_reader :url
|
9
|
+
|
10
|
+
def render(context)
|
11
|
+
@url = super.to_s.strip
|
12
|
+
Jekyll::ArchiveLink.debug("Render called: #{@url}")
|
13
|
+
|
14
|
+
<<~HTML
|
15
|
+
<a href="#{archive_url}">Archive link</a>
|
16
|
+
HTML
|
17
|
+
end
|
18
|
+
|
19
|
+
def archive_url
|
20
|
+
Jekyll::ArchiveLink.debug("archive_url: #{@url}")
|
21
|
+
|
22
|
+
URL.new(url).latest_archive_url
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
Liquid::Template.register_tag("archive_url_link", Jekyll::ArchiveLink::Tag)
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
require "fileutils"
|
5
|
+
module Jekyll
|
6
|
+
module ArchiveLink
|
7
|
+
class TmpDirCache
|
8
|
+
TMP_DIR = "./tmp/jekyll-archive_link/cache"
|
9
|
+
|
10
|
+
def read(url)
|
11
|
+
key = cache_key(url)
|
12
|
+
path = path_for_file_with_key(key)
|
13
|
+
if File.exist?(path)
|
14
|
+
Jekyll::ArchiveLink.debug "HIT: Cache read #{url}"
|
15
|
+
JSON.parse File.read(path)
|
16
|
+
else
|
17
|
+
Jekyll::ArchiveLink.debug "MISS: Cache read #{url}"
|
18
|
+
nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def write(url, value)
|
23
|
+
Jekyll::ArchiveLink.debug "Cache write: #{url}, value: #{value}"
|
24
|
+
key = cache_key(url)
|
25
|
+
path = path_for_file_with_key(key)
|
26
|
+
FileUtils.mkdir_p(TMP_DIR)
|
27
|
+
File.binwrite(path, value)
|
28
|
+
end
|
29
|
+
|
30
|
+
def delete(url)
|
31
|
+
key = cache_key(url)
|
32
|
+
path = path_for_file_with_key(key)
|
33
|
+
FileUtils.rm(path)
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def cache_key(url)
|
39
|
+
Digest::MD5.hexdigest(url)
|
40
|
+
end
|
41
|
+
|
42
|
+
def path_for_file_with_key(key)
|
43
|
+
Pathname.new("#{TMP_DIR}/#{key}")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module ArchiveLink
|
5
|
+
require "faraday"
|
6
|
+
require "faraday-http-cache"
|
7
|
+
require_relative "tmp_dir_cache"
|
8
|
+
require_relative "invalid_url"
|
9
|
+
|
10
|
+
class URL
|
11
|
+
ARCHIVE_HOST = "https://web.archive.org"
|
12
|
+
API_URI = "wayback/available?url=%<url>s"
|
13
|
+
|
14
|
+
attr_reader :api_client, :url
|
15
|
+
|
16
|
+
class << self
|
17
|
+
API_BASE = "https://archive.org"
|
18
|
+
def api_client
|
19
|
+
@api_client ||= Faraday.new(API_BASE) do |config|
|
20
|
+
config.request(:json)
|
21
|
+
config.response(:json)
|
22
|
+
config.response :logger, Jekyll::ArchiveLink.logger
|
23
|
+
|
24
|
+
config.use :http_cache,
|
25
|
+
store: Jekyll::ArchiveLink::TmpDirCache.new,
|
26
|
+
serializer: JSON
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def initialize(url, api_client: self.class.api_client)
|
32
|
+
Jekyll::ArchiveLink.debug("Initialize URL with #{url}")
|
33
|
+
@api_client = api_client
|
34
|
+
@url = url
|
35
|
+
end
|
36
|
+
|
37
|
+
# rubocop:disable Metrics/MethodLength
|
38
|
+
def latest_archive_url
|
39
|
+
Jekyll::ArchiveLink.debug("latest_archive_url")
|
40
|
+
if url.empty?
|
41
|
+
Jekyll::ArchiveLink.debug("URL is blank")
|
42
|
+
return ""
|
43
|
+
end
|
44
|
+
|
45
|
+
unless URI.parse(url).is_a?(URI::HTTP)
|
46
|
+
raise InvalidURL, "#{url} doesn't look like an archiveable URL"
|
47
|
+
end
|
48
|
+
|
49
|
+
if url.start_with?(ARCHIVE_HOST)
|
50
|
+
Jekyll::ArchiveLink.debug("URL is already an archive link: #{url}")
|
51
|
+
return url
|
52
|
+
end
|
53
|
+
|
54
|
+
memento_location
|
55
|
+
end
|
56
|
+
# rubocop:enable Metrics/MethodLength
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def response
|
61
|
+
@response ||= api_client.get(format(API_URI, url: url))
|
62
|
+
end
|
63
|
+
|
64
|
+
def response_headers
|
65
|
+
response.headers || Hash.new("")
|
66
|
+
end
|
67
|
+
|
68
|
+
def memento_location
|
69
|
+
response_headers["memento-location"]
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "forwardable"
|
4
|
+
require "jekyll"
|
5
|
+
|
6
|
+
require_relative "archive_link/version"
|
7
|
+
require_relative "archive_link/tag"
|
8
|
+
require_relative "archive_link/logger"
|
9
|
+
|
10
|
+
module Jekyll
|
11
|
+
module ArchiveLink
|
12
|
+
class << self
|
13
|
+
LOG_DIR = "./log"
|
14
|
+
LOGGER_PATH = Pathname.new("#{LOG_DIR}/jekyll-archive_link.log")
|
15
|
+
extend Forwardable
|
16
|
+
def_delegators :logger, :debug, :warn, :info
|
17
|
+
|
18
|
+
def logger
|
19
|
+
@logger ||= initialize_logger
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def initialize_logger
|
25
|
+
FileUtils.mkdir_p(LOG_DIR)
|
26
|
+
Jekyll::ArchiveLink::Logger.new(LOGGER_PATH, level: Jekyll.logger.level)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,223 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-archive_link
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bodacious
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-07-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday-http-cache
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.4'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.4'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: jekyll
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: liquid
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '13.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '13.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.11'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.11'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.31'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.31'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop-performance
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.14'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.14'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rubocop-rake
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0.6'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0.6'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rubocop-rspec
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '2.12'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '2.12'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: webmock
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '3.14'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '3.14'
|
167
|
+
description: 'Adds a link to Archive.org''s wayback machine''s latest capture
|
168
|
+
|
169
|
+
'
|
170
|
+
email:
|
171
|
+
- gavin@gavinmorrice.com
|
172
|
+
executables: []
|
173
|
+
extensions: []
|
174
|
+
extra_rdoc_files: []
|
175
|
+
files:
|
176
|
+
- ".github/workflows/main.yml"
|
177
|
+
- ".gitignore"
|
178
|
+
- ".rspec"
|
179
|
+
- ".rubocop.yml"
|
180
|
+
- Gemfile
|
181
|
+
- Gemfile.lock
|
182
|
+
- LICENSE.txt
|
183
|
+
- README.md
|
184
|
+
- Rakefile
|
185
|
+
- bin/console
|
186
|
+
- bin/setup
|
187
|
+
- jekyll-archive_link.gemspec
|
188
|
+
- lib/jekyll-archive_link.rb
|
189
|
+
- lib/jekyll/archive_link.rb
|
190
|
+
- lib/jekyll/archive_link/invalid_url.rb
|
191
|
+
- lib/jekyll/archive_link/logger.rb
|
192
|
+
- lib/jekyll/archive_link/tag.rb
|
193
|
+
- lib/jekyll/archive_link/tmp_dir_cache.rb
|
194
|
+
- lib/jekyll/archive_link/url.rb
|
195
|
+
- lib/jekyll/archive_link/version.rb
|
196
|
+
homepage: https://github.com/bodacious/jekyll-archive_link
|
197
|
+
licenses:
|
198
|
+
- MIT
|
199
|
+
metadata:
|
200
|
+
homepage_uri: https://github.com/bodacious/jekyll-archive_link
|
201
|
+
source_code_uri: https://github.com/bodacious/jekyll-archive_link
|
202
|
+
changelog_uri: https://github.com/bodacious/jekyll-archive_link/blob/main/History.md
|
203
|
+
rubygems_mfa_required: 'true'
|
204
|
+
post_install_message:
|
205
|
+
rdoc_options: []
|
206
|
+
require_paths:
|
207
|
+
- lib
|
208
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
209
|
+
requirements:
|
210
|
+
- - ">="
|
211
|
+
- !ruby/object:Gem::Version
|
212
|
+
version: '3.0'
|
213
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
214
|
+
requirements:
|
215
|
+
- - ">="
|
216
|
+
- !ruby/object:Gem::Version
|
217
|
+
version: '0'
|
218
|
+
requirements: []
|
219
|
+
rubygems_version: 3.3.7
|
220
|
+
signing_key:
|
221
|
+
specification_version: 4
|
222
|
+
summary: Adds a link to Archive.org's wayback machine
|
223
|
+
test_files: []
|