Skip to content

Commit

Permalink
build_emoji: Generate emoji names and codepoints from emoji_map.
Browse files Browse the repository at this point in the history
Replaces the hardcoded list of emoji_names and unicode_emoji_names in
static/js/emoji.js with a list generated from emoji_map.json, both to get
the list out of version control and so we can start modifying it for our
autocomplete. This does not change the contents of emoji_names. It sorts and
removes duplicates from unicode_emoji_names (causes no change in behavior,
since unicode_emoji_names is only used as if it were a set).
  • Loading branch information
rishig authored and timabbott committed Jan 29, 2017
1 parent 762b847 commit 6b3abce
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@
"pm_list": false,
"unread_ui": false,
"user_events": false,
"Plotly": false
"Plotly": false,
"emoji_codes": false
},
"rules": {
"no-restricted-syntax": 1,
Expand Down
1 change: 1 addition & 0 deletions frontend_tests/node_tests/echo.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ set_global('page_params', {

add_dependencies({
marked: 'third/marked/lib/marked.js',
emoji_codes: 'generated/emoji/emoji_codes.js',
emoji: 'js/emoji.js',
people: 'js/people.js',
stream_data: 'js/stream_data.js',
Expand Down
1 change: 1 addition & 0 deletions frontend_tests/node_tests/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set_global('page_params', {realm_emoji: {
add_dependencies({
Handlebars: 'handlebars',
templates: 'js/templates',
emoji_codes: 'generated/emoji/emoji_codes.js',
emoji: 'js/emoji',
i18n: 'i18next',
});
Expand Down
10 changes: 3 additions & 7 deletions static/js/emoji.js

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions tools/setup/emoji/build_emoji
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,21 @@ TARGET_EMOJI_DUMP = os.path.join(ZULIP_PATH, 'static', 'generated', 'emoji')
EMOJI_CACHE_PATH = "/srv/zulip-emoji-cache"
EMOJI_SCRIPT_DIR_PATH = os.path.join(ZULIP_PATH, 'tools', 'setup', 'emoji')

EMOJI_CODES_FILE_TEMPLATE = """\
var emoji_codes = (function () {
var exports = {};
exports.names = %(names)s;
exports.codepoints = %(codepoints)s;
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = emoji_codes;
}
"""

# change directory
os.chdir(EMOJI_SCRIPT_DIR_PATH)

Expand Down Expand Up @@ -209,5 +224,13 @@ def dump_emojis(cache_path):
assets = "{}/static/assets/zulip-emoji/*".format(ZULIP_PATH)
run(['cp', '-RPp', assets, cache_emoji], shell=True)

EMOJI_CODES_PATH = os.path.join(cache_path, 'emoji_codes.js')
emoji_codes_file = open(EMOJI_CODES_PATH, 'w')
emoji_codes_file.write(EMOJI_CODES_FILE_TEMPLATE % {
'names': [str(name) for name in sorted(emoji_map.keys())],
'codepoints': sorted([str(code_point) for code_point in set(emoji_map.values())])
})
emoji_codes_file.close()

if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ZULIP_VERSION = "1.4.1+git"
PROVISION_VERSION = '4.3'
PROVISION_VERSION = '4.4'
1 change: 1 addition & 0 deletions zproject/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,7 @@ def get_secret(key):
'node_modules/winchan/winchan.js',
'third/handlebars/handlebars.runtime.js',
'third/marked/lib/marked.js',
'generated/emoji/emoji_codes.js',
'templates/compiled.js',
'js/feature_flags.js',
'js/loading.js',
Expand Down

0 comments on commit 6b3abce

Please sign in to comment.