commit d041feb127b8c4e423241f43c3037d2b68cb9728 Author: elukjanovica Date: Mon Apr 15 19:55:18 2024 +0300 diff --git a/main.py b/main.py new file mode 100644 index 0000000..250db10 --- /dev/null +++ b/main.py @@ -0,0 +1,60 @@ +from flask import Flask, render_template, redirect, request, session, url_for + +app = Flask(__name__) + +users = { + 'user1': 'password1', + 'user2': 'password2' +} + +posts = [ + {"alias": "update-1", "title": "Game 'Picture Puzzle remake' update 1.0", "image": "picture-puzzle.png"}, + {"alias": "how-it-was-made", "title": "Picture Puzzle remake - How it was made", "image": "coding.png"} +] + +def fetch_latest_posts(): + return posts + +@app.route("/") +def index(): + latest_posts = fetch_latest_posts() + return render_template("index.html", latest_posts=latest_posts) + +@app.route("/posts") +def all_posts(): + return render_template("posts.html", posts=posts) + +@app.route("/posts/") +def post(alias): + post_info = next((p for p in posts if p['alias'] == alias), None) + if post_info: + return render_template(f"{alias}.html") + else: + return "Post not found", 404 + +@app.route("/login", methods=["GET", "POST"]) +def login(): + if request.method == "POST": + username = request.form["username"] + password = request.form["password"] + if username in users and users[username] == password: + session["username"] = username + return redirect(url_for("index")) + return render_template("auth/login.html") + +@app.route("/logout") +def logout(): + session.pop("username", None) + return redirect(url_for("index")) + +@app.route("/register", methods=["GET", "POST"]) +def register(): + if request.method == "POST": + username = request.form["username"] + password = request.form["password"] + users[username] = password + return redirect(url_for("login")) + return render_template("auth/register.html") + +if __name__ == "__main__": + app.run(debug=True) \ No newline at end of file diff --git a/static/css/main.css b/static/css/main.css new file mode 100644 index 0000000..76e339c --- /dev/null +++ b/static/css/main.css @@ -0,0 +1,326 @@ +/* Global */ +html { + font-family: 'JetBrains Mono', monospace; + background: #1F1F1F; +} + +body { + background-color: #f8f9fa; + margin: 0; + padding: 0; + box-sizing: border-box; + margin: 0 auto; + background: #1F1F1F; + color: #fff; +} + +h1 { + font-weight: bold; + color: #0889E5; + margin: 1rem 0; +} + +a { + color: #0889E5; +} + +hr { + border: none; + border-top: 1px solid #B6C7D3; +} + +/* Navbar */ +nav { + background: #1a1b1e; + display: flex; + align-items: center; + justify-content: space-between; + padding: 1rem 2rem; + color: #fff; +} + +nav img { + margin: 0; +} + +nav li a, nav a.link { + text-decoration: none; + padding: 0.6rem 0.25rem; + position: relative; + color: #fff; +} + +nav a.link:hover { + color: #fff; +} + +nav a.link::before { + content: ""; + position: absolute; + display: block; + width: 80%; + height: 2px; + bottom: -2px; + left: 10%; + transform: translateX(-50%); + background-color: #fff; + transform-origin: center; + transform: scaleX(0); + transition: transform 0.3s ease; +} + +nav a.link:hover::before { + transform: scaleX(1); +} + +nav ul { + display: flex; + list-style: none; + margin: 0; + padding: 0; + align-items: flex-end; + justify-content: flex-end; +} + +nav ul li { + margin-right: 1.5rem; +} + +nav ul li:last-child { + margin-right: 0; +} + +.dropdown.pull-left .dropdown-content { + right: 0; + left: auto; +} + +nav ul li a { + color: #fff; + text-decoration: none; + font-size: 20px; + font-weight: bold; +} + +nav .dropdown a::before { + display: none; +} + +.dropdown { + position: relative; +} + +.dropdown-content { + display: none; + position: absolute; + background-color: #f9f9f9; + min-width: 160px; + z-index: 1; + border: 1px solid #ccc; + padding: 10px; + margin-top: 10px; + border-radius: 5px; + box-shadow: 0 2px 5px rgba(0,0,0,0.1); + top: 100%; +} + +.dropdown:hover .dropdown-content { + display: block; +} + +.dropdown-content a { + color: #1F1F1F; + padding: 8px 12px; + text-decoration: none; + display: block; +} + +.dropdown-content a:hover { + background-color: #B6C7D3; +} + +.dropdown-content a::before { + display: none; +} + +/* Content Section */ +.content { + padding: 20px; + font-style: italic; +} + +/* Other */ +.featured-posts-container, +.latest-posts-container { + display: flex; + flex-wrap: wrap; +} + +.featured-post, +.latest-post { + padding: 0 20px; + box-sizing: border-box; + margin-bottom: 20px; + text-align: center; +} + +.featured-post a, +.latest-post a { + display: flex; + flex-direction: column; + align-items: center; + text-decoration: none; + color: inherit; + position: relative; + color: #fff; + font-size: 20px; +} + +.featured-post img, +.latest-post img { + margin-bottom: 10px; + flex-shrink: 0; +} + +.featured-post a::before, +.latest-post a::before { + content: ""; + position: absolute; + bottom: -2px; + left: 50%; + transform: translateX(-50%); + width: 0; + height: 2px; + background-color: #fff; + transition: width 0.3s ease; +} + +.featured-post a:hover::before, +.latest-post a:hover::before { + width: 100%; +} + +.featured-posts h3, .latest-posts h3 { + margin: 0.25rem; +} + +/* Footer */ +footer { + background-color: #005DA5; + color: #fff; + padding: 20px; + text-align: center; + font-size: 14px; + margin-top: 20px; +} + +footer ul { + list-style: none; + padding: 0; + margin: 0; +} + +footer ul li { + display: inline-block; + margin-right: 10px; +} + +footer ul li:last-child { + margin-right: 0; +} + +footer ul li a { + color: #fff; + text-decoration: none; + position: relative; +} + +footer ul li a:hover { + color: #fff; +} + +footer ul li a::before { + content: ""; + position: absolute; + display: block; + width: 100%; + height: 2px; + bottom: -2px; + left: 0; + background-color: #fff; + transform: scaleX(0); + transition: transform 0.3s ease; +} + +footer ul li a:hover::before { + transform: scaleX(1); +} + +/* Input Fields */ +input[type="text"], +input[type="email"], +input#password, input#username, +textarea { + padding: 10px; + border: 1px solid #ccc; + border-radius: 5px; + width: 20%; + margin-bottom: 10px; + box-sizing: border-box; + font-size: 16px; + transition: box-shadow 0.15s, transform 0.15s; +} + +input[type="text"]:hover, +input[type="email"]:hover, +input#password, input#username, +textarea:hover { + box-shadow: rgba(45, 35, 66, 0.4) 0 4px 8px, rgba(45, 35, 66, 0.3) 0 7px 13px -3px, #D6D6E7 0 -3px 0 inset; + transform: translateY(-2px); +} + +/* Button */ +button, input { + align-items: center; + appearance: none; + background-color: #FCFCFD; + border-radius: 4px; + border-width: 0; + box-shadow: rgba(45, 35, 66, 0.4) 0 2px 4px, rgba(45, 35, 66, 0.3) 0 7px 13px -3px, #D6D6E7 0 -3px 0 inset; + box-sizing: border-box; + color: #36395A; + cursor: pointer; + display: inline-flex; + font-family: "JetBrains Mono", monospace; + height: 40px; + justify-content: center; + line-height: 1; + list-style: none; + overflow: hidden; + padding-left: 16px; + padding-right: 16px; + position: relative; + text-align: left; + text-decoration: none; + transition: box-shadow 0.15s, transform 0.15s; + user-select: none; + -webkit-user-select: none; + touch-action: manipulation; + white-space: nowrap; + will-change: box-shadow, transform; + font-size: 18px; +} + +button:focus, input:focus { + box-shadow: #D6D6E7 0 0 0 1.5px inset, rgba(45, 35, 66, 0.4) 0 2px 4px, rgba(45, 35, 66, 0.3) 0 7px 13px -3px, #D6D6E7 0 -3px 0 inset; +} + +button:hover, input:hover { + box-shadow: rgba(45, 35, 66, 0.4) 0 4px 8px, rgba(45, 35, 66, 0.3) 0 7px 13px -3px, #D6D6E7 0 -3px 0 inset; + transform: translateY(-2px); +} + +button:active, input:active { + box-shadow: #D6D6E7 0 3px 7px inset; + transform: translateY(2px); +} diff --git a/static/css/posts.css b/static/css/posts.css new file mode 100644 index 0000000..555abf4 --- /dev/null +++ b/static/css/posts.css @@ -0,0 +1,13 @@ +body { + display: flex; + align-items: center; + flex-direction: column; +} + +h1 { + margin:100px; +} + +p { + font-size: 20px; +} diff --git a/static/images/Picture-Puzzle-logo.png b/static/images/Picture-Puzzle-logo.png new file mode 100644 index 0000000..e56ae99 Binary files /dev/null and b/static/images/Picture-Puzzle-logo.png differ diff --git a/static/images/coding.png b/static/images/coding.png new file mode 100644 index 0000000..3028b25 Binary files /dev/null and b/static/images/coding.png differ diff --git a/static/images/picture-puzzle.png b/static/images/picture-puzzle.png new file mode 100644 index 0000000..6016628 Binary files /dev/null and b/static/images/picture-puzzle.png differ diff --git a/static/js/main.js b/static/js/main.js new file mode 100644 index 0000000..e69de29 diff --git a/templates/auth/login.html b/templates/auth/login.html new file mode 100644 index 0000000..a404da7 --- /dev/null +++ b/templates/auth/login.html @@ -0,0 +1,14 @@ +{% extends 'base.html' %} + +{% block title %}Log In{% endblock %} + +{% block content %} +

Log In

+
+ + + + + +
+{% endblock %} diff --git a/templates/auth/logout.html b/templates/auth/logout.html new file mode 100644 index 0000000..ffecd24 --- /dev/null +++ b/templates/auth/logout.html @@ -0,0 +1,10 @@ +{% extends 'base.html' %} + +{% block title %}Log Out{% endblock %} + +{% block content %} +

Log Out

+
+ +
+{% endblock %} diff --git a/templates/auth/register.html b/templates/auth/register.html new file mode 100644 index 0000000..29e87ce --- /dev/null +++ b/templates/auth/register.html @@ -0,0 +1,14 @@ +{% extends 'base.html' %} + +{% block title %}Register{% endblock %} + +{% block content %} +

Register

+
+ + + + + +
+{% endblock %} diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..ab202eb --- /dev/null +++ b/templates/base.html @@ -0,0 +1,59 @@ + + + + + + {% block title %}Picture Puzzle Website{% endblock %} + + + + +
+ {% block content %} + {% endblock %} +
+ + + diff --git a/templates/how-it-was-made.html b/templates/how-it-was-made.html new file mode 100644 index 0000000..8e4c64d --- /dev/null +++ b/templates/how-it-was-made.html @@ -0,0 +1,12 @@ +{% extends 'base.html' %} + +{% block title %} + "Picture Puzzle remake" - How it was made +{% endblock %} + +{% block content %} +
+

"Picture Puzzle remake" - How it was made

+ Some intense coding +

Somehow idk

+{% endblock %} diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..b6f628b --- /dev/null +++ b/templates/index.html @@ -0,0 +1,62 @@ +{% extends 'base.html' %} + +{% block title %} + Home Page +{% endblock %} + +{% block header %} +

Welcome to Picture Puzzle remake web!

+{% endblock %} + +{% block content %} +
+

Welcome to Picture Puzzle remake web! Here you can see game updates, articles, and more.

+
+ + + +
+

Latest Posts

+
+ {% for post in latest_posts %} +
+ + {{ post.title }} +

{{ post.title }}

+
+
+ {% endfor %} +
+
+ + + +
+

Subscribe to game updates

+ +

+
+{% endblock %} diff --git a/templates/posts.html b/templates/posts.html new file mode 100644 index 0000000..3c819e1 --- /dev/null +++ b/templates/posts.html @@ -0,0 +1,21 @@ +{% extends 'base.html' %} + +{% block title %} + All Posts +{% endblock %} + +{% block content %} +
+

All Posts

+
+ {% for post in posts %} +
+ + {{ post['title'] }} +

{{ post['title'] }}

+
+
+ {% endfor %} +
+
+{% endblock %} diff --git a/templates/update-1.html b/templates/update-1.html new file mode 100644 index 0000000..061abee --- /dev/null +++ b/templates/update-1.html @@ -0,0 +1,18 @@ +{% extends 'base.html' %} + +{% block title %} + Game "Picture Puzzle remake" update 1.0 +{% endblock %} + +{% block content %} +
+

Game "Picture Puzzle remake" update 1.0

+ Picture Puzzle original +

Added:

+
    +
  • Game itself
  • +
  • New stuff
  • +
  • And more...
  • +
+
+{% endblock %}