jekyll-openmoji 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -27,10 +27,10 @@ Gem::Specification.new do |spec|
27
27
 
28
28
  spec.required_ruby_version = ">= 2.3.0"
29
29
 
30
- spec.add_dependency "html-pipeline", "~> 2.2"
31
- spec.add_dependency "html-pipeline-negarmoji", "~> 0.1.0"
30
+ spec.add_dependency "html-pipeline", "~> 2.12"
31
+ spec.add_dependency "html-pipeline-negarmoji", "~> 0.1.1"
32
32
  spec.add_dependency "jekyll", ">= 3.0", "< 5.0"
33
- spec.add_dependency "negarmoji", "~> 0.1.3"
33
+ spec.add_dependency "negarmoji", "~> 0.1.4"
34
34
 
35
35
  spec.add_development_dependency "bundler", "~> 2.0"
36
36
  spec.add_development_dependency "rake", "~> 13.0"
@@ -8,11 +8,18 @@ require "html/pipeline/negarmoji-pipeline"
8
8
  module Jekyll
9
9
  class Emoji
10
10
  # Extend negarmoji emoji class.
11
- OPENMOJI_ASSET_HOST_URL = "https://cdn.jsdelivr.net/gh/azadeh-afzar/OpenMoji-Jekyll-Plugin@latest"
12
- ASSET_PATH = "/images/color/svg"
11
+
12
+ # Default configuration.
13
+ DEFAULT_HOST_URL = "https://cdn.jsdelivr.net/gh/azadeh-afzar/OpenMoji-Jekyll-Plugin@latest"
14
+ DEFAULT_ASSET_PATH = "/images/color/svg"
13
15
  DEFAULT_DIR = "/emoji"
14
- FILE_NAME = "/:file_name"
15
16
  DEFAULT_EXTENSION = "svg"
17
+ DEFAULT_IMG_ATTRS = { "class" => "emoji",
18
+ "height" => "20",
19
+ "width" => "20",
20
+ "align" => nil, }
21
+ # Regex values.
22
+ FILE_NAME = "/:file_name"
16
23
  BODY_START_TAG = "<body"
17
24
  OPENING_BODY_TAG_REGEX = %r!<body(.*?)>\s*!m.freeze
18
25
 
@@ -28,18 +35,21 @@ module Jekyll
28
35
  src_root = emoji_src_root(doc.site.config)
29
36
  asset_path = emoji_asset_path(doc.site.config)
30
37
  file_extension = emoji_extension(doc.site.config)
31
- filter_with_emoji(src_root, asset_path, file_extension)
32
- .call(doc.output)[:output].to_s
38
+ img_attrs = emoji_attributes(doc.site.config)
39
+ filter_with_emoji(src_root, asset_path, file_extension,
40
+ img_attrs).call(doc.output)[:output].to_s
33
41
  end
34
42
  end
35
43
 
36
44
  # Public: Create or fetch the filter for the given {{src_root}} asset root.
37
45
  #
38
- # src_root - the asset root URL (e.g. https://cdn.jsdelivr.net/gh/azadeh-afzar/OpenMoji-Jekyll-Plugin@latest)
39
- # asset_path - the asset sub-path of src (e.g. "/images/color/svg")
40
- # [default = "emoji"]
46
+ # :src_root - the asset root URL (e.g. https://cdn.jsdelivr.net/gh/azadeh-afzar/OpenMoji-Jekyll-Plugin@latest)
47
+ # :asset_path - the asset sub-path of src (e.g. "/images/color/svg")
48
+ # [default = "emoji"].
41
49
  #
42
- # extension - the extension of emoji image files, [default = svg ]
50
+ # :extension - the extension of emoji image files, [default = svg ].
51
+ #
52
+ # :img_attrs - the custom css properties for emoji <img> tag.
43
53
  #
44
54
  # examples of _config.yml:
45
55
  # 1. user provided all URLs:
@@ -57,13 +67,13 @@ module Jekyll
57
67
  # emoji files will serve from https://cdn.jsdelivr.net/gh/azadeh-afzar/OpenMoji-Jekyll-Plugin@latest/images/color/svg
58
68
  #
59
69
  # Returns an HTML::Pipeline instance for the given asset root.
60
- def filter_with_emoji(src_root, asset_path, file_extension)
70
+ def filter_with_emoji(src_root, asset_path, file_extension, img_attrs)
61
71
  filters[src_root] ||= HTML::Pipeline.new([HTML::Pipeline::
62
72
  NegarMojiHtmlPipeline::NegarehEmojiFilter],
63
73
  :asset_root => src_root,
64
74
  :asset_path => asset_path,
65
75
  :extension => file_extension,
66
- :img_attrs => { :align => nil })
76
+ :img_attrs => img_attrs)
67
77
  end
68
78
 
69
79
  # Public: Filters hash where the key is the asset root source.
@@ -75,9 +85,9 @@ module Jekyll
75
85
  # Public: Calculate the asset root source for the given config.
76
86
  # The custom emoji asset root can be defined in the config as
77
87
  # emoji.src, and must be a valid URL (i.e. it must include a
78
- # protocol and valid domain)
88
+ # protocol and valid domain).
79
89
  #
80
- # config - the hash-like configuration of the document's site
90
+ # config - the hash-like configuration of the document's site.
81
91
  #
82
92
  # Returns a full URL to use as the asset root URL. Defaults to the root
83
93
  # URL for assets provided by an ASSET_HOST_URL environment variable,
@@ -94,9 +104,9 @@ module Jekyll
94
104
  # The custom emoji asset root can be defined in the config as
95
105
  # emoji.asset.
96
106
  #
97
- # If emoji.asset isn't defined, its value will explicitly set to "emoji"
107
+ # If emoji.asset isn't defined, its value will explicitly set to "emoji".
98
108
  #
99
- # config - the hash-like configuration of the document's site
109
+ # config - the hash-like configuration of the document's site.
100
110
  #
101
111
  # Returns a string to use as the asset path. Defaults to the ASSET_PATH.
102
112
  def emoji_asset_path(config = {})
@@ -107,7 +117,7 @@ module Jekyll
107
117
  "#{DEFAULT_DIR}#{FILE_NAME}"
108
118
  end
109
119
  else
110
- "#{ASSET_PATH}#{FILE_NAME}"
120
+ "#{DEFAULT_ASSET_PATH}#{FILE_NAME}"
111
121
  end
112
122
  end
113
123
 
@@ -115,9 +125,9 @@ module Jekyll
115
125
  # The custom emoji extension can be defined in the config as
116
126
  # emoji.extension.
117
127
  #
118
- # If emoji.extension isn't defined, its value will explicitly set to "svg"
128
+ # If emoji.extension isn't defined, its value will explicitly set to "svg".
119
129
  #
120
- # config - the hash-like configuration of the document's site
130
+ # config - the hash-like configuration of the document's site.
121
131
  #
122
132
  # Returns a string to use as the extension. Defaults to the DEFAULT_EXTENSION.
123
133
  def emoji_extension(config = {})
@@ -128,6 +138,36 @@ module Jekyll
128
138
  end
129
139
  end
130
140
 
141
+ # Public: return emoji <img> tag attributes.
142
+ # The custom emoji css attributes can be defined with emoji.img_attrs.
143
+ #
144
+ # for example:
145
+ #
146
+ # emoji:
147
+ # img_attrs:
148
+ # class: "openmoji"
149
+ # height: 30
150
+ #
151
+ # this will override default emoji css attributes.
152
+ #
153
+ # If emoji.img_attrs isn't defined, its value will explicitly set to
154
+ # DEFAULT_IMG_ATTRS.
155
+ #
156
+ # config - the hash-like configuration of the document's site
157
+ #
158
+ # Returns a hash to use as the attributes. Defaults to the DEFAULT_IMG_ATTRS.
159
+ def emoji_attributes(config = {})
160
+ if config.key?("emoji") && config["emoji"].key?("img_attrs")
161
+ # merge default values with custom values and then
162
+ # convert hash keys to symbols.
163
+ DEFAULT_IMG_ATTRS.merge!(config["emoji"]["img_attrs"])
164
+ .map { |key, value| [key.to_sym, value] }.to_h
165
+ else
166
+ # convert hash keys to symbols.
167
+ DEFAULT_IMG_ATTRS.map { |key, value| [key.to_sym, value] }.to_h
168
+ end
169
+ end
170
+
131
171
  # Public: Defines the conditions for a document to be emojiable.
132
172
  #
133
173
  # doc - the Jekyll::Document or Jekyll::Page
@@ -146,7 +186,7 @@ module Jekyll
146
186
  asset_host_url = ENV["ASSET_HOST_URL"].chomp("/")
147
187
  asset_host_url.to_s
148
188
  else
149
- OPENMOJI_ASSET_HOST_URL.to_s
189
+ DEFAULT_HOST_URL.to_s
150
190
  end
151
191
  end
152
192
 
@@ -154,10 +194,12 @@ module Jekyll
154
194
  src_root = emoji_src_root(doc.site.config)
155
195
  asset_path = emoji_asset_path(doc.site.config)
156
196
  file_extension = emoji_extension(doc.site.config)
197
+ img_attrs = emoji_attributes(doc.site.config)
157
198
  head, opener, tail = doc.output.partition(OPENING_BODY_TAG_REGEX)
158
199
  body_content, *rest = tail.partition("</body>")
159
- processed_markup = filter_with_emoji(src_root, asset_path, file_extension)
160
- .call(body_content)[:output].to_s
200
+ processed_markup = filter_with_emoji(src_root, asset_path, file_extension,
201
+ img_attrs).call(body_content)[:output]
202
+ .to_s
161
203
  String.new(head) << opener << processed_markup << rest.join
162
204
  end
163
205
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  class Emoji
5
- VERSION = "0.1.0"
5
+ VERSION = "0.1.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-openmoji
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mohammad Mahdi Baghbani Pourvahid
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-17 00:00:00.000000000 Z
11
+ date: 2019-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: html-pipeline
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.2'
19
+ version: '2.12'
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: '2.2'
26
+ version: '2.12'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: html-pipeline-negarmoji
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.1.0
33
+ version: 0.1.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.1.0
40
+ version: 0.1.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: jekyll
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -64,14 +64,14 @@ dependencies:
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: 0.1.3
67
+ version: 0.1.4
68
68
  type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: 0.1.3
74
+ version: 0.1.4
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: bundler
77
77
  requirement: !ruby/object:Gem::Requirement
@@ -170,6 +170,32 @@ files:
170
170
  - ROADMAP.md
171
171
  - Rakefile
172
172
  - SUPPORT.md
173
+ - doc/blog/.bundle/config
174
+ - doc/blog/404.html
175
+ - doc/blog/Gemfile
176
+ - doc/blog/_config.yml
177
+ - doc/blog/_includes/disqus_comments.html
178
+ - doc/blog/_includes/footer.html
179
+ - doc/blog/_includes/google-analytics.html
180
+ - doc/blog/_includes/head.html
181
+ - doc/blog/_includes/header.html
182
+ - doc/blog/_includes/social.html
183
+ - doc/blog/_layouts/default.html
184
+ - doc/blog/_layouts/home.html
185
+ - doc/blog/_layouts/page.html
186
+ - doc/blog/_layouts/post.html
187
+ - doc/blog/_sass/minima-classic.scss
188
+ - doc/blog/_sass/minima-solarized-dark.scss
189
+ - doc/blog/_sass/minima-solarized.scss
190
+ - doc/blog/_sass/minima/_base.scss
191
+ - doc/blog/_sass/minima/_layout.scss
192
+ - doc/blog/_sass/minima/custom-styles.scss
193
+ - doc/blog/_sass/minima/custom-variables.scss
194
+ - doc/blog/_sass/minima/initialize.scss
195
+ - doc/blog/assets/css/style.scss
196
+ - doc/blog/assets/minima-social-icons.svg
197
+ - doc/blog/favicon.ico
198
+ - doc/blog/index.md
173
199
  - jekyll-openmoji.gemspec
174
200
  - lib/jekyll-openmoji.rb
175
201
  - lib/jekyll-openmoji/plugin.rb