diff options
| author | Bobby <[email protected]> | 2025-07-07 15:40:09 +0530 |
|---|---|---|
| committer | Bobby <[email protected]> | 2025-07-07 15:40:09 +0530 |
| commit | b6a04140f2668a0dcae4befcd272e05b75bd14e5 (patch) | |
| tree | bec232ae247690bf030bf05a452192f264df8c92 | |
| parent | 98afdc4673f616bc61f9ef673580ca3933bdef8a (diff) | |
| download | imageboard-b6a04140f2668a0dcae4befcd272e05b75bd14e5.tar.xz imageboard-b6a04140f2668a0dcae4befcd272e05b75bd14e5.zip | |
fix templates to use proper layout and semantic forms instead of tables
| -rw-r--r-- | controllers/login.go | 1 | ||||
| -rw-r--r-- | controllers/posts.go | 1 | ||||
| -rw-r--r-- | controllers/preferences.go | 1 | ||||
| -rw-r--r-- | controllers/register.go | 1 | ||||
| -rw-r--r-- | static/css/main.css | 50 | ||||
| -rw-r--r-- | templates/layouts/main.django | 6 | ||||
| -rw-r--r-- | templates/login.django | 61 | ||||
| -rw-r--r-- | templates/partials/search.django | 24 | ||||
| -rw-r--r-- | templates/posts.django | 61 | ||||
| -rw-r--r-- | templates/preferences.django | 48 | ||||
| -rw-r--r-- | templates/register.django | 80 |
11 files changed, 202 insertions, 132 deletions
diff --git a/controllers/login.go b/controllers/login.go index 1d6bc5e..dc8dd48 100644 --- a/controllers/login.go +++ b/controllers/login.go @@ -8,5 +8,6 @@ import ( func LoginController(ctx *fiber.Ctx) error { ctx.Locals("Title", "Login") + ctx.Locals("request", fiber.Map{"path": ctx.Path()}) return shortcuts.Render(ctx, "login", nil) } diff --git a/controllers/posts.go b/controllers/posts.go index 6fdcd26..c3da9c1 100644 --- a/controllers/posts.go +++ b/controllers/posts.go @@ -8,6 +8,7 @@ import ( func PostsController(ctx *fiber.Ctx) error {
ctx.Locals("Title", "Posts")
+ ctx.Locals("request", fiber.Map{"path": ctx.Path()})
searchQuery := ctx.Query("tags", "")
diff --git a/controllers/preferences.go b/controllers/preferences.go index 86e0fb3..3a504ed 100644 --- a/controllers/preferences.go +++ b/controllers/preferences.go @@ -8,5 +8,6 @@ import ( func PreferencesController(ctx *fiber.Ctx) error { ctx.Locals("Title", "Site Preferences") + ctx.Locals("request", fiber.Map{"path": ctx.Path()}) return shortcuts.Render(ctx, "preferences", nil) } diff --git a/controllers/register.go b/controllers/register.go index 3be4e64..9343732 100644 --- a/controllers/register.go +++ b/controllers/register.go @@ -8,5 +8,6 @@ import ( func RegisterController(ctx *fiber.Ctx) error { ctx.Locals("Title", "Register") + ctx.Locals("request", fiber.Map{"path": ctx.Path()}) return shortcuts.Render(ctx, "register", nil) } diff --git a/static/css/main.css b/static/css/main.css index 47a393e..ac463c9 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -321,4 +321,54 @@ section h2 { .center { text-align: center; +} + +/* Form Elements */ +fieldset { + background: var(--bg-section); + border: 2px inset var(--border-main); + padding: 12px; + margin: 8px 0; +} + +legend { + font-weight: bold; + font-size: 12px; + color: var(--text-main); + padding: 0 4px; + background: var(--bg-main); +} + +.form-group { + margin: 8px 0; +} + +.form-group label { + display: block; + font-weight: bold; + font-size: 12px; + margin: 4px 0 2px 0; + color: var(--text-main); +} + +.form-group small { + display: block; + font-size: 10px; + color: var(--text-dim); + margin-top: 2px; +} + +.form-actions { + margin: 12px 0 8px 0; + text-align: center; +} + +.radio-group div { + margin: 4px 0; +} + +.radio-group label { + display: inline; + font-weight: normal; + margin-left: 4px; }
\ No newline at end of file diff --git a/templates/layouts/main.django b/templates/layouts/main.django index 5c9eeb6..2d9c241 100644 --- a/templates/layouts/main.django +++ b/templates/layouts/main.django @@ -8,7 +8,11 @@ <body> {% include 'partials/navbar.django' %} - <main>{{ embed }}</main> + <main> + {% block content %} + + {% endblock %} + </main> <footer> <p>© 2025 {{ Appname }}. All rights reserved.</p> diff --git a/templates/login.django b/templates/login.django index e3d632a..9e5ab88 100644 --- a/templates/login.django +++ b/templates/login.django @@ -1,33 +1,36 @@ -<h2>Login to {{ Appname }}</h2> +{% extends 'layouts/main.django' %} -{% if Error %} - <div class="error">{{ Error }}</div> -{% endif %} +{% block content %} + <h2>Login to {{ Appname }}</h2> -<form action="/login" method="POST"> - <table> - <tr> - <th colspan="2">User Login</th> - </tr> - <tr> - <td><label for="username">Username or Email:</label></td> - <td><input type="text" id="username" name="username" required value="{{ Username }}" /></td> - </tr> - <tr> - <td><label for="password">Password:</label></td> - <td><input type="password" id="password" name="password" required /></td> - </tr> - <tr> - <td colspan="2" class="center"> + {% if Error %} + <div class="error">{{ Error }}</div> + {% endif %} + + <form action="/login" method="POST"> + <fieldset> + <legend>User Login</legend> + + <div class="form-group"> + <label for="username">Username or Email:</label> + <input type="text" id="username" name="username" required value="{{ Username }}" /> + </div> + + <div class="form-group"> + <label for="password">Password:</label> + <input type="password" id="password" name="password" required /> + </div> + + <div class="form-actions"> <input type="submit" value="LOGIN" /> - </td> - </tr> - </table> -</form> + </div> + </fieldset> + </form> -<p> - Don't have an account? <a href="/register">Register here</a> -</p> -<p> - <a href="/forgot-password">Forgot your password?</a> -</p> + <p> + Don't have an account? <a href="/register">Register here</a> + </p> + <p> + <a href="/forgot-password">Forgot your password?</a> + </p> +{% endblock %} diff --git a/templates/partials/search.django b/templates/partials/search.django index 58c2480..7b66170 100644 --- a/templates/partials/search.django +++ b/templates/partials/search.django @@ -1,16 +1,8 @@ -<form action="/" method="GET"> - <div class="search-box"> - <table> - <tr> - <th>Search Posts</th> - </tr> - <tr> - <td> - <input type="text" name="tags" placeholder="tags..." value="{{ SearchQuery }}" /> - <input type="submit" value="SEARCH" /> - <input type="button" value="CLEAR" onclick="this.form.reset(); window.location.href='/';" /> - </td> - </tr> - </table> - </div> -</form> +<aside> + <form action="/" method="GET"> + <h3>Search Posts</h3> + <input type="text" name="tags" placeholder="tags..." value="{{ SearchQuery }}" /> + <input type="submit" value="SEARCH" /> + <input type="button" value="CLEAR" onclick="this.form.reset(); window.location.href='/';" /> + </form> +</aside> diff --git a/templates/posts.django b/templates/posts.django index 1a22b97..111c959 100644 --- a/templates/posts.django +++ b/templates/posts.django @@ -1,39 +1,34 @@ +{% extends 'layouts/main.django' %} {% include 'partials/search.django' %} +{% block content %} + <h2>{{ Title }}</h2> -<h2>{{ Title }}</h2> - -<div class="posts-grid"> - {% if Posts %} - {% for post in Posts %} - <div class="post-cell"> - <img src="/uploads/thumbnails/{{ post.FileName }}" alt="{{ post.Title }}" class="post-img" /> - <div class="post-title"> - {% if post.Title %} - {{ post.Title }} - {% else %} - Post #{{ post.ID }} - {% endif %} + <div class="posts-grid"> + {% if Posts %} + {% for post in Posts %} + <div class="post-cell"> + <img src="/uploads/thumbnails/{{ post.FileName }}" alt="{{ post.Title }}" class="post-img" /> + <div class="post-title"> + {% if post.Title %} + {{ post.Title }} + {% else %} + Post #{{ post.ID }} + {% endif %} + </div> + <div class="post-info">{{ post.Tags|length }} tags</div> </div> - <div class="post-info">{{ post.Tags|length }} tags</div> + {% endfor %} + {% else %} + <div class="empty-state"> + <h3>NO POSTS FOUND!</h3> + <p>Be the first to share something awesome!</p> + <input type="button" value="UPLOAD IMAGE" onclick="location.href='/upload'" /> </div> - {% endfor %} - {% else %} - <table class="post-table"> - <tr> - <th>NO POSTS FOUND!</th> - </tr> - <tr> - <td class="center"> - Be the first to share something awesome!<br> - <input type="button" value="UPLOAD IMAGE" onclick="location.href='/upload'"> - </td> - </tr> - </table> - {% endif %} -</div> + {% endif %} + </div> -<p class="center"> - <input type="button" value="UPLOAD IMAGE" onclick="location.href='/upload'"> -</p> + <p class="center"> + <input type="button" value="UPLOAD IMAGE" onclick="location.href='/upload'" /> + </p> <button class="secondary" onclick="location.href='/tags'">BROWSE TAGS</button> -</div> +{% endblock %} diff --git a/templates/preferences.django b/templates/preferences.django index 837d94a..53fc2fc 100644 --- a/templates/preferences.django +++ b/templates/preferences.django @@ -1,21 +1,33 @@ -<h2>Site Preferences</h2> +{% extends 'layouts/main.django' %} -<form id="preferences-form"> - <div> - <label>Theme</label> - <div> - <input type="radio" name="theme" value="light" id="theme-light" /> - <label for="theme-light">Light Mode</label> - </div> - <div> - <input type="radio" name="theme" value="dark" id="theme-dark" /> - <label for="theme-dark">Dark Mode</label> - </div> - </div> +{% block content %} + <h2>Site Preferences</h2> - <button type="submit">SAVE PREFERENCES</button> -</form> + <form id="preferences-form"> + <fieldset> + <legend>Theme Settings</legend> -<p> - <a href="/">Back to Posts</a> -</p> + <div class="form-group"> + <label>Theme</label> + <div class="radio-group"> + <div> + <input type="radio" name="theme" value="light" id="theme-light" /> + <label for="theme-light">Light Mode</label> + </div> + <div> + <input type="radio" name="theme" value="dark" id="theme-dark" /> + <label for="theme-dark">Dark Mode</label> + </div> + </div> + </div> + + <div class="form-actions"> + <button type="submit">SAVE PREFERENCES</button> + </div> + </fieldset> + </form> + + <p> + <a href="/">Back to Posts</a> + </p> +{% endblock %} diff --git a/templates/register.django b/templates/register.django index c096104..2d0e8b2 100644 --- a/templates/register.django +++ b/templates/register.django @@ -1,35 +1,45 @@ -<h2>Join {{ Appname }}</h2> - -{% if Error %} - <div class="error-message">{{ Error }}</div> -{% endif %} - -<form action="/register" method="POST"> - <div> - <label for="username">Username</label> - <input type="text" id="username" name="username" required value="{{ Username }}" minlength="3" maxlength="72" pattern="[a-zA-Z0-9_-]+" /> - <small>3-72 characters, letters, numbers, underscores, and hyphens only</small> - </div> - - <div> - <label for="email">Email Address</label> - <input type="email" id="email" name="email" required value="{{ Email }}" /> - </div> - - <div> - <label for="password">Password</label> - <input type="password" id="password" name="password" required minlength="8" /> - <small>Minimum 8 characters</small> - </div> - - <div> - <label for="confirm_password">Confirm Password</label> - <input type="password" id="confirm_password" name="confirm_password" required /> - </div> - - <button type="submit">CREATE ACCOUNT</button> -</form> - -<p> - Already have an account? <a href="/login">Login here</a> -</p> +{% extends 'layouts/main.django' %} + +{% block content %} + <h2>Join {{ Appname }}</h2> + + {% if Error %} + <div class="error">{{ Error }}</div> + {% endif %} + + <form action="/register" method="POST"> + <fieldset> + <legend>Create Account</legend> + + <div class="form-group"> + <label for="username">Username</label> + <input type="text" id="username" name="username" required value="{{ Username }}" minlength="3" maxlength="72" pattern="[a-zA-Z0-9_-]+" /> + <small>3-72 characters, letters, numbers, underscores, and hyphens only</small> + </div> + + <div class="form-group"> + <label for="email">Email Address</label> + <input type="email" id="email" name="email" required value="{{ Email }}" /> + </div> + + <div class="form-group"> + <label for="password">Password</label> + <input type="password" id="password" name="password" required minlength="8" /> + <small>Minimum 8 characters</small> + </div> + + <div class="form-group"> + <label for="confirm_password">Confirm Password</label> + <input type="password" id="confirm_password" name="confirm_password" required /> + </div> + + <div class="form-actions"> + <button type="submit">CREATE ACCOUNT</button> + </div> + </fieldset> + </form> + + <p> + Already have an account? <a href="/login">Login here</a> + </p> +{% endblock %} |
