diff --git a/routes.py b/routes.py index 10ef841..c4dba18 100644 --- a/routes.py +++ b/routes.py @@ -25,8 +25,7 @@ def touch_viewer(resp): @app.route('/') def index(): if g.viewer: - posts = Post.query.filter_by(author_id = g.viewer.account_id).order_by(db.desc(Post.created_at)).limit(30) - return render_template('index.html', posts=posts) + return render_template('logged_in.html', scales=lib.interval_scales) else: return render_template('index.html') @@ -66,27 +65,46 @@ def upload_tweet_archive(): tasks.import_twitter_archive.s(ta.id).apply_async(routing_key='high') - return render_template('upload_tweet_archive.html') + return redirect(url_for('index')) -@app.route('/settings', methods=('GET', 'POST')) +@app.route('/settings', methods=('POST',)) @require_auth def settings(): - if request.method == 'POST': - for attr in ('policy_enabled', - 'policy_keep_favourites', - 'policy_keep_latest', - 'policy_delete_every_significand', - 'policy_delete_every_scale', - 'policy_keep_younger_significand', - 'policy_keep_younger_scale', - ): - if attr in request.form: - setattr(g.viewer.account, attr, request.form[attr]) + for attr in ( + 'policy_keep_favourites', + 'policy_keep_latest', + 'policy_delete_every_significand', + 'policy_delete_every_scale', + 'policy_keep_younger_significand', + 'policy_keep_younger_scale', + ): + if attr in request.form: + setattr(g.viewer.account, attr, request.form[attr]) - db.session.commit() + db.session.commit() - return render_template('settings.html', scales=lib.interval_scales) + return redirect(url_for('index', settings_saved='')) +@app.route('/disable', methods=('POST',)) +@require_auth +def disable(): + g.viewer.account.policy_enabled = False + db.session.commit() + + return redirect(url_for('index')) + +@app.route('/enable', methods=('POST',)) +@require_auth +def enable(): + + # TODO require confirmation when risky + # i.e. about to instantly delete a lot of posts, + # or when enabling for the first time (last_delete is >1 year in the past) + + g.viewer.account.policy_enabled = True + db.session.commit() + + return redirect(url_for('index')) @app.route('/logout') diff --git a/static/logotype.png b/static/logotype.png new file mode 100644 index 0000000..3671bf3 Binary files /dev/null and b/static/logotype.png differ diff --git a/static/style.css b/static/style.css new file mode 100644 index 0000000..b3bbd7a --- /dev/null +++ b/static/style.css @@ -0,0 +1,103 @@ +body { + margin: 0; + font-family: sans-serif; +} + +*, *::before, *::after { + box-sizing: border-box; +} + +body > section, body > header { + max-width: 45rem; + margin-left: auto; + margin-right: auto; + padding-left: 3rem; + padding-right: 3rem; + margin-bottom: 3rem; +} + +section > * { + padding-left: 5rem; + padding-right: 5rem; +} + +section > ul { + padding-left: 7rem; +} + +h2 { + font-size: 1.4em; + font-weight: normal; + padding-left: 2rem; +} + +h3 { + font-size: inherit; + font-weight: bold; + padding-left: 5rem; +} + +header { + text-align: center; +} + +header h1 { + margin-top: 0; + text-indent:-1000vw; + background: url('/static/logotype.png') no-repeat 2rem bottom, white; + background-size: contain; + padding: 2em; +} + +input[type=number]{ + max-width: 8ch; +} + +.viewer img.avatar { + height: 1.5em; + width: 1.5em; + background-color: #ccc; + border-radius:100%; + transform:translateY(25%); +} + +.banner { + border-left-width: .7rem; + border-left-style: solid; + padding-top: .6rem; + padding-bottom: .6rem; + margin-bottom: 1rem; +} + +body > section > .banner { + padding-left: 4.3rem; +} + +.banner.enabled { + border-left-color: transparent; + background: #bbfbff; +} + +.banner.disabled { + border-left-color: transparent; + background: #eee; +} + +.banner.success { + background: #dec; + border-left-color: #4a2; +} + +.banner.error { + border-color: #a24; + background: #ecd; +} + +.banner.warning { + border-color: #dc4; + background: #eec; +} + +.banner form { + display: inline; +} diff --git a/templates/index.html b/templates/index.html index 0df2142..3d8565b 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,20 +1,28 @@ -
Hello, - - {{g.viewer.account.display_name}}! - Settings - Log out -
+Hello, stranger!
+Forget is a service that automatically deletes your old posts once everyone has forgotten about them. After all, why shouldn't computers forget too?
+Sound good to you? Log in with Twitter
+Forget will only start deleting posts if and when you explicitly enable it on this page. Forget will not post as you, follow any account or do anything else than delete posts.
++
{{ "♥ " if post.favourite }}{{post.body}}
- {% else %} -no posts :(
- {% endfor %} -{% else %} -Hello, stranger! Log in with Twitter
-{% endif %} +{% endblock %} diff --git a/templates/lib/interval.html b/templates/lib/interval.html index 18e709c..c84be62 100644 --- a/templates/lib/interval.html +++ b/templates/lib/interval.html @@ -2,7 +2,7 @@ +min=0 step=1>