Current section
7 Versions
Jump to
Current section
7 Versions
Compare versions
5
files changed
+24
additions
-10
deletions
| @@ -16,7 +16,7 @@ end | |
| 16 16 | |
| 17 17 | If you want to render in svg, you must run `mix emojix.install` to copy `emoji.svg` inside `priv/static/images` |
| 18 18 | |
| 19 | - ### Some examples: |
| 19 | + ## Some examples: |
| 20 20 | |
| 21 21 | ```iex |
| 22 22 | iex> Emojix.all |
| @@ -37,7 +37,11 @@ iex> Emojix.replace_by_html("I love my :dog:") | |
| 37 37 | "I love my <svg class='emoji-icon'><use xlink:href=\"/images/emoji.svg#emoji-1f436\"></svg>" |
| 38 38 | ``` |
| 39 39 | |
| 40 | + ## TODO |
| 41 | + |
| 42 | + - [ ] write the documentation |
| 43 | + |
| 40 44 | ## Credits |
| 41 | - --- |
| 45 | + |
| 42 46 | * Inspired by [Exmoji](https://github.com/mroth/exmoji) |
| 43 47 | * Emoji provided free by [EmojiOne](http://emojione.com/) |
| @@ -19,4 +19,4 @@ | |
| 19 19 | {<<"name">>,<<"poison">>}, |
| 20 20 | {<<"optional">>,false}, |
| 21 21 | {<<"requirement">>,<<"~> 3.0">>}]]}. |
| 22 | - {<<"version">>,<<"0.1.0">>}. |
| 22 | + {<<"version">>,<<"0.1.1">>}. |
| @@ -1,4 +1,8 @@ | |
| 1 1 | defmodule Emojix do |
| 2 | + @moduledoc """ |
| 3 | + An elixir library that converts emoji in char or svg. Supports 1820 emoji. |
| 4 | + """ |
| 5 | + |
| 2 6 | emoji = |
| 3 7 | Application.app_dir(:emojix, "priv/data/emoji.json") |
| 4 8 | |> File.read! |
| @@ -27,8 +31,7 @@ defmodule Emojix do | |
| 27 31 | |
| 28 32 | def find_by_keyword(keyword) do |
| 29 33 | keyword = String.strip(keyword, ?:) |
| 30 | - find_by_shortname(":#{keyword}:") |
| 31 | - |> List.first |
| 34 | + List.first(find_by_shortname(":#{keyword}:")) |
| 32 35 | end |
| 33 36 | |
| 34 37 | def replace_by_char(text) do |
| @@ -51,7 +54,6 @@ defmodule Emojix do | |
| 51 54 | |
| 52 55 | defp search_by(field, value) do |
| 53 56 | value = String.downcase(value) |
| 54 | - all() |
| 55 | - |> Enum.filter(&String.contains?(Map.get(&1, field), value)) |
| 57 | + Enum.filter(all(), &String.contains?(Map.get(&1, field), value)) |
| 56 58 | end |
| 57 59 | end |
| @@ -1,6 +1,7 @@ | |
| 1 1 | defmodule Emojix.Emoji do |
| 2 | - @emoji_path Application.get_env(:emojix, :path) |
| 3 | - |
| 2 | + @moduledoc """ |
| 3 | + Emoji module |
| 4 | + """ |
| 4 5 | defstruct [ |
| 5 6 | name: nil, |
| 6 7 | shortname: nil, |
| @@ -10,7 +11,7 @@ defmodule Emojix.Emoji do | |
| 10 11 | |
| 11 12 | def render(%Emojix.Emoji{unicode: unicode}, opts), do: render(unicode, opts) |
| 12 13 | def render(unicode, :html) do |
| 13 | - ~s(<svg class='emoji-icon'><use xlink:href="#{@emoji_path}#emoji-#{unicode}"></svg>) |
| 14 | + ~s(<svg class='emoji-icon'><use xlink:href="#{emoji_path()}#emoji-#{unicode}"></svg>) |
| 14 15 | end |
| 15 16 | def render(unicode, :char) do |
| 16 17 | unicode |
| @@ -33,4 +34,8 @@ defmodule Emojix.Emoji do | |
| 33 34 | |> String.rjust(4,?0) |
| 34 35 | |> String.downcase |
| 35 36 | end |
| 37 | + |
| 38 | + defp emoji_path do |
| 39 | + Application.get_env(:emojix, :path, "/images/emoji.svg") |
| 40 | + end |
| 36 41 | end |
| @@ -1,9 +1,11 @@ | |
| 1 1 | defmodule Emojix.Mixfile do |
| 2 2 | use Mix.Project |
| 3 3 | |
| 4 | + @version "0.1.1" |
| 5 | + |
| 4 6 | def project do |
| 5 7 | [app: :emojix, |
| 6 | - version: "0.1.0", |
| 8 | + version: @version, |
| 7 9 | elixir: "~> 1.4", |
| 8 10 | build_embedded: Mix.env == :prod, |
| 9 11 | start_permanent: Mix.env == :prod, |