jekyll-github-last-modified 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d49d6c209129b3ceaec03e1ecdfb987297464332
4
+ data.tar.gz: 237918f84fcd000b8d01e35fa273f5237b6405a0
5
+ SHA512:
6
+ metadata.gz: 352d545ef73b14879850ab57c069ed9180fe90acb8c64c082f77258db8c9d581e0d7551e296f0ed845a06304c4d27fb45ebebf26a7889c51891cc09848bd1819
7
+ data.tar.gz: bfa50ff483e54f08d9ca1bb404c8dcf1d185cc0cbf20bb599a59c1274ac80092c6cb511665aa74c8cea2ca3a14a34525b9b6eeaf559a914987cc304dc08c13bd
@@ -0,0 +1,9 @@
1
+ module Jekyll
2
+ module GitHubLastModified
3
+ autoload :VERSION, 'jekyll-github-last-modified/version'
4
+ autoload :Tag, 'jekyll-github-last-modified/tag'
5
+
6
+ Tag ;
7
+
8
+ end
9
+ end
@@ -0,0 +1,33 @@
1
+ require 'json'
2
+ require 'rest-client'
3
+ require 'date'
4
+
5
+ module Jekyll
6
+ module GitHubLastModified
7
+ class Tag < Liquid::Tag
8
+
9
+ def initialize(tag_name, path, tokens)
10
+ super
11
+ @path = path
12
+ end
13
+
14
+ def render(context)
15
+ github_path = Liquid::Template.parse(@path).render context
16
+ github_token = context.registers[:site].config['github_token']
17
+ github_repo = context.registers[:site].config['repository']
18
+ headers = if github_token.nil? || github_token.empty? then {} else {Authorization: "token #{github_token.to_s}"} end
19
+ uri = "https://api.github.com/repos/#{github_repo.to_s}/commits?path="+github_path.strip!
20
+ response = RestClient.get(uri, headers)
21
+ gitHubDetails = response.body
22
+ return if gitHubDetails.nil? || gitHubDetails.empty?
23
+ hash = JSON.parse(gitHubDetails)
24
+ return if hash.nil? || hash.empty?
25
+ github_date = hash[0]["commit"]["committer"]["date"]
26
+ return if github_date.nil? || github_date.empty?
27
+ DateTime.strptime(github_date,'%FT%TZ').to_s
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ Liquid::Template.register_tag('last_modified', Jekyll::GitHubLastModified::Tag)
@@ -0,0 +1,5 @@
1
+ module Jekyll
2
+ module GitHubLastModified
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-github-last-modified
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Aksel Davis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-01-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jekyll
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rest-client
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.8'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.8'
41
+ description:
42
+ email:
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - lib/jekyll-github-last-modified.rb
48
+ - lib/jekyll-github-last-modified/tag.rb
49
+ - lib/jekyll-github-last-modified/version.rb
50
+ homepage:
51
+ licenses:
52
+ - MIT
53
+ metadata: {}
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubyforge_project:
70
+ rubygems_version: 2.6.14.1
71
+ signing_key:
72
+ specification_version: 4
73
+ summary: A Jekyll plugin for retrieving files' last modified timestamp from GitHub.
74
+ test_files: []