A lot of changes in /web

* Moved /web endpoint to /app + created a link
* Create kernel includer for pages
This commit is contained in:
Niko 2022-02-09 21:05:27 +01:00
parent 7e0abcbc17
commit 56bca7e0a0
6 changed files with 49 additions and 5 deletions

View File

@ -4,7 +4,7 @@ server {
server_name _;
# Web client
location ~ ^(/$|/@|/web) {
location ~ ^(/$|/@|/app) {
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;

1
web/src/app/index.php Symbolic link
View File

@ -0,0 +1 @@
../index.php

5
web/src/base.php Normal file
View File

@ -0,0 +1,5 @@
<?php
function s($name) {
echo $name;
}

View File

@ -1,11 +1,35 @@
<?php
$uri = trim($_SERVER['REQUEST_URI']);
chdir( $_SERVER['DOCUMENT_ROOT'] );
define('PROD', 'prod');
define('DEV', 'dev');
$env = getenv('ENV');
if (!in_array($env, [PROD, DEV]))
$env = DEV;
putenv('env='.$env);
$uri = rtrim(trim($_SERVER['REQUEST_URI']),'/');
$simple_uri = preg_replace('/^\/app\//', '/', $uri);
function req_pub($name) { require "public/$name.php"; die; }
function redirect($url) { header('Location: '.$url); die; }
# Public URLs
switch ($simple_uri)
{
case '/': req_pub('home');
case '/login': req_pub('login');
}
# Example: /@username
if (preg_match('/^\/\@[a-zA-Z0-9\-\_]+/', $uri))
{
if ($_SERVER['HTTP_ACCEPT'] === 'application/activity+json') {
header('Location: /u/'.substr($uri, 2)); die();
}
if ($_SERVER['HTTP_ACCEPT'] === 'application/activity+json')
redirect( substr($uri, 2) );
req_pub('profile');
}

11
web/src/public/login.php Normal file
View File

@ -0,0 +1,11 @@
<?php require 'base.php' ?>
<?php
?>
<form id="login">
<span>Email</span>
<input type="email" name="email" /><br>
<span>Password</span>
<input type="password" name="password" /><br>
<input type="submit" value="<?php s('log_in') ?>" />
</form>

View File

@ -0,0 +1,3 @@
<?php
echo 'PROFILE';