mirror of
https://codeberg.org/vlw/vlw.se.git
synced 2025-09-13 21:13:40 +02:00
Compare commits
72 commits
Author | SHA1 | Date | |
---|---|---|---|
e8a81b789b | |||
5e9317def5 | |||
8209ea5ecc | |||
85e8e00091 | |||
d4d73e9278 | |||
fafa8c5852 | |||
03492df615 | |||
37f2ac00c3 | |||
d5cc7fa82c | |||
17bd93dca9 | |||
6b5eee505a | |||
cd3139e778 | |||
afe450a6d2 | |||
b398354594 | |||
62ddd25f38 | |||
fef10a8ea8 | |||
a6c74f5c4f | |||
f60a27855d | |||
c5c7aaa919 | |||
f4279c0343 | |||
f76962e2ac | |||
5c7c9d2d3a | |||
041d175757 | |||
0bb7a3a8be | |||
0baa6f8d85 | |||
4b71bbd10e | |||
56cf142e0d | |||
2fa62991f9 | |||
359342c7f7 | |||
e420f33d4a | |||
e25b1b6689 | |||
3b51458dd4 | |||
ff7d4f5397 | |||
07e0046828 | |||
18e1ae5088 | |||
9e3c549e0a | |||
80c6579136 | |||
1ac2704124 | |||
f551d5d889 | |||
51e8215e78 | |||
7f4b54685e | |||
6dad22f226 | |||
0483e092dd | |||
ae1e992c5f | |||
43ddf1fdf6 | |||
903a14b3ae | |||
99e9996e93 | |||
7cd41d3e13 | |||
bef1bab522 | |||
285bdc3980 | |||
ce1f3e3bab | |||
32f13b356a | |||
608f775f24 | |||
e1e4c3fd1a | |||
0478685791 | |||
fd04c3d5ae | |||
9b3ab0b17b | |||
a7655f9cdb | |||
412a457bee | |||
982acc6a40 | |||
3fd7ce6bf0 | |||
e1e3a4a68a | |||
87cf63c884 | |||
3154afab3c | |||
f963a8993d | |||
3f944e1a33 | |||
94d20d51ae | |||
a7d2730aac | |||
8dccd20d39 | |||
a82c853153 | |||
6ef024db6f | |||
a8a1c5791f |
179 changed files with 4079 additions and 3991 deletions
|
@ -1,4 +1,15 @@
|
|||
[api]
|
||||
base_url = "https://api.vlw.one/"
|
||||
api_key = ""
|
||||
verify_peer = 0
|
||||
[mariadb]
|
||||
host = ""
|
||||
user = ""
|
||||
pass = ""
|
||||
db = ""
|
||||
|
||||
[config_time_available]
|
||||
time_zone = "Europe/Stockholm"
|
||||
available_to_hour = 0;
|
||||
reply_average_hours = 0;
|
||||
available_from_hour = 0;
|
||||
|
||||
[service_forgejo]
|
||||
url = ""
|
||||
profiles = ""
|
18
.gitignore
vendored
18
.gitignore
vendored
|
@ -1,18 +1,2 @@
|
|||
assets/media/content
|
||||
|
||||
# Bootstrapping #
|
||||
#################
|
||||
vendor
|
||||
.env.ini
|
||||
|
||||
# OS generated files #
|
||||
######################
|
||||
.DS_Store
|
||||
.DS_Store?
|
||||
._*
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
Icon?
|
||||
ehthumbs.db
|
||||
Thumbs.db
|
||||
.directory
|
||||
.env.ini
|
6
.gitmodules
vendored
Normal file
6
.gitmodules
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
[submodule "reflect"]
|
||||
path = reflect
|
||||
url = https://codeberg.org/reflect/reflect
|
||||
[submodule "vegvisir"]
|
||||
path = vegvisir
|
||||
url = https://codeberg.org/vegvisir/vegvisir
|
80
README.md
80
README.md
|
@ -1,65 +1,27 @@
|
|||
# vlw.se
|
||||
This is the source code behind [vlw.se](https://vlw.se) which has been written from the ground up by me. This website is built on top of my [Vegvisir web framework](https://github.com/victorwesterlund/vegvisir) and my [Reflect API framework](https://github.com/victorwesterlund/reflect).
|
||||
This is the source code behind [vlw.se](https://vlw.se) which is my personal website that I have written and designed from the ground up. The website is built on top of my own [Vegvisir web framework](https://vegvisir.vlw.se) and its optional REST API is built on top of my [Reflect API framework](https://reflect.vlw.se).
|
||||
|
||||
# Installation
|
||||
If you for whatever reason want to get this website up and running for yourself this is how that is done.
|
||||
Here's how you get my website up and running on your own machine. Note, I have only tested this on Linux and the install script we will run requires Bash with `coreutils` installed.
|
||||
|
||||
This website is built for PHP 8.0+ and MariaDB 14+ (for the API database).
|
||||
## Prerequisites
|
||||
- A web server
|
||||
- A MariaDB/MySQL server
|
||||
- PHP 8.4 or newer with the following extensions enabled:
|
||||
- - `php8.4-mysql`
|
||||
- - `php8.4-mbstring`
|
||||
- The composer package manager
|
||||
- Bash with `coreutils` installed (for the install script)
|
||||
|
||||
## Website (Vegvisir)
|
||||
1. **Download this repo**
|
||||
|
||||
Git clone or download this repo to any local folder
|
||||
```
|
||||
git clone https://github.com/VictorWesterlund/vlw.se
|
||||
```
|
||||
2. **Download and install Vegvisir**
|
||||
|
||||
Follow the installation instructions for [Vegvisir](https://github.com/victorwesterlund/vegvisir) and point the `site_path` variable to the local vlw.se folder.
|
||||
## 1. Clone this repo
|
||||
Clone this repository with its submodules. Preferably to a non-public directory - the frameworks will handle that.
|
||||
```
|
||||
git clone https://codeberg.org/vlw/vlw.se --recurse-submodules --depth 1
|
||||
```
|
||||
|
||||
3. **Install dependencies**
|
||||
|
||||
Install dependencies with composer.
|
||||
```
|
||||
composer install --optimize-autoloader
|
||||
```
|
||||
|
||||
Et voila! You probably want to install the API-side too but the website itself should now be accessible from your configured Vegvisir host.
|
||||
|
||||
## API (Reflect)
|
||||
The API (and database) is where most content is stored and served from on this website.
|
||||
|
||||
1. **Download this repo**
|
||||
|
||||
**You can skip this if you've already downloaded the repo from step 1 in the website installation.**
|
||||
|
||||
Otherwise... Git clone or download this repo to any local folder
|
||||
```
|
||||
git clone https://github.com/VictorWesterlund/vlw.se
|
||||
```
|
||||
|
||||
2. **Download and install Reflect**
|
||||
|
||||
Follow the installation instructions for [Reflect](https://github.com/victorwesterlund/vegvisir) and point the `endpoints` variable to the `/api` subdirectory in the local vlw.se folder.
|
||||
|
||||
3. **Install dependencies**
|
||||
|
||||
Install dependencies with composer.
|
||||
```
|
||||
composer install --optimize-autoloader
|
||||
```
|
||||
|
||||
4. **Create and import database**
|
||||
|
||||
[Create and] import the two databases associated with vlw.se data and the Reflect API configurations from `.sql` files on the Releases page.
|
||||
|
||||
5. **Set environment variables**
|
||||
|
||||
Make a copy of `/api/.env.example.ini` and change the `[vlwdb]` variables with your MariaDB credentials.
|
||||
|
||||
You also have to generate a [GitHub access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) if you wish to use the `releases` endpoint.
|
||||
[Read more about this endpoint here](#)
|
||||
|
||||
6. **Set environment variables for website**
|
||||
|
||||
It's reasonable to assume if you've installed the website from this repo that you'd also want to use the API with it. Start my making a copy of `/.env.example.ini` (root directory) and change the `[api]` variables to point to your API hostname.
|
||||
## 2. Run the install script
|
||||
Run the `install.sh` script from the root directory of this repository.
|
||||
```
|
||||
./install.sh
|
||||
```
|
||||
This script will install and configure Vegvisir, Reflect, and the website through a few propmpted steps.
|
|
@ -1,11 +0,0 @@
|
|||
[vlwdb]
|
||||
mariadb_host = ""
|
||||
mariadb_user = ""
|
||||
mariadb_pass = ""
|
||||
mariadb_db = ""
|
||||
|
||||
[github]
|
||||
api_key = ""
|
||||
# Use-Agent string sent to GitHub API
|
||||
# They recommend setting it to your GitHub username or app name
|
||||
user_agent = ""
|
29
api/coffee/DELETE.php
Normal file
29
api/coffee/DELETE.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
use Reflect\{Response, Path};
|
||||
use Reflect\Rules\{Ruleset, Rules, Type};
|
||||
|
||||
use VLW\API\API;
|
||||
use VLW\Helpers\UUID;
|
||||
use VLW\Database\Models\Coffee\Coffee;
|
||||
use VLW\Database\Tables\Coffee\Coffee as CoffeeTable;
|
||||
|
||||
require_once Path::root("src/API/API.php");
|
||||
require_once Path::root("src/Database/Models/Coffee/Coffee.php");
|
||||
require_once Path::root("src/Database/Tables/Coffee/Coffee.php");
|
||||
|
||||
final class DELETE_Coffee extends API {
|
||||
public function __construct() {
|
||||
parent::__construct(new Ruleset()->GET([
|
||||
new Rules(CoffeeTable::ID->value)
|
||||
->required()
|
||||
->type(Type::STRING)
|
||||
->min(UUID::LENGTH)
|
||||
->max(UUID::LENGTH)
|
||||
]));
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
return new Response(new Coffee($_GET[CoffeeTable::ID->value])->delete());
|
||||
}
|
||||
}
|
19
api/coffee/GET.php
Normal file
19
api/coffee/GET.php
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
use Reflect\{Response, Path};
|
||||
|
||||
use VLW\API\API;
|
||||
use VLW\Database\Models\Coffee\Coffee;
|
||||
|
||||
require_once Path::root("src/API/API.php");
|
||||
require_once Path::root("src/Database/Models/Coffee/Coffee.php");
|
||||
|
||||
final class GET_Coffee extends API {
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
return new Response(Coffee::all());
|
||||
}
|
||||
}
|
41
api/coffee/POST.php
Normal file
41
api/coffee/POST.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
use Reflect\{Response, Path};
|
||||
use Reflect\Rules\{Ruleset, Rules, Type};
|
||||
|
||||
use VLW\API\API;
|
||||
use VLW\Database\Models\Coffee\Coffee;
|
||||
use VLW\Database\Tables\Coffee\Coffee as CoffeeTable;
|
||||
|
||||
require_once Path::root("src/API/API.php");
|
||||
require_once Path::root("src/Database/Models/Coffee/Coffee.php");
|
||||
require_once Path::root("src/Database/Tables/Coffee/Coffee.php");
|
||||
|
||||
final class POST_Coffee extends API {
|
||||
public function __construct() {
|
||||
parent::__construct(new Ruleset(strict: true)->POST([
|
||||
new Rules(CoffeeTable::DATE_CREATED->value)
|
||||
->type(Type::STRING)
|
||||
->type(Type::NUMBER)
|
||||
->default(null)
|
||||
]));
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
$datetime = new DateTimeImmutable();
|
||||
|
||||
// Parse DateTime from POST string
|
||||
if ($_POST[CoffeeTable::DATE_CREATED->value]) {
|
||||
try {
|
||||
// Create DateTimeImmutable from Unix timestamp or datetime string
|
||||
$datetime = gettype($_POST[CoffeeTable::DATE_CREATED->value]) === "integer"
|
||||
? DateTimeImmutable::createFromTimestamp($_POST[CoffeeTable::DATE_CREATED->value])
|
||||
: new DateTimeImmutable($_POST[CoffeeTable::DATE_CREATED->value]);
|
||||
} catch (DateMalformedStringException $error) {
|
||||
return new Response($error->getMessage(), 400);
|
||||
}
|
||||
}
|
||||
|
||||
return new Response(Coffee::new($datetime));
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
{
|
||||
"require": {
|
||||
"local/api.endpoints": "1.0.0-dev",
|
||||
"reflect/plugin-rules": "^1.5",
|
||||
"victorwesterlund/xenum": "^1.1"
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"repositories": [
|
||||
{
|
||||
"type": "path",
|
||||
"url": "src/packages/Endpoints"
|
||||
}
|
||||
]
|
||||
}
|
120
api/composer.lock
generated
120
api/composer.lock
generated
|
@ -1,120 +0,0 @@
|
|||
{
|
||||
"_readme": [
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "9da96ba90ef20d885034442b30dce0a3",
|
||||
"packages": [
|
||||
{
|
||||
"name": "local/api.endpoints",
|
||||
"version": "1.0.0-dev",
|
||||
"dist": {
|
||||
"type": "path",
|
||||
"url": "src/packages/Endpoints",
|
||||
"reference": "89b7b9a4cc504abddb4aeec8e05a95c9d9087575"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"VLW\\API\\": "src/"
|
||||
}
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Victor Westerlund",
|
||||
"email": "victor@vlw.se"
|
||||
}
|
||||
],
|
||||
"description": "Endpoint pathmappings for VLW API",
|
||||
"transport-options": {
|
||||
"relative": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "reflect/plugin-rules",
|
||||
"version": "1.5.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/VictorWesterlund/reflect-rules-plugin.git",
|
||||
"reference": "9c837fd1944133edfed70a63ce8b32bf67f0d94b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/VictorWesterlund/reflect-rules-plugin/zipball/9c837fd1944133edfed70a63ce8b32bf67f0d94b",
|
||||
"reference": "9c837fd1944133edfed70a63ce8b32bf67f0d94b",
|
||||
"shasum": ""
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"ReflectRules\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"GPL-3.0-only"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Victor Westerlund",
|
||||
"email": "victor.vesterlund@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Add request search paramter and request body constraints to an API built with Reflect",
|
||||
"support": {
|
||||
"issues": "https://github.com/VictorWesterlund/reflect-rules-plugin/issues",
|
||||
"source": "https://github.com/VictorWesterlund/reflect-rules-plugin/tree/1.5.0"
|
||||
},
|
||||
"time": "2024-01-17T11:07:44+00:00"
|
||||
},
|
||||
{
|
||||
"name": "victorwesterlund/xenum",
|
||||
"version": "1.1.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/VictorWesterlund/php-xenum.git",
|
||||
"reference": "8972f06f42abd1f382807a67e937d5564bb89699"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/VictorWesterlund/php-xenum/zipball/8972f06f42abd1f382807a67e937d5564bb89699",
|
||||
"reference": "8972f06f42abd1f382807a67e937d5564bb89699",
|
||||
"shasum": ""
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"victorwesterlund\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"GPL-3.0-only"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Victor Westerlund",
|
||||
"email": "victor.vesterlund@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "PHP eXtended Enums. The missing quality-of-life features from PHP 8+ Enums",
|
||||
"support": {
|
||||
"issues": "https://github.com/VictorWesterlund/php-xenum/issues",
|
||||
"source": "https://github.com/VictorWesterlund/php-xenum/tree/1.1.1"
|
||||
},
|
||||
"time": "2023-11-20T10:10:39+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
"aliases": [],
|
||||
"minimum-stability": "dev",
|
||||
"stability-flags": {
|
||||
"local/api.endpoints": 20
|
||||
},
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": [],
|
||||
"platform-dev": [],
|
||||
"plugin-api-version": "2.0.0"
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
<?php
|
||||
|
||||
|
||||
use Reflect\Path;
|
||||
use Reflect\Response;
|
||||
|
||||
use VLW\API\Databases\VLWdb\VLWdb;
|
||||
use VLW\API\Databases\VLWdb\Models\Coffee\CoffeeModel;
|
||||
|
||||
require_once Path::root("src/databases/VLWdb.php");
|
||||
require_once Path::root("src/databases/models/Coffee.php");
|
||||
|
||||
class GET_Coffee extends VLWdb {
|
||||
const LIST_LIMIT = 20;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
// Return a 503 Service Unavailable error if something went wrong with the database call
|
||||
private function resp_database_error(): Response {
|
||||
return new Response("Failed to get work data, please try again later", 503);
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
// Get the last LIST_LIMIT coffees from the database
|
||||
$resp = $this->db->for(CoffeeModel::TABLE)
|
||||
->order([CoffeeModel::DATE_TIMESTAMP_CREATED->value => "DESC"])
|
||||
->limit(self::LIST_LIMIT)
|
||||
->select([
|
||||
CoffeeModel::ID->value,
|
||||
CoffeeModel::DATE_TIMESTAMP_CREATED->value
|
||||
]);
|
||||
|
||||
return parent::is_mysqli_result($resp)
|
||||
? new Response($resp->fetch_all(MYSQLI_ASSOC))
|
||||
: $this->resp_database_error();
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Reflect\Path;
|
||||
use Reflect\Response;
|
||||
|
||||
use VLW\API\Databases\VLWdb\VLWdb;
|
||||
use VLW\API\Databases\VLWdb\Models\Coffee\CoffeeModel;
|
||||
|
||||
require_once Path::root("src/databases/VLWdb.php");
|
||||
require_once Path::root("src/databases/models/Coffee.php");
|
||||
|
||||
class POST_Coffee extends VLWdb {
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
// Return a 503 Service Unavailable error if something went wrong with the database call
|
||||
private function resp_database_error(): Response {
|
||||
return new Response("Failed to record coffee! Ugh please take a note somewhere else", 503);
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
// Generate UUID for entity
|
||||
$id = parent::gen_uuid4();
|
||||
|
||||
// Attempt to create new entity
|
||||
$insert = $this->db->for(CoffeeModel::TABLE)
|
||||
->insert([
|
||||
CoffeeModel::ID->value => $id,
|
||||
CoffeeModel::DATE_TIMESTAMP_CREATED->value => time(),
|
||||
]);
|
||||
|
||||
// Return 201 Created and entity id if successful
|
||||
return $insert ? new Response($id, 201) : $this->resp_database_error();
|
||||
}
|
||||
}
|
|
@ -1,95 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Reflect\Path;
|
||||
use Reflect\Response;
|
||||
use ReflectRules\Type;
|
||||
use ReflectRules\Rules;
|
||||
use ReflectRules\Ruleset;
|
||||
|
||||
use VLW\API\Databases\VLWdb\VLWdb;
|
||||
use VLW\API\Databases\VLWdb\Models\Media\MediaModel;
|
||||
|
||||
use victorwesterlund\xEnum;
|
||||
|
||||
require_once Path::root("src/databases/VLWdb.php");
|
||||
require_once Path::root("src/databases/models/Media.php");
|
||||
|
||||
enum MediaDispositionEnum: string {
|
||||
use xEnum;
|
||||
|
||||
case METADATA = "metadata";
|
||||
case INLINE = "inline";
|
||||
case DOWNLOAD = "download";
|
||||
}
|
||||
|
||||
class GET_Media extends VLWdb {
|
||||
const GET_DISPOSITION_KEY = "disposition";
|
||||
|
||||
protected Ruleset $ruleset;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->ruleset = new Ruleset(strict: true);
|
||||
|
||||
$this->ruleset->GET([
|
||||
(new Rules(MediaModel::ID->value))
|
||||
->required()
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::MYSQL_VARCHAR_MAX_LENGTH),
|
||||
|
||||
(new Rules(self::GET_DISPOSITION_KEY))
|
||||
->type(Type::ENUM, MediaDispositionEnum::values())
|
||||
->default(MediaDispositionEnum::METADATA->value)
|
||||
]);
|
||||
}
|
||||
|
||||
// # Helper methods
|
||||
|
||||
private function fetch_srcset(string $id): array {
|
||||
$resp = $this->db->for(WorkTagsModel::TABLE)
|
||||
->where([WorkTagsModel::ANCHOR->value => $id])
|
||||
->select(WorkTagsModel::NAME->value);
|
||||
|
||||
return parent::is_mysqli_result($resp) ? $resp->fetch_all(MYSQLI_ASSOC) : [];
|
||||
}
|
||||
|
||||
// # Responses
|
||||
|
||||
// Return 422 Unprocessable Content error if request validation failed
|
||||
private function resp_rules_invalid(): Response {
|
||||
return new Response($this->ruleset->get_errors(), 422);
|
||||
}
|
||||
|
||||
// Return a 503 Service Unavailable error if something went wrong with the database call
|
||||
private function resp_database_error(): Response {
|
||||
return new Response("Failed to get work data, please try again later", 503);
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
// Bail out if request validation failed
|
||||
if (!$this->ruleset->is_valid()) {
|
||||
return $this->resp_rules_invalid();
|
||||
}
|
||||
|
||||
$resp = $this->db->for(MediaModel::TABLE)
|
||||
->where([MediaModel::ID->value => $_GET[MediaModel::ID->value]])
|
||||
->select([
|
||||
MediaModel::ID->value,
|
||||
MediaModel::NAME->value,
|
||||
MediaModel::TYPE->value,
|
||||
MediaModel::MIME->value,
|
||||
MediaModel::EXTENSION->value,
|
||||
MediaModel::SRCSET->value,
|
||||
MediaModel::DATE_TIMESTAMP_CREATED->value,
|
||||
]);
|
||||
|
||||
// Bail out if something went wrong retrieving rows from the database
|
||||
if (!parent::is_mysqli_result($resp)) {
|
||||
return $this->resp_database_error();
|
||||
}
|
||||
|
||||
$media = $resp->fetch_assoc();
|
||||
$test = true;
|
||||
}
|
||||
}
|
|
@ -1,117 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Reflect\Path;
|
||||
use Reflect\Response;
|
||||
use ReflectRules\Type;
|
||||
use ReflectRules\Rules;
|
||||
use ReflectRules\Ruleset;
|
||||
|
||||
use Reflect\Method;
|
||||
use function Reflect\Call;
|
||||
|
||||
use VLW\API\Databases\VLWdb\VLWdb;
|
||||
use VLW\API\Databases\VLWdb\Models\Media\MediaModel;
|
||||
use VLW\API\Databases\VLWdb\Models\Media\MediaTypeEnum;
|
||||
|
||||
require_once Path::root("src/databases/VLWdb.php");
|
||||
require_once Path::root("src/databases/models/Media.php");
|
||||
|
||||
class POST_Media extends VLWdb {
|
||||
protected Ruleset $ruleset;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->ruleset = new Ruleset(strict: true);
|
||||
|
||||
$this->ruleset->POST([
|
||||
(new Rules(MediaModel::ID->value))
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::MYSQL_VARCHAR_MAX_LENGTH)
|
||||
->default(parent::gen_uuid4()),
|
||||
|
||||
(new Rules(MediaModel::NAME->value))
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::MYSQL_VARCHAR_MAX_LENGTH)
|
||||
->default(null),
|
||||
|
||||
(new Rules(MediaModel::TYPE->value))
|
||||
->type(Type::ENUM, MediaTypeEnum::values())
|
||||
->default(null),
|
||||
|
||||
(new Rules(MediaModel::EXTENSION->value))
|
||||
->type(Type::STRING)
|
||||
->min(3)
|
||||
->max(parent::MYSQL_VARCHAR_MAX_LENGTH)
|
||||
->default(null),
|
||||
|
||||
(new Rules(MediaModel::MIME->value))
|
||||
->type(Type::STRING)
|
||||
->min(3)
|
||||
->max(parent::MYSQL_VARCHAR_MAX_LENGTH)
|
||||
->default(null),
|
||||
|
||||
(new Rules(MediaModel::SRCSET->value))
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::MYSQL_VARCHAR_MAX_LENGTH)
|
||||
->default(null)
|
||||
]);
|
||||
}
|
||||
|
||||
// # Helper methods
|
||||
|
||||
// Returns true if an srcset exists for provided key
|
||||
private static function media_srcset_exists(): bool {
|
||||
// No srcet get parameter has been set
|
||||
if (empty($_POST[MediaModel::SRCSET->value])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if the provided srcset exists by calling the srcset endpoint
|
||||
return Call("media/srcset?id={$_POST[MediaModel::SRCSET->value]}", Method::GET)->ok;
|
||||
}
|
||||
|
||||
// # Responses
|
||||
|
||||
// Return 422 Unprocessable Content error if request validation failed
|
||||
private function resp_rules_invalid(): Response {
|
||||
return new Response($this->ruleset->get_errors(), 422);
|
||||
}
|
||||
|
||||
// Return a 503 Service Unavailable error if something went wrong with the database call
|
||||
private function resp_database_error(): Response {
|
||||
return new Response("Failed to get work data, please try again later", 503);
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
// Bail out if request validation failed
|
||||
if (!$this->ruleset->is_valid()) {
|
||||
return $this->resp_rules_invalid();
|
||||
}
|
||||
|
||||
// Bail out if an srcset doesn't exist
|
||||
if (!self::media_srcset_exists()) {
|
||||
return new Response("No media srcset exists with id '{$_POST[MediaModel::SRCSET->value]}'", 404);
|
||||
}
|
||||
|
||||
$insert = $this->db->for(MediaModel::TABLE)
|
||||
->insert([
|
||||
MediaModel::ID->value => $_POST[MediaModel::ID->value],
|
||||
MediaModel::NAME->value => $_POST[MediaModel::NAME->value],
|
||||
MediaModel::MIME->value => $_POST[MediaModel::MIME->value],
|
||||
// Strip dots from extension string if set
|
||||
MediaModel::EXTENSION->value => $_POST[MediaModel::EXTENSION->value]
|
||||
? str_replace(".", "", $_POST[MediaModel::EXTENSION->value])
|
||||
: null,
|
||||
MediaModel::SRCSET->value => $_POST[MediaModel::SRCSET->value],
|
||||
MediaModel::DATE_TIMESTAMP_CREATED->value => time()
|
||||
]);
|
||||
|
||||
// Return media id if insert was successful
|
||||
return $insert
|
||||
? new Response($_POST[MediaModel::ID->value], 201)
|
||||
: $this->resp_database_error();
|
||||
}
|
||||
}
|
|
@ -1,106 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Reflect\Path;
|
||||
use Reflect\Response;
|
||||
use ReflectRules\Type;
|
||||
use ReflectRules\Rules;
|
||||
use ReflectRules\Ruleset;
|
||||
|
||||
use VLW\API\Databases\VLWdb\VLWdb;
|
||||
use VLW\API\Databases\VLWdb\Models\Media\MediaModel;
|
||||
use VLW\API\Databases\VLWdb\Models\MediaSrcset\MediaSrcsetModel;
|
||||
|
||||
require_once Path::root("src/databases/VLWdb.php");
|
||||
require_once Path::root("src/databases/models/Media.php");
|
||||
require_once Path::root("src/databases/models/MediaSrcset.php");
|
||||
|
||||
class GET_MediaSrcset extends VLWdb {
|
||||
protected Ruleset $ruleset;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->ruleset = new Ruleset(strict: true);
|
||||
|
||||
$this->ruleset->GET([
|
||||
(new Rules(MediaSrcsetModel::ID->value))
|
||||
->required()
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::MYSQL_VARCHAR_MAX_LENGTH)
|
||||
]);
|
||||
}
|
||||
|
||||
// # Helper methods
|
||||
|
||||
// Get metadata for the requested srcset
|
||||
private function get_srcset(): array|false {
|
||||
$srcset = $this->db->for(MediaSrcsetModel::TABLE)
|
||||
->where([MediaSrcsetModel::ID->value => $_GET[MediaSrcsetModel::ID->value]])
|
||||
->select([MediaSrcsetModel::ANCHOR_DEFAULT->value]);
|
||||
|
||||
// Something went wrong retrieving rows from the database
|
||||
if (!parent::is_mysqli_result($srcset)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Return assoc array of srcset data if it exists
|
||||
return $srcset->num_rows === 1 ? $srcset->fetch_assoc() : false;
|
||||
}
|
||||
|
||||
// Get all media entities that are part of the requested srcset
|
||||
private function get_srcset_media(): mysqli_result|false {
|
||||
$media = $this->db->for(MediaModel::TABLE)
|
||||
->where([MediaModel::SRCSET->value => $_GET[MediaSrcsetModel::ID->value]])
|
||||
->select([
|
||||
MediaModel::ID->value,
|
||||
MediaModel::TYPE->value,
|
||||
MediaModel::MIME->value,
|
||||
MediaModel::EXTENSION->value
|
||||
]);
|
||||
|
||||
return parent::is_mysqli_result($media) ? $media : false;
|
||||
}
|
||||
|
||||
// # Responses
|
||||
|
||||
// Return 422 Unprocessable Content error if request validation failed
|
||||
private function resp_rules_invalid(): Response {
|
||||
return new Response($this->ruleset->get_errors(), 422);
|
||||
}
|
||||
|
||||
// Return a 503 Service Unavailable error if something went wrong with the database call
|
||||
private function resp_database_error(): Response {
|
||||
return new Response("Failed to get work data, please try again later", 503);
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
// Bail out if request validation failed
|
||||
if (!$this->ruleset->is_valid()) {
|
||||
return $this->resp_rules_invalid();
|
||||
}
|
||||
|
||||
// Get srcset data
|
||||
$srcset = $this->get_srcset();
|
||||
if (!$srcset) {
|
||||
return new Response("No media srcset exist with id '{$_GET[MediaSrcsetModel::ID->value]}'", 404);
|
||||
}
|
||||
|
||||
$media = $this->get_srcset_media();
|
||||
if (!$media) {
|
||||
return new Response("Failed to fetch srcset media", 500);
|
||||
}
|
||||
|
||||
$media_entities = $media->fetch_all(MYSQLI_ASSOC);
|
||||
|
||||
// This is the id of the media entity that is considered the default or "fallback"
|
||||
$srcet_default_media_id = $srcset[MediaSrcsetModel::ANCHOR_DEFAULT->value];
|
||||
|
||||
// Return assoc array of all media entities that are in this srcset
|
||||
return new Response([
|
||||
// Return default media entity separately from the rest of the srcset as an assoc array
|
||||
"default" => array_filter($media_entities, fn(array $entity) => $entity[MediaModel::ID->value] === $srcet_default_media_id)[0],
|
||||
// Return all media that isn't default as array of assoc arrays
|
||||
"srcset" => array_filter($media_entities, fn(array $entity) => $entity[MediaModel::ID->value] !== $srcet_default_media_id)
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Reflect\Path;
|
||||
use Reflect\Response;
|
||||
|
||||
use Reflect\Method;
|
||||
use function Reflect\Call;
|
||||
|
||||
use VLW\API\Databases\VLWdb\VLWdb;
|
||||
use VLW\API\Databases\VLWdb\Models\MediaSrcset\MediaSrcsetModel;
|
||||
|
||||
require_once Path::root("src/databases/VLWdb.php");
|
||||
require_once Path::root("src/databases/models/Media.php");
|
||||
require_once Path::root("src/databases/models/MediaSrcset.php");
|
||||
|
||||
class POST_MediaSrcset extends VLWdb {
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
// # Responses
|
||||
|
||||
// Return a 503 Service Unavailable error if something went wrong with the database call
|
||||
private function resp_database_error(): Response {
|
||||
return new Response("Failed to get work data, please try again later", 503);
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
// Generate a random UUID for this srcset
|
||||
$id = parent::gen_uuid4();
|
||||
|
||||
// Ensure an srcset with the generated id doesn't exist, although it shouldn't realistically ever happen
|
||||
$srcset_existing = Call("media/srcset?id={$id}", Method::GET);
|
||||
if ($srcset_existing->code !== 404) {
|
||||
// Wow a UUID4 collision... buy a lottery ticket
|
||||
if ($srcset_existing->code === 200) {
|
||||
return $this->main();
|
||||
}
|
||||
|
||||
// Failed to get srcset
|
||||
return new Response("Something went wrong when checking if the srcset exists", 500);
|
||||
}
|
||||
|
||||
// Create new srcset entity
|
||||
$insert = $this->db->for(MediaSrcsetModel::TABLE)
|
||||
->insert([
|
||||
MediaSrcsetModel::ID->value => $id
|
||||
]);
|
||||
|
||||
// Return created srcset id if successful
|
||||
return $insert
|
||||
? new Response($id, 201)
|
||||
: $this->resp_database_error();
|
||||
}
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Reflect\Path;
|
||||
use Reflect\Response;
|
||||
use ReflectRules\Type;
|
||||
use ReflectRules\Rules;
|
||||
use ReflectRules\Ruleset;
|
||||
|
||||
use Reflect\Method;
|
||||
use function Reflect\Call;
|
||||
|
||||
use VLW\API\Databases\VLWdb\VLWdb;
|
||||
use VLW\API\Databases\VLWdb\Models\Messages\MessagesModel;
|
||||
|
||||
require_once Path::root("src/databases/VLWdb.php");
|
||||
require_once Path::root("src/databases/models/Messages.php");
|
||||
|
||||
class POST_Messages extends VLWdb {
|
||||
protected Ruleset $ruleset;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->ruleset = new Ruleset(strict: true);
|
||||
|
||||
$this->ruleset->POST([
|
||||
(new Rules(MessagesModel::EMAIL->value))
|
||||
->type(Type::STRING)
|
||||
->max(255)
|
||||
->default(null),
|
||||
|
||||
(new Rules(MessagesModel::MESSAGE->value))
|
||||
->required()
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::MYSQL_TEXT_MAX_LENGTH)
|
||||
]);
|
||||
}
|
||||
|
||||
// # Responses
|
||||
|
||||
// Return 422 Unprocessable Content error if request validation failed
|
||||
private function resp_rules_invalid(): Response {
|
||||
return new Response($this->ruleset->get_errors(), 422);
|
||||
}
|
||||
|
||||
// Return a 503 Service Unavailable error if something went wrong with the database call
|
||||
private function resp_database_error(): Response {
|
||||
return new Response("Failed to get work data, please try again later", 503);
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
//return new Response(["hello" => "maybe"], 500);
|
||||
|
||||
// Bail out if request validation failed
|
||||
if (!$this->ruleset->is_valid()) {
|
||||
return $this->resp_rules_invalid();
|
||||
}
|
||||
|
||||
// Generate UUID for entity
|
||||
$id = parent::gen_uuid4();
|
||||
|
||||
// Attempt to create new entity
|
||||
$insert = $this->db->for(MessagesModel::TABLE)
|
||||
->insert([
|
||||
MessagesModel::ID->value => $id,
|
||||
MessagesModel::EMAIL->value => $_POST["email"],
|
||||
MessagesModel::MESSAGE->value => $_POST["message"],
|
||||
MessagesModel::DATE_TIMESTAMP_CREATED->value => time(),
|
||||
]);
|
||||
|
||||
// Bail out if insert failed
|
||||
if (!$insert) {
|
||||
return $this->resp_database_error();
|
||||
}
|
||||
|
||||
// Return 201 Created and entity id
|
||||
return new Response($id, 201);
|
||||
}
|
||||
}
|
|
@ -1,223 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Reflect\Path;
|
||||
use Reflect\Response;
|
||||
use ReflectRules\Type;
|
||||
use ReflectRules\Rules;
|
||||
use ReflectRules\Ruleset;
|
||||
|
||||
use Reflect\Method;
|
||||
use function Reflect\Call;
|
||||
|
||||
use VLW\API\Databases\VLWdb\Models\Work\WorkModel;
|
||||
use VLW\API\Databases\VLWdb\Models\Work\WorkTagsModel;
|
||||
use VLW\API\Databases\VLWdb\Models\Work\WorkTagsNameEnum;
|
||||
use VLW\API\Databases\VLWdb\Models\Work\WorkActionsModel;
|
||||
|
||||
require_once Path::root("src/databases/models/Work.php");
|
||||
require_once Path::root("src/databases/models/WorkTags.php");
|
||||
require_once Path::root("src/databases/models/WorkActions.php");
|
||||
|
||||
// "Virtual" database model for the POST request body since we're not writing to a db directly
|
||||
enum ReleasesPostModel: string {
|
||||
case GITHUB_USER = "user";
|
||||
case GITHUB_REPO = "repo";
|
||||
case GITHUB_TAG = "tag";
|
||||
}
|
||||
|
||||
class POST_Releases {
|
||||
// Base URL of the GitHub API (no tailing slash)
|
||||
const GITHUB_API = "https://api.github.com";
|
||||
|
||||
const REGEX_HANDLE = "/@[\w]+/";
|
||||
const REGEX_URL = "/\b(?:https?):\/\/\S+\b/";
|
||||
|
||||
protected Ruleset $ruleset;
|
||||
|
||||
protected CurlHandle $curl;
|
||||
|
||||
public function __construct() {
|
||||
$this->ruleset = new Ruleset(strict: true);
|
||||
|
||||
$this->ruleset->POST([
|
||||
(new Rules(ReleasesPostModel::GITHUB_USER->value))
|
||||
->required()
|
||||
->type(Type::STRING)
|
||||
->min(1),
|
||||
|
||||
(new Rules(ReleasesPostModel::GITHUB_REPO->value))
|
||||
->required()
|
||||
->type(Type::STRING)
|
||||
->min(1),
|
||||
|
||||
(new Rules(ReleasesPostModel::GITHUB_TAG->value))
|
||||
->required()
|
||||
->type(Type::STRING)
|
||||
->type(Type::NUMBER)
|
||||
->min(1)
|
||||
]);
|
||||
|
||||
$this->curl = curl_init();
|
||||
|
||||
curl_setopt($this->curl, CURLOPT_USERAGENT, $_ENV["github"]["user_agent"]);
|
||||
curl_setopt($this->curl, CURLOPT_HEADER, true);
|
||||
curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($this->curl, CURLOPT_HTTPHEADER, [
|
||||
"Accept" => "application/vnd.github+json",
|
||||
"Authorization" => "token {$_ENV["github"]["api_key"]}",
|
||||
"X-GitHub-Api-Version" => "2022-11-28"
|
||||
]);
|
||||
}
|
||||
|
||||
// # GitHub
|
||||
|
||||
// Generate HTML from a GitHub "auto-generate" release body
|
||||
protected static function gh_auto_release_md_to_html(string $md): string {
|
||||
$output = "";
|
||||
|
||||
// Parse each line of markdown
|
||||
$lines = explode(PHP_EOL, $md);
|
||||
|
||||
foreach ($lines as $i => $line) {
|
||||
// Ignore header line from releases
|
||||
if ($i < 1) continue;
|
||||
|
||||
// Replace all URLs with HTMLAnchor tags, they will be PRs
|
||||
$links = [];
|
||||
preg_match_all(self::REGEX_URL, $line, $links, PREG_UNMATCHED_AS_NULL);
|
||||
foreach ($links as $i => $link) {
|
||||
if (empty($link)) continue;
|
||||
|
||||
// Last crumb from link pathname will be the PR id
|
||||
$pr_id = explode("/", $link[$i]);
|
||||
$pr_id = end($pr_id);
|
||||
|
||||
$line = str_replace($link, "<a href='{$link[$i]}'>{$pr_id}</a>", $line);
|
||||
}
|
||||
|
||||
// Replace all at-handles with links to GitHub user profiles
|
||||
$handles = [];
|
||||
preg_match_all(self::REGEX_HANDLE, $line, $handles, PREG_UNMATCHED_AS_NULL);
|
||||
foreach ($handles as $i => $handle) {
|
||||
if (empty($handle)) continue;
|
||||
|
||||
// GitHub user URL without the "@"
|
||||
$url = "https://github.com/" . substr($handle[$i], 1);
|
||||
|
||||
$line = str_replace($handle, "<a href='{$url}'>{$handle[$i]}</a>", $line);
|
||||
}
|
||||
|
||||
$output .= "<p>{$line}</p>";
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
// Return fully qualified URL to GitHub API releases endpoint
|
||||
private static function get_url(): string {
|
||||
return implode("/", [
|
||||
self::GITHUB_API,
|
||||
"repos",
|
||||
$_POST[ReleasesPostModel::GITHUB_USER->value],
|
||||
$_POST[ReleasesPostModel::GITHUB_REPO->value],
|
||||
"releases",
|
||||
"tags",
|
||||
$_POST[ReleasesPostModel::GITHUB_TAG->value],
|
||||
]);
|
||||
}
|
||||
|
||||
// Fetch release information from GitHub API
|
||||
private function fetch_release_data(): array {
|
||||
$url = self::get_url();
|
||||
curl_setopt($this->curl, CURLOPT_URL, self::get_url());
|
||||
|
||||
$resp = curl_exec($this->curl);
|
||||
|
||||
$header_size = curl_getinfo($this->curl, CURLINFO_HEADER_SIZE);
|
||||
$header = substr($resp, 0, $header_size);
|
||||
$body = substr($resp, $header_size);
|
||||
|
||||
return json_decode($body, true);
|
||||
}
|
||||
|
||||
// # Sup
|
||||
|
||||
private function create_link_to_release_page(string $id, string $href): Response {
|
||||
return Call("work/actions?id={$id}", Method::POST, [
|
||||
WorkActionsModel::DISPLAY_TEXT->value => "Release details",
|
||||
WorkActionsModel::HREF->value => $href,
|
||||
WorkActionsModel::EXTERNAL->value => true
|
||||
]);
|
||||
}
|
||||
|
||||
// Create a tag for entity
|
||||
private function create_tag(string $id, WorkTagsNameEnum $tag): Response {
|
||||
return Call("work/tags?id={$id}", Method::POST, [
|
||||
// Set "RELEASE" tag on new entity
|
||||
WorkTagsModel::NAME->value => $tag->value
|
||||
]);
|
||||
}
|
||||
|
||||
// # Responses
|
||||
|
||||
// Return 422 Unprocessable Content error if request validation failed
|
||||
private function resp_rules_invalid(): Response {
|
||||
return new Response($this->ruleset->get_errors(), 422);
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
// Bail out if request validation failed
|
||||
if (!$this->ruleset->is_valid()) {
|
||||
return $this->resp_rules_invalid();
|
||||
}
|
||||
|
||||
$data = $this->fetch_release_data();
|
||||
if (!$data) {
|
||||
return new Response("Failed to fetch release data", 500);
|
||||
}
|
||||
|
||||
|
||||
// Transform repo name to lowercase for summary title
|
||||
$title = strtolower($_POST["repo"]);
|
||||
|
||||
// Use repo name and tag name as heading for summary
|
||||
$summary = "<h3>Release {$title}@{$data["name"]}</h3>";
|
||||
// Append HTML-ified release notes from GitHub to summary
|
||||
$summary .= self::gh_auto_release_md_to_html($data["body"]);
|
||||
|
||||
$date_published = new \DateTime($data["published_at"], new \DateTimeZone("UTC"));
|
||||
|
||||
// Create work entity
|
||||
$work_entity = Call("work", Method::POST, [
|
||||
WorkModel::SUMMARY->value => $summary,
|
||||
// Convert time created to Unix timestamp for work endpoint
|
||||
WorkModel::DATE_TIMESTAMP_CREATED->value => $date_published->format("U"),
|
||||
]);
|
||||
|
||||
// Bail out if creating the work entity failed
|
||||
if (!$work_entity->ok) {
|
||||
return new Response("Failed to create work entity for release", 500);
|
||||
}
|
||||
|
||||
$work_entity_id = $work_entity->output();
|
||||
|
||||
// Create entity tags for release
|
||||
$tags = [
|
||||
WorkTagsNameEnum::VLW,
|
||||
WorkTagsNameEnum::RELEASE
|
||||
];
|
||||
foreach ($tags as $tag) {
|
||||
// Create entity tag for release or exit if failed to create
|
||||
if (!$this->create_tag($work_entity_id, $tag)->ok) {
|
||||
return new Response("Failed to create {$tag->name} tag for release entity", 500);
|
||||
}
|
||||
}
|
||||
|
||||
// Create link to release page on GitHub
|
||||
if (!$this->create_link_to_release_page($work_entity_id, $data["html_url"])) {
|
||||
return new Response("Failed to create link to release page on GitHub", 500);
|
||||
}
|
||||
|
||||
return new Response($work_entity_id, 201);
|
||||
}
|
||||
}
|
|
@ -1,140 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Reflect\Call;
|
||||
use Reflect\Path;
|
||||
use Reflect\Response;
|
||||
use ReflectRules\Type;
|
||||
use ReflectRules\Rules;
|
||||
use ReflectRules\Ruleset;
|
||||
|
||||
use VLW\API\Endpoints;
|
||||
|
||||
use VLW\API\Databases\VLWdb\VLWdb;
|
||||
use VLW\API\Databases\VLWdb\Models\Work\WorkModel;
|
||||
use VLW\API\Databases\VLWdb\Models\Work\WorkActionsModel;
|
||||
|
||||
require_once Path::root("src/databases/VLWdb.php");
|
||||
require_once Path::root("src/databases/models/Work.php");
|
||||
require_once Path::root("src/databases/models/WorkActions.php");
|
||||
|
||||
class GET_Search extends VLWdb {
|
||||
const GET_QUERY = "q";
|
||||
|
||||
protected Ruleset $ruleset;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->ruleset = new Ruleset(strict: true);
|
||||
|
||||
$this->ruleset->GET([
|
||||
(new Rules(self::GET_QUERY))
|
||||
->required()
|
||||
->type(Type::STRING)
|
||||
->min(2)
|
||||
->max(parent::MYSQL_VARCHAR_MAX_LENGTH)
|
||||
]);
|
||||
}
|
||||
|
||||
// Return an SQL string from array for use in prepared statements
|
||||
private static function array_to_wildcard_sql(array $columns): string {
|
||||
$sql = array_map(fn(string $column): string => "{$column} LIKE CONCAT('%', ?, '%')", $columns);
|
||||
|
||||
return implode(" OR ", $sql);
|
||||
}
|
||||
|
||||
// Return chained AND statements from array for use in prepared statements
|
||||
private static function array_to_and_statement(array $keys): string {
|
||||
$sql = array_map(fn(string $k): string => "{$k} = ?", $keys);
|
||||
|
||||
return implode(" AND ", $sql);
|
||||
}
|
||||
|
||||
// Wildcard search columns in table with query string from query string
|
||||
// This has to be implemented manually until "libmysqldriver/MySQL" supports wildcard SELECT
|
||||
private function search(string $table, array $columns, array $conditions = null): array {
|
||||
// Create CSV from columns array
|
||||
$columns_concat = implode(",", $columns);
|
||||
|
||||
// Create SQL LIKE wildcard statement for each column.
|
||||
$where = self::array_to_wildcard_sql($columns);
|
||||
|
||||
// Create array of values from query string for each colum
|
||||
$values = array_fill(0, count($columns), $_GET[self::GET_QUERY]);
|
||||
|
||||
if ($conditions) {
|
||||
$conditions_sql = self::array_to_and_statement(array_keys($conditions));
|
||||
|
||||
// Wrap positive where statements and prepare new group of conditions
|
||||
// WHERE (<search_terms>) AND (<conditions>)
|
||||
$where = "({$where}) AND ({$conditions_sql})";
|
||||
|
||||
// Append values from conditions statements to prepared statement
|
||||
array_push($values, ...array_values($conditions));
|
||||
}
|
||||
|
||||
// Order the rows by the array index of $colums received
|
||||
$rows = $this->db->exec("SELECT {$columns_concat} FROM {$table} WHERE {$where} ORDER BY {$columns_concat}", $values);
|
||||
// Return results as assoc or empty array
|
||||
return parent::is_mysqli_result($rows) ? $rows->fetch_all(MYSQLI_ASSOC) : [];
|
||||
}
|
||||
|
||||
// Search work table
|
||||
private function search_work(): array {
|
||||
$search = [
|
||||
WorkModel::TITLE->value,
|
||||
WorkModel::SUMMARY->value,
|
||||
WorkModel::DATE_TIMESTAMP_CREATED->value,
|
||||
WorkModel::ID->value
|
||||
];
|
||||
|
||||
$conditions = [
|
||||
WorkModel::IS_LISTABLE->value => true
|
||||
];
|
||||
|
||||
$results = $this->search(WorkModel::TABLE, $search, $conditions);
|
||||
|
||||
foreach ($results as &$result) {
|
||||
$result["actions"] = (new Call(Endpoints::WORK_ACTIONS->value))
|
||||
->params([WorkActionsModel::ANCHOR->value => $result[WorkModel::ID->value]])
|
||||
->get()->output();
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
// # Responses
|
||||
|
||||
// Return 422 Unprocessable Content error if request validation failed
|
||||
private function resp_rules_invalid(): Response {
|
||||
return new Response($this->ruleset->get_errors(), 422);
|
||||
}
|
||||
|
||||
// Return a 503 Service Unavailable error if something went wrong with the database call
|
||||
private function resp_database_error(): Response {
|
||||
return new Response("Failed to get work data, please try again later", 503);
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
// Bail out if request validation failed
|
||||
if (!$this->ruleset->is_valid()) {
|
||||
return $this->resp_rules_invalid();
|
||||
}
|
||||
|
||||
// Get search results for each category
|
||||
$categories = [
|
||||
WorkModel::TABLE => $this->search_work()
|
||||
];
|
||||
|
||||
// Count total number of results from all categories
|
||||
$total_num_results = 0;
|
||||
foreach (array_values($categories) as $results) {
|
||||
$total_num_results += count($results);
|
||||
}
|
||||
|
||||
return new Response([
|
||||
"query" => $_GET[self::GET_QUERY],
|
||||
"results" => $categories,
|
||||
"total_num_results" => $total_num_results
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
<?php
|
||||
|
||||
|
||||
use Reflect\Path;
|
||||
use Reflect\Response;
|
||||
use ReflectRules\Type;
|
||||
use ReflectRules\Rules;
|
||||
use ReflectRules\Ruleset;
|
||||
|
||||
use VLW\API\Databases\VLWdb\VLWdb;
|
||||
use VLW\API\Databases\VLWdb\Models\Work\WorkModel;
|
||||
|
||||
require_once Path::root("src/databases/VLWdb.php");
|
||||
require_once Path::root("src/databases/models/Work.php");
|
||||
|
||||
class DELETE_Work extends VLWdb {
|
||||
protected Ruleset $ruleset;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->ruleset = new Ruleset(strict: true);
|
||||
|
||||
$this->ruleset->GET([
|
||||
(new Rules("id"))
|
||||
->required()
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::MYSQL_VARCHAR_MAX_LENGTH)
|
||||
]);
|
||||
}
|
||||
|
||||
// # Responses
|
||||
|
||||
// Return 422 Unprocessable Content error if request validation failed
|
||||
private function resp_rules_invalid(): Response {
|
||||
return new Response($this->ruleset->get_errors(), 422);
|
||||
}
|
||||
|
||||
// Return a 503 Service Unavailable error if something went wrong with the database call
|
||||
private function resp_database_error(): Response {
|
||||
return new Response("Failed to delete work data, please try again later", 503);
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
// Bail out if request validation failed
|
||||
if (!$this->ruleset->is_valid()) {
|
||||
return $this->resp_rules_invalid();
|
||||
}
|
||||
|
||||
// Attempt to update the entity
|
||||
$update = $this->db->for(WorkModel::TABLE)
|
||||
->where([WorkModel::ID->value => $_GET["id"]])
|
||||
->update([
|
||||
WorkModel::IS_LISTABLE->value => false,
|
||||
WorkModel::IS_READABLE->value => false
|
||||
]);
|
||||
|
||||
return $update ? new Response($_GET["id"]) : $this->resp_database_error();
|
||||
}
|
||||
}
|
|
@ -1,136 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Reflect\Call;
|
||||
use Reflect\Path;
|
||||
use Reflect\Method;
|
||||
use Reflect\Response;
|
||||
use ReflectRules\Type;
|
||||
use ReflectRules\Rules;
|
||||
use ReflectRules\Ruleset;
|
||||
|
||||
use VLW\API\Endpoints;
|
||||
|
||||
use VLW\API\Databases\VLWdb\VLWdb;
|
||||
use VLW\API\Databases\VLWdb\Models\Work\WorkModel;
|
||||
use VLW\API\Databases\VLWdb\Models\Work\WorkTagsModel;
|
||||
use VLW\API\Databases\VLWdb\Models\Work\WorkActionsModel;
|
||||
|
||||
require_once Path::root("src/databases/VLWdb.php");
|
||||
require_once Path::root("src/databases/models/Work.php");
|
||||
require_once Path::root("src/databases/models/WorkTags.php");
|
||||
require_once Path::root("src/databases/models/WorkActions.php");
|
||||
|
||||
class GET_Work extends VLWdb {
|
||||
protected Ruleset $ruleset;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->ruleset = new Ruleset(strict: true);
|
||||
|
||||
$this->ruleset->GET([
|
||||
(new Rules("id"))
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::MYSQL_VARCHAR_MAX_LENGTH)
|
||||
->default(null)
|
||||
]);
|
||||
}
|
||||
|
||||
// # Helper methods
|
||||
|
||||
private function fetch_row_tags(string $id): array {
|
||||
$resp = $this->db->for(WorkTagsModel::TABLE)
|
||||
->where([WorkTagsModel::ANCHOR->value => $id])
|
||||
->select(WorkTagsModel::NAME->value);
|
||||
|
||||
return parent::is_mysqli_result($resp) ? $resp->fetch_all(MYSQLI_ASSOC) : [];
|
||||
}
|
||||
|
||||
// # Responses
|
||||
|
||||
// Return 422 Unprocessable Content error if request validation failed
|
||||
private function resp_rules_invalid(): Response {
|
||||
return new Response($this->ruleset->get_errors(), 422);
|
||||
}
|
||||
|
||||
// Return a 503 Service Unavailable error if something went wrong with the database call
|
||||
private function resp_database_error(): Response {
|
||||
return new Response("Failed to get work data, please try again later", 503);
|
||||
}
|
||||
|
||||
private function resp_item_details(string $id): Response {
|
||||
$resp = $this->db->for(WorkModel::TABLE)
|
||||
->where([
|
||||
WorkModel::ID->value => $id,
|
||||
WorkModel::IS_READABLE->value => true
|
||||
])
|
||||
->limit(1)
|
||||
->select([
|
||||
WorkModel::ID->value,
|
||||
WorkModel::TITLE->value,
|
||||
WorkModel::SUMMARY->value,
|
||||
WorkModel::COVER_SRCSET->value,
|
||||
WorkModel::DATE_YEAR->value,
|
||||
WorkModel::DATE_MONTH->value,
|
||||
WorkModel::DATE_DAY->value,
|
||||
WorkModel::DATE_TIMESTAMP_MODIFIED->value,
|
||||
WorkModel::DATE_TIMESTAMP_CREATED->value
|
||||
]);
|
||||
|
||||
// Bail out if something went wrong retrieving rows from the database
|
||||
if (!parent::is_mysqli_result($resp)) {
|
||||
return $this->resp_database_error();
|
||||
}
|
||||
|
||||
return $resp->num_rows === 1
|
||||
? new Response($resp->fetch_assoc())
|
||||
: new Response("No entity with id '{$id}' was found", 404);
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
// Bail out if request validation failed
|
||||
if (!$this->ruleset->is_valid()) {
|
||||
return $this->resp_rules_invalid();
|
||||
}
|
||||
|
||||
// Return details about a specific item by id
|
||||
if (!empty($_GET["id"])) {
|
||||
return $this->resp_item_details($_GET["id"]);
|
||||
}
|
||||
|
||||
$resp = $this->db->for(WorkModel::TABLE)
|
||||
->where([WorkModel::IS_LISTABLE->value => true])
|
||||
->order([WorkModel::DATE_TIMESTAMP_CREATED->value => "DESC"])
|
||||
->select([
|
||||
WorkModel::ID->value,
|
||||
WorkModel::TITLE->value,
|
||||
WorkModel::SUMMARY->value,
|
||||
WorkModel::COVER_SRCSET->value,
|
||||
WorkModel::DATE_YEAR->value,
|
||||
WorkModel::DATE_MONTH->value,
|
||||
WorkModel::DATE_DAY->value,
|
||||
WorkModel::DATE_TIMESTAMP_MODIFIED->value,
|
||||
WorkModel::DATE_TIMESTAMP_CREATED->value
|
||||
]);
|
||||
|
||||
// Bail out if something went wrong retrieving rows from the database
|
||||
if (!parent::is_mysqli_result($resp)) {
|
||||
return $this->resp_database_error();
|
||||
}
|
||||
|
||||
// Resolve foreign keys
|
||||
$rows = [];
|
||||
while ($row = $resp->fetch_assoc()) {
|
||||
$row["tags"] = $this->fetch_row_tags($row["id"]);
|
||||
|
||||
// Fetch actions for work entity by id from endpoint
|
||||
$row["actions"] = (new Call(Endpoints::WORK_ACTIONS->value))
|
||||
->params([WorkActionsModel::ANCHOR->value => $row[WorkModel::ID->value]])
|
||||
->get()->output();
|
||||
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
||||
return new Response($rows);
|
||||
}
|
||||
}
|
|
@ -1,201 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Reflect\Path;
|
||||
use Reflect\Response;
|
||||
use ReflectRules\Type;
|
||||
use ReflectRules\Rules;
|
||||
use ReflectRules\Ruleset;
|
||||
|
||||
use Reflect\Method;
|
||||
use function Reflect\Call;
|
||||
|
||||
use VLW\API\Databases\VLWdb\VLWdb;
|
||||
use VLW\API\Databases\VLWdb\Models\Work\WorkModel;
|
||||
use VLW\API\Databases\VLWdb\Models\WorkPermalinks\WorkPermalinksModel;
|
||||
|
||||
require_once Path::root("src/databases/VLWdb.php");
|
||||
require_once Path::root("src/databases/models/Work.php");
|
||||
require_once Path::root("src/databases/models/WorkPermalinks.php");
|
||||
|
||||
class PATCH_Work extends VLWdb {
|
||||
protected Ruleset $ruleset;
|
||||
|
||||
protected Response $current_entity;
|
||||
protected array $updated_entity;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->ruleset = new Ruleset(strict: true);
|
||||
|
||||
$this->ruleset->GET([
|
||||
(new Rules(WorkModel::ID->value))
|
||||
->required()
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::MYSQL_VARCHAR_MAX_LENGTH)
|
||||
]);
|
||||
|
||||
$this->ruleset->POST([
|
||||
(new Rules(WorkModel::TITLE->value))
|
||||
->type(Type::STRING)
|
||||
->min(3)
|
||||
->max(parent::MYSQL_VARCHAR_MAX_LENGTH),
|
||||
|
||||
(new Rules(WorkModel::SUMMARY->value))
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::MYSQL_TEXT_MAX_LENGTH),
|
||||
|
||||
(new Rules(WorkModel::IS_LISTABLE->value))
|
||||
->type(Type::BOOLEAN),
|
||||
|
||||
(new Rules(WorkModel::IS_READABLE->value))
|
||||
->type(Type::BOOLEAN),
|
||||
|
||||
(new Rules(WorkModel::DATE_TIMESTAMP_CREATED->value))
|
||||
->type(Type::NUMBER)
|
||||
->min(0)
|
||||
->max(parent::MYSQL_INT_MAX_LENGHT)
|
||||
]);
|
||||
|
||||
$this->get_existing_entity();
|
||||
|
||||
// Copy all provided post data into a new array
|
||||
$this->updated_entity = $_POST;
|
||||
|
||||
// Set date modified timestamp
|
||||
$this->updated_entity[WorkModel::DATE_TIMESTAMP_MODIFIED->value] = time();
|
||||
}
|
||||
|
||||
// Generate a slug URL from string
|
||||
private static function gen_slug(string $input): string {
|
||||
return strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', $input)));
|
||||
}
|
||||
|
||||
// # Helper methods
|
||||
|
||||
private function get_existing_entity(): Response {
|
||||
// Check if an entity already exists with slugified title from GET endpoint
|
||||
$this->current_entity = Call("work?id={$_GET["id"]}", Method::GET);
|
||||
|
||||
// Response is not 404 (Not found) so we can't create the entity
|
||||
if ($this->current_entity->code !== 200) {
|
||||
// Response is not a valid entity, something went wrong
|
||||
if ($this->current_entity->code !== 404) {
|
||||
return $this->resp_database_error();
|
||||
}
|
||||
|
||||
// Return 402 Conflict
|
||||
return new Response("No entity with id '{$_GET["id"]}' was found", 404);
|
||||
}
|
||||
|
||||
return $this->current_entity;
|
||||
}
|
||||
|
||||
// Create new permalink for entity slug
|
||||
private function create_permalink(string $slug): bool {
|
||||
$create = Call("work/permalinks", Method::POST, [
|
||||
WorkPermalinksModel::SLUG->value => $slug,
|
||||
WorkPermalinksModel::ANCHOR->value => $slug
|
||||
]);
|
||||
|
||||
return $create->ok;
|
||||
}
|
||||
|
||||
// ## Updated entity
|
||||
|
||||
private function change_slug(): bool {
|
||||
if (!array_key_exists(WorkModel::ID->value, $this->updated_entity)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Generate new permalink for entity id
|
||||
return $this->create_permalink($this->updated_entity[WorkModel::ID->value]);
|
||||
}
|
||||
|
||||
private function timestamp_to_dates(): void {
|
||||
if (!array_key_exists(WorkModel::DATE_TIMESTAMP_CREATED->value, $this->updated_entity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get timestamp from post data
|
||||
$timestamp = $this->updated_entity[WorkModel::DATE_TIMESTAMP_CREATED->value];
|
||||
|
||||
// Update fractured dates from timestamp
|
||||
$this->updated_entity[WorkModel::DATE_YEAR->value] = date("Y", $timestamp);
|
||||
$this->updated_entity[WorkModel::DATE_MONTH ->value] = date("n", $timestamp);
|
||||
$this->updated_entity[WorkModel::DATE_DAY->value] = date("j", $timestamp);
|
||||
}
|
||||
|
||||
// # Responses
|
||||
|
||||
// Return 422 Unprocessable Content error if request validation failed
|
||||
private function resp_rules_invalid(): Response {
|
||||
return new Response($this->ruleset->get_errors(), 422);
|
||||
}
|
||||
|
||||
// Return a 503 Service Unavailable error if something went wrong with the database call
|
||||
private function resp_database_error(): Response {
|
||||
return new Response("Failed to get work data, please try again later", 503);
|
||||
}
|
||||
|
||||
// Return a 422 Unprocessable Entity if there is nothing to change
|
||||
private function resp_no_changes(): Response {
|
||||
return new Response("No columns to update", 422);
|
||||
}
|
||||
|
||||
// Rollback changes and return error response
|
||||
private function resp_permalink_error_rollback(): Response {
|
||||
$update = $this->db->for(WorkModel::TABLE)
|
||||
->where([WorkModel::ID->value => $_GET["id"]])
|
||||
->update($this->current_entity->output());
|
||||
|
||||
return $update
|
||||
? new Response("Failed to create new permalink for updated entity. Changes have been rolled back", 500)
|
||||
: new Reponse("Failed to create new permalink for updated entity. Changes failed to rollback, this is bad.", 500);
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
// Bail out if request validation failed
|
||||
if (!$this->ruleset->is_valid()) {
|
||||
return $this->resp_rules_invalid();
|
||||
}
|
||||
|
||||
// Empty payload, nothing to do
|
||||
if (empty($_POST)) {
|
||||
return $this->resp_no_changes();
|
||||
}
|
||||
|
||||
// Generate new slug for entity if title is updated
|
||||
if (array_key_exists(WorkModel::TITLE->value, $_POST)) {
|
||||
// Generate URL slug from title text or UUID if undefined
|
||||
$slug = self::gen_slug($_POST["title"]);
|
||||
|
||||
// Save generated slug from title if it's different from existing slug
|
||||
if ($slug !== $this->current_entity->output()[WorkModel::ID->value]) {
|
||||
$this->updated_entity[WorkModel::ID->value] = $slug;
|
||||
}
|
||||
}
|
||||
|
||||
// Update fractured dates from timestamp
|
||||
$this->timestamp_to_dates();
|
||||
|
||||
// Attempt to update the entity
|
||||
$update = $this->db->for(WorkModel::TABLE)
|
||||
->where([WorkModel::ID->value => $_GET["id"]])
|
||||
->update($this->updated_entity);
|
||||
|
||||
// Bail out if update failed
|
||||
if (!$update) {
|
||||
return $this->resp_database_error();
|
||||
}
|
||||
|
||||
// Create new slug for entity if title was changed
|
||||
if (!$this->change_slug()) {
|
||||
return $this->resp_permalink_error_rollback();
|
||||
}
|
||||
|
||||
// Return 200 OK and new or existing entity slug as body
|
||||
return new Response($this->current_entity->output()[WorkModel::ID->value]);
|
||||
}
|
||||
}
|
|
@ -1,133 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Reflect\Path;
|
||||
use Reflect\Response;
|
||||
use ReflectRules\Type;
|
||||
use ReflectRules\Rules;
|
||||
use ReflectRules\Ruleset;
|
||||
|
||||
use Reflect\Method;
|
||||
use function Reflect\Call;
|
||||
|
||||
use VLW\API\Databases\VLWdb\VLWdb;
|
||||
use VLW\API\Databases\VLWdb\Models\Work\WorkModel;
|
||||
use VLW\API\Databases\VLWdb\Models\WorkPermalinks\WorkPermalinksModel;
|
||||
|
||||
require_once Path::root("src/databases/VLWdb.php");
|
||||
require_once Path::root("src/databases/models/Work.php");
|
||||
require_once Path::root("src/databases/models/WorkPermalinks.php");
|
||||
|
||||
class POST_Work extends VLWdb {
|
||||
protected Ruleset $ruleset;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->ruleset = new Ruleset(strict: true);
|
||||
|
||||
$this->ruleset->POST([
|
||||
(new Rules(WorkModel::TITLE->value))
|
||||
->type(Type::STRING)
|
||||
->min(3)
|
||||
->max(parent::MYSQL_VARCHAR_MAX_LENGTH)
|
||||
->default(null),
|
||||
|
||||
(new Rules(WorkModel::SUMMARY->value))
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::MYSQL_TEXT_MAX_LENGTH)
|
||||
->default(null),
|
||||
|
||||
(new Rules(WorkModel::DATE_TIMESTAMP_CREATED->value))
|
||||
->type(Type::NUMBER)
|
||||
->min(1)
|
||||
->max(parent::MYSQL_INT_MAX_LENGHT)
|
||||
->default(null)
|
||||
]);
|
||||
}
|
||||
|
||||
// Generate a slug URL from string
|
||||
private static function gen_slug(string $input): string {
|
||||
return strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', $input)));
|
||||
}
|
||||
|
||||
// Create permalink for entity slug
|
||||
private function create_permalink(string $slug): bool {
|
||||
$create = Call("work/permalinks", Method::POST, [
|
||||
WorkPermalinksModel::SLUG->value => $slug,
|
||||
WorkPermalinksModel::ANCHOR->value => $slug
|
||||
]);
|
||||
|
||||
return $create->ok;
|
||||
}
|
||||
|
||||
// # Responses
|
||||
|
||||
// Return 422 Unprocessable Content error if request validation failed
|
||||
private function resp_rules_invalid(): Response {
|
||||
return new Response($this->ruleset->get_errors(), 422);
|
||||
}
|
||||
|
||||
// Return a 503 Service Unavailable error if something went wrong with the database call
|
||||
private function resp_database_error(): Response {
|
||||
return new Response("Failed to get work data, please try again later", 503);
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
// Bail out if request validation failed
|
||||
if (!$this->ruleset->is_valid()) {
|
||||
return $this->resp_rules_invalid();
|
||||
}
|
||||
|
||||
// Generate URL slug from title text or UUID if undefined
|
||||
$slug = !empty($_POST["title"]) ? self::gen_slug($_POST["title"]) : parent::gen_uuid4();
|
||||
|
||||
// Check if an entity already exists with slugified title from GET endpoint
|
||||
$existing_entity = Call("work?id={$slug}", Method::GET);
|
||||
// Response is not 404 (Not found) so we can't create the entity
|
||||
if ($existing_entity->code !== 404) {
|
||||
// Response is not a valid entity, something went wrong
|
||||
if ($existing_entity->code !== 200) {
|
||||
return $this->resp_database_error();
|
||||
}
|
||||
|
||||
// Return 402 Conflict
|
||||
return new Response("Entity with id '{$slug}' already exists", 402);
|
||||
}
|
||||
|
||||
// Get created timestamp from payload or use current time if not specified
|
||||
$created_timestamp = $_POST[WorkModel::DATE_TIMESTAMP_CREATED->value]
|
||||
? $_POST[WorkModel::DATE_TIMESTAMP_CREATED->value]
|
||||
: time();
|
||||
|
||||
// Attempt to create new entity
|
||||
$insert = $this->db->for(WorkModel::TABLE)
|
||||
->insert([
|
||||
WorkModel::ID->value => $slug,
|
||||
WorkModel::TITLE->value => $_POST["title"],
|
||||
WorkModel::SUMMARY->value => $_POST["summary"],
|
||||
WorkModel::IS_LISTABLE->value => true,
|
||||
WorkModel::IS_READABLE->value => true,
|
||||
WorkModel::DATE_YEAR->value => date("Y", $created_timestamp),
|
||||
WorkModel::DATE_MONTH ->value => date("n", $created_timestamp),
|
||||
WorkModel::DATE_DAY->value => date("j", $created_timestamp),
|
||||
WorkModel::DATE_TIMESTAMP_MODIFIED->value => null,
|
||||
WorkModel::DATE_TIMESTAMP_CREATED->value => $created_timestamp,
|
||||
]);
|
||||
|
||||
// Bail out if insert failed
|
||||
if (!$insert) {
|
||||
return $this->resp_database_error();
|
||||
}
|
||||
|
||||
// Create permalink for new entity
|
||||
if (!$this->create_permalink($slug)) {
|
||||
// Rollback created entity if permalink creation failed
|
||||
Call("work", Method::DELETE, [WorkModel::ID->value => $slug]);
|
||||
|
||||
return new Response("Failed to create permalink", 500);
|
||||
}
|
||||
|
||||
// Return 201 Created and entity slug as body
|
||||
return new Response($slug, 201);
|
||||
}
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Reflect\Path;
|
||||
use Reflect\Response;
|
||||
use ReflectRules\Type;
|
||||
use ReflectRules\Rules;
|
||||
use ReflectRules\Ruleset;
|
||||
|
||||
use Reflect\Method;
|
||||
use function Reflect\Call;
|
||||
|
||||
use VLW\API\Databases\VLWdb\VLWdb;
|
||||
use VLW\API\Databases\VLWdb\Models\Work\WorkActionsModel;
|
||||
|
||||
require_once Path::root("src/databases/VLWdb.php");
|
||||
require_once Path::root("src/databases/models/WorkActions.php");
|
||||
|
||||
class DELETE_WorkActions extends VLWdb {
|
||||
protected Ruleset $ruleset;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->ruleset = new Ruleset(strict: true);
|
||||
|
||||
$this->ruleset->POST([
|
||||
(new Rules("id"))
|
||||
->required()
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::MYSQL_VARCHAR_MAX_LENGTH)
|
||||
]);
|
||||
}
|
||||
|
||||
// # Responses
|
||||
|
||||
// Return 422 Unprocessable Content error if request validation failed
|
||||
private function resp_rules_invalid(): Response {
|
||||
return new Response($this->ruleset->get_errors(), 422);
|
||||
}
|
||||
|
||||
// Return a 503 Service Unavailable error if something went wrong with the database call
|
||||
private function resp_database_error(): Response {
|
||||
return new Response("Failed to get work data, please try again later", 503);
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
// Bail out if request validation failed
|
||||
if (!$this->ruleset->is_valid()) {
|
||||
return $this->resp_rules_invalid();
|
||||
}
|
||||
|
||||
// Ensure the action exists by id
|
||||
$existing_action = $this->db->for(WorkActionsModel::TABLE)
|
||||
->where([
|
||||
WorkActionsModel::ID->value => $_POST["id"]
|
||||
])
|
||||
->select(null);
|
||||
|
||||
// Return idempotent deletion if the action does not exist
|
||||
if ($existing_action->num_rows === 0) {
|
||||
return new Response($_POST["id"]);
|
||||
}
|
||||
|
||||
// Attempt to delete action by id
|
||||
$delete = $this->db->for(WorkActionsModel::TABLE)
|
||||
->delete([
|
||||
WorkActionsModel::ID->value => $_POST["id"]
|
||||
]);
|
||||
|
||||
// Return 201 Created and entity id as body if insert was successful
|
||||
return $delete === true ? new Response($_POST["id"], 201) : $this->resp_database_error();
|
||||
}
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Reflect\Path;
|
||||
use Reflect\Response;
|
||||
use ReflectRules\Type;
|
||||
use ReflectRules\Rules;
|
||||
use ReflectRules\Ruleset;
|
||||
|
||||
use VLW\API\Databases\VLWdb\VLWdb;
|
||||
use VLW\API\Databases\VLWdb\Models\Work\WorkActionsModel;
|
||||
|
||||
require_once Path::root("src/databases/VLWdb.php");
|
||||
require_once Path::root("src/databases/models/WorkActions.php");
|
||||
|
||||
class GET_WorkActions extends VLWdb {
|
||||
protected Ruleset $ruleset;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->ruleset = new Ruleset(strict: true);
|
||||
|
||||
$this->ruleset->GET([
|
||||
(new Rules(WorkActionsModel::ANCHOR->value))
|
||||
->required()
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::MYSQL_VARCHAR_MAX_LENGTH)
|
||||
]);
|
||||
}
|
||||
|
||||
// # Responses
|
||||
|
||||
// Return 422 Unprocessable Content error if request validation failed
|
||||
private function resp_rules_invalid(): Response {
|
||||
return new Response($this->ruleset->get_errors(), 422);
|
||||
}
|
||||
|
||||
// Return a 503 Service Unavailable error if something went wrong with the database call
|
||||
private function resp_database_error(): Response {
|
||||
return new Response("Failed to get work data, please try again later", 503);
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
// Bail out if request validation failed
|
||||
if (!$this->ruleset->is_valid()) {
|
||||
return $this->resp_rules_invalid();
|
||||
}
|
||||
|
||||
$resp = $this->db->for(WorkActionsModel::TABLE)
|
||||
->where([WorkActionsModel::ANCHOR->value => $_GET[WorkActionsModel::ANCHOR->value]])
|
||||
->select([
|
||||
WorkActionsModel::DISPLAY_TEXT->value,
|
||||
WorkActionsModel::HREF->value,
|
||||
WorkActionsModel::CLASS_LIST->value,
|
||||
WorkActionsModel::EXTERNAL->value
|
||||
]);
|
||||
|
||||
// Bail out if something went wrong retrieving rows from the database
|
||||
if (!parent::is_mysqli_result($resp)) {
|
||||
return $this->resp_database_error();
|
||||
}
|
||||
|
||||
return $resp->num_rows > 0
|
||||
? new Response($resp->fetch_all(MYSQLI_ASSOC))
|
||||
: new Response([]);
|
||||
}
|
||||
}
|
|
@ -1,102 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Reflect\Path;
|
||||
use Reflect\Response;
|
||||
use ReflectRules\Type;
|
||||
use ReflectRules\Rules;
|
||||
use ReflectRules\Ruleset;
|
||||
|
||||
use Reflect\Method;
|
||||
use function Reflect\Call;
|
||||
|
||||
use VLW\API\Databases\VLWdb\VLWdb;
|
||||
use VLW\API\Databases\VLWdb\Models\Work\WorkActionsModel;
|
||||
|
||||
require_once Path::root("src/databases/VLWdb.php");
|
||||
require_once Path::root("src/databases/models/WorkActions.php");
|
||||
|
||||
class POST_WorkActions extends VLWdb {
|
||||
protected Ruleset $ruleset;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->ruleset = new Ruleset(strict: true);
|
||||
|
||||
$this->ruleset->GET([
|
||||
(new Rules("id"))
|
||||
->required()
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::MYSQL_VARCHAR_MAX_LENGTH)
|
||||
]);
|
||||
|
||||
$this->ruleset->POST([
|
||||
(new Rules(WorkActionsModel::DISPLAY_TEXT->value))
|
||||
->required()
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::MYSQL_VARCHAR_MAX_LENGTH),
|
||||
|
||||
(new Rules(WorkActionsModel::HREF->value))
|
||||
->required()
|
||||
->type(Type::STRING)
|
||||
->type(Type::NULL)
|
||||
->min(1)
|
||||
->max(parent::MYSQL_VARCHAR_MAX_LENGTH),
|
||||
|
||||
(new Rules(WorkActionsModel::CLASS_LIST->value))
|
||||
->type(Type::ARRAY)
|
||||
->min(1)
|
||||
->max(4)
|
||||
->default([]),
|
||||
|
||||
(new Rules(WorkActionsModel::EXTERNAL->value))
|
||||
->type(Type::BOOLEAN)
|
||||
->default(false)
|
||||
]);
|
||||
}
|
||||
|
||||
// # Responses
|
||||
|
||||
// Return 422 Unprocessable Content error if request validation failed
|
||||
private function resp_rules_invalid(): Response {
|
||||
return new Response($this->ruleset->get_errors(), 422);
|
||||
}
|
||||
|
||||
// Return a 503 Service Unavailable error if something went wrong with the database call
|
||||
private function resp_database_error(): Response {
|
||||
return new Response("Failed to get work data, please try again later", 503);
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
// Bail out if request validation failed
|
||||
if (!$this->ruleset->is_valid()) {
|
||||
return $this->resp_rules_invalid();
|
||||
}
|
||||
|
||||
// Ensure an entity with the provided id exists
|
||||
$entity = Call("work?id={$_GET["id"]}", Method::GET);
|
||||
if ($entity->code !== 200) {
|
||||
// Response from endpoint is not 404, something went wrong
|
||||
if ($entity->code !== 404) {
|
||||
return $this->resp_database_error();
|
||||
}
|
||||
|
||||
return new Response("No entity with id '{$_GET["id"]}' was found", 404);
|
||||
}
|
||||
|
||||
// Attempt to create action for entity
|
||||
$insert = $this->db->for(WorkActionsModel::TABLE)
|
||||
->insert([
|
||||
WorkActionsModel::ID->value => parent::gen_uuid4(),
|
||||
WorkActionsModel::ANCHOR->value => $_GET["id"],
|
||||
WorkActionsModel::DISPLAY_TEXT->value => $_POST[WorkActionsModel::DISPLAY_TEXT->value],
|
||||
WorkActionsModel::HREF->value => $_POST[WorkActionsModel::HREF->value],
|
||||
WorkActionsModel::CLASS_LIST->value => implode(",", $_POST[WorkActionsModel::CLASS_LIST->value]),
|
||||
WorkActionsModel::EXTERNAL->value => $_POST[WorkActionsModel::EXTERNAL->value],
|
||||
]);
|
||||
|
||||
// Return 201 Created and entity id as body if insert was successful
|
||||
return $insert === true ? new Response($_GET["id"], 201) : $this->resp_database_error();
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
<?php
|
||||
|
||||
|
||||
use Reflect\Path;
|
||||
use Reflect\Response;
|
||||
use ReflectRules\Type;
|
||||
use ReflectRules\Rules;
|
||||
use ReflectRules\Ruleset;
|
||||
|
||||
use VLW\API\Databases\VLWdb\VLWdb;
|
||||
use VLW\API\Databases\VLWdb\Models\WorkPermalinks\WorkPermalinksModel;
|
||||
|
||||
require_once Path::root("src/databases/VLWdb.php");
|
||||
require_once Path::root("src/databases/models/WorkPermalinks.php");
|
||||
|
||||
class GET_WorkPermalinks extends VLWdb {
|
||||
protected Ruleset $ruleset;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->ruleset = new Ruleset(strict: true);
|
||||
|
||||
$this->ruleset->GET([
|
||||
(new Rules("id"))
|
||||
->required()
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::MYSQL_VARCHAR_MAX_LENGTH)
|
||||
]);
|
||||
}
|
||||
|
||||
// # Responses
|
||||
|
||||
// Return 422 Unprocessable Content error if request validation failed
|
||||
private function resp_rules_invalid(): Response {
|
||||
return new Response($this->ruleset->get_errors(), 422);
|
||||
}
|
||||
|
||||
// Return a 503 Service Unavailable error if something went wrong with the database call
|
||||
private function resp_database_error(): Response {
|
||||
return new Response("Failed to resolve permalink, please try again later", 503);
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
// Bail out if request validation failed
|
||||
if (!$this->ruleset->is_valid()) {
|
||||
return $this->resp_rules_invalid();
|
||||
}
|
||||
|
||||
// Get all anchors that match the requested slug
|
||||
$resolve = $this->db->for(WorkPermalinksModel::TABLE)
|
||||
->where([WorkPermalinksModel::SLUG->value => $_GET["id"]])
|
||||
->select(WorkPermalinksModel::ANCHOR->value);
|
||||
|
||||
// Return array of all matched work table ids. Or empty array if none found
|
||||
return parent::is_mysqli_result($resolve)
|
||||
? new Response(array_column($resolve->fetch_all(MYSQLI_ASSOC), WorkPermalinksModel::ANCHOR->value))
|
||||
: $this->resp_database_error();
|
||||
}
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
<?php
|
||||
|
||||
|
||||
use Reflect\Path;
|
||||
use Reflect\Response;
|
||||
use ReflectRules\Type;
|
||||
use ReflectRules\Rules;
|
||||
use ReflectRules\Ruleset;
|
||||
|
||||
use Reflect\Method;
|
||||
use function Reflect\Call;
|
||||
|
||||
use VLW\API\Databases\VLWdb\VLWdb;
|
||||
use VLW\API\Databases\VLWdb\Models\WorkPermalinks\WorkPermalinksModel;
|
||||
|
||||
require_once Path::root("src/databases/VLWdb.php");
|
||||
require_once Path::root("src/databases/models/WorkPermalinks.php");
|
||||
|
||||
class POST_WorkPermalinks extends VLWdb {
|
||||
protected Ruleset $ruleset;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->ruleset = new Ruleset(strict: true);
|
||||
|
||||
$this->ruleset->POST([
|
||||
(new Rules("slug"))
|
||||
->required()
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::MYSQL_VARCHAR_MAX_LENGTH),
|
||||
|
||||
(new Rules("anchor"))
|
||||
->required()
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::MYSQL_VARCHAR_MAX_LENGTH)
|
||||
]);
|
||||
}
|
||||
|
||||
// # Responses
|
||||
|
||||
// Return 422 Unprocessable Content error if request validation failed
|
||||
private function resp_rules_invalid(): Response {
|
||||
return new Response($this->ruleset->get_errors(), 422);
|
||||
}
|
||||
|
||||
// Return a 503 Service Unavailable error if something went wrong with the database call
|
||||
private function resp_database_error(): Response {
|
||||
return new Response("Failed to resolve permalink, please try again later", 503);
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
// Bail out if request validation failed
|
||||
if (!$this->ruleset->is_valid()) {
|
||||
return $this->resp_rules_invalid();
|
||||
}
|
||||
|
||||
// Check if an entity exists with slug
|
||||
$existing_entity = Call("work?id={$_POST["slug"]}", Method::GET);
|
||||
// Response is not 404 (Not found) so we can't create the entity
|
||||
if ($existing_entity->code !== 200) {
|
||||
// Response is not a valid entity, something went wrong
|
||||
if ($existing_entity->code !== 404) {
|
||||
return $this->resp_database_error();
|
||||
}
|
||||
|
||||
// Return 402 Conflict
|
||||
return new Response("No work entity with id '{$_POST["slug"]}' was found to permalink", 404);
|
||||
}
|
||||
|
||||
// Attempt to create new entity
|
||||
$insert = $this->db->for(WorkPermalinksModel::TABLE)
|
||||
->insert([
|
||||
WorkPermalinksModel::SLUG->value => $_POST["slug"],
|
||||
WorkPermalinksModel::ANCHOR->value => $_POST["anchor"],
|
||||
WorkPermalinksModel::DATE_TIMESTAMP_CREATED->value => time(),
|
||||
]);
|
||||
|
||||
// Return 201 Created and entity slug as body if insert was successful
|
||||
return $insert === true ? new Response($_POST["slug"], 201) : $this->resp_database_error();
|
||||
}
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Reflect\Path;
|
||||
use Reflect\Response;
|
||||
use ReflectRules\Type;
|
||||
use ReflectRules\Rules;
|
||||
use ReflectRules\Ruleset;
|
||||
|
||||
use Reflect\Method;
|
||||
use function Reflect\Call;
|
||||
|
||||
use VLW\API\Databases\VLWdb\VLWdb;
|
||||
use VLW\API\Databases\VLWdb\Models\Work\WorkTagsModel;
|
||||
use VLW\API\Databases\VLWdb\Models\Work\WorkTagsNameEnum;
|
||||
|
||||
require_once Path::root("src/databases/VLWdb.php");
|
||||
require_once Path::root("src/databases/models/WorkTags.php");
|
||||
|
||||
class DELETE_WorkTags extends VLWdb {
|
||||
protected Ruleset $ruleset;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->ruleset = new Ruleset(strict: true);
|
||||
|
||||
$this->ruleset->POST([
|
||||
(new Rules("id"))
|
||||
->required()
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::MYSQL_VARCHAR_MAX_LENGTH),
|
||||
|
||||
(new Rules(WorkTagsModel::NAME->value))
|
||||
->required()
|
||||
->type(Type::ENUM, WorkTagsNameEnum::names())
|
||||
]);
|
||||
}
|
||||
|
||||
// # Responses
|
||||
|
||||
// Return 422 Unprocessable Content error if request validation failed
|
||||
private function resp_rules_invalid(): Response {
|
||||
return new Response($this->ruleset->get_errors(), 422);
|
||||
}
|
||||
|
||||
// Return a 503 Service Unavailable error if something went wrong with the database call
|
||||
private function resp_database_error(): Response {
|
||||
return new Response("Failed to get work data, please try again later", 503);
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
// Bail out if request validation failed
|
||||
if (!$this->ruleset->is_valid()) {
|
||||
return $this->resp_rules_invalid();
|
||||
}
|
||||
|
||||
// Ensure the tag exists for entity id
|
||||
$existing_tag = $this->db->for(WorkTagsModel::TABLE)
|
||||
->where([
|
||||
WorkTagsModel::ANCHOR->value => $_POST["id"],
|
||||
WorkTagsModel::NAME->value => $_POST["name"]
|
||||
])
|
||||
->select(null);
|
||||
|
||||
// Return idempotent deletion if the tag does not exist
|
||||
if ($existing_tag->num_rows === 0) {
|
||||
return new Response($_POST["id"]);
|
||||
}
|
||||
|
||||
// Attempt to delete tag for entity
|
||||
$delete = $this->db->for(WorkTagsModel::TABLE)
|
||||
->delete([
|
||||
WorkTagsModel::ANCHOR->value => $_POST["id"],
|
||||
WorkTagsModel::NAME->value => $_POST["name"]
|
||||
]);
|
||||
|
||||
// Return 201 Created and entity id as body if insert was successful
|
||||
return $delete === true ? new Response($_POST["id"], 201) : $this->resp_database_error();
|
||||
}
|
||||
}
|
|
@ -1,93 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Reflect\Path;
|
||||
use Reflect\Response;
|
||||
use ReflectRules\Type;
|
||||
use ReflectRules\Rules;
|
||||
use ReflectRules\Ruleset;
|
||||
|
||||
use Reflect\Method;
|
||||
use function Reflect\Call;
|
||||
|
||||
use VLW\API\Databases\VLWdb\VLWdb;
|
||||
use VLW\API\Databases\VLWdb\Models\Work\WorkTagsModel;
|
||||
use VLW\API\Databases\VLWdb\Models\Work\WorkTagsNameEnum;
|
||||
|
||||
require_once Path::root("src/databases/VLWdb.php");
|
||||
require_once Path::root("src/databases/models/WorkTags.php");
|
||||
|
||||
class POST_WorkTags extends VLWdb {
|
||||
protected Ruleset $ruleset;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->ruleset = new Ruleset(strict: true);
|
||||
|
||||
$this->ruleset->GET([
|
||||
(new Rules("id"))
|
||||
->required()
|
||||
->type(Type::STRING)
|
||||
->min(1)
|
||||
->max(parent::MYSQL_VARCHAR_MAX_LENGTH)
|
||||
]);
|
||||
|
||||
$this->ruleset->POST([
|
||||
(new Rules(WorkTagsModel::NAME->value))
|
||||
->required()
|
||||
->type(Type::ENUM, WorkTagsNameEnum::names())
|
||||
]);
|
||||
}
|
||||
|
||||
// # Responses
|
||||
|
||||
// Return 422 Unprocessable Content error if request validation failed
|
||||
private function resp_rules_invalid(): Response {
|
||||
return new Response($this->ruleset->get_errors(), 422);
|
||||
}
|
||||
|
||||
// Return a 503 Service Unavailable error if something went wrong with the database call
|
||||
private function resp_database_error(): Response {
|
||||
return new Response("Failed to get work data, please try again later", 503);
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
// Bail out if request validation failed
|
||||
if (!$this->ruleset->is_valid()) {
|
||||
return $this->resp_rules_invalid();
|
||||
}
|
||||
|
||||
// Ensure an entity with the provided id exists
|
||||
$entity = Call("work?id={$_GET["id"]}", Method::GET);
|
||||
if ($entity->code !== 200) {
|
||||
// Response from endpoint is not 404, something went wrong
|
||||
if ($entity->code !== 404) {
|
||||
return $this->resp_database_error();
|
||||
}
|
||||
|
||||
return new Response("No entity with id '{$_GET["id"]}' was found", 404);
|
||||
}
|
||||
|
||||
// Ensure the tag does not already exist for entity
|
||||
$existing_tag = $this->db->for(WorkTagsModel::TABLE)
|
||||
->where([
|
||||
WorkTagsModel::ANCHOR->value => $_GET["id"],
|
||||
WorkTagsModel::NAME->value => $_POST["name"]
|
||||
])
|
||||
->select(null);
|
||||
|
||||
// Bail out if this tag already exists
|
||||
if ($existing_tag->num_rows !== 0) {
|
||||
return new Response("Tag '{$_POST["name"]}' is already set on entity id '{$_GET["id"]}'", 402);
|
||||
}
|
||||
|
||||
// Attempt to create tag for entity
|
||||
$insert = $this->db->for(WorkTagsModel::TABLE)
|
||||
->insert([
|
||||
WorkTagsModel::ANCHOR->value => $_GET["id"],
|
||||
WorkTagsModel::NAME->value => $_POST["name"]
|
||||
]);
|
||||
|
||||
// Return 201 Created and entity id as body if insert was successful
|
||||
return $insert === true ? new Response($_GET["id"], 201) : $this->resp_database_error();
|
||||
}
|
||||
}
|
19
api/languages/GET.php
Normal file
19
api/languages/GET.php
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
use Reflect\{Response, Path};
|
||||
|
||||
use VLW\API\API;
|
||||
use VLW\Database\Models\Languages\Language;
|
||||
|
||||
require_once Path::root("src/API/API.php");
|
||||
require_once Path::root("src/Database/Models/Languages/Language.php");
|
||||
|
||||
final class GET_Languages extends API {
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
return new Response(Language::all());
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace VLW\API\Databases\VLWdb;
|
||||
|
||||
use libmysqldriver\MySQL;
|
||||
|
||||
class VLWdb {
|
||||
const UUID_LENGTH = 36;
|
||||
|
||||
const MYSQL_TEXT_MAX_LENGTH = 65538;
|
||||
const MYSQL_VARCHAR_MAX_LENGTH = 255;
|
||||
const MYSQL_INT_MAX_LENGHT = 2147483647;
|
||||
|
||||
protected MySQL $db;
|
||||
|
||||
public function __construct() {
|
||||
// Create new MariaDB connection
|
||||
$this->db = new MySQL(
|
||||
$_ENV["vlwdb"]["mariadb_host"],
|
||||
$_ENV["vlwdb"]["mariadb_user"],
|
||||
$_ENV["vlwdb"]["mariadb_pass"],
|
||||
$_ENV["vlwdb"]["mariadb_db"],
|
||||
);
|
||||
}
|
||||
|
||||
// Generate and return UUID4 string
|
||||
public static function gen_uuid4(): string {
|
||||
return sprintf("%04x%04x-%04x-%04x-%04x-%04x%04x%04x",
|
||||
// 32 bits for "time_low"
|
||||
mt_rand(0, 0xffff), mt_rand(0, 0xffff),
|
||||
|
||||
// 16 bits for "time_mid"
|
||||
mt_rand(0, 0xffff),
|
||||
|
||||
// 16 bits for "time_hi_and_version",
|
||||
// four most significant bits holds version number 4
|
||||
mt_rand(0, 0x0fff) | 0x4000,
|
||||
|
||||
// 16 bits, 8 bits for "clk_seq_hi_res",
|
||||
// 8 bits for "clk_seq_low",
|
||||
// two most significant bits holds zero and one for variant DCE1.1
|
||||
mt_rand(0, 0x3fff) | 0x8000,
|
||||
|
||||
// 48 bits for "node"
|
||||
mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
|
||||
);
|
||||
}
|
||||
|
||||
public static function is_mysqli_result(\mysqli_result|bool $resp): bool {
|
||||
return $resp instanceof \mysqli_result;
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace VLW\API\Databases\VLWdb\Models\Coffee;
|
||||
|
||||
enum CoffeeModel: string {
|
||||
const TABLE = "coffee";
|
||||
|
||||
case ID = "id";
|
||||
case DATE_TIMESTAMP_CREATED = "date_timestamp_created";
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace VLW\API\Databases\VLWdb\Models\Media;
|
||||
|
||||
use victorwesterlund\xEnum;
|
||||
|
||||
enum MediaTypeEnum: string {
|
||||
use xEnum;
|
||||
|
||||
case BLOB = "BLOB";
|
||||
case IMAGE = "IMAGE";
|
||||
}
|
||||
|
||||
enum MediaModel: string {
|
||||
const TABLE = "media";
|
||||
|
||||
case ID = "id";
|
||||
case NAME = "name";
|
||||
case TYPE = "type";
|
||||
case MIME = "mime";
|
||||
case EXTENSION = "extension";
|
||||
case SRCSET = "srcset";
|
||||
case DATE_TIMESTAMP_CREATED = "date_timestamp_created";
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace VLW\API\Databases\VLWdb\Models\MediaSrcset;
|
||||
|
||||
enum MediaSrcsetModel: string {
|
||||
const TABLE = "media_srcset";
|
||||
|
||||
case ID = "id";
|
||||
case ANCHOR_DEFAULT = "anchor_default";
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace VLW\API\Databases\VLWdb\Models\Messages;
|
||||
|
||||
enum MessagesModel: string {
|
||||
const TABLE = "messages";
|
||||
|
||||
case ID = "id";
|
||||
case EMAIL = "email";
|
||||
case MESSAGE = "message";
|
||||
case IS_READ = "is_read";
|
||||
case IS_SPAM = "is_spam";
|
||||
case IS_SAVED = "is_saved";
|
||||
case DATE_TIMESTAMP_CREATED = "date_timestamp_created";
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace VLW\API\Databases\VLWdb\Models\Work;
|
||||
|
||||
enum WorkModel: string {
|
||||
const TABLE = "work";
|
||||
|
||||
case ID = "id";
|
||||
case TITLE = "title";
|
||||
case SUMMARY = "summary";
|
||||
case COVER_SRCSET = "cover_srcset";
|
||||
case IS_LISTABLE = "is_listable";
|
||||
case IS_READABLE = "is_readable";
|
||||
case DATE_YEAR = "date_year";
|
||||
case DATE_MONTH = "date_month";
|
||||
case DATE_DAY = "date_day";
|
||||
case DATE_TIMESTAMP_MODIFIED = "date_timestamp_modified";
|
||||
case DATE_TIMESTAMP_CREATED = "date_timestamp_created";
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace VLW\API\Databases\VLWdb\Models\Work;
|
||||
|
||||
enum WorkActionsModel: string {
|
||||
const TABLE = "work_actions";
|
||||
|
||||
case ID = "id";
|
||||
case ANCHOR = "anchor";
|
||||
case DISPLAY_TEXT = "display_text";
|
||||
case HREF = "href";
|
||||
case CLASS_LIST = "class_list";
|
||||
case EXTERNAL = "external";
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace VLW\API\Databases\VLWdb\Models\Work;
|
||||
|
||||
enum WorkMediaModel: string {
|
||||
const TABLE = "work_media";
|
||||
|
||||
case ANCHOR = "anchor";
|
||||
case MEDIA = "media";
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace VLW\API\Databases\VLWdb\Models\WorkPermalinks;
|
||||
|
||||
enum WorkPermalinksModel: string {
|
||||
const TABLE = "work_permalinks";
|
||||
|
||||
case SLUG = "slug";
|
||||
case ANCHOR = "anchor";
|
||||
case DATE_TIMESTAMP_CREATED = "date_timestamp_created";
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace VLW\API\Databases\VLWdb\Models\Work;
|
||||
|
||||
use victorwesterlund\xEnum;
|
||||
|
||||
enum WorkTagsNameEnum: string {
|
||||
use xEnum;
|
||||
|
||||
case VLW = "VLW";
|
||||
case RELEASE = "RELEASE";
|
||||
case WEBSITE = "WEBSITE";
|
||||
}
|
||||
|
||||
enum WorkTagsModel: string {
|
||||
const TABLE = "work_tags";
|
||||
|
||||
case ANCHOR = "anchor";
|
||||
case NAME = "name";
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
{
|
||||
"name": "local/api.endpoints",
|
||||
"description": "Endpoint pathmappings for VLW API",
|
||||
"type": "library",
|
||||
"version": "1.0.0-dev",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Victor Westerlund",
|
||||
"email": "victor@vlw.se"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"VLW\\API\\": "src/"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace VLW\API;
|
||||
|
||||
enum Endpoints: string {
|
||||
case WORK = "/work";
|
||||
case SEARCH = "/search";
|
||||
case MESSAGES = "/messages";
|
||||
case WORK_TAGS = "/work/tags";
|
||||
case WORK_ACTIONS = "/work/actions";
|
||||
}
|
71
api/update/GET.php
Normal file
71
api/update/GET.php
Normal file
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
use \vlw\xEnum;
|
||||
use Reflect\{Response, Path};
|
||||
use Reflect\Rules\{Ruleset, Rules, Type};
|
||||
|
||||
use VLW\API\API;
|
||||
use VLW\Helpers\{
|
||||
Forgejo,
|
||||
GenerateSearch,
|
||||
GenerateTimeline
|
||||
};
|
||||
|
||||
require_once Path::root("src/API/API.php");
|
||||
require_once Path::root("src/Helpers/Forgejo.php");
|
||||
require_once Path::root("src/Helpers/GenerateSearch.php");
|
||||
require_once Path::root("src/Helpers/GenerateTimeline.php");
|
||||
|
||||
enum ServiceEnum: string {
|
||||
use xEnum;
|
||||
|
||||
case ALL = "all";
|
||||
case SEARCH = "search";
|
||||
case FORGEJO = "forgejo";
|
||||
case TIMELINE = "timeline";
|
||||
}
|
||||
|
||||
final class GET_Update extends API {
|
||||
private const KEY_SERVICE = "service";
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct(new Ruleset()->GET([
|
||||
new Rules(self::KEY_SERVICE)
|
||||
->type(Type::ENUM, ServiceEnum::values())
|
||||
->default(ServiceEnum::ALL->value)
|
||||
]));
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
switch ($_GET[self::KEY_SERVICE]) {
|
||||
case ServiceEnum::FORGEJO->value:
|
||||
return new Response($this->update_forgejo());
|
||||
|
||||
case ServiceEnum::SEARCH->value:
|
||||
return new Response($this->update_search());
|
||||
|
||||
case ServiceEnum::TIMELINE->value:
|
||||
return new Response($this->update_timeline());
|
||||
|
||||
case ServiceEnum::ALL->value:
|
||||
default:
|
||||
return new Response(
|
||||
$this->update_timeline() &&
|
||||
$this->update_search() &&
|
||||
$this->update_forgejo()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private function update_timeline(): bool {
|
||||
return new GenerateTimeline()->generate();
|
||||
}
|
||||
|
||||
private function update_search(): bool {
|
||||
return new GenerateSearch()->generate();
|
||||
}
|
||||
|
||||
private function update_forgejo(): bool {
|
||||
return new Forgejo()->update();
|
||||
}
|
||||
}
|
28
api/work/GET.php
Normal file
28
api/work/GET.php
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
use Reflect\{Response, Path};
|
||||
|
||||
use VLW\API\API;
|
||||
use VLW\Database\Models\Work\{Work, Tag};
|
||||
|
||||
require_once Path::root("src/API/API.php");
|
||||
require_once Path::root("src/Database/Models/Work/Tag.php");
|
||||
require_once Path::root("src/Database/Models/Work/Work.php");
|
||||
|
||||
final class GET_Work extends API {
|
||||
private static function entity(Work $work): object {
|
||||
return (object) [
|
||||
"tags" => array_map(fn(Tag $tag): string => $tag->label->name, Tag::from($work)),
|
||||
"actions" => [],
|
||||
"details" => $work
|
||||
];
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function main(): Response {
|
||||
return new Response(array_map(fn(Work $work): object => self::entity($work), Work::all()));
|
||||
}
|
||||
}
|
|
@ -1,325 +0,0 @@
|
|||
:root {
|
||||
--primer-color-accent: 255, 255, 0;
|
||||
--color-accent: yellow;
|
||||
--hue-accent: 0deg;
|
||||
|
||||
--padding: 20px;
|
||||
--running-size: 80px;
|
||||
}
|
||||
|
||||
/* # Cornerstones */
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
box-sizing: border-box;
|
||||
font-family: "Roboto Mono", sans-serif;
|
||||
color: inherit;
|
||||
font-size: inherit;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
body {
|
||||
display: grid;
|
||||
justify-items: center;
|
||||
grid-template-rows: var(--running-size) 1fr;
|
||||
overscroll-behavior: none;
|
||||
background-color: black;
|
||||
color: white;
|
||||
overflow-x: hidden;
|
||||
min-height: 100svh;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
body.search-dialog-open {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
a {
|
||||
display: contents;
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/* # Components */
|
||||
|
||||
:is(h1, h2, h3, p, li) > a {
|
||||
--underline-tickness: 3px;
|
||||
|
||||
display: initial;
|
||||
text-decoration: underline;
|
||||
text-decoration-thickness: var(--underline-tickness);
|
||||
text-underline-offset: var(--underline-tickness);
|
||||
text-decoration-color: var(--color-accent);
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 30px;
|
||||
color: var(--color-accent);
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 30px;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 25px;
|
||||
}
|
||||
|
||||
/* ## Buttons */
|
||||
|
||||
button {
|
||||
padding: calc(var(--padding) / 2) var(--padding);
|
||||
color: white;
|
||||
border: solid 2px white;
|
||||
border-radius: 6px;
|
||||
background-color: transparent;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
button.solid {
|
||||
color: black;
|
||||
border-color: var(--color-accent);
|
||||
background-color: var(--color-accent);
|
||||
}
|
||||
|
||||
a > button::after {
|
||||
content: " ➜";
|
||||
}
|
||||
|
||||
a[target="_blank"] > button::after,
|
||||
:is(h1, h2, h3, p, li) > a[target="_blank"]::after {
|
||||
content: " ⮥";
|
||||
color: var(--color-accent);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
a > button.solid:not(:hover)::after {
|
||||
color: black;
|
||||
}
|
||||
|
||||
/* ## Header */
|
||||
|
||||
header {
|
||||
--border-style: solid 1px rgba(255, 255, 255, .2);
|
||||
|
||||
position: sticky;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: var(--running-size);
|
||||
border-bottom: var(--border-style);
|
||||
display: grid;
|
||||
align-items: stretch;
|
||||
justify-items: end;
|
||||
grid-template-columns: 1fr var(--running-size);
|
||||
background-color: rgba(0, 0, 0, .8);
|
||||
z-index: 100;
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
backdrop-filter: blur(20px);
|
||||
}
|
||||
|
||||
header nav {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: var(--padding);
|
||||
}
|
||||
|
||||
header .logo {
|
||||
width: calc(var(--running-size) - 1px);
|
||||
height: calc(var(--running-size) - 1px);
|
||||
display: grid;
|
||||
align-items: center;
|
||||
justify-items: center;
|
||||
border-left: var(--border-style);
|
||||
}
|
||||
|
||||
header .logo path.stroke {
|
||||
fill: var(--color-accent);
|
||||
}
|
||||
|
||||
header searchbox {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* ## Main */
|
||||
|
||||
main {
|
||||
transition: 400ms transform;
|
||||
position: relative;
|
||||
padding: calc(var(--padding) * 1.5);
|
||||
width: 100%;
|
||||
max-width: 1000px;
|
||||
}
|
||||
|
||||
main > * {
|
||||
transition: 100ms opacity;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
main.loading > * {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
/* ## Search */
|
||||
|
||||
/* ### Box */
|
||||
|
||||
searchbox {
|
||||
display: grid;
|
||||
width: 100%;
|
||||
border-left: var(--border-style);
|
||||
grid-template-columns: 25px 1fr;
|
||||
align-items: center;
|
||||
padding: var(--padding);
|
||||
gap: var(--padding);
|
||||
fill: var(--color-accent);
|
||||
font-size: 13px;
|
||||
color: rgba(255, 255, 255, .5);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* ### Dialog */
|
||||
|
||||
body.search-dialog-open main {
|
||||
transform: scale(.94);
|
||||
}
|
||||
|
||||
dialog.search {
|
||||
transition: 200ms height cubic-bezier(.41,0,.34,.99);
|
||||
margin: auto;
|
||||
width: 100%;
|
||||
max-width: 1000px;
|
||||
height: calc(var(--running-size) + (var(--padding) * 5));
|
||||
max-height: 1000px;
|
||||
border-color: transparent;
|
||||
background-color: transparent;
|
||||
overflow: visible;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
dialog.search.active {
|
||||
height: 70vh;
|
||||
}
|
||||
|
||||
dialog.search search {
|
||||
transition: 400ms transform, 200ms opacity;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: grid;
|
||||
grid-template-rows: var(--running-size) 1fr;
|
||||
gap: calc(var(--padding) * 2);
|
||||
transform: scale(1.1);
|
||||
overflow: hidden;
|
||||
background-color: rgba(255, 255, 255, .05);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
backdrop-filter: brightness(.3) blur(20px);
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 10px 30px 10px black;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
body.search-dialog-open dialog.search search {
|
||||
transform: scale(1);
|
||||
padding: calc(var(--padding) * 1.5);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
search input {
|
||||
transition: 200ms background-color, 200ms box-shadow, 200ms color;
|
||||
border-radius: 6px;
|
||||
border: none;
|
||||
outline: none;
|
||||
color: black;
|
||||
font-size: 16px;
|
||||
padding: var(--padding) calc(var(--padding) * 1.5);
|
||||
background-color: rgba(255, 255, 255, .05);
|
||||
box-shadow: 0 5px 70px 10px rgba(0, 0, 0, .3);
|
||||
color: white;
|
||||
}
|
||||
|
||||
search input:focus {
|
||||
background-color: rgba(255, 255, 255, .9);
|
||||
box-shadow: 0 10px 30px 10px black;
|
||||
color: black;
|
||||
}
|
||||
|
||||
/* ### Search results */
|
||||
|
||||
dialog.search search search-results {
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
dialog.search search search-results > svg {
|
||||
margin: auto;
|
||||
width: 150px;
|
||||
fill: rgba(255, 255, 255, .05);
|
||||
}
|
||||
|
||||
/* # Feature queries */
|
||||
|
||||
@media (hover: hover) {
|
||||
:is(h1, h2, h3, p, li) > a:hover {
|
||||
text-underline-offset: 1px;
|
||||
text-decoration-thickness: calc(var(--underline-tickness) * 2);
|
||||
color: var(--color-accent);
|
||||
}
|
||||
|
||||
/* # Components */
|
||||
|
||||
button {
|
||||
transition: 200ms background-color, 200ms border-color, 200ms color;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
border-color: rgba(255, 255, 255, .2);
|
||||
background-color: rgba(255, 255, 255, .1);
|
||||
}
|
||||
|
||||
button.solid:hover {
|
||||
color: var(--color-accent);
|
||||
border-color: rgba(var(--primer-color-accent), .2);
|
||||
background-color: rgba(var(--primer-color-accent), .2);
|
||||
box-shadow: 0 -10px 20px 10px rgba(var(--primer-color-accent), .05);
|
||||
}
|
||||
|
||||
/* ## Header */
|
||||
|
||||
header .logo:hover path.solid {
|
||||
fill: var(--color-accent);
|
||||
}
|
||||
|
||||
searchbox {
|
||||
transition: 200ms background-color;
|
||||
}
|
||||
|
||||
searchbox:hover {
|
||||
background-color: rgba(255, 255, 255, .07);
|
||||
}
|
||||
}
|
||||
|
||||
/* # Size queries */
|
||||
|
||||
@media (min-width: 700px) {
|
||||
header {
|
||||
grid-template-columns: 1fr 250px var(--running-size);
|
||||
}
|
||||
|
||||
header nav {
|
||||
justify-self: start;
|
||||
margin: 0 calc(var(--padding) / 2);
|
||||
}
|
||||
|
||||
/* # Menu */
|
||||
|
||||
/* < Move the search box to the header */
|
||||
header searchbox {
|
||||
display: grid;
|
||||
}
|
||||
|
||||
menu searchbox {
|
||||
display: none;
|
||||
}
|
||||
/* /> */
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
@font-face {
|
||||
font-family: "Roboto Mono";
|
||||
ascent-override: 100%;
|
||||
font-weight: 400;
|
||||
size-adjust: 105%;
|
||||
font-stretch: 97.5% 112.5%;
|
||||
src: local("Roboto Mono Regular"), url("/assets/fonts/roboto-mono-regular.woff2") format("woff2");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Roboto Mono";
|
||||
ascent-override: 100%;
|
||||
size-adjust: 95%;
|
||||
font-weight: 800;
|
||||
src: local("Roboto Mono Bold"), url("/assets/fonts/roboto-mono-bold.woff2") format("woff2");
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
/* # Overrides */
|
||||
|
||||
:root {
|
||||
--primer-color-accent: 148, 255, 21;
|
||||
--color-accent: rgb(var(--primer-color-accent));
|
||||
}
|
||||
|
||||
main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--padding);
|
||||
}
|
||||
|
||||
/* # Sections */
|
||||
|
||||
/* ## Divider */
|
||||
|
||||
main > hr {
|
||||
border-color: rgba(255, 255, 255, .1);
|
||||
}
|
||||
|
||||
/* ## About */
|
||||
|
||||
section.about {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: calc(var(--padding) / 2);
|
||||
}
|
||||
|
||||
section.about p:first-of-type:first-letter {
|
||||
font-size: 1.8rem;
|
||||
font-weight: bold;
|
||||
margin-right: .1rem;
|
||||
color: var(--color-accent);
|
||||
}
|
||||
|
||||
section.about span.interests {
|
||||
-webkit-user-select: none;
|
||||
user-select: none;
|
||||
color: var(--color-accent);
|
||||
animation: interests-hue 5s infinite linear;
|
||||
}
|
||||
|
||||
/* ## Version */
|
||||
|
||||
section.version {
|
||||
color: rgba(255, 255, 255, .2);
|
||||
}
|
||||
|
||||
/* # Interests */
|
||||
|
||||
div.interests {
|
||||
transition: 300ms opacity;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
font-weight: bold;
|
||||
pointer-events: none;
|
||||
font-size: 50px;
|
||||
color: var(--color-accent);
|
||||
overflow: hidden;
|
||||
opacity: 0;
|
||||
z-index: 200;
|
||||
}
|
||||
|
||||
div.interests.active {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
div.interests p {
|
||||
--text-shadow-blur: 30px;
|
||||
|
||||
transition: 300ms transform;
|
||||
position: absolute;
|
||||
text-shadow:
|
||||
0 0 var(--text-shadow-blur) black,
|
||||
0 0 var(--text-shadow-blur) black,
|
||||
0 0 var(--text-shadow-blur) black,
|
||||
0 0 var(--text-shadow-blur) black,
|
||||
0 0 var(--text-shadow-blur) black;
|
||||
}
|
||||
|
||||
@keyframes interests-hue {
|
||||
to {
|
||||
-webkit-filter: hue-rotate(360deg);
|
||||
filter: hue-rotate(360deg);
|
||||
}
|
||||
}
|
|
@ -1,93 +0,0 @@
|
|||
/* # Overrides */
|
||||
|
||||
[vv-page="/search"]:not(body) {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--padding);
|
||||
}
|
||||
|
||||
/* # Sections */
|
||||
|
||||
/* ## Search */
|
||||
|
||||
section.search {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: var(--padding);
|
||||
background-color: rgba(255, 255, 255, .05);
|
||||
padding: calc(var(--padding) * 1.5);
|
||||
margin-bottom: calc(var(--padding) * 2);
|
||||
}
|
||||
|
||||
section.search form {
|
||||
display: contents;
|
||||
}
|
||||
|
||||
section.search search {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
section.search input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
section.search button[type="submit"] {
|
||||
width: 100%;
|
||||
max-width: 350px;
|
||||
}
|
||||
|
||||
section.search > svg {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
body:not([vv-page="/search"]) section.search {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* # Search results */
|
||||
|
||||
section.results .result {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: calc(var(--padding) / 2);
|
||||
}
|
||||
|
||||
/* ---- */
|
||||
|
||||
main > svg,
|
||||
dialog.search search search-results > svg {
|
||||
margin: auto;
|
||||
width: 150px;
|
||||
fill: rgba(255, 255, 255, .05);
|
||||
}
|
||||
|
||||
dialog.search search search-results .empty {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* ## Titles */
|
||||
|
||||
section.title a h2 {
|
||||
color: var(--color-accent);
|
||||
}
|
||||
|
||||
section.title a h2::before {
|
||||
content: "// ";
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* ## Work */
|
||||
|
||||
section.results.work {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: calc(var(--padding) / 2);
|
||||
}
|
||||
|
||||
section.results.work .result {
|
||||
padding: var(--padding);
|
||||
background-color: rgba(255, 255, 255, .03);
|
||||
border-radius: 6px;
|
||||
}
|
Binary file not shown.
Binary file not shown.
|
@ -1,72 +0,0 @@
|
|||
new vv.Interactions("document");
|
||||
|
||||
const mainElement = document.querySelector(vv._env.MAIN);
|
||||
|
||||
// Crossfade pages on navigation
|
||||
// Or maybe I shouldn't... hmmm
|
||||
mainElement.addEventListener(vv.Navigation.events.LOADING, () => {
|
||||
mainElement.classList.add("loading");
|
||||
|
||||
// Clean up modified transform-origin if set after search dialog animation
|
||||
mainElement.style.removeProperty("transform-origin");
|
||||
});
|
||||
|
||||
mainElement.addEventListener(vv.Navigation.events.LOADED, () => {
|
||||
[...document.querySelectorAll("dialog")].forEach(element => element.close())
|
||||
|
||||
// Wait 200ms for the page fade-in animation to finish
|
||||
setTimeout(() => mainElement.classList.remove("loading"), 200);
|
||||
});
|
||||
|
||||
// Search dialog open/close logic
|
||||
{
|
||||
const CLASNAME_DIALOG_OPEN = "search-dialog-open";
|
||||
// Offset in pixels from scroll position when scaling the main element
|
||||
const TRANSFORM_ORIGIN_Y_PADDING = 350;
|
||||
|
||||
const dialog = document.querySelector("dialog.search");
|
||||
|
||||
// "Polyfill" for HTMLDialogELement open and close events
|
||||
(new MutationObserver((mutations) => {
|
||||
// There is only one search dialog elemenet
|
||||
const target = mutations[0].target;
|
||||
|
||||
// Set or unset dialog open class on body depending on dialog visibility
|
||||
target.hasAttribute("open")
|
||||
? target.dispatchEvent(new Event("open"))
|
||||
: target.dispatchEvent(new Event("close"));
|
||||
|
||||
}).observe(dialog, { attributes: true }));
|
||||
|
||||
dialog.addEventListener("open", () => {
|
||||
// Scale main element from the current scroll position
|
||||
mainElement.style.setProperty("transform-origin", `50% calc(${window.scrollY}px + ${TRANSFORM_ORIGIN_Y_PADDING}px)`);
|
||||
|
||||
document.body.classList.add(CLASNAME_DIALOG_OPEN);
|
||||
});
|
||||
dialog.addEventListener("close", () => document.body.classList.remove(CLASNAME_DIALOG_OPEN));
|
||||
|
||||
// Close search dialog if dialog is clicked outside inner content
|
||||
dialog.addEventListener("click", (event) => event.target === dialog ? dialog.close() : null);
|
||||
|
||||
// Open search dialog when searchbox is clicked
|
||||
document.querySelector("searchbox").addEventListener("click", () => dialog.showModal());
|
||||
}
|
||||
|
||||
// Search logic
|
||||
{
|
||||
const searchResultsElement = document.querySelector("search-results");
|
||||
const search = (query) => {
|
||||
new vv.Navigation(`/search?q=${query}`, {
|
||||
carrySearchParams: true
|
||||
}).navigate(searchResultsElement);
|
||||
};
|
||||
|
||||
// Run search on keyup
|
||||
document.querySelector("search input").addEventListener("keyup", (event) => search(event.target.value));
|
||||
|
||||
// Trigger expand search box animation
|
||||
document.querySelector("search input").addEventListener("keydown", () => {
|
||||
searchResultsElement.closest("dialog").classList.add("active");
|
||||
}, { once: true });
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
new vv.Interactions("about");
|
||||
|
||||
const randomIntFromInterval = (min, max) => {
|
||||
return Math.floor(Math.random() * (max - min + 1) + min);
|
||||
}
|
||||
|
||||
// Interest explosion effect from origin position
|
||||
const explodeInterests = (originX, originY) => {
|
||||
// Elements can not translate more than negative- and positive from this number
|
||||
const TRANS_LIMIT = 300;
|
||||
|
||||
const wrapper = document.querySelector("div.interests");
|
||||
wrapper.classList.add("active");
|
||||
|
||||
[...wrapper.querySelectorAll("p")].forEach(element => {
|
||||
/*
|
||||
Generate random visuals for current element
|
||||
*/
|
||||
const hue = randomIntFromInterval(0, 360);
|
||||
const rotate = randomIntFromInterval(-5, 5);
|
||||
const transX = randomIntFromInterval(TRANS_LIMIT * -1, TRANS_LIMIT);
|
||||
const transY = randomIntFromInterval(TRANS_LIMIT * -1, TRANS_LIMIT);
|
||||
|
||||
// Set initial position
|
||||
element.style.setProperty("top", `${originY}px`);
|
||||
element.style.setProperty("left", `${originX}px`);
|
||||
|
||||
// Set random HUE rotation
|
||||
element.style.setProperty("-webkit-filter", `hue-rotate(${hue}deg)`);
|
||||
element.style.setProperty("filter", `hue-rotate(${hue}deg)`);
|
||||
|
||||
// Translate and rotate to random position from origin
|
||||
element.style.setProperty("transform", `translate(${transX}px, ${transY}px) rotate(${rotate}deg)`);
|
||||
});
|
||||
};
|
||||
|
||||
// Interest implotion effect from explodeInterests()
|
||||
const implodeInterests = () => {
|
||||
const wrapper = document.querySelector("div.interests");
|
||||
wrapper.classList.remove("active");
|
||||
|
||||
[...wrapper.querySelectorAll("p")].forEach(element => {
|
||||
// Reset to initial position
|
||||
element.style.setProperty("transform", "translate(0, 0)");
|
||||
});
|
||||
};
|
||||
|
||||
// Bind triggers for interests explosion and implotion
|
||||
{
|
||||
const interestsElement = document.querySelector("section.about span.interests");
|
||||
// Bind mouse or touch events depending on pointer type of device
|
||||
const canHover = window.matchMedia("(pointer: fine)").matches;
|
||||
|
||||
interestsElement.addEventListener(canHover ? "mouseenter" : "touchstart", () => {
|
||||
// Get absolute position of the trigger element
|
||||
const size = interestsElement.getBoundingClientRect();
|
||||
|
||||
const x = size.x - 80;
|
||||
const y = size.y - 10;
|
||||
|
||||
explodeInterests(x, y);
|
||||
});
|
||||
|
||||
interestsElement.addEventListener(canHover ? "mouseleave" : "touchend", () => implodeInterests());
|
||||
}
|
|
@ -1,120 +0,0 @@
|
|||
const EMAIL_CPY_ANIM_DUR_MSECONDS = 1000;
|
||||
|
||||
// Run email copied splash animation
|
||||
const emailCopiedAnimation = () => {
|
||||
const CONFETTI_COUNT = 40;
|
||||
const CONFETTI_SCALE_PIXELS = 300;
|
||||
|
||||
const randomIntFromInterval = (min, max) => {
|
||||
return Math.floor(Math.random() * (max - min + 1) + min)
|
||||
}
|
||||
|
||||
// Create new splash element
|
||||
const splashElement = document.createElement("splash");
|
||||
splashElement.innerText = "copied!";
|
||||
|
||||
// Set inline display to none to hide this element on pages where the splash element has no override styles defined.
|
||||
splashElement.style.display = "none";
|
||||
|
||||
// Array of box-shadow strings as "confetti"
|
||||
const confetti = [];
|
||||
|
||||
// Generate random confetti
|
||||
for (let i = 0; i < CONFETTI_COUNT; i++) {
|
||||
// Random confetti position
|
||||
const x = randomIntFromInterval(CONFETTI_SCALE_PIXELS * -1, CONFETTI_SCALE_PIXELS);
|
||||
const y = randomIntFromInterval(CONFETTI_SCALE_PIXELS * -1, CONFETTI_SCALE_PIXELS);
|
||||
|
||||
// Random confetti RGB color
|
||||
const rgb = [
|
||||
randomIntFromInterval(0, 255),
|
||||
randomIntFromInterval(0, 255),
|
||||
randomIntFromInterval(0, 255)
|
||||
];
|
||||
|
||||
// Interpolate random values and append to outer confetti array
|
||||
confetti.push(`${x}px ${y}px 0 rgb(${rgb.join(",")})`);
|
||||
}
|
||||
|
||||
// Set CSS variable on splash element that in turn will be used by pseudo-element
|
||||
splashElement.style.setProperty("--confetti", confetti.join(","));
|
||||
|
||||
// Start animation by appending the created element to the document body
|
||||
document.body.appendChild(splashElement);
|
||||
|
||||
// Run hide animation
|
||||
setTimeout(() => {
|
||||
splashElement.classList.add("hide");
|
||||
|
||||
// Selfdestruct element when hide animation finishes
|
||||
setTimeout(() => splashElement.remove(), 400);
|
||||
}, EMAIL_CPY_ANIM_DUR_MSECONDS + 100);
|
||||
}
|
||||
|
||||
new vv.Interactions("index", {
|
||||
// Copy email address to clipboard
|
||||
copyEmail: async () => {
|
||||
try {
|
||||
await navigator.clipboard.writeText("victor@vlw.se");
|
||||
|
||||
// Run "email copied" animation!
|
||||
emailCopiedAnimation();
|
||||
|
||||
// NOTE: I don't know, spamming the button is kinda fun
|
||||
// Prevent interactions with the copy email elements while the animation is running
|
||||
/*[...document.querySelectorAll("[vv-call='copyEmail']")].forEach(element => {
|
||||
//element.classList.add("lock");
|
||||
|
||||
setTimeout(() => element.classList.remove("lock"), EMAIL_CPY_ANIM_DUR_MSECONDS);
|
||||
});*/
|
||||
} catch (error) {
|
||||
console.error(error.message);
|
||||
}
|
||||
},
|
||||
// Open the fullscreen menu
|
||||
openMenu: () => document.querySelector("menu").classList.add("active"),
|
||||
// Close the fullscreen menu
|
||||
closeMenu: () => document.querySelector("menu").classList.remove("active")
|
||||
});
|
||||
|
||||
// Change site accent color on hover of menu items
|
||||
if (window.matchMedia("(hover: hover)")) {
|
||||
// Update root CSS variables
|
||||
const updateColor = (rgb = null, hue = 0) => {
|
||||
if (!rgb) {
|
||||
document.documentElement.style.removeProperty("--hue-accent");
|
||||
document.documentElement.style.removeProperty("--primer-color-accent");
|
||||
document.documentElement.style.removeProperty("--color-accent");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
document.documentElement.style.setProperty("--hue-accent", `${hue}deg`);
|
||||
|
||||
document.documentElement.style.setProperty("--primer-color-accent", `${rgb}`);
|
||||
// Compiled color variable must to be updated to receive the new RGB values
|
||||
document.documentElement.style.setProperty("--color-accent", "rgb(var(--primer-color-accent)");
|
||||
};
|
||||
|
||||
[...document.querySelectorAll("menu li")].forEach(element => {
|
||||
// Change site accent color to RGB and HUE rotation defined in element dataset
|
||||
element.addEventListener("mouseenter", (event) => updateColor(event.target.dataset.rgb, event.target.dataset.hue));
|
||||
// Reset initial accent color and hues
|
||||
element.addEventListener("mouseleave", () => updateColor());
|
||||
});
|
||||
|
||||
// Reset color on navigation
|
||||
document.querySelector(vv._env.MAIN).addEventListener(vv.Navigation.events.LOADED, () => updateColor(), { once: true });
|
||||
}
|
||||
|
||||
// Open search box from mobile fullscreen menu
|
||||
{
|
||||
// Open search dialog when searchbox is clicked
|
||||
document.querySelector("menu searchbox").addEventListener("click", () => {
|
||||
// Search box dialog element
|
||||
document.querySelector("dialog.search").showModal();
|
||||
|
||||
// Close fullscreen menu
|
||||
document.querySelector("menu").classList.remove("active");
|
||||
});
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
// Don't open the search dialog overlay if search page is open stand-alone
|
||||
{
|
||||
const searchBox = document.querySelector("body:not(.search-dialog-open) searchbox");
|
||||
|
||||
// Page is stand-alone
|
||||
if (searchBox) {
|
||||
// Shift focus to the on-page search box instead of opening search dialog on click
|
||||
const shiftSearchboxFocus = () => {
|
||||
// Override normal "open search dialog" behavior
|
||||
document.querySelector("dialog.search").close();
|
||||
|
||||
// Shift focus to the on-page search input instead
|
||||
}
|
||||
|
||||
// Bind event listener to searchbox element
|
||||
document.querySelector("body:not(.search-dialog-open) searchbox").addEventListener("click", shiftSearchboxFocus, true);
|
||||
|
||||
// Remove event listener from searchbox element on page navigation
|
||||
mainElement.addEventListener(vv.Navigation.events.LOADING, () => {
|
||||
searchBox.removeEventListener("click", shiftSearchboxFocus);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
new vv.Interactions("search");
|
|
@ -1 +0,0 @@
|
|||
new vv.Interactions("work");
|
|
@ -1 +0,0 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 98 98"><path fill-rule="evenodd" clip-rule="evenodd" d="M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z" fill="#fff"/></svg>
|
Before Width: | Height: | Size: 957 B |
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 6.8 KiB |
|
@ -1 +0,0 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="36" height="22"><g fill="none"><path class="solid" d="M12 22 0 0h24Z"/><path class="stroke" d="M12 17.823 20.63 2H3.37L12 17.823M12 22 0 0h24L12 22Z"/><g opacity=".5"><path class="solid" d="M24 22 12 0h24Z"/><path class="stroke" d="M24 17.823 32.63 2H15.37L24 17.823M24 22 12 0h24L24 22Z"/></g></g></svg>
|
Before Width: | Height: | Size: 351 B |
|
@ -1,17 +1,7 @@
|
|||
{
|
||||
"require": {
|
||||
"local/api.client": "1.0.0-dev",
|
||||
"local/api.endpoints": "1.0.0-dev"
|
||||
"vlw/mysql": "dev-master",
|
||||
"vlw/xenum": "dev-master"
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"repositories": [
|
||||
{
|
||||
"type": "path",
|
||||
"url": "src/packages/API"
|
||||
},
|
||||
{
|
||||
"type": "path",
|
||||
"url": "api/src/packages/Endpoints"
|
||||
}
|
||||
]
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||
|
|
116
composer.lock
generated
116
composer.lock
generated
|
@ -4,109 +4,75 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "73a61bf0308871f9dc9ad050aedfe13e",
|
||||
"content-hash": "a7ce20d192550ef2d037220b593b5eb9",
|
||||
"packages": [
|
||||
{
|
||||
"name": "local/api.client",
|
||||
"version": "1.0.0-dev",
|
||||
"dist": {
|
||||
"type": "path",
|
||||
"url": "src/packages/API",
|
||||
"reference": "020275feb0e0017fa91ae0b33213bc54f35cac75"
|
||||
},
|
||||
"require": {
|
||||
"reflect/client": "^3.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"VLW\\API\\": "src/"
|
||||
}
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Victor Westerlund",
|
||||
"email": "victor@vlw.se"
|
||||
}
|
||||
],
|
||||
"description": "Wrapper for vlw.se API",
|
||||
"transport-options": {
|
||||
"relative": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "local/api.endpoints",
|
||||
"version": "1.0.0-dev",
|
||||
"dist": {
|
||||
"type": "path",
|
||||
"url": "api/src/packages/Endpoints",
|
||||
"reference": "89b7b9a4cc504abddb4aeec8e05a95c9d9087575"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"VLW\\API\\": "src/"
|
||||
}
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Victor Westerlund",
|
||||
"email": "victor@vlw.se"
|
||||
}
|
||||
],
|
||||
"description": "Endpoint pathmappings for VLW API",
|
||||
"transport-options": {
|
||||
"relative": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "reflect/client",
|
||||
"version": "3.0.6",
|
||||
"name": "vlw/mysql",
|
||||
"version": "dev-master",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/VictorWesterlund/reflect-client-php.git",
|
||||
"reference": "89a8c041044c8c60cefafc4716d5d61b96c43e06"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/VictorWesterlund/reflect-client-php/zipball/89a8c041044c8c60cefafc4716d5d61b96c43e06",
|
||||
"reference": "89a8c041044c8c60cefafc4716d5d61b96c43e06",
|
||||
"shasum": ""
|
||||
"url": "https://codeberg.org/vlw/php-mysql",
|
||||
"reference": "0e367f797fa9348408881ed758976f21e8c667e4"
|
||||
},
|
||||
"default-branch": true,
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Reflect\\": "src/Reflect/"
|
||||
"vlw\\MySQL\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"GPL-2.0-only"
|
||||
"GPL-3.0-or-later"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Victor Westerlund",
|
||||
"email": "victor.vesterlund@gmail.com"
|
||||
"email": "victor@vlw.se"
|
||||
}
|
||||
],
|
||||
"description": "Extendable PHP interface for communicating with Reflect API over HTTP or UNIX sockets",
|
||||
"support": {
|
||||
"issues": "https://github.com/VictorWesterlund/reflect-client-php/issues",
|
||||
"source": "https://github.com/VictorWesterlund/reflect-client-php/tree/3.0.6"
|
||||
"description": "Abstraction library for common MySQL/MariaDB DML operations with php-mysqli",
|
||||
"time": "2025-07-29T07:46:46+00:00"
|
||||
},
|
||||
{
|
||||
"name": "vlw/xenum",
|
||||
"version": "dev-master",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://codeberg.org/vlw/php-xenum",
|
||||
"reference": "ba3f43a9e2787bf938cfbfcb85ea87e5062df294"
|
||||
},
|
||||
"time": "2024-04-06T14:55:04+00:00"
|
||||
"default-branch": true,
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"vlw\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"GPL-3.0-only"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Victor Westerlund",
|
||||
"email": "victor@vlw.se"
|
||||
}
|
||||
],
|
||||
"description": "PHP eXtended Enums. The missing quality-of-life features from PHP 8+ Enums",
|
||||
"time": "2025-05-10T11:28:03+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
"aliases": [],
|
||||
"minimum-stability": "dev",
|
||||
"stability-flags": {
|
||||
"local/api.client": 20,
|
||||
"local/api.endpoints": 20
|
||||
"vlw/mysql": 20,
|
||||
"vlw/xenum": 20
|
||||
},
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": [],
|
||||
"platform-dev": [],
|
||||
"plugin-api-version": "2.0.0"
|
||||
"plugin-api-version": "2.3.0"
|
||||
}
|
||||
|
|
251
install.sh
Normal file
251
install.sh
Normal file
|
@ -0,0 +1,251 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Define constants
|
||||
DB_VLW="vlw"
|
||||
DB_API="vlw_api"
|
||||
|
||||
# Initialize variables
|
||||
cwd=""
|
||||
database_app_host=""
|
||||
database_app_user=""
|
||||
database_seed_host=""
|
||||
database_seed_user=""
|
||||
database_app_password=""
|
||||
database_seed_password=""
|
||||
|
||||
echo_err() {
|
||||
echo "!! -> $1"
|
||||
}
|
||||
|
||||
# Make sure we have all the system packages we need to proceed with the installation
|
||||
check_sys_depend() {
|
||||
local valid=true
|
||||
local packages=("git" "composer")
|
||||
|
||||
for package in "${packages[@]}" ; do
|
||||
if ! dpkg -l | grep -qw "ii ${package}" ; then
|
||||
echo_err "Package '${package}' is not installed."
|
||||
valid=false
|
||||
fi
|
||||
done
|
||||
|
||||
# Bail out if any required package is missing
|
||||
if [ "$valid" = false ] ; then
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
install_vegvisir() {
|
||||
echo
|
||||
echo "Installing Vegvisir into '$cwd/vegvisir'"
|
||||
|
||||
curl -fsSL https://codeberg.org/vegvisir/install/raw/branch/master/install.sh | bash -s -- --install=n --overwrite=y --example=n --dir="$cwd"
|
||||
}
|
||||
|
||||
install_reflect() {
|
||||
echo
|
||||
echo "Installing Reflect into '$cwd/reflect'"
|
||||
|
||||
curl -fsSL https://codeberg.org/reflect/install/raw/branch/master/install.sh | bash -s -- --install=n --overwrite=y --seed=n --dir="$cwd" --endpoints="api" --host="$database_app_host" --user="$database_app_user" --password="$database_app_password" --db="$DB_API"
|
||||
}
|
||||
|
||||
install_vlw() {
|
||||
composer install --classmap-authoritative
|
||||
}
|
||||
|
||||
seed_databases() {
|
||||
echo
|
||||
echo "-- Database seeding --"
|
||||
echo "We're now going to seed the databases '$DB_VLW' and '$DB_API' with default data"
|
||||
echo "- Make sure that both databases exist and are empty"
|
||||
echo "- Your credentials for this user '$(whoami)' might be different from your app credentials (php-mysql)"
|
||||
echo
|
||||
|
||||
# Database seed hostname
|
||||
echo "Enter the full hostname of your MySQL/MariaDB server to use in this script for seeding."
|
||||
read -p "Press enter to use the same host as the app credentials [$database_app_host]: " database_seed_host </dev/tty
|
||||
|
||||
# Use the same database host as the app configuration
|
||||
if [[ "$database_seed_host" == "" ]] ; then
|
||||
database_seed_host=$database_app_host
|
||||
fi
|
||||
|
||||
# Database seed user
|
||||
echo
|
||||
echo "Enter the username for your MySQL/MariaDB server to use in this script for seeding."
|
||||
read -p "Press enter to use the same host as the app credentials [$database_app_user]: " database_seed_user </dev/tty
|
||||
|
||||
# Use the same database user as the app configuration
|
||||
if [[ "$database_seed_user" == "" ]] ; then
|
||||
database_seed_user=$database_app_user
|
||||
fi
|
||||
|
||||
# Database seed password
|
||||
echo
|
||||
echo "Enter the password for your MySQL/MariaDB server to use in this script for seeding."
|
||||
echo "Enter 'null' to disable password authentication"
|
||||
read -p "Press enter to use the same password as the app credentials [<database_password>]: " database_seed_password </dev/tty
|
||||
|
||||
# Use the same database password as the app configuration
|
||||
if [[ "$database_seed_password" == "" ]] ; then
|
||||
database_seed_password=$database_app_password
|
||||
fi
|
||||
|
||||
# Seed the main database
|
||||
mysql -h "$database_seed_host" -u "$database_seed_user" --password="$database_seed_password" $DB_VLW < src/Database/Seeds/vlw.sql
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo_err "Installation aborted: MySQL error"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Seed the API database
|
||||
mysql -h "$database_seed_host" -u "$database_seed_user" --password="$database_seed_password" $DB_API < src/Database/Seeds/api.sql
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo_err "Installation aborted: MySQL error"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
configure_vlw() {
|
||||
local config_password=""
|
||||
|
||||
local config_available=""
|
||||
local config_available_to=""
|
||||
local config_available_from=""
|
||||
local config_available_average=""
|
||||
local config_available_timezone=""
|
||||
|
||||
local config_forgejo=""
|
||||
local config_forgejo_url=""
|
||||
local config_forgejo_profiles=""
|
||||
|
||||
# A configuration file already exists
|
||||
if [[ -f ".env.ini" ]] ; then
|
||||
echo
|
||||
echo "A configuration file already exists at: ${cwd}/.env.ini"
|
||||
read -p "Do you want to overwrite this file? (y/n): " overwrite </dev/tty
|
||||
|
||||
# Remove existing configuration file or abort
|
||||
if [[ "$overwrite" == "y" || "$overwrite" == "Y" ]] ; then
|
||||
echo "Removing existing configuration and proceeding with the installation in ${cwd}..."
|
||||
rm .env.ini
|
||||
else
|
||||
echo_err "Installation aborted: Configuration file already exists"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "-- Database configuration --"
|
||||
read -p "Enter the full hostname of your MySQL/MariaDB server (php-mysql): " database_app_host </dev/tty
|
||||
read -p "Enter the app username for your MySQL/MariaDB server (php-mysql): " database_app_user </dev/tty
|
||||
read -p "Enter the app password for your MySQL/MariaDB server (php-mysql): " config_password </dev/tty
|
||||
|
||||
# Coerce empty input as null keyword for later configurations
|
||||
if [[ "$config_password" == "" ]] ; then
|
||||
database_app_password="null"
|
||||
fi
|
||||
|
||||
echo
|
||||
read -p "(Optional) Would you like to configure time available settings? (y/n): " config_available </dev/tty
|
||||
|
||||
# Check the user's response
|
||||
if [[ "$config_available" == "n" || "$config_available" == "N" ]]; then
|
||||
config_available_to=0
|
||||
config_available_from=0
|
||||
config_available_average=0
|
||||
config_available_timezone="Europe/Stockholm"
|
||||
fi
|
||||
|
||||
if ! [[ -n "$config_available_timezone" ]]; then
|
||||
read -p "Enter your timezone in IANA Time Zone Database Format ('Europe/Stockholm' for example): " config_available_timezone </dev/tty
|
||||
fi
|
||||
|
||||
if ! [[ -n "$config_available_from" ]]; then
|
||||
read -p "Enter time available from hour (24-hour format): " config_available_from </dev/tty
|
||||
fi
|
||||
|
||||
if ! [[ -n "$config_available_to" ]]; then
|
||||
read -p "Enter time available to hour (24-hour format): " config_available_to </dev/tty
|
||||
fi
|
||||
|
||||
if ! [[ -n "$config_available_average" ]]; then
|
||||
read -p "Enter average reply time in hours: " config_available_average </dev/tty
|
||||
fi
|
||||
|
||||
echo
|
||||
read -p "(Optional) Would you like to configure Forgejo language updates? (y/n): " config_forgejo </dev/tty
|
||||
|
||||
# Check the user's response
|
||||
if [[ "$config_forgejo" == "n" || "$config_forgejo" == "N" ]]; then
|
||||
config_forgejo_url="https://git.vlw.se"
|
||||
config_forgejo_profiles="vlw,vegvisir,reflect"
|
||||
fi
|
||||
|
||||
if ! [[ -n "$config_forgejo_url" ]]; then
|
||||
read -p "Enter a hostname to a Forgejo instance ('https://git.vlw.se' for example): " config_forgejo_url </dev/tty
|
||||
fi
|
||||
|
||||
if ! [[ -n "$config_forgejo_profiles" ]]; then
|
||||
read -p "Enter a comma seperated list of Forgejo profiles to scan ('vlw,vegvisir,reflect' for example): " config_forgejo_profiles </dev/tty
|
||||
fi
|
||||
|
||||
local config=(
|
||||
"; This config file was generated automatically by ./install.sh"
|
||||
"; Refer to '.env.example.ini' for more information"
|
||||
"[mariadb]"
|
||||
"host = '$database_app_host'"
|
||||
"user = '$database_app_user'"
|
||||
"pass = '$config_password'"
|
||||
"db = '$DB_VLW'"
|
||||
"[config_time_available]"
|
||||
"time_zone = '$config_available_timezone'"
|
||||
"available_to_hour = '$config_available_to'"
|
||||
"reply_average_hours = '$config_available_average'"
|
||||
"available_from_hour = '$config_available_from'"
|
||||
"[service_forgejo]"
|
||||
"url = '$config_forgejo_url'"
|
||||
"profiles = '$config_forgejo_profiles'"
|
||||
)
|
||||
|
||||
for line in "${config[@]}" ; do
|
||||
echo "${line}" >> .env.ini
|
||||
done
|
||||
}
|
||||
|
||||
main() {
|
||||
# Get the current working directory
|
||||
cwd=$(pwd)
|
||||
|
||||
check_sys_depend
|
||||
|
||||
configure_vlw
|
||||
seed_databases
|
||||
|
||||
install_vlw
|
||||
install_vegvisir
|
||||
install_reflect
|
||||
|
||||
echo "-- Success --"
|
||||
echo "vlw.se has been installed! :)"
|
||||
echo "- Point all traffic to your web server to '${cwd}/vegvisir/public/index.php'"
|
||||
echo "- Point all traffic to your REST API server to '${cwd}/reflect/public/index.php'"
|
||||
echo "-------------"
|
||||
echo
|
||||
}
|
||||
|
||||
# Prompt the user for confirmation
|
||||
echo
|
||||
echo "-- Installing vlw.se --"
|
||||
echo "You are currently in: $(pwd)"
|
||||
read -p "Do you want to proceed with the installation in this directory? (y/n): " choice </dev/tty
|
||||
|
||||
# Check the user's response
|
||||
if [[ "$choice" == "y" || "$choice" == "Y" ]] ; then
|
||||
echo "Proceeding with the installation in $(pwd)..."
|
||||
main
|
||||
else
|
||||
echo "Installation aborted."
|
||||
fi
|
|
@ -1,48 +0,0 @@
|
|||
<style><?= VV::css("pages/about") ?></style>
|
||||
<section class="intro">
|
||||
<h2 aria-hidden="true">Hi, I'm</h2>
|
||||
<h1>Victor Westerlund</h1>
|
||||
</section>
|
||||
<hr aria-hidden="true">
|
||||
<section class="about">
|
||||
<p>I​'m a full-stack web developer from Sweden, currently working as IT-Lead at <a href="https://icellate.com">iCellate Medical</a> in Solna, Stockholm - a biopharma start-up developing precision oncology. I develop and maintain <a href="https://github.com/VictorWesterlund/vegvisir">my own web framework</a> and use it to build web apps and websites - including this one.</p>
|
||||
<p>The <programming/markup/command>-languages I currently use the most are (in a mostly accurate decending order): PHP, JavaScript, CSS, MySQL, Python, SQLite, Bash, and [raw] HTML.</p>
|
||||
</section>
|
||||
<section class="about">
|
||||
<h2>This website</h2>
|
||||
<p>This site and all of its components are 100% Free Software; licensed under the GNU GPLv3. It's built on top of my own <a href="">Vegvisir</a> (web) and <a href="">Reflect</a> (API) framework. There are no cookies or trackers on this site and analytics <strong>only</strong> consist of basic access and error logs; and from which IP address.</p>
|
||||
</section>
|
||||
<section class="about">
|
||||
<h2>Projects</h2>
|
||||
<p>These are my top projects I'm working on right now:</p>
|
||||
<p>* <a href="https://github.com/VictorWesterlund/vegvisir">Vegvisir</a>: A web framework written in PHP, for PHP developers.</p>
|
||||
<p>* <a href="https://github.com/VictorWesterlund/reflect">Reflect</a>: An API framework also written in PHP, for PHP developers.</p>
|
||||
<p>See more on my <a href="work" vv="about" vv-call="navigate">works page</a>. And even more including smaller projects on my <a href="https://github.com/VictorWesterlund">GitHub</a>.</p>
|
||||
</section>
|
||||
<section class="about">
|
||||
<h2>Personal</h2>
|
||||
<p>At times, I can become a real sucker for a <span class="interests">variety of topics I find interesting</span>, and spend hours reading as much as I can about them too. When I'm not glued to a computer screen, I like me some skiing and occasional hobby photography. I'm also a real coffeeholic.</p>
|
||||
<p>Let's work on something together, have a chat, or anything else. <a href="contact" vv="about" vv-call="navigate">write me a line!</a></p>
|
||||
</section>
|
||||
<section class="about">
|
||||
<h2>Projects</h2>
|
||||
<p>These are my top projects I'm working on right now:</p>
|
||||
<p>* <a href="">Vegvisir</a>: A web framework written in PHP, for PHP developers.</p>
|
||||
<p>* <a href="">Reflect</a>: An API framework also written in PHP, for PHP developers.</p>
|
||||
<p>See more on my <a href="work" vv="about" vv-call="navigate">works page</a>. And even more including smaller projects on my <a href="https://github.com/VictorWesterlund">GitHub</a>.</p>
|
||||
</section>
|
||||
<hr>
|
||||
<section class="version">
|
||||
<p>website version: <?= VV::include("about/version") ?></p>
|
||||
</section>
|
||||
|
||||
<div class="interests" aria-hidden="true">
|
||||
<p>practical engineering</p>
|
||||
<p>music</p>
|
||||
<p>astronomy</p>
|
||||
<p>electronics</p>
|
||||
<p>aviation</p>
|
||||
<p>marine technology</p>
|
||||
<p>typography</p>
|
||||
</div>
|
||||
<script><?= VV::js("pages/about") ?></script>
|
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
A pretty naive website version fetcher that assumes the latest git tag is the
|
||||
version the website is currently displaying. The intent is that any live-master
|
||||
of this website should always track the master branch and pull the latest HEAD
|
||||
without any exceptions.
|
||||
*/
|
||||
|
||||
use Vegvisir\Path;
|
||||
|
||||
// Get tags from local git folder
|
||||
$dir = scandir(Path::root(".git/refs/tags"), SCANDIR_SORT_ASCENDING);
|
||||
|
||||
// Get current version number from latest tag
|
||||
$version = $dir[2] ?? "";
|
||||
|
||||
?>
|
||||
<a href="https://github.com/victorwesterlund/vlw.se/releases/<?= $version ?>"><?= $version ?></a>
|
|
@ -1,89 +0,0 @@
|
|||
<?php
|
||||
|
||||
use VLW\API\Client;
|
||||
use VLW\API\Endpoints;
|
||||
|
||||
enum ContactFieldsEnum: string {
|
||||
case EMAIL = "email";
|
||||
case MESSAGE = "message";
|
||||
}
|
||||
|
||||
// Connect to VLW API
|
||||
$api = new Client();
|
||||
|
||||
// Null when nothing has been sent, true if message has been sent, false if it failed
|
||||
$message_sent = null;
|
||||
|
||||
// Message has been submitted
|
||||
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
// Submit message to endpoint and set variable with results
|
||||
$message_sent = $api->call(Endpoints::MESSAGES->value)->post([
|
||||
ContactFieldsEnum::EMAIL->value => $_POST[ContactFieldsEnum::EMAIL->value],
|
||||
ContactFieldsEnum::MESSAGE->value => $_POST[ContactFieldsEnum::MESSAGE->value]
|
||||
])->ok;
|
||||
}
|
||||
|
||||
?>
|
||||
<style><?= VV::css("pages/contact") ?></style>
|
||||
<section>
|
||||
<h1>Let's chat</h1>
|
||||
<p>The best way to get in touch is by email, or with the form on this page. The time in Sweden right now is <span></span> so I will probably reply within a few hours.</p>
|
||||
</section>
|
||||
<section class="social">
|
||||
<a href="mailto:victor@vlw.se"><social>
|
||||
<?= VV::media("icons/email.svg") ?>
|
||||
<p>e-mail</p>
|
||||
</social></a>
|
||||
<a href="https://mastodon.social/@vlwone"><social>
|
||||
<?= VV::media("icons/mastodon.svg") ?>
|
||||
<p>mastodon</p>
|
||||
</social></a>
|
||||
<a href="https://web.libera.chat/#vlw.se"><social>
|
||||
<?= VV::media("icons/libera.svg") ?>
|
||||
<p>libera.chat</p>
|
||||
</social></a>
|
||||
</section>
|
||||
<?= VV::media("line.svg") ?>
|
||||
<section class="pgp">
|
||||
<?= VV::media("icons/pin.svg") ?>
|
||||
<h3>encrypt your message with my OpenPGP key.</h3>
|
||||
<p>my key is also listed on the <a href="https://keys.openpgp.org/search?q=victor%40vlw.se" target="_blank" rel="noopener noreferer">openPGP key server</a> for victor@vlw.se so your e-mail client can automatically retreive it if supported.</p>
|
||||
<div class="buttons">
|
||||
<a href="https://keys.openpgp.org/vks/v1/by-fingerprint/DCE987311CB5D2A252F58951D0AD730E1057DFC6"><button class="solid">download ASC</button></a>
|
||||
<a href="https://emailselfdefense.fsf.org/en/" target="_blank" rel="noopener noreferer"><button>more info</button></a>
|
||||
</div>
|
||||
</section>
|
||||
<?= VV::media("line.svg") ?>
|
||||
|
||||
<?php // Show contact form if a message has not been (sucessfully) sent ?>
|
||||
<?php if ($message_sent !== true): ?>
|
||||
|
||||
<?php // Show error message if something went wrong ?>
|
||||
<?php if ($message_sent === false): ?>
|
||||
<section class="form-message error">
|
||||
<h3>😟 Oh no, something went wrong</h3>
|
||||
<p>Response from API:</p>
|
||||
<pre><?= json_encode($post_message[1], JSON_PRETTY_PRINT) ?></pre>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<section class="form">
|
||||
<form method="POST">
|
||||
<input-group>
|
||||
<label>your email</label>
|
||||
<input type="email" name="<?= ContactFieldsEnum::EMAIL->value ?>" placeholder="nissehult@example.com" autocomplete="off"></input>
|
||||
</input-group>
|
||||
<input-group>
|
||||
<label title="this field is required">your message<sup>*</sup></label>
|
||||
<textarea name="<?= ContactFieldsEnum::MESSAGE->value ?>" required placeholder="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed molestie dignissim mauris vel dignissim. Sed et aliquet odio, id egestas libero. Vestibulum ut dui a turpis aliquam hendrerit id et dui. Morbi eu tristique quam, sit amet dictum felis. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin ac nibh a ex accumsan ullamcorper non quis eros. Nam at suscipit lacus. Nullam placerat semper sapien, vitae aliquet nisl elementum a. Duis viverra quam eros, eu vestibulum quam egestas sit amet. Duis lobortis varius malesuada. Mauris in fringilla mi. "></textarea>
|
||||
</input-group>
|
||||
<button class="solid">send</button>
|
||||
</form>
|
||||
</section>
|
||||
<?php else: ?>
|
||||
<section class="form-message sent">
|
||||
<h3>🙏 Message sent!</h3>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<script><?= VV::js("pages/contact") ?></script>
|
|
@ -1,6 +0,0 @@
|
|||
<style><?= VV::css("pages/error") ?></style>
|
||||
<canvas></canvas>
|
||||
<section class="error">
|
||||
<h1 glitch-text><span>4</span><span>0</span><span>4</span></h1>
|
||||
</section>
|
||||
<script type="module"><?= VV::js("pages/error") ?></script>
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
|
||||
enum RGB: string {
|
||||
case WORK = "3,255,219";
|
||||
case ABOUT = "148,255,21";
|
||||
case CONTACT = "255,195,255";
|
||||
}
|
||||
|
||||
?>
|
||||
<style><?= VV::css("pages/index") ?></style>
|
||||
<div class="menu">
|
||||
<?= VV::media("line.svg") ?>
|
||||
<menu>
|
||||
<a href="/work" vv="index" vv-call="navigate"><li data-rgb="<?= RGB::WORK->value ?>" data-hue="90">work</li></a>
|
||||
<a href="/about" vv="index" vv-call="navigate"><li data-rgb="<?= RGB::ABOUT->value ?>" data-hue="390">about</li></a>
|
||||
<a href="/contact" vv="index" vv-call="navigate"><li data-rgb="<?= RGB::CONTACT->value ?>" data-hue="200">contact</li></a>
|
||||
</menu>
|
||||
<?= VV::media("line.svg") ?>
|
||||
<button class="email" vv="index" vv-call="copyEmail">
|
||||
<p>victor@vlw.se</p>
|
||||
<p class="cta">to copy</p>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<img src="/assets/media/gazing.jpg"/>
|
||||
<!--<picture class="gazing">
|
||||
<source srcset="/assets/media/gazing.avif" type="image/avif"/>
|
||||
<source srcset="/assets/media/gazing.webp" type="image/webp"/>
|
||||
<img src="/assets/media/gazing.jpg"/>
|
||||
</picture>-->
|
||||
<script><?= VV::js("pages/index") ?></script>
|
137
pages/search.php
137
pages/search.php
|
@ -1,137 +0,0 @@
|
|||
<?php
|
||||
|
||||
use VLW\API\Client;
|
||||
use VLW\API\Endpoints;
|
||||
|
||||
$api = new Client();
|
||||
|
||||
$query = $_GET["q"] ?? null;
|
||||
|
||||
// Get search results from endpoint
|
||||
$response = $api->call(Endpoints::SEARCH->value)
|
||||
// Get query string from search parameter if set
|
||||
->params(["q" => $query])
|
||||
->get();
|
||||
|
||||
?>
|
||||
<style><?= VV::css("pages/search") ?></style>
|
||||
<section class="search">
|
||||
<form method="GET">
|
||||
<search>
|
||||
<input name="q" type="text" placeholder="search anything..." value="<?= $query ?>"></input>
|
||||
</search>
|
||||
<button type="submit" class="solid">Search</button>
|
||||
</form>
|
||||
<?= VV::media("line.svg") ?>
|
||||
<button>advanced search options</button>
|
||||
</section>
|
||||
|
||||
<?php if ($response): ?>
|
||||
<?php // Get response body ?>
|
||||
<?php $body = $response->json(); ?>
|
||||
|
||||
<?php // Do things depending on the response code from API ?>
|
||||
<?php switch ($response->code): default: ?>
|
||||
<?php // An unknown error occured ?>
|
||||
<section class="error">
|
||||
<p>Something went wrong</p>
|
||||
</section>
|
||||
<?php break; ?>
|
||||
|
||||
<?php // Query was successful! (Doesn't meant we got search results tho) ?>
|
||||
<?php case 200: ?>
|
||||
|
||||
<?php // Show category sections if search matches were found ?>
|
||||
<?php if ($body["total_num_results"] > 0): ?>
|
||||
<?php // Get search results by category ?>
|
||||
<?php $categories = $body["results"]; ?>
|
||||
|
||||
<?php // Results category: work ?>
|
||||
<?php if (!empty($categories["work"])): ?>
|
||||
<section class="title work">
|
||||
<a href="/work" vv="search" vv-call="navigate"><h2>Work</h2></a>
|
||||
<p><?= count($categories["work"]) ?> search result(s) from my public work</p>
|
||||
</section>
|
||||
<section class="results work">
|
||||
|
||||
<?php // List all work category search results ?>
|
||||
<?php foreach ($categories["work"] as $result): ?>
|
||||
<div class="result">
|
||||
<h3><?= $result["title"] ?></h3>
|
||||
<p><?= $result["summary"] ?></p>
|
||||
<p><?= date(Client::DATE_FORMAT, $result["date_timestamp_created"]) ?></p>
|
||||
|
||||
<?php // Result has actions defined ?>
|
||||
<?php if (!empty($result["actions"])): ?>
|
||||
<div class="actions">
|
||||
|
||||
<?php // List all actions ?>
|
||||
<?php foreach ($result["actions"] as $action): ?>
|
||||
|
||||
<?php if (!$action["external"]): ?>
|
||||
<a href="<?= $action["href"] ?>" vv="search" vv-call="navigate"><button class="<?= $action["class_list"] ?>"><?= $action["display_text"] ?></button></a>
|
||||
<?php else: ?>
|
||||
<a href="<?= $action["href"] ?>" target="_blank"><button class="<?= $action["class_list"] ?>"><?= $action["display_text"] ?></button></a>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php endforeach; ?>
|
||||
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php // No search matches were found ?>
|
||||
<?php else: ?>
|
||||
<section class="empty">
|
||||
<p>No results for search term "<?= $_GET["q"] ?>"</p>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php break; ?>
|
||||
|
||||
<?php // No access to the search endpoint ?>
|
||||
<?php case 404: ?>
|
||||
<section class="error">
|
||||
<p>Connection to VLW API was successful but lacking permission to search</p>
|
||||
</section>
|
||||
<?php break; ?>
|
||||
|
||||
<?php // Got a request validation error from the endpoint ?>
|
||||
<?php case 422: ?>
|
||||
|
||||
<?php // Get all validation errors for query and list them ?>
|
||||
<?php foreach ($body["GET"]["q"] as $error_code => $error_msg): ?>
|
||||
|
||||
<?php // Check the error code of the current error ?>
|
||||
<?php switch ($error_code): default: ?>
|
||||
<section class="error">
|
||||
<p>Unknown request validation error</p>
|
||||
</section>
|
||||
<?php break; ?>
|
||||
|
||||
<?php // Search query string is not long enough ?>
|
||||
<?php case "VALUE_MIN_ERROR": ?>
|
||||
<section class="error">
|
||||
<p>Type at least <?= $error_msg ?> characters to search!</p>
|
||||
</section>
|
||||
<?php break; ?>
|
||||
|
||||
<?php endswitch; ?>
|
||||
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php break; ?>
|
||||
|
||||
<?php endswitch; ?>
|
||||
|
||||
<?php // No query search paramter set, show general information ?>
|
||||
<?php else: ?>
|
||||
<?= VV::media("icons/search.svg") ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<script><?= VV::js("pages/search") ?></script>
|
162
pages/work.php
162
pages/work.php
|
@ -1,162 +0,0 @@
|
|||
<?php
|
||||
|
||||
use VLW\API\Client;
|
||||
use VLW\API\Endpoints;
|
||||
|
||||
// Connect to VLW API
|
||||
$api = new Client();
|
||||
|
||||
// Retreive rows from work endpoint
|
||||
$response = $api->call(Endpoints::WORK->value)->get();
|
||||
|
||||
?>
|
||||
<style><?= VV::css("pages/work") ?></style>
|
||||
|
||||
<section class="git">
|
||||
<?= VV::media("icons/github.svg") ?>
|
||||
<p>Most of my free open-source software is available on GitHub and it's also mirrored on my server</p>
|
||||
<div class="buttons">
|
||||
<a href="https://github.com/victorwesterlund"><button class="solid">open GitHub</button></a>
|
||||
<a href="https://git.vlw.se"><button>mirror</button></a>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<?php if ($response->ok): ?>
|
||||
<?php
|
||||
|
||||
/*
|
||||
Order response from endpoint into a multi-dimensional array.
|
||||
For example, a single item created at 14th of February 2024 would be ordered like this
|
||||
[2024 => [[02 => [14 => [<row_data>]]]]]
|
||||
*/
|
||||
|
||||
$rows = [];
|
||||
// Create array of arrays ordered by decending year, month, day, items
|
||||
foreach ($response->json() as $row) {
|
||||
// Create array for current year if it doesn't exist
|
||||
if (!array_key_exists($row["date_year"], $rows)) {
|
||||
$rows[$row["date_year"]] = [];
|
||||
}
|
||||
|
||||
// Create array for current month if it doesn't exist
|
||||
if (!array_key_exists($row["date_month"], $rows[$row["date_year"]])) {
|
||||
$rows[$row["date_year"]][$row["date_month"]] = [];
|
||||
}
|
||||
|
||||
// Create array for current day if it doesn't exist
|
||||
if (!array_key_exists($row["date_day"], $rows[$row["date_year"]][$row["date_month"]])) {
|
||||
$rows[$row["date_year"]][$row["date_month"]][$row["date_day"]] = [];
|
||||
}
|
||||
|
||||
// Append item to ordered array
|
||||
$rows[$row["date_year"]][$row["date_month"]][$row["date_day"]][] = $row;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<section class="timeline">
|
||||
<?php // Get year int from key and array of months for current year ?>
|
||||
<?php foreach($rows as $year => $months): ?>
|
||||
<div class="year">
|
||||
<div class="track">
|
||||
<p><?= $year ?></p>
|
||||
</div>
|
||||
|
||||
<div class="months">
|
||||
<?php // Get month int from key and array of days for current month ?>
|
||||
<?php foreach($months as $month => $days): ?>
|
||||
<div class="month">
|
||||
<div class="track">
|
||||
<?php // Append leading zero to month ?>
|
||||
<p><?= sprintf("%02d", $month) ?></p>
|
||||
</div>
|
||||
|
||||
<div class="days">
|
||||
<?php // Get day int from key and array of items for current day ?>
|
||||
<?php foreach($days as $day => $items): ?>
|
||||
<div class="day">
|
||||
<div class="track">
|
||||
<?php // Append leading zero to day ?>
|
||||
<p><?= sprintf("%02d", $day) ?></p>
|
||||
</div>
|
||||
|
||||
<div class="items">
|
||||
<?php foreach($items as $item): ?>
|
||||
<div class="item">
|
||||
|
||||
<?php // List tags if defined for item ?>
|
||||
<?php if(!empty($item["tags"])): ?>
|
||||
<div class="tags">
|
||||
<?php foreach($item["tags"] as $tag): ?>
|
||||
<p class="tag <?= $tag["name"] ?>"><?= $tag["name"] ?></p>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php // Show large heading if defined ?>
|
||||
<?php if (!empty($item["title"])): ?>
|
||||
<h2><?= $item["title"] ?></h2>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php // Show cover image if defined for item ?>
|
||||
<?php if (!empty($item["cover_srcset"])): ?>
|
||||
<picture>
|
||||
|
||||
<?php // List all srcset images ?>
|
||||
<?php foreach ($item["cover_srcset"]["srcset"] as $srcset): ?>
|
||||
<?php // Skip any media that isn't an image ?>
|
||||
<?php if ($srcset["type"] !== "IMAGE"): continue; endif; ?>
|
||||
|
||||
<srcset src="/assets/media/content/<?= $srcset["id"] ?>.<?= $srcset["extension"] ?>" type="<?= $srcset["mime"] ?>"></srcset>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php
|
||||
// Get the default/fallback image for this srcset
|
||||
$default = $item["cover_srcset"]["default"];
|
||||
?>
|
||||
<img src="/assets/media/content/<?= $default["id"] ?>.<?= $default["extension"] ?>" type="<?= $default["mime"] ?>" loading="lazy"/>
|
||||
</picture>
|
||||
<?php endif; ?>
|
||||
|
||||
<p><?= $item["summary"] ?></p>
|
||||
|
||||
<?php // List actions if defined for item ?>
|
||||
<?php if(!empty($item["actions"])): ?>
|
||||
<div class="actions">
|
||||
<?php foreach($item["actions"] as $action): ?>
|
||||
<?php
|
||||
// Bind VV interactions for buttons or add new tab target if external link
|
||||
$link_attr = !$action["external"] ? "vv='work' vv-call='navigate'" : "target='_blank'";
|
||||
|
||||
// Self-reference to a work page with the item id if no href is set
|
||||
$link_href = $action["href"] === null ? "/work/{$item["id"]}" : $action["href"];
|
||||
?>
|
||||
|
||||
<a href="<?= $link_href ?>" <?= $link_attr ?>><button class="<?= $action["class_list"] ?>"><?= $action["display_text"] ?></button></a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</section>
|
||||
<section class="note">
|
||||
<p>This is not really the end of the list. I will add some of my notable older work at some point.</p>
|
||||
</section>
|
||||
<?php else: ?>
|
||||
<p>Something went wrong!</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<script><?= VV::js("pages/work") ?></script>
|
140
public/about.php
Normal file
140
public/about.php
Normal file
|
@ -0,0 +1,140 @@
|
|||
<?php
|
||||
|
||||
use VLW\Database\Models\Coffee\Coffee;
|
||||
use VLW\Database\Models\Languages\Language;
|
||||
|
||||
require_once VV::root("src/Database/Models/Coffee/Coffee.php");
|
||||
require_once VV::root("src/Database/Models/Languages/Language.php");
|
||||
|
||||
const FORGEJO = "https://git.vlw.se/explore/repos?language=";
|
||||
const SI_BYTE_MULTIPLE = ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
||||
|
||||
$languages = new class extends Language {
|
||||
private readonly int $total_bytes;
|
||||
|
||||
public function __construct() {
|
||||
$this->total_bytes = array_sum(array_map(fn(Language $language): int => $language->bytes, parent::all()));
|
||||
}
|
||||
|
||||
public function percent(Language $language, int $mode = PHP_ROUND_HALF_UP): int {
|
||||
return round(($language->bytes / $this->total_bytes) * 100, 0, $mode);
|
||||
}
|
||||
|
||||
public function percent_string(Language $language): string {
|
||||
return ($this->percent($language) > 1 ? $this->percent($language) : "<1") . "%";
|
||||
}
|
||||
|
||||
public function bytes_si_string(Language $language): string {
|
||||
// Calculate factor for unit
|
||||
$factor = floor((strlen($language->bytes) - 1) / 3);
|
||||
// Divide by radix 10
|
||||
$format = $language->bytes / pow(1000, $factor);
|
||||
|
||||
return round($format) . " " . SI_BYTE_MULTIPLE[$factor];
|
||||
}
|
||||
};
|
||||
|
||||
$coffee = new class extends Coffee {
|
||||
public readonly int $count_week;
|
||||
public readonly int $count_week_average;
|
||||
|
||||
public function __construct() {
|
||||
$this->count_week = parent::count_week();
|
||||
$this->count_week_average = parent::count_week_average();
|
||||
}
|
||||
|
||||
public function week_average_string(): string {
|
||||
$diff = $this->count_week - $this->count_week_average;
|
||||
|
||||
return match (true) {
|
||||
$diff < 0 => "less than",
|
||||
$diff === 0 => "the same as",
|
||||
$diff > 0 => "more than"
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
?>
|
||||
<style><?= VV::css("public/assets/css/pages/about") ?></style>
|
||||
<section class="intro">
|
||||
<h2 aria-hidden="true">Hi, I'm</h2>
|
||||
<h1>Victor Westerlund</h1>
|
||||
</section>
|
||||
<hr aria-hidden="true">
|
||||
<section class="about">
|
||||
<p>I​'m a full-stack web developer from Sweden, and welcome to my little personal corner of the Internet!</p>
|
||||
<p>My coding happens almost exclusivly in <a href="https://github.com/coder/code-server">code-server</a>, which is a fork of VSCode that runs entirely in the browser. I keep my development environment tucked away in a lightweight Debian VA that I can tote around to whatever host machine I happen to work on. I also keep an ephemeral Debian Live ISO ready which boots into a VM RAM disk where I can mess around without fear or breaking things or try new software.</p>
|
||||
<p>I used to list the <programming/markup/command/whatever>-languages here that I use the most and order them by guesstimating how much I use each one. But then I thought it would be better to just show you instead using this chart that automatically pulls the total bytes for each language from my <a href="https://git.vlw.se/explore/repos">public repos on Forgejo</a>.</p>
|
||||
</section>
|
||||
<section class="languages">
|
||||
<stacked-bar-chart>
|
||||
|
||||
<?php foreach ($languages::all() as $language): ?>
|
||||
<a href="<?= FORGEJO . $language->name ?>" target="_blank"><chart-segment style="--size:<?= $languages->percent($language) ?>%;" data-lang="<?= $language->name ?>" data-bytes="<?= $language->bytes ?>">
|
||||
<span data-hover><strong><?= $languages->percent_string($language) ?> <?= $language->name ?></strong><br>(<?= $language->bytes ?> bytes)</span>
|
||||
</chart-segment></a>
|
||||
<?php endforeach; ?>
|
||||
|
||||
</stacked-bar-chart>
|
||||
<languages-list>
|
||||
|
||||
<?php foreach ($languages::all() as $language): ?>
|
||||
<a href="<?= FORGEJO . $language->name ?>"><button data-lang="<?= $language->name ?>" class="inline">
|
||||
<p><?= $languages->percent_string($language) ?></p>
|
||||
<p class="lang"><?= $language->name ?></p>
|
||||
<p><?= $languages->bytes_si_string($language) ?></p>
|
||||
<?= VV::embed("public/assets/media/icons/chevron.svg") ?>
|
||||
</button></a>
|
||||
<?php endforeach; ?>
|
||||
|
||||
</languages-list>
|
||||
<stacked-bar-chart>
|
||||
|
||||
<?php foreach ($languages::all() as $language): ?>
|
||||
<a href="<?= FORGEJO . $language->name ?>" target="_blank"><chart-segment style="--size:<?= $languages->percent($language) ?>%;" data-lang="<?= $language->name ?>" data-bytes="<?= $language->bytes ?>">
|
||||
<span data-hover><strong><?= $languages->percent_string($language) ?> <?= $language->name ?></strong><br>(<?= $language->bytes ?> bytes)</span>
|
||||
</chart-segment></a>
|
||||
<?php endforeach; ?>
|
||||
|
||||
</stacked-bar-chart>
|
||||
|
||||
</section>
|
||||
<section class="about">
|
||||
<h2>This website</h2>
|
||||
<p>This site and all of its components, including texts and graphics have been created by me and are all <a href="https://codeberg.org/vlw/vlw.se">100% free and open source</a>. Feel free to use anything you see on this website in your own projects as long as it's under the same GNU GPLv3-or-later license. The website is designed by me on top of my own <a href="https://vegvisir.vlw.se">web framework</a> and <a href="https://reflect.vlw.se">API framework</a>.</p>
|
||||
<p>You won't find any cookies or trackers on this site! The only information I have about you are in the standard NGINX access and error logs, which get overwritten automatically after some time.</p>
|
||||
</section>
|
||||
<section class="about">
|
||||
<h2>Personal</h2>
|
||||
<p>One thing that most people know about me is that I like coffee.. lots of coffee. In fact, I've had <?= $coffee->count_week ?> cup<?= $coffee->count_week === 1 ? "" : "s" ?> of coffee in the last 7 days! That's <?= $coffee->week_average_string() ?> my average of <?= $coffee->count_week_average ?> per week, impressive! Even though you just read that.. I don't consider myself <i>too much</i> of a coffee snob! As long as it's dark roast and warm, I'm probably happy to have it.</p>
|
||||
<p>At times, I become a true, amateur, armchair detective for a <span class="interests">variety of your typical-nerdy topics that I find interesting</span> and you can bet I spend way more time reading about those things than I will ever have use for in life.</p>
|
||||
<p>Another silent passion of mine that comes out every few years is building computers and fiddling with networking stuff.</p>
|
||||
</section>
|
||||
<hr>
|
||||
<section class="about">
|
||||
<h3>GitHub</h3>
|
||||
<p>I have <a href="https://giveupgithub.com" target="_blank" rel="noopener noreferer">given up GitHub</a> and moved most of my free software to <a href="https://codeberg.org/vlw">Codeberg</a>. You can still find my <a href="https://github.com/VictorWesterlund">GitHub profile here</a> but I don't use it for source control of my projects anymore.</p>
|
||||
</section>
|
||||
<hr>
|
||||
<section>
|
||||
<p>Let's work on something together or just have a chat? <a href="contact">Write me a line!</a></p>
|
||||
</section>
|
||||
|
||||
<div class="interests" aria-hidden="true">
|
||||
<p>SSTV</p>
|
||||
<p>music</p>
|
||||
<p>aviation</p>
|
||||
<p>maritime</p>
|
||||
<p>politics</p>
|
||||
<p>astronomy</p>
|
||||
<p>typography</p>
|
||||
<p>networking</p>
|
||||
<p>electronics</p>
|
||||
<p>simulations</p>
|
||||
<p>engineering</p>
|
||||
<p>photography</p>
|
||||
<p>videography</p>
|
||||
<p>RFC 3339</p>
|
||||
<p>digital archiving</p>
|
||||
</div>
|
||||
<script><?= VV::js("public/assets/js/pages/about") ?></script>
|
8
public/assets/css/fonts.css
Normal file
8
public/assets/css/fonts.css
Normal file
|
@ -0,0 +1,8 @@
|
|||
@font-face {
|
||||
font-family: "Roboto Mono";
|
||||
src:
|
||||
url("/assets/fonts/roboto-mono.woff2") format("woff2 supports variations"),
|
||||
url("/assets/fonts/roboto-mono.woff2") format("woff2-variations")
|
||||
;
|
||||
font-weight: 100 900;
|
||||
}
|
286
public/assets/css/pages/about.css
Normal file
286
public/assets/css/pages/about.css
Normal file
|
@ -0,0 +1,286 @@
|
|||
/* # Overrides */
|
||||
|
||||
:root {
|
||||
--primer-color-accent: 148, 255, 21;
|
||||
--color-accent: rgb(var(--primer-color-accent));
|
||||
--hue-accent: 390deg;
|
||||
|
||||
--primer-color-go: 0, 173, 216;
|
||||
--primer-color-php: 79, 93, 149;
|
||||
--primer-color-css: 86, 61, 124;
|
||||
--primer-color-html: 227, 76, 38;
|
||||
--primer-color-shell: 137, 224, 81;
|
||||
--primer-color-python: 53, 114, 165;
|
||||
--primer-color-typescript: 49, 120, 198;
|
||||
--primer-color-javascript: 241, 224, 90;
|
||||
|
||||
--color-go: rgb(var(--primer-color-go));
|
||||
--color-php: rgb(var(--primer-color-php));
|
||||
--color-css: rgb(var(--primer-color-css));
|
||||
--color-html: rgb(var(--primer-color-html));
|
||||
--color-shell: rgb(var(--primer-color-shell));
|
||||
--color-python: rgb(var(--primer-color-python));
|
||||
--color-typescript: rgb(var(--primer-color-typescript));
|
||||
--color-javascript: rgb(var(--primer-color-javascript));
|
||||
}
|
||||
|
||||
vv-shell {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--padding);
|
||||
}
|
||||
|
||||
/* # Sections */
|
||||
|
||||
/* ## Divider */
|
||||
|
||||
vv-shell > hr {
|
||||
border-color: rgba(255, 255, 255, .1);
|
||||
}
|
||||
|
||||
/* ## About */
|
||||
|
||||
section.about {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: calc(var(--padding) / 2);
|
||||
}
|
||||
|
||||
section.about p:first-of-type:first-letter {
|
||||
font-size: 1.8rem;
|
||||
font-weight: bold;
|
||||
margin-right: .1rem;
|
||||
color: var(--color-accent);
|
||||
}
|
||||
|
||||
section.about span.interests {
|
||||
-webkit-user-select: none;
|
||||
user-select: none;
|
||||
color: var(--color-accent);
|
||||
animation: interests-hue 5s infinite linear;
|
||||
}
|
||||
|
||||
/* ## Languages */
|
||||
|
||||
section.languages {
|
||||
margin: calc(var(--padding) / 1.5) 0;
|
||||
}
|
||||
|
||||
section.languages stacked-bar-chart {
|
||||
gap: 3px;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
border-radius: 100px;
|
||||
height: var(--padding);
|
||||
background-color: rgba(255, 255, 255, 0);
|
||||
}
|
||||
|
||||
section.languages stacked-bar-chart:last-of-type {
|
||||
flex-direction: row-reverse;
|
||||
}
|
||||
|
||||
section.languages stacked-bar-chart:hover chart-segment {
|
||||
opacity: .5;
|
||||
}
|
||||
|
||||
section.languages stacked-bar-chart chart-segment {
|
||||
--border-corner-radius: 100px;
|
||||
|
||||
transition: 150ms opacity;
|
||||
width: var(--size, 0%);
|
||||
min-width: 3%;
|
||||
height: 100%;
|
||||
color: white;
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background-color: rgba(255, 255, 255, .1);
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
section.languages stacked-bar-chart a:nth-child(odd) chart-segment {
|
||||
background-color: rgba(255, 255, 255, .3);
|
||||
}
|
||||
|
||||
/* ### Round corners */
|
||||
|
||||
section.languages stacked-bar-chart a:first-child chart-segment {
|
||||
border-top-right-radius: var(--padding);
|
||||
border-bottom-right-radius: var(--padding);
|
||||
border-top-left-radius: var(--border-corner-radius);
|
||||
border-bottom-left-radius: var(--border-corner-radius);
|
||||
}
|
||||
|
||||
section.languages stacked-bar-chart a:last-child chart-segment {
|
||||
border-top-left-radius: var(--padding);
|
||||
border-bottom-left-radius: var(--padding);
|
||||
border-top-right-radius: var(--border-corner-radius);
|
||||
border-bottom-right-radius: var(--border-corner-radius);
|
||||
}
|
||||
|
||||
section.languages stacked-bar-chart:last-of-type a:first-child chart-segment {
|
||||
border-top-left-radius: var(--padding);
|
||||
border-bottom-left-radius: var(--padding);
|
||||
border-top-right-radius: var(--border-corner-radius);
|
||||
border-bottom-right-radius: var(--border-corner-radius);
|
||||
}
|
||||
|
||||
section.languages stacked-bar-chart:last-of-type a:last-child chart-segment {
|
||||
border-top-right-radius: var(--padding);
|
||||
border-bottom-right-radius: var(--padding);
|
||||
border-top-left-radius: var(--border-corner-radius);
|
||||
border-bottom-left-radius: var(--border-corner-radius);
|
||||
}
|
||||
|
||||
/* ### Texts */
|
||||
|
||||
section.languages stacked-bar-chart chart-segment p {
|
||||
text-align: center;
|
||||
color: inherit;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
pointer-events: none;
|
||||
text-overflow: ellipsis;
|
||||
padding: 0 3px;
|
||||
}
|
||||
|
||||
section.languages stacked-bar-chart chart-segment[style="--size:0%;"] p span {
|
||||
display: none;
|
||||
}
|
||||
|
||||
section.languages stacked-bar-chart chart-segment[style="--size:0%;"] p::before {
|
||||
content: "<1%";
|
||||
opacity: .5;
|
||||
}
|
||||
|
||||
section.languages stacked-bar-chart chart-segment [data-hover] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* ### Colors */
|
||||
|
||||
section.languages stacked-bar-chart a chart-segment[data-lang="Go"] { background-color: var(--color-go); }
|
||||
section.languages stacked-bar-chart a chart-segment[data-lang="PHP"] { background-color: var(--color-php); }
|
||||
section.languages stacked-bar-chart a chart-segment[data-lang="CSS"] { background-color: var(--color-css); }
|
||||
section.languages stacked-bar-chart a chart-segment[data-lang="HTML"] { background-color: var(--color-html); }
|
||||
section.languages stacked-bar-chart a chart-segment[data-lang="Python"] { background-color: var(--color-python); }
|
||||
section.languages stacked-bar-chart a chart-segment[data-lang="TypeScript"] { background-color: var(--color-typescript); }
|
||||
section.languages stacked-bar-chart a chart-segment[data-lang="Shell"] { background-color: var(--color-shell); color: black; }
|
||||
section.languages stacked-bar-chart a chart-segment[data-lang="JavaScript"] { background-color: var(--color-javascript); color: black; }
|
||||
|
||||
/* ### Legend */
|
||||
|
||||
section.languages languages-list {
|
||||
gap: calc(var(--padding) / 2);
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
margin: var(--padding) 0;
|
||||
}
|
||||
|
||||
section.languages languages-list language-item {
|
||||
gap: 10px;
|
||||
display: flex;
|
||||
border-radius: 8px;
|
||||
align-items: center;
|
||||
fill: var(--color-php);
|
||||
padding: calc(var(--padding) / 1.5);
|
||||
border: solid 1px rgba(255, 255, 255, .1);
|
||||
background: linear-gradient(139deg, rgba(0, 0, 0, 0) 0%, rgba(79, 93, 144, .2) 100%);
|
||||
}
|
||||
|
||||
section.languages languages-list language-item svg {
|
||||
width: 2em;
|
||||
margin-left: auto;
|
||||
transform: rotate(-90deg);
|
||||
}
|
||||
|
||||
section.languages button p.lang {
|
||||
font-size: 1.3em;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
/* # Interests */
|
||||
|
||||
div.interests {
|
||||
--text-shadow-blur: 30px;
|
||||
|
||||
transition: 300ms opacity;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
font-weight: bold;
|
||||
pointer-events: none;
|
||||
font-size: clamp(16px, 15vw, 50px);
|
||||
color: var(--color-accent);
|
||||
overflow: hidden;
|
||||
opacity: 0;
|
||||
z-index: 200;
|
||||
}
|
||||
|
||||
div.interests.active {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
div.interests p {
|
||||
transition: 500ms transform cubic-bezier(.34,0,0,.99);
|
||||
position: absolute;
|
||||
text-shadow:
|
||||
0 0 var(--text-shadow-blur) black,
|
||||
0 0 var(--text-shadow-blur) black,
|
||||
0 0 var(--text-shadow-blur) black,
|
||||
0 0 var(--text-shadow-blur) black,
|
||||
0 0 var(--text-shadow-blur) black;
|
||||
}
|
||||
|
||||
@keyframes interests-hue {
|
||||
to {
|
||||
-webkit-filter: hue-rotate(360deg);
|
||||
filter: hue-rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
/* Feature queries */
|
||||
|
||||
@media (hover: hover) {
|
||||
section.languages stacked-bar-chart chart-segment:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
section.languages stacked-bar-chart chart-segment [data-hover] {
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
text-align: center;
|
||||
transform: translate(0, 0);
|
||||
background-color: inherit;
|
||||
padding: 5px 10px;
|
||||
white-space: nowrap;
|
||||
pointer-events: none;
|
||||
border-radius: 6px;
|
||||
z-index: 2000;
|
||||
-webkit-backdrop-filter: brightness(.2) blur(20px);
|
||||
backdrop-filter: brightness(.2) blur(20px);
|
||||
}
|
||||
|
||||
section.languages stacked-bar-chart chart-segment [data-hover].hovering {
|
||||
display: initial;
|
||||
}
|
||||
}
|
||||
|
||||
/* Size queries */
|
||||
|
||||
@media (max-width: 900px) {
|
||||
section.languages languages-list {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 650px) {
|
||||
section.languages languages-list {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
51
assets/css/pages/contact.css → public/assets/css/pages/contact.css
Executable file → Normal file
51
assets/css/pages/contact.css → public/assets/css/pages/contact.css
Executable file → Normal file
|
@ -3,21 +3,32 @@
|
|||
:root {
|
||||
--primer-color-accent: 255, 195, 255;
|
||||
--color-accent: rgb(var(--primer-color-accent));
|
||||
--hue-accent: 200deg;
|
||||
}
|
||||
|
||||
main {
|
||||
vv-shell {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: var(--padding);
|
||||
}
|
||||
|
||||
.fingerprint {
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
/* # Sections */
|
||||
|
||||
main > svg {
|
||||
vv-shell > svg {
|
||||
margin: var(--padding) 0;
|
||||
}
|
||||
|
||||
/* ## Modifiers */
|
||||
|
||||
section.center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* ## Social */
|
||||
|
||||
section.social {
|
||||
|
@ -57,18 +68,22 @@ section.social social:hover {
|
|||
fill: var(--color-accent);
|
||||
}
|
||||
|
||||
section.social social.hovering p {
|
||||
section.social social p.hovering {
|
||||
display: initial;
|
||||
}
|
||||
|
||||
/* ## OpenPGP key */
|
||||
/* ## PGP key */
|
||||
|
||||
section.pgp {
|
||||
max-width: 800px;
|
||||
position: relative;
|
||||
display: flex;
|
||||
border-radius: 12px;
|
||||
flex-direction: column;
|
||||
gap: var(--padding);
|
||||
text-align: center;
|
||||
background-color: rgba(var(--primer-color-accent), .15);
|
||||
padding: calc(var(--padding) * 1.5);
|
||||
padding: var(--padding);
|
||||
transform: rotate(-1.5deg);
|
||||
}
|
||||
|
||||
|
@ -81,16 +96,29 @@ section.pgp > svg {
|
|||
}
|
||||
|
||||
section.pgp > p {
|
||||
margin-bottom: var(--padding);
|
||||
padding: var(--padding);
|
||||
padding: 0 var(--padding);
|
||||
}
|
||||
|
||||
section.pgp .buttons {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin-top: var(--padding);
|
||||
gap: var(--padding);
|
||||
}
|
||||
|
||||
/* ## Blockquote */
|
||||
|
||||
cite {
|
||||
text-decoration: underline;
|
||||
text-decoration-style: dotted;
|
||||
text-decoration-color: rgba(var(--primer-color-accent), .5);
|
||||
text-decoration-thickness: .1em;
|
||||
|
||||
&:hover {
|
||||
text-decoration-color: var(--color-accent);
|
||||
}
|
||||
}
|
||||
|
||||
/* ## Contact form */
|
||||
|
||||
section.form :is(input, textarea) {
|
||||
|
@ -158,6 +186,7 @@ section.form-message h3 {
|
|||
}
|
||||
|
||||
section.form-message pre {
|
||||
white-space: pre-wrap;
|
||||
padding: var(--padding);
|
||||
background-color: rgba(0, 0, 0, .15);
|
||||
}
|
||||
|
@ -171,9 +200,17 @@ section.form-message.sent {
|
|||
background-color: var(--color-accent);
|
||||
}
|
||||
|
||||
section.form-message.sent + section.form {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* # Size queries */
|
||||
|
||||
@media (min-width: 460px) {
|
||||
section.pgp {
|
||||
padding: calc(var(--padding) * 1.5);
|
||||
}
|
||||
|
||||
section.pgp .buttons {
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
2
assets/css/pages/error.css → public/assets/css/pages/error.css
Executable file → Normal file
2
assets/css/pages/error.css → public/assets/css/pages/error.css
Executable file → Normal file
|
@ -6,7 +6,7 @@ header {
|
|||
backdrop-filter: unset;
|
||||
}
|
||||
|
||||
main {
|
||||
vv-shell {
|
||||
max-width: unset;
|
||||
display: grid;
|
||||
justify-items: center;
|
39
assets/css/pages/index.css → public/assets/css/pages/index.css
Executable file → Normal file
39
assets/css/pages/index.css → public/assets/css/pages/index.css
Executable file → Normal file
|
@ -1,15 +1,21 @@
|
|||
/* # Main styles */
|
||||
/* # Overrides */
|
||||
|
||||
body[vv-top-page="/"]::before {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
/* # vv-shell styles */
|
||||
|
||||
/* ## Picture */
|
||||
|
||||
main {
|
||||
vv-shell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
flex-direction: column-reverse;
|
||||
}
|
||||
|
||||
main img {
|
||||
vv-shell img {
|
||||
margin: auto;
|
||||
width: 25vh;
|
||||
pointer-events: none;
|
||||
|
@ -32,7 +38,7 @@ main img {
|
|||
padding: unset;
|
||||
text-align: right;
|
||||
font-size: clamp(20px, 8vh, 60px);
|
||||
font-weight: 900;
|
||||
font-weight: bold;
|
||||
line-height: clamp(20px, 8vh, 60px);
|
||||
color: var(--color-accent);
|
||||
}
|
||||
|
@ -43,6 +49,11 @@ main img {
|
|||
|
||||
.menu svg {
|
||||
width: 100%;
|
||||
animation: dash 1500ms linear infinite;
|
||||
}
|
||||
|
||||
@keyframes dash {
|
||||
to { stroke-dashoffset: 32; }
|
||||
}
|
||||
|
||||
/* ### Copy email button */
|
||||
|
@ -146,25 +157,33 @@ splash::after {
|
|||
|
||||
.menu menu li:hover {
|
||||
opacity: 1;
|
||||
font-weight: 100;
|
||||
text-shadow: 0 0 10px rgba(var(--primer-color-accent), .4);
|
||||
}
|
||||
|
||||
button.email:hover {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
/* enable font-weight hover animation */
|
||||
@media not (prefers-reduced-motion: reduce) {
|
||||
.menu menu li {
|
||||
transition: 200ms opacity, 200ms color, 300ms font-weight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* # Size quries */
|
||||
|
||||
@media (min-width: 900px) {
|
||||
main {
|
||||
vv-shell {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
justify-items: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
main img {
|
||||
vv-shell img {
|
||||
width: 35vh;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: transparent;
|
||||
}
|
||||
}
|
84
public/assets/css/pages/search.css
Normal file
84
public/assets/css/pages/search.css
Normal file
|
@ -0,0 +1,84 @@
|
|||
vv-shell[vv-page="/search"] {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: calc(var(--padding) / 2);
|
||||
}
|
||||
|
||||
/* # Search */
|
||||
|
||||
section.search {
|
||||
display: flex;
|
||||
gap: var(--padding);
|
||||
border-radius: 6px;
|
||||
padding: var(--padding);
|
||||
background-color: rgba(255, 255, 255, .1);
|
||||
}
|
||||
|
||||
section.search form {
|
||||
display: contents;
|
||||
}
|
||||
|
||||
section.search input {
|
||||
flex: 1 1 auto;
|
||||
border-radius: 6px;
|
||||
padding: 0 var(--padding);
|
||||
border: solid 2px rgba(255, 255, 255, .1);
|
||||
background-color: rgba(255, 255, 255, .1);
|
||||
}
|
||||
|
||||
section.search input:focus {
|
||||
outline: none;
|
||||
border-color: white;
|
||||
}
|
||||
|
||||
section.search select {
|
||||
padding: 5px;
|
||||
border: none;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
section.search select :is(option, optgroup) {
|
||||
color: black;
|
||||
}
|
||||
|
||||
/* # Center */
|
||||
|
||||
section.center {
|
||||
display: flex;
|
||||
flex: 1 1 auto;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
fill: var(--color-accent);
|
||||
gap: calc(var(--padding) / 2);
|
||||
}
|
||||
|
||||
section.center svg {
|
||||
width: 60px;
|
||||
}
|
||||
|
||||
/* # Result */
|
||||
|
||||
section.result {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
section.result button {
|
||||
flex: 1 1 auto;
|
||||
text-align: left;
|
||||
padding: var(--padding);
|
||||
}
|
||||
|
||||
/* # Stats */
|
||||
|
||||
section.stats {
|
||||
min-height: calc(var(--padding) * 2);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: calc(var(--padding) / 2);
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
vv-shell[vv-page="/search"] section.stats button {
|
||||
display: none;
|
||||
}
|
16
public/assets/css/pages/work/archive.css
Normal file
16
public/assets/css/pages/work/archive.css
Normal file
|
@ -0,0 +1,16 @@
|
|||
/* # Overrides */
|
||||
|
||||
:root {
|
||||
--primer-color-accent: 3, 255, 219;
|
||||
--color-accent: rgb(var(--primer-color-accent));
|
||||
--hue-accent: 90deg;
|
||||
}
|
||||
|
||||
vv-shell {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--padding);
|
||||
width: 100%;
|
||||
max-width: 1200px;
|
||||
overflow-x: initial;
|
||||
}
|
167
public/assets/css/pages/work/index.css
Normal file
167
public/assets/css/pages/work/index.css
Normal file
|
@ -0,0 +1,167 @@
|
|||
/* # Overrides */
|
||||
|
||||
:root {
|
||||
--primer-color-accent: 3, 255, 219;
|
||||
--color-accent: rgb(var(--primer-color-accent));
|
||||
--hue-accent: 90deg;
|
||||
|
||||
--primer-color-reflect: 220, 26, 0;
|
||||
--primer-color-vegvisir: 0, 128, 255;
|
||||
}
|
||||
|
||||
vv-shell {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--padding);
|
||||
width: 100%;
|
||||
max-width: 1200px;
|
||||
overflow-x: initial;
|
||||
}
|
||||
|
||||
/* # Sections */
|
||||
|
||||
/* ## Hero */
|
||||
|
||||
section.hero {
|
||||
--color-accent: rgb(255, 255, 255);
|
||||
|
||||
display: grid;
|
||||
gap: var(--padding);
|
||||
grid-template-columns: repeat(1, 1fr);
|
||||
}
|
||||
|
||||
section.hero .item {
|
||||
width: 100%;
|
||||
position: relative;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
section.hero .wrapper {
|
||||
gap: var(--padding);
|
||||
z-index: 1;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
position: relative;
|
||||
align-items: baseline;
|
||||
flex-direction: column;
|
||||
padding: calc(var(--padding) * 1.5);
|
||||
}
|
||||
|
||||
section.hero .item .title {
|
||||
display: grid;
|
||||
align-items: center;
|
||||
gap: var(--padding);
|
||||
grid-template-columns: 40px 1fr;
|
||||
}
|
||||
|
||||
section.hero .item .title svg {
|
||||
height: 3em;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
section.hero .actions {
|
||||
margin-top: auto;
|
||||
}
|
||||
|
||||
/* ### Vegivisr */
|
||||
|
||||
section.hero .item.vegvisir {
|
||||
--primer-color-accent: var(--primer-color-vegvisir);
|
||||
--color-accent: rgb(var(--primer-color-vegvisir));
|
||||
|
||||
color: var(--color-vegvisir);
|
||||
background-color: rgba(var(--primer-color-vegvisir), .1);
|
||||
}
|
||||
|
||||
/* ### Reflect */
|
||||
|
||||
section.hero .item.reflect {
|
||||
--primer-color-accent: var(--primer-color-reflect);
|
||||
--color-accent: rgb(var(--primer-color-reflect));
|
||||
|
||||
color: var(--color-reflect);
|
||||
background-color: rgba(var(--primer-color-reflect), .2);
|
||||
}
|
||||
|
||||
/* ## Heading */
|
||||
|
||||
section.heading {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
section.heading svg {
|
||||
height: 2em;
|
||||
}
|
||||
|
||||
/* ## Featured */
|
||||
|
||||
section.featured {
|
||||
display: grid;
|
||||
gap: var(--padding);
|
||||
grid-template-columns: repeat(1, 1fr);
|
||||
}
|
||||
|
||||
section.featured featured-item {
|
||||
display: flex;
|
||||
fill: white;
|
||||
color: white;
|
||||
border-radius: 8px;
|
||||
align-items: baseline;
|
||||
flex-direction: column;
|
||||
padding: var(--padding);
|
||||
background-color: rgba(255, 255, 255, .1);
|
||||
}
|
||||
|
||||
section.featured featured-item .title {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: calc(var(--padding) / 2);
|
||||
}
|
||||
|
||||
section.featured featured-item .title svg {
|
||||
height: 2em;
|
||||
fill: var(--color-accent);
|
||||
}
|
||||
|
||||
section.featured featured-item img {
|
||||
width: 100%;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
section.featured featured-item .actions {
|
||||
gap: var(--padding);
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding-top: var(--padding);
|
||||
margin-top: auto;
|
||||
}
|
||||
|
||||
/* # Size queries */
|
||||
|
||||
@media (min-width: 400px) {
|
||||
section.featured featured-item .actions {
|
||||
flex-direction: row;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 600px) {
|
||||
section.hero {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 900px) {
|
||||
section.featured {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
|
||||
section.featured featured-item .actions button.collapse p {
|
||||
display: none;
|
||||
}
|
||||
}
|
53
assets/css/pages/work.css → public/assets/css/pages/work/timeline.css
Executable file → Normal file
53
assets/css/pages/work.css → public/assets/css/pages/work/timeline.css
Executable file → Normal file
|
@ -3,9 +3,10 @@
|
|||
:root {
|
||||
--primer-color-accent: 3, 255, 219;
|
||||
--color-accent: rgb(var(--primer-color-accent));
|
||||
--hue-accent: 90deg;
|
||||
}
|
||||
|
||||
main {
|
||||
vv-shell {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--padding);
|
||||
|
@ -27,7 +28,8 @@ section.git {
|
|||
border-radius: 6px;
|
||||
}
|
||||
|
||||
section.git svg {
|
||||
section.git > svg {
|
||||
fill: white;
|
||||
width: 60px;
|
||||
}
|
||||
|
||||
|
@ -119,13 +121,10 @@ section.timeline .items .item img {
|
|||
}
|
||||
|
||||
section.timeline .items .item .actions {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
margin-top: 7px;
|
||||
}
|
||||
|
||||
/* ## Note */
|
||||
|
||||
section.note {
|
||||
text-align: center;
|
||||
gap: var(--padding);
|
||||
}
|
||||
|
||||
/* # Size queries */
|
||||
|
@ -136,23 +135,6 @@ section.note {
|
|||
}
|
||||
}
|
||||
|
||||
@media (min-width: 900px) {
|
||||
section.git {
|
||||
display: grid;
|
||||
grid-template-columns: 70px 1fr 400px;
|
||||
align-items: center;
|
||||
gap: calc(var(--padding) * 1.5);
|
||||
}
|
||||
|
||||
section.git svg {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
section.git .buttons {
|
||||
justify-content: end;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 500px) {
|
||||
section.timeline {
|
||||
padding: unset;
|
||||
|
@ -187,7 +169,28 @@ section.note {
|
|||
border-top-color: rgba(var(--primer-color-accent), .2);
|
||||
}
|
||||
|
||||
section.timeline .items .item .actions {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
section.timeline .year:first-of-type .month:first-of-type .day:first-of-type .items .item:first-of-type {
|
||||
margin-top: var(--padding);
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 900px) {
|
||||
section.git {
|
||||
display: grid;
|
||||
grid-template-columns: 70px 1fr 400px;
|
||||
align-items: center;
|
||||
gap: calc(var(--padding) * 1.5);
|
||||
}
|
||||
|
||||
section.git svg {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
section.git .buttons {
|
||||
justify-content: end;
|
||||
}
|
||||
}
|
16
public/assets/css/pages/work/wip.css
Normal file
16
public/assets/css/pages/work/wip.css
Normal file
|
@ -0,0 +1,16 @@
|
|||
/* # Overrides */
|
||||
|
||||
:root {
|
||||
--primer-color-accent: 3, 255, 219;
|
||||
--color-accent: rgb(var(--primer-color-accent));
|
||||
--hue-accent: 90deg;
|
||||
}
|
||||
|
||||
vv-shell {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--padding);
|
||||
width: 100%;
|
||||
max-width: 1200px;
|
||||
overflow-x: initial;
|
||||
}
|
488
public/assets/css/shell.css
Normal file
488
public/assets/css/shell.css
Normal file
|
@ -0,0 +1,488 @@
|
|||
:root {
|
||||
--primer-color-accent: 255, 255, 0;
|
||||
--color-accent: yellow;
|
||||
--hue-accent: 0deg;
|
||||
|
||||
--padding: 20px;
|
||||
--running-size: 80px;
|
||||
--header-search-size: var(--running-size);
|
||||
}
|
||||
|
||||
/* # Cornerstones */
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
fill: inherit;
|
||||
box-sizing: border-box;
|
||||
font-family: "Roboto Mono", sans-serif;
|
||||
color: inherit;
|
||||
font-size: inherit;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
body {
|
||||
display: grid;
|
||||
justify-items: center;
|
||||
grid-template-rows: var(--running-size) 1fr;
|
||||
overscroll-behavior: none;
|
||||
background-color: black;
|
||||
color: white;
|
||||
overflow-x: hidden;
|
||||
min-height: 100svh;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
body::before {
|
||||
transition: 1s opacity;
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: -5%;
|
||||
right: 0;
|
||||
width: 20%;
|
||||
height: 5%;
|
||||
border-radius: 100%;
|
||||
z-index: 1000;
|
||||
box-shadow:
|
||||
0 0 30svh 10svh rgba(var(--primer-color-accent), .2),
|
||||
0 0 30svh 60svh rgba(var(--primer-color-accent), .1),
|
||||
0 0 30svh 150svh rgba(var(--primer-color-accent), .02)
|
||||
;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
/* "enable" the corner glow effect on initial load when a page has been fully loaded */
|
||||
body[vv-top-page]::before {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
a {
|
||||
display: contents;
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/* # Components */
|
||||
|
||||
:is(h1, h2, h3, p, li) > a {
|
||||
--underline-tickness: 3px;
|
||||
|
||||
display: initial;
|
||||
text-decoration: underline;
|
||||
text-decoration-thickness: var(--underline-tickness);
|
||||
text-underline-offset: var(--underline-tickness);
|
||||
text-decoration-color: var(--color-accent);
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 30px;
|
||||
color: var(--color-accent);
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 30px;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 25px;
|
||||
}
|
||||
|
||||
/* ## Page transition */
|
||||
|
||||
[vv-loading] * {
|
||||
transition: 200ms opacity;
|
||||
}
|
||||
|
||||
[vv-loading="true"] * {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
[vv-loading="true"]::after {
|
||||
content: "";
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
width: 45px;
|
||||
height: 49px;
|
||||
background-size: contain;
|
||||
image-rendering: pixelated;
|
||||
transform: translate(-50%, -50%);
|
||||
background-image: url("/assets/media/spinner.gif");
|
||||
-webkit-filter: hue-rotate(var(--hue-accent));
|
||||
filter: hue-rotate(var(--hue-accent));
|
||||
}
|
||||
|
||||
/* ## Buttons */
|
||||
|
||||
button {
|
||||
border: none;
|
||||
background-color: transparent;
|
||||
color: inherit;
|
||||
fill: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* ### Inline */
|
||||
|
||||
button.inline {
|
||||
gap: 10px;
|
||||
display: flex;
|
||||
border-radius: 7px;
|
||||
align-items: center;
|
||||
fill: var(--color-accent);
|
||||
padding: calc(var(--padding) / 1.5);
|
||||
background: linear-gradient(139deg, rgba(0, 0, 0, 0) 0%, rgba(var(--primer-color-accent), .1) 100%);
|
||||
}
|
||||
|
||||
button.inline:not(.solid) {
|
||||
box-shadow:
|
||||
0 0 0 2px rgba(var(--primer-color-accent), .1),
|
||||
10px 7px 40px 3px rgba(var(--primer-color-accent), .06)
|
||||
;
|
||||
}
|
||||
|
||||
button.inline svg {
|
||||
flex: none;
|
||||
height: 1em;
|
||||
}
|
||||
|
||||
button.inline svg:last-child {
|
||||
width: 1.5em;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
button.inline svg.chevron:last-child {
|
||||
transform: rotate(-90deg);
|
||||
}
|
||||
|
||||
button.inline.solid {
|
||||
fill: black;
|
||||
color: black;
|
||||
border: solid 2px rgba(var(--primer-color-accent), 1);
|
||||
border-color: var(--color-accent);
|
||||
background-color: var(--color-accent);
|
||||
}
|
||||
|
||||
/* ## Header */
|
||||
|
||||
header {
|
||||
--border-style: solid 1px rgba(255, 255, 255, .2);
|
||||
|
||||
position: sticky;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: var(--running-size);
|
||||
border-bottom: var(--border-style);
|
||||
display: grid;
|
||||
align-items: stretch;
|
||||
grid-template-columns: 1fr var(--header-search-size) var(--running-size);
|
||||
grid-template-rows: var(--running-size);
|
||||
background-color: rgba(0, 0, 0, .8);
|
||||
z-index: 100;
|
||||
perspective: 3000px;
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
backdrop-filter: blur(20px);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
header > * {
|
||||
--anim-3d-depth: 5px;
|
||||
--anim-3d-peek: 25deg;
|
||||
|
||||
transition: 300ms background-color;
|
||||
transform: rotateX(0deg);
|
||||
backface-visibility: hidden;
|
||||
box-shadow: 0 var(--anim-3d-depth) 0 0 rgba(255, 255, 255, .2);
|
||||
}
|
||||
|
||||
/* enable 3d flip animation */
|
||||
@media not (prefers-reduced-motion: reduce) {
|
||||
header > * {
|
||||
--transform-duration: 600ms;
|
||||
|
||||
transition: var(--transform-duration) transform, 300ms background-color;
|
||||
}
|
||||
}
|
||||
|
||||
header nav {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: var(--padding);
|
||||
}
|
||||
|
||||
header .logo {
|
||||
fill: none;
|
||||
}
|
||||
|
||||
header .logo path.stroke {
|
||||
fill: var(--color-accent);
|
||||
}
|
||||
|
||||
header header .search {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* ### Buttons */
|
||||
|
||||
header button {
|
||||
--icon-size: 25px;
|
||||
|
||||
display: grid;
|
||||
width: 100%;
|
||||
border-left: var(--border-style);
|
||||
grid-template-columns: 1fr;
|
||||
align-items: center;
|
||||
justify-items: center;
|
||||
padding: var(--padding);
|
||||
gap: var(--padding);
|
||||
fill: var(--color-accent);
|
||||
font-size: 13px;
|
||||
color: rgba(255, 255, 255, .5);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
header button:not(.logo) svg {
|
||||
width: var(--icon-size);
|
||||
}
|
||||
|
||||
header button.search p {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* ### Searchbox */
|
||||
|
||||
header searchbox {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
width: 100%;
|
||||
height: var(--running-size);
|
||||
background-color: var(--color-accent);
|
||||
display: grid;
|
||||
align-items: stretch;
|
||||
grid-template-columns: 1fr var(--running-size);
|
||||
grid-template-rows: var(--running-size);
|
||||
box-shadow: none;
|
||||
transform: rotateX(180deg);
|
||||
}
|
||||
|
||||
header searchbox > * {
|
||||
box-shadow: 0 calc(var(--anim-3d-depth) * -1) 0 0 rgba(var(--primer-color-accent), .8);
|
||||
}
|
||||
|
||||
header searchbox button {
|
||||
transition: 300ms background-color, 300ms border-color;
|
||||
border-color: rgba(0, 0, 0, .1);
|
||||
fill: black;
|
||||
}
|
||||
|
||||
header searchbox input {
|
||||
padding: 0 var(--padding);
|
||||
background-color: transparent;
|
||||
outline: none;
|
||||
color: black;
|
||||
border: none;
|
||||
}
|
||||
|
||||
header searchbox input::placeholder {
|
||||
color: rgba(0, 0, 0, .5);
|
||||
}
|
||||
|
||||
/* #### Active */
|
||||
|
||||
header.searchboxActive > * {
|
||||
transform: rotateX(-180deg);
|
||||
}
|
||||
|
||||
header.searchboxActive searchbox {
|
||||
transform: rotateX(0);
|
||||
}
|
||||
|
||||
/* ## vv-shell */
|
||||
|
||||
vv-shell {
|
||||
position: relative;
|
||||
padding: calc(var(--padding) * 1.5);
|
||||
width: 100%;
|
||||
max-width: 1000px;
|
||||
}
|
||||
|
||||
/* ## Search results */
|
||||
|
||||
search-results {
|
||||
transition: 500ms opacity, 300ms transform;
|
||||
position: fixed;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--padding);
|
||||
top: var(--running-size);
|
||||
right: 0;
|
||||
width: 100%;
|
||||
padding: var(--padding);
|
||||
height: calc(100svh - var(--running-size));
|
||||
background-color: black;
|
||||
pointer-events: none;
|
||||
opacity: 0;
|
||||
transform: scale(.99);
|
||||
transform-origin: 100% 0;
|
||||
overflow-y: scroll;
|
||||
z-index: 50;
|
||||
}
|
||||
|
||||
header.searchboxActive ~ search-results {
|
||||
opacity: 1;
|
||||
pointer-events: all;
|
||||
transform: scale(1);
|
||||
}
|
||||
|
||||
search-results section.search {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* ### "Start typing" prompt */
|
||||
|
||||
search-results .info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
margin: auto;
|
||||
gap: var(--padding);
|
||||
}
|
||||
|
||||
search-results .info :is(svg, img) {
|
||||
width: 60px;
|
||||
fill: var(--color-accent);
|
||||
}
|
||||
|
||||
/* # Feature queries */
|
||||
|
||||
@media (hover: hover) {
|
||||
:is(h1, h2, h3, p, li) > a:hover {
|
||||
text-underline-offset: 1px;
|
||||
text-decoration-thickness: calc(var(--underline-tickness) * 2);
|
||||
color: var(--color-accent);
|
||||
}
|
||||
|
||||
/* # Components */
|
||||
|
||||
button.inline {
|
||||
transition-duration: 300ms;
|
||||
transition-property: background-color, border-color, box-shadow, color, fill;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
border-color: rgba(255, 255, 255, .2);
|
||||
background-color: rgba(255, 255, 255, .1);
|
||||
}
|
||||
|
||||
button.inline:hover {
|
||||
fill: var(--color-accent);
|
||||
color: var(--color-accent);
|
||||
}
|
||||
|
||||
button.inline:not(.solid):hover {
|
||||
box-shadow:
|
||||
0 0 0 2px rgba(var(--primer-color-accent), 1),
|
||||
10px 7px 30px 3px rgba(var(--primer-color-accent), .07)
|
||||
;
|
||||
}
|
||||
|
||||
button.solid:hover {
|
||||
border-color: rgba(var(--primer-color-accent), .2);
|
||||
background-color: rgba(var(--primer-color-accent), .2);
|
||||
box-shadow: 0 -10px 20px 10px rgba(var(--primer-color-accent), .05);
|
||||
}
|
||||
|
||||
/* ## Header */
|
||||
|
||||
header .logo:hover path.solid {
|
||||
fill: var(--color-accent);
|
||||
}
|
||||
|
||||
header searchbox button:hover {
|
||||
background-color: rgba(0, 0, 0, .08);
|
||||
}
|
||||
|
||||
/* ### Search */
|
||||
|
||||
@media not (prefers-reduced-motion: reduce) {
|
||||
header:not(.searchboxActive) button.search:hover,
|
||||
header:not(.searchboxActive) button.search:hover + button.logo {
|
||||
transform: rotateX(calc(var(--anim-3d-peek) * -1));
|
||||
}
|
||||
|
||||
header:not(.searchboxActive) button.search:hover ~ searchbox {
|
||||
transform: rotateX(calc(180deg - var(--anim-3d-peek)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* # Size queries */
|
||||
|
||||
@media (min-width: 700px) {
|
||||
:root {
|
||||
--header-search-size: 250px;
|
||||
}
|
||||
|
||||
/* # Cornerstones */
|
||||
|
||||
body::before {
|
||||
right: unset;
|
||||
left: 0;
|
||||
box-shadow:
|
||||
0 0 30svh 10svh rgba(var(--primer-color-accent), .1),
|
||||
0 0 30svh 60svh rgba(var(--primer-color-accent), .05),
|
||||
0 0 30svh 150svh rgba(var(--primer-color-accent), .02)
|
||||
;
|
||||
}
|
||||
|
||||
/* ## Header */
|
||||
|
||||
header nav {
|
||||
margin: 0 calc(var(--padding) / 2);
|
||||
}
|
||||
|
||||
header > button.search {
|
||||
grid-template-columns: var(--icon-size) 1fr;
|
||||
}
|
||||
|
||||
header > button.search p {
|
||||
display: initial;
|
||||
}
|
||||
|
||||
header.searchboxActive > nav {
|
||||
transform: rotateX(0deg);
|
||||
pointer-events: all;
|
||||
}
|
||||
|
||||
/* ### Searchbox */
|
||||
|
||||
header searchbox {
|
||||
width: calc(var(--header-search-size) + var(--running-size));
|
||||
}
|
||||
|
||||
/* ### Menu */
|
||||
|
||||
/* Move the search box to the header */
|
||||
header > button.search {
|
||||
display: grid;
|
||||
justify-items: baseline;
|
||||
}
|
||||
|
||||
@media (min-height: 600px) {
|
||||
search-results {
|
||||
top: calc(var(--running-size) + var(--padding));
|
||||
width: 50%;
|
||||
height: calc(100svh - 100px);
|
||||
background-color: rgba(0, 0, 0, .8);
|
||||
box-shadow:
|
||||
inset 0 0 100px 200px rgba(0, 0, 0, 1),
|
||||
0 0 100px 200px rgba(0, 0, 0, 1)
|
||||
;
|
||||
--webkit-backdrop-filter: blur(15px);
|
||||
backdrop-filter: blur(15px);
|
||||
}
|
||||
}
|
||||
}
|
BIN
public/assets/fonts/roboto-mono.woff2
Normal file
BIN
public/assets/fonts/roboto-mono.woff2
Normal file
Binary file not shown.
32
public/assets/js/modules/Hoverpop.mjs
Normal file
32
public/assets/js/modules/Hoverpop.mjs
Normal file
|
@ -0,0 +1,32 @@
|
|||
import { Elevent } from "/assets/js/modules/npm/Elevent.mjs";
|
||||
|
||||
export const TARGET_SELECTOR = "[data-hover]";
|
||||
|
||||
export class Hoverpop {
|
||||
/**
|
||||
* Bind hover targets on provided Elevent-compatible element(s)
|
||||
* @param {HTMLElement|HTMLElements|string} elements
|
||||
*/
|
||||
constructor(elements) {
|
||||
// Bind hover targets on element(s)
|
||||
new Elevent("mouseenter", elements, (event) => {
|
||||
const element = event.target.querySelector(TARGET_SELECTOR);
|
||||
|
||||
// Bail out if target element contains no hover target element
|
||||
if (!element) {
|
||||
return;
|
||||
}
|
||||
|
||||
element.classList.add("hovering");
|
||||
event.target.addEventListener("mousemove", (event) => {
|
||||
const x = event.layerX - (element.clientWidth / 2);
|
||||
const y = event.layerY + element.clientHeight;
|
||||
|
||||
element.style.setProperty("transform", `translate(${x}px, ${y}px)`);
|
||||
});
|
||||
});
|
||||
|
||||
// Bind hover leave targets on element(s)
|
||||
new Elevent("mouseleave", elements, () => elements.forEach(element => element.querySelector(TARGET_SELECTOR)?.classList.remove("hovering")));
|
||||
}
|
||||
}
|
0
assets/js/modules/glitch/Generator.mjs → public/assets/js/modules/glitch/Generator.mjs
Executable file → Normal file
0
assets/js/modules/glitch/Generator.mjs → public/assets/js/modules/glitch/Generator.mjs
Executable file → Normal file
0
assets/js/modules/glitch/Glitch.mjs → public/assets/js/modules/glitch/Glitch.mjs
Executable file → Normal file
0
assets/js/modules/glitch/Glitch.mjs → public/assets/js/modules/glitch/Glitch.mjs
Executable file → Normal file
0
assets/js/modules/glitch/GlitchWorker.js → public/assets/js/modules/glitch/GlitchWorker.js
Executable file → Normal file
0
assets/js/modules/glitch/GlitchWorker.js → public/assets/js/modules/glitch/GlitchWorker.js
Executable file → Normal file
78
public/assets/js/pages/about.js
Normal file
78
public/assets/js/pages/about.js
Normal file
|
@ -0,0 +1,78 @@
|
|||
const randomIntFromInterval = (min, max) => {
|
||||
return Math.floor(Math.random() * (max - min + 1) + min);
|
||||
}
|
||||
|
||||
// Interest explosion effect from origin position
|
||||
const explodeInterests = (originX, originY) => {
|
||||
const wrapper = document.querySelector("div.interests");
|
||||
wrapper.classList.add("active");
|
||||
|
||||
// Elements can not expand further than positive or negative of these values
|
||||
const transLimitX = window.innerWidth / 4;
|
||||
const transLimitY = window.innerHeight / 3;
|
||||
|
||||
[...wrapper.querySelectorAll("p")].forEach(element => {
|
||||
const size = element.getBoundingClientRect();
|
||||
|
||||
// Generate random HUE wheel rotation degrees
|
||||
const hue = randomIntFromInterval(0, 360);
|
||||
// Generate random element transform rotation
|
||||
const rotate = randomIntFromInterval(-5, 5);
|
||||
|
||||
// Generate random offsets in each direction clamped to translation limit
|
||||
let transX = randomIntFromInterval(transLimitX * -1, transLimitX);
|
||||
let transY = randomIntFromInterval(transLimitY * -1, transLimitY);
|
||||
|
||||
// Clamp translation to screen left and right X size
|
||||
transX = Math.max(0 - originX, Math.min((window.innerWidth - originX) - size.width, transX));
|
||||
// Clamp translation to top and bottom Y size
|
||||
transY = Math.max(0 - originY, Math.min((window.innerHeight - originY) - size.height, transY));
|
||||
|
||||
// Set initial position
|
||||
element.style.setProperty("top", `${originY}px`);
|
||||
element.style.setProperty("left", `${originX}px`);
|
||||
|
||||
// Set HUE rotation
|
||||
element.style.setProperty("-webkit-filter", `hue-rotate(${hue}deg)`);
|
||||
element.style.setProperty("filter", `hue-rotate(${hue}deg)`);
|
||||
|
||||
// Translate and rotate to random position from origin
|
||||
element.style.setProperty("transform", `translate(${transX}px, ${transY}px) rotate(${rotate}deg)`);
|
||||
});
|
||||
};
|
||||
|
||||
// Interest implotion effect from explodeInterests()
|
||||
const implodeInterests = () => {
|
||||
const wrapper = document.querySelector("div.interests");
|
||||
wrapper.classList.remove("active");
|
||||
|
||||
// Reset to initial position
|
||||
[...wrapper.querySelectorAll("p")].forEach(element => element.style.setProperty("transform", "translate(0, 0)"));
|
||||
};
|
||||
|
||||
// Bind triggers for interests explosion and implotion
|
||||
{
|
||||
const interestsElement = document.querySelector("section.about span.interests");
|
||||
// Bind mouse or touch events depending on pointer type of device
|
||||
const canHover = window.matchMedia("(pointer: fine)").matches;
|
||||
|
||||
// Explode interests when mouse hovers or touch hold starts
|
||||
interestsElement.addEventListener(canHover ? "mouseenter" : "touchstart", (event) => explodeInterests(event.x, event.y));
|
||||
// Implode interests when mouse leaves or touch hold ends
|
||||
interestsElement.addEventListener(canHover ? "mouseleave" : "touchend", () => implodeInterests());
|
||||
}
|
||||
|
||||
// Language bar chart hover tooltip
|
||||
document.querySelectorAll("stacked-bar-chart chart-segment").forEach(element => {
|
||||
const tooltipElement = element.querySelector("[data-hover]");
|
||||
|
||||
element.addEventListener("mouseenter", () => tooltipElement.classList.add("hovering"));
|
||||
element.addEventListener("mouseleave", () => tooltipElement.classList.remove("hovering"));
|
||||
|
||||
element.addEventListener("mousemove", (event) => {
|
||||
const x = event.layerX - (tooltipElement.clientWidth / 2);
|
||||
const y = event.layerY + (tooltipElement.clientHeight - 30);
|
||||
|
||||
tooltipElement.style.setProperty("transform", `translate(${x}px, ${y}px)`);
|
||||
});
|
||||
});
|
32
assets/js/pages/contact.js → public/assets/js/pages/contact.js
Executable file → Normal file
32
assets/js/pages/contact.js → public/assets/js/pages/contact.js
Executable file → Normal file
|
@ -10,8 +10,6 @@ class ContactForm {
|
|||
[...document.querySelectorAll("form :is(input, textarea)")].forEach(element => {
|
||||
element.addEventListener("keyup", () => this.saveMessage());
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Get saved message as JSON from SessionStorage
|
||||
|
@ -36,6 +34,7 @@ class ContactForm {
|
|||
return ContactForm.removeSavedMessage();
|
||||
}
|
||||
|
||||
// Set value of each input field in DOM by name attribute
|
||||
for (const [name, value] of Object.entries(message)) {
|
||||
this.form.querySelector(`[name="${name}"]`).value = value;
|
||||
}
|
||||
|
@ -61,27 +60,16 @@ class ContactForm {
|
|||
form ? (new ContactForm(form)) : ContactForm.removeSavedMessage();
|
||||
}
|
||||
|
||||
// Social links hover
|
||||
{
|
||||
const socialElementHover = (target) => {
|
||||
const element = target.querySelector("p");
|
||||
document.querySelectorAll("social").forEach(element => {
|
||||
const tooltipElement = element.querySelector("[data-hover]");
|
||||
|
||||
target.classList.add("hovering");
|
||||
target.addEventListener("mousemove", (event) => {
|
||||
const x = event.layerX - (element.clientWidth / 2);
|
||||
const y = event.layerY + element.clientHeight;
|
||||
element.addEventListener("mouseenter", () => tooltipElement.classList.add("hovering"));
|
||||
element.addEventListener("mouseleave", () => tooltipElement.classList.remove("hovering"));
|
||||
|
||||
element.style.setProperty("transform", `translate(${x}px, ${y}px)`);
|
||||
});
|
||||
};
|
||||
element.addEventListener("mousemove", (event) => {
|
||||
const x = event.layerX - (tooltipElement.clientWidth / 2);
|
||||
const y = event.layerY + tooltipElement.clientHeight;
|
||||
|
||||
const elements = [...document.querySelectorAll("social")];
|
||||
|
||||
elements.forEach(element => {
|
||||
element.addEventListener("mouseenter", () => socialElementHover(element));
|
||||
|
||||
element.addEventListener("mouseleave", () => {
|
||||
elements.forEach(element => element.classList.remove("hovering"));
|
||||
});
|
||||
tooltipElement.style.setProperty("transform", `translate(${x}px, ${y}px)`);
|
||||
});
|
||||
}
|
||||
});
|
0
assets/js/pages/error.js → public/assets/js/pages/error.js
Executable file → Normal file
0
assets/js/pages/error.js → public/assets/js/pages/error.js
Executable file → Normal file
106
public/assets/js/pages/index.js
Normal file
106
public/assets/js/pages/index.js
Normal file
|
@ -0,0 +1,106 @@
|
|||
// Click to copy email button
|
||||
{
|
||||
const EMAIL_CPY_ANIM_DUR_MSECONDS = 1000;
|
||||
|
||||
// Run email copied splash animation
|
||||
const emailCopiedAnimation = () => {
|
||||
const CONFETTI_COUNT = 40;
|
||||
const CONFETTI_SCALE_PIXELS = 300;
|
||||
|
||||
const randomIntFromInterval = (min, max) => {
|
||||
return Math.floor(Math.random() * (max - min + 1) + min)
|
||||
}
|
||||
|
||||
// Create new splash element
|
||||
const splashElement = document.createElement("splash");
|
||||
splashElement.innerText = "copied!";
|
||||
|
||||
// Set inline display to none to hide this element on pages where the splash element has no override styles defined.
|
||||
splashElement.style.display = "none";
|
||||
|
||||
// Array of box-shadow strings as "confetti"
|
||||
const confetti = [];
|
||||
|
||||
// Generate random confetti
|
||||
for (let i = 0; i < CONFETTI_COUNT; i++) {
|
||||
// Random confetti position
|
||||
const x = randomIntFromInterval(CONFETTI_SCALE_PIXELS * -1, CONFETTI_SCALE_PIXELS);
|
||||
const y = randomIntFromInterval(CONFETTI_SCALE_PIXELS * -1, CONFETTI_SCALE_PIXELS);
|
||||
|
||||
// Random confetti RGB color
|
||||
const rgb = [
|
||||
randomIntFromInterval(0, 255),
|
||||
randomIntFromInterval(0, 255),
|
||||
randomIntFromInterval(0, 255)
|
||||
];
|
||||
|
||||
// Interpolate random values and append to outer confetti array
|
||||
confetti.push(`${x}px ${y}px 0 rgb(${rgb.join(",")})`);
|
||||
}
|
||||
|
||||
// Set CSS variable on splash element that in turn will be used by pseudo-element
|
||||
splashElement.style.setProperty("--confetti", confetti.join(","));
|
||||
|
||||
// Start animation by appending the created element to the document body
|
||||
document.body.appendChild(splashElement);
|
||||
|
||||
// Run hide animation
|
||||
setTimeout(() => {
|
||||
splashElement.classList.add("hide");
|
||||
|
||||
// Selfdestruct element when hide animation finishes
|
||||
setTimeout(() => splashElement.remove(), 400);
|
||||
}, EMAIL_CPY_ANIM_DUR_MSECONDS + 100);
|
||||
}
|
||||
|
||||
document.querySelector(".email").addEventListener("click", async () => {
|
||||
try {
|
||||
await navigator.clipboard.writeText("victor@vlw.se");
|
||||
|
||||
// Run "email copied" animation!
|
||||
emailCopiedAnimation();
|
||||
|
||||
// NOTE: I don't know, spamming the button is kinda fun
|
||||
// Prevent interactions with the copy email elements while the animation is running
|
||||
/*[...document.querySelectorAll("[vv-call='copyEmail']")].forEach(element => {
|
||||
//element.classList.add("lock");
|
||||
|
||||
setTimeout(() => element.classList.remove("lock"), EMAIL_CPY_ANIM_DUR_MSECONDS);
|
||||
});*/
|
||||
} catch (error) {
|
||||
console.error(error.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Change site accent color on hover of menu items
|
||||
{
|
||||
if (window.matchMedia("(hover: hover)")) {
|
||||
// Update root CSS variables
|
||||
const updateColor = (rgb = null, hue = 0) => {
|
||||
if (!rgb) {
|
||||
document.documentElement.style.removeProperty("--hue-accent");
|
||||
document.documentElement.style.removeProperty("--primer-color-accent");
|
||||
document.documentElement.style.removeProperty("--color-accent");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
document.documentElement.style.setProperty("--hue-accent", `${hue}deg`);
|
||||
|
||||
document.documentElement.style.setProperty("--primer-color-accent", `${rgb}`);
|
||||
// Compiled color variable must to be updated to receive the new RGB values
|
||||
document.documentElement.style.setProperty("--color-accent", "rgb(var(--primer-color-accent)");
|
||||
};
|
||||
|
||||
[...document.querySelectorAll("menu li")].forEach(element => {
|
||||
// Change site accent color to RGB and HUE rotation defined in element dataset
|
||||
element.addEventListener("mouseenter", (event) => updateColor(event.target.dataset.rgb, event.target.dataset.hue));
|
||||
// Reset initial accent color and hues
|
||||
element.addEventListener("mouseleave", () => updateColor());
|
||||
});
|
||||
|
||||
// Reset color on navigation
|
||||
VV.shell.addEventListener(VV.EVENT.START, () => updateColor(), { once: true });
|
||||
}
|
||||
}
|
0
public/assets/js/pages/search.js
Normal file
0
public/assets/js/pages/search.js
Normal file
4
public/assets/js/pages/work/archive.js
Normal file
4
public/assets/js/pages/work/archive.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
// Redirect to work page if no href is defined
|
||||
if (!new URLSearchParams(window.location.search).has("href")) {
|
||||
new VV().navigate("/work");
|
||||
}
|
0
public/assets/js/pages/work/timeline.js
Normal file
0
public/assets/js/pages/work/timeline.js
Normal file
45
public/assets/js/shell.js
Normal file
45
public/assets/js/shell.js
Normal file
|
@ -0,0 +1,45 @@
|
|||
const DEBOUNCE_TIMEOUT_MS = 100;
|
||||
const CLASSNAME_SEARCHBOX_ACTIVE = "searchboxActive";
|
||||
|
||||
// Navigate to the start page if the logo in the header is clicked
|
||||
document.querySelector("header .logo").addEventListener("click", () => new VV().navigate("/"));
|
||||
|
||||
// Navigate to the start page if the logo in the header is clicked
|
||||
document.querySelector("header .logo").addEventListener("click", () => new VV().navigate("/"));
|
||||
|
||||
// Scroll page to top on navigation
|
||||
VV.shell.addEventListener(VV.EVENT.FINISH, () => window.scrollTo({ top: 0 }));
|
||||
|
||||
// Open search box
|
||||
document.querySelector(".searchbox-open").addEventListener("click", () => {
|
||||
document.querySelector("header").classList.add(CLASSNAME_SEARCHBOX_ACTIVE);
|
||||
// Select searchbox inner input element
|
||||
document.querySelector("searchbox input").focus();
|
||||
});
|
||||
|
||||
// Close searchbox
|
||||
document.querySelector(".searchbox-close").addEventListener("click", () => {
|
||||
// Disable search button interaction while animation is running
|
||||
// This is required to prevent conflicts with the :hover "peak" transformation
|
||||
const searchButtonElement = document.querySelector("header button.search");
|
||||
const transformDuration = parseInt(window.getComputedStyle(searchButtonElement).getPropertyValue("--transform-duration"));
|
||||
searchButtonElement.style.setProperty("pointer-events", "none");
|
||||
|
||||
document.querySelector("header").classList.remove(CLASSNAME_SEARCHBOX_ACTIVE);
|
||||
|
||||
// Wait for the transform animation to finish
|
||||
setTimeout(() => searchButtonElement.style.removeProperty("pointer-events"), transformDuration);
|
||||
});
|
||||
|
||||
// Close searchbox on top shell navigations
|
||||
VV.shell.addEventListener(VV.EVENT.START, () => document.querySelector("header").classList.remove(CLASSNAME_SEARCHBOX_ACTIVE));
|
||||
|
||||
// Handle search logic
|
||||
document.querySelector("header input[type='search']").addEventListener("input", (event) => {
|
||||
// Debounce user input
|
||||
clearTimeout(event.target._throttle);
|
||||
event.target._throttle = setTimeout(() => {
|
||||
// Navigate search-results element on user input
|
||||
new VV(document.querySelector("search-results")).navigate(`/search?q=${event.target.value}`);
|
||||
}, DEBOUNCE_TIMEOUT_MS);
|
||||
});
|
0
assets/media/gazing.jpg → public/assets/media/gazing.jpg
Executable file → Normal file
0
assets/media/gazing.jpg → public/assets/media/gazing.jpg
Executable file → Normal file
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 62 KiB |
0
assets/media/glitch_b64/1.txt → public/assets/media/glitch_b64/1.txt
Executable file → Normal file
0
assets/media/glitch_b64/1.txt → public/assets/media/glitch_b64/1.txt
Executable file → Normal file
0
assets/media/glitch_b64/2.txt → public/assets/media/glitch_b64/2.txt
Executable file → Normal file
0
assets/media/glitch_b64/2.txt → public/assets/media/glitch_b64/2.txt
Executable file → Normal file
0
assets/media/glitch_b64/3.txt → public/assets/media/glitch_b64/3.txt
Executable file → Normal file
0
assets/media/glitch_b64/3.txt → public/assets/media/glitch_b64/3.txt
Executable file → Normal file
0
assets/media/glitch_b64/4.txt → public/assets/media/glitch_b64/4.txt
Executable file → Normal file
0
assets/media/glitch_b64/4.txt → public/assets/media/glitch_b64/4.txt
Executable file → Normal file
1
public/assets/media/icons/chevron.svg
Normal file
1
public/assets/media/icons/chevron.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg class="chevron" viewBox="0 0 78.743 46.968" xmlns="http://www.w3.org/2000/svg"><path d="m530.436 290.342 6.658 8.935c4.438 5.956 8.512 11.037 12.222 15.242 3.71 4.205 7.691 8.797 11.945 13.776a590.023 590.023 0 0 1 11.95 14.425c3.713 4.638 9.56 11.441 17.54 20.41 7.98 8.97 15.892 17.872 23.736 26.707a2267.256 2267.256 0 0 0 21.633 24.05c6.578 7.197 11.225 8.056 13.942 2.576 2.717-5.48 8.45-12.8 17.199-21.96 8.748-9.162 15.904-16.447 21.468-21.856a2287.547 2287.547 0 0 1 17.272-16.611 674.569 674.569 0 0 0 16.506-16.229c5.054-5.154 9.753-9.968 14.098-14.443 4.344-4.475 9.494-10.016 15.448-16.624 5.954-6.607 10.747-11.748 14.38-15.422 3.631-3.675 6.18-6.009 7.645-7.003a16.094 16.094 0 0 1 4.757-2.202 16.095 16.095 0 0 1 5.212-.568c1.768.096 3.474.47 5.12 1.126a16.094 16.094 0 0 1 4.492 2.701 16.094 16.094 0 0 1 3.394 3.995 16.094 16.094 0 0 1 1.941 4.87c.381 1.729.476 3.473.285 5.234a16.094 16.094 0 0 1-1.402 5.051 16.095 16.095 0 0 1-2.94 4.34c-15.004 15.842-39.417-8.906-22.252-23.487a16.094 16.094 0 0 1 4.491-2.703 16.094 16.094 0 0 1 5.12-1.127 16.095 16.095 0 0 1 5.211.567 16.095 16.095 0 0 1 4.758 2.2 16.094 16.094 0 0 1 3.805 3.606 16.094 16.094 0 0 1 2.456 4.631c.565 1.678.848 3.403.848 5.173 0 1.771-.283 3.495-.849 5.173a16.095 16.095 0 0 1-2.455 4.632l-1.606 2.112-5.37 4.582c-3.583 3.055-8.51 7.767-14.786 14.135a11933.445 11933.445 0 0 0-15.839 16.1c-4.284 4.364-8.943 9.26-13.975 14.688a75638.076 75638.076 0 0 1-15.826 17.063 2642.057 2642.057 0 0 0-15.89 17.273c-5.073 5.567-11.507 12.866-19.3 21.897-7.794 9.03-13.63 15.948-17.51 20.753a496.057 496.057 0 0 1-12.49 14.836c-4.447 5.085-9.976 7.77-16.588 8.052-6.612.283-12.583-2.325-17.913-7.822-5.33-5.498-11.117-11.861-17.361-19.091-6.245-7.23-11.274-13.11-15.087-17.64a385.872 385.872 0 0 0-11.496-13.06 905.91 905.91 0 0 1-12.117-13.426c-4.228-4.774-10.087-11.613-17.577-20.518-7.49-8.905-13.37-15.797-17.635-20.676-4.266-4.88-8.437-9.663-12.511-14.35-4.075-4.687-8.453-9.915-13.135-15.684-4.681-5.77-7.355-9.208-8.02-10.317a15.914 15.914 0 0 1-1.567-3.517 15.937 15.937 0 0 1 .724-11.305 15.914 15.914 0 0 1 2.003-3.288 15.914 15.914 0 0 1 2.733-2.713 15.913 15.913 0 0 1 3.302-1.98 15.914 15.914 0 0 1 3.68-1.132 15.914 15.914 0 0 1 3.845-.219c1.29.083 2.552.319 3.785.708 1.233.39 2.401.92 3.505 1.593a15.914 15.914 0 0 1 3.023 2.386l1.366 1.375z" transform="matrix(.26458 0 0 .26458 -132.758 -75.015)"/></svg>
|
After Width: | Height: | Size: 2.3 KiB |
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue