mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
save page title to the database history
This commit is contained in:
parent
eeceb7caaa
commit
7451d6d78f
3 changed files with 57 additions and 42 deletions
|
|
@ -161,7 +161,7 @@ class History
|
|||
|
||||
$this->treeview->append_column(
|
||||
new \GtkTreeViewColumn(
|
||||
'URL',
|
||||
'Time',
|
||||
new \GtkCellRendererText(),
|
||||
'text',
|
||||
0
|
||||
|
|
@ -170,15 +170,27 @@ class History
|
|||
|
||||
$this->treeview->append_column(
|
||||
new \GtkTreeViewColumn(
|
||||
'Time',
|
||||
'Title',
|
||||
new \GtkCellRendererText(),
|
||||
'text',
|
||||
1
|
||||
)
|
||||
);
|
||||
|
||||
$this->treeview->append_column(
|
||||
new \GtkTreeViewColumn(
|
||||
'URL',
|
||||
new \GtkCellRendererText(),
|
||||
'text',
|
||||
2
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
|
||||
// Init list storage
|
||||
$this->list = new \GtkListStore(
|
||||
\GObject::TYPE_STRING,
|
||||
\GObject::TYPE_STRING,
|
||||
\GObject::TYPE_STRING
|
||||
);
|
||||
|
|
@ -259,11 +271,12 @@ class History
|
|||
{
|
||||
$this->list->append(
|
||||
[
|
||||
$record->url,
|
||||
date(
|
||||
$this->config->time->format,
|
||||
$record->time
|
||||
)
|
||||
),
|
||||
$record->title,
|
||||
$record->url
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,10 +46,10 @@ class Page
|
|||
$this->history = new \Yggverse\Yoda\Model\History;
|
||||
|
||||
// Run database cleaner
|
||||
if ($this->config->history->timeout)
|
||||
if ($this->config->database->history->timeout)
|
||||
{
|
||||
$this->app->database->cleanHistory(
|
||||
$this->config->history->timeout
|
||||
$this->config->database->history->timeout
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -366,42 +366,17 @@ class Page
|
|||
$url
|
||||
);
|
||||
|
||||
// Ignore history record on same URL given
|
||||
if ($url == $this->history->getCurrent())
|
||||
{
|
||||
$history = false;
|
||||
}
|
||||
|
||||
// Ignore history record on same URL stored in DB
|
||||
if ($result = $this->app->database->getHistory('', 0, 1))
|
||||
{
|
||||
if ($url == $result[0]->url)
|
||||
{
|
||||
$history = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Update address field by requested
|
||||
$this->address->set_text(
|
||||
$url
|
||||
);
|
||||
|
||||
if ($history)
|
||||
// Update history in memory pool
|
||||
if ($history && $this->config->memory->history->enabled && $url != $this->history->getCurrent())
|
||||
{
|
||||
// Update history in memory pool
|
||||
$this->history->add(
|
||||
$url
|
||||
);
|
||||
|
||||
// Update history in the database
|
||||
if ($this->config->history->enabled)
|
||||
{
|
||||
$this->app->database->addHistory(
|
||||
$url
|
||||
);
|
||||
|
||||
$this->app->history->refresh();
|
||||
}
|
||||
}
|
||||
|
||||
// Update home button sensibility on match requested
|
||||
|
|
@ -450,7 +425,8 @@ class Page
|
|||
private function _openGemini(
|
||||
string $url,
|
||||
int $code = 0,
|
||||
int $redirects = 0
|
||||
int $redirects = 0,
|
||||
bool $history = true
|
||||
): void
|
||||
{
|
||||
// Init base URL
|
||||
|
|
@ -625,6 +601,29 @@ class Page
|
|||
$this->config->footer->status->open->complete
|
||||
)
|
||||
);
|
||||
|
||||
// Update history database
|
||||
if ($history && $this->config->database->history->enabled)
|
||||
{
|
||||
// Ignore history record on same URL stored
|
||||
if ($result = $this->app->database->getHistory('', 0, 1))
|
||||
{
|
||||
if ($url == $result[0]->url)
|
||||
{
|
||||
$history = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($history)
|
||||
{
|
||||
$this->app->database->addHistory(
|
||||
$url,
|
||||
$title
|
||||
);
|
||||
|
||||
$this->app->history->refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function _openYoda(
|
||||
|
|
|
|||
|
|
@ -37,9 +37,10 @@ class Database
|
|||
$this->_database->query('
|
||||
CREATE TABLE IF NOT EXISTS "history"
|
||||
(
|
||||
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
"time" INTEGER NOT NULL,
|
||||
"url" VARCHAR(1024) NOT NULL
|
||||
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
"time" INTEGER NOT NULL,
|
||||
"url" VARCHAR(1024) NOT NULL,
|
||||
"title" VARCHAR(255)
|
||||
)
|
||||
');
|
||||
}
|
||||
|
|
@ -56,17 +57,19 @@ class Database
|
|||
}
|
||||
|
||||
public function addHistory(
|
||||
string $url
|
||||
string $url,
|
||||
?string $title = null
|
||||
): int
|
||||
{
|
||||
$query = $this->_database->prepare(
|
||||
'INSERT INTO `history` (`time`, `url`) VALUES (:time, :url)'
|
||||
'INSERT INTO `history` (`time`, `url`, `title`) VALUES (:time, :url, :title)'
|
||||
);
|
||||
|
||||
$query->execute(
|
||||
[
|
||||
':time' => time(),
|
||||
':url' => $url
|
||||
':time' => time(),
|
||||
':url' => $url,
|
||||
':title' => $title
|
||||
]
|
||||
);
|
||||
|
||||
|
|
@ -81,7 +84,7 @@ class Database
|
|||
{
|
||||
$query = $this->_database->prepare(
|
||||
sprintf(
|
||||
'SELECT * FROM `history` WHERE `url` LIKE :search ORDER BY `id` DESC LIMIT %d,%d',
|
||||
'SELECT * FROM `history` WHERE `url` LIKE :search OR `title` LIKE :search ORDER BY `id` DESC LIMIT %d,%d',
|
||||
$start,
|
||||
$limit
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue