Compare commits
No commits in common. "40b877a4d9fc1438a79285cabebd92e29977935c" and "ba2e11f07c6b207c348d7b7aa54c865a48eba8b0" have entirely different histories.
40b877a4d9
...
ba2e11f07c
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -687,7 +687,7 @@ checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mdpreview"
|
name = "mdpreview"
|
||||||
version = "0.1.2"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"axum",
|
"axum",
|
||||||
"clap",
|
"clap",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "mdpreview"
|
name = "mdpreview"
|
||||||
version = "0.1.2"
|
version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
authors = ["Vladislav Kan <thek4n@yandex.ru>"]
|
authors = ["Vladislav Kan <thek4n@yandex.ru>"]
|
||||||
|
|
||||||
|
|||||||
@ -41,7 +41,7 @@ struct Args {
|
|||||||
host: String,
|
host: String,
|
||||||
|
|
||||||
/// Port to listen
|
/// Port to listen
|
||||||
#[arg(short, long, default_value_t = 8080)]
|
#[arg(short, long, default_value_t = 8000)]
|
||||||
port: u16,
|
port: u16,
|
||||||
|
|
||||||
/// Markdown documents directory root
|
/// Markdown documents directory root
|
||||||
@ -248,15 +248,8 @@ async fn serve_file(
|
|||||||
|
|
||||||
let html_content = markdown_to_html(&content, &state.syntax_set, &state.theme_set, &full_path);
|
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
|
let final_html = TEMPLATE_FILE
|
||||||
.replace("{{TITLE}}", &filename)
|
|
||||||
.replace("{{CONTENT}}", &html_content)
|
.replace("{{CONTENT}}", &html_content)
|
||||||
.replace("{{SSE_URL}}", &format!("/events/{full_path}"))
|
.replace("{{SSE_URL}}", &format!("/events/{full_path}"))
|
||||||
.replace("{{BACK_LINK}}", &back_link);
|
.replace("{{BACK_LINK}}", &back_link);
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>{{TITLE}}</title>
|
<title>Markdown Preview</title>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.min.js"></script>
|
||||||
<style>
|
<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; }
|
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,9 +34,6 @@
|
|||||||
.disconnected { background-color: #e74c3c; color: #fff; }
|
.disconnected { background-color: #e74c3c; color: #fff; }
|
||||||
.reconnecting { background-color: #f1c40f; color: #000; }
|
.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 {
|
img {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
height: auto;
|
height: auto;
|
||||||
@ -56,13 +53,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
{{CONTENT}}
|
{{CONTENT}}
|
||||||
|
|
||||||
<div class="footer">
|
|
||||||
<a href="/">← На главную</a>
|
|
||||||
<a href="/random">🎲 Случайный файл</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const sseUrl = "{{SSE_URL}}";
|
const sseUrl = "{{SSE_URL}}";
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user