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(
|
$this->treeview->append_column(
|
||||||
new \GtkTreeViewColumn(
|
new \GtkTreeViewColumn(
|
||||||
'URL',
|
'Time',
|
||||||
new \GtkCellRendererText(),
|
new \GtkCellRendererText(),
|
||||||
'text',
|
'text',
|
||||||
0
|
0
|
||||||
|
|
@ -170,15 +170,27 @@ class History
|
||||||
|
|
||||||
$this->treeview->append_column(
|
$this->treeview->append_column(
|
||||||
new \GtkTreeViewColumn(
|
new \GtkTreeViewColumn(
|
||||||
'Time',
|
'Title',
|
||||||
new \GtkCellRendererText(),
|
new \GtkCellRendererText(),
|
||||||
'text',
|
'text',
|
||||||
1
|
1
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->treeview->append_column(
|
||||||
|
new \GtkTreeViewColumn(
|
||||||
|
'URL',
|
||||||
|
new \GtkCellRendererText(),
|
||||||
|
'text',
|
||||||
|
2
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Init list storage
|
// Init list storage
|
||||||
$this->list = new \GtkListStore(
|
$this->list = new \GtkListStore(
|
||||||
|
\GObject::TYPE_STRING,
|
||||||
\GObject::TYPE_STRING,
|
\GObject::TYPE_STRING,
|
||||||
\GObject::TYPE_STRING
|
\GObject::TYPE_STRING
|
||||||
);
|
);
|
||||||
|
|
@ -259,11 +271,12 @@ class History
|
||||||
{
|
{
|
||||||
$this->list->append(
|
$this->list->append(
|
||||||
[
|
[
|
||||||
$record->url,
|
|
||||||
date(
|
date(
|
||||||
$this->config->time->format,
|
$this->config->time->format,
|
||||||
$record->time
|
$record->time
|
||||||
)
|
),
|
||||||
|
$record->title,
|
||||||
|
$record->url
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,10 +46,10 @@ class Page
|
||||||
$this->history = new \Yggverse\Yoda\Model\History;
|
$this->history = new \Yggverse\Yoda\Model\History;
|
||||||
|
|
||||||
// Run database cleaner
|
// Run database cleaner
|
||||||
if ($this->config->history->timeout)
|
if ($this->config->database->history->timeout)
|
||||||
{
|
{
|
||||||
$this->app->database->cleanHistory(
|
$this->app->database->cleanHistory(
|
||||||
$this->config->history->timeout
|
$this->config->database->history->timeout
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -366,42 +366,17 @@ class Page
|
||||||
$url
|
$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
|
// Update address field by requested
|
||||||
$this->address->set_text(
|
$this->address->set_text(
|
||||||
$url
|
$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(
|
$this->history->add(
|
||||||
$url
|
$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
|
// Update home button sensibility on match requested
|
||||||
|
|
@ -450,7 +425,8 @@ class Page
|
||||||
private function _openGemini(
|
private function _openGemini(
|
||||||
string $url,
|
string $url,
|
||||||
int $code = 0,
|
int $code = 0,
|
||||||
int $redirects = 0
|
int $redirects = 0,
|
||||||
|
bool $history = true
|
||||||
): void
|
): void
|
||||||
{
|
{
|
||||||
// Init base URL
|
// Init base URL
|
||||||
|
|
@ -625,6 +601,29 @@ class Page
|
||||||
$this->config->footer->status->open->complete
|
$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(
|
private function _openYoda(
|
||||||
|
|
|
||||||
|
|
@ -37,9 +37,10 @@ class Database
|
||||||
$this->_database->query('
|
$this->_database->query('
|
||||||
CREATE TABLE IF NOT EXISTS "history"
|
CREATE TABLE IF NOT EXISTS "history"
|
||||||
(
|
(
|
||||||
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||||
"time" INTEGER NOT NULL,
|
"time" INTEGER NOT NULL,
|
||||||
"url" VARCHAR(1024) NOT NULL
|
"url" VARCHAR(1024) NOT NULL,
|
||||||
|
"title" VARCHAR(255)
|
||||||
)
|
)
|
||||||
');
|
');
|
||||||
}
|
}
|
||||||
|
|
@ -56,17 +57,19 @@ class Database
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addHistory(
|
public function addHistory(
|
||||||
string $url
|
string $url,
|
||||||
|
?string $title = null
|
||||||
): int
|
): int
|
||||||
{
|
{
|
||||||
$query = $this->_database->prepare(
|
$query = $this->_database->prepare(
|
||||||
'INSERT INTO `history` (`time`, `url`) VALUES (:time, :url)'
|
'INSERT INTO `history` (`time`, `url`, `title`) VALUES (:time, :url, :title)'
|
||||||
);
|
);
|
||||||
|
|
||||||
$query->execute(
|
$query->execute(
|
||||||
[
|
[
|
||||||
':time' => time(),
|
':time' => time(),
|
||||||
':url' => $url
|
':url' => $url,
|
||||||
|
':title' => $title
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -81,7 +84,7 @@ class Database
|
||||||
{
|
{
|
||||||
$query = $this->_database->prepare(
|
$query = $this->_database->prepare(
|
||||||
sprintf(
|
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,
|
$start,
|
||||||
$limit
|
$limit
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue