diff --git a/README.md b/README.md index a2a46d0..8d2e0ca 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ The blog is intended to be used to review and critique things. - [x] Login - [x] Logout - [x] Register - - [ ] User Page + - [x] User Page - [ ] Review blog entries - [x] Writing entries - [ ] Editing entries diff --git a/src/app.py b/src/app.py index 20f6fcb..82e06aa 100644 --- a/src/app.py +++ b/src/app.py @@ -45,10 +45,19 @@ def index(): @app.route("/archive") @app.route("/archive.html") def archive(): + entries = db.get_entries() content = con_gen.gen_arch_string() return render_template("archive.html", content_string=content) +@app.route("/user/") +def user(name): + content = con_gen.gen_user_string(name) + if content != "": + return render_template("user.html", name=name, content_string=content) + abort(404) + + @app.route("/entry/") def entry(ident): content = con_gen.gen_stand_string(ident) @@ -103,12 +112,10 @@ def logout(): @app.route("/register", methods=["GET", "POST"]) @app.route("/register.html", methods=["GET", "POST"]) def register(): - if current_user.is_authenticated or not REGISTER: + if current_user.is_authenticated or not config.ALLOW_REGISTRATION: return redirect(url_for("index")) form = RegisterForm() if form.validate_on_submit(): - if not config.ALLOW_REGISTRATION: - return redirect(url_for("index")) db_user = db.get_user_by_name(form.username.data) if db_user is None: user = User(form.username.data) diff --git a/src/content.py b/src/content.py index cc699b7..e286af8 100644 --- a/src/content.py +++ b/src/content.py @@ -33,6 +33,45 @@ def gen_arch_string(): entries = db.get_entries() if entries is None: return "" + entries.sort(key=lambda y: y[1]) + entries.reverse() + entries.sort(key=lambda y: y[2]) + entries.reverse() + for entry in entries: + ident = entry[0] + title = entry[1] + year = entry[2] + rating = entry[4] + username = db.get_user_by_id(entry[5])[1] + if year != last_year: + if last_year != "": + content_string += "\n" + content_string += "

" + year + "

\n" + content_string += "\n" @@ -47,18 +87,18 @@ def gen_arch_string(): content_string += "