60 lines
1.4 KiB
Mathematica
60 lines
1.4 KiB
Mathematica
include "pages/page.wl"
|
|
|
|
let posts = $query("SELECT id, title, is_link, content, 0 as num_comments, CURRENT_TIMESTAMP as date FROM Posts")
|
|
|
|
if posts == none:
|
|
posts = []
|
|
|
|
let style =
|
|
<style>
|
|
.item {
|
|
overflow: auto;
|
|
border-bottom: 1px solid #E8D4A9;
|
|
font-size: 14px;
|
|
}
|
|
.item:last-child {
|
|
border-bottom: 0;
|
|
}
|
|
.item span {
|
|
color: #7A5F2A;
|
|
text-decoration: none;
|
|
}
|
|
.item div {
|
|
color: #E8D4A9;
|
|
float: left
|
|
}
|
|
.item div:first-child {
|
|
width: calc(100% - 250px);
|
|
}
|
|
.item div:last-child {
|
|
width: 250px;
|
|
text-align: right;
|
|
}
|
|
</style>
|
|
|
|
let main =
|
|
<main>
|
|
|
|
\if len(posts) == 0:
|
|
<div>There are no posts yet!</div>
|
|
|
|
\for post in posts: {
|
|
|
|
let link
|
|
if post.is_link != 0:
|
|
link = post.content
|
|
else
|
|
link = ["/post?id=", post.id]
|
|
|
|
<div class="item">
|
|
<div>
|
|
<a href=link>\post.title</a>
|
|
</div>
|
|
<div>
|
|
<span>\post.date</span> | <span><a href=link>\post.num_comments comments</a></span>
|
|
</div>
|
|
</div>
|
|
}
|
|
</main>
|
|
|
|
page("Index", $login_user_id, style, main) |