Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,34 @@
# For more see: http://jekyllrb.com/docs/permalinks/
permalink: /:categories/:year/:month/:day/:title

exclude: [".rvmrc", ".rbenv-version", "README.md", "Rakefile", "changelog.md"]
exclude: [".rvmrc", ".rbenv-version", "README.md", "Rakefile", "changelog.md", "Gemfile"]
Copy link
Collaborator

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.

auto: true
pygments: true

# Path to the directory containing Emoji icons.
#
# Note: you also have to include tje following tag in the each post's YAML Front Matter
# to trigger the Emoji plugin
# -------------
# emojify: true
# -------------
#
# Directory definition examples:
#
# Pointing to a web server
# emoji_dir: https://public.blog.url/images/emoji
#
# Using directory, will work only on the local machine
# emoji_dir: ./images/emoji
#
# If you will be serving emoji icons from your website,
# defined first as directory and run 'jekyll build'.
# This will copy the icons from the gemoji gem to the
# directory you specified. Test locally then change to URL.
# See class EmojiGenerator in the plugin code for more information
emoji_dir: ./images/emoji


# Themes are encouraged to use these universal variables
# so be sure to set them if your theme uses them.
#
Expand Down
6 changes: 5 additions & 1 deletion _includes/themes/twitter/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@
<div class="container-narrow">

<div class="content">
{{ content }}
{% if page.emojify == true %}
{{ content | emojify }}
{% else %}
{{ content }}
{% endif %}
</div>
<hr>
<footer>
Expand Down
6 changes: 5 additions & 1 deletion _includes/themes/twitter/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ <h1>{{ page.title }} {% if page.tagline %} <small>{{ page.tagline }}</small>{% e

<div class="row-fluid">
<div class="span12">
{{ content }}
{% if page.emojify == true %}
{{ content | emojify }}
{% else %}
{{ content }}
{% endif %}
</div>
</div>
6 changes: 5 additions & 1 deletion _includes/themes/twitter/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ <h1>{{ page.title }} {% if page.tagline %}<small>{{page.tagline}}</small>{% endi
<span>{{ page.date | date_to_long_string }}</span>
</div>
<div class="content">
{{ content }}
{% if page.emojify == true %}
{{ content | emojify }}
{% else %}
{{ content }}
{% endif %}
</div>

{% unless page.categories == empty %}
Expand Down
69 changes: 69 additions & 0 deletions _plugins/emoji.rb
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)
27 changes: 27 additions & 0 deletions _posts/core-samples/2013-08-25-jekyll-emoji.md
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.