diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5554cf0..e864668 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -41,6 +41,6 @@ repos: - id: check-todos # [NOGREP] name: check-todos # [NOGREP] language: system - entry: sh -c "! grep --color=always --binary-files=without-match --dereference-recursive --exclude-dir='notes' --exclude-dir='target' --exclude-dir='node_modules' --exclude-dir='.git' --exclude='.pre-commit-config.yaml' --exclude-dir='venv' 'TODO'" # [NOGREP] + entry: sh -c "! grep --color=always --binary-files=without-match --dereference-recursive --exclude-dir='notes' --exclude-dir='target' --exclude-dir='node_modules' --exclude-dir='.git' --exclude='.pre-commit-config.yaml' --exclude-dir='venv' 'TODO' | grep -v '[NOGREP]'" # [NOGREP] pass_filenames: false always_run: true diff --git a/Cargo.lock b/Cargo.lock index 02f4f59..85aa0f9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -982,7 +982,7 @@ checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" [[package]] name = "mdpreview" -version = "0.3.0" +version = "0.4.0" dependencies = [ "askama", "askama_axum", diff --git a/Cargo.toml b/Cargo.toml index 157e0d1..7a0130d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mdpreview" -version = "0.3.0" +version = "0.4.0" edition = "2024" authors = ["Vladislav Kan "] diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..6e6add4 --- /dev/null +++ b/TODO.md @@ -0,0 +1,4 @@ +# TODO + +* [ ] Сделать кнопку скопировать путь +* [ ] Сделать кнопку скопировать путь вместе с командой (`note edit ...`) diff --git a/src/main.rs b/src/main.rs index 5e6d6fa..fbe2356 100644 --- a/src/main.rs +++ b/src/main.rs @@ -56,6 +56,7 @@ pub struct NoteTemplate { pub back_link: String, pub content: String, pub sse_url: String, + pub copy_path: String, } #[derive(clap::Parser, Debug)] @@ -255,11 +256,14 @@ async fn serve_file( let sse_url = format!("/events/{full_path}"); + let copy_path = format!("note edit {full_path}"); + let template = NoteTemplate { filename, back_link, content: html_content, sse_url, + copy_path, }; Ok(template.into_response()) diff --git a/templates/base.html b/templates/base.html index ecd19e9..fac419d 100644 --- a/templates/base.html +++ b/templates/base.html @@ -76,6 +76,17 @@ } .copy-btn:hover { background-color: #444; color: #fff; border-color: #777; } .copy-btn:active { transform: scale(0.95); } + + .copy-path-btn { + background: transparent; + color: #ccc; + border-radius: 4px; + cursor: pointer; + font-size: 0.8em; + transition: all 0.2s; + } + .copy-path-btn:hover { background-color: #444; color: #fff; border-color: #777; } + .copy-path-btn:active { transform: scale(0.95); } pre { padding: 15px; overflow-x: auto; margin: 0; } pre code { background: transparent; padding: 0; color: inherit; } .mermaid-wrapper .mermaid { @@ -167,6 +178,13 @@ }); } + function copyPath(path) { + navigator.clipboard.writeText(path).then(() => {}).catch(err => { + console.error('Error copying:', err); + button.innerText = 'Error'; + }); + } + mermaid.initialize({ startOnLoad: true, theme: 'dark', diff --git a/templates/file.html b/templates/file.html index 0f6c087..590678b 100644 --- a/templates/file.html +++ b/templates/file.html @@ -7,6 +7,7 @@ Back 🎲 Random note +Copy edit command {% endblock %} {% block content %}