tabulka na novinky or samfink

Tento commit je obsažen v:
sneedmaster 2023-12-25 14:53:44 +01:00
rodič 4faa8e94cd
revize 6f4403e376
28 změnil soubory, kde provedl 66 přidání a 109 odebrání

Zobrazit soubor

@ -1,6 +1,6 @@
use chrono::{DateTime, Locale, Utc}; use chrono::{DateTime, Locale, Utc};
use regex::{Captures, Regex};
use lazy_static::lazy_static; use lazy_static::lazy_static;
use regex::{Captures, Regex};
use std::{collections::HashSet, fmt::Display}; use std::{collections::HashSet, fmt::Display};
use crate::markup::SPOILER_REGEX; use crate::markup::SPOILER_REGEX;

Zobrazit soubor

@ -2,38 +2,21 @@ use actix_web::{get, web::Data, HttpRequest, HttpResponse};
use askama::Template; use askama::Template;
use super::tcx::TemplateCtx; use super::tcx::TemplateCtx;
use crate::{ use crate::{ctx::Ctx, db::models::NewsPost, error::NekrochanError, web::template_response};
ctx::Ctx,
db::models::{Board, Post},
error::NekrochanError,
filters,
web::template_response,
};
#[derive(Template)] #[derive(Template)]
#[template(path = "index.html")] #[template(path = "index.html")]
struct IndexTemplate { struct IndexTemplate {
tcx: TemplateCtx, tcx: TemplateCtx,
boards: Vec<Board>, _news: Vec<NewsPost>,
posts: Vec<Post>,
files: Vec<Post>,
} }
#[get("/")] #[get("/")]
pub async fn index(ctx: Data<Ctx>, req: HttpRequest) -> Result<HttpResponse, NekrochanError> { pub async fn index(ctx: Data<Ctx>, req: HttpRequest) -> Result<HttpResponse, NekrochanError> {
let tcx = TemplateCtx::new(&ctx, &req).await?; let tcx = TemplateCtx::new(&ctx, &req).await?;
let _news = NewsPost::read_all(&ctx).await?;
let boards = Board::read_all(&ctx).await?; let template = IndexTemplate { tcx, _news };
let posts = Post::read_latest(&ctx).await.unwrap_or_else(|_| Vec::new());
let files = Post::read_files(&ctx).await.unwrap_or_else(|_| Vec::new());
let template = IndexTemplate {
tcx,
boards,
posts,
files,
};
template_response(&template) template_response(&template)
} }

binární
static/favicon.ico Spustitelný soubor → Normální soubor

Binární soubor nebyl zobrazen.

Před

Šířka:  |  Výška:  |  Velikost: 15 KiB

Za

Šířka:  |  Výška:  |  Velikost: 4.2 KiB

Binární soubor nebyl zobrazen.

Před

Šířka:  |  Výška:  |  Velikost: 1.1 KiB

Zobrazit soubor

@ -207,10 +207,14 @@ summary {
} }
.small { .small {
font-size: 8pt; font-size: 0.8rem;
font-weight: normal; font-weight: normal;
} }
.big {
font-size: 1.2rem;
}
.center { .center {
text-align: center; text-align: center;
} }
@ -228,6 +232,7 @@ summary {
} }
.board-links { .board-links {
color: var(--board-links-color);
padding: 2px; padding: 2px;
} }
@ -412,8 +417,7 @@ summary {
.icon { .icon {
height: 1em; height: 1em;
vertical-align: middle; vertical-align: text-top;
image-rendering: pixelated;
} }
.posts-omitted { .posts-omitted {

Zobrazit soubor

@ -1,6 +1,6 @@
:root { :root {
/* General */ /* General */
--bg: linear-gradient(#d6daf0 3rem, #eef2ff 230px); --bg: linear-gradient(#d1d5ee 3rem, #eef2ff 230px);
--text: #000000; --text: #000000;
--font: Arial, Helvetica, sans-serif; --font: Arial, Helvetica, sans-serif;
/* Text */ /* Text */
@ -8,6 +8,7 @@
--link-hover: #dd0000; --link-hover: #dd0000;
--post-link-color: #34345c; --post-link-color: #34345c;
--post-link-hover: #dd0000; --post-link-hover: #dd0000;
--board-links-color: #8899aa;
--title-color: #af0a0f; --title-color: #af0a0f;
--title-font: tahoma; --title-font: tahoma;
--hr-color: #d3d3d3; --hr-color: #d3d3d3;

Zobrazit soubor

@ -1,6 +1,6 @@
:root { :root {
/* General */ /* General */
--bg: linear-gradient(#fed6af90 3rem, #ffe 230px); --bg: linear-gradient(#fed6af 3rem, #ffffee 230px);
--text: #800000; --text: #800000;
--font: Arial, Helvetica, sans-serif; --font: Arial, Helvetica, sans-serif;
/* Text */ /* Text */
@ -8,6 +8,7 @@
--link-hover: #dd0000; --link-hover: #dd0000;
--post-link-color: #000080; --post-link-color: #000080;
--post-link-hover: #dd0000; --post-link-hover: #dd0000;
--board-links-color: #bb8866;
--title-color: #af0a0f; --title-color: #af0a0f;
--title-font: tahoma; --title-font: tahoma;
--hr-color: #d9bfb7; --hr-color: #d9bfb7;

Zobrazit soubor

@ -1,3 +1,5 @@
{% import "./macros/board-links.html" as board_links %}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="cs"> <html lang="cs">
<head> <head>
@ -13,12 +15,7 @@
<body> <body>
<div class="board-links"> <div class="board-links">
<span class="link-group"><a href="/">domov</a></span> <span class="link-group"><a href="/">domov</a></span>
<span class="link-group"> {% call board_links::board_links() %}
{% for board_link in tcx.boards %}
<a href="/boards/{{ board_link }}">{{ board_link }}</a>
{% if !loop.last %}<span class="link-separator"></span>{% endif %}
{% endfor %}
</span>
<span class="link-group"><a href="/overboard">nadnástěnka</a></span> <span class="link-group"><a href="/overboard">nadnástěnka</a></span>
<span style="float: right;"> <span style="float: right;">
{% if tcx.logged_in %} {% if tcx.logged_in %}

Zobrazit soubor

@ -22,6 +22,6 @@
{% endfor %} {% endfor %}
</div> </div>
<hr> <hr>
{% call post_actions::post_actions(tcx.perms) %} {% call post_actions::post_actions() %}
</form> </form>
{% endblock %} {% endblock %}

Zobrazit soubor

@ -15,7 +15,7 @@
<p class="description">{{ board.description }}</p> <p class="description">{{ board.description }}</p>
<a href="/boards/{{ board.id }}/catalog">Katalog</a> <a href="/boards/{{ board.id }}/catalog">Katalog</a>
</div> </div>
{% call post_form::post_form(board, tcx.perms, false, 0) %} {% call post_form::post_form(board, false, 0) %}
</div> </div>
<hr> <hr>
<form method="post"> <form method="post">

Zobrazit soubor

@ -1,52 +1,12 @@
{% import "./macros/board-links.html" as board_links %}
{% extends "base.html" %} {% extends "base.html" %}
{% block title %}{{ tcx.cfg.site.name }}{% endblock %} {% block title %}{{ tcx.cfg.site.name }}{% endblock %}
{% block content %} {% block content %}
<div class="container">
<div class="center"> <div class="center">
<h1 class="title">{{ tcx.cfg.site.name }}</h1> <h1 class="title">{{ tcx.cfg.site.name }}</h1>
<p class="description">{{ tcx.cfg.site.description }}</p> <p class="description">{{ tcx.cfg.site.description }}</p>
</div> </div>
{% if !boards.is_empty() %}
<div class="infobox">
<div class="infobox-head">Nástěnky</div>
<div class="infobox-content">
<ul class="infobox-list">
{% for board in boards %}
<li><a href="/boards/{{ board.id }}">/{{ board.id }}/ - {{ board.name }}</a></li>
{% endfor %}
</ul>
</div>
</div>
{% endif %}
{% if !posts.is_empty() %}
<div class="infobox">
<div class="infobox-head">Nejnovější příspěvky</div>
<div class="infobox-content">
<ul class="infobox-list">
{% for post in posts %}
<li><b>/{{ post.board }}/</b>: <a href="{{ post.post_url() }}">{{ post.content_nomarkup|inline_post }}</a></li>
{% endfor %}
</ul>
</div>
</div>
{% endif %}
{% if !files.is_empty() %}
<div class="infobox">
<div class="infobox-head">Nejnovější soubory</div>
<div class="infobox-content">
<div class="post-files multi-files">
{% for post in files %}
<div class="post-file">
<a href="{{ post.post_url() }}">
<img class="thumb" src="{{ post.files.0[0].thumb_url() }}">
</a>
</div>
{% endfor %}
</div>
</div>
</div>
{% endif %}
</div>
{% endblock %} {% endblock %}

8
templates/macros/board-links.html Normální soubor
Zobrazit soubor

@ -0,0 +1,8 @@
{% macro board_links() %}
<span class="link-group">
{% for board_link in tcx.boards %}
<a href="/boards/{{ board_link }}">{{ board_link }}</a>
{% if !loop.last %}<span class="link-separator"></span>{% endif %}
{% endfor %}
</span>
{% endmacro %}

Zobrazit soubor

@ -1,4 +1,4 @@
{% macro post_actions(perms) %} {% macro post_actions() %}
<details> <details>
<summary class="box">Uživatelské akce</summary> <summary class="box">Uživatelské akce</summary>
<table class="form-table"> <table class="form-table">
@ -68,11 +68,11 @@
</table> </table>
</details> </details>
<br> <br>
{% if perms.owner() || perms.manage_posts() || perms.bans() || perms.edit_posts() %} {% if tcx.perms.owner() || tcx.perms.manage_posts() || tcx.perms.bans() || tcx.perms.edit_posts() %}
<details> <details>
<summary class="box">Uklízečské akce</summary> <summary class="box">Uklízečské akce</summary>
<table class="form-table"> <table class="form-table">
{% if perms.owner() || perms.manage_posts() %} {% if tcx.perms.owner() || tcx.perms.manage_posts() %}
<tr> <tr>
<td class="label">Odstranit příspěvky</td> <td class="label">Odstranit příspěvky</td>
<td> <td>
@ -114,7 +114,7 @@
</td> </td>
</tr> </tr>
{% endif %} {% endif %}
{% if perms.owner() || perms.bans() %} {% if tcx.perms.owner() || tcx.perms.bans() %}
<tr> <tr>
<td class="label">Zabanovat uživatele</td> <td class="label">Zabanovat uživatele</td>
<td> <td>
@ -169,7 +169,7 @@
</td> </td>
</tr> </tr>
</table> </table>
{% if perms.owner() || perms.edit_posts() %} {% if tcx.perms.owner() || tcx.perms.edit_posts() %}
<table class="form-table"> <table class="form-table">
<tr> <tr>
<td class="submit"> <td class="submit">

Zobrazit soubor

@ -1,4 +1,4 @@
{% macro post_form(board, perms, reply, reply_to) %} {% macro post_form(board, reply, reply_to) %}
<form method="post" enctype="multipart/form-data" action="/actions/create-post"> <form method="post" enctype="multipart/form-data" action="/actions/create-post">
<input name="board" type="hidden" value="{{ board.id }}"> <input name="board" type="hidden" value="{{ board.id }}">
{% if reply %} {% if reply %}
@ -50,7 +50,7 @@
<input name="password" type="text" autocomplete="new-password" value="{{ tcx.password }}" required=""> <input name="password" type="text" autocomplete="new-password" value="{{ tcx.password }}" required="">
</td> </td>
</tr> </tr>
{% if !(perms.bypass_captcha() || perms.owner()) %} {% if !(tcx.perms.bypass_captcha() || tcx.perms.owner()) %}
{% if reply %} {% if reply %}
{% if let Some((id, base64)) = board.reply_captcha() %} {% if let Some((id, base64)) = board.reply_captcha() %}
<tr> <tr>

Zobrazit soubor

@ -11,7 +11,7 @@
<span class="tripcode">{{ tripcode }}</span>&#32; <span class="tripcode">{{ tripcode }}</span>&#32;
{% endif %} {% endif %}
{% if let Some(capcode) = post.capcode %} {% if let Some(capcode) = post.capcode %}
<span class="capcode">## {{ capcode }}</span>&#32; <span class="capcode">## {{ capcode }} <img class="icon" src="/favicon.ico"></span>&#32;
{% endif %} {% endif %}
{% if tcx.ip == post.ip %} {% if tcx.ip == post.ip %}
{# Technically not a tripcode or something but same styling #} {# Technically not a tripcode or something but same styling #}
@ -41,8 +41,11 @@
{% for file in post.files.0 %} {% for file in post.files.0 %}
<div class="post-file"> <div class="post-file">
<a download="{{ file.original_name }}" href="{{ file.file_url() }}"> <a download="{{ file.original_name }}" href="{{ file.file_url() }}">
{% if file.spoiler %}<i>[Spoiler]</i>{% else %}{{ file.original_name }}{% endif %}&#32; {% if file.spoiler %}
<img class="icon" src="/static/icons/download.png"> [Spoiler]
{% else %}
{{ file.original_name }}
{% endif %}
</a> </a>
<br> <br>
({{ file.size|filesizeformat }}, {{ file.width }}x{{ file.height }}) ({{ file.size|filesizeformat }}, {{ file.width }}x{{ file.height }})

Zobrazit soubor

@ -1,21 +1,21 @@
{% macro staff_nav(perms) %} {% macro staff_nav() %}
<div class="box inline-block pagination"> <div class="box inline-block pagination">
<a href="/staff/account">[Účet]</a>&#32; <a href="/staff/account">[Účet]</a>&#32;
<a href="/staff/accounts">[Účty]</a>&#32; <a href="/staff/accounts">[Účty]</a>&#32;
{% if perms.owner() || perms.board_config() || perms.banners() %} {% if tcx.perms.owner() || tcx.perms.board_config() || tcx.perms.banners() %}
<a href="/staff/boards">[Nástěnky]</a>&#32; <a href="/staff/boards">[Nástěnky]</a>&#32;
{% endif %} {% endif %}
{% if perms.owner() || perms.bans() %} {% if tcx.perms.owner() || tcx.perms.bans() %}
<a href="/staff/bans">[Bany]</a>&#32; <a href="/staff/bans">[Bany]</a>&#32;
{% endif %} {% endif %}
{% if perms.owner() || perms.banners() %} {% if tcx.perms.owner() || tcx.perms.banners() %}
<a href="/staff/banners">[Bannery]</a>&#32; <a href="/staff/banners">[Bannery]</a>&#32;
{% endif %} {% endif %}
{% if perms.owner() || perms.reports() %} {% if tcx.perms.owner() || tcx.perms.reports() %}
<a href="/staff/reports">[Hlášení]</a>&#32; <a href="/staff/reports">[Hlášení]</a>&#32;
{% endif %} {% endif %}
</div> </div>

Zobrazit soubor

@ -22,6 +22,6 @@
{% endfor %} {% endfor %}
</div> </div>
<hr> <hr>
{% call post_actions::post_actions(tcx.perms) %} {% call post_actions::post_actions() %}
</form> </form>
{% endblock %} {% endblock %}

Zobrazit soubor

@ -42,6 +42,6 @@
{% endfor %} {% endfor %}
{% call pagination::pagination("/overboard", pages, page) %} {% call pagination::pagination("/overboard", pages, page) %}
<hr> <hr>
{% call post_actions::post_actions(tcx.perms) %} {% call post_actions::post_actions() %}
</form> </form>
{% endblock %} {% endblock %}

Zobrazit soubor

@ -6,7 +6,7 @@
{% block content %} {% block content %}
<h1 class="title">Účet ({{ account.username }})</h1> <h1 class="title">Účet ({{ account.username }})</h1>
{% call staff_nav::staff_nav(tcx.perms) %} {% call staff_nav::staff_nav() %}
<hr> <hr>
<h2>Změnit heslo</h2> <h2>Změnit heslo</h2>
<form method="post" action="/staff/actions/change-password"> <form method="post" action="/staff/actions/change-password">

Zobrazit soubor

@ -6,7 +6,7 @@
{% block content %} {% block content %}
<h1 class="title">Účty</h1> <h1 class="title">Účty</h1>
{% call staff_nav::staff_nav(tcx.perms) %} {% call staff_nav::staff_nav() %}
<hr> <hr>
<h2>Účty</h2> <h2>Účty</h2>
<form method="post" action="/staff/actions/remove-accounts"> <form method="post" action="/staff/actions/remove-accounts">

Zobrazit soubor

@ -6,7 +6,7 @@
{% block content %} {% block content %}
<h1 class="title">Bannery</h1> <h1 class="title">Bannery</h1>
{% call staff_nav::staff_nav(tcx.perms) %} {% call staff_nav::staff_nav() %}
<hr> <hr>
<h2>Bannery</h2> <h2>Bannery</h2>
<form method="post" action="/staff/actions/remove-banners"> <form method="post" action="/staff/actions/remove-banners">

Zobrazit soubor

@ -6,7 +6,7 @@
{% block content %} {% block content %}
<h1 class="title">Bany</h1> <h1 class="title">Bany</h1>
{% call staff_nav::staff_nav(tcx.perms) %} {% call staff_nav::staff_nav() %}
<hr> <hr>
<h2>Bany</h2> <h2>Bany</h2>
<form method="post" action="/staff/actions/remove-bans"> <form method="post" action="/staff/actions/remove-bans">

Zobrazit soubor

@ -6,7 +6,7 @@
{% block content %} {% block content %}
<h1 class="title">Nastavení (/{{ board.id }}/)</h1> <h1 class="title">Nastavení (/{{ board.id }}/)</h1>
{% call staff_nav::staff_nav(tcx.perms) %} {% call staff_nav::staff_nav() %}
<hr> <hr>
<form method="post" action="/staff/actions/update-board-config"> <form method="post" action="/staff/actions/update-board-config">
<input name="board" type="hidden" value="{{ board.id }}"> <input name="board" type="hidden" value="{{ board.id }}">

Zobrazit soubor

@ -6,7 +6,7 @@
{% block content %} {% block content %}
<h1 class="title">Nástěnky</h1> <h1 class="title">Nástěnky</h1>
{% call staff_nav::staff_nav(tcx.perms) %} {% call staff_nav::staff_nav() %}
<hr> <hr>
<h2>Nástěnky</h2> <h2>Nástěnky</h2>
<form method="post"> <form method="post">

Zobrazit soubor

@ -7,7 +7,7 @@
{% block content %} {% block content %}
<h1 class="title">Záznamy</h1> <h1 class="title">Záznamy</h1>
{% call staff_nav::staff_nav(tcx.perms) %} {% call staff_nav::staff_nav() %}
<hr> <hr>
<h2>Záznamy</h2> <h2>Záznamy</h2>
<div class="table-wrap"> <div class="table-wrap">

Zobrazit soubor

@ -6,7 +6,7 @@
{% block content %} {% block content %}
<h1 class="title">Oprávnění ({{ account.username }})</h1> <h1 class="title">Oprávnění ({{ account.username }})</h1>
{% call staff_nav::staff_nav(tcx.perms) %} {% call staff_nav::staff_nav() %}
<hr> <hr>
{% if account.perms().owner() %} {% if account.perms().owner() %}
<h2 class="title">Tento uživatel je vlastník, změny nebudou mít žádný vliv.</h2> <h2 class="title">Tento uživatel je vlastník, změny nebudou mít žádný vliv.</h2>

Zobrazit soubor

@ -7,7 +7,7 @@
{% block content %} {% block content %}
<h1 class="title">Hlášení</h1> <h1 class="title">Hlášení</h1>
{% call staff_nav::staff_nav(tcx.perms) %} {% call staff_nav::staff_nav() %}
<hr> <hr>
<h1>Dočasně nedostupné</h1> <h1>Dočasně nedostupné</h1>
{% endblock %} {% endblock %}

Zobrazit soubor

@ -14,7 +14,7 @@
<p class="description">{{ board.description }}</p> <p class="description">{{ board.description }}</p>
<a href="/boards/{{ board.id }}/catalog">Katalog</a> <a href="/boards/{{ board.id }}/catalog">Katalog</a>
</div> </div>
{% call post_form::post_form(board, tcx.perms, true, thread.id) %} {% call post_form::post_form(board, true, thread.id) %}
</div> </div>
<hr> <hr>
<form method="post"> <form method="post">
@ -26,6 +26,6 @@
{% endfor %} {% endfor %}
</div> </div>
<hr> <hr>
{% call post_actions::post_actions(tcx.perms) %} {% call post_actions::post_actions() %}
</form> </form>
{% endblock %} {% endblock %}