From 16a4e2dc9fb6e9ea1e8193c1a99fdc15d774bc06 Mon Sep 17 00:00:00 2001 From: iou1name Date: Sun, 6 Oct 2019 18:11:48 -0400 Subject: [PATCH] added gallery --- saddle.py | 16 ++++++++++++++++ static/saddle.css | 36 +++++++++++++++++++++++++++++++++--- templates/gallery.html | 25 +++++++++++++++++++++++++ templates/index.html | 7 +++++-- 4 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 templates/gallery.html diff --git a/saddle.py b/saddle.py index 1037948..afa025c 100644 --- a/saddle.py +++ b/saddle.py @@ -68,6 +68,22 @@ async def index(request): return render_template("result.html", request, locals()) +@routes.get('/gallery/{user_id}', name='gallery') +async def gallery(request): + """A user's gallery page.""" + try: + user_id = int(request.match_info['user_id']) + except ValueError: + raise web.HTTPNotFound + + async with request.app['pool'] as conn: + uploads = await conn.fetch( + "SELECT * FROM upload WHERE user_id = $1", + user_id) + upload_url = config.upload_url + return render_template("gallery.html", request, locals()) + + def handle_filefield(filefield, rand_name=True): """Handles a posted file.""" filename = safe_filename(filefield.filename) diff --git a/static/saddle.css b/static/saddle.css index c3cd0d1..e6939e0 100644 --- a/static/saddle.css +++ b/static/saddle.css @@ -1,6 +1,6 @@ body { - margin-left: 10%; - margin-right: 10%; + margin-left: 0; + margin-right: 0; background-color: lightcoral; font-family: Helvetica,sans-serif; font-size: 14px; @@ -8,6 +8,11 @@ body { header { margin-bottom: 3em; +} + +#logo_line { + margin-left: 10%; + margin-bottom: 0.5em; display: flex; } @@ -16,8 +21,33 @@ header { margin-right: 1em; } +nav { + padding-left: 10%; + display: flex; + background-color: whitesmoke; + border-top: 1px solid darkgray; + border-bottom: 1px solid darkgray; +} + +nav span { + padding: 0.5em; +} + +nav span:hover { + background-color: lightgray; + transition: 0.1s; +} + +nav a { + padding: 0.5em; + text-decoration: none; + color: black; +} + + main { - display: grid; + margin-left: 10%; + margin-right: 10%; } section { diff --git a/templates/gallery.html b/templates/gallery.html new file mode 100644 index 0000000..3128c74 --- /dev/null +++ b/templates/gallery.html @@ -0,0 +1,25 @@ + + + + Saddle - Gallery + + + + + +
+

Saddle

+
+
+
+ + {% for upload in uploads %} + + + + {% endfor %} +
{{ upload['filename'] }}
+
+
+ + diff --git a/templates/index.html b/templates/index.html index 8862e6c..8ab1251 100644 --- a/templates/index.html +++ b/templates/index.html @@ -8,8 +8,11 @@
- -

Saddle

+
+ +

Saddle

+
+