Skip to content
Permalink
Browse files

directory listings working (part 1)

  • Loading branch information...
fileformat committed Jul 24, 2017
1 parent d45ba59 commit 817d195640ceeb5344ec9625190d0dbfcbd96e3a
Showing with 36 additions and 35 deletions.
  1. +21 −17 bin/update-db.py
  2. +1 −1 bin/update-noto.py
  3. +12 −16 docs/_includes/navbar.html
  4. +1 −0 docs/normalize.json
  5. +1 −1 run.sh
@@ -4,6 +4,7 @@
#

import argparse
import collections
import datetime
import json
import os
@@ -72,11 +73,11 @@

def to_hex(i):
if i > 0xFFFF:
return "%X" % i
return "%x" % i
else:
return "%04X" % i
return "%04x" % i

emojis = dict()
emojis = collections.OrderedDict()


line_pattern = re.compile("([A-F0-9 ]+);([-a-z ]+)# ([^ ]+) (.*)$")
@@ -103,7 +104,7 @@ def to_hex(i):
continue

emoji = {}
emoji['codepoints'] = matcher.group(1).strip()
emoji['codepoints'] = matcher.group(1).strip().lower()
emoji['status'] = matcher.group(2).strip()
emoji['chars'] = matcher.group(3)
emoji['text'] = matcher.group(4).strip()
@@ -142,7 +143,7 @@ def to_hex(i):

str = matcher.group(1).strip()
if ".." not in str:
codepoints = [ str ]
codepoints = [ str.lower() ]
else:
codepoints = []
split = str.split("..")
@@ -176,23 +177,28 @@ def to_hex(i):
sys.stdout.write("INFO: complete %d emoji processed\n" % emoji_count)
sys.stdout.write("INFO: complete %d emoji added\n" % new_count)

#
# hack for missing 20e3
#
emojis['20e3'] = { "codepoints": "20e3", 'chars': chr(0x20e3), 'status': 'component-only', 'text': 'combining enclosing keycap' }

#
# link non-fully-qualified to their parents
#
count = 0
for key in emojis.keys():
if emojis[key]["status"] == "fully-qualified" and "_FE0F" in key:
unqualified = key.replace("_FE0F", "", 1)
if emojis[key]["status"] == "fully-qualified" and "_fe0f" in key:
unqualified = key.replace("_fe0f", "", 1)
if unqualified in emojis:
count = count + 1
#sys.stdout.write("DEBUG: %s -> %s (1)\n" % (unqualified, key))
emojis[unqualified]['fully-qualified'] = key
else:
sys.stdout.write("WARNING: no unqualified found for %s" % unqualifed)
sys.stdout.write("WARNING: no unqualified found for %s" % unqualified)

# multiple instance of FE0F, so need to map with missing only 2nd instance, or missing both instances
if "_FE0F" in unqualified:
unqualified = key.replace("_FE0F", "")
if "_fe0f" in unqualified:
unqualified = key.replace("_fe0f", "")
if unqualified in emojis:
count = count + 1
sys.stdout.write("DEBUG: %s -> %s (both)\n" % (unqualified, key))
@@ -224,23 +230,21 @@ def to_hex(i):
else:
sys.stdout.write("INFO: all non-fully-qualified emoji are mapped\n")

filename = "output.json"
filename = "data.json"
sys.stdout.write("INFO: saving to file '%s'\n" % filename)
f = open(os.path.join(args.output, filename), mode='w', encoding='utf-8')
f.write(json.dumps(emojis, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ': ')))
f.write(json.dumps(emojis, ensure_ascii=False, sort_keys=False, indent=4, separators=(',', ': ')))
f.close()
sys.stdout.write("INFO: save complete: %d emoji\n" % len(emojis))

normalize = {}
for key in emojis.keys():
if emojis[key]["status"] == "non-fully-qualified":
normalize[key.lower()] = emojis[key]['fully-qualified'].lower()
normalize[key] = emojis[key]['fully-qualified']
elif emojis[key]["status"] == "component-only":
normalize[key.lower()] = key.lower()
normalize[key] = key
else:
normalize[key.lower()] = key.lower()

normalize["20e3"] = "20e3"
normalize[key] = key

filename = "normalize.json"
sys.stdout.write("INFO: saving to file '%s'\n" % filename)
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
# generate strings.xml files for Android from translations.json
# copy noto images from github
#

import argparse
@@ -1,18 +1,14 @@
<nav class="navbar navbar-toggleable-md navbar-inverse bg-inverse mb-4 hidden-print">
<div class="container">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="https://www.fileformat.info/info/emoji/">FileFormat.Info</a>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav mr-auto float-right">
<li class="nav-item active"><a class="nav-link" href="/index.html">Emoji <span class="sr-only">(current)</span></a></li>
<!-- <li class="nav-item"><a class="nav-link" href="/robots.txt">Someplace else</a></li>-->
</ul>
<!-- <form class="form-inline mt-2 mt-md-0">
<input class="form-control mr-sm-2" type="text" placeholder="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>-->
</div>
</div>
<div class="container">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="https://www.fileformat.info/info/emoji/">FileFormat.Info</a>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav mr-auto float-right">
<li class="nav-item{% if page.url == '/' %} active{% endif %}"><a class="nav-link" href="/index.html">Emoji{% if page.url == '/' %} <span class="sr-only">(current)</span>{% endif %}</a></li>
<li class="nav-item{% if page.url == '/noto/' %} active{% endif %}"><a class="nav-link" href="/noto/index.html">Noto{% if page.url == '/noto/' %} <span class="sr-only">(current)</span>{% endif %}</a></li>
</ul>
</div>
</div>
</nav>
@@ -3095,6 +3095,7 @@
"203c_fe0f": "203c_fe0f",
"2049": "2049_fe0f",
"2049_fe0f": "2049_fe0f",
"20e3": "20e3",
"2122": "2122_fe0f",
"2122_fe0f": "2122_fe0f",
"2139": "2139_fe0f",
2 run.sh
@@ -2,4 +2,4 @@
#
# script to run on localhost
#
jekyll serve --watch --source doc
jekyll serve --watch --source docs

0 comments on commit 817d195

Please sign in to comment.
You can’t perform that action at this time.