Skip to content

Commit

Permalink
Merge pull request #4 from Bushido/emoticons
Browse files Browse the repository at this point in the history
Emoticons
  • Loading branch information
kevzettler committed Apr 12, 2012
2 parents 13520aa + 5e2369d commit 017af93
Show file tree
Hide file tree
Showing 21 changed files with 46 additions and 0 deletions.
Binary file added app/assets/images/emoticons/alone.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/awwyea.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/badass.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/bitchplease.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/cereal.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/challenge.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/fuckyeah.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/ilied.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/megusta.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/notbad.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/okay.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/omgface.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/pokerface.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/rageguy.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/seriously.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/sweetjesus.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/truestory.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/youdontsay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/yuno.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/javascripts/backbone/kandan.js.coffee.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ window.Kandan =
,"Pastie"
,"Attachments"
,"MeAnnounce"
,"Emoticons"
]

for plugin in plugins
Expand Down
45 changes: 45 additions & 0 deletions app/assets/javascripts/backbone/plugins/emoticons.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
class Kandan.Plugins.Emoticons

@options:
regex: /\([a-zA-Z]+\)/g
template: _.template '''
<img class="emoticon-embed" src="/assets/emoticons/<%= emoticon %>" height="30" width="30" />
'''


@emoticons: {
"(alone)" : "alone.jpg",
"(awwyea)" : "awwyea.jpg",
"(badass)" : "badass.png",
"(bitchplease)" : "bitchplease.jpg",
"(cereal)" : "cereal.jpg",
"(challenge)" : "challenge.jpg",
"(fuckyeah)" : "fuckyeah.jpg",
"(ilied)" : "ilied.jpg",
"(megusta)" : "megusta.jpg",
"(notbad)" : "notbad.jpg",
"(okay)" : "okay.jpg",
"(omgface)" : "omgface.jpg",
"(pokerface)" : "pokerface.jpg",
"(rageguy)" : "rageguy.jpg",
"(seriously)" : "seriously.jpg",
"(sweetjesus)" : "sweetjesus.jpg",
"(truestory)" : "truestory.png",
"(youdontsay)" : "youdontsay.png",
"(yuno)" : "yuno.jpg"
}

@init: ()->
Kandan.Modifiers.register @options.regex, (message, state) =>
matches = message.content.match(@options.regex)
for match in _.unique(matches)
emoticon = @emoticons[match]
needle = match.replace('(', '\\(').replace(')', '\\)')
search = new RegExp(needle, 'g')
console.log(search)
replacement = @options.template({ emoticon: emoticon })
message.content = message.content.replace(search, replacement) if emoticon
console.log(message.content)
return Kandan.Helpers.Activities.buildFromBaseTemplate(message)

# Kandan.Plugins.register "Kandan.Plugins.Emoticons"

0 comments on commit 017af93

Please sign in to comment.