feat(footer): add package name, version and authors to footer
This commit is contained in:
parent
b990725af1
commit
3b0de79a17
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -982,7 +982,7 @@ checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94"
|
||||
|
||||
[[package]]
|
||||
name = "mdpreview"
|
||||
version = "0.4.1"
|
||||
version = "0.4.2"
|
||||
dependencies = [
|
||||
"askama",
|
||||
"askama_axum",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "mdpreview"
|
||||
version = "0.4.1"
|
||||
version = "0.4.2"
|
||||
edition = "2024"
|
||||
authors = ["Vladislav Kan <thek4n@yandex.ru>"]
|
||||
|
||||
|
||||
3
rust-toolchain.toml
Normal file
3
rust-toolchain.toml
Normal file
@ -0,0 +1,3 @@
|
||||
[toolchain]
|
||||
channel = "stable"
|
||||
components = ["clippy", "rustfmt", "chef"]
|
||||
33
src/main.rs
33
src/main.rs
@ -2,7 +2,10 @@ use askama::Template;
|
||||
use axum::{
|
||||
Router,
|
||||
extract::{Path as AxumPath, State},
|
||||
http::{HeaderMap, StatusCode, header},
|
||||
http::{
|
||||
HeaderMap, StatusCode,
|
||||
header::{self},
|
||||
},
|
||||
response::{IntoResponse, Redirect, Sse},
|
||||
routing::get,
|
||||
};
|
||||
@ -47,6 +50,9 @@ pub struct FileEntry {
|
||||
pub struct DirectoryTemplate {
|
||||
pub title_path: String,
|
||||
pub files: Vec<FileEntry>,
|
||||
pub package_name: String,
|
||||
pub authors: String,
|
||||
pub version: String,
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
@ -57,8 +63,15 @@ pub struct NoteTemplate {
|
||||
pub content: String,
|
||||
pub sse_url: String,
|
||||
pub copy_path: String,
|
||||
pub package_name: String,
|
||||
pub authors: String,
|
||||
pub version: String,
|
||||
}
|
||||
|
||||
const PACKAGE_NAME: &str = env!("CARGO_PKG_NAME");
|
||||
const AUTHORS: &str = env!("CARGO_PKG_AUTHORS");
|
||||
const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
|
||||
#[derive(clap::Parser, Debug)]
|
||||
#[command(author, version, about, long_about = None)]
|
||||
struct Args {
|
||||
@ -232,6 +245,9 @@ async fn render_single_file(
|
||||
content: html_content,
|
||||
sse_url,
|
||||
copy_path,
|
||||
package_name: PACKAGE_NAME.to_string(),
|
||||
authors: AUTHORS.to_string(),
|
||||
version: VERSION.to_string(),
|
||||
})
|
||||
}
|
||||
|
||||
@ -338,6 +354,9 @@ async fn serve_file(
|
||||
content: html_content,
|
||||
sse_url,
|
||||
copy_path,
|
||||
package_name: PACKAGE_NAME.to_string(),
|
||||
authors: AUTHORS.to_string(),
|
||||
version: VERSION.to_string(),
|
||||
};
|
||||
|
||||
Ok(template.into_response())
|
||||
@ -388,7 +407,17 @@ async fn render_directory_index(
|
||||
|
||||
let title_path = request_path.trim_start_matches('/').to_string();
|
||||
|
||||
Ok(DirectoryTemplate { title_path, files })
|
||||
let package_name = env!("CARGO_PKG_NAME").to_string();
|
||||
let authors = env!("CARGO_PKG_AUTHORS").to_string();
|
||||
let version = env!("CARGO_PKG_VERSION").to_string();
|
||||
|
||||
Ok(DirectoryTemplate {
|
||||
title_path,
|
||||
files,
|
||||
package_name,
|
||||
authors,
|
||||
version,
|
||||
})
|
||||
}
|
||||
|
||||
async fn sse_handler(
|
||||
|
||||
@ -165,6 +165,9 @@
|
||||
<div class="footer">
|
||||
<a href="/">← Main</a>
|
||||
<a href="/random">🎲 Random note</a>
|
||||
{% block footer %}
|
||||
<p>{{ package_name }} - {{ authors }} - v{{ version }}</p>
|
||||
{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user