Compare commits

...

5 Commits
0.4.2 ... main

Author SHA1 Message Date
71c5915628 ci(docker): add Dockerfile 2026-04-07 03:25:36 +03:00
17ae6a036e docs(changelog): change changelog style 2026-03-30 13:38:27 +03:00
6c88272e58 chore: rust-toolchain file 2026-03-30 13:24:18 +03:00
0dd24e2ba4 fix(style): fix removing newlines 2026-03-29 12:09:00 +03:00
a6c8739044 style: some changes 2026-03-29 09:24:50 +03:00
9 changed files with 91 additions and 13 deletions

8
.dockerignore Normal file
View File

@ -0,0 +1,8 @@
target/
.git/
.gitignore
Dockerfile
.dockerignore
README.md
.env
*.md

View File

@ -5,7 +5,31 @@ The format is based on [Keep a
Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to
[Semantic Versioning](https://semver.org/lang/en/).
## [0.4.1] - 2026-03-26
## v0.4.4 - 2026-03-29
### Fixed
- Fixed removing newlines.
---
## v0.4.3 - 2026-03-28
### Changed
- Change footer.
---
## v0.4.2 - 2026-03-27
### Added
- Added version and project name in footer.
---
## v0.4.1 - 2026-03-26
### Fixed
- Added support for rendering individual files, not just directories (e.g.,
`mdpreview dir/file.md`).
@ -15,7 +39,7 @@ Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to
---
## [0.4.0] - 2026-03-25
## v0.4.0 - 2026-03-25
### Added
- Added a button to copy the edit command (`note edit current_note.md`).
@ -23,7 +47,7 @@ Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to
---
## [0.3.0] - 2026-03-24
## v0.3.0 - 2026-03-24
### Added
- Added the `--random` flag to open the browser on a random page when used with
`--browser` (`--browser --random`).
@ -32,7 +56,7 @@ Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to
---
## [0.2.1] - 2026-03-23
## v0.2.1 - 2026-03-23
### Fixed
- Fixed an issue where listening on port 0 (`--port 0`) caused the browser to
open the wrong port.
@ -41,7 +65,7 @@ Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to
---
## [0.2.0] - 2026-03-23
## v0.2.0 - 2026-03-23
### Added
- Added the `--browser` flag to automatically open the page in the browser.
@ -49,7 +73,7 @@ Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to
---
## [0.1.3] - 2026-03-23
## v0.1.3 - 2026-03-23
### Added
- Added a "Random File" button to the header.
@ -65,7 +89,7 @@ Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to
---
## [0.1.2] - 2026-03-22
## v0.1.2 - 2026-03-22
### Added
- Added a "Random File" button.
- Added an "On Main" button.
@ -78,6 +102,6 @@ Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to
---
## [0.1.1] - 2026-03-21
## v0.1.1 - 2026-03-21
### Added
- Added page titles.

2
Cargo.lock generated
View File

@ -982,7 +982,7 @@ checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94"
[[package]]
name = "mdpreview"
version = "0.4.2"
version = "0.4.4"
dependencies = [
"askama",
"askama_axum",

View File

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

43
Dockerfile Normal file
View File

@ -0,0 +1,43 @@
FROM rust:1.94 AS chef
RUN cargo install --locked cargo-chef
WORKDIR /app
COPY Cargo.toml Cargo.lock .
RUN mkdir src && touch src/main.rs
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder
COPY --from=chef /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
COPY rust-toolchain.toml rust-toolchain.toml
RUN cargo fetch
COPY . .
RUN cargo build --release
FROM debian:bookworm-slim AS runtime
RUN useradd -m -s /bin/bash appuser
WORKDIR /app
COPY --from=builder /app/target/release/mdpreview /usr/local/bin/mdpreview
USER appuser
EXPOSE 8080
CMD ["mdpreview"]

View File

@ -1,3 +1,3 @@
[toolchain]
channel = "stable"
components = ["clippy", "rustfmt", "chef"]
components = ["clippy", "rustfmt"]

View File

@ -154,7 +154,7 @@ async fn main() {
let listener = tokio::net::TcpListener::bind(addr).await.unwrap();
let actual_addr = listener.local_addr().expect("Failed to get local address");
println!("Server started on http://{actual_addr}");
println!("mdpreview v{VERSION} server started on http://{actual_addr}");
if args.browser {
let mut url = format!("http://{actual_addr}");

View File

@ -127,10 +127,13 @@ pub fn markdown_to_html(markdown: &str, ss: &SyntaxSet, ts: &ThemeSet, _file_pat
IncludeBackground::No,
)
.unwrap_or_else(|_| escape_html(&line));
result_html.push_str(&html_line);
result_html.push('\n');
}
Err(_) => {
result_html.push_str(&escape_html(&line));
result_html.push('\n');
}
}
}

View File

@ -166,7 +166,7 @@
<a href="/">← Main</a>
<a href="/random">🎲 Random note</a>
{% block footer %}
<p>{{ package_name }} - {{ authors }} - v{{ version }}</p>
<p>{{ package_name }} v{{ version }}</p>
{% endblock %}
</div>
</div>