jekyll-onebox 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 624c7dda2f03f56d874a11c1267e31c0d644d326
4
+ data.tar.gz: b3f45233c80ca67dcf35a63955f9c1e8dbe03138
5
+ SHA512:
6
+ metadata.gz: fa3d5dd4c48023efbe7919eecad0f7b69de7d79a265556612825ddde66848019e51ee5e947a595e32dc071cd55e6c4ac66c242772656a8c236ae99392e97ba5a
7
+ data.tar.gz: 905b334da84d8af392db1f6e879d826f87ac97d5ff0d81b5a2eeec02b69583dd72d3fd516c7c19b23d9d1506153bf92cf1d2355206ee038116748b9da5fc034f
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ ## HEAD
2
+
3
+ ## 0.1.0 / 2017-04-02
4
+
5
+ * Birthday!
6
+ * move monkey patched code to a proper Jekyll Tag plug-in
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+ gemspec
5
+
6
+ if ENV["GH_PAGES"]
7
+ gem "github-pages"
8
+ elsif ENV["JEKYLL_VERSION"]
9
+ gem "jekyll", "~> #{ENV["JEKYLL_VERSION"]}"
10
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2017-present Robert Riemann and jekyll-onebox contributors
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # Jekyll::Onebox
2
+
3
+ Liquid tag for displaying GitHub Gists in Jekyll sites: `{% gist %}`.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ $ gem 'jekyll-onebox'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install jekyll-onebox
18
+
19
+ Then add the following to your site's `_config.yml`:
20
+
21
+ ```
22
+ plugins:
23
+ - jekyll-onebox
24
+ ```
25
+
26
+ 💡 If you are using a Jekyll version less than 3.5.0, use the `gems` key instead of `plugins`.
27
+
28
+ ## Usage
29
+
30
+ Use the tag as follows in your Jekyll pages, posts and collections:
31
+
32
+ ```liquid
33
+ {% onebox http://github.com/rriemann/jekyll-onebox %}
34
+ ```
35
+
36
+ This will create a html preview, i.e. an embed, for websites supported by the ruby gem [onebox](https://github.com/discourse/onebox).
37
+
38
+ The html preview depends on the actual link and may be the [oEmbed](http://oembed.com/) or [Open Graph](https://developers.facebook.com/docs/opengraph/) of a (whitelisted) website with support for those previews. Onebox also comes with many engines to construct a custom preview for supported websites, such as IMDB, Amazon, Wikipedia, etc.
39
+
40
+ **Pro-tip**: Onebox uses in most cases HTTP GET requests to fetch content from the provided link. With evolving website content or updates of the Onebox gem, the html preview of the same link may also evolve.
41
+
42
+ ## Custom Whitelisting
43
+
44
+ If Onebox does not support a domain out of the box, but implements either [oEmbed](http://oembed.com/) or [Open Graph](https://developers.facebook.com/docs/opengraph/), than support can be added by simple whitelisting. Please find [in the Onebox code](https://github.com/discourse/onebox/blob/master/lib/onebox/engine/whitelisted_generic_onebox.rb) a list of all whitelisted domains.
45
+
46
+ If a domain is not supported and does not implement oEmbed or Open Graph, than a new engine must be added to the Onebox gem.
47
+
48
+ ```yml
49
+ onebox:
50
+ whitelist:
51
+ - blog.riemann.cc
52
+ - tagesschau.de
53
+ ```
54
+
55
+ ## TODO
56
+
57
+ - add caching of previews to speed-up page builds
58
+
59
+ ## Similar Projects
60
+
61
+ - <https://kalifi.org/2015/08/using-discourse-onebox-with-jekyll.html> uses the Onebox gem for a Jekyll Filter plug-in and inspired this Tag plug-in.
62
+
63
+ ## Contributing
64
+
65
+ 1. Fork it ( https://github.com/rriemann/jekyll-onebox/fork )
66
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
67
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
68
+ 4. Push to the branch (`git push origin my-new-feature`)
69
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path("lib", __dir__)
4
+
5
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
+ require "jekyll-onebox/version"
7
+
8
+ Gem::Specification.new do |spec|
9
+ spec.name = "jekyll-onebox"
10
+ spec.version = Jekyll::Onebox::VERSION
11
+ spec.authors = ["Robert Riemann"]
12
+ spec.email = ["robert@riemann.cc"]
13
+ spec.summary = "Liquid tag for displaying HTML previews (embeds) for links."
14
+ spec.homepage = "https://github.com/rriemann/jekyll-onebox"
15
+ spec.license = "MIT"
16
+
17
+ spec.required_ruby_version = ">= 2.1"
18
+
19
+ spec.files = `git ls-files -z`.split("\x0")
20
+ spec.executables = spec.files.grep(%r!^bin/!) { |f| File.basename(f) }
21
+ # spec.test_files = spec.files.grep(%r!^(test|spec|features)/!)
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_dependency "onebox", "~> 1.8"
25
+ spec.add_development_dependency "bundler", "~> 1.6"
26
+ spec.add_development_dependency "jekyll", ">= 3.0"
27
+ spec.add_development_dependency "rake"
28
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "jekyll-onebox/version"
4
+ require "jekyll-onebox/onebox_tag"
5
+
6
+ module Jekyll
7
+ module Onebox
8
+ end
9
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "onebox"
4
+
5
+ # Inspiration:
6
+ # source: https://kalifi.org/2015/08/using-discourse-onebox-with-jekyll.html
7
+ # Onebox::Engine::WhitelistedGenericOnebox.whitelist << "kalifi.org"
8
+
9
+ # module Jekyll
10
+ # module OneboxFilter
11
+ # def preview(url)
12
+ # Onebox.preview(url).to_s
13
+ # end
14
+ # end
15
+ # end
16
+ #
17
+ # Liquid::Template.register_filter(Jekyll::OneboxFilter)
18
+
19
+ module Jekyll
20
+ module Onebox
21
+ class OneboxTag < Liquid::Tag
22
+ def initialize(tag_name, url, tokens)
23
+ super
24
+ # STDERR.puts url
25
+ @url = url.strip
26
+ end
27
+
28
+ def render(context)
29
+ @settings = context.registers[:site].config["onebox"]
30
+ if @settings && @settings["whitelist"]
31
+ whitelist = @settings["whitelist"]
32
+ if whitelist.kind_of?(Array)
33
+ whitelist.each do |domain|
34
+ Onebox::Engine::WhitelistedGenericOnebox.whitelist << domain
35
+ end
36
+ end
37
+ end
38
+ Onebox.preview(@url).to_s
39
+ end
40
+ end
41
+ end
42
+ end
43
+
44
+ Liquid::Template.register_tag('onebox', Jekyll::Onebox::OneboxTag)
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module Onebox
5
+ VERSION = "0.1.0".freeze
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-onebox
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Robert Riemann
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-04-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: onebox
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: jekyll
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '3.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
+ description:
70
+ email:
71
+ - robert@riemann.cc
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - CHANGELOG.md
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - jekyll-onebox.gemspec
82
+ - lib/jekyll-onebox.rb
83
+ - lib/jekyll-onebox/onebox_tag.rb
84
+ - lib/jekyll-onebox/version.rb
85
+ homepage: https://github.com/rriemann/jekyll-onebox
86
+ licenses:
87
+ - MIT
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '2.1'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 2.6.14
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: Liquid tag for displaying HTML previews (embeds) for links.
109
+ test_files: []