feat(button): add button for copy edit command
This commit is contained in:
parent
1bf0eec41f
commit
d4f7619bdf
@ -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
|
||||
|
||||
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -982,7 +982,7 @@ checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94"
|
||||
|
||||
[[package]]
|
||||
name = "mdpreview"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0"
|
||||
dependencies = [
|
||||
"askama",
|
||||
"askama_axum",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "mdpreview"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0"
|
||||
edition = "2024"
|
||||
authors = ["Vladislav Kan <thek4n@yandex.ru>"]
|
||||
|
||||
|
||||
4
TODO.md
Normal file
4
TODO.md
Normal file
@ -0,0 +1,4 @@
|
||||
# TODO <!-- [NOGREP] -->
|
||||
|
||||
* [ ] Сделать кнопку скопировать путь
|
||||
* [ ] Сделать кнопку скопировать путь вместе с командой (`note edit ...`)
|
||||
@ -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())
|
||||
|
||||
@ -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',
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
<span>←</span> Back
|
||||
</a>
|
||||
<a href="/random">🎲 Random note</a>
|
||||
<a class="copy-path-btn" onclick="copyPath('{{ copy_path }}')">Copy edit command</a>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user