jekyll_emoji_tag 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5fcbd2d4d07f48b73b88309e826023eca537c472e7d2b9924a02d72e41fb9aa3
4
+ data.tar.gz: fb1b823f3f23fdbefe64ada67e22bfb0d75cfe23be4b40835e67f3c5e9a368f3
5
+ SHA512:
6
+ metadata.gz: 2054b06c3c37341f6609788c7611cb1c45fd87f57c625a722190660134a14529e949ebef091a3f5680e66913758b66a84c897da7130790b520953d2a157b984b
7
+ data.tar.gz: 0c29401d2878048954c58117c63ac041d3b356e50c40b46aaa7e4a248673ef5681f4add7b36cf128d6250f39bfe00285d48c5af0e0a3dfea18e546d8f6af51a7
data/.rubocop.yml ADDED
@@ -0,0 +1,71 @@
1
+ require:
2
+ # - rubocop-jekyll
3
+ - rubocop-md
4
+ - rubocop-performance
5
+ - rubocop-rake
6
+ - rubocop-rspec
7
+
8
+ AllCops:
9
+ Exclude:
10
+ - binstub/**/*
11
+ - exe/**/*
12
+ - vendor/**/*
13
+ - Gemfile*
14
+ NewCops: enable
15
+ TargetRubyVersion: 3.1.3
16
+
17
+ Gemspec/DeprecatedAttributeAssignment:
18
+ Enabled: false
19
+
20
+ Gemspec/RequireMFA:
21
+ Enabled: false
22
+
23
+ Layout/HashAlignment:
24
+ EnforcedColonStyle: table
25
+ EnforcedHashRocketStyle: table
26
+
27
+ Layout/LineLength:
28
+ Max: 150
29
+
30
+ Metrics/AbcSize:
31
+ Max: 35
32
+
33
+ Metrics/BlockLength:
34
+ Exclude:
35
+ - jekyll_emoji_tag.gemspec
36
+ Max: 30
37
+
38
+ Metrics/CyclomaticComplexity:
39
+ Max: 15
40
+
41
+ Metrics/MethodLength:
42
+ Max: 40
43
+
44
+ Metrics/ModuleLength:
45
+ Enabled: false
46
+
47
+ Metrics/PerceivedComplexity:
48
+ Max: 15
49
+
50
+ Naming/FileName:
51
+ Exclude:
52
+ - Rakefile
53
+
54
+ Style/Documentation:
55
+ Enabled: false
56
+
57
+ Style/FrozenStringLiteralComment:
58
+ Enabled: false
59
+
60
+ Style/TrailingCommaInHashLiteral:
61
+ EnforcedStyleForMultiline: comma
62
+
63
+ RSpec/FilePath:
64
+ IgnoreMethods: true
65
+ SpecSuffixOnly: true
66
+
67
+ RSpec/ExampleLength:
68
+ Max: 30
69
+
70
+ RSpec/MultipleExpectations:
71
+ Max: 15
data/CHANGELOG.md ADDED
@@ -0,0 +1,2 @@
1
+ ## 0.1.0
2
+ * Initial release.
data/README.md ADDED
@@ -0,0 +1,96 @@
1
+ `jekyll_emoji_tag`
2
+ [![Gem Version](https://badge.fury.io/rb/jekyll_emoji_tag.svg)](https://badge.fury.io/rb/jekyll_emoji_tag)
3
+ ===========
4
+
5
+ Inserts the specified emoji into the document.
6
+ You can specify the size and alignment of the emoji.
7
+ If you specify an emoji name that does not exist, the `undefined` emoji is shown.
8
+
9
+
10
+ ## Installation
11
+
12
+ Add this line to your Jekyll website's `Gemfile`, within the `jekyll_plugins` group:
13
+
14
+ ```ruby
15
+ group :jekyll_plugins do
16
+ gem 'jekyll_emoji_tag'
17
+ end
18
+ ```
19
+
20
+ And then execute:
21
+ ```bash
22
+ $ bundle
23
+ ```
24
+
25
+
26
+ ## Syntax
27
+
28
+ ```text
29
+ {% emoji OPTIONS %}
30
+ ```
31
+ `OPTIONS` are:
32
+
33
+ - `align` - `left`, `right` or `inline` (default is inline)
34
+ - `emoji_and_name` - causes the name of the emoji to be output along with the image (default is false)
35
+ - `list` - output all emojis (default is false)
36
+ - `name` - name of emoji (defaults to smiley)
37
+ - `size` - height of emoji (defaults to 3em)
38
+
39
+ `list` and `name` are mutually exclusive; only specify one of them.
40
+
41
+ If neither `list` nor `name` is specified, the `smiley` emoji is output.
42
+
43
+ The names of all supported emojis are:
44
+
45
+ ```
46
+ angry
47
+ boom
48
+ grin
49
+ horns
50
+ kiss
51
+ open
52
+ poop
53
+ sad
54
+ scream
55
+ smiley
56
+ smirk
57
+ two_hearts
58
+ ```
59
+
60
+ ## Example Usage
61
+
62
+ ```text
63
+ {% emoji name='boom' %}
64
+ {% emoji align='right' name='grin' %}
65
+ {% emoji name='sad' size='12pt' %}
66
+ {% emoji align='right' name='horns' size='12pt' %}
67
+ {% emoji emoji_and_name name='poop' %}
68
+ {% emoji align='right' emoji_and_name name='scream' %}
69
+ {% emoji list %}
70
+ {% emoji list size='1em' %}
71
+ ```
72
+
73
+ See the [demo](demo/index.html) for more examples.
74
+
75
+
76
+ ## Development
77
+
78
+ After checking out the repo, run `bin/setup` to install dependencies.
79
+ Then, run `bundle exec rake test` to run the tests.
80
+ You can also run `bin/console` for an interactive prompt that will allow you to experiment.
81
+
82
+ To install this gem onto your local machine, run `bundle exec rake install`.
83
+
84
+ To release a new version, run `bundle exec rake release`,
85
+ which will create a git tag for the version, push git commits and tags,
86
+ and push the `.gem` file to https://rubygems.org.
87
+
88
+
89
+ ## Contributing
90
+
91
+ Bug reports and pull requests are welcome on #<struct Creategem::Repository::Host domain="github.com", camel_case="GitHub", id=:github> at https://github.com/mslinn/jekyll_emoji_tag.
92
+
93
+
94
+ ## License
95
+
96
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,40 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << 'test'
6
+ t.libs << 'lib'
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ desc 'Bump patch version'
11
+ task :patch do
12
+ system 'gem bump --tag'
13
+ end
14
+
15
+ desc 'Bump minor version'
16
+ task :minor do
17
+ system 'gem bump --version minor --tag'
18
+ end
19
+
20
+ desc 'Bump major version'
21
+ task :major do
22
+ system 'gem bump --version major --tag'
23
+ end
24
+
25
+ task publish: [:build] do
26
+ $VERBOSE = nil
27
+ load 'jekyll_emoji_tag/version.rb'
28
+ system "gem push pkg/jekyll_emoji_tag-#{JekyllEmojiTag::VERSION}.gem"
29
+ end
30
+
31
+ desc 'Bump patch version, create git tag, build the gem and release to geminabox (default)'
32
+ task release_patch: %i[test patch publish]
33
+
34
+ desc 'Bump minor version, create git tag, build the gem and release to geminabox'
35
+ task release_minor: %i[test minor publish]
36
+
37
+ desc 'Bump major version, create git tag, build the gem and release to geminabox'
38
+ task release_major: %i[test major publish]
39
+
40
+ task default: :test
@@ -0,0 +1,34 @@
1
+ require_relative 'lib/jekyll_emoji_tag/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ host = 'https://github.com/mslinn/jekyll_emoji_tag'
5
+
6
+ spec.authors = ['Mike Slinn']
7
+ spec.description = <<~END_DESC
8
+ Inserts an emoji
9
+ END_DESC
10
+ spec.email = ['mslinn@mslinn.com']
11
+ spec.files = Dir['.rubocop.yml', 'LICENSE.*', 'Rakefile', '{lib,spec}/**/*', '*.gemspec', '*.md']
12
+ spec.homepage = 'https://github.com/mslinn/jekyll_emoji_tag'
13
+ spec.license = 'MIT'
14
+ spec.metadata = {
15
+ 'allowed_push_host' => 'https://rubygems.org',
16
+ 'bug_tracker_uri' => "#{host}/issues",
17
+ 'changelog_uri' => "#{host}/CHANGELOG.md",
18
+ 'homepage_uri' => spec.homepage,
19
+ 'source_code_uri' => host,
20
+ }
21
+ spec.name = 'jekyll_emoji_tag'
22
+ spec.post_install_message = <<~END_MESSAGE
23
+
24
+ Thanks for installing #{spec.name}!
25
+
26
+ END_MESSAGE
27
+ spec.require_paths = ['lib']
28
+ spec.required_ruby_version = '>= 3.1.0'
29
+ spec.summary = 'Inserts an emoji'
30
+ spec.version = JekyllEmojiTag::VERSION
31
+
32
+ spec.add_dependency 'jekyll', '>= 3.5.0'
33
+ spec.add_dependency 'jekyll_plugin_support', '>= 0.7.0'
34
+ end
data/lib/emoji.rb ADDED
@@ -0,0 +1,114 @@
1
+ require 'jekyll_plugin_support'
2
+ require_relative 'jekyll_emoji_tag/version.rb'
3
+
4
+ # This Jekyll tag plugin creates an emoji of the desired size and alignment.
5
+ #
6
+ # @example Float Smiley emoji right, sized 3em
7
+ # {% tag_template name='smile' align='right' size='5em' %}
8
+ # The above results in the following HTML:
9
+ # <span style="float: right; font-size: 5em;">&#x1F601;</span>
10
+ #
11
+ # @example Defaults
12
+ # {% tag_template name='smile' %}
13
+ # The above results in the following HTML:
14
+ # <span style="font-size: 3em;">&#x1F601;</span>
15
+ #
16
+ # The Jekyll log level defaults to :info, which means all the Jekyll.logger statements below will not generate output.
17
+ # You can control the log level when you start Jekyll.
18
+ # To set the log level to :debug, write an entery into _config.yml, like this:
19
+ # plugin_loggers:
20
+ # MyTag: debug
21
+ module JekyllEmojiTag
22
+ # This class implements the Jekyll emoji functionality
23
+ class Emoji < JekyllSupport::JekyllTag
24
+ PLUGIN_NAME = 'emoji'.freeze
25
+ VERSION = JekyllEmojiTag::VERSION
26
+
27
+ # Supported emojis (GitHub symbol, hex code) - see https://gist.github.com/rxaviers/7360908 and
28
+ # https://www.quackit.com/character_sets/emoji/emoji_v3.0/unicode_emoji_v3.0_characters_all.cfm
29
+ @@emojis = {
30
+ 'angry' => '&#x1F620;',
31
+ 'boom' => '&#x1F4A5;', # used when requested emoji is not recognized
32
+ 'grin' => '&#128512;',
33
+ 'horns' => '&#128520;',
34
+ 'kiss' => '&#x1F619;',
35
+ 'open' => '&#128515;',
36
+ 'poop' => '&#x1F4A9;',
37
+ 'sad' => '&#128546;',
38
+ 'scream' => '&#x1F631;',
39
+ 'smiley' => '&#x1F601;', # default emoji
40
+ 'smirk' => '&#x1F60F;',
41
+ 'two_hearts' => '&#x1F495;',
42
+ }.sort_by { |k, _v| [k] }.to_h
43
+
44
+ # @param tag_name [String] is the name of the tag, which we already know.
45
+ # @param argument_string [String] the arguments from the web page.
46
+ # @param tokens [Liquid::ParseContext] tokenized command line
47
+ # @return [void]
48
+ def render_impl
49
+ @emoji_name = @helper.parameter_specified?('name') || 'smiley' # Ignored if `list` is specified
50
+ @emoji_align = @helper.parameter_specified?('align') || 'inline' # Allowable values are: inline, right or left
51
+ @emoji_size = @helper.parameter_specified?('size') || '3em'
52
+ @emoji_and_name = @helper.parameter_specified?('emoji_and_name')
53
+ @list = @helper.parameter_specified?('list')
54
+ @emoji_hex_code = @@emojis[@emoji_name] if @emoji_name || @@emojis['boom']
55
+
56
+ # variables defined in pages are stored as hash values in liquid_context
57
+ # _assigned_page_variable = @liquid_context['assigned_page_variable']
58
+
59
+ @layout_hash = @page['layout']
60
+
61
+ @logger.debug do
62
+ <<~HEREDOC
63
+ liquid_context.scopes=#{@liquid_context.scopes}
64
+ mode="#{@mode}"
65
+ page attributes:
66
+ #{@page.sort
67
+ .reject { |k, _| REJECTED_ATTRIBUTES.include? k }
68
+ .map { |k, v| "#{k}=#{v}" }
69
+ .join("\n ")}
70
+ HEREDOC
71
+ end
72
+
73
+ # Return the value of this Jekyll tag
74
+ if @list
75
+ list
76
+ else
77
+ assemble_emoji(@emoji_name, @emoji_hex_code)
78
+ end
79
+ end
80
+
81
+ private
82
+
83
+ def assemble_emoji(emoji_name, emoji_hex_code)
84
+ case @emoji_align
85
+ when 'inline'
86
+ align = ''
87
+ when 'right'
88
+ align = ' float: right; margin-left: 5px;'
89
+ when 'left'
90
+ align = ' float: left; margin-right: 5px;'
91
+ else
92
+ @logger.error { "Invalid emoji alignment #{@emoji_align}" }
93
+ align = ''
94
+ end
95
+
96
+ name = " <code>#{emoji_name}</code>" if @emoji_and_name
97
+
98
+ "<span style='font-size: #{@emoji_size};#{align}'>#{emoji_hex_code}</span>#{name}"
99
+ end
100
+
101
+ def list
102
+ items = @@emojis.map do |ename, hex_code|
103
+ " <li>#{assemble_emoji(ename, hex_code)}</li>"
104
+ end
105
+ <<~END_RESULT
106
+ <ul class='emoji_list'>
107
+ #{items.join("\n ")}
108
+ </ul>
109
+ END_RESULT
110
+ end
111
+
112
+ JekyllPluginHelper.register(self, PLUGIN_NAME)
113
+ end
114
+ end
@@ -0,0 +1,3 @@
1
+ module JekyllEmojiTag
2
+ VERSION = '0.1.0'.freeze unless defined? VERSION
3
+ end
@@ -0,0 +1,10 @@
1
+ require 'jekyll'
2
+ require 'jekyll_plugin_logger'
3
+ require 'jekyll_plugin_support'
4
+
5
+ require_relative 'jekyll_emoji_tag/version'
6
+
7
+ # Require all Ruby files in 'lib/', except this file
8
+ Dir[File.join(__dir__, '*.rb')].each do |file|
9
+ require file unless file.end_with?('/jekyll_emoji_tag.rb')
10
+ end
@@ -0,0 +1,13 @@
1
+ require_relative '../lib/jekyll_emoji_tag'
2
+
3
+ RSpec.describe JekyllEmojiTag::JekyllEmojiTag do
4
+ let(:logger) do
5
+ PluginMetaLogger.instance.new_logger(self, PluginMetaLogger.instance.config)
6
+ end
7
+
8
+ let(:parse_context) { TestParseContext.new }
9
+
10
+ it 'has a test' do
11
+ expect(true).to be_true
12
+ end
13
+ end
@@ -0,0 +1,79 @@
1
+ require 'jekyll'
2
+ require 'jekyll_plugin_logger'
3
+ require 'liquid'
4
+ require 'fileutils'
5
+ require 'yaml'
6
+ require_relative '../lib/<%= @gem_name %>'
7
+
8
+ RSpec.configure do |config|
9
+ config.filter_run :focus
10
+ # config.order = 'random'
11
+ config.run_all_when_everything_filtered = true
12
+
13
+ # See https://relishapp.com/rspec/rspec-core/docs/command-line/only-failures
14
+ config.example_status_persistence_file_path = '../spec/status_persistence.txt'
15
+
16
+ config.filter_run_when_matching focus: true
17
+ end
18
+
19
+ Registers = Struct.new(:page, :site)
20
+
21
+ # Mock for Collections
22
+ class Collections
23
+ def values
24
+ []
25
+ end
26
+ end
27
+
28
+ # Mock for Site
29
+ class SiteMock
30
+ attr_reader :config
31
+
32
+ def initialize
33
+ @config = YAML.safe_load(File.read('../demo/_config.yml'))
34
+ @config['env'] = { 'JEKYLL_ENV' => 'development' }
35
+ end
36
+
37
+ def collections
38
+ Collections.new
39
+ end
40
+ end
41
+
42
+ class TestLiquidContext < Liquid::Context
43
+ def initialize
44
+ super
45
+
46
+ page = {
47
+ 'content' => 'blah blah',
48
+ 'description' => 'Jekyll plugin support demo',
49
+ 'dir' => '/',
50
+ 'excerpt' => nil,
51
+ 'layout' => 'default',
52
+ 'name' => 'index.html',
53
+ 'path' => 'index.html',
54
+ 'title' => 'Welcome',
55
+ 'url' => '/',
56
+ }
57
+
58
+ @content = 'Interior of the tag'
59
+ @registers = Registers.new(
60
+ page,
61
+ SiteMock.new
62
+ )
63
+ end
64
+ end
65
+
66
+ # Mock for Liquid::ParseContent
67
+ class TestParseContext < Liquid::ParseContext
68
+ attr_reader :line_number, :registers
69
+
70
+ def initialize
71
+ super
72
+ @line_number = 123
73
+
74
+ @registers = Registers.new(
75
+ { 'path' => 'path/to/page.html' },
76
+ SiteMock.new
77
+ )
78
+ end
79
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll_emoji_tag
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Mike Slinn
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-07-07 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: 3.5.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 3.5.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: jekyll_plugin_support
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.7.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.7.0
41
+ description: 'Inserts an emoji
42
+
43
+ '
44
+ email:
45
+ - mslinn@mslinn.com
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - ".rubocop.yml"
51
+ - CHANGELOG.md
52
+ - README.md
53
+ - Rakefile
54
+ - jekyll_emoji_tag.gemspec
55
+ - lib/emoji.rb
56
+ - lib/jekyll_emoji_tag.rb
57
+ - lib/jekyll_emoji_tag/version.rb
58
+ - spec/jekyll_emoji_tag_spec.rb
59
+ - spec/spec_helper.rb
60
+ homepage: https://github.com/mslinn/jekyll_emoji_tag
61
+ licenses:
62
+ - MIT
63
+ metadata:
64
+ allowed_push_host: https://rubygems.org
65
+ bug_tracker_uri: https://github.com/mslinn/jekyll_emoji_tag/issues
66
+ changelog_uri: https://github.com/mslinn/jekyll_emoji_tag/CHANGELOG.md
67
+ homepage_uri: https://github.com/mslinn/jekyll_emoji_tag
68
+ source_code_uri: https://github.com/mslinn/jekyll_emoji_tag
69
+ post_install_message: |2+
70
+
71
+ Thanks for installing jekyll_emoji_tag!
72
+
73
+ rdoc_options: []
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: 3.1.0
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubygems_version: 3.3.3
88
+ signing_key:
89
+ specification_version: 4
90
+ summary: Inserts an emoji
91
+ test_files: []
92
+ ...