Tweaks to document access

This commit is contained in:
2024-06-03 18:18:51 -04:00
parent 93dd8e880f
commit 1ca7dbdedd
12 changed files with 107 additions and 30 deletions

View File

@@ -76,6 +76,8 @@ class Data
Definition::ensureFieldIndex(Table::ITEM, 'feed', ['feed_id', 'item_link'], $db);
self::createSearchIndex($db);
}
$journalMode = Custom::scalar("PRAGMA journal_mode", [], fn($it) => $it[0]);
if ($journalMode <> 'wal') Custom::nonQuery("PRAGMA journal_mode = 'wal'", []);
$db->close();
}

View File

@@ -10,6 +10,7 @@ use BitBadger\Documents\JsonMapper;
use BitBadger\Documents\Query;
use BitBadger\Documents\SQLite\Custom;
use BitBadger\Documents\SQLite\Parameters;
use Iterator;
/**
* A list of items to be displayed
@@ -140,7 +141,7 @@ class ItemList
if ($isBookmarked) $fields[] = Data::bookmarkField(Table::ITEM);
$list = new static('Matching' . ($isBookmarked ? ' Bookmarked' : ''),
"/search?search=$search&items=" . ($isBookmarked ? 'bookmarked' : 'all'), $fields,
' ' . Table::ITEM . ".data->>'" . Configuration::idField() . "' IN "
' AND ' . Table::ITEM . ".data->>'" . Configuration::idField() . "' IN "
. '(SELECT ROWID FROM item_search WHERE content MATCH @search)');
$list->showIndicators = true;
$list->displayFeed = true;
@@ -159,8 +160,7 @@ class ItemList
$return = $this->returnURL == '' ? '' : '&from=' . urlencode($this->returnURL);
$hasItems = false;
echo '<article>';
iterator_apply($this->dbList->items(), function (ItemWithFeed $it) use (&$hasItems, $return)
{
foreach ($this->dbList->items() as $it) {
$hasItems = true;
echo '<p>' . hx_get("/item?id=$it->id$return", strip_tags($it->title)) . '<br><small>';
if ($this->showIndicators) {
@@ -176,7 +176,7 @@ class ItemList
echo ' &bull; ' . htmlentities($it->feed->title);
}
echo '</small>';
});
}
if (!$hasItems) {
echo '<p><em>There are no ' . strtolower($this->itemType) . ' items</em>';
}

View File

@@ -22,7 +22,7 @@ class ItemWithFeed extends Item
/** @var string The `SELECT` clause to add the feed as a property to the item's document */
public const string SELECT_WITH_FEED =
'SELECT json_set(' . Table::ITEM . ".data, '$.feed', " . Table::FEED . '.data) AS data FROM '
'SELECT json_set(' . Table::ITEM . ".data, '$.feed', json(" . Table::FEED . '.data)) AS data FROM '
. self::FROM_WITH_JOIN;
/** @var Feed The feed to which this item belongs */

View File

@@ -68,7 +68,6 @@ class Security
$dbEmail = $email;
}
$user = User::findByEmail($dbEmail);
var_dump($user);
if ($user) self::verifyPassword($user, $password, $returnTo);
add_error('Invalid credentials; log on unsuccessful');
}