Skip to content

Commit

Permalink
self serve image assets
Browse files Browse the repository at this point in the history
  • Loading branch information
a-sync committed Aug 5, 2023
1 parent 37e6625 commit d14aaa7
Show file tree
Hide file tree
Showing 15 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# <img src="https://i.imgur.com/2Ok3pxv.png" width="40" align="left"> Game Server Watcher
# <img src="https://user-images.githubusercontent.com/14183614/182869472-643f4028-8143-429b-80c2-86c62d9c2de2.png" width="40" align="left"> Game Server Watcher
A simple discord/telegram bot that can be hosted on a free service to monitor your game servers and players in style. 😎

# About the Project
Expand Down Expand Up @@ -34,7 +34,7 @@ The project is in a very early stage. More detailed customization options and fe
* github action workflows to deploy to other cloud providers (aws, linode, atlantic, vultr, pikapods, okteto, ibm cloud etc.)
* SQL, JSON or object store database support (postgres, redis etc.)
* run as stateless serverless function (aws lambda, azure function, heroku, vercel, fly.io machines etc.)
* [pterodactyl](https://pterodactyl.io) egg release
* pterodactyl egg release

# Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See [deployment](#deployment) for notes on how to deploy the project on a live system.
Expand Down
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "A simple discord/telegram bot that can be hosted on a free service to monitor your game servers and players in style. 😎",
"website": "https://github.com/a-sync/game-server-watcher",
"repository": "https://github.com/a-sync/game-server-watcher",
"logo": "https://i.imgur.com/2Ok3pxv.png",
"logo": "https://user-images.githubusercontent.com/14183614/182869472-643f4028-8143-429b-80c2-86c62d9c2de2.png",
"env": {
"SECRET": {
"description": "Admin secret",
Expand Down
Binary file added public/bg0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/bg1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/bg2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/bg3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/bg4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/bg5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion public/images/TODO

This file was deleted.

4 changes: 2 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta charset="utf-8">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://i.imgur.com/2Ok3pxv.png" rel="icon" type="image/png">
<link href="favicon.png" rel="icon" type="image/png">

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- <link href="https://cdn.jsdelivr.net/npm/@forevolve/bootstrap-dark@latest/dist/css/toggle-bootstrap-dark.min.css" rel="stylesheet"> -->
Expand Down Expand Up @@ -38,7 +38,7 @@
<body>
<nav id="top-menu" class="navbar navbar-expand-lg navbar-dark invisible">
<span class="navbar-brand mb-0 h1">
<img src="https://i.imgur.com/2Ok3pxv.png" width="30" height="30" class="d-inline-block align-middle mr-sm-1 mr-md-2 mr-lg-3" alt="">
<img src="favicon.png" width="30" height="30" class="d-inline-block align-middle mr-sm-1 mr-md-2 mr-lg-3" alt="">
<span>GSW Control Panel</span>
</span>
<ul class="navbar-nav mr-auto">
Expand Down
2 changes: 1 addition & 1 deletion public/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ body {
background-attachment: fixed;
background-repeat: no-repeat;
background-size: cover;
background-image: url('https://i.imgur.com/lTly23N.png');
background-image: url('bg0.png');
}

body>nav {
Expand Down
10 changes: 5 additions & 5 deletions public/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,11 +380,11 @@ async function generateBearerToken(secret) {

function setRandomBg() {
const bgs = [
'https://i.imgur.com/bDzhwG5.png',
'https://i.imgur.com/rA8JXuI.png',
'https://i.imgur.com/pstAPIw.png',
'https://i.imgur.com/gQD3xfo.png',
'https://i.imgur.com/iKTfM8z.png'
'bg1.png',
'bg2.png',
'bg3.png',
'bg4.png',
'bg5.png'
];

const bgImg = new Image();
Expand Down
4 changes: 2 additions & 2 deletions src/game-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ export class GameServer {
if (DBG) console.log('gs.up', this.config.host, this.config.port);
let info = await this.gamedig();

if (DBG) console.log('gs.gamedig', Object.assign({}, info, { players: info?.players.length }));
if (DBG) console.log('gs.gamedig %j', Object.assign({}, info, { players: info?.players.length }));
if (!info && STEAM_WEB_API_KEY && this.config.appId) {
info = await this.steam();
if (DBG) console.log('gs.steam', info);
}

if (info) {
if (info.players.length > 0 && DBG) {
console.log('gs.players.0', info.players[0]);
console.log('gs.players.0 %j', info.players[0]);
}

this.online = true;
Expand Down
5 changes: 3 additions & 2 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,18 @@ const EXT_MIME: Record<string, string> = {

createServer(async (req, res) => {
if (DBG) console.log('DBG: %j %j', (new Date()), req.url);

const reqUrl = new URL(req.url || '', 'http://localhost');
const p = reqUrl.pathname === '/' ? 'index.html' : path.normalize(reqUrl.pathname).slice(1);
const ext = path.extname(p).slice(1);

const ext = path.extname(p);
if (ext in EXT_MIME && !p.includes('/') && !p.includes('\\')) {
if (SECRET !== '') {
res.writeHead(200, {
'Content-Type': EXT_MIME[ext] || 'plain/text',
'Cache-Control': 'max-age=' + String(CACHE_MAX_AGE)
});
fs.createReadStream('./public/' + p).pipe(res);
fs.createReadStream(path.resolve('./public/', p)).pipe(res);
} else {
res.end('Configure the `SECRET` env var to enable the web UI!');
}
Expand Down

0 comments on commit d14aaa7

Please sign in to comment.