Compare commits

...

3 commits

21 changed files with 388 additions and 298 deletions

View file

@ -39,10 +39,7 @@
->min(1)
->max(parent::MYSQL_TEXT_MAX_LENGTH),
(new Rules(WorkModel::IS_LISTABLE->value))
->type(Type::BOOLEAN),
(new Rules(WorkModel::IS_READABLE->value))
(new Rules(WorkModel::IS_LISTED->value))
->type(Type::BOOLEAN),
(new Rules(WorkModel::DATE_MODIFIED->value))

View file

@ -37,11 +37,7 @@
->type(Type::STRING)
->max(parent::MYSQL_TEXT_MAX_LENGTH),
(new Rules(WorkModel::IS_LISTABLE->value))
->type(Type::BOOLEAN)
->default(true),
(new Rules(WorkModel::IS_READABLE->value))
(new Rules(WorkModel::IS_LISTED->value))
->type(Type::BOOLEAN)
->default(true),
@ -57,9 +53,10 @@
(new Rules(PARAM_LIMIT))
->type(Type::NUMBER)
->type(Type::NULL)
->min(1)
->max(parent::MYSQL_INT_MAX_LENGTH)
->default(parent::MYSQL_INT_MAX_LENGTH)
->default(null)
]);
parent::__construct(Databases::VLW, $this->ruleset);
@ -93,10 +90,10 @@
->limit($_GET[PARAM_LIMIT])
->select([
WorkModel::ID->value,
WorkModel::REF_NAMESPACE_ID->value,
WorkModel::TITLE->value,
WorkModel::SUMMARY->value,
WorkModel::IS_LISTABLE->value,
WorkModel::IS_READABLE->value,
WorkModel::IS_LISTED->value,
WorkModel::DATE_YEAR->value,
WorkModel::DATE_MONTH->value,
WorkModel::DATE_DAY->value,

View file

@ -47,10 +47,7 @@
->min(1)
->max(parent::MYSQL_TEXT_MAX_LENGTH),
(new Rules(WorkModel::IS_LISTABLE->value))
->type(Type::BOOLEAN),
(new Rules(WorkModel::IS_READABLE->value))
(new Rules(WorkModel::IS_LISTED->value))
->type(Type::BOOLEAN),
(new Rules(WorkModel::DATE_MODIFIED->value))

View file

@ -41,11 +41,7 @@
->max(parent::MYSQL_TEXT_MAX_LENGTH)
->default(null),
(new Rules(WorkModel::IS_LISTABLE->value))
->type(Type::BOOLEAN)
->default(false),
(new Rules(WorkModel::IS_READABLE->value))
(new Rules(WorkModel::IS_LISTED->value))
->type(Type::BOOLEAN)
->default(false),

View file

@ -38,12 +38,11 @@
WorkActionsModel::REF_WORK_ID->value,
WorkActionsModel::DISPLAY_TEXT->value,
WorkActionsModel::HREF->value,
WorkActionsModel::CLASS_LIST->value,
WorkActionsModel::EXTERNAL->value
WorkActionsModel::CLASS_LIST->value
]);
return $response->num_rows > 0
? new Response($response->fetch_all(MYSQLI_ASSOC))
? new Response(parent::index_array_by_key($response->fetch_all(MYSQLI_ASSOC), WorkActionsModel::REF_WORK_ID->value))
: new Response([], 404);
}
}

View file

@ -50,11 +50,7 @@
(new Rules(WorkActionsModel::CLASS_LIST->value))
->type(Type::ARRAY)
->min(1)
->default([]),
(new Rules(WorkActionsModel::EXTERNAL->value))
->type(Type::BOOLEAN)
->default(false)
->default([])
]);
parent::__construct(Databases::VLW, $this->ruleset);

View file

@ -45,7 +45,7 @@
]);
return $response->num_rows > 0
? new Response($response->fetch_all(MYSQLI_ASSOC))
? new Response(parent::index_array_by_key($response->fetch_all(MYSQLI_ASSOC), WorkTagsModel::REF_WORK_ID->value))
: new Response([], 404);
}
}

View file

@ -37,6 +37,11 @@
);
}
// Bail out if provided ReflectRules\Ruleset is invalid
private static function eval_ruleset_or_exit(Ruleset $ruleset): ?Response {
return !$ruleset->is_valid() ? new Response($ruleset->get_errors(), 422) : null;
}
// Generate and return UUID4 string
public static function gen_uuid4(): string {
return sprintf("%04x%04x-%04x-%04x-%04x-%04x%04x%04x",
@ -76,8 +81,21 @@
return $filters;
}
// Bail out if provided ReflectRules\Ruleset is invalid
private static function eval_ruleset_or_exit(Ruleset $ruleset): ?Response {
return !$ruleset->is_valid() ? new Response($ruleset->get_errors(), 422) : null;
public function index_array_by_key(array $input, string $key): array {
$output = [];
foreach ($input as $item) {
$idx = $item[$key];
// Create entry for key in output array if first item
if (!array_key_exists($idx, $output)) {
$output[$idx] = [];
}
// Append item to array of array by key
$output[$idx][] = $item;
}
return $output;
}
}

View file

@ -10,11 +10,11 @@
const TABLE = "work";
case ID = "id";
case REF_NAMESPACE_ID = "ref_namespace_id";
case TITLE = "title";
case SUMMARY = "summary";
case COVER_SRCSET = "cover_srcset";
case IS_LISTABLE = "is_listable";
case IS_READABLE = "is_readable";
case IS_LISTED = "is_listed";
case DATE_YEAR = "date_year";
case DATE_MONTH = "date_month";
case DATE_DAY = "date_day";

View file

@ -6,8 +6,10 @@
const TABLE = "work_actions";
case REF_WORK_ID = "ref_work_id";
case ICON_PREFIX = "icon_prefix";
case ICON_SUFFIX = "icon_suffix";
case ORDER_IDX = "order_idx";
case DISPLAY_TEXT = "display_text";
case HREF = "href";
case CLASS_LIST = "class_list";
case EXTERNAL = "external";
}

View file

@ -0,0 +1,15 @@
<?php
namespace VLW\API\Databases\VLWdb\Models\Work;
enum WorkNamespacesModel: string {
const TABLE = "work_actions";
case REF_WORK_ID = "ref_work_id";
case ICON_PREFIX = "icon_prefix";
case ICON_SUFFIX = "icon_suffix";
case ORDER_IDX = "order_idx";
case DISPLAY_TEXT = "display_text";
case HREF = "href";
case CLASS_LIST = "class_list";
}

View file

@ -10,6 +10,7 @@
case VLW;
case RELEASE;
case WEBSITE;
case REPO;
}
enum WorkTagsModel: string {

View file

@ -19,28 +19,6 @@ vv-shell {
/* # Sections */
/* ## Git */
section.git {
display: flex;
flex-direction: column;
gap: var(--padding);
background-color: rgba(var(--primer-color-accent), .1);
padding: calc(var(--padding) * 1.5);
border-radius: 6px;
}
section.git svg {
fill: white;
width: 60px;
}
section.git .buttons {
display: flex;
flex-direction: column;
gap: var(--padding);
}
/* ## Hero */
section.hero {
@ -48,17 +26,17 @@ section.hero {
display: grid;
gap: var(--padding);
grid-template-columns: repeat(2, 1fr);
grid-template-columns: repeat(1, 1fr);
}
section.hero .item {
width: 100%;
height: 300px;
position: relative;
border-radius: 6px;
}
section.hero .wrapper {
gap: var(--padding);
z-index: 1;
height: 100%;
display: flex;
@ -68,11 +46,19 @@ section.hero .wrapper {
padding: calc(var(--padding) * 1.5);
}
section.hero p {
width: 50%;
section.hero .item .title {
display: grid;
align-items: center;
gap: var(--padding);
grid-template-columns: 40px 1fr;
}
section.hero button {
section.hero .item .title svg {
height: 3em;
border-radius: 4px;
}
section.hero .actions {
margin-top: auto;
}
@ -85,10 +71,6 @@ section.hero .item.vegvisir {
background-color: rgba(var(--color-vegvisir), .1);
}
section.hero .item.vegvisir .bg {
opacity: .2;
}
/* ### Reflect */
section.hero .item.reflect {
@ -98,25 +80,6 @@ section.hero .item.reflect {
background-color: rgba(var(--color-reflect), .2);
}
/* ### Background */
section.hero .item .bg {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
overflow: hidden;
pointer-events: none;
border-radius: 6px;
}
section.hero .item video {
position: absolute;
width: 100%;
bottom: 0;
}
/* ## Heading */
section.heading {
@ -136,7 +99,7 @@ section.heading svg {
section.featured {
display: grid;
gap: var(--padding);
grid-template-columns: repeat(3, 1fr);
grid-template-columns: repeat(1, 1fr);
}
section.featured featured-item {
@ -144,32 +107,27 @@ section.featured featured-item {
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 > svg {
width: 2em;
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);
}
/* ### Languages */
section.featured featured-item .langs {
gap: 5px;
display: flex;
margin: 5px 0;
}
section.featured featured-item .langs button {
border-radius: 4px;
background-color: rgba(255, 255, 255, .1);
}
section.featured featured-item .langs button p::before {
content: "● ";
}
/* ### Actions */
section.featured featured-item .actions {
@ -181,25 +139,14 @@ section.featured featured-item .actions {
/* # Size queries */
@media (min-width: 460px) {
section.git .buttons {
flex-direction: row;
@media (min-width: 600px) {
section.hero {
grid-template-columns: repeat(2, 1fr);
}
}
@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;
section.featured {
grid-template-columns: repeat(3, 1fr);
}
}

View file

@ -16,6 +16,28 @@ vv-shell {
/* # Sections */
/* ## Git */
section.git {
display: flex;
flex-direction: column;
gap: var(--padding);
background-color: rgba(var(--primer-color-accent), .1);
padding: calc(var(--padding) * 1.5);
border-radius: 6px;
}
section.git svg {
fill: white;
width: 60px;
}
section.git .buttons {
display: flex;
flex-direction: column;
gap: var(--padding);
}
/* ## Timeline */
section.timeline {
@ -101,10 +123,12 @@ section.timeline .items .item .actions {
margin-top: 7px;
}
/* ## Note */
/* # Size queries */
section.note {
text-align: center;
@media (min-width: 460px) {
section.git .buttons {
flex-direction: row;
}
}
@media (max-width: 500px) {
@ -145,3 +169,20 @@ section.note {
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;
}
}

View file

@ -0,0 +1 @@
<svg viewBox="0 0 60.965 60.965" xmlns="http://www.w3.org/2000/svg"><path style="fill:#dc1a00;fill-opacity:1;stroke-width:.529167" d="M0 0h135.467v135.467H0z" transform="matrix(.45004 0 0 .45004 0 0)"/><g style="fill:#fff;fill-opacity:1"><g fill="none" style="fill:#fff;fill-opacity:1"><path class="solid" d="M12 22 0 0h24z" style="display:inline;fill:#fff;fill-opacity:1" transform="matrix(.95357 0 0 .95357 19.04 10.01)"/><path class="stroke" d="M12 17.823 20.63 2H3.37L12 17.823M12 22 0 0h24z" style="display:inline;fill:#fff;fill-opacity:1" transform="matrix(.95357 0 0 .95357 19.04 10.01)"/></g><g opacity=".5" style="fill:#fff;fill-opacity:1"><path class="solid" d="M24 22 12 0h24z" style="display:inline;fill:#fff;fill-opacity:1" transform="matrix(-.95357 0 0 -.95357 53.368 51.968)"/><path class="stroke" d="M24 17.823 32.63 2H15.37L24 17.823M24 22 12 0h24z" style="display:inline;fill:#fff;fill-opacity:1" transform="matrix(-.95357 0 0 -.95357 53.368 51.968)"/></g></g></svg>

After

Width:  |  Height:  |  Size: 984 B

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 8 KiB

View file

@ -0,0 +1 @@
<svg viewBox="0 0 60.965 60.965" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"><path style="fill:#0080ff;fill-opacity:1;stroke-width:.529167" d="M0 0h135.467v135.467H0z" transform="matrix(.45004 0 0 .45004 0 0)"/><g style="fill:#87ffff;fill-opacity:1"><g fill="none" style="fill:#87ffff;fill-opacity:1"><path class="solid" d="M12 22 0 0h24z" style="display:inline;fill:#87ffff;fill-opacity:1" transform="matrix(-.95357 0 0 -.95357 41.925 30.482)"/><path class="stroke" d="M12 17.823 20.63 2H3.37L12 17.823M12 22 0 0h24z" style="display:inline;fill:#87ffff;fill-opacity:1" transform="matrix(-.95357 0 0 -.95357 41.925 30.482)"/></g><g fill="none" style="fill:#87ffff;fill-opacity:1"><path class="solid" d="M12 22 0 0h24z" style="display:inline;fill:#87ffff;fill-opacity:1" transform="matrix(.95357 0 0 .95357 19.04 30.482)"/><path class="stroke" d="M12 17.823 20.63 2H3.37L12 17.823M12 22 0 0h24z" style="display:inline;fill:#87ffff;fill-opacity:1" transform="matrix(.95357 0 0 .95357 19.04 30.482)"/></g><g opacity=".5" style="fill:#87ffff;fill-opacity:1"><path class="solid" d="M24 22 12 0h24z" style="display:inline;fill:#87ffff;fill-opacity:1" transform="matrix(0 .95357 -.95357 0 29.529 7.597)"/><path class="stroke" d="M24 17.823 32.63 2H15.37L24 17.823M24 22 12 0h24z" style="display:inline;fill:#87ffff;fill-opacity:1" transform="matrix(0 .95357 -.95357 0 29.529 7.597)"/></g><g opacity=".5" style="fill:#87ffff;fill-opacity:1"><path class="solid" d="M24 22 12 0h24z" style="display:inline;fill:#87ffff;fill-opacity:1" transform="matrix(0 -.95357 .95357 0 30.482 53.368)"/><path class="stroke" d="M24 17.823 32.63 2H15.37L24 17.823M24 22 12 0h24z" style="display:inline;fill:#87ffff;fill-opacity:1" transform="matrix(0 -.95357 .95357 0 30.482 53.368)"/></g></g></svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 5.2 KiB

View file

@ -66,11 +66,7 @@
<?php foreach ($actions->json() as $action): ?>
<?php // Bind VV Interactions if link is same origin, else open in new tab ?>
<?php if (!$action[WorkActionsModel::EXTERNAL->value]): ?>
<a href="<?= $action[WorkActionsModel::HREF->value] ?>"><button class="inline <?= $action[WorkActionsModel::CLASS_LIST->value] ?>"><?= $action[WorkActionsModel::DISPLAY_TEXT->value] ?></button></a>
<?php else: ?>
<a href="<?= $action[WorkActionsModel::HREF->value] ?>" target="_blank"><button class="inline <?= $action[WorkActionsModel::CLASS_LIST->value] ?>"><?= $action[WorkActionsModel::DISPLAY_TEXT->value] ?></button></a>
<?php endif; ?>
<?php endforeach; ?>
</div>

View file

@ -1,59 +1,132 @@
<?php
use Reflect\Response;
use VLW\Client\API;
use VLW\API\Endpoints;
use VLW\API\Databases\VLWdb\Models\Work\WorkModel;
require_once VV::root("src/client/API.php");
require_once VV::root("api/src/Endpoints.php");
require_once VV::root("api/src/databases/models/Work/Work.php");
// Number of items from the timeline to display on this page
const TIMELINE_PREVIEW_LIMIT = 10;
const TIMELINE_PREVIEW_LIMIT = 5;
$work = new class extends API {
const ERROR_MSG = "Something went wrong";
private readonly Response $resp;
public function __construct() {
parent::__construct();
// Get work items from endpoint
$this->resp = $this->call(Endpoints::WORK->value)->params([
WorkModel::IS_LISTED->value => true
])->get();
}
private function get_item(string $key): array {
$idx = array_search($key, array_column($this->resp->json(), WorkModel::ID->value));
return $this->resp->json()[$idx];
}
public function get_summary(string $key): string {
return $this->resp->ok ? $this->get_item($key)[WorkModel::SUMMARY->value] : self::ERROR_MSG;
}
}
?>
<style><?= VV::css("public/assets/css/pages/work") ?></style>
<section class="git">
<?= VV::embed("public/assets/media/icons/codeberg.svg") ?>
<p>I have moved most of my free open-source software <a href="https://giveupgithub.com">away from GitHub</a> to <a href="https://codeberg.org/vlw">Codeberg</a>. I also have a mirror of everything and sources for some smaller projects on <a href="https://git.vlw.se">Forgejo</a>.</p>
<div class="buttons">
<a href="https://codeberg.org/vlw"><button class="inline solid">Codeberg</button></a>
<a href="https://git.vlw.se"><button class="inline">Forgejo</button></a>
</div>
</section>
<section class="heading">
<?= VV::embed("public/assets/media/icons/star.svg") ?>
<h1>featured projects</h1>
<?= VV::embed("public/assets/media/icons/star.svg") ?>
</section>
<section class="hero">
<div class="item vegvisir">
<div class="wrapper">
<h1>Vegvisir</h1>
<p>A PHP and JavaScript navigation framework for the seamless [open] web seas.</p>
<a href=""><button class="inline">Read more</button></a>
<div class="title">
<?= VV::embed("public/assets/media/icons/vegvisir.svg") ?>
<h1>vegvisir</h1>
</div>
<p><?= $work->get_summary("vlw/vegvisir") ?></p>
<div class="actions">
<a href="https://vegvisir.vlw.se"><button class="inline">Read more</button></a>
</div>
<div class="bg">
<video muted autoplay loop src="/assets/media/vegvisir.webm"></video>
</div>
</div>
<div class="item reflect">
<div class="wrapper">
<h1>Reflect</h1>
<p>A strange framework for building REST APIs in PHP.</p>
<a href=""><button class="inline">Read more</button></a>
<div class="title">
<?= VV::embed("public/assets/media/icons/reflect.svg") ?>
<h1>reflect</h1>
</div>
<p><?= $work->get_summary("vlw/reflect") ?></p>
<div class="actions">
<a href="https://reflect.vlw.se"><button class="inline">Read more</button></a>
</div>
</div>
<div class="bg"></div>
</div>
</section>
<section class="featured">
<featured-item>
<?= VV::embed("public/assets/media/icons/repo.svg") ?>
<h3>lorem</h3>
<p>ipsuum</p>
<div class="langs">
<a href=""><button><p>PHP</p></button></a>
<div class="title">
<?= VV::embed("public/assets/media/icons/vw.svg") ?>
</div>
<h3>vlw.se</h3>
<p>Can I put my own website here, is that cheating? Maybe, but I think this site counts as the most important thing I've personally created. I've only used my own libraries and frameworks to create this website, so it kind of works as a live demonstration of many of my web projects bundled together.</p>
<div class="actions">
<a href="/work/vlw/vlw.se"><button class="inline">read more</button></a>
</div>
</featured-item>
<featured-item>
<div class="title">
<?= VV::embed("public/assets/media/icons/vw.svg") ?>
</div>
<h3>My dabbles</h3>
<p>I play around with a lot of technologies and sometimes create smaller programs that might not merit to a lot on their own. This page is all those things collected together, hopefully that will attest to something.</p>
<div class="actions">
<a href="/work/playground"><button class="inline">playground</button></a>
</div>
</featured-item>
<featured-item>
<div class="title">
<?= VV::embed("public/assets/media/icons/repo.svg") ?>
<div>
<button class="lang">PHP</button>
</div>
</div>
<h3>vlw/php-mysql</h3>
<p><?= $work->get_summary("vlw/php-mysql") ?></p>
<div class="actions">
<a href="PHP"><button class="inline">read more</button></a>
</div>
</featured-item>
<featured-item>
<div class="title">
<?= VV::embed("public/assets/media/icons/star.svg") ?>
<h3>lorem</h3>
<p>ipsuum</p>
</div>
<h3>Website for iCellate Medical</h3>
<p><?= $work->get_summary("icellate/website") ?></p>
<div class="actions">
<a href=""><button class="inline">read more</button></a>
</div>
</featured-item>
<featured-item>
<div class="title">
<?= VV::embed("public/assets/media/icons/star.svg") ?>
</div>
<h3>Modernizing GeneMate by iCellate</h3>
<p><?= $work->get_summary("icellate/genemate") ?></p>
<div class="actions">
<a href=""><button class="inline">read more</button></a>
</div>
</featured-item>
<featured-item>
<div class="title">
<?= VV::embed("public/assets/media/icons/star.svg") ?>
</div>
<h3>Custom pages for Deltaco AB</h3>
<p><?= $work->get_summary("deltaco/asyncapp") ?></p>
<div class="actions">
<a href=""><button class="inline">read more</button></a>
</div>

View file

@ -19,57 +19,95 @@
require_once VV::root("api/src/databases/models/Work/WorkTags.php");
require_once VV::root("api/src/databases/models/Work/WorkActions.php");
// Connect to VLW API
$api = new API();
$work = new class extends API {
private const API_PARAM_LIMIT = "limit";
// Retreive rows from work endpoints
$resp_work = $api->call(Endpoints::WORK->value)->params($_GET)->get();
private readonly Response $resp;
private readonly Response $tags;
private readonly Response $actions;
// Resolve tags and actions if we got work results
if ($resp_work->ok) {
$work_tags = $api->call(Endpoints::WORK_TAGS->value)->get()->json();
$work_actions = $api->call(Endpoints::WORK_ACTIONS->value)->get()->json();
public function __construct() {
parent::__construct();
$this->resp = $this->call(Endpoints::WORK->value)->params([
WorkModel::IS_LISTED->value => true,
self::API_PARAM_LIMIT => $_GET[self::API_PARAM_LIMIT] ?? null
])->get();
// Fetch metadata for work items if we got an ok from work endpoint
if ($this->resp->ok) {
$this->tags = $this->call(Endpoints::WORK_TAGS->value)->get();
$this->actions = $this->call(Endpoints::WORK_ACTIONS->value)->get();
}
}
?>
<style><?= VV::css("public/assets/css/pages/work/timeline") ?></style>
<?php if ($resp_work->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>]]]]]
*/
public function get_timeline(): array {
if (!$this->resp->ok) {
return [];
}
$timeline = [];
$rows = [];
// Create array of arrays ordered by decending year, month, day, items
foreach ($resp_work->json() as $row) {
foreach ($this->resp->json() as $row) {
// Create array for current year if it doesn't exist
if (!array_key_exists($row[WorkModel::DATE_YEAR->value], $rows)) {
$rows[$row[WorkModel::DATE_YEAR->value]] = [];
if (!array_key_exists($row[WorkModel::DATE_YEAR->value], $timeline)) {
$timeline[$row[WorkModel::DATE_YEAR->value]] = [];
}
// Create array for current month if it doesn't exist
if (!array_key_exists($row[WorkModel::DATE_MONTH->value], $rows[$row[WorkModel::DATE_YEAR->value]])) {
$rows[$row[WorkModel::DATE_YEAR->value]][$row[WorkModel::DATE_MONTH->value]] = [];
if (!array_key_exists($row[WorkModel::DATE_MONTH->value], $timeline[$row[WorkModel::DATE_YEAR->value]])) {
$timeline[$row[WorkModel::DATE_YEAR->value]][$row[WorkModel::DATE_MONTH->value]] = [];
}
// Create array for current day if it doesn't exist
if (!array_key_exists($row[WorkModel::DATE_DAY->value], $rows[$row[WorkModel::DATE_YEAR->value]][$row[WorkModel::DATE_MONTH->value]])) {
$rows[$row[WorkModel::DATE_YEAR->value]][$row[WorkModel::DATE_MONTH->value]][$row[WorkModel::DATE_DAY->value]] = [];
if (!array_key_exists($row[WorkModel::DATE_DAY->value], $timeline[$row[WorkModel::DATE_YEAR->value]][$row[WorkModel::DATE_MONTH->value]])) {
$timeline[$row[WorkModel::DATE_YEAR->value]][$row[WorkModel::DATE_MONTH->value]][$row[WorkModel::DATE_DAY->value]] = [];
}
// Append item to ordered array
$rows[$row[WorkModel::DATE_YEAR->value]][$row[WorkModel::DATE_MONTH->value]][$row[WorkModel::DATE_DAY->value]][] = $row;
$timeline[$row[WorkModel::DATE_YEAR->value]][$row[WorkModel::DATE_MONTH->value]][$row[WorkModel::DATE_DAY->value]][] = $row;
}
return $timeline;
}
public function get_tags(string $key): array {
if (!$this->resp->ok) {
return [];
}
return in_array($key, $this->tags->json()) ? $this->tags->json()[$key] : [];
}
public function get_actions(string $key): array {
if (!$this->resp->ok) {
return [];
}
return array_key_exists($key, $this->actions->json()) ? $this->actions->json()[$key] : [];
}
}
?>
<style><?= VV::css("public/assets/css/pages/work/timeline") ?></style>
<section class="git">
<?= VV::embed("public/assets/media/icons/codeberg.svg") ?>
<p>This timeline contains most but not all of my FOSS software. If you want to see a list of all things I've created for the free software world, check out my repos on Codeberg or Forgejo.</p>
<div class="buttons">
<a href="https://codeberg.org/vlw"><button class="inline solid">Codeberg</button></a>
<a href="https://git.vlw.se"><button class="inline">Forgejo</button></a>
</div>
</section>
<section class="timeline">
<?php // Get year int from key and array of months for current year ?>
<?php foreach($rows as $year => $months): ?>
<?php foreach ($work->get_timeline() as $year => $months): ?>
<div class="year">
<div class="track">
<p><?= $year ?></p>
@ -97,16 +135,10 @@
<?php foreach ($items as $item): ?>
<div class="item">
<?php // Get array index ids from tags array where work entity id matches ref_work_id ?>
<?php $tag_ids = array_keys(array_column($work_tags, WorkTagsModel::REF_WORK_ID->value), $item[WorkModel::ID->value]); ?>
<?php // List tags if available ?>
<?php if($tag_ids): ?>
<?php if ($work->get_tags($item[WorkModel::ID->value])): ?>
<div class="tags">
<?php foreach($tag_ids as $tag_id): ?>
<?php // Get tag details from tag array by index id ?>
<?php $tag = $work_tags[$tag_id]; ?>
<?php foreach ($work->get_tags($item[WorkModel::ID->value]) as $tag): ?>
<p class="tag <?= $tag[WorkTagsModel::NAME->value] ?>"><?= $tag[WorkTagsModel::NAME->value] ?></p>
<?php endforeach; ?>
</div>
@ -119,54 +151,34 @@
<p><?= $item[WorkModel::SUMMARY->value] ?></p>
<?php // Get array index ids from actions array where work entity id matches ref_work_id ?>
<?php $action_ids = array_keys(array_column($work_actions, WorkTagsModel::REF_WORK_ID->value), $item[WorkModel::ID->value]); ?>
<?php // List actions if defined for item ?>
<?php if($action_ids): ?>
<div class="actions">
<?php foreach($action_ids as $action_id): ?>
<?php
// Get tag details from tag array by index id
$action = $work_actions[$action_id];
<?php if ($work->get_actions($item[WorkModel::ID->value])): ?>
$link_attr = !$action[WorkActionsModel::EXTERNAL->value]
// Bind VV Interactions for local links
? "vv='work' vv-call='navigate'"
// Open external links in a new tab
: "target='_blank'";
$link_href = $action[WorkActionsModel::HREF->value] === null
// Navigate to work details page if no href is defined
? "/work/{$item[WorkModel::ID->value]}"
// Href is defined so use it directly
: $action[WorkActionsModel::HREF->value];
?>
<a href="<?= $link_href ?>" <?= $link_attr ?>><button class="inline <?= $action["class_list"] ?>"><?= $action["display_text"] ?></button></a>
<?php // Display each action button ?>
<?php foreach ($work->get_actions($item[WorkModel::ID->value]) as $action): ?>
<a href="<?= $action[WorkActionsModel::HREF->value] ?>"><button class="inline <?= $action[WorkActionsModel::CLASS_LIST->value] ?>"><?= $action[WorkActionsModel::DISPLAY_TEXT->value] ?></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 // Display a link to namespaced page on vlw.se if no action is defined ?>
<?php else: ?>
<p>Something went wrong!</p>
<a href="<?= $item[WorkModel::ID->value] ?>"><button class="inline">read more</button></a>
<?php endif; ?>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
<?php endforeach; ?>
</section>
<script><?= VV::js("assets/js/pages/work/timeline") ?></script>