Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for aliases #44

Closed
wants to merge 6 commits into from
Closed

Adds support for aliases #44

wants to merge 6 commits into from

Conversation

mislav
Copy link
Contributor

@mislav mislav commented Mar 13, 2014

require 'emoji/aliases'
Emoji.aliases_for('smile') #=> [...]

The use-case is to enhance the completion suggester for entering emojis.

This initial set of aliases is inspired by @muan's emojis.json.

This is 🚧 🚧 since there are a couple of open questions:

  • Is it OK to keep the list in YAML? It could be a plain text file just as well. I only want to keep it line-based for easier editing & diffs.
  • Is it useful that this is an optional require, or should it come by default when you require (g)emoji?
  • There is already a scheme for aliasing via symlinks. The following emojis already had multiple names:
names Unicode description
😆 laughing, satisfied smiling face with open mouth and tightly-closed eyes
💩 hankey, poop, shit pile of poo
💥 boom, collision collision symbol
👍 +1, thumbsup thumbs up sign
👎 -1, thumbsdown thumbs down sign
👊 facepunch, punch fisted hand sign
hand, raised_hand raised hand
🏃 runner, running runner
👞 mans_shoe, shoe mans shoe
👕 shirt, tshirt t-shirt
🐝 bee, honeybee honeybee
🐬 dolphin, flipper dolphin
🐾 feet, paw_prints paw prints
🌔 moon, waxing_gibbous_moon waxing gibbous moon symbol
☎️ phone, telephone black telephone
🔪 hocho, knife hocho
📧 email, envelope envelope
📝 memo, pencil memo
📖 book, open_book open book
boat, sailboat sailboat
🚗 car, red_car automobile
🏮 izakaya_lantern, lantern izakaya lantern
🇬🇧 gb, uk regional indicator symbol letter g + b
exclamation, heavy_exclamation_mark heavy exclamation mark symbol

This PR adds another scheme for aliasing, and now we end up with 2 levels of aliasing, which I don't like. I would prefer to get rid of multiple aliases on the filesystem and just go the route with aliases kept in a data file. However, if we delete the filesystem aliases then we break backwards compatibility, since people might be using :knife: in their textareas and knife.png in their apps.

mislav added 6 commits March 12, 2014 12:16
Do lookups via `Hash#fetch`, and return nil directly without having to
create an intermediate empty array for missed lookups
Some emojis have multiple named mappings pointing to it, like
"hocho" = "knife". This tweaks the inverted_mapping hash to keep track
of all names for an emoji, not just the last one registered.
Example:

    require 'emoji/aliases'
    Emoji.aliases_for('smile') #=> [...]
@josh
Copy link
Contributor

josh commented Mar 13, 2014

Is it useful that this is an optional require, or should it come by default when you require (g)emoji?

It should be in the standard require.

This PR adds another scheme for aliasing, and now we end up with 2 levels of aliasing, which I don't like. I would prefer to get rid of multiple aliases on the filesystem and just go the route with aliases kept in a data file.

I kinda like not normalizing to a canonical name. That requires the use of a suggester. I'd rather have literal :toilet: and :wc syntaxes both work.

We currently have a issue with the symlinks we might need to work out first. When the gem is built, symlinks get stripped. So we might need to move to a data file anyway.

@josh
Copy link
Contributor

josh commented Mar 13, 2014

/cc @trevorturk @aroben @javan @asianmack

@javan
Copy link
Contributor

javan commented Mar 13, 2014

👍 to killing all the symlinked files. The gem should just contain the images in unicode/.

If the data file mapped each unicode to an array of names ({ "1f4a9" => ["poop", "shit"] }), we'd be all set. The first name in the array could be considered "canonical", but it wouldn't matter.

The install task could then create all the symlinks.

@mislav
Copy link
Contributor Author

mislav commented Mar 13, 2014

Here's the difference right now with "names" vs. "aliases":

  1. "Names" have a corresponding image and are a valid argument for Emoji.unicode_for(name). A single emoji can have multiple names (illustrated by the table above).
  2. "Aliases" don't have a corresponding image and are not a valid argument for Emoji.unicode_for(alias).

This creates 2 different vectors for referring to a single emoji. I don't like that, and even before this PR I didn't like the symlink style:

  1. People end up with multiple png images (hankey, poop, shit) representing the same emoji.
  2. Png images named with unicode codepoints also get copied to people's project, but people don't know what to do with them.
  3. Not all emoji from this gem resolve to some unicode codepoints; there are a few custom emoji that are not part of Unicode.

I think I'll open a separate PR to first propose how I would get rid of symlinks. Adding aliases to the current situation would just be confusing.

@josh
Copy link
Contributor

josh commented Mar 13, 2014

I think I'll open a separate PR to first propose how I would get rid of symlinks. Adding aliases to the current situation would just be confusing.

Rad.

@javan
Copy link
Contributor

javan commented Mar 13, 2014

🤘

@mislav
Copy link
Contributor Author

mislav commented Jun 18, 2014

Closing this; going with #47 instead

@mislav mislav closed this Jun 18, 2014
@mislav mislav deleted the aliases branch June 27, 2014 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants