big cleanup, prepare for production

This commit is contained in:
Ludvík Prokopec 2022-10-19 10:19:43 +02:00
parent ad7633ae60
commit 0e5c90eee5
20 changed files with 111 additions and 150 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

View File

@ -1 +0,0 @@
{"name":"","short_name":"","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"}

0
j.html
View File

View File

@ -1,10 +1,5 @@
<Files "api/.env">
Order Allow,Deny
Deny from all
</Files>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
RewriteRule . index.html [L]

View File

@ -1,6 +0,0 @@
PRODUCTION=false
DB_HOST="db.db030.webglobe.com"
DB_USER="mysql85033"
DB_PASSWORD="troglodyt"
DB_DATABASE="mysql122279"

View File

@ -1,10 +1,5 @@
<Files "api/.env">
Order Allow,Deny
Deny from all
</Files>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.html [L]
RewriteRule . index.php [L]

View File

@ -21,52 +21,20 @@ function env($key) {
$database = new Medoo([
'type' => 'mysql',
'host' => env("DB_HOST"),
'database' => env("DB_DATABASE"),
'username' => env("DB_USER"),
'password' => env("DB_PASSWORD")
'host' => "db.db030.webglobe.com",
'database' => "mysql122279",
'username' => "mysql85033",
'password' => "troglodyt"
]);
$data = json_decode(file_get_contents("php://input"), true);
$routesDirectory = __DIR__ . "/routes";
$getFolderContentUtil = null;
$getFolderContentUtil = function($dir) use($routesDirectory, &$getFolderContentUtil, $router, $data, $database) {
$files = scandir($dir);
$filter = '/\.php$/';
foreach($files as $key => $value) {
$path = realpath($dir.DIRECTORY_SEPARATOR.$value);
$pathWithoutRoot = str_replace($routesDirectory, '', $path);
$pathWithoutRelativeRoot = str_replace($dir, '', $path);
if(!is_dir($path)) {
if(empty($filter) || preg_match($filter, $path)) {
$error = false;
$response = require $path;
if(!empty($response) && is_array($response)) {
foreach($response as $key => $fn) {
$router->{$key}(str_replace(".php", '', $pathWithoutRelativeRoot), function() use($router, $fn, $data, $error, $database) {
$responseResult = $fn($data, getallheaders(), $database, $error, $router);
if($responseResult) {
$responseResult["status"] = array_key_exists("status", $responseResult) ? $responseResult["status"] : 200;
http_response_code($responseResult["status"]);
echo json_encode($responseResult["data"]);
exit();
}
});
}
}
}
} else if($value != "." && $value != "..") {
$router->mount($pathWithoutRelativeRoot, function() use($getFolderContentUtil, $path, $filter) {
$getFolderContentUtil($path);
});
}
}
};
$getFolderContentUtil($routesDirectory);
$router->post('/game/details', function() use($database, $data) {
$fn = require __DIR__ . '/routes/game/details.php';
$response = $fn($data, getallheaders(), $database);
$response["status"] = array_key_exists("status", $response) ? $response["status"] : 200;
http_response_code($response["status"]);
echo json_encode($response["data"]);
});
$router->run();

View File

@ -1,9 +1,6 @@
<?php
return [
"post" => function($data, $headers, $db) {
function remoteFileExists($url) {
function remoteFileExists($url) {
$curl = curl_init($url);
//don't fetch the actual page, you only want to check the connection is ok
@ -27,8 +24,9 @@ return [
curl_close($curl);
return $ret;
}
}
return function($data, $headers, $db) {
$imagesHostName = 'https://geohry.skolazdola.cz/';
if(!isset($data['gameurl']) || empty($data['gameurl'])) return [
@ -69,6 +67,4 @@ return [
"success" => true,
"data" => $gameDetails
];
}
];
};

View File

Before

Width:  |  Height:  |  Size: 9.9 KiB

After

Width:  |  Height:  |  Size: 9.9 KiB

View File

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

View File

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

View File

Before

Width:  |  Height:  |  Size: 554 B

After

Width:  |  Height:  |  Size: 554 B

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 15 KiB

19
public/webmanifest.json Normal file
View File

@ -0,0 +1,19 @@
{
"name": "Erant",
"short_name": "Erant",
"icons": [
{
"src": "assets/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "assets/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}

View File

@ -3,10 +3,7 @@
import './main.scss'
import Game from './routes/game.svelte'
import Finish from './lib/Components/Forms/Finish.svelte'
import Renderer from './lib/Components/Forms/Renderer.svelte'
//import Try from './routes/try.svelte'
import { data } from './lib/stores/game'
import Play from './routes/play.svelte'
</script>
<main>
@ -15,13 +12,7 @@
<h1 class="flex items-center justify-center">Nebyla vybrána žádná hra</h1>
</Route>
<Route path="/play">
{#if $data}
<Renderer gameData={$data} />
{:else}
<h1 class="flex items-center justify-center">Nebyla vybrána žádná hra</h1>
{/if}
</Route>
<Route path="/play" component={Play} />
<Route path="/game">
<h1 class="flex items-center justify-center">Nebyla vybrána žádná hra</h1>

View File

@ -21,7 +21,6 @@
}
let startQuestion = false
let userCurrentCoords = {}
let control = null // if true => spravne if false spatne
//$: console.log(`kontrola: ${control}`)
@ -68,13 +67,11 @@
let lat = Number.parseFloat($data.questions[clientAnswers.pos].lat)
let lng = Number.parseFloat($data.questions[clientAnswers.pos].lng)
console.log({ lat, lng })
</script>
{#if !startQuestion}
<Map center={{ lat, lng }} class="w-full h-full" on:move={console.log} let:user>
<Circle on:enter={console.log} {lat} {lng} {user} />
<Circle on:enter={() => (startQuestion = true)} {lat} {lng} {user} />
</Map>
{/if}

View File

@ -1,6 +1,6 @@
<script>
import { Map, controls } from '@beyonk/svelte-mapbox'
import { createEventDispatcher, setContext } from 'svelte'
import { createEventDispatcher } from 'svelte'
const { GeolocateControl } = controls
let mapComponent
let className = ''
@ -23,7 +23,7 @@
mapComponent.resize()
mapComponent.setCenter([center.lng, center.lat], 14)
}}
zoom="14"
zoom={14}
>
<slot {user} />
<GeolocateControl

View File

@ -26,7 +26,6 @@
gameurl,
})
console.log($data)
loading = false
})()
</script>
@ -72,7 +71,6 @@
<h1 class="flex items-center justify-center">Tato hra neexistuje</h1>
{/if}
<!---->
<style>
.bubbles {
display: flex;

View File

@ -1 +1,10 @@
<!-- mapa -->
<script>
import { data } from '$lib/stores/game'
import Renderer from '$lib/Components/Forms/Renderer.svelte'
</script>
{#if $data}
<Renderer gameData={$data} />
{:else}
<h1 class="flex items-center justify-center">Nebyla vybrána žádná hra</h1>
{/if}