-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
234 lines (211 loc) · 11.1 KB
/
index.html
File metadata and controls
234 lines (211 loc) · 11.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1252">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML-Chan</title>
<link rel="stylesheet" href="index/style.css?v=4">
<style>
/* Принудительно задаём flex-схему для прижатия футера */
html, body {
height: 100% !important;
margin: 0 !important;
padding: 0 !important;
}
body {
display: flex !important;
flex-direction: column !important;
}
.main-wrapper {
flex: 1 0 auto !important;
}
.site-footer {
flex-shrink: 0 !important;
}
/* Скрываем стандартную ссылку-заглушку комментариев */
#HCB_comment_box a[href="http://www.htmlcommentbox.com"] {
display: none !important;
}
.hcb-icon[alt="rss"] {
display: none !important;
}
/* Дополнительные стили для списка тредов */
.post-meta {
font-size: 0.9em;
color: #654;
margin-bottom: 5px;
}
.reply-count {
margin-top: 5px;
font-size: 0.9em;
color: #876;
}
.error {
color: red;
font-weight: bold;
}
</style>
</head>
<body>
<!-- Header -->
<header class="site-header">
<div class="header-content">
<div class="header-nav">
<nav>
<ul>
<li><a href="https://your_url.com/index.html">/index/</a></li>
<li><a href="https://your_url.com/boards/b/index.html">/b/</a></li>
<li><a href="https://your_url.com/boards/a/index.html">/a/</a></li>
<li><a href="https://your_url.com/boards/dev/index.html">/dev/</a></li>
<li><a href="https://your_url.com/boards/g/index.html">/g/</a></li>
<li><a href="https://your_url.com/boards/v/index.html">/v/</a></li>
<li><a href="https://your_url.com/boards/r/index.html">/r/</a></li>
</ul>
</nav>
</div>
</div>
</header>
<!-- Основной контент -->
<div class="main-wrapper">
<div class="container">
<div class="left">
<div class="hotanimegirl">
<img src="index/nekoz.webp" alt="Anime Girl">
</div>
<div class="navbar">
<ul> <li><a href="https://your_url.com/index.html">/index/</a></li> </ul>
<ul> <li><a href="https://your_url.com/boards/b/index.html">/b/</a></li> </ul>
<ul> <li><a href="https://your_url.com/boards/a/index.html">/a/</a></li> </ul>
<ul> <li><a href="https://your_url.com/boards/dev/index.html">/dev/</a></li> </ul>
<ul> <li><a href="https://your_url.com/boards/g/index.html">/g/</a></li> </ul>
<ul> <li><a href="https://your_url.com/boards/v/index.html">/v/</a></li> </ul>
<ul> <li><a href="https://your_url.com/boards/r/index.html">/r/</a></li> </ul>
</div>
</div>
<div class="center">
<div class="banner"><!-- no image here >:) --></div>
<div class="main">
<h1>NekoChan</h1>
<p>An imageboard hosted on NekoWeb with Supabase.</p>
<p>It was created just for fun. It works on NeoCities/NekoWeb.</p>
<p>It's very messsy and shitty rn, but will be updated</p>
<h2>Latest Threads</h2>
<div id="threads-list">Загрузка...</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2"></script>
<script>
const supabaseClient = window.supabase.createClient(
"https://<your_project>.supabase.co",
"<your_key>"
);
async function loadThreads() {
const container = document.getElementById("threads-list");
container.innerHTML = "Загрузка...";
// 1. Загружаем все треды (без фильтра по доске)
const { data: threads, error } = await supabaseClient
.from("threads")
.select("*")
.order("created_at", { ascending: false })
.limit(50); // можно увеличить лимит
if (error) {
console.error(error);
container.innerHTML = "<p class='error'>Ошибка загрузки тредов.</p>";
return;
}
if (!threads || threads.length === 0) {
container.innerHTML = "<p>Пока нет тредов. Создайте первый!</p>";
return;
}
// 2. Получаем ID всех тредов
const threadIds = threads.map(t => t.id);
// 3. Загружаем все посты (ответы) для этих тредов
const { data: allPosts, error: postsError } = await supabaseClient
.from('posts')
.select('thread_id, created_at')
.in('thread_id', threadIds);
if (postsError) {
console.error(postsError);
// Если ошибка, продолжаем без статистики
}
// 4. Строим статистику по каждому треду
const statsMap = {};
if (allPosts) {
allPosts.forEach(post => {
if (!statsMap[post.thread_id]) {
statsMap[post.thread_id] = { count: 0, last: null };
}
statsMap[post.thread_id].count++;
const postDate = new Date(post.created_at);
if (!statsMap[post.thread_id].last || postDate > statsMap[post.thread_id].last) {
statsMap[post.thread_id].last = postDate;
}
});
}
// 5. Объединяем данные и вычисляем дату бампа
const threadsWithStats = threads.map(thread => {
const stats = statsMap[thread.id] || { count: 0, last: null };
const threadDate = new Date(thread.created_at);
const bumpDate = stats.last && stats.last > threadDate ? stats.last : threadDate;
return {
...thread,
reply_count: stats.count,
last_reply: stats.last,
bump_date: bumpDate
};
});
// 6. Сортируем по bump_date (от новых к старым)
threadsWithStats.sort((a, b) => b.bump_date - a.bump_date);
// 7. Отрисовываем
container.innerHTML = "";
threadsWithStats.forEach(thread => {
const div = document.createElement("div");
div.style.marginBottom = "15px";
// Определяем доску (если поле отсутствует, ставим 'b' как запасной вариант)
const board = thread.board || 'b';
const threadUrl = `/boards/${board}/thread.html?id=${thread.id}`;
const author = thread.author || 'Anon';
const posterId = thread.poster_id ?? '?';
const replyCount = thread.reply_count;
const lastActivity = thread.bump_date.toLocaleString();
div.innerHTML = `
<div style="background: rgba(240,224,214,0.7); padding:10px; border:2px solid #ea8;">
<div class="post-meta">
<strong>${escapeHtml(author)}</strong>
<span>ID: ${escapeHtml(posterId)}</span>
<span>Доска: /${escapeHtml(board)}/</span>
<span>Создан: ${new Date(thread.created_at).toLocaleString()}</span>
</div>
<a href="${threadUrl}">
<strong>${escapeHtml(thread.title)}</strong>
</a>
<br>
${thread.image_url ? `<img src="${thread.image_url}" style="max-width:200px;margin-top:5px;">` : ""}
<div class="reply-count">
Ответов: ${replyCount} | Последняя активность: ${lastActivity}
</div>
</div>
`;
container.appendChild(div);
});
}
function escapeHtml(text) {
if (text === undefined || text === null) return '';
const div = document.createElement("div");
div.textContent = text;
return div.innerHTML;
}
// Загружаем треды при старте
loadThreads();
</script>
</div>
</div>
</div>
<!-- Footer -->
<footer class="site-footer">
<div class="footer-content">
<p><a href="https://your_url.com/rules.html">Rules</a> | <a href="https://your_url.com/faq.html">FAQ</a> | <a href="https://your_url.com/contact.html">Contact</a></p>
<p>HTML-Chan v0.1</p>
</div>
</footer>
</body>
</html>