This repository was archived by the owner on Nov 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Added Emoji feature. First operational code 😄 #177
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| # Jekyll Emoji | ||
| # | ||
| # Chris Kempson (http://chriskempson.com) | ||
| # https://github.com/chriskempson/jekyll-emoji | ||
| # | ||
| # A jekyll plug-in that provides a Liquid filter for emojifying text with | ||
| # https://github.com/github/gemoji. See http://www.emoji-cheat-sheet.com for | ||
| # a full listing of emoji codes. | ||
| # | ||
| # Installation: | ||
| # - Run `gem install gemoji` or add `gem 'gemoji'` to your gemfile and run `bundle install` | ||
| # - Copy this file to your `_plugins` directory | ||
| # - Add a line like `emoji_dir: images/emoji` to your `_config.yml` | ||
| # - If you want to use external source for emoji, set `emoji_dir: http://...` to your `_config.yml`. | ||
| # | ||
| # Usage: | ||
| # - Apply the filter wherever needed e.g. {{ content | emojify }} | ||
| # - Add some emoji to your article! e.g. "Hello :wink:" | ||
|
|
||
| require 'gemoji' | ||
|
|
||
| module Jekyll | ||
|
|
||
| module EmojiFilter | ||
|
|
||
| def emojify(content) | ||
| return false if !content | ||
|
|
||
| config = @context.registers[:site].config | ||
| if config['emoji_dir'] | ||
| if config['emoji_dir'].start_with?('http') | ||
| emoji_dir = config['emoji_dir'] | ||
| else | ||
| emoji_dir = '/' + File.join(config['source'], config['emoji_dir']) | ||
| end | ||
| end | ||
|
|
||
| content.to_str.gsub(/([^:]):([\w\d+-]+):/) do |match| | ||
| if Emoji.names.include?($2) and emoji_dir | ||
| $1 + '<img alt="' + $2 + '" src="' + emoji_dir + "/#{$2}.png" + '" class="emoji" />' | ||
| else | ||
| match | ||
| end | ||
| end | ||
| end | ||
|
|
||
| end | ||
|
|
||
| class EmojiGenerator < Generator | ||
| def generate(site) | ||
| config = site.config | ||
| return false if not config['emoji_dir'] | ||
| return false if config['emoji_dir'].start_with?('http') | ||
| emoji_dir = File.join(config['source'], config['emoji_dir']) | ||
| return false if File.exist?(emoji_dir + '/smiley.png') | ||
|
|
||
| # Make Emoji directory | ||
| FileUtils.mkdir_p(emoji_dir) | ||
|
|
||
| # Copy Gemoji files | ||
| Dir["#{Emoji.images_path}/emoji/*.png"].each do |src| | ||
| FileUtils.cp src, emoji_dir | ||
| end | ||
| end | ||
| end | ||
|
|
||
| end | ||
|
|
||
| Liquid::Template.register_filter(Jekyll::EmojiFilter) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| --- | ||
| layout: post | ||
| category : features | ||
| tagline: "Supporting tagline" | ||
| emojify: true | ||
| tags : [intro, beginner, jekyll, tutorial, emoji, features] | ||
| --- | ||
| {% include JB/setup %} | ||
|
|
||
| # Emoji feature integration test page. | ||
|
|
||
| Testing replacement of **::smile:** with :smile: | ||
| Did it worked? | ||
|
|
||
| Note that the string to use to get this smile is one containing only one **':'** character. The plugin as been tuned as suggested by [DrSlump here](http://juandebravo.com/2012/11/17/emoji-support-in-jekyll/#) to avoid replacing a string by its emoji if it starts with **'::'**. | ||
|
|
||
|
|
||
| **Author: Patrice Lachance, http://www.itisopen.net** | ||
|
|
||
|
|
||
| **This plugin would not have been make without the following articles!** | ||
|
|
||
| - [Chris Kempson](https://github.com/chriskempson/jekyll-emoji) | ||
| Source of the plugin, I made only few modifications. | ||
| - [Juan de Bravo](http://juandebravo.com/2012/11/17/emoji-support-in-jekyll/) | ||
| Detailed step by step guide to understand how it works. | ||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please include "Gemfile" in your .gitignore instead of adding it here.
Thanks.