song uploading is now properly disableable

This commit is contained in:
Jill 2023-01-05 20:13:05 +03:00
parent 94c8cdf463
commit c029f7a0d2
3 changed files with 12 additions and 6 deletions

View File

@ -22,8 +22,8 @@
<%- end -%>
<form action="/tools/reupload" method="post">
ID: <input type="text" id="level_id" name="level_id" disabled="<%= disabled ? "1" : "" %>" />
<input type="submit" value="Submit" disabled="<%= disabled ? "1" : "" %>" />
ID: <input type="text" id="level_id" name="level_id" <%= disabled ? "disabled" : "" %> />
<input type="submit" value="Submit" <%= disabled ? "disabled" : "" %> />
</form>
<br>
<i>Currently only vanilla servers are supported</i>

View File

@ -15,10 +15,14 @@
<%- elsif song_id -%>
<div>Uploaded successfully! Song ID: <b><%= song_id %></b></div><br />
<%- end -%>
<%- if disabled -%>
<b>Custom songs have been disabled</b><br><br>
<%- end -%>
<form action="/tools/song_upload" method="post">
URL: <input type="text" id="url" name="url" />
<input type="submit" value="Submit" />
URL: <input type="text" id="url" name="url" <%= disabled ? "disabled" : "" %> />
<input type="submit" value="Submit" <%= disabled ? "disabled" : "" %> />
</form>
</body>
</html>

View File

@ -20,10 +20,12 @@ end
CrystalGauntlet.template_endpoints["/tools/song_upload"] = ->(context : HTTP::Server::Context) {
context.response.content_type = "text/html"
disabled = !(config_get("songs.allow_custom_songs").as?(Bool))
error = nil
song_id = nil
body = context.request.body
if body
if body && !disabled
begin
params = URI::Params.parse(body.gets_to_end)
song_id = get_next_song_id()