mdpreview/templates/file.html
2026-03-23 15:07:22 +03:00

248 lines
6.8 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{TITLE}}</title>
<script src="https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.min.js"></script>
<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;
}
.content {
max-width: 800px;
width: 100%;
background-color: #1e1e1e;
padding: 40px;
border-radius: 12px;
box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
a {
color: #bb86fc;
text-decoration: none !important;
}
h1, h2, h3, h4 {
color: #ffffff;
margin-top: 1.5em;
margin-bottom: 0.5em;
}
h1 {
border-bottom: 1px solid #333;
padding-bottom: 10px;
}
table {
border-collapse: collapse;
width: 100%;
margin: 1em 0;
}
th, td {
border: 1px solid #444;
padding: 8px;
text-align: left;
}
th {
background-color: #2c2c2c;
}
blockquote {
border-left: 4px solid #bb86fc;
margin: 1em 0;
padding-left: 1em;
color: #aaa;
background: #252525;
padding: 10px;
}
code {
font-family: 'Consolas', 'Monaco', monospace;
}
p > code, li > code {
background-color: #2c2c2c;
padding: 2px 6px;
border-radius: 4px;
color: #ff79c6;
}
.code-block-wrapper {
margin: 1em 0;
border: 1px solid #444;
border-radius: 6px;
overflow: hidden;
background-color: #2b303b;
}
.code-header {
display: flex;
justify-content: space-between;
align-items: center;
background-color: #232730;
padding: 6px 12px;
border-bottom: 1px solid #444;
font-size: 0.85em;
color: #a0a0a0;
}
.code-lang {
font-weight: bold;
text-transform: uppercase;
letter-spacing: 0.5px;
}
.copy-btn {
background: transparent;
border: 1px solid #555;
color: #ccc;
padding: 2px 8px;
border-radius: 4px;
cursor: pointer;
font-size: 0.8em;
transition: all 0.2s;
}
.copy-btn:hover {
background-color: #444;
color: #fff;
border-color: #777;
}
.copy-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 {
background-color: #f9f9f9;
border-radius: 0 0 6px 6px;
display: flex;
justify-content: center;
}
#status {
position: fixed;
top: 10px; right: 10px;
padding: 5px 10px;
border-radius: 4px;
font-size: 12px;
font-weight: bold;
}
.connected {
background-color: #2ecc71;
color: #000;
}
.disconnected {
background-color: #e74c3c;
color: #fff;
}
.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;
}
.back-link {
display: inline-flex;
align-items: center;
color: #90a4ae;
text-decoration: none;
font-size: 0.95em;
transition: color 0.2s;
}
.back-link span {
margin-right: 8px;
font-size: 1.2em;
}
img {
max-width: 100%;
height: auto;
display: block;
margin: 1.5em auto;
border-radius: 6px;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
</style>
</head>
<body>
<div class="content">
<div style="margin-bottom: 20px;">
<a href="{{BACK_LINK}}" class="back-link" onmouseover="this.style.color='#ffffff'" onmouseout="this.style.color='#90a4ae'">
<span></span> Назад
</a>
</div>
{{CONTENT}}
<div class="footer">
<a href="/">На главную</a>
<a href="/random">🎲 Случайный файл</a>
</div>
</div>
<script>
const sseUrl = "{{SSE_URL}}";
function connect() {
const evtSource = new EventSource(sseUrl);
evtSource.onerror = (err) => {
evtSource.close();
setTimeout(connect, 3000);
};
evtSource.addEventListener("reload", (event) => {
console.log("Получено событие обновления");
location.reload();
});
}
connect();
function copyCode(button) {
const wrapper = button.closest('.code-block-wrapper');
if (!wrapper) return;
const target = wrapper.querySelector('pre') || wrapper.querySelector('.mermaid');
if (!target) return;
const codeText = target.innerText;
navigator.clipboard.writeText(codeText).then(() => {
const originalText = button.innerText;
button.innerText = 'Copied!';
button.style.borderColor = '#2ecc71';
button.style.color = '#2ecc71';
setTimeout(() => {
button.innerText = originalText;
button.style.borderColor = '';
button.style.color = '';
}, 2000);
}).catch(err => {
console.error('Ошибка копирования:', err);
button.innerText = 'Error';
});
}
mermaid.initialize({
startOnLoad: true,
theme: 'dark',
securityLevel: 'loose',
});
</script>
</body>
</html>