From f4809d9d71ed28a699805419c7ba33674558c529 Mon Sep 17 00:00:00 2001 From: heartdev <88726114+lt3Dev@users.noreply.github.com> Date: Tue, 31 Aug 2021 07:32:08 +0000 Subject: [PATCH 1/9] display emojos by category --- app.py | 50 ++++++++++++++++++++++++++++++-------------- templates/emojo.html | 30 +++++++++++++------------- 2 files changed, 49 insertions(+), 31 deletions(-) diff --git a/app.py b/app.py index baa1e55..4a29e7e 100644 --- a/app.py +++ b/app.py @@ -19,10 +19,22 @@ import urllib.parse import botocore.session import requests import serverless_wsgi +from collections import defaultdict +from dataclasses import dataclass from flask import Flask, redirect, render_template, request, url_for app = Flask(__name__) +def slug_filter(s): + return s.lower().replace(" ", "-") + +app.jinja_env.filters["slug"] = slug_filter + +@dataclass +class Emoj: + __slots__ = frozenset({"shortcode", "url"}) + shortcode: str + url: str @app.route("/") def emojo(domain): @@ -35,27 +47,33 @@ def emojo(domain): else: show_animated = False + url = urllib.parse.urlunsplit( + ("https", domain, "/api/v1/custom_emojis", "", "") + ) try: - url = urllib.parse.urlunsplit( - ("https", domain, "/api/v1/custom_emojis", "", "") - ) response = requests.get(url) - if response.status_code == 401: - return render_template("forbidden.html", domain=domain) - - if show_all: - emojo = sorted(response.json(), key=operator.itemgetter("shortcode")) - else: - emojo = sorted( - filter(lambda x: x.get("visible_in_picker", True), response.json()), - key=operator.itemgetter("shortcode"), - ) - return render_template( - "emojo.html", domain=domain, emojo=emojo, show_animated=show_animated - ) except requests.exceptions.RequestException: return render_template("oh_no.html", domain=domain) + if response.status_code == 401: + return render_template("forbidden.html", domain=domain) + + categories = defaultdict(list) + for emoji in sorted( + response.json(), + # sort by category, then name within each category, then disambiguate by capitalization + key=lambda x: (x.get("category", ""), x["shortcode"].lower(), x["shortcode"]), + ): + if not show_all and not emoji.get("visible_in_picker", True): + continue + + url = emoji["url" if show_animated else "static_url"] + categories[emoji.get("category")].append(Emoj(shortcode=emoji["shortcode"], url=url)) + + return render_template( + "emojo.html", domain=domain, categories=categories, show_animated=show_animated + ) + @app.route("/favicon.ico") @app.route("/robots.txt") diff --git a/templates/emojo.html b/templates/emojo.html index 7f67f51..85f7c13 100644 --- a/templates/emojo.html +++ b/templates/emojo.html @@ -5,23 +5,23 @@ {{ domain }} emojo list
click/touch to copy to clipboard

-
- {% if show_animated %} +{% for category, emojo in categories.items() %} +

+ {% if not category %} + (No category) + {% else %} + {{ category }} + {% endif %} +

+
{% for emoj in emojo %} -
-
:{{ emoj.shortcode }}:
-
:{{ emoj.shortcode }}:
-
+
+
:{{ emoj.shortcode }}:
+
:{{ emoj.shortcode }}:
+
{% endfor %} - {% else %} - {% for emoj in emojo %} -
-
:{{ emoj.shortcode }}:
-
:{{ emoj.shortcode }}:
-
- {% endfor %} - {% endif %} -
+
+{% endfor %} {% endblock body %} {% block script %} From a713371a247678e72a3b101e872893f2843e43ef Mon Sep 17 00:00:00 2001 From: heartdev <88726114+lt3Dev@users.noreply.github.com> Date: Tue, 31 Aug 2021 07:37:58 +0000 Subject: [PATCH 2/9] lint massacre --- app.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app.py b/app.py index 4a29e7e..164e317 100644 --- a/app.py +++ b/app.py @@ -13,7 +13,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -import operator import urllib.parse import botocore.session @@ -25,17 +24,21 @@ from flask import Flask, redirect, render_template, request, url_for app = Flask(__name__) + def slug_filter(s): return s.lower().replace(" ", "-") + app.jinja_env.filters["slug"] = slug_filter + @dataclass class Emoj: __slots__ = frozenset({"shortcode", "url"}) shortcode: str url: str + @app.route("/") def emojo(domain): if request.args.get("show_all", "") == "on": @@ -47,9 +50,7 @@ def emojo(domain): else: show_animated = False - url = urllib.parse.urlunsplit( - ("https", domain, "/api/v1/custom_emojis", "", "") - ) + url = urllib.parse.urlunsplit(("https", domain, "/api/v1/custom_emojis", "", "")) try: response = requests.get(url) except requests.exceptions.RequestException: @@ -61,14 +62,18 @@ def emojo(domain): categories = defaultdict(list) for emoji in sorted( response.json(), - # sort by category, then name within each category, then disambiguate by capitalization + # sort by category, + # then name within each category, + # then disambiguate by capitalization key=lambda x: (x.get("category", ""), x["shortcode"].lower(), x["shortcode"]), ): if not show_all and not emoji.get("visible_in_picker", True): continue url = emoji["url" if show_animated else "static_url"] - categories[emoji.get("category")].append(Emoj(shortcode=emoji["shortcode"], url=url)) + categories[emoji.get("category")].append( + Emoj(shortcode=emoji["shortcode"], url=url) + ) return render_template( "emojo.html", domain=domain, categories=categories, show_animated=show_animated From 6930d0905652ee7e7da9aa0bf934f37738a307dd Mon Sep 17 00:00:00 2001 From: Kay Faraday Date: Sat, 11 Sep 2021 01:55:38 +0000 Subject: [PATCH 3/9] remove unneeded deps and update branding --- Pipfile | 18 --- Pipfile.lock | 321 -------------------------------------------- app.py | 17 --- requirements.txt | 2 + templates/base.html | 6 +- 5 files changed, 4 insertions(+), 360 deletions(-) delete mode 100644 Pipfile delete mode 100644 Pipfile.lock create mode 100644 requirements.txt diff --git a/Pipfile b/Pipfile deleted file mode 100644 index 37ec1e3..0000000 --- a/Pipfile +++ /dev/null @@ -1,18 +0,0 @@ -[[source]] -url = "https://pypi.python.org/simple" -verify_ssl = true -name = "pypi" - -[packages] -flask = "*" -requests = "*" -serverless-wsgi = "*" - -[dev-packages] -black = "==21.4b0" -botocore = "==1.19.31" -flake8 = "*" -isort = "*" - -[requires] -python_version = "3.8" diff --git a/Pipfile.lock b/Pipfile.lock deleted file mode 100644 index 25f57bb..0000000 --- a/Pipfile.lock +++ /dev/null @@ -1,321 +0,0 @@ -{ - "_meta": { - "hash": { - "sha256": "2dd6d041f0b30b05f1d6cbd0b1cbc66a34f9beaaf63207526fd9265926cb7284" - }, - "pipfile-spec": 6, - "requires": { - "python_version": "3.8" - }, - "sources": [ - { - "name": "pypi", - "url": "https://pypi.python.org/simple", - "verify_ssl": true - } - ] - }, - "default": { - "certifi": { - "hashes": [ - "sha256:1a4995114262bffbc2413b159f2a1a480c969de6e6eb13ee966d470af86af59c", - "sha256:719a74fb9e33b9bd44cc7f3a8d94bc35e4049deebe19ba7d8e108280cfd59830" - ], - "version": "==2020.12.5" - }, - "chardet": { - "hashes": [ - "sha256:0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa", - "sha256:f864054d66fd9118f2e67044ac8981a54775ec5b67aed0441892edb553d21da5" - ], - "version": "==4.0.0" - }, - "click": { - "hashes": [ - "sha256:d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a", - "sha256:dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc" - ], - "version": "==7.1.2" - }, - "flask": { - "hashes": [ - "sha256:4efa1ae2d7c9865af48986de8aeb8504bf32c7f3d6fdc9353d34b21f4b127060", - "sha256:8a4fdd8936eba2512e9c85df320a37e694c93945b33ef33c89946a340a238557" - ], - "index": "pypi", - "version": "==1.1.2" - }, - "idna": { - "hashes": [ - "sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6", - "sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0" - ], - "version": "==2.10" - }, - "itsdangerous": { - "hashes": [ - "sha256:321b033d07f2a4136d3ec762eac9f16a10ccd60f53c0c91af90217ace7ba1f19", - "sha256:b12271b2047cb23eeb98c8b5622e2e5c5e9abd9784a153e9d8ef9cb4dd09d749" - ], - "version": "==1.1.0" - }, - "jinja2": { - "hashes": [ - "sha256:03e47ad063331dd6a3f04a43eddca8a966a26ba0c5b7207a9a9e4e08f1b29419", - "sha256:a6d58433de0ae800347cab1fa3043cebbabe8baa9d29e668f1c768cb87a333c6" - ], - "version": "==2.11.3" - }, - "markupsafe": { - "hashes": [ - "sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473", - "sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161", - "sha256:09c4b7f37d6c648cb13f9230d847adf22f8171b1ccc4d5682398e77f40309235", - "sha256:1027c282dad077d0bae18be6794e6b6b8c91d58ed8a8d89a89d59693b9131db5", - "sha256:13d3144e1e340870b25e7b10b98d779608c02016d5184cfb9927a9f10c689f42", - "sha256:195d7d2c4fbb0ee8139a6cf67194f3973a6b3042d742ebe0a9ed36d8b6f0c07f", - "sha256:22c178a091fc6630d0d045bdb5992d2dfe14e3259760e713c490da5323866c39", - "sha256:24982cc2533820871eba85ba648cd53d8623687ff11cbb805be4ff7b4c971aff", - "sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b", - "sha256:2beec1e0de6924ea551859edb9e7679da6e4870d32cb766240ce17e0a0ba2014", - "sha256:3b8a6499709d29c2e2399569d96719a1b21dcd94410a586a18526b143ec8470f", - "sha256:43a55c2930bbc139570ac2452adf3d70cdbb3cfe5912c71cdce1c2c6bbd9c5d1", - "sha256:46c99d2de99945ec5cb54f23c8cd5689f6d7177305ebff350a58ce5f8de1669e", - "sha256:500d4957e52ddc3351cabf489e79c91c17f6e0899158447047588650b5e69183", - "sha256:535f6fc4d397c1563d08b88e485c3496cf5784e927af890fb3c3aac7f933ec66", - "sha256:596510de112c685489095da617b5bcbbac7dd6384aeebeda4df6025d0256a81b", - "sha256:62fe6c95e3ec8a7fad637b7f3d372c15ec1caa01ab47926cfdf7a75b40e0eac1", - "sha256:6788b695d50a51edb699cb55e35487e430fa21f1ed838122d722e0ff0ac5ba15", - "sha256:6dd73240d2af64df90aa7c4e7481e23825ea70af4b4922f8ede5b9e35f78a3b1", - "sha256:6f1e273a344928347c1290119b493a1f0303c52f5a5eae5f16d74f48c15d4a85", - "sha256:6fffc775d90dcc9aed1b89219549b329a9250d918fd0b8fa8d93d154918422e1", - "sha256:717ba8fe3ae9cc0006d7c451f0bb265ee07739daf76355d06366154ee68d221e", - "sha256:79855e1c5b8da654cf486b830bd42c06e8780cea587384cf6545b7d9ac013a0b", - "sha256:7c1699dfe0cf8ff607dbdcc1e9b9af1755371f92a68f706051cc8c37d447c905", - "sha256:7fed13866cf14bba33e7176717346713881f56d9d2bcebab207f7a036f41b850", - "sha256:84dee80c15f1b560d55bcfe6d47b27d070b4681c699c572af2e3c7cc90a3b8e0", - "sha256:88e5fcfb52ee7b911e8bb6d6aa2fd21fbecc674eadd44118a9cc3863f938e735", - "sha256:8defac2f2ccd6805ebf65f5eeb132adcf2ab57aa11fdf4c0dd5169a004710e7d", - "sha256:98bae9582248d6cf62321dcb52aaf5d9adf0bad3b40582925ef7c7f0ed85fceb", - "sha256:98c7086708b163d425c67c7a91bad6e466bb99d797aa64f965e9d25c12111a5e", - "sha256:9add70b36c5666a2ed02b43b335fe19002ee5235efd4b8a89bfcf9005bebac0d", - "sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c", - "sha256:a6a744282b7718a2a62d2ed9d993cad6f5f585605ad352c11de459f4108df0a1", - "sha256:acf08ac40292838b3cbbb06cfe9b2cb9ec78fce8baca31ddb87aaac2e2dc3bc2", - "sha256:ade5e387d2ad0d7ebf59146cc00c8044acbd863725f887353a10df825fc8ae21", - "sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2", - "sha256:b1282f8c00509d99fef04d8ba936b156d419be841854fe901d8ae224c59f0be5", - "sha256:b1dba4527182c95a0db8b6060cc98ac49b9e2f5e64320e2b56e47cb2831978c7", - "sha256:b2051432115498d3562c084a49bba65d97cf251f5a331c64a12ee7e04dacc51b", - "sha256:b7d644ddb4dbd407d31ffb699f1d140bc35478da613b441c582aeb7c43838dd8", - "sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6", - "sha256:bf5aa3cbcfdf57fa2ee9cd1822c862ef23037f5c832ad09cfea57fa846dec193", - "sha256:c8716a48d94b06bb3b2524c2b77e055fb313aeb4ea620c8dd03a105574ba704f", - "sha256:caabedc8323f1e93231b52fc32bdcde6db817623d33e100708d9a68e1f53b26b", - "sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f", - "sha256:cdb132fc825c38e1aeec2c8aa9338310d29d337bebbd7baa06889d09a60a1fa2", - "sha256:d53bc011414228441014aa71dbec320c66468c1030aae3a6e29778a3382d96e5", - "sha256:d73a845f227b0bfe8a7455ee623525ee656a9e2e749e4742706d80a6065d5e2c", - "sha256:d9be0ba6c527163cbed5e0857c451fcd092ce83947944d6c14bc95441203f032", - "sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7", - "sha256:e8313f01ba26fbbe36c7be1966a7b7424942f670f38e666995b88d012765b9be", - "sha256:feb7b34d6325451ef96bc0e36e1a6c0c1c64bc1fbec4b854f4529e51887b1621" - ], - "version": "==1.1.1" - }, - "requests": { - "hashes": [ - "sha256:27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804", - "sha256:c210084e36a42ae6b9219e00e48287def368a26d03a048ddad7bfee44f75871e" - ], - "index": "pypi", - "version": "==2.25.1" - }, - "serverless-wsgi": { - "hashes": [ - "sha256:0e58e517210130fcc5121954254ce040a82fec07927a342efd3823b95333d0ce", - "sha256:cdf1c84350724441910464cc05adf672760e3670c3fcbda50b4975344d8dd456" - ], - "index": "pypi", - "version": "==1.7.7" - }, - "urllib3": { - "hashes": [ - "sha256:2f4da4594db7e1e110a944bb1b551fdf4e6c136ad42e4234131391e21eb5b0df", - "sha256:e7b021f7241115872f92f43c6508082facffbd1c048e3c6e2bb9c2a157e28937" - ], - "version": "==1.26.4" - }, - "werkzeug": { - "hashes": [ - "sha256:2de2a5db0baeae7b2d2664949077c2ac63fbd16d98da0ff71837f7d1dea3fd43", - "sha256:6c80b1e5ad3665290ea39320b91e1be1e0d5f60652b964a3070216de83d2e47c" - ], - "version": "==1.0.1" - } - }, - "develop": { - "appdirs": { - "hashes": [ - "sha256:7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41", - "sha256:a841dacd6b99318a741b166adb07e19ee71a274450e68237b4650ca1055ab128" - ], - "version": "==1.4.4" - }, - "black": { - "hashes": [ - "sha256:2db7040bbbbaa46247bfcc05c6efdebd7ebe50c1c3ca745ca6e0f6776438c96c", - "sha256:915d916c48646dbe8040d5265cff7111421a60a3dfe7f7e07273176a57c24a34" - ], - "index": "pypi", - "version": "==21.4b0" - }, - "botocore": { - "hashes": [ - "sha256:1e5712d53ecdefb0279dc45abef32bd9499f92800ddd89038a8dddb99423f940", - "sha256:624e1d4ce704494f73440c416624481d4ff283049b17d12e06890b79f2ac177d" - ], - "index": "pypi", - "version": "==1.19.31" - }, - "click": { - "hashes": [ - "sha256:d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a", - "sha256:dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc" - ], - "version": "==7.1.2" - }, - "flake8": { - "hashes": [ - "sha256:1aa8990be1e689d96c745c5682b687ea49f2e05a443aff1f8251092b0014e378", - "sha256:3b9f848952dddccf635be78098ca75010f073bfe14d2c6bda867154bea728d2a" - ], - "index": "pypi", - "version": "==3.9.1" - }, - "isort": { - "hashes": [ - "sha256:0a943902919f65c5684ac4e0154b1ad4fac6dcaa5d9f3426b732f1c8b5419be6", - "sha256:2bb1680aad211e3c9944dbce1d4ba09a989f04e238296c87fe2139faa26d655d" - ], - "index": "pypi", - "version": "==5.8.0" - }, - "jmespath": { - "hashes": [ - "sha256:b85d0567b8666149a93172712e68920734333c0ce7e89b78b3e987f71e5ed4f9", - "sha256:cdf6525904cc597730141d61b36f2e4b8ecc257c420fa2f4549bac2c2d0cb72f" - ], - "version": "==0.10.0" - }, - "mccabe": { - "hashes": [ - "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42", - "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f" - ], - "version": "==0.6.1" - }, - "mypy-extensions": { - "hashes": [ - "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d", - "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8" - ], - "version": "==0.4.3" - }, - "pathspec": { - "hashes": [ - "sha256:86379d6b86d75816baba717e64b1a3a3469deb93bb76d613c9ce79edc5cb68fd", - "sha256:aa0cb481c4041bf52ffa7b0d8fa6cd3e88a2ca4879c533c9153882ee2556790d" - ], - "version": "==0.8.1" - }, - "pycodestyle": { - "hashes": [ - "sha256:514f76d918fcc0b55c6680472f0a37970994e07bbb80725808c17089be302068", - "sha256:c389c1d06bf7904078ca03399a4816f974a1d590090fecea0c63ec26ebaf1cef" - ], - "version": "==2.7.0" - }, - "pyflakes": { - "hashes": [ - "sha256:7893783d01b8a89811dd72d7dfd4d84ff098e5eed95cfa8905b22bbffe52efc3", - "sha256:f5bc8ecabc05bb9d291eb5203d6810b49040f6ff446a756326104746cc00c1db" - ], - "version": "==2.3.1" - }, - "python-dateutil": { - "hashes": [ - "sha256:73ebfe9dbf22e832286dafa60473e4cd239f8592f699aa5adaf10050e6e1823c", - "sha256:75bb3f31ea686f1197762692a9ee6a7550b59fc6ca3a1f4b5d7e32fb98e2da2a" - ], - "version": "==2.8.1" - }, - "regex": { - "hashes": [ - "sha256:01afaf2ec48e196ba91b37451aa353cb7eda77efe518e481707e0515025f0cd5", - "sha256:11d773d75fa650cd36f68d7ca936e3c7afaae41b863b8c387a22aaa78d3c5c79", - "sha256:18c071c3eb09c30a264879f0d310d37fe5d3a3111662438889ae2eb6fc570c31", - "sha256:1e1c20e29358165242928c2de1482fb2cf4ea54a6a6dea2bd7a0e0d8ee321500", - "sha256:281d2fd05555079448537fe108d79eb031b403dac622621c78944c235f3fcf11", - "sha256:314d66636c494ed9c148a42731b3834496cc9a2c4251b1661e40936814542b14", - "sha256:32e65442138b7b76dd8173ffa2cf67356b7bc1768851dded39a7a13bf9223da3", - "sha256:339456e7d8c06dd36a22e451d58ef72cef293112b559010db3d054d5560ef439", - "sha256:3916d08be28a1149fb97f7728fca1f7c15d309a9f9682d89d79db75d5e52091c", - "sha256:3a9cd17e6e5c7eb328517969e0cb0c3d31fd329298dd0c04af99ebf42e904f82", - "sha256:47bf5bf60cf04d72bf6055ae5927a0bd9016096bf3d742fa50d9bf9f45aa0711", - "sha256:4c46e22a0933dd783467cf32b3516299fb98cfebd895817d685130cc50cd1093", - "sha256:4c557a7b470908b1712fe27fb1ef20772b78079808c87d20a90d051660b1d69a", - "sha256:52ba3d3f9b942c49d7e4bc105bb28551c44065f139a65062ab7912bef10c9afb", - "sha256:563085e55b0d4fb8f746f6a335893bda5c2cef43b2f0258fe1020ab1dd874df8", - "sha256:598585c9f0af8374c28edd609eb291b5726d7cbce16be6a8b95aa074d252ee17", - "sha256:619d71c59a78b84d7f18891fe914446d07edd48dc8328c8e149cbe0929b4e000", - "sha256:67bdb9702427ceddc6ef3dc382455e90f785af4c13d495f9626861763ee13f9d", - "sha256:6d1b01031dedf2503631d0903cb563743f397ccaf6607a5e3b19a3d76fc10480", - "sha256:741a9647fcf2e45f3a1cf0e24f5e17febf3efe8d4ba1281dcc3aa0459ef424dc", - "sha256:7c2a1af393fcc09e898beba5dd59196edaa3116191cc7257f9224beaed3e1aa0", - "sha256:7d9884d86dd4dd489e981d94a65cd30d6f07203d90e98f6f657f05170f6324c9", - "sha256:90f11ff637fe8798933fb29f5ae1148c978cccb0452005bf4c69e13db951e765", - "sha256:919859aa909429fb5aa9cf8807f6045592c85ef56fdd30a9a3747e513db2536e", - "sha256:96fcd1888ab4d03adfc9303a7b3c0bd78c5412b2bfbe76db5b56d9eae004907a", - "sha256:97f29f57d5b84e73fbaf99ab3e26134e6687348e95ef6b48cfd2c06807005a07", - "sha256:980d7be47c84979d9136328d882f67ec5e50008681d94ecc8afa8a65ed1f4a6f", - "sha256:a91aa8619b23b79bcbeb37abe286f2f408d2f2d6f29a17237afda55bb54e7aac", - "sha256:ade17eb5d643b7fead300a1641e9f45401c98eee23763e9ed66a43f92f20b4a7", - "sha256:b9c3db21af35e3b3c05764461b262d6f05bbca08a71a7849fd79d47ba7bc33ed", - "sha256:bd28bc2e3a772acbb07787c6308e00d9626ff89e3bfcdebe87fa5afbfdedf968", - "sha256:bf5824bfac591ddb2c1f0a5f4ab72da28994548c708d2191e3b87dd207eb3ad7", - "sha256:c0502c0fadef0d23b128605d69b58edb2c681c25d44574fc673b0e52dce71ee2", - "sha256:c38c71df845e2aabb7fb0b920d11a1b5ac8526005e533a8920aea97efb8ec6a4", - "sha256:ce15b6d103daff8e9fee13cf7f0add05245a05d866e73926c358e871221eae87", - "sha256:d3029c340cfbb3ac0a71798100ccc13b97dddf373a4ae56b6a72cf70dfd53bc8", - "sha256:e512d8ef5ad7b898cdb2d8ee1cb09a8339e4f8be706d27eaa180c2f177248a10", - "sha256:e8e5b509d5c2ff12f8418006d5a90e9436766133b564db0abaec92fd27fcee29", - "sha256:ee54ff27bf0afaf4c3b3a62bcd016c12c3fdb4ec4f413391a90bd38bc3624605", - "sha256:fa4537fb4a98fe8fde99626e4681cc644bdcf2a795038533f9f711513a862ae6", - "sha256:fd45ff9293d9274c5008a2054ecef86a9bfe819a67c7be1afb65e69b405b3042" - ], - "version": "==2021.4.4" - }, - "six": { - "hashes": [ - "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259", - "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced" - ], - "version": "==1.15.0" - }, - "toml": { - "hashes": [ - "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b", - "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f" - ], - "version": "==0.10.2" - }, - "urllib3": { - "hashes": [ - "sha256:2f4da4594db7e1e110a944bb1b551fdf4e6c136ad42e4234131391e21eb5b0df", - "sha256:e7b021f7241115872f92f43c6508082facffbd1c048e3c6e2bb9c2a157e28937" - ], - "version": "==1.26.4" - } - } -} diff --git a/app.py b/app.py index 164e317..2612777 100644 --- a/app.py +++ b/app.py @@ -17,7 +17,6 @@ import urllib.parse import botocore.session import requests -import serverless_wsgi from collections import defaultdict from dataclasses import dataclass from flask import Flask, redirect, render_template, request, url_for @@ -86,18 +85,6 @@ def no_content(): return ("", 204) -@app.route("/code") -def code(): - context = request.environ.get("context") - session = botocore.session.get_session() - # region name is detected from lambda environment - client = session.create_client("lambda") - code = client.get_function( - FunctionName=context.function_name, Qualifier=context.function_version - ) - return redirect(code["Code"]["Location"], code=303) - - @app.route("/", methods=("GET", "POST")) def index(): if request.method == "POST": @@ -116,7 +103,3 @@ def index(): return redirect(url_for("index")) else: return render_template("index.html") - - -def handle_request(event, context): - return serverless_wsgi.handle_request(app, event, context) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..30692b7 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +flask +requests diff --git a/templates/base.html b/templates/base.html index 1b1fac8..bc0a3c6 100644 --- a/templates/base.html +++ b/templates/base.html @@ -10,13 +10,11 @@ {% endblock body %} {% block script %} From 418ab4fd8def8571d3e4d105e41c89de8f1ba397 Mon Sep 17 00:00:00 2001 From: Kay Faraday Date: Sat, 11 Sep 2021 01:56:09 +0000 Subject: [PATCH 4/9] support onions --- app.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 2612777..8972ca7 100644 --- a/app.py +++ b/app.py @@ -49,7 +49,8 @@ def emojo(domain): else: show_animated = False - url = urllib.parse.urlunsplit(("https", domain, "/api/v1/custom_emojis", "", "")) + scheme = "http" if domain.endswith(".onion") else "https" + url = urllib.parse.urlunsplit((scheme, domain, "/api/v1/custom_emojis", "", "")) try: response = requests.get(url) except requests.exceptions.RequestException: From 9feac466421e4d0333e45beb0afca686d6ad07d6 Mon Sep 17 00:00:00 2001 From: Kay Faraday Date: Sat, 11 Sep 2021 02:03:20 +0000 Subject: [PATCH 5/9] remove unused import --- app.py | 1 - 1 file changed, 1 deletion(-) diff --git a/app.py b/app.py index 8972ca7..2573c59 100644 --- a/app.py +++ b/app.py @@ -15,7 +15,6 @@ import urllib.parse -import botocore.session import requests from collections import defaultdict from dataclasses import dataclass From 3d7b8b743d1f45ae2b9d093fa5f010d72858dbb7 Mon Sep 17 00:00:00 2001 From: Kay Faraday Date: Fri, 10 Dec 2021 00:44:50 +0000 Subject: [PATCH 6/9] Update source code link --- templates/base.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/base.html b/templates/base.html index bc0a3c6..8e2ab49 100644 --- a/templates/base.html +++ b/templates/base.html @@ -14,7 +14,7 @@ · AGPLv3 · - source code + source code

{% block script %} From 34ec199edb622371721517a2b64f36a1420f9f51 Mon Sep 17 00:00:00 2001 From: Kay Faraday Date: Fri, 10 Dec 2021 00:51:54 +0000 Subject: [PATCH 7/9] only display click to copy instructions if click to copy is enabled --- static/copy.js | 3 +++ templates/emojo.html | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/static/copy.js b/static/copy.js index dc76f7e..c417efa 100644 --- a/static/copy.js +++ b/static/copy.js @@ -28,4 +28,7 @@ Array.from(document.querySelectorAll('dl.emojo div')).forEach((element) => { element.addEventListener('click', copyEmojo); }); + + // only display the instructions if JS is enabled + document.getElementById('copy-instructions').innerText = 'click/touch to copy to clipboard'; }()); diff --git a/templates/emojo.html b/templates/emojo.html index 85f7c13..3b3b620 100644 --- a/templates/emojo.html +++ b/templates/emojo.html @@ -3,7 +3,7 @@ {% block body %}

{{ domain }} emojo list
- click/touch to copy to clipboard +

{% for category, emojo in categories.items() %}

From a9417e99ae2db5d53acabcd08e59a6e56897c79e Mon Sep 17 00:00:00 2001 From: Kay Faraday Date: Sat, 25 Dec 2021 22:01:12 +0000 Subject: [PATCH 8/9] add gitignore and readme --- .gitignore | 1 + README.md | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 .gitignore create mode 100644 README.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c18dd8d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +__pycache__/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..634cd84 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# Emojos (Freak U edition) + +This is an online tool that lets you view all emojis for a Mastodon (or Pleroma) instance. +Additionally, it supports viewing emojis by category and viewing emojis for an .onion instance. + +It's currently deployed at [emojos.freak.university](https://emojos.freak.university). From 25f0d1d130304136b3c0c4a6b5bec065e9ab5a17 Mon Sep 17 00:00:00 2001 From: Kay Faraday Date: Sat, 25 Dec 2021 22:02:38 +0000 Subject: [PATCH 9/9] update source code URL --- templates/base.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/base.html b/templates/base.html index 8e2ab49..f8a3c6e 100644 --- a/templates/base.html +++ b/templates/base.html @@ -14,7 +14,7 @@ · AGPLv3 · - source code + source code

{% block script %}