feat: Added emoji display to domain list
All checks were successful
Build Docker / Build Image (push) Successful in 22s

This commit is contained in:
Nathan Woodburn 2024-02-20 10:57:12 +11:00
parent 5e21074b24
commit 171e891555
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
2 changed files with 16 additions and 4 deletions

View File

@ -168,4 +168,10 @@ def emoji_to_punycode(emoji):
try: try:
return emoji.encode("idna").decode("ascii") return emoji.encode("idna").decode("ascii")
except Exception as e: except Exception as e:
return "" return emoji
def punycode_to_emoji(punycode):
try:
return punycode.encode("ascii").decode("idna")
except Exception as e:
return punycode

View File

@ -2,6 +2,7 @@ import datetime
import json import json
import urllib.parse import urllib.parse
from flask import render_template from flask import render_template
from domainLookup import punycode_to_emoji
def domains(domains, mobile=False): def domains(domains, mobile=False):
html = '' html = ''
@ -13,12 +14,17 @@ def domains(domains, mobile=False):
expires = "No expiration date" expires = "No expiration date"
paid = domain['value'] paid = domain['value']
paid = paid / 1000000 paid = paid / 1000000
# Handle punycodes
name = domain['name']
emoji = punycode_to_emoji(name)
if emoji != name:
name = f'{emoji} ({name})'
if not mobile: if not mobile:
html += f'<tr><td>{domain["name"]}</td><td>{expires} days</td><td>{paid} HNS</td><td><a href="/manage/{domain["name"]}">Manage</a></td></tr>' html += f'<tr><td>{name}</td><td>{expires} days</td><td>{paid} HNS</td><td><a href="/manage/{domain["name"]}">Manage</a></td></tr>'
else: else:
html += f'<tr><td><a href="/manage/{domain["name"]}">{domain["name"]}</a></td><td>{expires} days</td></tr>' html += f'<tr><td><a href="/manage/{domain["name"]}">{name}</a></td><td>{expires} days</td></tr>'
return html return html