This repository has been archived by the owner on Mar 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Revert "Merge pull request #34 from sfc-rg/demmys/emoji""
This reverts commit 21ebf05.
- Loading branch information
Showing
31 changed files
with
180 additions
and
17 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -18,3 +18,5 @@ | |
|
||
/config/oauth.yml | ||
bundle/ | ||
public/images/emoji | ||
vendor/assets/bower_components |
This file contains 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 @@ | ||
asset 'jquery-textcomplete' |
This file contains 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 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 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 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 |
---|---|---|
|
@@ -4,3 +4,5 @@ | |
require File.expand_path('../config/application', __FILE__) | ||
|
||
Rails.application.load_tasks | ||
|
||
load 'tasks/emoji.rake' |
This file contains 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 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,16 @@ | ||
ready = -> | ||
emojiCompletions = $('textarea.emoji-complete') | ||
if emojiCompletions.length > 0 | ||
emojiAliases = Object.keys(gon.emojis) | ||
emojiCompletions.textcomplete([ | ||
match: /(^|\s):([\w+-]*)$/, | ||
search: (term, callback) -> | ||
callback(emojiAliases.filter (e) -> e.indexOf(term) != -1) | ||
template: (value) -> | ||
"<img src='/images/emoji/#{gon.emojis[value]}' class=emoji /> #{value}" | ||
replace: (value) -> | ||
"$1:#{value}:" | ||
], maxCount: 5) | ||
|
||
$(ready) | ||
$(document).on('page:load', ready) |
This file contains 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 |
---|---|---|
|
@@ -109,3 +109,10 @@ nav { | |
width: 15%; | ||
} | ||
} | ||
|
||
.emoji { | ||
width: 1em; | ||
height: 1em; | ||
margin: 0; | ||
padding: 0; | ||
} |
This file contains 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 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,5 @@ | ||
module EmojiComplete | ||
def set_emoji_completion | ||
gon.emojis = Emoji.send(:names_index).map { |name, emoji| [name, emoji.image_filename] }.to_h | ||
end | ||
end |
This file contains 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 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 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,13 @@ | ||
module Emojifier | ||
def emojify | ||
self.content.gsub(/:([\w+-]+):/) do |match| | ||
name = Regexp.last_match(1) | ||
emoji = Emoji.find_by_alias(name) | ||
return match unless emoji | ||
ActionController::Base.helpers.image_tag( | ||
ActionController::Base.helpers.image_path("emoji/#{emoji.image_filename}"), | ||
alt: name, class: 'emoji' | ||
) | ||
end | ||
end | ||
end |
This file contains 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 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
class Page < ActiveRecord::Base | ||
include Emojifier | ||
include MarkdownRender | ||
|
||
has_many :comments | ||
|
This file contains 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 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 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 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 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 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,19 @@ | ||
BowerRails.configure do |bower_rails| | ||
# Tell bower-rails what path should be considered as root. Defaults to Dir.pwd | ||
# bower_rails.root_path = Dir.pwd | ||
|
||
# Invokes rake bower:install before precompilation. Defaults to false | ||
bower_rails.install_before_precompile = true | ||
|
||
# Invokes rake bower:resolve before precompilation. Defaults to false | ||
# bower_rails.resolve_before_precompile = true | ||
|
||
# Invokes rake bower:clean before precompilation. Defaults to false | ||
bower_rails.clean_before_precompile = true | ||
|
||
# Invokes rake bower:install:deployment instead rake bower:install. Defaults to false | ||
# bower_rails.use_bower_install_deployment = true | ||
# | ||
# Invokes rake bower:install and rake bower:install:deployment with -F (force) flag. Defaults to false | ||
# bower_rails.force_install = true | ||
end |
This file contains 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 |
---|---|---|
@@ -1,8 +1,7 @@ | ||
FactoryGirl.define do | ||
factory :comment do | ||
user nil | ||
post nil | ||
content "MyText" | ||
content 'This is a comment.' | ||
association :user | ||
association :page | ||
end | ||
|
||
end |
This file contains 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,7 @@ | ||
FactoryGirl.define do | ||
factory :page do | ||
path 'sample' | ||
title 'sample' | ||
content 'This is a page.' | ||
end | ||
end |
This file contains 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
FactoryGirl.define do | ||
factory :slack_credential do | ||
user_id 'U03AE1H0U' | ||
sequence(:slack_user_id) { |n| "U03AE1H0U#{n}" } | ||
end | ||
end |
This file contains 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe Comment, type: :model do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
it_behaves_like 'emojifier' | ||
end |
This file contains 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,20 @@ | ||
require 'rails_helper' | ||
|
||
shared_examples_for 'emojifier' do | ||
let(:model) { described_class } | ||
let(:factory) { model.to_s.underscore.to_sym } | ||
|
||
subject { object.emojify } | ||
|
||
context 'contents do not include any emojis' do | ||
let(:object) { FactoryGirl.create(factory, content: 'Example content') } | ||
it { should eq(object.content) } | ||
end | ||
|
||
context 'contents include some emojis' do | ||
let(:object) { FactoryGirl.create(factory, content: 'Example content :smile: :+1:') } | ||
|
||
it { should_not match(/:[\w+-]+:/) } | ||
it { should match(/<img/) } | ||
end | ||
end |
This file contains 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
require 'rails_helper' | ||
|
||
describe Page, type: :model do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
it_behaves_like 'emojifier' | ||
end |
This file contains 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 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,3 @@ | ||
{ | ||
"directory": "bower_components" | ||
} |
This file contains 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,6 @@ | ||
{ | ||
"name": "dsl-generated dependencies", | ||
"dependencies": { | ||
"jquery-textcomplete": "latest" | ||
} | ||
} |