Skip to content
This repository has been archived by the owner on Oct 3, 2018. It is now read-only.

Commit

Permalink
Merge branch 'release/1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
hassankhan committed Feb 1, 2015
2 parents 4ffb10c + 27169d8 commit 102d189
Show file tree
Hide file tree
Showing 1,819 changed files with 10,385 additions and 4,218 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
root = true

[*]
charset = "utf8"
charset = "utf-8"
end_of_line = lf
insert_final_newline = true

Expand Down
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
node_modules
css
vendor
tests.browserified.js


# editors
.idea
*.iml
*.sublime-project
6 changes: 6 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*
!dist
!dist/*
!README.md
!LICENSE.md
!LICENSE-IMAGES.md
11 changes: 6 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ This project follows [Git-Flow](http://nvie.com/posts/a-successful-git-branching

1. Install the appropriate [EditorConfig](http://editorconfig.org) plugin for your IDE/editor. This helps keep the code style consistent.
2. Install [PhantomJS](http://phantomjs.org). Make sure it's on your path / available when calling `phantomjs` from the command line.
2. `npm install -g grunt-cli`
2. `npm install -g gulp`
3. `npm install`

## Running the tests

- All tests: `npm test`
- Just the browser ones: `phantomjs tests/phantom.js`
- Just the Node ones: `grunt test-node`
- Just the Node ones: `node tests/node.js`

## Before creating a pull request

Make sure you do the following:

- Run `grunt`
- Run `gulp`

Note: The build script will generate new `*.min.{css,js}` files. If, for example, you only changed the JavaScript then don't bother committing `emojify.min.css`.

Expand All @@ -34,6 +34,7 @@ git log --pretty=format:"- %s" >> log.md

If you have rights to publish to npm, do the following first:

- Run `update.sh`. This will update the project with the latest emoji from [emoji-cheat-sheet.com](http://www.emoji-cheat-sheet.com).
- Run `grunt`
- Run `gulp update`. This will update the project with the latest emoji from [emoji-cheat-sheet.com](http://www.emoji-cheat-sheet.com).
- Run `gulp`
- Run `gulp bump`
- Run `npm publish`
74 changes: 0 additions & 74 deletions Gruntfile.js

This file was deleted.

14 changes: 14 additions & 0 deletions LICENSE-IMAGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
octocat, squirrel, shipit
Copyright (c) 2012 GitHub Inc. All rights reserved.

bowtie, neckbeard
Copyright (c) 2012 37signals, LLC. All rights reserved.

feelsgood, finnadie, goberserk, godmode, hurtrealbad, rage 1-4, suspect
Copyright (c) 2012 id Software. All rights reserved.

trollface
Copyright (c) 2012 whynne@deviantart. All rights reserved.

All other images
Copyright (c) 2012 Apple Inc. All rights reserved.
8 changes: 8 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
THE MIT LICENSE (MIT)
Copyright © 2014 Hassan Khan, http://hassankhan.me <contact@hassankhan.me>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
76 changes: 58 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
Master | Develop
--- | ---
[![Master branch build status][ico-build]][travis] | [![Develop branch build status][ico-build-dev]][travis]
[![Master branch Windows build status][ico-windows-build]][appveyor] | [![Develop branch Windows build status][ico-windows-build-dev]][appveyor]

[![Browser Results](https://ci.testling.com/hassankhan/emojify.js.png)](https://ci.testling.com/hassankhan/emojify.js)

A swiss-army-knife for all emoji, in Javascript. Used by [Gitter](https://gitter.im/)
A swiss-army-knife for all emoji, in Javascript. Used by [Gitter](https://gitter.im/) and [Mapbox](https://www.mapbox.com/blog/emoji-map-markers/).

The emoji keywords are as described by [emoji-cheat-sheet.com](http://www.emoji-cheat-sheet.com).

Expand All @@ -23,20 +24,30 @@ Go to this project's [GitHub pages](http://hassankhan.github.com/emojify.js) to

- Fast
- Awesome
- Made from unicorn blood
- Available on a CDN **(gasp)**
- Converts emoticons like `:) :( :'(`
- Allows customisation of processed emoji
- Multiple modes; `img`, sprites and data-URI
- Available on a CDN **(gasp)**
- Includes a [sample `.htaccess` file](.htaccess) for caching Javascript and CSS
- Switchable emoji sets **(SOON!)**
- Made from unicorn blood

## Installation

### Via cdnjs **[SOON]**
Care about old browsers compatibility? Use https://github.com/es-shims/es5-shim

### Via cdnjs

emojify.js is now available on cdnjs - https://cdnjs.com/libraries/emojify.js

Add this to the rest of your stylesheet imports:

`<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/emojify.js/0.9.5/emojify.min.css" />`

Then add this to your Javascript code:

`<script src="//cdnjs.cloudflare.com/ajax/libs/emojify.js/0.9.5/emojify.min.js"></script>`

### Via Bower

`bower install emojify.js --save`
Expand All @@ -52,37 +63,63 @@ Then add this to your Javascript code:
*This works in the browser and on Node*

#### Parameters

- `object` - Optional JSON object with any of the following attributes:

Option | Default | Description
--- | --- | ---
`emojify_tag_type` | `null` | When set, emojify uses this element with the class `emoji emoji-#{emojiname}` instead of an `img` with a `src` attribute. Example valid values: `div`, `span`
`only_crawl_id` | `null` | Restricts searching for emojis to a specified element & it's children. If null, and no object is passed to `run()`, `document.body` is used
`blacklist.elements` | `['script', 'textarea', 'a', 'pre', 'code']` | An array of elements you don't want emojified
`blacklist.classes` | `['no-emojify']` | An array of classes you don't want emojified
`mode` | `img` | By default, emojify will output an `img` with a `src` attribute for each emoji found. But if `mode` is set to `sprite` or `data-uri`, then `span`s with classes are outputted. Don't forget to include the appropriate CSS for your choice though, see the `/dist` directory.
`tag_type` | `null` | When set, emojify uses this element with the class `emoji emoji-#{emojiname}` instead of an `img` with a `src` attribute. Example valid values: `div`, `span`. This takes precedence over the `mode` option. Note: if you're not using `img`s, `.emoji-+1` isn't a valid class, so `.emoji-plus1` is used instead.
`only_crawl_id` | `null` | **[DEPRECATED]** Restricts searching for emojis to a specified element & it's children. If null, and no object is passed to `run()`, `document.body` is used
`img_dir` | `'images/emoji'` | Defines the path to the emoji images
`ignore_emoticons` | `false` | If `true`, only convert emoji like `:smile:` and ignore emoticons like `:)`
`ignored_tags` | `{'SCRIPT': 1,'TEXTAREA': 1,'A': 1,'PRE': 1,'CODE': 1}` | A list of elements that you don't want emojified

#### Usage
```js
emojify.setConfig({emojify_tag_type : 'div'});
emojify.setConfig({tag_type : 'div'});
```

---

### run([element])
### run([element], [replacer])

*This only works in the browser*
*This works in the browser and Node*

#### Parameters
- `element` - Optional HTML element to restrict the emojification to.
- `replacer` - Optional Function to override emoji replacement behaviour with your own. The function will receive two arguments, the emoji pattern found (`emoji`), and the emoji name (`name`). In the case of emoticons, for example, `emoji = ':)'` and `name = 'smile'`. Your function must return a HTMLElement.

#### Usage

##### Browser
```js
emojify.run();
// OR
emojify.run(document.getElementById('my-element'))
// OR
emojify.run(null, function(emoji, emojiName){
var span = document.createElement('span');
span.className = 'emoji emoji-' + emojiName;
span.innerHTML = emoji + ' replaced';
return span;
});
```

##### Node.js
Requires you to have jsdom installed:
`npm i jsdom --save`

```js
var jsdom = require('jsdom')

jsdom.env({
html: "<p><code>jhhh</code><em>:)</em></p>",
done: function(errors, window) {
emojify.run(window.document.body)
}
});
```
---

### replace(string, [callback])
Expand All @@ -97,7 +134,7 @@ emojify.run(document.getElementById('my-element'))

By default, emojify.js uses the internal function `defaultReplacer()` to replace emoji. You can override this behaviour by supplying your own callback function.

Your callback function will receive two parameters, the emoji pattern found (`emoji`), and the emoji name (`name`). In the case of emoticons, for example, `emoji = ':)'` and `name = 'smile'`.
Your callback function will receive two arguments, the emoji pattern found (`emoji`), and the emoji name (`name`). In the case of emoticons, for example, `emoji = ':)'` and `name = 'smile'`.

The context in which your replacer function is run will have the config available. So you can access properties such as `img_dir` at `this.config.img_dir`.

Expand All @@ -112,22 +149,25 @@ replacer = function(emoji, name) {
emojify.replace('I am happy :)', replacer);
```

### Excluding elements from being processed

To exclude tags from being emojified, add `no-emojify` to their `class` attributes.

## Contributing changes

Please read [CONTRIBUTING.md](CONTRIBUTING.md).

## License

Please read [LICENSE.md](LICENSE.md). For image attributions, please read [LICENSE-IMAGES.md](LICENSE-IMAGES.md)

[travis]: https://travis-ci.org/hassankhan/emojify.js
[appveyor]: https://ci.appveyor.com/project/adam-lynch/emojify-js
[package-bower]: http://bower.io/search/?q=emojify.js
[package-npm]: https://www.npmjs.org/package/emojify.js
[ico-build]: http://img.shields.io/travis/hassankhan/emojify.js.svg?style=flat-square
[ico-build-dev]: http://img.shields.io/travis/hassankhan/emojify.js/develop.svg?style=flat-square
[ico-bower]: http://img.shields.io/badge/bower-0.9.4-blue.svg?style=flat-square
[ico-windows-build]: https://ci.appveyor.com/api/projects/status/6umkf6gc7dq64c2g/branch/master?svg=true
[ico-windows-build-dev]: https://ci.appveyor.com/api/projects/status/6umkf6gc7dq64c2g/branch/develop?svg=true
[ico-bower]: http://img.shields.io/bower/v/emojify.js.svg?style=flat-square
[ico-npm]: http://img.shields.io/npm/v/emojify.js.svg?style=flat-square
[ico-license]: http://img.shields.io/npm/l/emojify.js.svg?style=flat-square
[ico-gitter]: https://badges.gitter.im/hassankhan/emojify.js.png
[ico-gitter]: https://badges.gitter.im/hassankhan/emojify.js.svg
[license]: http://hassankhan.mit-license.org/
[gitter]: https://gitter.im/hassankhan/emojify.js
36 changes: 36 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Test against these versions of Node.js.
environment:
matrix:
- nodejs_version: "0.10"
- nodejs_version: "0.11"

# Allow failing jobs for bleeding-edge Node.js versions.
matrix:
allow_failures:
- nodejs_version: "0.11"

platform:
- x86
- x64

# Install scripts. (runs after repo cloning)
install:
# Get the latest stable version of Node 0.STABLE.latest
- ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version)
# Typical npm stuff.
- npm install
- npm install -g phantomjs

# Post-install test scripts.
test_script:
# Output useful info for debugging.
- phantomjs --version
- node --version
- npm --version
- cmd: npm test

# Don't actually build.
build: off

# Set build version format here instead of in the admin panel.
version: "{build}"
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "emojify.js",
"main": "emojify.js",
"version": "0.9.5",
"main": "dist/js/emojify.js",
"version": "1.0.0",
"homepage": "https://github.com/hassankhan/emojify.js",
"authors": [
"Hassan Khan (hassankhan)"
Expand Down
24 changes: 24 additions & 0 deletions build/sprites.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{#sprite}}
{{class}} {
background-image: url('{{{escaped_image}}}');
display: inline-block;
}

{{/sprite}}
{{#retina}}
@media (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (-webkit-min-device-pixel-ratio: 1.5), (min-device-pixel-ratio: 1.5), (min-resolution: 1.5dppx) {
{{class}} {
background-image: url('{{{escaped_image}}}');
background-size: {{px.total_width}} {{px.total_height}};
}
}

{{/retina}}
{{#items}}
{{class}} {
background-position: {{px.offset_x}} {{px.offset_y}};
width: {{px.width}};
height: {{px.height}};
}

{{/items}}
6 changes: 6 additions & 0 deletions dist/css/basic/emojify.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.emoji {
width: 1.5em;
height: 1.5em;
display: inline-block;
margin-bottom: -0.25em;
}
Loading

0 comments on commit 102d189

Please sign in to comment.