mirror of
https://github.com/perstarkse/minne.git
synced 2026-03-20 08:34:31 +01:00
121 lines
2.7 KiB
HTML
121 lines
2.7 KiB
HTML
{% extends 'body_base.html' %}
|
|
{% block title %}Minne Chat{% endblock %}
|
|
{% block head %}
|
|
<script src="/assets/marked.min.js"></script>
|
|
<script src="/assets/htmx-ext-sse.js" defer></script>
|
|
{% endblock %}
|
|
|
|
{% block main %}
|
|
<div class="flex justify-center mt-2 sm:mt-4 mb-10">
|
|
<div class="max-w-3xl w-full overflow-auto hide-scrollbar">
|
|
{% include "chat/history.html" %}
|
|
{% include "chat/new_message_form.html" %}
|
|
</div>
|
|
</div>
|
|
<style>
|
|
.hide-scrollbar {
|
|
-ms-overflow-style: none;
|
|
scrollbar-width: none;
|
|
}
|
|
|
|
.hide-scrollbar::-webkit-scrollbar {
|
|
display: none;
|
|
}
|
|
|
|
.markdown-content p {
|
|
margin-bottom: 0.75em;
|
|
}
|
|
|
|
.markdown-content p:last-child {
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
.markdown-content ul,
|
|
.markdown-content ol {
|
|
margin-top: 0.5em;
|
|
margin-bottom: 0.75em;
|
|
padding-left: 2em;
|
|
}
|
|
|
|
.markdown-content li {
|
|
margin-bottom: 0.25em;
|
|
}
|
|
|
|
.markdown-content pre {
|
|
background-color: rgba(0, 0, 0, 0.05);
|
|
padding: 0.5em;
|
|
border-radius: 4px;
|
|
overflow-x: auto;
|
|
}
|
|
|
|
.markdown-content code {
|
|
background-color: rgba(0, 0, 0, 0.05);
|
|
padding: 0.2em 0.4em;
|
|
border-radius: 3px;
|
|
font-size: 0.9em;
|
|
}
|
|
|
|
.markdown-content {
|
|
line-height: 1.5;
|
|
word-wrap: break-word;
|
|
}
|
|
|
|
.markdown-content table {
|
|
border-collapse: collapse;
|
|
margin: 0.75em 0;
|
|
width: 100%;
|
|
}
|
|
|
|
.markdown-content th,
|
|
.markdown-content td {
|
|
border: 1px solid #ddd;
|
|
padding: 6px 12px;
|
|
text-align: left;
|
|
}
|
|
|
|
.markdown-content blockquote {
|
|
border-left: 4px solid #ddd;
|
|
padding-left: 10px;
|
|
margin: 0.5em 0 0.5em 0.5em;
|
|
color: #666;
|
|
}
|
|
|
|
.markdown-content hr {
|
|
border: none;
|
|
border-top: 1px solid #ddd;
|
|
margin: 0.75em 0;
|
|
}
|
|
</style>
|
|
<script>
|
|
function initialize() {
|
|
marked.setOptions({
|
|
breaks: true, gfm: true, headerIds: false, mangle: false,
|
|
smartLists: true, smartypants: true, xhtml: false
|
|
});
|
|
}
|
|
|
|
// Render static markdown (any .markdown-content[data-content])
|
|
function renderStaticMarkdown() {
|
|
document.querySelectorAll('.markdown-content[data-content]').forEach(el => {
|
|
const raw = el.getAttribute('data-content') || '';
|
|
el.innerHTML = marked.parse(raw);
|
|
});
|
|
}
|
|
|
|
function scrollChatToBottom() {
|
|
console.log("scrolling chat");
|
|
const chatContainer = document.getElementById('chat_container');
|
|
console.log(chatContainer);
|
|
if (chatContainer) chatContainer.scrollTop = chatContainer.scrollHeight;
|
|
}
|
|
|
|
function processChatUi() {
|
|
initialize();
|
|
renderStaticMarkdown();
|
|
scrollChatToBottom();
|
|
}
|
|
|
|
document.addEventListener('DOMContentLoaded', processChatUi);
|
|
document.body.addEventListener('htmx:afterSettle', processChatUi);
|
|
</script>
|
|
{% endblock %} |