diff --git a/assets/mastodon.png b/assets/mastodon.png new file mode 100644 index 0000000..ffaff4d Binary files /dev/null and b/assets/mastodon.png differ diff --git a/assets/mastodon.svg b/assets/mastodon.svg new file mode 100644 index 0000000..14525ed --- /dev/null +++ b/assets/mastodon.svg @@ -0,0 +1,61 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/assets/styles.css b/assets/styles.css index 4fcdc22..e57e8c2 100644 --- a/assets/styles.css +++ b/assets/styles.css @@ -190,3 +190,44 @@ form aside { font-style: italic; font-size: 0.8em; } + +a.btn { + color: white; + text-decoration: none; + background-color: #555; + border-radius: .3em; + overflow: hidden; + height: 2em; + + display: inline-block; +} + +a.btn:hover { + opacity: 0.9; +} + +.btn > * { + display: inline-block; + vertical-align: middle; +} + +.btn-header { + flex: 0 0; + width: 2em; + height: 2em; + padding-left: 0.1em; + background-image: linear-gradient(0deg, + rgba(255,255,255,0), + rgba(255,255,255,0.2) + ); + text-align: center; +} + +.btn-header img { + margin-top: 0.4em; + height: 1.1em; +} + +.btn-content { + margin: 0 .5em 0 .1em; +} diff --git a/assets/twitter.png b/assets/twitter.png new file mode 100644 index 0000000..1cfb0d6 Binary files /dev/null and b/assets/twitter.png differ diff --git a/assets/twitter.svg b/assets/twitter.svg new file mode 100644 index 0000000..644d15b --- /dev/null +++ b/assets/twitter.svg @@ -0,0 +1,63 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/dodo.py b/dodo.py index 5434382..937a937 100644 --- a/dodo.py +++ b/dodo.py @@ -35,7 +35,7 @@ def task_gen_logo(): def task_copy_asset(): import shutil - assets = ('icon.png', 'logotype.png', 'settings.js') + assets = ('icon.png', 'logotype.png', 'settings.js', 'twitter.png', 'mastodon.png') for asset in assets: yield dict( name=asset, diff --git a/routes.py b/routes.py index 4d421b0..da3dc1f 100644 --- a/routes.py +++ b/routes.py @@ -60,7 +60,9 @@ def index(): settings_error = 'settings_error' in request.args ) else: + instances = MastodonInstance.query.filter(MastodonInstance.popularity > 1).order_by(db.desc(MastodonInstance.popularity)).limit(3) return render_template('index.html', + mastodon_instances = instances, twitter_login_error = 'twitter_login_error' in request.args) @app.route('/login/twitter') @@ -216,16 +218,18 @@ def api_viewer_timers(): ) @app.route('/login/mastodon', methods=('GET', 'POST')) -def mastodon_login_step1(): +def mastodon_login_step1(instance=None): instances = MastodonInstance.query.filter(MastodonInstance.popularity > 1).order_by(db.desc(MastodonInstance.popularity)).limit(16) - if request.method == 'GET': - return render_template('mastodon_login.html', instances=instances, generic_error = 'error' in request.args) + instance_url = request.args.get('instance_url', None) or request.form.get('instance_url', None) - if not 'instance_url' in request.form or not request.form['instance_url']: - return render_template('mastodon_login.html', instances=instances, address_error=True) + if not instance_url: + return render_template('mastodon_login.html', instances=instances, + address_error = request.method == 'POST', + generic_error = 'error' in request.args + ) - instance_url = request.form['instance_url'].split("@")[-1].lower() + instance_url = instance_url.split("@")[-1].lower() callback = url_for('mastodon_login_step2', instance=instance_url, _external=True) diff --git a/templates/index.html b/templates/index.html index 4d9e9e3..6061e08 100644 --- a/templates/index.html +++ b/templates/index.html @@ -27,8 +27,33 @@ {% endif %}

Sound good to you?

-

Log in with Twitter

-

Log in with Mastodon

+

+ + + + Log in with Twitter + +

+ +{% for instance in mastodon_instances %} + +

+ + + + Log in with {{instance.instance}} + +

+ +{% endfor %} + +

+ + + + Log in with another Mastodon instance + +

Policy