Move files, complete PHP migration

The application works the same way as the F# version
This commit is contained in:
danieljsummers committed 2024-06-23 16:35:55 -04:00
1 parent 9421bb2035
commit 20ad50928a
37 files changed
+354 -301

No files matched your search

+3 -2
View File
@@ -1,10 +1,11 @@
<?php declare(strict_types=1);
use MyPrayerJournal\{Auth, UI};
use MyPrayerJournal\Auth;
use MyPrayerJournal\UI\Component;
if ($_SERVER['REQUEST_METHOD'] <> 'GET') not_found();
require '../../start.php';
Auth::requireUser(false);
UI::journal();
Component::journal();
+1 -1
View File
@@ -1,6 +1,6 @@
<?php declare(strict_types=1);
use MyPrayerJournal\{Auth, Layout, Request};
use MyPrayerJournal\UI\Layout;
require '../../../start.php';
+2 -2
View File
@@ -1,6 +1,6 @@
<?php declare(strict_types=1);
use MyPrayerJournal\{Layout, UI};
use MyPrayerJournal\UI\{Component, Layout};
require '../../../start.php';
@@ -10,7 +10,7 @@ Layout::bareHead();?>
<p class=text-center><strong>Prior Notes for This Request</strong><?php
if (sizeof($req->notes) > 0) {
foreach ($req->notes as $note) { ?>
<p><small class=text-muted><?php UI::relativeDate($note->asOf); ?></small><br>
<p><small class=text-muted><?=Component::relativeDate($note->asOf)?></small><br>
<?=htmlentities($note->text)?><?php
}
} else { ?>
+1 -1
View File
@@ -1,6 +1,6 @@
<?php declare(strict_types=1);
use MyPrayerJournal\Layout;
use MyPrayerJournal\UI\Layout;
require '../../../start.php';
+1 -1
View File
@@ -1,6 +1,6 @@
<?php declare(strict_types=1);
use MyPrayerJournal\Layout;
use MyPrayerJournal\UI\Layout;
require '../start.php';
if ($_SERVER['REQUEST_METHOD'] <> 'GET') not_found();
+1 -1
View File
@@ -1,6 +1,6 @@
<?php declare(strict_types=1);
use MyPrayerJournal\Layout;
use MyPrayerJournal\UI\Layout;
require '../start.php';
if ($_SERVER['REQUEST_METHOD'] <> 'GET') not_found();
+5 -4
View File
@@ -1,6 +1,7 @@
<?php declare(strict_types=1);
use MyPrayerJournal\{Auth, Layout, UI};
use MyPrayerJournal\Auth;
use MyPrayerJournal\UI\{Component, Layout};
require '../start.php';
if ($_SERVER['REQUEST_METHOD'] <> 'GET') not_found();
@@ -12,9 +13,9 @@ $name = $user['given_name'] ?? 'Your';
Layout::pageHead('Journal'); ?>
<article class="container-fluid mt-3">
<h2 class=pb-3><?=$name?><?=$name == 'Your' ? '' : '&rsquo;s'?> Prayer Journal</h2>
<p class="pb-3 text-center"><?php
UI::pageLink('/request/edit?id=new', UI::icon('add_box') . ' Add a Prayer Request',
['class' => 'btn btn-primary']); ?>
<p class="pb-3 text-center">
<?=Component::pageLink('/request/edit?id=new', Component::icon('add_box') . ' Add a Prayer Request',
['class' => 'btn btn-primary'])?>
<p hx-get=/components/journal-items hx-swap=outerHTML hx-trigger=load hx-target=this>
Loading your prayer journal&hellip;
<div id=notesModal class="modal fade" tabindex=-1 aria-labelledby=nodesModalLabel aria-hidden=true>
+1 -1
View File
@@ -1,6 +1,6 @@
<?php declare(strict_types=1);
use MyPrayerJournal\Layout;
use MyPrayerJournal\UI\Layout;
require '../../start.php';
if ($_SERVER['REQUEST_METHOD'] <> 'GET') not_found();
+3 -3
View File
@@ -1,6 +1,6 @@
<?php declare(strict_types=1);
use MyPrayerJournal\{Layout, UI};
use MyPrayerJournal\UI\{Component, Layout};
require '../../start.php';
if ($_SERVER['REQUEST_METHOD'] <> 'GET') not_found();
@@ -24,7 +24,7 @@ Layout::pageHead('Terms of Service'); ?>
myPrayerJournal is a service that allows individuals to enter and amend their prayer requests. It
requires no registration by itself, but access is granted based on a successful login with an
external identity provider. See
<?php UI::pageLink('/legal/privacy-policy', 'our privacy policy'); ?> for details on how that
<?=Component::pageLink('/legal/privacy-policy', 'our privacy policy')?> for details on how that
information is accessed and stored.
</div>
<div class=list-group-item>
@@ -53,7 +53,7 @@ Layout::pageHead('Terms of Service'); ?>
</div>
</div>
<p class=pt-3>
You may also wish to review our <?php UI::pageLink('/legal/privacy-policy', 'privacy policy'); ?> to learn how
You may also wish to review our <?=Component::pageLink('/legal/privacy-policy', 'privacy policy')?> to learn how
we handle your data.
</article><?php
Layout::pageFoot();
+6 -4
View File
@@ -1,15 +1,17 @@
<?php declare(strict_types=1);
use MyPrayerJournal\{Layout, Table, UI};
use BitBadger\PDODocument\RemoveFields;
use MyPrayerJournal\Table;
use MyPrayerJournal\UI\{Component, Layout};
require '../../../start.php';
require '../../start.php';
$req = validate_request($_GET['id'], ['GET'], false);
$req = validate_request($_GET['id'], ['PATCH'], false);
RemoveFields::byId(Table::REQUEST, $req->id, ['snoozedUntil']);
$req->snoozedUntil = null;
// TODO: message
Layout::bareHead();
UI::requestItem($req);
Component::requestItem($req);
Layout::bareFoot();
+6 -3
View File
@@ -1,6 +1,8 @@
<?php declare(strict_types=1);
use MyPrayerJournal\{Auth, Layout, RecurrencePeriod, Request, RequestAction, UI};
use MyPrayerJournal\Auth;
use MyPrayerJournal\Domain\{RecurrencePeriod, Request, RequestAction};
use MyPrayerJournal\UI\{Component, Layout};
require '../../start.php';
if ($_SERVER['REQUEST_METHOD'] <> 'GET') not_found();
@@ -97,8 +99,9 @@ Layout::pageHead("$action Prayer Request");?>
</div>
</div>
<div class="text-end pt-3">
<button class="btn btn-primary me-2" type=submit><?=UI::icon('save');?> Save</button><?php
UI::pageLink($cancelLink, UI::icon('arrow_back') . ' Cancel', ['class' => 'btn btn-secondary ms-2']); ?>
<button class="btn btn-primary me-2" type=submit><?=Component::icon('save');?> Save</button>
<?=Component::pageLink($cancelLink, Component::icon('arrow_back') . ' Cancel',
['class' => 'btn btn-secondary ms-2'])?>
</div>
</form>
</article><?php
+3 -2
View File
@@ -1,6 +1,7 @@
<?php declare(strict_types=1);
use MyPrayerJournal\{History, Layout, Note, RequestAction, UI};
use MyPrayerJournal\Domain\{History, Note, RequestAction};
use MyPrayerJournal\UI\{Layout, RelativeDate};
require '../../start.php';
@@ -27,7 +28,7 @@ Layout::pageHead('Full Request');?>
<h6 class="card-subtitle text-muted mb-2"><?php
if (!is_null($answered)) { ?>
Answered <?=$answered->format('F j, Y')?>
(<?=UI::formatDistance('now', $req->history[0]->asOf);?>) &bull;<?php
(<?= RelativeDate::between('now', $req->history[0]->asOf);?>) &bull;<?php
} ?>
Prayed <?=number_format($prayed)?> times &bull; Open <?=number_format($daysOpen)?> days
</h6>
+2 -1
View File
@@ -1,7 +1,8 @@
<?php declare(strict_types=1);
use MyPrayerJournal\{Note, Table};
use BitBadger\PDODocument\Patch;
use MyPrayerJournal\Domain\Note;
use MyPrayerJournal\Table;
require '../../start.php';
+4 -2
View File
@@ -1,7 +1,9 @@
<?php declare(strict_types=1);
use MyPrayerJournal\{History, RecurrencePeriod, RequestAction, Table, UI};
use BitBadger\PDODocument\Patch;
use MyPrayerJournal\Domain\{History, RecurrencePeriod, RequestAction};
use MyPrayerJournal\Table;
use MyPrayerJournal\UI\Component;
require '../../start.php';
@@ -16,4 +18,4 @@ if ($req->recurrence->period <> RecurrencePeriod::Immediate) {
}
Patch::byId(Table::REQUEST, $req->id, $patch);
UI::journal();
Component::journal();
+2 -1
View File
@@ -1,7 +1,8 @@
<?php declare(strict_types=1);
use MyPrayerJournal\{Auth, History, Recurrence, RecurrencePeriod, Request, RequestAction, Table};
use BitBadger\PDODocument\{Document, Patch, RemoveFields};
use MyPrayerJournal\{Auth, Table};
use MyPrayerJournal\Domain\{History, Recurrence, RecurrencePeriod, Request, RequestAction};
require '../../start.php';
if ($_SERVER['REQUEST_METHOD'] <> 'POST' && $_SERVER['REQUEST_METHOD'] <> 'PATCH') not_found();
+17
View File
@@ -0,0 +1,17 @@
<?php declare(strict_types=1);
use BitBadger\PDODocument\RemoveFields;
use MyPrayerJournal\Table;
use MyPrayerJournal\UI\{Component, Layout};
require '../../start.php';
$req = validate_request($_GET['id'], ['PATCH'], false);
RemoveFields::byId(Table::REQUEST, $req->id, ['showAfter']);
$req->showAfter = null;
// TODO: message
Layout::bareHead();
Component::requestItem($req);
Layout::bareFoot();
+3 -2
View File
@@ -1,7 +1,8 @@
<?php declare(strict_types=1);
use MyPrayerJournal\{Table, UI};
use BitBadger\PDODocument\Patch;
use MyPrayerJournal\Table;
use MyPrayerJournal\UI\Component;
require '../../start.php';
@@ -14,4 +15,4 @@ Patch::byId(Table::REQUEST, $req->id, ['snoozedUntil' => $until->format('c')]);
// TODO: message
hide_modal('snooze');
UI::journal();
Component::journal();
+5 -3
View File
@@ -1,6 +1,8 @@
<?php declare(strict_types=1);
use MyPrayerJournal\{Auth, Layout, Request, UI};
use MyPrayerJournal\Auth;
use MyPrayerJournal\Domain\Request;
use MyPrayerJournal\UI\{Component, Layout};
require '../../start.php';
if ($_SERVER['REQUEST_METHOD'] <> 'GET') not_found();
@@ -13,9 +15,9 @@ Layout::pageHead('Active Requests'); ?>
<article class="container mt-3">
<h2 class=pb-3>Active Requests</h2><?php
if ($reqs->hasItems()) {
UI::requestList($reqs);
Component::requestList($reqs);
} else {
UI::noResults('No Active Requests', '/journal', 'Return to your journal',
Component::noResults('No Active Requests', '/journal', 'Return to your journal',
'Your prayer journal has no active requests');
} ?>
</article><?php
+5 -3
View File
@@ -1,6 +1,8 @@
<?php declare(strict_types=1);
use MyPrayerJournal\{Auth, Layout, Request, UI};
use MyPrayerJournal\Auth;
use MyPrayerJournal\Domain\Request;
use MyPrayerJournal\UI\{Component, Layout};
require '../../start.php';
if ($_SERVER['REQUEST_METHOD'] <> 'GET') not_found();
@@ -13,9 +15,9 @@ Layout::pageHead('Answered Requests'); ?>
<article class="container mt-3">
<h2 class=pb-3>Answered Requests</h2><?php
if ($reqs->hasItems()) {
UI::requestList($reqs);
Component::requestList($reqs);
} else {
UI::noResults('No Answered Requests', '/journal', 'Return to your journal', <<<'TEXT'
Component::noResults('No Answered Requests', '/journal', 'Return to your journal', <<<'TEXT'
Your prayer journal has no answered requests; once you have marked one as &ldquo;Answered&rdquo;, it will
appear here
TEXT);
+5 -3
View File
@@ -1,6 +1,8 @@
<?php declare(strict_types=1);
use MyPrayerJournal\{Auth, Layout, Request, UI};
use MyPrayerJournal\Auth;
use MyPrayerJournal\Domain\Request;
use MyPrayerJournal\UI\{Component, Layout};
require '../../start.php';
if ($_SERVER['REQUEST_METHOD'] <> 'GET') not_found();
@@ -13,9 +15,9 @@ Layout::pageHead('Snoozed Requests'); ?>
<article class="container mt-3">
<h2 class=pb-3>Snoozed Requests</h2><?php
if ($reqs->hasItems()) {
UI::requestList($reqs);
Component::requestList($reqs);
} else {
UI::noResults('No Snoozed Requests', '/journal', 'Return to your journal',
Component::noResults('No Snoozed Requests', '/journal', 'Return to your journal',
'Your prayer journal has no snoozed requests');
} ?>
</article><?php
+1
View File
@@ -3,5 +3,6 @@
use MyPrayerJournal\Auth;
require '../../start.php';
if ($_SERVER['REQUEST_METHOD'] <> 'GET') not_found();
Auth::logOff();
+1 -1
View File
@@ -2,7 +2,7 @@
use MyPrayerJournal\Auth;
if ($_SERVER['REQUEST_METHOD'] <> 'GET') not_found();
require '../../start.php';
if ($_SERVER['REQUEST_METHOD'] <> 'GET') not_found();
Auth::logOn();