some fixes

This commit is contained in:
doesnm 2024-10-29 15:50:40 +03:00
parent 2792f8dcfa
commit 94df3810ec
Signed by: doesnm
SSH key fingerprint: SHA256:fSXBOeK0SXxGqmbQ2pKhSvH3TF0kCijXZfzh3gHfQYM
2 changed files with 17 additions and 2 deletions

14
blog.js
View file

@ -27,11 +27,13 @@ if(post.type != "m.room.message") return false;
let body = DOMPurify.sanitize(post.content.formatted_body ?? post.content.body);
body = body.split("\n").join("<br>");
// body = body.replace(/mxc\:\/\//, "https://matrix.org/_matrix/media/v3/download/")
table.innerHTML += `<tr><td><b>${post.sender}</b><br>${body}${post.content.msgtype == "m.image" ? `<br><img src="https://matrix.org/_matrix/media/v3/download/${post.content.url.slice(6)}">` : ''}${getReactions(posts,post)}${!noButton ? `<br><a href="#${roomId}/${post.event_id}">Открыть</a>` : ''}</td></tr>`;
}
function loadPosts(roomId,start){
const ignored_events = [];
posts = [];
table.innerHTML = `<tr><th>Контент</th></tr>`;
if(posts.length < 1 || start != undefined){
fetch("https://matrix.org/_matrix/client/v3/rooms/" + encodeURIComponent(roomId) + "/messages?limit=50&access_token=" + localStorage.access_token + (start ? `&from=${start}`: '') + "&dir=b").then(r => r.json()).then(json => {
@ -97,7 +99,17 @@ table.innerHTML = `<tr><th>Контент</th></tr>`;
}
});
}else{
table.innerHTML = '<tr><th>Добро пожаловать</th></tr><tr><td>Это блог работающий поверх децентрализованного мессенджера Matrix</td></tr>'
table.innerHTML = `
<tr><th>Добро пожаловать</th></tr>
<tr><td>Это блог работающий поверх децентрализованного мессенджера Matrix</td></tr>
<tr><td>
Известные блоги:
<ul>
<li><a href="#zero_blog:matrix.org">Блог Zero</a></li>
<li><a href="#ego-oqo:envs.net">Блог EGO</a></li>
</ul>
</td></tr>
`;
}
}
window.addEventListener("load", () => {

View file

@ -4,6 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Blog powered by Matrix">
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
<title>Blog</title>
</head>
<body>
@ -11,11 +12,13 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/dompurify/3.0.6/purify.min.js" integrity="sha512-H+rglffZ6f5gF7UJgvH4Naa+fGCgjrHKMgoFOGmcPTRwR6oILo5R+gtzNrpDp7iMV3udbymBVjkeZGNz1Em4rQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="blog.js"></script>
<style>
tr {
tr, article, p {
white-space: normal;
overflow-wrap: break-word;
text-wrap: break-word;
word-break: break-word;
}
</style>
</body>
</html>