mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-02-06 08:24:14 +00:00
update response route by mime type
This commit is contained in:
parent
a478e31bd5
commit
ebadc548c0
@ -370,33 +370,21 @@ void Page::navigation_reload(
|
|||||||
action__update->activate();
|
action__update->activate();
|
||||||
|
|
||||||
// Parse meta
|
// Parse meta
|
||||||
Socket::Client::Gemini::Response::Status status;
|
Socket::Client::Gemini::Response::Status status; // @TODO make page global?
|
||||||
|
|
||||||
Socket::Client::Gemini::Response::Match::meta(
|
Socket::Client::Gemini::Response::Match::meta(
|
||||||
buffer,
|
buffer,
|
||||||
status,
|
status,
|
||||||
mime
|
mime
|
||||||
);
|
);
|
||||||
|
|
||||||
// Try detect mime by file extension on still undefined @TODO
|
// MIME type not detected
|
||||||
if (mime == MIME::UNDEFINED)
|
if (mime == MIME::UNDEFINED)
|
||||||
{
|
{
|
||||||
|
// Try detect by file extension
|
||||||
if (Glib::str_has_suffix(g_uri_get_path(uri), ".gmi"))
|
if (Glib::str_has_suffix(g_uri_get_path(uri), ".gmi"))
|
||||||
{
|
{
|
||||||
mime = MIME::TEXT_GEMINI;
|
mime = MIME::TEXT_GEMINI;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Update
|
|
||||||
title = _("Oops");
|
|
||||||
|
|
||||||
description = _("MIME type not supported");
|
|
||||||
|
|
||||||
progress_fraction = 1;
|
|
||||||
|
|
||||||
action__update->activate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Route by status code
|
// Route by status code
|
||||||
@ -404,6 +392,42 @@ void Page::navigation_reload(
|
|||||||
{
|
{
|
||||||
case Socket::Client::Gemini::Response::Status::SUCCESS:
|
case Socket::Client::Gemini::Response::Status::SUCCESS:
|
||||||
|
|
||||||
|
// Route by MIME
|
||||||
|
switch (mime)
|
||||||
|
{
|
||||||
|
case MIME::TEXT_GEMINI:
|
||||||
|
|
||||||
|
progress_fraction = 1;
|
||||||
|
|
||||||
|
// Set content driver
|
||||||
|
pageContent->update(
|
||||||
|
page::Content::TEXT_GEMINI,
|
||||||
|
buffer,
|
||||||
|
uri
|
||||||
|
);
|
||||||
|
|
||||||
|
// Update title on detected by document provider
|
||||||
|
if (!pageContent->get_title().empty())
|
||||||
|
{
|
||||||
|
title = pageContent->get_title();
|
||||||
|
}
|
||||||
|
|
||||||
|
action__update->activate();
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
|
||||||
|
// Update
|
||||||
|
title = _("Oops");
|
||||||
|
|
||||||
|
description = _("MIME type not supported");
|
||||||
|
|
||||||
|
progress_fraction = 1;
|
||||||
|
|
||||||
|
action__update->activate();
|
||||||
|
}
|
||||||
|
|
||||||
// Update
|
// Update
|
||||||
title = _("Done"); // @TODO page title
|
title = _("Done"); // @TODO page title
|
||||||
|
|
||||||
@ -411,23 +435,6 @@ void Page::navigation_reload(
|
|||||||
uri
|
uri
|
||||||
);
|
);
|
||||||
|
|
||||||
progress_fraction = 1;
|
|
||||||
|
|
||||||
// Set content driver
|
|
||||||
pageContent->update(
|
|
||||||
page::Content::TEXT_GEMINI,
|
|
||||||
buffer,
|
|
||||||
uri
|
|
||||||
);
|
|
||||||
|
|
||||||
// Update title on detected by document provider
|
|
||||||
if (!pageContent->get_title().empty())
|
|
||||||
{
|
|
||||||
title = pageContent->get_title();
|
|
||||||
}
|
|
||||||
|
|
||||||
action__update->activate();
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// @TODO other statuses..
|
// @TODO other statuses..
|
||||||
|
Loading…
x
Reference in New Issue
Block a user