First cut of read bookmarked item page (#14)

- Added Bookmarked link to header if items exist
This commit is contained in:
2024-05-23 23:02:07 -04:00
parent f4273935cb
commit 2495136fc9
2 changed files with 43 additions and 14 deletions

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,
feed.title AS feed_title
FROM item
INNER JOIN feed ON feed.id = item.feed_id
WHERE feed.user_id = :userId
AND item.is_read = 0
AND $itemCriteria
ORDER BY coalesce(item.updated_on, item.published_on) DESC
SQL);
$query->bindValue(':userId', $_SESSION[Key::USER_ID]);
$result = $query->execute();
$item = $result ? $result->fetchArray(SQLITE3_ASSOC) : false;
page_head('Your Unread Items'); ?>
page_head($title); ?>
<h1>
Your Unread Items &nbsp;
<a class=refresh href=/?refresh hx-get=/?refresh hx-indicator="closest h1">(Refresh All Feeds)</a>
<span class=loading>Refreshing&hellip;</span>
<?=$title?><?php
if (!$type == 'Unread') { ?> &nbsp;
<a class=refresh href=/?refresh hx-get=/?refresh hx-indicator="closest h1">(Refresh All Feeds)</a>
<span class=loading>Refreshing&hellip;</span><?php
} ?>
</h1>
<article><?php
if ($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;
<?=hx_get("/feed/items?id={$item['feed_id']}&unread", htmlentities($item['feed_title']))?></small><?php
$item = $result->fetchArray(SQLITE3_ASSOC);
}
} else { ?>
<p>There are no unread items</p><?php
<p>There are no <?=strtolower($type)?> items<?php
} ?>
</article><?php