Skip to content

Commit

Permalink
feat: Add button to open counter folder
Browse files Browse the repository at this point in the history
  • Loading branch information
cyperdark authored and KotRikD committed Feb 28, 2024
1 parent b5c9dc0 commit f7f3d7a
Show file tree
Hide file tree
Showing 2 changed files with 373 additions and 2 deletions.
327 changes: 326 additions & 1 deletion packages/server/assets/homepage.min.css
Original file line number Diff line number Diff line change
@@ -1 +1,326 @@
:root{--text-1: #647a91;--text-links: #6593c5;--background-1: #191e25;--block-1: #242d37;--block-on-block: 211.25deg, 75.28%, 68.43%;--block-color-1: #97a7b9;--button-download: #568cc7;--button-delete: #d57397;--button-open: #73a6d5;--submit-delete: #56c763;--notification-block-green: #56c763;--notification-color-green: #191e25;--notification-block-red: #d57397;--notification-color-red: #191e25;--search-color-2: #707f8d;--search-color-1: #cbd8e5;--search-block: #3f4e5d}*{position:relative;padding:0;margin:0;box-sizing:border-box;min-width:0}::-moz-selection{color:var(--background-1);background-color:var(--text-links)}::selection{color:var(--background-1);background-color:var(--text-links)}::-webkit-scrollbar{width:16px}::-webkit-scrollbar-thumb{background-color:var(--text-links);border-radius:.2em}button{font-size:1em;font-family:inherit;font-weight:inherit;font-style:inherit;border:0;outline:0}img{display:flex}body{font-size:20px;font-family:"Roboto",sans-serif;font-weight:400;font-style:normal;justify-content:center;flex-direction:column;display:flex;max-width:min(1280px,100vw - 2em);min-height:100vh !important;color:var(--text-1);margin:0 auto;background:var(--background-1);overflow-x:hidden}iframe{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}main{display:grid;min-height:0;margin-top:1em;margin-bottom:3em}footer{text-align:center;font-size:.8em;position:sticky;bottom:0;padding:.6em 0;margin-top:auto}footer::before{content:"";pointer-events:none;-webkit-mask-image:linear-gradient(0deg, black 0%, transparent 100%);mask-image:linear-gradient(0deg, black 0%, transparent 100%);position:absolute;height:7em;left:0;right:0;bottom:0;background:var(--background-1);z-index:0}footer>*{z-index:1}a{color:var(--text-links)}.flexer{justify-content:flex-start;align-items:center;display:flex;flex-wrap:wrap}.tabs{justify-content:center;position:sticky;top:1em;width:calc(100% - 1.5em);margin:0 auto;gap:1em;z-index:1}.tabs .tab-item{cursor:pointer;color:var(--text-1);padding:.4em .6em;text-decoration:underline;text-underline-position:under;text-decoration-thickness:1px;text-decoration-color:rgba(0,0,0,0);text-underline-offset:.3em;transition:.1s ease;transition-property:color,text-decoration-color}.tabs .tab-item.active{color:var(--text-links);text-decoration-color:var(--text-links)}.tabs::before{content:"";position:absolute;top:-2em;left:-3em;right:-3em;bottom:0;background:var(--background-1)}.indent-left{margin-left:auto}.results{display:grid;gap:.5em}.no-results{text-align:center;width:100%;margin:2em 0}.result-item{display:grid;gap:.8em;color:var(--block-color-1);padding:1em;background:var(--block-1);border-radius:.3em}.result-item hr{border-color:var(--background-1)}.result-item .ri-gallery{gap:.4em}.result-item .ri-gallery img{height:7.5em;border-radius:.4em}.result-item .ri-links{font-size:.9em;gap:.4em;margin-top:.4em}.result-item .ri-links img{height:1.2em;border-radius:.2em}.result-item .ri-footer{font-size:.9em;gap:1em}.copyable{-webkit-user-select:none;-moz-user-select:none;user-select:none;cursor:pointer;padding:.1em .2em;background:hsl(var(--block-on-block), 0.2);transition:.5s ease;transition-property:background,filter;border-radius:.2em}.copyable:active{filter:brightness(2);background:hsl(var(--block-on-block), 0.4);transition:.1s ease}.notification{font-size:.8em;font-weight:bold;position:absolute;left:50%;bottom:2em;padding:.5em 1.6em;translate:0 0;box-shadow:0 .7em 1.2em rgba(0,0,0,.7);transition:.3s ease;transition-property:translate,opacity;border-radius:.3em}.notification.hidden{opacity:0;translate:0 1em}.notification.red{color:var(--notification-color-red);background:var(--notification-block-red)}.notification.green{color:var(--notification-color-green);background:var(--notification-block-green)}@keyframes spin{0%{rotate:0}100%{rotate:360deg}}.button{text-decoration:none;font-size:.9em;font-weight:700;cursor:pointer;padding:.4em 1em;border-radius:.4em;transition:.1s ease;transition-property:translate,filter}.button span{display:block;pointer-events:none;transition:.3s ease;transition-property:opacity,width}.button img{width:1em;height:1em;-o-object-fit:cover;object-fit:cover;transition:.3s ease;transition-property:opacity,width,height;animation:spin 1s infinite forwards linear}.button:hover{filter:brightness(1.1);translate:0 -0.05em}.button:active{filter:brightness(0.9);translate:0 .1em}.button.disable{-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:none;filter:grayscale(1)}.buttons-group{font-size:.9em;gap:10px}.dl-button{color:var(--background-1);background:var(--button-download)}.delete-button{color:var(--background-1);background:var(--button-delete)}.open-button{color:var(--background-1);background:var(--button-open)}.submit-button{display:block;color:var(--background-1);padding:.2em 1em;background:var(--submit-delete)}.search-bar{font-size:.9em;font-family:inherit;color:var(--search-color-1);background:var(--search-block);padding:.2em .6em;border-radius:.2em;outline:0;border:0;transition:.2s ease;transition-property:filter,opacity}.search-bar::-moz-placeholder{color:var(--search-color-2)}.search-bar::placeholder{color:var(--search-color-2)}.search-bar.disable{-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:none;filter:grayscale(1);opacity:.5}
:root {
--text-1: #647a91;
--text-links: #6593c5;
--background-1: #191e25;
--block-1: #242d37;
--block-on-block: 211.25deg, 75.28%, 68.43%;
--block-color-1: #97a7b9;
--button-download: #568cc7;
--button-delete: #d57397;
--button-open: #73a6d5;
--submit-delete: #56c763;
--notification-block-green: #56c763;
--notification-color-green: #191e25;
--notification-block-red: #d57397;
--notification-color-red: #191e25;
--search-color-2: #707f8d;
--search-color-1: #cbd8e5;
--search-block: #3f4e5d;
}
* {
position: relative;
padding: 0;
margin: 0;
box-sizing: border-box;
min-width: 0;
}
::-moz-selection {
color: var(--background-1);
background-color: var(--text-links);
}
::selection {
color: var(--background-1);
background-color: var(--text-links);
}
::-webkit-scrollbar {
width: 16px;
}
::-webkit-scrollbar-thumb {
background-color: var(--text-links);
border-radius: 0.2em;
}
button {
font-size: 1em;
font-family: inherit;
font-weight: inherit;
font-style: inherit;
border: 0;
outline: 0;
}
img {
display: flex;
}
body {
font-size: 20px;
font-family: 'Roboto', sans-serif;
font-weight: 400;
font-style: normal;
justify-content: center;
flex-direction: column;
display: flex;
max-width: min(1280px, 100vw - 2em);
min-height: 100vh !important;
color: var(--text-1);
margin: 0 auto;
background: var(--background-1);
overflow-x: hidden;
}
iframe {
pointer-events: none;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
main {
display: grid;
min-height: 0;
margin-top: 1em;
margin-bottom: 3em;
}
footer {
text-align: center;
font-size: 0.8em;
position: sticky;
bottom: 0;
padding: 0.6em 0;
margin-top: auto;
}
footer::before {
content: '';
pointer-events: none;
-webkit-mask-image: linear-gradient(0deg, black 0%, transparent 100%);
mask-image: linear-gradient(0deg, black 0%, transparent 100%);
position: absolute;
height: 7em;
left: 0;
right: 0;
bottom: 0;
background: var(--background-1);
z-index: 0;
}
footer > * {
z-index: 1;
}
a {
color: var(--text-links);
}
.flexer {
justify-content: flex-start;
align-items: center;
display: flex;
flex-wrap: wrap;
}
.tabs {
justify-content: center;
position: sticky;
top: 1em;
width: calc(100% - 1.5em);
margin: 0 auto;
gap: 1em;
z-index: 1;
}
.tabs .tab-item {
cursor: pointer;
color: var(--text-1);
padding: 0.4em 0.6em;
text-decoration: underline;
text-underline-position: under;
text-decoration-thickness: 1px;
text-decoration-color: rgba(0, 0, 0, 0);
text-underline-offset: 0.3em;
transition: 0.1s ease;
transition-property: color, text-decoration-color;
}
.tabs .tab-item.active {
color: var(--text-links);
text-decoration-color: var(--text-links);
}
.tabs::before {
content: '';
position: absolute;
top: -2em;
left: -3em;
right: -3em;
bottom: 0;
background: var(--background-1);
}
.indent-left {
margin-left: auto;
}
.results {
display: grid;
gap: 0.5em;
}
.no-results {
text-align: center;
width: 100%;
margin: 2em 0;
}
.result-item {
display: grid;
gap: 0.8em;
color: var(--block-color-1);
padding: 1em;
background: var(--block-1);
border-radius: 0.3em;
}
.result-item hr {
border-color: var(--background-1);
}
.result-item .ri-gallery {
gap: 0.4em;
}
.result-item .ri-gallery img {
height: 7.5em;
border-radius: 0.4em;
}
.result-item .ri-links {
font-size: 0.9em;
gap: 0.4em;
margin-top: 0.4em;
}
.result-item .ri-links img {
height: 1.2em;
border-radius: 0.2em;
}
.result-item .ri-footer {
font-size: 0.9em;
gap: 1em;
}
.copyable {
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
cursor: pointer;
padding: 0.1em 0.2em;
background: hsl(var(--block-on-block), 0.2);
transition: 0.5s ease;
transition-property: background, filter;
border-radius: 0.2em;
}
.copyable:active {
filter: brightness(2);
background: hsl(var(--block-on-block), 0.4);
transition: 0.1s ease;
}
.notification {
font-size: 0.8em;
font-weight: bold;
position: absolute;
left: 50%;
bottom: 2em;
padding: 0.5em 1.6em;
translate: 0 0;
box-shadow: 0 0.7em 1.2em rgba(0, 0, 0, 0.7);
transition: 0.3s ease;
transition-property: translate, opacity;
border-radius: 0.3em;
}
.notification.hidden {
opacity: 0;
translate: 0 1em;
}
.notification.red {
color: var(--notification-color-red);
background: var(--notification-block-red);
}
.notification.green {
color: var(--notification-color-green);
background: var(--notification-block-green);
}
@keyframes spin {
0% {
rotate: 0;
}
100% {
rotate: 360deg;
}
}
.button {
text-decoration: none;
font-size: 0.9em;
font-weight: 700;
cursor: pointer;
padding: 0.4em 1em;
border-radius: 0.4em;
transition: 0.1s ease;
transition-property: translate, filter;
}
.button span {
display: block;
pointer-events: none;
transition: 0.3s ease;
transition-property: opacity, width;
}
.button img {
width: 1em;
height: 1em;
-o-object-fit: cover;
object-fit: cover;
transition: 0.3s ease;
transition-property: opacity, width, height;
animation: spin 1s infinite forwards linear;
}
.button:hover {
filter: brightness(1.1);
translate: 0 -0.05em;
}
.button:active {
filter: brightness(0.9);
translate: 0 0.1em;
}
.button.disable {
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
pointer-events: none;
filter: grayscale(1);
}
.buttons-group {
font-size: 0.9em;
gap: 10px;
}
.dl-button {
color: var(--background-1);
background: var(--button-download);
}
.delete-button {
color: var(--background-1);
background: var(--button-delete);
}
.open-button {
color: var(--background-1);
background: var(--button-open);
}
.submit-button {
display: block;
color: var(--background-1);
padding: 0.2em 1em;
background: var(--submit-delete);
}
.search-bar {
font-size: 0.9em;
font-family: inherit;
color: var(--search-color-1);
background: var(--search-block);
padding: 0.2em 0.6em;
border-radius: 0.2em;
outline: 0;
border: 0;
transition: 0.2s ease;
transition-property: filter, opacity;
}
.search-bar::-moz-placeholder {
color: var(--search-color-2);
}
.search-bar::placeholder {
color: var(--search-color-2);
}
.search-bar.disable {
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
pointer-events: none;
filter: grayscale(1);
opacity: 0.5;
}
48 changes: 47 additions & 1 deletion packages/server/router/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Beatmap, Calculator } from '@kotrikd/rosu-pp';
import { config, downloadFile, unzip, wLogger } from '@tosu/common';
import { exec } from 'child_process';
import fs from 'fs';
import path from 'path';

Expand Down Expand Up @@ -102,7 +103,52 @@ export default function buildBaseApi(app: HttpServer) {
}
});

app.route(/\/api\/deleteCounter\/(?<name>.*)/, 'GET', (req, res) => {
app.route(/\/api\/counters\/open\/(?<name>.*)/, 'GET', (req, res) => {
try {
const folderName = req.params.name;
if (!folderName) {
return sendJson(res, {
error: 'no folder name'
});
}

const staticPath =
config.staticFolderPath ||
path.join(path.dirname(process.execPath), 'static');
const folderPath = path.join(staticPath, decodeURI(folderName));

if (!fs.existsSync(folderPath)) {
return sendJson(res, {
error: `Folder doesn't exists`
});
}

// ADDED MULTI PLATFORM SUPPORT
// mac exec(`open "${path}"`, (err, stdout, stderr) => {
// linux exec(`xdg-open "${path}"`, (err, stdout, stderr) => {

wLogger.info(`PP Counter opened: ${folderName}`);

exec(`start "" "${folderPath}"`, (err, stdout, stderr) => {
if (err) {
console.error('Error opening file explorer:', err);
return sendJson(res, {
error: `Error opening file explorer: ${err.message}`
});
}

return sendJson(res, {
status: 'opened'
});
});
} catch (error) {
return sendJson(res, {
error: (error as any).message
});
}
});

app.route(/\/api\/counters\/delete\/(?<name>.*)/, 'GET', (req, res) => {
try {
const folderName = req.params.name;
if (!folderName) {
Expand Down

0 comments on commit f7f3d7a

Please sign in to comment.