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