Compare commits
8 commits
54a16cc77e
...
5bcba0b689
Author | SHA1 | Date | |
---|---|---|---|
5bcba0b689 | |||
502ddd1ad9 | |||
57d6d82be9 | |||
1862ccbbb6 | |||
472ec10496 | |||
472dfcd834 | |||
cc75b4a98b | |||
1323549316 |
14
.forgejo/workflows/lint.yaml
Normal 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
|
|
@ -1,6 +0,0 @@
|
||||||
|
|
||||||
RewriteEngine On
|
|
||||||
RewriteBase /
|
|
||||||
|
|
||||||
RewriteCond %{REQUEST_URI} !^/?static/.*
|
|
||||||
RewriteRule (.*) router.php
|
|
|
@ -1,7 +1,7 @@
|
||||||
FROM composer
|
FROM composer
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY composer.* .
|
COPY www/composer.* .
|
||||||
RUN composer install
|
RUN composer install
|
||||||
|
|
||||||
FROM php:apache
|
FROM php:apache
|
||||||
|
@ -12,6 +12,7 @@ RUN chmod -R a+r ./vendor
|
||||||
|
|
||||||
RUN a2enmod rewrite
|
RUN a2enmod rewrite
|
||||||
RUN a2enmod headers
|
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)
|
RUN chmod -R a+r $(ls -I vendor)
|
||||||
|
|
4
docker_dev/MysqlDockerfile
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
FROM mysql:8.0-debian
|
||||||
|
|
||||||
|
WORKDIR /docker-entrypoint-initdb.d
|
||||||
|
COPY mysql_schema.sql ./
|
|
@ -9,18 +9,28 @@ services:
|
||||||
watch:
|
watch:
|
||||||
- path: ./
|
- path: ./
|
||||||
action: rebuild
|
action: rebuild
|
||||||
- path: ../.
|
- path: ../www/
|
||||||
action: sync
|
action: sync
|
||||||
target: /usr/local/apache2/htdocs/
|
target: /var/www/html
|
||||||
|
ignore:
|
||||||
|
- ../.git
|
||||||
|
- mysql_schema.sql
|
||||||
mysql:
|
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
|
# 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)
|
# (this is just an example, not intended to be a production configuration)
|
||||||
command: --default-authentication-plugin=mysql_native_password
|
command: --default-authentication-plugin=mysql_native_password
|
||||||
restart: always
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
MYSQL_ROOT_PASSWORD: example
|
MYSQL_ROOT_PASSWORD: example
|
||||||
volumes:
|
ports:
|
||||||
- sqlvolume:/var/lib/mysql
|
- 3306:3306
|
||||||
|
develop:
|
||||||
|
watch:
|
||||||
|
- path: mysql_schema.sql
|
||||||
|
action: rebuild
|
||||||
|
# volumes:
|
||||||
|
# - sqlvolume:/var/lib/mysql
|
||||||
volumes:
|
volumes:
|
||||||
sqlvolume: {}
|
sqlvolume: {}
|
||||||
|
|
48
docker_dev/mysql_schema.sql
Normal 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
|
@ -0,0 +1 @@
|
||||||
|
vendor/
|
|
@ -1 +1,6 @@
|
||||||
Allow from all
|
|
||||||
|
RewriteEngine On
|
||||||
|
RewriteBase /
|
||||||
|
|
||||||
|
RewriteCond %{REQUEST_URI} !^/?static/.*
|
||||||
|
RewriteRule (.*) router.php
|
||||||
|
|
0
composer.lock → www/composer.lock
generated
|
@ -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;
|
|
||||||
}
|
|
|
@ -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."
|
|
||||||
]);
|
|
||||||
?>
|
|
|
@ -2,6 +2,31 @@
|
||||||
|
|
||||||
require_once 'vendor/autoload.php';
|
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']);
|
$loader = new \Twig\Loader\FilesystemLoader(['./templates', './user_content']);
|
||||||
|
|
||||||
$twig = new \Twig\Environment($loader,['debug' => true]);
|
$twig = new \Twig\Environment($loader,['debug' => true]);
|
||||||
|
@ -21,6 +46,11 @@ $twig->addRuntimeLoader(new class implements RuntimeLoaderInterface {
|
||||||
|
|
||||||
if($_SERVER['REQUEST_URI'] == '/') {
|
if($_SERVER['REQUEST_URI'] == '/') {
|
||||||
echo $twig->render('root.html');
|
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'])) {
|
} elseif(preg_match('/^\/about(.html)?$/', $_SERVER['REQUEST_URI'])) {
|
||||||
echo $twig->render('about.html');
|
echo $twig->render('about.html');
|
||||||
} elseif(preg_match('/^\/gallery\/([^\?]+)/', $_SERVER['REQUEST_URI'])) {
|
} elseif(preg_match('/^\/gallery\/([^\?]+)/', $_SERVER['REQUEST_URI'])) {
|
Before Width: | Height: | Size: 527 KiB After Width: | Height: | Size: 527 KiB |
Before Width: | Height: | Size: 2.4 MiB After Width: | Height: | Size: 2.4 MiB |
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 66 KiB |
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 66 KiB |