diff --git a/src/app-config.php b/src/app-config.php index 0862dab..bc29c5a 100644 --- a/src/app-config.php +++ b/src/app-config.php @@ -1,7 +1,7 @@ prepare('SELECT * FROM feed WHERE id = :id AND user_id = :user'); - $query->bindValue(':id', $feedId); - $query->bindValue(':user', $_SESSION[Key::USER_ID]); - $result = $query->execute(); - return $result ? $result->fetchArray(SQLITE3_ASSOC) : false; - } finally { - if (is_null($dbConn)) $db->close(); - } - } - /** * Return the last SQLite error message as a result array * diff --git a/src/lib/Feed.php b/src/lib/Feed.php index c6e9191..7dd5fca 100644 --- a/src/lib/Feed.php +++ b/src/lib/Feed.php @@ -514,4 +514,18 @@ class Feed { return sizeof($errors) == 0 ? ['ok' => true] : ['error' => implode("\n", $errors)]; } + + /** + * Retrieve a feed by its ID for the current user + * + * @param int $feedId The ID of the feed to retrieve + * @param SQLite3 $db A database connection to use to retrieve the feed + * @return array|bool The data for the feed if found, false if not found + */ + public static function retrieveById(int $feedId, SQLite3 $db): array|bool { + $query = $db->prepare('SELECT * FROM feed WHERE id = :id AND user_id = :user'); + $query->bindValue(':id', $feedId); + $query->bindValue(':user', $_SESSION[Key::USER_ID]); + return ($result = $query->execute()) ? $result->fetchArray(SQLITE3_ASSOC) : false; + } } diff --git a/src/public/assets/style.css b/src/public/assets/style.css index 14747cc..d63410c 100644 --- a/src/public/assets/style.css +++ b/src/public/assets/style.css @@ -22,10 +22,14 @@ header { border-bottom-right-radius: .5rem; color: white; display: flex; - flex-flow: row nowrap; + flex-flow: row wrap; justify-content: space-between; align-items: baseline; + div { + margin-bottom: .25rem; + } + .title { font-size: 1.5rem; } @@ -101,6 +105,10 @@ article { width: unset; } } + + .meta { + font-size: .9rem; + } } article.docs { line-height: 1.4rem; diff --git a/src/public/docs/index.php b/src/public/docs/index.php index 37278bf..1811c50 100644 --- a/src/public/docs/index.php +++ b/src/public/docs/index.php @@ -7,10 +7,11 @@ Security::verifyUser($db, redirectIfAnonymous: false); page_head('Documentation'); ?>

Documentation Home

-

About the CLI provides orientation on Feed Reader Central’s command line interface -

Configuring Security Modes describes the three security modes and how to manage each - of them -

Refresh Feeds has instructions on how feeds can be refreshed on a schedule +

provides orientation on Feed Reader Central’s command line + interface +

describes the three security modes and how to + manage each of them +

has instructions on how feeds can be refreshed on a schedule

close(); diff --git a/src/public/docs/refresh-feeds.php b/src/public/docs/refresh-feeds.php index 1407e83..f5812af 100644 --- a/src/public/docs/refresh-feeds.php +++ b/src/public/docs/refresh-feeds.php @@ -6,7 +6,7 @@ Security::verifyUser($db, redirectIfAnonymous: false); page_head('Refresh Feeds | Documentation'); ?>

Refresh Feeds

-

Manual Feed Refresh

Next to the “Your Unread Items” heading on the main page, there is a link labeled “Refresh All diff --git a/src/public/docs/security-modes.php b/src/public/docs/security-modes.php index 32ddf49..222294c 100644 --- a/src/public/docs/security-modes.php +++ b/src/public/docs/security-modes.php @@ -6,7 +6,7 @@ Security::verifyUser($db, redirectIfAnonymous: false); page_head('Security Modes | Documentation'); ?>

Configuring Security Modes

-

Security Modes

Single-User mode assumes that every connection to the application is the same person. It is diff --git a/src/public/docs/the-cli.php b/src/public/docs/the-cli.php index 80aec65..d833e51 100644 --- a/src/public/docs/the-cli.php +++ b/src/public/docs/the-cli.php @@ -6,7 +6,7 @@ Security::verifyUser($db, redirectIfAnonymous: false); page_head('About the CLI | Documentation'); ?>

About the CLI

-

Feed Reader Central’s low-friction design includes having many administrative tasks run in a terminal or shell. “CLI” is short for “Command Line Interface”, and refers to commands that are run diff --git a/src/public/feed.php b/src/public/feed/index.php similarity index 52% rename from src/public/feed.php rename to src/public/feed/index.php index 80f985a..59a73e5 100644 --- a/src/public/feed.php +++ b/src/public/feed/index.php @@ -1,32 +1,46 @@ prepare('DELETE FROM item WHERE feed_id = :feed'); + $itemDelete->bindValue(':feed', $feed['id']); + if (!$itemDelete->execute()) add_error(Data::error($db)['error']); + $feedDelete = $db->prepare('DELETE FROM feed WHERE id = :feed'); + $feedDelete->bindValue(':feed', $feed['id']); + if ($feedDelete->execute()) { + add_info('Feed “' . htmlentities($feed['title']) . '” deleted successfully'); + } else { + add_error(Data::error($db)['error']); + } + frc_redirect('/feeds'); +} + if ($_SERVER['REQUEST_METHOD'] == 'POST') { $isNew = $_POST['id'] == 'new'; if ($isNew) { $result = Feed::add($_POST['url'], $db); } else { - $toEdit = Data::retrieveFeedById($_POST['id'], $db); + $toEdit = Feed::retrieveById($_POST['id'], $db); $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'); - $feedId = $isNew ? $result['ok'] : $_POST['id']; - } else { - add_error($result['error']); - $feedId = 'error'; + frc_redirect('/feeds'); } + add_error($result['error']); + $feedId = 'error'; } if ($feedId == 'new') { @@ -36,19 +50,13 @@ if ($feedId == 'new') { $title = 'Edit RSS Feed'; if ($feedId == 'error') { $feed = ['id' => $_POST['id'] ?? '', 'url' => $_POST['url'] ?? '']; - } else { - $feed = Data::retrieveFeedById((int) $feedId, $db); - if (!$feed) { - http_response_code(404); - die(); - } - } + } elseif (!($feed = Feed::retrieveById((int) $feedId, $db))) not_found(); } page_head($title); ?>

-
+ >