alpha1 #8
|
@ -190,9 +190,11 @@ class Feed {
|
||||||
&& ( $existing['published_on'] != $item['published']
|
&& ( $existing['published_on'] != $item['published']
|
||||||
|| $existing['updated_on'] ?? '' != $item['updated'] ?? '')) {
|
|| $existing['updated_on'] ?? '' != $item['updated'] ?? '')) {
|
||||||
self::updateItem($existing['id'], $item, $db);
|
self::updateItem($existing['id'], $item, $db);
|
||||||
|
} else {
|
||||||
|
self::addItem($feedId, $item, $db);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self::addItem($feedId, $item, $db);
|
throw new Exception($db->lastErrorMsg());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
|
|
|
@ -5,8 +5,15 @@ html {
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
background: linear-gradient(135deg, #eeeeff, #ddddff, #eeeeff, #ccccff);
|
background: linear-gradient(135deg, #eeeeff, #ddddff, #eeeeff, #ccccff) fixed;
|
||||||
/* background-color: #eeeeee; */
|
}
|
||||||
|
a:link, a:visited {
|
||||||
|
text-decoration: none;
|
||||||
|
font-weight: bold;
|
||||||
|
color: navy;
|
||||||
|
}
|
||||||
|
a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
header {
|
header {
|
||||||
padding: 0 1rem .5rem 1rem;
|
padding: 0 1rem .5rem 1rem;
|
||||||
|
@ -25,10 +32,6 @@ header {
|
||||||
|
|
||||||
a:link, a:visited {
|
a:link, a:visited {
|
||||||
color: white;
|
color: white;
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
a:hover {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
main {
|
main {
|
||||||
|
|
|
@ -18,7 +18,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
$result = Feed::add($_POST['url'], $db);
|
$result = Feed::add($_POST['url'], $db);
|
||||||
} else {
|
} else {
|
||||||
$toEdit = Data::retrieveFeedById($_POST['id'], $db);
|
$toEdit = Data::retrieveFeedById($_POST['id'], $db);
|
||||||
$result = $toEdit ? Feed::update($toEdit, $_POST['url'], $db) : [ 'error' => "Feed {$_POST['id']} not found" ];
|
$result = $toEdit ? Feed::update($toEdit, $_POST['url'], $db) : ['error' => "Feed {$_POST['id']} not found"];
|
||||||
}
|
}
|
||||||
if (array_key_exists('ok', $result)) {
|
if (array_key_exists('ok', $result)) {
|
||||||
add_info('Feed saved successfully');
|
add_info('Feed saved successfully');
|
||||||
|
|
|
@ -9,6 +9,35 @@ include '../start.php';
|
||||||
|
|
||||||
Security::verifyUser();
|
Security::verifyUser();
|
||||||
|
|
||||||
|
$db = Data::getConnection();
|
||||||
|
$result = $db->query(<<<'SQL'
|
||||||
|
SELECT item.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 item.is_read = 0
|
||||||
|
ORDER BY coalesce(item.updated_on, item.published_on) DESC
|
||||||
|
SQL);
|
||||||
|
$item = $result ? $result->fetchArray(SQLITE3_ASSOC) : false;
|
||||||
|
|
||||||
page_head('Welcome'); ?>
|
page_head('Welcome'); ?>
|
||||||
<p>Unread items go here</p><?php
|
<h1>Your Unread Items</h1>
|
||||||
|
<article><?php
|
||||||
|
if ($item) {
|
||||||
|
while ($item) {
|
||||||
|
try {
|
||||||
|
$asOf = (new DateTimeImmutable($item['as_of']))->format(DATE_TIME_FORMAT);
|
||||||
|
} catch (Exception) {
|
||||||
|
$asOf = '(invalid date)';
|
||||||
|
} ?>
|
||||||
|
<p><a href=/item/view?id=<?=$item['id']?>><?=htmlentities($item['item_title'])?></a><br>
|
||||||
|
<?=htmlentities($item['feed_title'])?><br><small><em><?=$asOf?></em></small><?php
|
||||||
|
$item = $result->fetchArray(SQLITE3_ASSOC);
|
||||||
|
}
|
||||||
|
} else { ?>
|
||||||
|
<p>There are no unread items</p><?php
|
||||||
|
} ?>
|
||||||
|
</article><?php
|
||||||
|
|
||||||
page_foot();
|
page_foot();
|
||||||
|
$db->close();
|
||||||
|
|
|
@ -19,5 +19,12 @@ const SECURITY_MODEL = Security::SINGLE_USER;
|
||||||
/** The name of the database file where users and feeds should be kept */
|
/** The name of the database file where users and feeds should be kept */
|
||||||
const DATABASE_NAME = 'frc.db';
|
const DATABASE_NAME = 'frc.db';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The format for date/time outputs; see https://www.php.net/manual/en/datetime.format.php for acceptable values
|
||||||
|
*
|
||||||
|
* The default, 'F j, Y \a\t g:ia', equates to "August 17, 2023 at 4:45pm"
|
||||||
|
*/
|
||||||
|
const DATE_TIME_FORMAT = 'F j, Y \a\t g:ia';
|
||||||
|
|
||||||
// END USER CONFIGURATION ITEMS
|
// END USER CONFIGURATION ITEMS
|
||||||
// (editing below this line is not advised)
|
// (editing below this line is not advised)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user