Merge branch 'main' of https://git.qwik.space/BurnyLlama/ddstats-server
This commit is contained in:
commit
724dadceb6
2
index.js
2
index.js
|
@ -21,13 +21,13 @@ const log = initLog("[ MAIN ]")
|
|||
// Read the .env file
|
||||
dotenv.config()
|
||||
|
||||
dbInit()
|
||||
setStat("startup", start)
|
||||
setStat("lastDBUpdate", start)
|
||||
|
||||
if (process.env.DOWNLOAD_FILES === "enabled")
|
||||
await downloadEssentialData()
|
||||
|
||||
dbInit()
|
||||
generateDB()
|
||||
|
||||
const Server = express()
|
||||
|
|
|
@ -373,7 +373,8 @@ export function searchMap(query, categories, stars, sortBy, order) {
|
|||
for(const map of maps) {
|
||||
output.push(prettyifyMap(map))
|
||||
}
|
||||
console.log(output)
|
||||
|
||||
return output
|
||||
}
|
||||
|
||||
export default {
|
||||
|
|
|
@ -12,6 +12,21 @@ routes.get(
|
|||
}
|
||||
)
|
||||
|
||||
routes.get(
|
||||
'/search',
|
||||
(req, res) => {
|
||||
const map = req.query.map ?? ""
|
||||
const categories = req.query.categories ? req.query.categories : "Novice,Moderate,Brutal,Insane,Dummy,DDmaX,Oldschool,Solo,Race,Fun"
|
||||
const stars = req.query.stars ? req.query.stars : "1,2,3,4,5"
|
||||
const sort = req.query.sortBy ? req.query.sortBy : "map"
|
||||
const order = req.query.order === "desc" ? "desc" : "asc"
|
||||
|
||||
const maps = wrapper.searchMap(map, categories.split(","), stars.split(","), sort, order)
|
||||
|
||||
tx(req, res)('pages/maps.njk', { maps }, true, { currentSection: "maps" })
|
||||
}
|
||||
)
|
||||
|
||||
routes.get(
|
||||
'/maps',
|
||||
(req, res) => {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
@use "partials/_settings.scss";
|
||||
@use "partials/_palette.scss";
|
||||
|
||||
* {
|
||||
*, *::before, *::after {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0 none transparent;
|
||||
|
@ -122,7 +122,6 @@ input {
|
|||
|
||||
margin: 1em 0;
|
||||
padding: .75em 1.25em;
|
||||
width: min(80ch, 80vw);
|
||||
|
||||
outline: 0 none transparent;
|
||||
border: .2rem solid transparent;
|
||||
|
@ -141,6 +140,101 @@ input {
|
|||
}
|
||||
}
|
||||
|
||||
button[type=submit] {
|
||||
margin: .75rem auto 1.25rem auto;
|
||||
padding: .15rem .5rem;
|
||||
|
||||
border: .1rem solid palette.$accent;
|
||||
border-radius: settings.$border_radius_s;
|
||||
|
||||
color: palette.$accent;
|
||||
background-color: transparent;
|
||||
|
||||
cursor: pointer;
|
||||
text-decoration: none transparent;
|
||||
transition: color .3s, background-color .3s;
|
||||
|
||||
&:hover {
|
||||
color: palette.$surface;
|
||||
background-color: palette.$accent;
|
||||
}
|
||||
}
|
||||
|
||||
label {
|
||||
cursor: pointer;
|
||||
margin: .25rem 0;
|
||||
|
||||
>input[type=radio] {
|
||||
// RESET
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
cursor: pointer;
|
||||
|
||||
margin: 0 .5rem -.25rem 1rem;
|
||||
padding: 0;
|
||||
width: 1.25rem;
|
||||
height: 1.25rem;
|
||||
|
||||
background-color: palette.$grey15;
|
||||
border: .25rem solid palette.$grey15;
|
||||
border-radius: 100%;
|
||||
|
||||
&:checked {
|
||||
border-color: palette.$primary;
|
||||
}
|
||||
}
|
||||
|
||||
&:hover>input[type=radio] {
|
||||
background-color: palette.$accent;
|
||||
}
|
||||
}
|
||||
|
||||
#search {
|
||||
display: grid;
|
||||
grid-template-columns: 2fr 1fr;
|
||||
grid-template-columns: repeat(auto, 4);
|
||||
grid-template-areas: 'header header'
|
||||
'map map'
|
||||
'category category'
|
||||
'stars sort'
|
||||
'submit submit';
|
||||
|
||||
width: min(90ch, 80vw);
|
||||
margin: 2rem 10vw;
|
||||
|
||||
>* {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
h1 {
|
||||
grid-area: header;
|
||||
}
|
||||
|
||||
#map {
|
||||
grid-area: map;
|
||||
}
|
||||
|
||||
#categories {
|
||||
grid-area: category;
|
||||
}
|
||||
|
||||
#stars {
|
||||
grid-area: stars;
|
||||
}
|
||||
|
||||
.sorting {
|
||||
grid-area: sort;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
button[type=submit] {
|
||||
grid-area: submit;
|
||||
width: max-content;
|
||||
margin: auto;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
|
|
|
@ -1 +1 @@
|
|||
*{margin:0;padding:0;border:0 none transparent;box-sizing:border-box;scroll-behavior:smooth;font-family:"Manrope Regular",sans-serif;font-size:1rem;line-height:1.5}html,body{color:#e0e0ff;background-color:#10102f;height:100%}nav{display:flex;align-items:center;background-color:#20203f;border-radius:0 0 2rem 2rem;box-shadow:.5rem 0 4rem #00001f;margin:0 0 2rem 0;padding:1rem 2rem}nav .logo{width:3rem;height:3rem;margin-right:2rem;border-radius:100%;background-color:#ee588f}nav a{color:#fba7c6;border-bottom:.1rem solid transparent;margin:.25rem 1rem .5rem 1rem;padding:.15rem .5rem .25rem .5rem;font-size:1.25rem;text-decoration:none transparent;transition:border .3s}nav a:hover{border-bottom:.1rem solid #fba7c6}nav a.current{color:#ee588f}nav a.current:hover{border-bottom:.1rem solid #ee588f}main.flex-container{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-around;margin:0 10vw}header,h1,h2,h3,h4,h5,h6{color:#fba7c6}header{font-size:4rem}h1{font-size:1.5rem;font-weight:normal}h2{font-size:1.35rem;font-weight:normal}h3{font-size:1.2rem;font-weight:normal}h4{font-size:1.05rem;font-weight:normal}h5{font-size:.9rem;font-weight:normal}a{color:#a3cefa}form{display:flex;flex-direction:column;justify-content:center;align-items:center}input{color:#e0e0ff;background-color:#20203f;margin:1em 0;padding:.75em 1.25em;width:min(80ch,80vw);outline:0 none transparent;border:.2rem solid transparent;border-radius:.5rem;box-shadow:.25rem 0 2rem #00001f;transition:border .3s,background-color .5s,border-radius .5s}input:hover{background-color:#30304f;border-radius:1rem}input:active,input:focus{border:.2rem solid #ee588f}tr{width:max-content}tr td{padding:.25rem 0;vertical-align:middle;width:max-content}tr td:first-child{padding:.25rem 1.5rem .25rem 0}footer{display:flex;flex-direction:column;align-items:center;margin:5vh 2rem}footer a{color:#74b6fb;font-size:.8rem}
|
||||
*,*::before,*::after{margin:0;padding:0;border:0 none transparent;box-sizing:border-box;scroll-behavior:smooth;font-family:"Manrope Regular",sans-serif;font-size:1rem;line-height:1.5}html,body{color:#e0e0ff;background-color:#10102f;height:100%}nav{display:flex;align-items:center;background-color:#20203f;border-radius:0 0 2rem 2rem;box-shadow:.5rem 0 4rem #00001f;margin:0 0 2rem 0;padding:1rem 2rem}nav .logo{width:3rem;height:3rem;margin-right:2rem;border-radius:100%;background-color:#ee588f}nav a{color:#fba7c6;border-bottom:.1rem solid transparent;margin:.25rem 1rem .5rem 1rem;padding:.15rem .5rem .25rem .5rem;font-size:1.25rem;text-decoration:none transparent;transition:border .3s}nav a:hover{border-bottom:.1rem solid #fba7c6}nav a.current{color:#ee588f}nav a.current:hover{border-bottom:.1rem solid #ee588f}main.flex-container{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-around;margin:0 10vw}header,h1,h2,h3,h4,h5,h6{color:#fba7c6}header{font-size:4rem}h1{font-size:1.5rem;font-weight:normal}h2{font-size:1.35rem;font-weight:normal}h3{font-size:1.2rem;font-weight:normal}h4{font-size:1.05rem;font-weight:normal}h5{font-size:.9rem;font-weight:normal}a{color:#a3cefa}form{display:flex;flex-direction:column;justify-content:center;align-items:center}input{color:#e0e0ff;background-color:#20203f;margin:1em 0;padding:.75em 1.25em;outline:0 none transparent;border:.2rem solid transparent;border-radius:.5rem;box-shadow:.25rem 0 2rem #00001f;transition:border .3s,background-color .5s,border-radius .5s}input:hover{background-color:#30304f;border-radius:1rem}input:active,input:focus{border:.2rem solid #ee588f}button[type=submit]{margin:.75rem auto 1.25rem auto;padding:.15rem .5rem;border:.1rem solid #fba7c6;border-radius:.5rem;color:#fba7c6;background-color:transparent;cursor:pointer;text-decoration:none transparent;transition:color .3s,background-color .3s}button[type=submit]:hover{color:#10102f;background-color:#fba7c6}label{cursor:pointer;margin:.25rem 0}label>input[type=radio]{-webkit-appearance:none;appearance:none;cursor:pointer;margin:0 .5rem -0.25rem 1rem;padding:0;width:1.25rem;height:1.25rem;background-color:#e0e0ff;border:.25rem solid #e0e0ff;border-radius:100%}label>input[type=radio]:checked{border-color:#ee588f}label:hover>input[type=radio]{background-color:#fba7c6}#search{display:grid;grid-template-columns:2fr 1fr;grid-template-columns:repeat(auto, 4);grid-template-areas:"header header" "map map" "category category" "stars sort" "submit submit";width:min(90ch,80vw);margin:2rem 10vw}#search>*{width:100%}#search h1{grid-area:header}#search #map{grid-area:map}#search #categories{grid-area:category}#search #stars{grid-area:stars}#search .sorting{grid-area:sort;display:flex;flex-direction:column}#search button[type=submit]{grid-area:submit;width:max-content;margin:auto}tr{width:max-content}tr td{padding:.25rem 0;vertical-align:middle;width:max-content}tr td:first-child{padding:.25rem 1.5rem .25rem 0}footer{display:flex;flex-direction:column;align-items:center;margin:5vh 2rem}footer a{color:#74b6fb;font-size:.8rem}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
<form action="/search" method="get">
|
||||
<h1>Search for a player or map...</h1>
|
||||
<input type="text" name="q" placeholder="Yumiko, Hitode, ...">
|
||||
<input type="text" name="map" placeholder="Yumiko, Hitode, ...">
|
||||
</form>
|
||||
</main>
|
||||
{% endblock %}
|
|
@ -8,6 +8,26 @@
|
|||
|
||||
{% block body %}
|
||||
<main class="flex-container">
|
||||
<form action="/search" method="get" id="search">
|
||||
<h1>Search</h1>
|
||||
<input type="text" name="map" id="map" placeholder="Map name">
|
||||
<input type="text" name="categories" id="categories" placeholder="Category">
|
||||
<input type="text" name="stars" id="stars" placeholder="Star amount">
|
||||
|
||||
<div class="sorting">
|
||||
<label for="asc">
|
||||
<input type="radio" name="sortBy" id="asc" value="asc">
|
||||
Sort Ascending
|
||||
</label>
|
||||
<label for="desc">
|
||||
<input type="radio" name="sortBy" id="desc" value="desc">
|
||||
Sort Descending
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<button type="submit">Search!</button>
|
||||
</form>
|
||||
|
||||
{% for map in data.maps %}
|
||||
{{ mapComponent.card(map) }}
|
||||
{% endfor %}
|
||||
|
|
Loading…
Reference in New Issue
Block a user