Compare commits

...

2 Commits

Author SHA1 Message Date
40b877a4d9 feat(title): add footer 2026-03-21 01:03:22 +03:00
4121f3481c feat(title): add filename to title 2026-03-20 21:57:54 +03:00
4 changed files with 20 additions and 4 deletions

2
Cargo.lock generated
View File

@ -687,7 +687,7 @@ checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94"
[[package]]
name = "mdpreview"
version = "0.1.0"
version = "0.1.2"
dependencies = [
"axum",
"clap",

View File

@ -1,6 +1,6 @@
[package]
name = "mdpreview"
version = "0.1.0"
version = "0.1.2"
edition = "2024"
authors = ["Vladislav Kan <thek4n@yandex.ru>"]

View File

@ -41,7 +41,7 @@ struct Args {
host: String,
/// Port to listen
#[arg(short, long, default_value_t = 8000)]
#[arg(short, long, default_value_t = 8080)]
port: u16,
/// Markdown documents directory root
@ -248,8 +248,15 @@ async fn serve_file(
let html_content = markdown_to_html(&content, &state.syntax_set, &state.theme_set, &full_path);
let filename: String = if let Some(filename) = PathBuf::from(&full_path).file_name() {
filename.to_str().unwrap_or("Markdown Preview").to_string()
} else {
"Markdown Preview".to_string()
};
// Заполнение шаблона
let final_html = TEMPLATE_FILE
.replace("{{TITLE}}", &filename)
.replace("{{CONTENT}}", &html_content)
.replace("{{SSE_URL}}", &format!("/events/{full_path}"))
.replace("{{BACK_LINK}}", &back_link);

View File

@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Markdown Preview</title>
<title>{{TITLE}}</title>
<script src="https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.min.js"></script>
<style>
body { background-color: #121212; color: #e0e0e0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; margin: 0; padding: 40px 20px; display: flex; justify-content: center; line-height: 1.6; }
@ -34,6 +34,9 @@
.disconnected { background-color: #e74c3c; color: #fff; }
.reconnecting { background-color: #f1c40f; color: #000; }
.footer { margin-top: 30px; color: #666; font-size: 0.9em; border-top: 1px solid #333; padding-top: 15px; }
.footer a { color: #757575; }
img {
max-width: 100%;
height: auto;
@ -53,7 +56,13 @@
</a>
</div>
{{CONTENT}}
<div class="footer">
<a href="/">На главную</a>
<a href="/random">🎲 Случайный файл</a>
</div>
</div>
<script>
const sseUrl = "{{SSE_URL}}";