Alpha 7 #22

Merged
danieljsummers merged 6 commits from alpha-7 into main 2024-05-26 21:33:13 +00:00
2 changed files with 43 additions and 14 deletions
Showing only changes of commit 2495136fc9 - Show all commits

View File

@ -19,35 +19,48 @@ if (array_key_exists('refresh', $_GET)) {
} }
} }
$query = $db->prepare(<<<'SQL' if (key_exists('bookmarked', $_GET)) {
$itemCriteria = 'item.is_bookmarked = 1';
$returnURL = '&from=' . urlencode('/?bookmarked');
$type = 'Bookmarked';
} else {
$itemCriteria = 'item.is_read = 0';
$returnURL = '';
$type = 'Unread';
}
$title = "Your $type Items";
$query = $db->prepare(<<<SQL
SELECT item.id, item.feed_id, item.title AS item_title, coalesce(item.updated_on, item.published_on) AS as_of, SELECT item.id, item.feed_id, item.title AS item_title, coalesce(item.updated_on, item.published_on) AS as_of,
feed.title AS feed_title feed.title AS feed_title
FROM item FROM item
INNER JOIN feed ON feed.id = item.feed_id INNER JOIN feed ON feed.id = item.feed_id
WHERE feed.user_id = :userId WHERE feed.user_id = :userId
AND item.is_read = 0 AND $itemCriteria
ORDER BY coalesce(item.updated_on, item.published_on) DESC ORDER BY coalesce(item.updated_on, item.published_on) DESC
SQL); SQL);
$query->bindValue(':userId', $_SESSION[Key::USER_ID]); $query->bindValue(':userId', $_SESSION[Key::USER_ID]);
$result = $query->execute(); $result = $query->execute();
$item = $result ? $result->fetchArray(SQLITE3_ASSOC) : false; $item = $result ? $result->fetchArray(SQLITE3_ASSOC) : false;
page_head('Your Unread Items'); ?> page_head($title); ?>
<h1> <h1>
Your Unread Items &nbsp; <?=$title?><?php
if (!$type == 'Unread') { ?> &nbsp;
<a class=refresh href=/?refresh hx-get=/?refresh hx-indicator="closest h1">(Refresh All Feeds)</a> <a class=refresh href=/?refresh hx-get=/?refresh hx-indicator="closest h1">(Refresh All Feeds)</a>
<span class=loading>Refreshing&hellip;</span> <span class=loading>Refreshing&hellip;</span><?php
} ?>
</h1> </h1>
<article><?php <article><?php
if ($item) { if ($item) {
while ($item) { ?> while ($item) { ?>
<p><?=hx_get("/item?id={$item['id']}", strip_tags($item['item_title']))?><br> <p><?=hx_get("/item?id={$item['id']}$returnURL", strip_tags($item['item_title']))?><br>
<small><?=date_time($item['as_of'])?> &bull; <small><?=date_time($item['as_of'])?> &bull;
<?=hx_get("/feed/items?id={$item['feed_id']}&unread", htmlentities($item['feed_title']))?></small><?php <?=hx_get("/feed/items?id={$item['feed_id']}&unread", htmlentities($item['feed_title']))?></small><?php
$item = $result->fetchArray(SQLITE3_ASSOC); $item = $result->fetchArray(SQLITE3_ASSOC);
} }
} else { ?> } else { ?>
<p>There are no unread items</p><?php <p>There are no <?=strtolower($type)?> items<?php
} ?> } ?>
</article><?php </article><?php

View File

@ -52,14 +52,30 @@ function title_bar(): void {
default => FRC_VERSION default => FRC_VERSION
}; ?> }; ?>
<header hx-target=#main hx-push-url=true> <header hx-target=#main hx-push-url=true>
<div><?=hx_get('/', 'Feed Reader Central', 'class=title')?><span class=version>v<?=$version?></span></div> <div><a href=/ class=title>Feed Reader Central</a><span class=version>v<?=$version?></span></div>
<div><?php <div><?php
if (array_key_exists(Key::USER_ID, $_SESSION)) { ?> if (array_key_exists(Key::USER_ID, $_SESSION)) {
<?=hx_get('/feeds', 'Feeds')?> | <?=hx_get('/docs/', 'Docs')?> | $db = Data::getConnection();
try {
$bookQuery = $db->prepare(<<<'SQL'
SELECT EXISTS(
SELECT 1
FROM item INNER JOIN feed ON item.feed_id = feed.id
WHERE feed.user_id = :id AND item.is_bookmarked = 1)
SQL);
$bookQuery->bindValue(':id', $_SESSION[Key::USER_ID]);
$bookResult = $bookQuery->execute();
$hasBookmarks = $bookResult ? $bookResult->fetchArray(SQLITE3_NUM)[0] : false; ?>
<?=hx_get('/feeds', 'Feeds')?> |
<?=$hasBookmarks ? hx_get('/?bookmarked', 'Bookmarked') . ' | ' : ''?>
<?=hx_get('/docs/', 'Docs')?> |
<a href=/user/log-off>Log Off</a><?php <a href=/user/log-off>Log Off</a><?php
if ($_SESSION[Key::USER_EMAIL] != Security::SINGLE_USER_EMAIL) { ?> if ($_SESSION[Key::USER_EMAIL] != Security::SINGLE_USER_EMAIL) { ?>
| <?=$_SESSION[Key::USER_EMAIL]?><?php | <?=$_SESSION[Key::USER_EMAIL]?><?php
} }
} finally {
$db->close();
}
} else { ?> } else { ?>
<?=hx_get('/user/log-on', 'Log On')?> | <?=hx_get('/docs/', 'Docs')?><?php <?=hx_get('/user/log-on', 'Log On')?> | <?=hx_get('/docs/', 'Docs')?><?php
} ?> } ?>