Compare commits

...

2 Commits

Author SHA1 Message Date
Dendy 59cacfbe41 General improvement 2023-01-10 15:54:53 +01:00
Dendy 599da85947 Localization changes 2023-01-10 15:54:42 +01:00
8 changed files with 373 additions and 198 deletions

View File

@ -17,10 +17,50 @@ contact = "Contacte"
programming = "Programació"
git = "Perfil git"
keys = "Claus"
# main page
welcome = "Text per ocupar el espai"
welcomeHeader = "Yepa!"
welcome = "
<p>Hola i benvingudi a la meua pàgina</p>
<p>
Ací allotje les coses que fet així com
les que estic fent actualment, opinions
candents, coses que crec que mereixen ser
compartides i coses que me representen com
persona.
</p>
<p>
Si vols saber més de mí pots vore-ho
ací o pots contactar-me.
</p>
<p>
Espere que trobes coses que siguen del teu interés.
</p>
"
projectsHeader = "Projects"
projects = "
<h3>fai.st</h3>
<p>
Allotje i administre una sèrie de serveis de programari
lliure (un servidor fediversal, una instancia de Gitea, servei
VPN...) amb el nomb de <b>fai.st</b> amb uns amics.
</p>
<h3>USG</h3>
<p>
Clon competitiu del Tetris que busca ser correcte. Realitzat en
el llenguatge zig y amb la llibreria de SDL i renderització OpenGL.
Majoritariament fet el propòsit de aprendre.
</p>
<h3>keno</h3>
<p>
Client i biblioteca per a consumir la API de Mastodon gastant GTK i C.
Actualmen no està en desevolupament actiu.
</p>
"
# footer
copyright = "Aquesta pàgina està baix la llicència GPLv3 i el seu codi font estarà diponible prompte™. Els recursos utilitzats en aquesta pàgina estan baix CC-SA si no se especifica lo contrari."
copyright = "Aquesta pàgina està baix la llicència GPLv3 i el seu codi font estarà diponible prompte™. Els recursos utilitzats en aquesta pàgina estan baix CC-BY-NC-SA si no se especifica lo contrari."

View File

@ -16,10 +16,49 @@ contact = "Contact"
programming = "Programming"
git = "Git profile"
keys = "Keys"
# main page
welcome = "Text to occupy space"
welcomeHeader = "Hi"
welcome = "
<p>Hello and welcome to my place!</p>
<p>
Here I'm hosting the things I've done,
thing's im currently doing, my hot takes
and things that I think are worth sharing
and represent who I am as a being
</p>
<p>
If you want to know more about me you
can see it here or contact me.
</p>
<p>
Hope you find something that interests you.
</p>
"
projectsHeader = "Projects"
projects = "
<h3>fai.st</h3>
<p>
I host and manage a number of free software services
(a fediverse server, Gitea instance, VPN...)
under the name <b>fai.st</b> alongside some friends.
</p>
<h3>USG</h3>
<p>
Proper competitive tetris clone made in ziglang and SDL2,
with OpenGL rendering. Mostly made for learning purposes.
</p>
<h3>keno</h3>
<p>
Mastodon-API client and library using C and GTK. Not under
active development anymore.
</p>
"
# footer
copyright = "This website is under the GPLv3 license and its source code will be avalible soon™. The resources used on this website are under CC-SA unless stated otherwise."
copyright = "This website is under the GPLv3 license and its source code will be avalible soon™. The resources used on this website are under CC-BY-NC-SA unless stated otherwise."

View File

@ -17,10 +17,49 @@ contact = "Contacto"
programming = "Programación"
git = "Perfil git"
keys = "Claves"
# main page
welcome = "Texto para ocupar espacio"
welcomeHeader = "¡Buenas!"
welcome = "
<p>Hola y bienvenide a mi página</p>
<p>
Aquí alojo las cosas que hecho así como
las que estoy actualmente haciendo, opiniones
candentes, cosas que creo que vale la pena
compartir y cosas que me representan como persona.
</p>
<p>
Si quieres saber más sobre mí lo puedes ver
aquí o puedes contactarme.
</p>
<p>
Espero que encuentres cosas que te sean de interés.
</p>
"
projectsHeader = "Projects"
projects = "
<h3>fai.st</h3>
<p>
Alojo y administro una serie de servicios sofware libre
(un servidor fediversal, una instancia de Gitea, servicio VPN...)
bajo el nombre <b>fai.st</b> con unos amigos.
</p>
<h3>USG</h3>
<p>
Clon competitivo del Tetris de implementación correcta realizado
en ziglang y SDL2, con renderización mediante OpenGL. Mayoritariamente
hecho con el propósito de aprender.
</p>
<h3>keno</h3>
<p>
Cliente y biblioteca para consumir la API de Mastodon usando GTK y C.
Actualmente no está en desarrollo activo.
</p>
"
# footer
copyright = "Esta página está bajo la licencia GPLv3 y su código fuente estará diponible pronto™. Los recursos usados en esta página están bajo CC-SA a no ser que se diga lo contrario."
copyright = "Esta página está bajo la licencia GPLv3 y su código fuente estará diponible pronto™. Los recursos usados en esta página están bajo CC-BY-NC-SA a no ser que se diga lo contrario."

View File

@ -22,4 +22,4 @@ keys = "Kweys"
welcome = "Tewxt to occupy spwace >:3c"
# footer
copyright = "Twis website is unwer the GPLv3 wicense and its sowwse code avawwable soon™. De wesources used on this webwsite are under CC-SA unwess stated oderwise. UwU"
copyright = "Twis website is unwer the GPLv3 wicense and its sowwse code avawwable soon™. De wesources used on this webwsite are under CC-BY-NC-SA unwess stated oderwise. UwU"

104
main.php
View File

@ -1,87 +1,27 @@
<?php
include_once("utils/localization.php");
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
// Global variables
$_dr = $_SERVER['DOCUMENT_ROOT'];
<title><?= $trans('title') ?></title>
<meta name="author" content="Dendy">
// Parse path into array
// (e.g."/hello////13/thing" into ["hello", "13", "thing"])
$GLOBALS['PARSED_PATH'] = (function () {
/* - Usage of '#' as delimiters to be able to use '/' without escaping
* - (a|b) checks patterns a or b and captures it, (?:a|b) doesn't capture
*
* - (?:/|) is there to remove the first '/'
* - ([^/]+?) gets the content in a non-greedy way
* - (?:/|$) limits the capture to the next '/' or the end of the string
*/
preg_match_all('#(?:/|)([^/]+?)(?:/|$)#', $_SERVER['DOCUMENT_URI'], $matches);
<!-- Stylesheets -->
<link rel="stylesheet" href="static/style/reset.css">
<link rel="stylesheet" href="static/style/main.css">
</head>
// If it doesn't find anything, it is the root
$matches[1][0] = $matches[1][0] ?? '';
<body>
<div id="title">
<img src="static/resources/avi.png"/>
<div>
<h1><?= $trans('title') ?></h1>
<p><?= $trans('subtitle') ?></p>
</div>
</div>
// We don't care about the full pattern, just the captured group
return $matches[1];
})();
<div id="menu" class="section">
<ul>
<li><a href="#"><?= $trans('home') ?></a></li>
<li><a href="#"><?= $trans('gallery') ?></a></li>
<li><a href="#"><?= $trans('blog') ?></a></li>
<li><a href="#"><?= $trans('about') ?></a></li>
</ul>
<div id="lang-select">
LANG:<?php
foreach($langs as $lang){
printf(' <a href="/?lang=%s">%s</a>', $lang, strtoupper($lang));
}
?></div>
</div>
<div id="content" class="row">
<div id="main-section" class="section column middle">
<h2><?= $trans('welcome') ?></h2>
</div>
<div id="links" class="column right section">
<h2><?= $trans('links') ?></h2>
<h3><?= $trans('programming') ?></h3><ul>
<li><a href="https://git.fai.st/dendy"><?= $trans('git') ?></a></li>
</ul>
<h3><?= $trans('people') ?></h3>
<ul>
<li><a href="https://dusk.fai.st">Dusk</a></li>
<li><a href="https://yari.fai.st">Yarita</a></li>
<li><a href="https://lidiarock.one">LidiaRock1</a></li>
</ul>
</div>
<div id="contact" class="column right section">
<h2><?= $trans('contact') ?></h2>
<ul>
<li><a href="https://awoo.fai.st/dendy" rel="me" target="_blank">Fedi</a></li>
<li><a href="xmpp:dendy@fai.st">XMPP</a></li>
<li><a target="_blank" href="https://matrix.to/#/@dendy:fai.st">Matrix</a></li>
</ul>
<h2><?= $trans('keys') ?></h2>
<ul>
<li><a target="_blank" href="static/dendy.asc">PGP public key</a></li>
</ul>
</div>
</div>
<div class="section" id="fediring">
<ul>
<li><a href="https://fediring.net/previous?host=dendy.cat">&lt;-</a></li>
<li><a href="https://fediring.net/">Fediring</a></li>
<li><a href="https://fediring.net/next?host=dendy.cat">-&gt;</a></li>
</ul>
</div>
<div class="section" id="footer">
<?= $trans('copyright') ?>
</div>
</body>
</html>
match ($GLOBALS['PARSED_PATH'][0]) {
'' => include_once "$_dr/pages/index.php",
default => printf("404"),
};

95
pages/index.php Normal file
View File

@ -0,0 +1,95 @@
<?php
include_once "$_dr/utils/localization.php";
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?= $trans('title') ?></title>
<meta name="author" content="Dendy">
<!-- Stylesheets -->
<link rel="stylesheet" href="static/style/reset.css">
<link rel="stylesheet" href="static/style/main.css">
</head>
<body>
<div id="title">
<img src="static/resources/avi.png" />
<div>
<h1><?= $trans('title') ?></h1>
<p><?= $trans('subtitle') ?></p>
</div>
</div>
<nav id="navbar" class="section">
<ul>
<li><a href="#"><?= $trans('home') ?></a></li>
<li><a href="#"><?= $trans('gallery') ?></a></li>
<li><a href="#"><?= $trans('blog') ?></a></li>
<li><a href="#"><?= $trans('about') ?></a></li>
</ul>
<div id="lang-select">
LANG:<?php
foreach ($langs as $lang) {
printf(' <a href="/?lang=%s">%s</a>', $lang, strtoupper($lang));
}
?>
</div>
</nav>
<main class="row">
<div class="column middle">
<div class="section">
<header><?= $trans('welcomeHeader') ?></header>
<?= $trans('welcome') ?>
</div>
<div class="section">
<header><?= $trans('projectsHeader') ?></header>
<?= $trans('projects') ?>
</div>
</div>
<div id="links" class="column right section">
<header><?= $trans('links') ?></header>
<h3><?= $trans('programming') ?></h3>
<ul>
<li><a href="https://git.fai.st/dendy"><?= $trans('git') ?></a></li>
</ul>
<h3><?= $trans('people') ?></h3>
<ul>
<li><a href="https://dusk.fai.st">Dusk</a></li>
<li><a href="https://yari.fai.st">Yarita</a></li>
<li><a href="https://lidiarock.one">LidiaRock1</a></li>
<li><a href="https://sugui.me">Suguivy</a></li>
</ul>
</div>
<div id="contact" class="column right section">
<header><?= $trans('contact') ?></header>
<ul>
<li><a href="https://awoo.fai.st/dendy" target="_blank">Fedi</a></li>
<li><a href="xmpp:dendy@fai.st">XMPP</a></li>
<li><a target="_blank" href="https://matrix.to/#/@dendy:fai.st">Matrix</a></li>
<li><a type="application/pgp-keys" target="_blank" href="https://keys.openpgp.org/vks/v1/by-fingerprint/AB537E17CB430578DBFF75080168B35FFD7F608F">PGP public key</a></li>
</ul>
</div>
</main>
<div class="section" id="fediring">
<ul>
<li><a href="https://fediring.net/previous?host=dendy.cat">&lt;-</a></li>
<li><a href="https://fediring.net/">Fediring</a></li>
<li><a href="https://fediring.net/next?host=dendy.cat">-&gt;</a></li>
</ul>
</div>
<div class="section" id="footer">
<?= $trans('copyright') ?>
</div>
</body>

View File

@ -1,63 +1,84 @@
/**
/********************
* Generic elements *
**/
++++++++++++++++++**/
*{
box-sizing: border-box;
box-sizing: border-box;
}
body{
background-color: rgb(14,14,14);
background-image: url(../resources/background.png);
background-size: cover;
color: white;
margin: 40px 10%;
font-family: sans-serif;
background-color: rgb(14,14,14);
background-image: url(../resources/background.png);
background-size: cover;
color: white;
margin: 40px 10%;
font-family: sans-serif;
}
h1{
font-size: 40px;
font-weight: bold;
font-size: 40px;
font-weight: bold;
margin-bottom: 5px;
}
h2{
text-align: center;
font-size: 20px;
font-weight: bold;
margin-bottom: 20px;
text-align: center;
font-size: 20px;
font-weight: bold;
margin-bottom: 20px;
}
h3{
font-weight: bold;
margin-bottom: 5px;
font-weight: bold;
margin-bottom: 5px;
}
a{
text-decoration: none;
color: darkgrey;
text-decoration: none;
color: darkgrey;
}
a:hover{
a:hover{
background-color: darkgrey;
color: black;
}
color: black;
}
p{
margin-bottom: 10px;
margin-bottom: 10px;
}
b{
font-weight: bold;
}
/**
/******************
* General layout *
**/
+++++++++++++++++*/
main {
padding: 10px 0px;
}
.section{
background-color: rgba(5,5,5,0.6);
margin-bottom: 10px;
padding: 30px;
border: 1px solid rgba(255,255,255,0.15);
border-radius: 5px;
background-color: rgba(5,5,5,0.6);
margin-bottom: 10px;
padding: 20px;
border: 1px solid rgba(255,255,255,0.25);
}
.section header{
text-align: center;
font-size: 20px;
font-weight: bold;
margin-bottom: 20px;
padding-bottom: 10px;
border-bottom: 1px solid rgba(255,255,255,0.25);
}
.section p:last-of-type {
margin-bottom: 0px;
}
.row:after {
content: "";
@ -65,26 +86,25 @@ p{
clear: both;
}
.column{
float: left;
float: left;
}
.column.middle{
width: 75%;
padding: 30px;
.column.middle{
width: 75%;
min-height: 400px;
}
.column.right{
width: calc(25% - 10px);
margin-left: 10px;
}
}
.column.right{
width: calc(25% - 20px);
margin-left: 20px;
}
.column.right li::before{
content: "· ";
}
@media screen and (max-width: 1070px){
.column.middle{
@media screen and (max-width: 1070px){
.column.middle{
width: 100%;
margin-left: 0px;
}
margin-left: 0px;
}
.column.right {
width: calc(50% - 5px);
margin-left: 0px;
@ -93,26 +113,26 @@ p{
.column.right:last-of-type{
margin-right: 0px;
}
}
}
#footer{
padding: 20px;
padding: 20px;
}
/**
* Page title *
**/
/***************
* Page header *
***************/
#title{
margin-bottom: 10px;
margin-bottom: 10px;
}
#title img {
display: none;
float: left;
#title img {
display: none;
float: left;
/* overlap border */
transform: translateY(1px);
}
}
#title:after {
content: "";
display: table;
@ -121,33 +141,33 @@ p{
#title div {
padding-top: 20px;
}
@media screen and (min-width: 800px){
#title{
margin-bottom:0;
}
#title img{
display: block;
}
}
@media screen and (min-width: 800px){
#title{
margin-bottom:0;
}
#title img{
display: block;
}
}
#menu, #fediring{
padding:0;
overflow: hidden;
padding: 10px 15px;
#navbar, #fediring{
padding:0;
overflow: hidden;
padding: 10px 15px;
}
#menu li { float: left; }
#navbar li { float: left; }
#lang-select { float: right; }
#menu a, #fediring a{
/*display: block;*/
color: white;
text-align: center;
padding: 12px 15px;
}
#menu a:hover, #fediring a:hover, #menu a.activated{
background: rgba(255,255,255,1);
#navbar a, #fediring a{
/*display: block;*/
color: white;
text-align: center;
padding: 12px 15px;
}
#navbar a:hover, #fediring a:hover, #navbar a.activated{
background: rgba(255,255,255,1);
color: black
}
}
#fediring{
text-align: center;

View File

@ -1,7 +1,7 @@
<?php
/////////////////////////////////////////////////
// Avaliable variables after importing this file
/////////////////////////////////////////////////
// Avaliable variables after importing this file
/////////////////////////////////////////////////
// The actual language being used
@ -9,7 +9,9 @@ $lang = null;
// Avaliable detected languages
$langs = [];
// Function that gets the strings
$trans = function(){ return 'N/A'; };
$trans = function () {
return 'N/A';
};
/* I use functions to create scopes. Anything below
* shouldn't be accesible from outside
@ -17,83 +19,83 @@ $trans = function(){ return 'N/A'; };
/* -------------------------------------------------*/
$__langfunc = function() use (&$lang, &$langs, &$trans){
$__langfunc = function () use (&$lang, &$langs, &$trans) {
///////////////
/// Get basedir
///////////////
/// Get basedir
///////////////
// DOCUMENT_ROOT makes sure we always get the right folder
$basedir = sprintf('%s/lang', $_SERVER['DOCUMENT_ROOT']);
///////////////////////////////////////
/// Get the languages we have avaliable
///////////////////////////////////////
/// Get the languages we have avaliable
///////////////////////////////////////
// To get the langs we scan the folder with the ini files
$langs = scandir($basedir);
// Filter for those that have to letters and end in ".ini"
$langs = array_filter($langs, fn($x) => preg_match('/.*\.ini/', $x) === 1);
// Filter for those that have two letters and end in ".ini"
$langs = array_filter($langs, fn ($x) => preg_match('/.*\.ini/', $x) === 1);
// And we remove the ".ini" part
$langs = array_map(fn($x) => substr($x, 0, 2), $langs);
$langs = array_map(fn ($x) => substr($x, 0, 2), $langs);
////////////////////////////////////
/// Get the optimal language to use
////////////////////////////////////
/// Get the optimal language to use
////////////////////////////////////
/* Try to get the language from browser-sent headers. The
* format for the header is like this: "en_US,es;q=0.5,ar;q=0.1".
* q=N represents the weight of preference, no q means q=1.0.
*/
{
if ($_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? false) {
// Divide language string per language
$http_langs = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
// Sanitize lang string and cast weight
$http_langs = array_map(function($x){
$x = explode(';',$x);
$http_langs = array_map(function ($x) {
$x = explode(';', $x);
$x[0] = strtolower(substr($x[0], 0, 2));
$x[1] = (float)(explode('=',$x[1]??'q=1.0')[1]??1.0);
$x[1] = (float)(explode('=', $x[1] ?? 'q=1.0')[1] ?? 1.0);
return $x;
}, $http_langs);
// Sort by weight
usort($http_langs, function($a, $b){
if($a[1] === $b[1]) return 0;
usort($http_langs, function ($a, $b) {
if ($a[1] === $b[1]) return 0;
return ($a[1] > $b[1]) ? -1 : 1;
});
// Create new neat array like this: ['en', 'es', 'ar']
$user_langs = [];
array_walk($http_langs, function($arr) use (&$user_langs){
if(!in_array($arr[0], $user_langs)) $user_langs[] = $arr[0];
array_walk($http_langs, function ($arr) use (&$user_langs) {
if (!in_array($arr[0], $user_langs)) $user_langs[] = $arr[0];
});
// Assign the first match
foreach($user_langs as $ilang){
if(in_array($ilang, $langs)) {
foreach ($user_langs as $ilang) {
if (in_array($ilang, $langs)) {
$lang = $ilang;
break;
}
}
}
// Manully selected lang > HTTP lang > fallback lang
$lang = ($_GET['lang']??null) ?: $lang ?: 'en';
$lang = ($_GET['lang'] ?? null) ?: $lang ?: 'en';
///////////////////////////////////////////////////
/// Get file and build function to get the strings
///////////////////////////////////////////////////
/// Get file and build function to get the strings
///////////////////////////////////////////////////
$text = parse_ini_file("$basedir/$lang.ini", true);
$trans = function (string $index) use ($text): string{
return htmlspecialchars($text[$index]??"N/A", ENT_QUOTES);
$trans = function (string $index) use ($text): string {
// return htmlspecialchars($text[$index] ?? 'N/A', ENT_QUOTES);
return $text[$index] ?? 'N/A';
};
};