commit
cbb3e6ea41
|
@ -1,2 +1,5 @@
|
||||||
__pycache__
|
__pycache__
|
||||||
*.swp
|
*.swp
|
||||||
|
venv
|
||||||
|
.vscode
|
||||||
|
.idea
|
||||||
|
|
30
emojos.py
30
emojos.py
|
@ -25,13 +25,23 @@ app = Flask(__name__)
|
||||||
|
|
||||||
@app.route('/<domain>')
|
@app.route('/<domain>')
|
||||||
def emojo(domain):
|
def emojo(domain):
|
||||||
|
if request.args.get('show_all', '') == 'on':
|
||||||
|
show_all = True
|
||||||
|
else:
|
||||||
|
show_all = False
|
||||||
|
if request.args.get('show_animated', '') == 'on':
|
||||||
|
show_animated = True
|
||||||
|
else:
|
||||||
|
show_animated = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
url = urllib.parse.urlunsplit(
|
url = urllib.parse.urlunsplit(('https', domain, '/api/v1/custom_emojis', '', ''))
|
||||||
('https', domain, '/api/v1/custom_emojis', '', ''))
|
if show_all:
|
||||||
emojo = sorted(filter(lambda x: x.get('visible_in_picker', True),
|
emojo = sorted(requests.get(url).json(), key=operator.itemgetter('shortcode'))
|
||||||
requests.get(url).json()),
|
else:
|
||||||
key=operator.itemgetter('shortcode'))
|
emojo = sorted(filter(lambda x: x.get('visible_in_picker', True), requests.get(url).json()),
|
||||||
return render_template('emojo.html', domain=domain, emojo=emojo)
|
key=operator.itemgetter('shortcode'))
|
||||||
|
return render_template('emojo.html', domain=domain, emojo=emojo, show_animated=show_animated)
|
||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
return render_template('oh_no.html', domain=domain)
|
return render_template('oh_no.html', domain=domain)
|
||||||
|
|
||||||
|
@ -48,8 +58,7 @@ def code():
|
||||||
session = botocore.session.get_session()
|
session = botocore.session.get_session()
|
||||||
# region name is detected from lambda environment
|
# region name is detected from lambda environment
|
||||||
client = session.create_client('lambda')
|
client = session.create_client('lambda')
|
||||||
code = client.get_function(FunctionName=context.function_name,
|
code = client.get_function(FunctionName=context.function_name, Qualifier=context.function_version)
|
||||||
Qualifier=context.function_version)
|
|
||||||
return redirect(code['Code']['Location'], code=303)
|
return redirect(code['Code']['Location'], code=303)
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,7 +66,10 @@ def code():
|
||||||
def index():
|
def index():
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
if 'instance' in request.form:
|
if 'instance' in request.form:
|
||||||
return redirect(url_for('emojo', domain=request.form['instance']))
|
show_all = request.form.get('show_all')
|
||||||
|
show_animated = request.form.get('show_animated')
|
||||||
|
return redirect(
|
||||||
|
url_for('emojo', domain=request.form['instance'], show_all=show_all, show_animated=show_animated))
|
||||||
else:
|
else:
|
||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -6,12 +6,21 @@
|
||||||
click/touch to copy to clipboard
|
click/touch to copy to clipboard
|
||||||
</p>
|
</p>
|
||||||
<dl class="emojo">
|
<dl class="emojo">
|
||||||
{% for emoj in emojo %}
|
{% if show_animated %}
|
||||||
<div>
|
{% for emoj in emojo %}
|
||||||
<dt><img src="{{ emoj.static_url }}" alt=":{{ emoj.shortcode }}:"></dt>
|
<div>
|
||||||
<dd>:{{ emoj.shortcode }}:</dd>
|
<dt><img src="{{ emoj.url }}" alt=":{{ emoj.shortcode }}:"></dt>
|
||||||
</div>
|
<dd>:{{ emoj.shortcode }}:</dd>
|
||||||
{% endfor %}
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
{% for emoj in emojo %}
|
||||||
|
<div>
|
||||||
|
<dt><img src="{{ emoj.static_url }}" alt=":{{ emoj.shortcode }}:"></dt>
|
||||||
|
<dd>:{{ emoj.shortcode }}:</dd>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
</dl>
|
</dl>
|
||||||
{% endblock body %}
|
{% endblock body %}
|
||||||
{% block script %}
|
{% block script %}
|
||||||
|
|
|
@ -3,7 +3,17 @@
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<p>get the emojos for:</p>
|
<p>get the emojos for:</p>
|
||||||
<form method="POST" action="">
|
<form method="POST" action="">
|
||||||
<input type="text" name="instance" placeholder="instance.domain">
|
<div>
|
||||||
|
<input type="text" name="instance" placeholder="instance.domain">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<input type="checkbox" name="show_all">
|
||||||
|
<label for="show_all">See unlisted emojos</label>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<input type="checkbox" name="show_animated">
|
||||||
|
<label for="show_animated">See animated emojos</label>
|
||||||
|
</div>
|
||||||
<input type="submit" value="go">
|
<input type="submit" value="go">
|
||||||
</form>
|
</form>
|
||||||
<p>(“emojo” is the semi-jokey term for custom emoji on <a href="https://joinmastodon.org">Mastodon</a>.)</p>
|
<p>(“emojo” is the semi-jokey term for custom emoji on <a href="https://joinmastodon.org">Mastodon</a>.)</p>
|
||||||
|
|
Loading…
Reference in New Issue