diff --git a/src/lib/Feed.php b/src/lib/Feed.php index f1b8d88..2a45ab8 100644 --- a/src/lib/Feed.php +++ b/src/lib/Feed.php @@ -190,9 +190,11 @@ class Feed { && ( $existing['published_on'] != $item['published'] || $existing['updated_on'] ?? '' != $item['updated'] ?? '')) { self::updateItem($existing['id'], $item, $db); + } else { + self::addItem($feedId, $item, $db); } } else { - self::addItem($feedId, $item, $db); + throw new Exception($db->lastErrorMsg()); } } } catch (Exception $ex) { diff --git a/src/public/assets/style.css b/src/public/assets/style.css index 1706a50..bc42762 100644 --- a/src/public/assets/style.css +++ b/src/public/assets/style.css @@ -5,8 +5,15 @@ html { body { margin: 0; font-size: 1rem; - background: linear-gradient(135deg, #eeeeff, #ddddff, #eeeeff, #ccccff); - /* background-color: #eeeeee; */ + background: linear-gradient(135deg, #eeeeff, #ddddff, #eeeeff, #ccccff) fixed; +} +a:link, a:visited { + text-decoration: none; + font-weight: bold; + color: navy; +} +a:hover { + text-decoration: underline; } header { padding: 0 1rem .5rem 1rem; @@ -25,10 +32,6 @@ header { a:link, a:visited { color: white; - text-decoration: none; - } - a:hover { - text-decoration: underline; } } main { diff --git a/src/public/feed.php b/src/public/feed.php index 3a6bafa..85446c2 100644 --- a/src/public/feed.php +++ b/src/public/feed.php @@ -18,7 +18,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { $result = Feed::add($_POST['url'], $db); } else { $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)) { add_info('Feed saved successfully'); diff --git a/src/public/index.php b/src/public/index.php index b4a1f38..852558e 100644 --- a/src/public/index.php +++ b/src/public/index.php @@ -9,6 +9,35 @@ include '../start.php'; 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'); ?> -

Unread items go here

Your Unread Items +
format(DATE_TIME_FORMAT); + } catch (Exception) { + $asOf = '(invalid date)'; + } ?> +

>
+
fetchArray(SQLITE3_ASSOC); + } +} else { ?> +

There are no unread items

+
close(); diff --git a/src/user-config.php b/src/user-config.php index 877d61a..55af358 100644 --- a/src/user-config.php +++ b/src/user-config.php @@ -19,5 +19,12 @@ const SECURITY_MODEL = Security::SINGLE_USER; /** The name of the database file where users and feeds should be kept */ 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 // (editing below this line is not advised)