jekyll-hive 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +41 -0
- data/README.md +79 -0
- data/lib/jekyll-hive.rb +9 -0
- data/lib/jekyll-hive/hive_tag.rb +91 -0
- data/lib/jekyll-hive/version.rb +7 -0
- metadata +189 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1a498c5b88a46e157b96371105a23234fe02fbdc595ffe332615f92c5d8dbfb4
|
4
|
+
data.tar.gz: e34b162f75d5225851831bb24239be567ca3e336d58d29d6549d17481b1ad356
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7ba17593792b5d8f17339e20ba4ef1a6b77297ede9ced3925fa25d3b860dd70c78133df802024065b647e436df83ce9f9b07ad065c95f87c19af31fb531deaf7
|
7
|
+
data.tar.gz: f4529f539627e83f5e0e063cd5ab1892671c51c8756356c0b042cb405a3fc701899238289048fc192a6151458abb749cbe48e66d53153b2fa57d4f56783436ea
|
data/LICENSE
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
CC0 1.0 Universal (CC0 1.0)
|
2
|
+
Public Domain Dedication
|
3
|
+
https://creativecommons.org/publicdomain/zero/1.0/
|
4
|
+
|
5
|
+
This is a human-readable summary of the Legal Code:
|
6
|
+
https://creativecommons.org/publicdomain/zero/1.0/legalcode
|
7
|
+
|
8
|
+
Disclaimer
|
9
|
+
|
10
|
+
The Commons Deed is not a legal instrument. It is simply a handy reference for
|
11
|
+
understanding the CC0 Legal Code, a human-readable expression of some of its key
|
12
|
+
terms. Think of it as the user-friendly interface to the CC0 Legal Code beneath.
|
13
|
+
This Deed itself has no legal value, and its contents do not appear in CC0.
|
14
|
+
Creative Commons is not a law firm and does not provide legal services.
|
15
|
+
Distributing, displaying, or linking to this Commons Deed does not create an
|
16
|
+
attorney-client relationship.
|
17
|
+
|
18
|
+
Creative Commons has not verified the copyright status of any work to which CC0
|
19
|
+
has been applied. CC makes no warranties about any work or its copyright status
|
20
|
+
in any jurisdiction, and disclaims all liability for all uses of any work.
|
21
|
+
|
22
|
+
No Copyright
|
23
|
+
|
24
|
+
The person who associated a work with this deed has dedicated the work to the
|
25
|
+
public domain by waiving all of his or her rights to the work worldwide under
|
26
|
+
copyright law, including all related and neighboring rights, to the extent
|
27
|
+
allowed by law.
|
28
|
+
|
29
|
+
You can copy, modify, distribute and perform the work, even for commercial
|
30
|
+
purposes, all without asking permission. See Other Information below.
|
31
|
+
|
32
|
+
Other Information
|
33
|
+
|
34
|
+
* In no way are the patent or trademark rights of any person affected by CC0,
|
35
|
+
nor are the rights that other persons may have in the work or in how the work
|
36
|
+
is used, such as publicity or privacy rights.
|
37
|
+
* Unless expressly stated otherwise, the person who associated a work with this
|
38
|
+
deed makes no warranties about the work, and disclaims liability for all uses
|
39
|
+
of the work, to the fullest extent permitted by applicable law.
|
40
|
+
* When using or citing the work, you should not imply endorsement by the author
|
41
|
+
or the affirmer.
|
data/README.md
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
# Jekyll::Hive
|
2
|
+
|
3
|
+
Liquid tag for displaying Hive content in Jekyll sites: `{% hive %}`.
|
4
|
+
|
5
|
+
[![Build Status](https://travis-ci.org/inertia186/jekyll-hive.svg?branch=master)](https://travis-ci.org/inertia186/jekyll-hive)
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```bash
|
12
|
+
gem 'jekyll-hive'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
```bash
|
18
|
+
bundle
|
19
|
+
```
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
```bash
|
24
|
+
gem install jekyll-hive
|
25
|
+
```
|
26
|
+
|
27
|
+
Then add the following to your site's `_config.yml`:
|
28
|
+
|
29
|
+
```yml
|
30
|
+
plugins:
|
31
|
+
- jekyll-hive
|
32
|
+
```
|
33
|
+
|
34
|
+
💡 If you are using a Jekyll version less than 3.5.0, use the `gems` key instead of `plugins`.
|
35
|
+
|
36
|
+
## Usage
|
37
|
+
|
38
|
+
Use the tag as follows in your Jekyll pages, posts and collections:
|
39
|
+
|
40
|
+
```liquid
|
41
|
+
{% hive author/permlink %}
|
42
|
+
```
|
43
|
+
This will place the associated content on the page.
|
44
|
+
|
45
|
+
## Jekyll Build
|
46
|
+
|
47
|
+
When building your site with jekyll, you can continue to use the default command:
|
48
|
+
|
49
|
+
```bash
|
50
|
+
jekyll build
|
51
|
+
```
|
52
|
+
|
53
|
+
If you would like to provide an alternate node:
|
54
|
+
|
55
|
+
```bash
|
56
|
+
NODE_URL=https://anyx.io jekyll build
|
57
|
+
```
|
58
|
+
|
59
|
+
## Contributing
|
60
|
+
|
61
|
+
1. Fork it ( https://github.com/inertia186/jekyll-hive/fork )
|
62
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
63
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
64
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
65
|
+
5. Create a new Pull Request
|
66
|
+
|
67
|
+
---
|
68
|
+
|
69
|
+
<center>
|
70
|
+
<img src="https://i.imgur.com/Yy47F6h.png" />
|
71
|
+
</center>
|
72
|
+
|
73
|
+
## Get in touch!
|
74
|
+
|
75
|
+
If you're using Jekyll::Hive, I'd love to hear from you. Drop me a line and tell me what you think! I'm [@inertia](https://hive.blog/@inertia) on Hive.
|
76
|
+
|
77
|
+
## License
|
78
|
+
|
79
|
+
I don't believe in intellectual "property". If you do, consider Jekyll::Hive as licensed under a Creative Commons [![CC0](http://i.creativecommons.org/p/zero/1.0/80x15.png)](http://creativecommons.org/publicdomain/zero/1.0/) License.
|
data/lib/jekyll-hive.rb
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'cgi'
|
4
|
+
require 'steem'
|
5
|
+
|
6
|
+
Net::OpenTimeout = Class.new(RuntimeError) unless Net.const_defined?(:OpenTimeout)
|
7
|
+
Net::ReadTimeout = Class.new(RuntimeError) unless Net.const_defined?(:ReadTimeout)
|
8
|
+
|
9
|
+
module Jekyll
|
10
|
+
module Hive
|
11
|
+
|
12
|
+
# Use the tag as follows in your Jekyll pages, posts and collections:
|
13
|
+
#
|
14
|
+
# {% hive author/permlink %}
|
15
|
+
class HiveTag < Liquid::Tag
|
16
|
+
def render(context)
|
17
|
+
@encoding = context.registers[:site].config['encoding'] || 'utf-8'
|
18
|
+
@settings = context.registers[:site].config['hive']
|
19
|
+
|
20
|
+
if (tag_contents = determine_arguments(@markup.strip))
|
21
|
+
hive_slug = tag_contents[0]
|
22
|
+
|
23
|
+
hive_tag(hive_slug)
|
24
|
+
else
|
25
|
+
raise ArgumentError, <<~ERROR
|
26
|
+
Syntax error in tag 'hive' while parsing the following markup:
|
27
|
+
#{@markup}
|
28
|
+
Valid syntax:
|
29
|
+
{% hive author/permlink %}
|
30
|
+
|
31
|
+
ERROR
|
32
|
+
end
|
33
|
+
end
|
34
|
+
private
|
35
|
+
def determine_arguments(input)
|
36
|
+
return unless input =~ /@?[^\/]+\/[^\/]+/i
|
37
|
+
|
38
|
+
[input]
|
39
|
+
end
|
40
|
+
|
41
|
+
def hive_tag(hive_slug)
|
42
|
+
hive_slug = hive_slug.split('@').last
|
43
|
+
hive_slug = hive_slug.split('/')
|
44
|
+
author = hive_slug[0]
|
45
|
+
permlink = hive_slug[1..-1].join('/')
|
46
|
+
permlink = permlink.split('?').first
|
47
|
+
permlink = permlink.split('#').first
|
48
|
+
api = ::Steem::CondenserApi.new(url: ENV.fetch('NODE_URL', 'https://api.openhive.network'))
|
49
|
+
|
50
|
+
api.get_content(author, permlink) do |content|
|
51
|
+
body = content.body
|
52
|
+
metadata = JSON[content.json_metadata] rescue nil || {}
|
53
|
+
canonical_url = metadata.fetch('canonical_url', "https://hive.blog/@#{author}/#{permlink}")
|
54
|
+
|
55
|
+
# This will normalize image hoster proxy URLs that the author copied
|
56
|
+
# from another post.
|
57
|
+
|
58
|
+
body = body.gsub(/https:\/\/steemitimages.com\/[0-9]+x0\/https:\/\//, 'https://')
|
59
|
+
body = body.gsub(/https:\/\/images.hive.blog\/[0-9]+x0\/https:\/\//, 'https://')
|
60
|
+
|
61
|
+
# Although it works on hive.blog and many other markdown interpretors,
|
62
|
+
# kramdown doesn't like this, so we have to fix it:
|
63
|
+
#
|
64
|
+
# <div>
|
65
|
+
# This *won't* work.
|
66
|
+
# </div>
|
67
|
+
#
|
68
|
+
# See: https://stackoverflow.blog/2008/06/25/three-markdown-gotcha/
|
69
|
+
|
70
|
+
body = body.gsub(/<([^\/].+)>(.+)<\/\1>/m) do
|
71
|
+
match = Regexp.last_match
|
72
|
+
html = Kramdown::Document.new(match[2]).to_html
|
73
|
+
|
74
|
+
"<#{match[1]}>#{html.gsub("\n", "<br />")}</#{match[1]}>"
|
75
|
+
end
|
76
|
+
|
77
|
+
body + <<~DONE
|
78
|
+
\n<hr />
|
79
|
+
<p>
|
80
|
+
See: <a href="#{canonical_url}">#{content.title}</a>
|
81
|
+
by
|
82
|
+
<a href="https://hive.blog/@#{author}">@#{author}</a>
|
83
|
+
</p>
|
84
|
+
DONE
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
Liquid::Template.register_tag('hive', Jekyll::Hive::HiveTag)
|
metadata
ADDED
@@ -0,0 +1,189 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-hive
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Anthony Martin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-04-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: steem-ruby
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.9'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: jekyll
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop-jekyll
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.4'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.4'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: webmock
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: vcr
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: simplecov
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: yard
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
description:
|
154
|
+
email:
|
155
|
+
- jekyll-hive@martin-studio.com
|
156
|
+
executables: []
|
157
|
+
extensions: []
|
158
|
+
extra_rdoc_files: []
|
159
|
+
files:
|
160
|
+
- LICENSE
|
161
|
+
- README.md
|
162
|
+
- lib/jekyll-hive.rb
|
163
|
+
- lib/jekyll-hive/hive_tag.rb
|
164
|
+
- lib/jekyll-hive/version.rb
|
165
|
+
homepage: https://github.com/inertia186/jekyll-hive
|
166
|
+
licenses:
|
167
|
+
- CC0-1.0
|
168
|
+
metadata: {}
|
169
|
+
post_install_message:
|
170
|
+
rdoc_options: []
|
171
|
+
require_paths:
|
172
|
+
- lib
|
173
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
174
|
+
requirements:
|
175
|
+
- - ">="
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
version: 2.3.0
|
178
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
|
+
requirements:
|
180
|
+
- - ">="
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: '0'
|
183
|
+
requirements: []
|
184
|
+
rubyforge_project:
|
185
|
+
rubygems_version: 2.7.10
|
186
|
+
signing_key:
|
187
|
+
specification_version: 4
|
188
|
+
summary: Liquid tag for displaying Hive content in Jekyll sites.
|
189
|
+
test_files: []
|