Compare commits

...

8 commits

Author SHA1 Message Date
5bcba0b689 refactor: move all HTTP-Website code into www subdirectory
Some checks failed
/ phplint (push) Failing after 4s
2023-10-19 21:54:37 +02:00
502ddd1ad9 ci: moved lint file name 2023-10-19 21:53:41 +02:00
57d6d82be9 ci: add first draft of MySQL data schema 2023-10-19 21:53:14 +02:00
1862ccbbb6 feat: [first attempt at using MySQLi in the docker dev env] 2023-10-16 16:15:24 +02:00
472ec10496 ci: 👷 mess with CI more, trying to run docker images
All checks were successful
/ phplint (push) Successful in 55s
2023-10-14 16:01:54 +02:00
472dfcd834 ci: 📌 adjust checkout version to v3 (Node20 issues <.<) 2023-10-14 16:01:54 +02:00
cc75b4a98b ci: ✏️ properly use run step 2023-10-14 16:01:54 +02:00
1323549316 ci: 👷 test out Forgejo CI 2023-10-14 16:01:53 +02:00
30 changed files with 121 additions and 67 deletions

View file

@ -0,0 +1,14 @@
on: [push]
jobs:
phplint:
runs-on: docker
steps:
- uses: actions/checkout@v3
- uses: docker://cytopia/phplint:alpine
with:
cmd: -i ./vendor/.* *.php
- uses: github.com/DavidAnson/markdownlint-cli2-action@v13
with:
globs: '**/*.md'
continue-on-error: true

View file

@ -1,6 +0,0 @@
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/?static/.*
RewriteRule (.*) router.php

View file

@ -1,7 +1,7 @@
FROM composer
WORKDIR /app
COPY composer.* .
COPY www/composer.* .
RUN composer install
FROM php:apache
@ -12,6 +12,7 @@ RUN chmod -R a+r ./vendor
RUN a2enmod rewrite
RUN a2enmod headers
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli
COPY . .
COPY www/ .
RUN chmod -R a+r $(ls -I vendor)

View file

@ -0,0 +1,4 @@
FROM mysql:8.0-debian
WORKDIR /docker-entrypoint-initdb.d
COPY mysql_schema.sql ./

View file

@ -9,18 +9,28 @@ services:
watch:
- path: ./
action: rebuild
- path: ../.
- path: ../www/
action: sync
target: /usr/local/apache2/htdocs/
target: /var/www/html
ignore:
- ../.git
- mysql_schema.sql
mysql:
image: mysql:8.0-debian
build:
dockerfile: MysqlDockerfile
# NOTE: use of "mysql_native_password" is not recommended: https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password
# (this is just an example, not intended to be a production configuration)
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_ROOT_PASSWORD: example
volumes:
- sqlvolume:/var/lib/mysql
ports:
- 3306:3306
develop:
watch:
- path: mysql_schema.sql
action: rebuild
# volumes:
# - sqlvolume:/var/lib/mysql
volumes:
sqlvolume: {}

View file

@ -0,0 +1,48 @@
CREATE DATABASE dragon_fire;
USE dragon_fire;
CREATE TABLE posts (
post_id INTEGER AUTO_INCREMENT,
post_path VARCHAR(255) NOT NULL,
post_path_depth INTEGER NOT NULL DEFAULT 0,
post_title TEXT,
post_description TEXT,
post_brief TEXT,
post_content MEDIUMTEXT,
post_content_type TEXT,
PRIMARY KEY(post_id),
CONSTRAINT unique_post_path UNIQUE (post_path),
INDEX(post_path),
INDEX(post_path_depth, post_path)
);
CREATE TABLE post_tags (
post_id INTEGER,
tag VARCHAR(255),
CONSTRAINT post_fkey
FOREIGN KEY(post_id) REFERENCES posts(post_id)
ON DELETE CASCADE,
INDEX(post_id),
INDEX(tag)
);
INSERT INTO posts (post_path, post_title, post_content)
VALUES (
'/about',
'About the Dergs',
'
# About the dergs indeed
This is just a simple test. Might be nice, though!
'
);

1
www/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
vendor/

View file

@ -1 +1,6 @@
Allow from all
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/?static/.*
RewriteRule (.*) router.php

View file

View file

@ -1,42 +0,0 @@
body {
color: #B0B0B0;
background: #302A3F;
}
:link {
color: cyan;
font-style: italic;
text-decoration: none;
transition: color 0.2s;
}
:link:hover {
color: lightblue;
}
ul {
display: flex;
flex-direction: row;
justify-content: center;
list-style-type: none;
margin-top: 1em;
padding: 0px;
}
ul li {
padding: 0em 0.3em 0em 0.3em;
}
#big_title {
text-align: center;
font-size: 2.5em;
margin-bottom: 0.2em;
}
#title_separator {
height: 1.5px;
background-color: #ddd;
opacity: 0.5;
margin-left: 2em;
margin-right: 2em;
}

View file

@ -1,11 +0,0 @@
<?php
require_once '../vendor/autoload.php';
$loader = new \Twig\Loader\FilesystemLoader('../templates');
$twig = new \Twig\Environment($loader);
echo $twig->render('index.html',[
"a_variable" => "is very spicy. In a good way."
]);
?>

View file

@ -2,6 +2,31 @@
require_once 'vendor/autoload.php';
$sql = mysqli_connect('mysql', 'root', 'example', 'dragon_fire');
function get_post_by_path($path) {
global $sql;
$qry = "SELECT * FROM posts WHERE post_path = ?";
$stmt = $sql->prepare($qry);
$stmt->bind_param("s", $path);
$stmt->execute();
// $result = $stmt->get_result();
return $stmt->get_result()->fetch_assoc();
}
//if (!$sql)
// {
// echo 'Connection failed<br>';
// echo 'Error number: ' . mysqli_connect_errno() . '<br>';
// echo 'Error message: ' . mysqli_connect_error() . '<br>';
// die();
// }
$loader = new \Twig\Loader\FilesystemLoader(['./templates', './user_content']);
$twig = new \Twig\Environment($loader,['debug' => true]);
@ -21,6 +46,11 @@ $twig->addRuntimeLoader(new class implements RuntimeLoaderInterface {
if($_SERVER['REQUEST_URI'] == '/') {
echo $twig->render('root.html');
} elseif(preg_match('/^\/api\/posts(.*)$/', $_SERVER['REQUEST_URI'], $match)) {
header('Content-Type: application/json');
echo json_encode(get_post_by_path($match[1]));
} elseif(preg_match('/^\/about(.html)?$/', $_SERVER['REQUEST_URI'])) {
echo $twig->render('about.html');
} elseif(preg_match('/^\/gallery\/([^\?]+)/', $_SERVER['REQUEST_URI'])) {

View file

Before

Width:  |  Height:  |  Size: 527 KiB

After

Width:  |  Height:  |  Size: 527 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 2.4 MiB

After

Width:  |  Height:  |  Size: 2.4 MiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 66 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 66 KiB

Before After
Before After