jekyll-twemoji 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/lib/jekyll/twemoji.rb +73 -0
- metadata +73 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 10ed12f29388c0043be6272fc94000d00b92546c
|
4
|
+
data.tar.gz: e120ef2481e5059974b78d0986d718888c2a0693
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3f4ad0019fc0542bdb4549170fe532a1dbad16b0c9c4f3d49dadbfa2501778a0c05ed056b03da35417105067f9f8c9e8ff651fa9f1783a777ddd9083eb131ecf
|
7
|
+
data.tar.gz: a31b3b43e6e35d380aa34eb3c82fed3bdee5343ce128a73f07f9cba4a9aa343f2997e46122565f6512c152332d85f78885a9a872e39511fb97ba6903b594c814
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require "jekyll"
|
2
|
+
require "twemoji"
|
3
|
+
|
4
|
+
module Jekyll
|
5
|
+
class Twemoji < Jekyll::Generator
|
6
|
+
attr_reader :config
|
7
|
+
safe true
|
8
|
+
|
9
|
+
JEKYLL_CONFIG_NAMESPACE = "jekyll-twemoji".freeze
|
10
|
+
VALID_IMAGE_TYPES = %w(png svg).freeze
|
11
|
+
VALID_IMAGE_SIZES = %w(16x16 32x32 72x72).freeze
|
12
|
+
|
13
|
+
def initialize(config = {})
|
14
|
+
@config = config
|
15
|
+
end
|
16
|
+
|
17
|
+
def image_type
|
18
|
+
@image_type ||=
|
19
|
+
if config_inquiry? "image_type"
|
20
|
+
validates_image_type(config["jekyll-twemoji"]["image_type"])
|
21
|
+
else
|
22
|
+
".svg"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def image_size
|
27
|
+
@image_size ||=
|
28
|
+
if config_inquiry? "image_size"
|
29
|
+
validates_image_sizes(config["jekyll-twemoji"]["image_size"])
|
30
|
+
else
|
31
|
+
"16x16"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def generate(site)
|
36
|
+
site.pages.each { |page| emojify page }
|
37
|
+
site.posts.each { |post| emojify post }
|
38
|
+
site.docs_to_write.each { |doc| emojify doc }
|
39
|
+
end
|
40
|
+
|
41
|
+
def emojify(page)
|
42
|
+
page.content =
|
43
|
+
::Twemoji.parse(page.content, file_ext: image_type, image_size: image_size)
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def config_inquiry?(key)
|
49
|
+
config.key?(JEKYLL_CONFIG_NAMESPACE) &&
|
50
|
+
config[JEKYLL_CONFIG_NAMESPACE].key?(key)
|
51
|
+
end
|
52
|
+
|
53
|
+
def validates_image_type(image_type)
|
54
|
+
if image_type.start_with? "."
|
55
|
+
fail "No need to put dot in front of image type: #{image_type}"
|
56
|
+
end
|
57
|
+
|
58
|
+
if VALID_IMAGE_TYPES.include? image_type
|
59
|
+
".#{image_type}" # Twemoji#parse file_ext option needs a leading dot.
|
60
|
+
else
|
61
|
+
fail "Image type not supported: #{image_type}. Supported image types are: #{VALID_IMAGE_TYPES.join(", ")}."
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def validates_image_sizes(image_size)
|
66
|
+
if VALID_IMAGE_SIZES.include? image_size
|
67
|
+
image_size
|
68
|
+
else
|
69
|
+
fail "Image size not supported: #{image_size}. Supported image sizes are: #{VALID_IMAGE_SIZES.join(", ")}."
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-twemoji
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Juanito Fatas
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-19 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: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: twemoji
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.1.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.1.0
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- katehuang0320@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- lib/jekyll/twemoji.rb
|
49
|
+
homepage: https://github.com/JuanitoFatas/jekyll-twemoji
|
50
|
+
licenses:
|
51
|
+
- MIT
|
52
|
+
metadata: {}
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options: []
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
requirements: []
|
68
|
+
rubyforge_project:
|
69
|
+
rubygems_version: 2.4.5
|
70
|
+
signing_key:
|
71
|
+
specification_version: 4
|
72
|
+
summary: Twemoji plugin for Jekyll in Pure Ruby.
|
73
|
+
test_files: []
|