jekyll-hn-comments 0.0.2

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
+ SHA256:
3
+ metadata.gz: 04f56c8ad4888f9398170fae0e7aaaeef37734b189308c7cc393ff9742f9a682
4
+ data.tar.gz: 968857c04b8224fa540567f31fcc369c32ada1ddd6b9e9cade356c9929c60757
5
+ SHA512:
6
+ metadata.gz: db427ff752bff0f72ee11c876d50443e30c226f9e70f1127310a4294d8ed1846fbf622dfdfbb0a74872f17e8362b6921a9e11c4da3c2743685646ea1e06e1f4d
7
+ data.tar.gz: e10af21af6794240f88a70ca05c89e6637b343db6b75cbf926bad541a04861893c12d3bf549397cfa8e9caeaf6ebfc5d83648dd2970c7b40bb96734b29d6202e
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ *.gem
data/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # jekyll-hn-comments
2
+ Jekyll Gem to Fetch Comment Stats from Hacker News
@@ -0,0 +1,17 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "jekyll-hn-comments/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "jekyll-hn-comments"
7
+ spec.summary = "Easily link to Blog Post comments on Hacker News"
8
+ spec.description = "Easily link to Blog Post comments on Hacker News"
9
+ spec.version = JekyllHNComments::VERSION
10
+ spec.authors = ["Jonathan Bayless"]
11
+ spec.email = ["me@jonathanbayless.com"]
12
+ spec.homepage = "https://github.com/baylessj/jekyll-hn-comments"
13
+ spec.licenses = ["MIT"]
14
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|spec|features)/!) }
15
+ spec.require_paths = ["lib"]
16
+ spec.add_dependency "jekyll"
17
+ end
@@ -0,0 +1,5 @@
1
+ require_relative "jekyll-hn-comments/version"
2
+ require_relative "jekyll-hn-comments/generator"
3
+
4
+ module JekyllHNComments
5
+ end
@@ -0,0 +1,23 @@
1
+ require "jekyll"
2
+ require "json"
3
+ require "open-uri"
4
+
5
+ module JekyllHNComments
6
+ class CommentLinkGenerator < Jekyll::Generator
7
+ safe true
8
+ priority :highest
9
+
10
+ def generate(site)
11
+ site.posts.docs.each do |p|
12
+ if not p.data['hn-id']
13
+ next
14
+ end
15
+ target = "https://hacker-news.firebaseio.com/v0/item/#{p.data['hn-id']}.json"
16
+ res = JSON.load(URI.open(target))
17
+
18
+ p.data['link'] = "https://news.ycombinator.com/item?id=#{p.data['hn-id']}"
19
+ p.data['num_comments'] = res['descendants']
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ module JekyllHNComments
2
+ VERSION = "0.0.2".freeze
3
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-hn-comments
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Jonathan Bayless
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-08-26 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: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Easily link to Blog Post comments on Hacker News
28
+ email:
29
+ - me@jonathanbayless.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - README.md
36
+ - jekyll-hn-comments.gemspec
37
+ - lib/jekyll-hn-comments.rb
38
+ - lib/jekyll-hn-comments/generator.rb
39
+ - lib/jekyll-hn-comments/version.rb
40
+ homepage: https://github.com/baylessj/jekyll-hn-comments
41
+ licenses:
42
+ - MIT
43
+ metadata: {}
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubygems_version: 3.1.2
60
+ signing_key:
61
+ specification_version: 4
62
+ summary: Easily link to Blog Post comments on Hacker News
63
+ test_files: []