diff --git a/homepage/cwsvJudo/Makefile b/homepage/cwsvJudo/Makefile index 534e15b..b6bcf36 100644 --- a/homepage/cwsvJudo/Makefile +++ b/homepage/cwsvJudo/Makefile @@ -45,12 +45,14 @@ echo: .PHONY: ampTest ampTest: $(ampFiles) +.PHONY: INSTALL_DEPENDENCIES +INSTALL_DEPENDENCIES: + npm install csso + npm install --save-dev --save-exact prettier + build/css/cwsvJudo.css: $(cssFiles) mkdir -p $(dir $@) - cat $^ > $@ -# cat $(cssFiles) | cleancss -o $@ -# cat $^ | ./node_modules/.bin/csso -o $@ -# cat $^ | $(CSSO) -o $@ + npx csso --input $^ --output $@ build/%.php: src/md/%.md build/yaml/%.yaml pandocTemplate/cwsvJudo.html5.pandocTemplate mkdir -p build diff --git a/homepage/cwsvJudo/Makefile.heliohost b/homepage/cwsvJudo/Makefile.heliohost index 03b8d87..f20e004 100644 --- a/homepage/cwsvJudo/Makefile.heliohost +++ b/homepage/cwsvJudo/Makefile.heliohost @@ -1,4 +1,4 @@ -CSSO = node_modules/csso-cli/bin/csso +#!/usr/bin/env make -f RES_LIST = 64 128 256 512 @@ -9,6 +9,9 @@ ampFiles = $(patsubst src/md/%.md, build/amp/%.php, $(mdFiles)) phpLibFiles = $(wildcard phpLib/cwsvJudo/*.php) phpLib/phpcount/phpcount.php configFiles = $(wildcard config/*.php) +distDir=./build/dist/heliohost + +LN = cp -r .PHONY: all all: $(phpFiles) @@ -20,8 +23,44 @@ all: $(phpFiles) clean: $(RM) -rf build +# copy/link all together to get a distributable package +.PHONY: dist +dist: all + mkdir -p $(distDir) +# page data + mkdir -p $(distDir)/httpdocs/pages/ + $(LN) ./build/materialize $(distDir)/httpdocs/pages/responsive + $(LN) ./src/shared/ $(distDir)/httpdocs/pages/shared +# php lib + mkdir -p $(distDir)/httpdocs/ressourcen/phpLib + $(LN) ./phpLib/cwsvJudo $(distDir)/httpdocs/ressourcen/phpLib/cwsvJudo + $(LN) ./phpLib/phpqrcode $(distDir)/httpdocs/ressourcen/phpLib/phpqrcode +# graphics + mkdir -p $(distDir)/httpdocs/ressourcen/graphiken + $(LN) ./build/graphiken/cwsvJudoLogoWappen $(distDir)/httpdocs/ressourcen/graphiken/logos + $(LN) ./graphiken/banner $(distDir)/httpdocs/ressourcen/graphiken/banner + $(LN) ./build/graphiken/favIcons/favicon.ico $(distDir)/httpdocs/favicon.ico + $(LN) ./res/videos.d $(distDir)/httpdocs/videos.d +# css + mkdir -p $(distDir)/httpdocs/ressourcen/css + $(LN) ./build/css/cwsvJudo.css $(distDir)/httpdocs/ressourcen/css/cwsvJudo.css +# fonts + $(LN) ./res/fonts $(distDir)/httpdocs/ressourcen/fonts +# htaccess + $(LN) ./src/htaccess/heliohost/.htaccess $(distDir)/httpdocs/.htaccess +# @todo Link is into the build directory breaking the above pattern. + $(LN) ./src/htaccess/heliohost/pages/responsive/.htaccess ./build/materialize/.htaccess +# config files +# @todo Link is into the build directory breaking the above pattern. + $(LN) ./configs/heliohost/pages.config.inc.php ./build/materialize/config.inc.php +# @todo shouldn't be used any more + mkdir -p $(distDir)/.local + $(LN) configs/heliohost/db.config.php $(distDir)/.local/db.config.php + +# build the materialize version of the page build/materialize/%.php: src/md/%.md build/yaml/%.yaml pandocTemplate/materialize.pandocTemplate mkdir -p build/materialize + # create html/php code pandoc \ --standalone \ --css="ressourcen/css/cwsvJudo.css" \ @@ -30,6 +69,7 @@ build/materialize/%.php: src/md/%.md build/yaml/%.yaml pandocTemplate/materializ --wrap=preserve \ --output=$@ \ $< $(word 2,$^) +# npx prettier --check $@ # @toDo: Verzeichnisstruktur überdenken build/yaml/%.yaml: src/yaml/images.yaml src/yaml/navTargets.yaml src/yaml/mainNav.yaml src/yaml/%.subNav.yaml diff --git a/homepage/cwsvJudo/PHP.dockerfile b/homepage/cwsvJudo/PHP.dockerfile new file mode 100644 index 0000000..1a9c5cb --- /dev/null +++ b/homepage/cwsvJudo/PHP.dockerfile @@ -0,0 +1,11 @@ +# select base image +FROM php:fpm + +# startup scripts for the image +# - docker-php-ext-install -- install helper script from PHP +RUN docker-php-ext-install pdo pdo_mysql + +# install and add xdebug extension +# @todo What is pecl? +# @todo What is xdebug and how do I use it? +RUN pecl install xdebug && docker-php-ext-enable xdebug diff --git a/homepage/cwsvJudo/docker-clean.sh b/homepage/cwsvJudo/docker-clean.sh new file mode 100644 index 0000000..f938dbc --- /dev/null +++ b/homepage/cwsvJudo/docker-clean.sh @@ -0,0 +1,8 @@ +#! /usr/bin/env bash + +# stop all containers +docker-compose down --remove-orphans +# delete all containers +docker rm -f $(docker ps -a -q) +# delete all volumes +docker volume rm $(docker volume ls -q) diff --git a/homepage/cwsvJudo/docker-compose.yaml b/homepage/cwsvJudo/docker-compose.yaml new file mode 100644 index 0000000..2c0d022 --- /dev/null +++ b/homepage/cwsvJudo/docker-compose.yaml @@ -0,0 +1,77 @@ +# version for the docker compose file to use +version: "3" + +# a dict of services running in the container label: {} label is a self defined name for the service +services: + # the webserver service + web: + image: nginx:latest + # port forwarding + ports: + # forward port 80 top port 80 in the container + - "8080:80" + # files and directories to be available in the container + # - localPath:pathInContainer + volumes: + # nginx config file + # - ./nginx.conf:/etc/nginx/conf.d/nginx.conf + # the www-data + # - ./build/dist/heliohost:/home/cwsvjudo/httpdocs + - ./build/dist/heliohost:/usr/share/nginx/html:Z + # php and extensions + php: + # use pre-build image from docker.. + # image: php:fpm + # .. or build your own image + build: + context: . + dockerfile: PHP.dockerfile + # files and directories to be available in the container + # @todo Except from better structuring: Is there a reason for not having the volumes as one central list? + volumes: + # the www-data + # - ./build/dist/heliohost:/home/cwsvjudo + - ./build/dist/heliohost:/usr/share/nginx/html:ro + # # @todo Maybe use postgre instead? + database: + image: mariadb:latest + restart: always + # define environment variables + # @todo Should credentials be placed here? Even if it is just a test environment + environment: + # MYSQL_TCP_PORT: 1433 + MYSQL_USER: "cwsvjudo" + MYSQL_DATABASE: "cwsvjudo" + MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db_root_password + MYSQL_PASSWORD_FILE: /run/secrets/db_password + volumes: + - mysqldata:/var/lib/mysql + # initial database + # - has to be created first, e.g., by dumping the database from the productive system + - ./cwsvjudo.sql:/docker-entrypoint-initdb.d/cwsvjudo.sql + + secrets: + - db_root_password + - db_password + # phpmyadmin + # phpmyadmin: + # image: phpmyadmin:latest + # restart: always + # depends_on: + # - database + # - php + # ports: + # - 8080:80 + # environment: + # # name of the host is the name of the db service started above! Why? I don't know! + # - PMA_HOST=database + # - PMA_PORT=1433 +volumes: + # data storage for the db + mysqldata: {} + +secrets: + db_root_password: + file: db_root_password.txt + db_password: + file: db_password.txt diff --git a/homepage/cwsvJudo/nginx.conf b/homepage/cwsvJudo/nginx.conf new file mode 100644 index 0000000..56ab2fc --- /dev/null +++ b/homepage/cwsvJudo/nginx.conf @@ -0,0 +1,24 @@ +# @todo Needs helpfull comments. +server { + listen 80 default_server; + # root /users/cwsvjudo/www; + # root /home/cwsvjudo/httpdocs; + root /usr/share/nginx/html; + + index index.php index.html index.htm; + + location / { + # rewrite rules + # - add php to requested filename if it exists + if (-e $request_filename.php) { + rewrite ^/(.*)$ /$1.php last; + break; + } + } + + location ~ \.php$ { + fastcgi_pass php:9000; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } +} diff --git a/homepage/cwsvJudo/pandocTemplate/materialize.pandocTemplate b/homepage/cwsvJudo/pandocTemplate/materialize.pandocTemplate index 3935ab7..71f8764 100644 --- a/homepage/cwsvJudo/pandocTemplate/materialize.pandocTemplate +++ b/homepage/cwsvJudo/pandocTemplate/materialize.pandocTemplate @@ -1,62 +1,53 @@ - + $for(author-meta)$ - + $endfor$ $if(date-meta)$ - + $endif$ $if(keywords)$ - + $endif$ $if(canonicalPath)$ - + $endif$ $if(ampVersionLink)$ - + $endif$ $if(phpTitleString)$ - - <?php echo( $phpTitleString$ );?> + <title><?php echo( $phpTitleString$ );?> $else$$if(title)$ - $if(title-prefix)$$title-prefix$ – $endif$$pagetitle$ - $endif$$endif$ + $if(title-prefix)$$title-prefix$ – $endif$$pagetitle$ + $endif$ + $endif$ $if(phpDescriptionString)$ - + $else$$if(description)$ - + $endif$$endif$ $endif$ $endif$ $for(extraCss)$ - + $endfor$ $if(math)$ - $math$ + $math$ $endif$