jemoji 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jemoji.rb +49 -26
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 863bbb0e3fc417fe221613909e76d946ab5a5fce
|
4
|
+
data.tar.gz: 434939b213fc37b2d6772c3938c27e9d281b16ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: feb452169907fb003decc0890429047806f24216483b2eb2b572d6ded58d907cd4656d9f8f289ed7a020899ed5e032da576230f3454ebccd867aebac6941068a
|
7
|
+
data.tar.gz: 7e63fa351ece10c4b5f4d85ff8dde2be1157775a09f5057ae8019b2ec850529ccad6873f58ea1c9c2d073abae11090fa2148c2db2e158f3fae2bd5ba5cedd3c6
|
data/lib/jemoji.rb
CHANGED
@@ -3,39 +3,62 @@ require 'gemoji'
|
|
3
3
|
require 'html/pipeline'
|
4
4
|
|
5
5
|
module Jekyll
|
6
|
-
class Emoji
|
7
|
-
|
8
|
-
safe true
|
6
|
+
class Emoji
|
7
|
+
GITHUB_DOT_COM_ASSET_ROOT = "https://assets.github.com/images/icons/".freeze
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
class << self
|
10
|
+
def emojify(doc)
|
11
|
+
src = emoji_src(doc.site.config)
|
12
|
+
doc.output = filter_with_emoji(src).call(doc.output)[:output].to_s
|
13
|
+
end
|
14
|
+
|
15
|
+
# Public: Create or fetch the filter for the given {{src}} asset root.
|
16
|
+
#
|
17
|
+
# src - the asset root URL (e.g. https://assets.github.com/images/icons/)
|
18
|
+
#
|
19
|
+
# Returns an HTML::Pipeline instance for the given asset root.
|
20
|
+
def filter_with_emoji(src)
|
21
|
+
filters[src] ||= HTML::Pipeline.new([
|
22
|
+
HTML::Pipeline::EmojiFilter
|
23
|
+
], { :asset_root => src })
|
24
|
+
end
|
25
|
+
|
26
|
+
# Public: Filters hash where the key is the asset root source.
|
27
|
+
# Effectively a cache.
|
28
|
+
def filters
|
29
|
+
@filters ||= {}
|
30
|
+
end
|
13
31
|
|
14
|
-
|
15
|
-
|
32
|
+
# Public: Calculate the asset root source for the given config.
|
33
|
+
# The custom emoji asset root can be defined in the config as
|
34
|
+
# emoji.src, and must be a valid URL (i.e. it must include a
|
35
|
+
# protocol and valid domain)
|
36
|
+
#
|
37
|
+
# config - the hash-like configuration of the document's site
|
38
|
+
#
|
39
|
+
# Returns a full URL to use as the asset root URL. Defaults to
|
40
|
+
# the assets.github.com emoji root.
|
41
|
+
def emoji_src(config = {})
|
16
42
|
if config.key?("emoji") && config["emoji"].key?("src")
|
17
43
|
config["emoji"]["src"]
|
18
44
|
else
|
19
|
-
|
45
|
+
GITHUB_DOT_COM_ASSET_ROOT
|
20
46
|
end
|
21
|
-
|
22
|
-
|
23
|
-
def filter
|
24
|
-
@filter ||= HTML::Pipeline::EmojiFilter.new(nil, { :asset_root => src })
|
25
|
-
end
|
47
|
+
end
|
26
48
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
def v3?
|
38
|
-
::Jekyll::VERSION.to_f >= 3.0
|
49
|
+
# Public: Defines the conditions for a document to be emojiable.
|
50
|
+
#
|
51
|
+
# doc - the Jekyll::Document or Jekyll::Page
|
52
|
+
#
|
53
|
+
# Returns true if the doc is written & is HTML.
|
54
|
+
def emojiable?(doc)
|
55
|
+
(doc.class == Jekyll::Page || doc.write?) &&
|
56
|
+
doc.output_ext == ".html" || (doc.permalink && doc.permalink.end_with?("/"))
|
57
|
+
end
|
39
58
|
end
|
40
59
|
end
|
41
60
|
end
|
61
|
+
|
62
|
+
Jekyll::Hooks.register [:pages, :documents], :post_render do |doc|
|
63
|
+
Jekyll::Emoji.emojify(doc) if Jekyll::Emoji.emojiable?(doc)
|
64
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jemoji
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '3.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '3.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: html-pipeline
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -121,9 +121,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
121
|
version: '0'
|
122
122
|
requirements: []
|
123
123
|
rubyforge_project:
|
124
|
-
rubygems_version: 2.
|
124
|
+
rubygems_version: 2.5.1
|
125
125
|
signing_key:
|
126
126
|
specification_version: 4
|
127
127
|
summary: GitHub-flavored emoji plugin for Jekyll
|
128
128
|
test_files: []
|
129
|
-
has_rdoc:
|