diff --git a/homepage/cwsvJudo/.gitignore b/homepage/cwsvJudo/.gitignore index 6bb3749..d80be2e 100644 --- a/homepage/cwsvJudo/.gitignore +++ b/homepage/cwsvJudo/.gitignore @@ -8,3 +8,5 @@ node_modules # don't commit any secrets Makefile.local +db_root_password.txt +db_password.txt diff --git a/homepage/cwsvJudo/Makefile.heliohost b/homepage/cwsvJudo/Makefile.heliohost index 8fbfb07..32b4c85 100644 --- a/homepage/cwsvJudo/Makefile.heliohost +++ b/homepage/cwsvJudo/Makefile.heliohost @@ -15,7 +15,7 @@ configFiles = $(wildcard config/*.php) LN = ln -f .PHONY: all -all: build/css/cwsvJudo.css pages images +all: build/css/cwsvJudo.css images # @todo This should only be temporary. Better outsource the graphics to it's own Makefile. make -j graphiken make build/css/cwsvJudo.css @@ -29,9 +29,6 @@ build/graphiken/wallpapers/%.svg: graphiken/wallpapers/%.svg .PHONY: images images: $(wallpapers) - echo $(wallpapersSrc) - echo $(wallpapers) - .PHONY: clean clean: @@ -83,17 +80,11 @@ dist: all $(LN) ./submodules/lazysizes/lazysizes.min.js $(distDir)/httpdocs/ressourcen/js/ # page data - mkdir -p $(distDir)/httpdocs/pages/responsive - find ./build/materialize/ -type f -exec $(LN) {} $(distDir)/httpdocs/pages/responsive \; - mkdir -p $(distDir)/httpdocs/pages/shared - find ./src/shared/ -type f -exec $(LN) {} $(distDir)/httpdocs/pages/shared \; - -# testing/development pages - mkdir -p $(distDevPages) - mkdir -p $(distDevPages)/phpLibs/cwsvJudo - - find src/pages/test -type f -exec $(LN) {} $(distDevPages) \; - find src/pages/test/phpLibs/cwsvJudo -type f -exec $(LN) {} $(distDevPages)/phpLibs/cwsvJudo \; + mkdir -p $(distWebRoot)/pages/responsive + find src/pages/responsive -type f -exec $(LN) {} $(distWebRoot)/pages/responsive \; + + mkdir -p $(distWebRoot)/pages/responsive/phpLibs/cwsvJudo + find src/pages/responsive/phpLibs/cwsvJudo -type f -exec $(LN) {} $(distWebRoot)/pages/responsive/phpLibs/cwsvJudo \; # structured data mkdir -p $(distDir)/httpdocs/ressourcen/structuredData/json @@ -194,6 +185,6 @@ build/css/cwsvJudo.css: $(cssFiles) # curl .PHONY: upload -upload: all +upload: dist lftp -f scripts/upload-heliohost diff --git a/homepage/cwsvJudo/configs/heliohost/config.json b/homepage/cwsvJudo/configs/heliohost/config.json index c9cbb9b..1ed5bc7 100644 --- a/homepage/cwsvJudo/configs/heliohost/config.json +++ b/homepage/cwsvJudo/configs/heliohost/config.json @@ -1,7 +1,7 @@ { "cwsvJudo": { "db": { - "host": "db", + "host": "localhost", "name": "cwsvjudo_main", "user": "cwsvjudo_marko" } diff --git a/homepage/cwsvJudo/configs/localDocker/config.json b/homepage/cwsvJudo/configs/localDocker/config.json new file mode 100644 index 0000000..c9cbb9b --- /dev/null +++ b/homepage/cwsvJudo/configs/localDocker/config.json @@ -0,0 +1,9 @@ +{ + "cwsvJudo": { + "db": { + "host": "db", + "name": "cwsvjudo_main", + "user": "cwsvjudo_marko" + } + } +} \ No newline at end of file diff --git a/homepage/cwsvJudo/configs/localDocker/secrets.json b/homepage/cwsvJudo/configs/localDocker/secrets.json new file mode 100644 index 0000000..aecb80c --- /dev/null +++ b/homepage/cwsvJudo/configs/localDocker/secrets.json @@ -0,0 +1,7 @@ +{ + "cwsvJudo": { + "db": { + "cwsvjudo_marko": "kodokan" + } + } +} \ No newline at end of file diff --git a/homepage/cwsvJudo/docker-compose.yaml b/homepage/cwsvJudo/docker-compose.yaml index f44b248..9a732a0 100644 --- a/homepage/cwsvJudo/docker-compose.yaml +++ b/homepage/cwsvJudo/docker-compose.yaml @@ -15,7 +15,8 @@ services: volumes: # this line maps the content of ./html in your pc to the /var/www/html of the container - ./build/dist/heliohost/httpdocs:/var/www/html - - ./build/dist/heliohost/:/home/cwsvjudo.helioho.st/ + - ./configs/localDocker/config.json:/home/cwsvjudo.de/.local/config.json + - ./configs/localDocker/secrets.json:/home/cwsvjudo.de/.local/secrets.json db: # check the mysql version you need for your project image: mariadb:latest diff --git a/homepage/cwsvJudo/scripts/upload-heliohost b/homepage/cwsvJudo/scripts/upload-heliohost index d613f92..0a2b787 100644 --- a/homepage/cwsvJudo/scripts/upload-heliohost +++ b/homepage/cwsvJudo/scripts/upload-heliohost @@ -1,27 +1,11 @@ #! /usr/bin/env bash -open cwsvjudo.helioho.st +open cwsvjudo.de user cwsvjudo CTI/eiT4RYe6?ac5 # @todo enable ssl check set ssl:verify-certificate no set ftp:ssl-allow off # upload: -# - page data -mirror --verbose --continue --parallel=8 --reverse ./build/materialize /httpdocs/pages/responsive -# - php lib -mirror --verbose --continue --parallel=8 --reverse ./phpLib/cwsvJudo /httpdocs/ressourcen/phpLib/cwsvJudo -# - graphics -mirror --verbose --continue --parallel=8 --reverse ./build/graphiken /httpdocs/ressourcen/graphiken -mirror --verbose --continue --parallel=8 --reverse ./graphiken/banner /httpdocs/ressourcen/graphiken/banner -put build/graphiken/favIcons/favicon.ico -o /httpdocs/favicon.ico -# - css -mkdir -pf /httpdocs/ressourcen/css -put build/css/cwsvJudo.css -o /httpdocs/ressourcen/css/cwsvJudo.css -# - fonts -mirror --verbose --continue --parallel=8 --reverse ./res/fonts /httpdocs/ressourcen/fonts -# config files -put configs/heliohost/pages.config.inc.php -o /httpdocs/pages/responsive/config.inc.php -# @todo shouldn't be used any more -mkdir -pf /.local +mirror --verbose --continue --parallel=8 --reverse ./build/dist/heliohost / put configs/heliohost/db.config.php -o /.local/db.config.php # exit diff --git a/homepage/cwsvJudo/src/pages/test/bootstrap.php b/homepage/cwsvJudo/src/pages/responsive/bootstrap.php similarity index 100% rename from homepage/cwsvJudo/src/pages/test/bootstrap.php rename to homepage/cwsvJudo/src/pages/responsive/bootstrap.php diff --git a/homepage/cwsvJudo/src/pages/test/config.php b/homepage/cwsvJudo/src/pages/responsive/config.php similarity index 79% rename from homepage/cwsvJudo/src/pages/test/config.php rename to homepage/cwsvJudo/src/pages/responsive/config.php index 3dc31f3..8fb4fc5 100644 --- a/homepage/cwsvJudo/src/pages/test/config.php +++ b/homepage/cwsvJudo/src/pages/responsive/config.php @@ -3,4 +3,4 @@ * 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.de"; diff --git a/homepage/cwsvJudo/src/pages/test/index.php b/homepage/cwsvJudo/src/pages/responsive/index.php similarity index 97% rename from homepage/cwsvJudo/src/pages/test/index.php rename to homepage/cwsvJudo/src/pages/responsive/index.php index 603f25b..e4fcbd3 100644 --- a/homepage/cwsvJudo/src/pages/test/index.php +++ b/homepage/cwsvJudo/src/pages/responsive/index.php @@ -19,8 +19,8 @@ $sections = [ dbHandle: $dbHandle, options: [ "limit" => 6, - // "dbCharset" => "ISO-8859-1", - "dbCharset" => "UTF-8", + "dbCharset" => "ISO-8859-1", + // "dbCharset" => "UTF-8", // "outCharset" => "ISO-8859-1", "outCharset" => "UTF-8", ] @@ -84,7 +84,7 @@ function main($sections, $wallpapers) ">" . "" . ""; - echo '
' . $section . "
"; + echo '
' . $section . "
"; } } ?> diff --git a/homepage/cwsvJudo/src/pages/test/news.php b/homepage/cwsvJudo/src/pages/responsive/news.php similarity index 100% rename from homepage/cwsvJudo/src/pages/test/news.php rename to homepage/cwsvJudo/src/pages/responsive/news.php diff --git a/homepage/cwsvJudo/src/pages/test/phpLibs/cwsvJudo/dbConnector.php b/homepage/cwsvJudo/src/pages/responsive/phpLibs/cwsvJudo/dbConnector.php similarity index 100% rename from homepage/cwsvJudo/src/pages/test/phpLibs/cwsvJudo/dbConnector.php rename to homepage/cwsvJudo/src/pages/responsive/phpLibs/cwsvJudo/dbConnector.php diff --git a/homepage/cwsvJudo/src/pages/test/phpLibs/cwsvJudo/news.php b/homepage/cwsvJudo/src/pages/responsive/phpLibs/cwsvJudo/news.php similarity index 95% rename from homepage/cwsvJudo/src/pages/test/phpLibs/cwsvJudo/news.php rename to homepage/cwsvJudo/src/pages/responsive/phpLibs/cwsvJudo/news.php index 1ca0c5d..4b311fc 100644 --- a/homepage/cwsvJudo/src/pages/test/phpLibs/cwsvJudo/news.php +++ b/homepage/cwsvJudo/src/pages/responsive/phpLibs/cwsvJudo/news.php @@ -64,7 +64,9 @@ class PromoImage { public function __construct(array $data) { - $this->src = filter_url($data["src"]); + // $this->src = filter_url($data["src"]); + // @todo php's url filter doesn't allow path only url + $this->src = $data["src"]; $this->height = filter_integer_range( value: $data["height"], min: 0, @@ -130,18 +132,13 @@ class Entry { return '
' . '
' . - '' . - $this->title . - "" . $this->promo->as_html() . "
" . '
' . '' . $this->title . "" . - "

" . $this->content . - "

" . "
" . "
"; } @@ -225,12 +222,13 @@ function getNews( function newsBoard(\CwsvJudo\Db\Connector $dbHandle, array $options): string { - $boardHtml = '

Neuigkeiten

'; + $boardHtml = '

Neuigkeiten

'; $entries = getNews(dbHandle: $dbHandle, options: $options); if (!is_null($entries)) { foreach ($entries as $entryData) { $entry = new \CwsvJudo\News\Entry($entryData); - $boardHtml .= '
' . $entry->as_card() . "
"; + $boardHtml .= + '
' . $entry->as_card() . "
"; } } $boardHtml .= "
"; diff --git a/homepage/cwsvJudo/src/pages/test/phpLibs/cwsvjudo/dbConnector.php b/homepage/cwsvJudo/src/pages/test/phpLibs/cwsvjudo/dbConnector.php deleted file mode 100644 index e05cc83..0000000 --- a/homepage/cwsvJudo/src/pages/test/phpLibs/cwsvjudo/dbConnector.php +++ /dev/null @@ -1,193 +0,0 @@ -getMessage()); - } - return $dbConnection; - } - - public static function getDbConnection() - { - return self::$db; - } - - /// perform a \PDO-query - /// - /// @param $aQueryString - /// @param $aBindArray e.g. array( - /// ':userId' => array('value'=>$anUserId, 'data_type'=>\PDO::PARAM_INT), - /// ':attributeId'=> array('value'=>$anAttributeId, 'data_type'=>\PDO::PARAM_INT) ) - /// @param $someOption - public static function query($aQueryString, $aBindArray = [], $someOptions = []) - { - // var_dump($aQueryString, $aBindArray); - // Standardbelegungen - if (empty($someOptions['dbCharset'])) { - $someOptions['dbCharset'] = 'ISO-8859-1'; - } - if (empty($someOptions['outCharset'])) { - $someOptions['outCharset'] = 'UTF-8'; - } - if (empty($someOptions['dontFetch'])) { - $someOptions['dontFetch'] = false; - } - - $ignoreErrors = $someOptions['ignoreErrors'] ?? false; - - /// @toDo: Bisher wird nur die Rückgabe konvertiert. Eigentlich muss - /// doch auch die Eingabe konvertiert werden. Aber das jetzt - /// umzustellen wird schwer! Die User im Wettkampfplaner sind ja z.B. - /// als UTF8 in latin1(?) gespeichert. - /// @toDo: Die Standardwerte sollten vielleicht aus einer config - /// kommen, nicht hardcoded - - try { - $PDOStatement = self::$db->prepare($aQueryString); - foreach ($aBindArray as $bindName => $bind) { - if ($bind['data_type'] == \PDO::PARAM_STR) { - $bind['value'] = iconv( - $someOptions['outCharset'], - $someOptions['dbCharset'], - $bind['value'] - ); - } - $PDOStatement->bindValue( - $bindName, - $bind['value'], - (isset($bind['data_type']) ? $bind['data_type'] : \PDO::PARAM_STR) - ); - } - $PDOResult = $PDOStatement->execute(); - if (!$ignoreErrors && !$PDOResult) { - echo("Error during dbQuery!\n"); - echo("DB-Error:\n"); - var_dump(self::$db->errorInfo()); - } - if ($someOptions['dontFetch']) { - $ret = null; - } else { - $ret = $PDOStatement->fetchAll(\PDO::FETCH_ASSOC); - } - } catch(\PDOException $db_error) { - print 'Error!: ' . $db_error->getMessage() . '
'; - return null; - } - - // Zeichensatzkonvertierung - if (is_array($ret)) { - foreach ($ret as &$entry) { - array_walk( - $entry, - function (&$value, $key, $someOptions) { - $value = iconv($someOptions['dbCharset'], $someOptions['outCharset'], $value); - }, - $someOptions - ); - } - } - return $ret; - } - - // @todo docu - public static function getLastInsertId() - { - return self::$db->lastInsertId(); - } - - - - // set the dbConnection (just setting, no establishing) - private function setDbConnection($dbConnection): bool - { - $success = false; - if ($dbConnection instanceof \PDO) { - self::$db = $dbConnection; - $success = true; - } else { - self::$db = null; - } - return $success; - } - - public static function debugEchoQuery($query, $params) - { - foreach ($params as $key => $value) { - switch($value['data_type']) { - case \PDO::PARAM_STR:{ - $query = str_replace($key, '\'' . $value['value'] . '\'', $query); - } - default:{ - $query = str_replace($key, $value['value'], $query); - } - } - }; - echo('query: ' . $query . PHP_EOL); - } -} diff --git a/homepage/cwsvJudo/src/pages/test/phpLibs/cwsvjudo/news.php b/homepage/cwsvJudo/src/pages/test/phpLibs/cwsvjudo/news.php deleted file mode 100644 index b2895dd..0000000 --- a/homepage/cwsvJudo/src/pages/test/phpLibs/cwsvjudo/news.php +++ /dev/null @@ -1,3 +0,0 @@ -