comments & level page polish

This commit is contained in:
Jill 2023-05-26 11:21:04 +03:00
parent dc6d5767bb
commit 344edf369c
Signed by: oat
GPG Key ID: 33489AA58A955108
3 changed files with 65 additions and 5 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -73,6 +73,11 @@
.label-right {
flex: 0 0 auto;
}
.label-right img {
height: 1em;
width: auto;
vertical-align: middle;
}
.card-header {
font-weight: bold;
color: var(--text-color-dark);
@ -132,7 +137,15 @@
width: 75px;
}
.leaderboard td.coins {
width: 3em;
width: 4em;
}
.leaderboard td.coins .coin-container {
display: flex;
flex-direction: row;
}
.leaderboard td.coins .coin-container img {
width: 1em;
height: auto;
}
.leaderboard td.icon {
width: 2.5em;
@ -149,6 +162,27 @@
width: auto;
vertical-align: middle;
}
.comment {
flex-direction: column;
}
.comment-author {
display: flex;
flex-direction: row;
gap: 1ex;
align-items: center;
}
.comment-author .player-icon {
height: 1.5em;
width: auto;
}
.comment-date {
color: var(--text-color-dark);
}
.comment-author-label {
font-weight: bold;
text-decoration: none;
}
</style>
</head>
<body>
@ -173,7 +207,7 @@
<%= name %>
</div>
<div class="label-right">
<%= downloads %> downloads <%= likes %> likes
<%= downloads %> <img src="/assets/icons/gd/download.png"> <%= likes %> <img src="/assets/icons/gd/like.png">
</div>
</div>
<div class="card-bottom">
@ -231,7 +265,13 @@
<tr>
<td class="rank">#<%= rank %></td>
<td class="percent"><%= percent %>%</td>
<td class="coins"></td>
<td class="coins">
<div class="coin-container">
<%- coins.times do |i| -%>
<img src="/assets/icons/gd/<%= rated_coins ? "silvercoin" : "browncoin" %>.png">
<%- end -%>
</div>
</td>
<td class="icon">
<img src="https://gdicon.oat.zone/icon.png?type=<%=type_str%>&value=<%=icon_value%>&color1=<%=color1%>&color2=<%=color2%><%=special ? "&glow=1" : ""%>" class="player-icon">
</td>
@ -252,7 +292,25 @@
<%- end -%>
</table>
<p>comments go here etc etc</p>
<h3>Comments</h3>
<%- comments.each do |comment, created_at, username, icon_type, color1, color2, cube, ship, ball, ufo, wave, robot, spider, special|
icon_value = [cube, ship, ball, ufo, wave, robot, spider][icon_type]
type_str = ["cube", "ship", "ball", "ufo", "wave", "robot", "spider"][icon_type]
created_at_date = Time.parse(created_at, Format::TIME_FORMAT, Time::Location::UTC)
%>
<div class="card comment">
<div class="comment-author">
<img src="https://gdicon.oat.zone/icon.png?type=<%=type_str%>&value=<%=icon_value%>&color1=<%=color1%>&color2=<%=color2%><%=special ? "&glow=1" : ""%>" class="player-icon">
<a class="comment-author-label" href="/user/<%= username %>"><%= username %></a>
<time class="comment-date" datetime="<%= Time::Format::RFC_3339.format(created_at_date) %>" title="<%= Time::Format::RFC_2822.format(created_at_date) %>"><%= Format.fmt_timespan(Time.utc - created_at_date) %> ago</time>
</div>
<div>
<%= HTML.escape(comment) %>
</div>
</div>
<%- end -%>
</body>
</html>

View File

@ -25,7 +25,7 @@ CrystalGauntlet.template_endpoints[{
id = params["id"].as(String).to_i
begin
name, username, difficulty_community, difficulty_set, demon_difficulty_int, featured, epic, downloads, likes, stars, description, song_id, song_name, song_author, song_url, song_author_url = DATABASE.query_one("select levels.name, users.username, community_difficulty, difficulty, demon_difficulty, featured, epic, downloads, likes, levels.stars, description, song_id, song_data.name, song_authors.name, songs.url, song_authors.source from levels left join users on levels.user_id = users.id left join songs on songs.id = levels.song_id left join song_data on song_data.id = levels.song_id left join song_authors on song_data.author_id = song_authors.id where levels.id = ?", id, as: {String, String, Int32?, Int32?, Int32?, Bool, Bool, Int32, Int32, Int32?, String, Int32, String?, String?, String?, String?})
name, username, difficulty_community, difficulty_set, demon_difficulty_int, featured, epic, rated_coins, downloads, likes, stars, description, song_id, song_name, song_author, song_url, song_author_url = DATABASE.query_one("select levels.name, users.username, community_difficulty, difficulty, demon_difficulty, featured, epic, rated_coins, downloads, likes, levels.stars, description, song_id, song_data.name, song_authors.name, songs.url, song_authors.source from levels left join users on levels.user_id = users.id left join songs on songs.id = levels.song_id left join song_data on song_data.id = levels.song_id left join song_authors on song_data.author_id = song_authors.id where levels.id = ?", id, as: {String, String, Int32?, Int32?, Int32?, Bool, Bool, Bool, Int32, Int32, Int32?, String, Int32, String?, String?, String?, String?})
rescue err
LOG.error {"whar.... #{err}"}
context.response.status = HTTP::Status::NOT_FOUND
@ -34,5 +34,7 @@ CrystalGauntlet.template_endpoints[{
scores = DATABASE.query_all("select distinct percent, level_scores.coins, users.username, users.icon_type, users.color1, users.color2, users.cube, users.ship, users.ball, users.ufo, users.wave, users.robot, users.spider, users.special, set_at from level_scores join users on level_scores.account_id = users.account_id where level_id = ? order by percent desc, level_scores.coins desc, set_at limit 25", id, as: {Int32, Int32, String, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, String})
comments = DATABASE.query_all("select comment, comments.created_at, users.username, users.icon_type, users.color1, users.color2, users.cube, users.ship, users.ball, users.ufo, users.wave, users.robot, users.spider, users.special from comments left join users on comments.user_id = users.id where level_id = ? order by comments.created_at asc limit 20", id, as: {String, String, String, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32})
ECR.embed("./public/template/level.ecr", context.response)
}