WIP make lokal hosting work

This commit is contained in:
marko
2025-05-09 08:13:18 +02:00
parent 0c415d4c3f
commit 0aa94137db
10 changed files with 97 additions and 71 deletions

View File

@@ -1,7 +1,7 @@
{ {
"cwsvJudo": { "cwsvJudo": {
"db": { "db": {
"host": "localhost", "host": "db",
"name": "cwsvjudo_main", "name": "cwsvjudo_main",
"user": "cwsvjudo_marko" "user": "cwsvjudo_marko"
} }

View File

@@ -8,7 +8,7 @@
$home = "/home/cwsvjudo.helioho.st"; $home = "/home/cwsvjudo.helioho.st";
/// Basis(/Root)-Verzeichnis auf dem Server (für Dateizugriffe, insbesondere phpIncludes) /// Basis(/Root)-Verzeichnis auf dem Server (für Dateizugriffe, insbesondere phpIncludes)
/// (ist eigentlich das serve verzeichnis, aka www-data) /// (ist eigentlich das serve verzeichnis, aka www-data)
$basePath = join("/", [$home, "httpdocs"]); $basePath = join(separator: "/", array: [$home, "httpdocs"]);
/// Url zum Zugriff auf "shared Data" unter der Hauptadresse /// Url zum Zugriff auf "shared Data" unter der Hauptadresse
$baseUrl = "http://".$baseDomain; $baseUrl = "http://".$baseDomain;

View File

@@ -21,10 +21,11 @@ services:
image: mariadb:latest image: mariadb:latest
restart: always restart: always
environment: environment:
MYSQL_USER: "cwsvjudo" MYSQL_USER: "cwsvjudo_marko"
MYSQL_DATABASE: "cwsvjudo" MYSQL_DATABASE: "cwsvjudo_main"
MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db_root_password MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db_root_password
MYSQL_PASSWORD_FILE: /run/secrets/db_password MYSQL_PASSWORD_FILE: /run/secrets/db_password
MYSQL_TCP_PORT: 3306
volumes: volumes:
# this line maps the content of ./mysql_data in your pc to the /var/lib/mysql of the container # this line maps the content of ./mysql_data in your pc to the /var/lib/mysql of the container
- mysqldata:/var/lib/mysql - mysqldata:/var/lib/mysql
@@ -44,7 +45,7 @@ services:
environment: environment:
# name of the host is the name of the db service started above! Why? I don't know! # name of the host is the name of the db service started above! Why? I don't know!
- PMA_HOST=db - PMA_HOST=db
- PMA_PORT=1433 - PMA_PORT=3306
volumes: volumes:
# data storage for the db # data storage for the db
mysqldata: {} mysqldata: {}

View File

@@ -15,8 +15,7 @@ $headerRootLevel = is_positive_integer($someOptions['headerRootLevel'])?$someOpt
/// Eine Datenbankverbindung (über pdo) erstellen /// Eine Datenbankverbindung (über pdo) erstellen
try{ try{
$db_connection = new PDO( $db_connection = new PDO(
"mysql:host=".$cwsvJudoConfig["db"]["host"].";". "mysql:host=".$cwsvJudoConfig["db"]["host"].";"."dbname=".$cwsvJudoConfig["db"]["name"],
"dbname=".$cwsvJudoConfig["db"]["name"],
$cwsvJudoConfig["db"]["user"], $cwsvJudoConfig["db"]["user"],
$cwsvJudoConfig["db"]["password"] $cwsvJudoConfig["db"]["password"]
); );

View File

@@ -15,7 +15,7 @@
font-family: 'Material Icons'; font-family: 'Material Icons';
font-weight: normal; font-weight: normal;
font-style: normal; font-style: normal;
font-size: 24px; font-size: 1em;
line-height: 1; line-height: 1;
letter-spacing: normal; letter-spacing: normal;
text-transform: none; text-transform: none;

View File

@@ -1,5 +1,5 @@
.parallax-container { .parallax-container {
height: 50vw; height: 38vh;
} }
.parallax-container > .parallax > img{ .parallax-container > .parallax > img{

View File

@@ -20,8 +20,8 @@ und [Wettkampfterminen][cwsvJudoWettkampfKalender].
Ein kleines Wiki bietet [Wissenswertes über Judo][cwsvJudoWiki], wie Ein kleines Wiki bietet [Wissenswertes über Judo][cwsvJudoWiki], wie
zum Beispiel das [Programm für die Gürtelprüfungen][cwsvJudoWikiKyu]. zum Beispiel das [Programm für die Gürtelprüfungen][cwsvJudoWikiKyu].
## Letzte Neuigkeiten ## Letzte Neuigkeiten
<?php $options=array(); $options['limit']=6; $options['headerRootLevel']=2; echoNewsTableHtml( $options ); ?> <?php $options=array(); $options['limit']=6; $options['headerRootLevel']=2; echoNewsTableHtml( $options ); ?>
[cwsvHomepage]: http://www.cwsv-sport.de "Homepage des Chemnitzer Freizeit- und Wohngebietssportvereines" [cwsvHomepage]: http://www.cwsv-sport.de "Homepage des Chemnitzer Freizeit- und Wohngebietssportvereines"

View File

@@ -1,2 +1,6 @@
<? <?
/**
* home directory on the server
* - meaning the users home directory (aka ~) in the environment, not the directory served via http
*/
$home = "/home/cwsvjudo.helioho.st"; $home = "/home/cwsvjudo.helioho.st";

View File

@@ -1,5 +1,10 @@
<!DOCTYPE html> <!DOCTYPE html>
<?php <?php
$directory_paths=[
"wallpapers" => "/ressourcen/graphiken/wallpapers",
];
$mainNav = [ $mainNav = [
[ [
"url" => "training", "url" => "training",
@@ -16,26 +21,72 @@ $sections = [
$wallpapers = [ $wallpapers = [
[ [
"src" => "/ressourcen/graphiken/wallpapers/osae-komi.svg", "src" => $directory_paths['wallpapers']. "/osae-komi.svg",
"data-src" => "/ressourcen/graphiken/wallpapers/osae-komi.jpg" "data-src" => $directory_paths['wallpapers']. "/osae-komi.jpg"
], ],
[ [
"src" => "/ressourcen/graphiken/wallpapers/nage.svg", "src" => $directory_paths['wallpapers']. "/nage.svg",
"data-src" => "/ressourcen/graphiken/wallpapers/nage.jpg" "data-src" => $directory_paths['wallpapers']. "/nage.jpg"
], ],
[ [
"src" => "/ressourcen/graphiken/wallpapers/kata.svg", "src" => $directory_paths['wallpapers']. "/kata.svg",
"data-src" => "/ressourcen/graphiken/wallpapers/kata.jpg" "data-src" => $directory_paths['wallpapers']. "/kata.jpg"
], ],
]; ];
// helper functions
// -html output
/**
* Inject the html code for the nav targets
* @param mixed $mainNav
* @return void
*/
function mainNavTargets($mainNav){
echo('<ul id="nav-mobile" class="right">');
foreach($mainNav as $nav){
echo('<li>');
echo('<a');
echo(' href="' . $nav['url']. '"');
echo(' title="' . $nav['caption']. '"');
echo('>');
echo('<span>'.$nav['caption'].'</span>');
echo('</a>');
echo('</li>');
}
echo('</ul>');
}
function main($sections, $wallpapers){
foreach($sections as $idx => $section){
echo(
'<div class="parallax-container">'
.'<div class="parallax">'
.'<img'
. ' class="lazyload" '
. ' src="'.$wallpapers[$idx]['src'].'" '
. ' data-src="'.$wallpapers[$idx]['data-src'].'" '
.'>'
.'</div>'
.'</div>'
);
echo(
'<div class="section">'.$section.'</div>'
);
}
}
?> ?>
<html> <html>
<head> <head>
<link type="text/css" rel="stylesheet" href="/ressourcen/css/cwsvJudo.css"> <!--Imports-->
<!--Import materialize.css--> <!-- - materialize Framework -->
<link type="text/css" rel="stylesheet" href="/ressourcen/css/materialize.min.css" media="screen,projection" /> <link type="text/css" rel="stylesheet" href="/ressourcen/css/materialize.min.css" media="screen,projection" />
<!-- - cwsvJudo adjustments -->
<link type="text/css" rel="stylesheet" href="/ressourcen/css/cwsvJudo.css">
<!--Let browser know website is optimized for mobile--> <!--Let browser know website is optimized for mobile-->
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head> </head>
@@ -50,20 +101,7 @@ $wallpapers = [
<a href="/" class="brand-logo"> <a href="/" class="brand-logo">
<span>cwsvJudo</span> <span>cwsvJudo</span>
</a> </a>
<?php // main nav targets <?php mainNavTargets($mainNav);?>
echo('<ul id="nav-mobile" class="right">');
foreach($mainNav as $nav){
echo('<li>');
echo('<a');
echo(' href="' . $nav['url']);
echo(' title="' . $nav['caption']);
echo('>');
echo('<span>'.$nav['caption'].'</span>');
echo('</a>');
echo('</li>');
}
echo('</ul>');
?>
</div> </div>
<!-- <div class="nav-content"> <!-- <div class="nav-content">
$if(subNav)$ $if(subNav)$
@@ -92,43 +130,24 @@ $wallpapers = [
</header> </header>
<main> <main>
<script> <?php main($sections, $wallpapers);?>
function postload(t){
if(t.src !== t.getAttribute('data-src')){
t.src = t.getAttribute('data-src');
}
}
</script>
<?php
foreach($sections as $idx => $section){
echo(
'<div class="parallax-container">'
.'<div class="parallax">'
.'<img'
. ' class="lazyload" '
. ' src="'.$wallpapers[$idx]['src'].'" '
. ' data-src="'.$wallpapers[$idx]['data-src'].'" '
.'>'
.'</div>'
.'</div>'
);
echo(
'<div class="section">'.$section.'</div>'
);
}
?>
</main> </main>
<!--JavaScript at end of body for optimized loading--> <!--JavaScript at end of body for optimized loading-->
<!-- Import external libraries -->
<!-- - materialize framework -->
<script type="text/javascript" src="/ressourcen/js/materialize.min.js"></script> <script type="text/javascript" src="/ressourcen/js/materialize.min.js"></script>
<!-- - lazysizes -->
<script type="text/javascript" src="/ressourcen/js/lazysizes.min.js"></script> <script type="text/javascript" src="/ressourcen/js/lazysizes.min.js"></script>
<!-- Configure external libraries -->
<!-- - materialize framework -->
<script> <script>
document.addEventListener('DOMContentLoaded', function () { document.addEventListener('DOMContentLoaded', function () {
const elems = document.querySelectorAll('.parallax'); const elems = document.querySelectorAll('.parallax');
const instances = M.Parallax.init(elems, { const instances = M.Parallax.init(elems, {
// specify options here // specify options here
}); });
}); })
</script> </script>
</body> </body>

View File

@@ -2,25 +2,28 @@
require_once("config.php"); require_once("config.php");
$config = json_decode( $config = json_decode(
file_get_contents($home."/.local/config.json"), json: file_get_contents(filename: $home."/.local/config.json"),
true associative: true
); );
$secrets = json_decode( $secrets = json_decode(
file_get_contents($home."/.local/secrets.json"), json: file_get_contents(filename: $home."/.local/secrets.json"),
true associative: true
); );
var_dump($config);
try { try {
$conn = new PDO( $conn = new PDO(
"mysql:host=".$config['cwsvJudo']['db']['host'].";dbname=".$config['cwsvJudo']['db']['name'], dsn: join(separator: ";",array: [
$config['cwsvJudo']['db']['user'], "mysql:host=".$config['cwsvJudo']['db']['host'],
$secrets['cwsvJudo']['db'][$config['cwsvJudo']['db']['user']] "port=3306",
"dbname=".$config['cwsvJudo']['db']['name']
]),
username: $config['cwsvJudo']['db']['user'],
password: $secrets['cwsvJudo']['db'][$config['cwsvJudo']['db']['user']]
); );
// set the PDO error mode to exception // set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $conn->setAttribute(attribute: PDO::ATTR_ERRMODE, value: PDO::ERRMODE_EXCEPTION);
echo "Connected successfully"; echo "Connected successfully";
} catch(PDOException $e) { } catch(PDOException $e) {
echo "Connection failed: " . $e->getMessage(); echo "Connection failed: " . $e->getMessage();