14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/jekyll-github-last-modified/tag.rb', line 14
def render(context)
github_path = Liquid::Template.parse(@path).render context
github_token = context.registers[:site].config['github_token']
github_repo = context.registers[:site].config['repository']
= if github_token.nil? || github_token.empty? then {} else {Authorization: "token #{github_token.to_s}"} end
uri = "https://api.github.com/repos/#{github_repo.to_s}/commits?path="+github_path.strip!
response = RestClient.get(uri, )
gitHubDetails = response.body
return if gitHubDetails.nil? || gitHubDetails.empty?
hash = JSON.parse(gitHubDetails)
return if hash.nil? || hash.empty?
github_date = hash[0]["commit"]["committer"]["date"]
return if github_date.nil? || github_date.empty?
DateTime.strptime(github_date,'%FT%TZ').to_s
end
|