diff --git a/public/style.css b/public/style.css index 1578744..1a014ce 100644 --- a/public/style.css +++ b/public/style.css @@ -78,4 +78,15 @@ a:hover { pre { display: inline; font-family: monospace; +} + +.dir-header { + background-color: rgba(150, 150, 150, 0.15); + color: #999; + padding: 0.5em; + border-radius: 12px; + line-height: 1.2; +} +.dir-header a { + text-decoration: none; } \ No newline at end of file diff --git a/public/template/account_management.ecr b/public/template/account_management.ecr new file mode 100644 index 0000000..a4d22ba --- /dev/null +++ b/public/template/account_management.ecr @@ -0,0 +1,14 @@ + + + + + + + + Account Management + + +

Account Management

+ hewwo + + diff --git a/public/template/index.ecr b/public/template/index.ecr index 30b4852..6a10520 100644 --- a/public/template/index.ecr +++ b/public/template/index.ecr @@ -42,8 +42,6 @@

-
- Crystal <%= Crystal::VERSION %>
<%= Crystal::BUILD_COMMIT %>
running on
<%= System.hostname %>
for <%= CrystalGauntlet.uptime_s %> -
+ <%= Templates.footer %> diff --git a/public/template/reupload.ecr b/public/template/reupload.ecr index 61fb00b..7bae1ff 100644 --- a/public/template/reupload.ecr +++ b/public/template/reupload.ecr @@ -7,7 +7,10 @@ Level Reupload - + + <%= Templates.dir_header %> +

Level Reupload

+ <%- if error -%>
Error while uploading: <%= error %>

<%- elsif level_id -%> @@ -18,6 +21,7 @@ ID: +
Currently only vanilla servers are supported diff --git a/public/template/song_search.ecr b/public/template/song_search.ecr index 6b23974..808f191 100644 --- a/public/template/song_search.ecr +++ b/public/template/song_search.ecr @@ -7,7 +7,10 @@ Song Search - + + <%= Templates.dir_header %> +

Song Search

+
ID/Author/Title: diff --git a/public/template/song_upload.ecr b/public/template/song_upload.ecr index 1acfd96..149fbd2 100644 --- a/public/template/song_upload.ecr +++ b/public/template/song_upload.ecr @@ -7,7 +7,9 @@ Song Uploader - + + <%= Templates.dir_header %> +

Song Upload

<%- if error -%>
Error while uploading: <%= error %>

<%- elsif song_id -%> diff --git a/src/crystal-gauntlet.cr b/src/crystal-gauntlet.cr index 7457c7b..4eb5373 100644 --- a/src/crystal-gauntlet.cr +++ b/src/crystal-gauntlet.cr @@ -20,6 +20,7 @@ require "./lib/songs" require "./lib/ids" require "./lib/level" require "./lib/dailies" +require "./lib/templates" if File.exists?(".env") Dotenv.load diff --git a/src/lib/templates.cr b/src/lib/templates.cr new file mode 100644 index 0000000..6dd0999 --- /dev/null +++ b/src/lib/templates.cr @@ -0,0 +1,16 @@ +module CrystalGauntlet::Templates + extend self + + macro dir_header() + path_split = context.request.path.split('/') + "
" + path_split.map_with_index { |v, i| "#{i == 0 ? "crystal-gauntlet" : v}"}.join(" / ") + "
" + end + + def footer() + %( +
+ Crystal #{Crystal::VERSION}
#{Crystal::BUILD_COMMIT}
running on
#{System.hostname}
for #{CrystalGauntlet.uptime_s} +
+ ) + end +end diff --git a/src/template_endpoints/account_management.cr b/src/template_endpoints/account_management.cr new file mode 100644 index 0000000..e5371ee --- /dev/null +++ b/src/template_endpoints/account_management.cr @@ -0,0 +1,14 @@ +require "uri" +require "compress/gzip" + +include CrystalGauntlet + +CrystalGauntlet.template_endpoints["/#{config_get("general.append_path").as(String | Nil) || ""}accounts/accountManagement.php"] = ->(context : HTTP::Server::Context) { + context.response.headers.add("Location", "/accounts/") + context.response.status = HTTP::Status::MOVED_PERMANENTLY +} + +CrystalGauntlet.template_endpoints["/accounts"] = ->(context : HTTP::Server::Context) { + context.response.content_type = "text/html" + ECR.embed("./public/template/account_management.ecr", context.response) +} diff --git a/src/template_endpoints/index.cr b/src/template_endpoints/index.cr index f246413..25e038c 100644 --- a/src/template_endpoints/index.cr +++ b/src/template_endpoints/index.cr @@ -2,6 +2,11 @@ require "ecr" include CrystalGauntlet +CrystalGauntlet.template_endpoints["/tools"] = ->(context : HTTP::Server::Context) { + context.response.headers.add("Location", "/") + context.response.status = HTTP::Status::TEMPORARY_REDIRECT +} + CrystalGauntlet.template_endpoints[""] = ->(context : HTTP::Server::Context) { context.response.content_type = "text/html" ECR.embed("./public/template/index.ecr", context.response)