Browse Source

resolve relative links

CPP-GTK4
yggverse 2 months ago
parent
commit
1c5a8d58f0
  1. 1
      src/app/browser/main/tab/page.cpp
  2. 6
      src/app/browser/main/tab/page/content.cpp
  3. 3
      src/app/browser/main/tab/page/content.hpp
  4. 8
      src/app/browser/main/tab/page/content/text.cpp
  5. 3
      src/app/browser/main/tab/page/content/text.hpp
  6. 2
      src/app/browser/main/tab/page/content/text/gemini.cpp
  7. 1
      src/app/browser/main/tab/page/content/text/gemini.hpp
  8. 25
      src/app/browser/main/tab/page/content/text/gemini/reader.cpp
  9. 2
      src/app/browser/main/tab/page/content/text/gemini/reader.hpp

1
src/app/browser/main/tab/page.cpp

@ -351,6 +351,7 @@ void Page::navigation_reload( @@ -351,6 +351,7 @@ void Page::navigation_reload(
// Set content driver
pageContent->update(
page::Content::TEXT_GEMINI,
pageNavigation->get_request_text(),
buffer
);

6
src/app/browser/main/tab/page/content.cpp

@ -40,7 +40,8 @@ Glib::ustring Content::get_title() @@ -40,7 +40,8 @@ Glib::ustring Content::get_title()
// Setters
void Content::update(
const MIME & MIME,
const Glib::ustring & DATA
const Glib::ustring & REQUEST,
const Glib::ustring & SOURCE
) {
// Cleanup, free memory
if (contentText != nullptr)
@ -63,7 +64,8 @@ void Content::update( @@ -63,7 +64,8 @@ void Content::update(
contentText = new content::Text(
content::Text::Type::GEMINI,
DATA
REQUEST,
SOURCE
);
title = contentText->get_title();

3
src/app/browser/main/tab/page/content.hpp

@ -42,7 +42,8 @@ namespace app::browser::main::tab::page @@ -42,7 +42,8 @@ namespace app::browser::main::tab::page
// Actions
void update(
const MIME & MIME,
const Glib::ustring & DATA
const Glib::ustring & REQUEST,
const Glib::ustring & SOURCE
);
// Getters

8
src/app/browser/main/tab/page/content/text.cpp

@ -6,7 +6,8 @@ using namespace app::browser::main::tab::page::content; @@ -6,7 +6,8 @@ using namespace app::browser::main::tab::page::content;
Text::Text(
const Type & TYPE,
const Glib::ustring & TEXT
const Glib::ustring & REQUEST,
const Glib::ustring & SOURCE
) {
switch (TYPE)
{
@ -14,7 +15,8 @@ Text::Text( @@ -14,7 +15,8 @@ Text::Text(
set_child(
* Gtk::make_managed<text::Gemini>(
TEXT,
REQUEST,
SOURCE,
title
)
);
@ -25,7 +27,7 @@ Text::Text( @@ -25,7 +27,7 @@ Text::Text(
set_child(
* Gtk::make_managed<text::Plain>(
TEXT
SOURCE
)
);

3
src/app/browser/main/tab/page/content/text.hpp

@ -30,7 +30,8 @@ namespace app::browser::main::tab::page::content @@ -30,7 +30,8 @@ namespace app::browser::main::tab::page::content
*/
Text(
const Type & TYPE,
const Glib::ustring & TEXT
const Glib::ustring & REQUEST,
const Glib::ustring & SOURCE
);
// Getters

2
src/app/browser/main/tab/page/content/text/gemini.cpp

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
using namespace app::browser::main::tab::page::content::text;
Gemini::Gemini(
const Glib::ustring & REQUEST,
const Glib::ustring & GEMTEXT,
Glib::ustring & title
) : Gtk::Viewport( // add scrolled window features to childs
@ -17,6 +18,7 @@ Gemini::Gemini( @@ -17,6 +18,7 @@ Gemini::Gemini(
set_child(
* Gtk::make_managed<gemini::Reader>(
REQUEST,
GEMTEXT,
title
)

1
src/app/browser/main/tab/page/content/text/gemini.hpp

@ -14,6 +14,7 @@ namespace app::browser::main::tab::page::content::text @@ -14,6 +14,7 @@ namespace app::browser::main::tab::page::content::text
public:
Gemini(
const Glib::ustring & REQUEST,
const Glib::ustring & GEMTEXT,
Glib::ustring & title
);

25
src/app/browser/main/tab/page/content/text/gemini/reader.cpp

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
using namespace app::browser::main::tab::page::content::text::gemini;
Reader::Reader(
const Glib::ustring & REQUEST,
const Glib::ustring & GEMTEXT,
Glib::ustring & title
) {
@ -47,6 +48,7 @@ Reader::Reader( @@ -47,6 +48,7 @@ Reader::Reader(
{
markup.append(
Make::link(
REQUEST,
address,
date,
alt
@ -245,6 +247,7 @@ Glib::ustring Reader::Make::header( @@ -245,6 +247,7 @@ Glib::ustring Reader::Make::header(
}
Glib::ustring Reader::Make::link(
const Glib::ustring & BASE,
const Glib::ustring & ADDRESS,
const Glib::ustring & DATE,
const Glib::ustring & ALT
@ -265,25 +268,15 @@ Glib::ustring Reader::Make::link( @@ -265,25 +268,15 @@ Glib::ustring Reader::Make::link(
);
}
/* @TODO
GError * error;
g_uri_resolve_relative(
get_text().c_str(),
get_text().c_str(),
G_URI_FLAGS_NONE,
&error
);
if (NULL)
*/
return Glib::ustring::sprintf(
"<a href=\"%s\" title=\"%s\">%s</a>\n",
Glib::Markup::escape_text(
ADDRESS // @TODO to absolute
g_uri_resolve_relative(
BASE.c_str(),
ADDRESS.c_str(),
G_URI_FLAGS_NONE,
NULL // GError * @TODO
)
),
Glib::Markup::escape_text(
ADDRESS

2
src/app/browser/main/tab/page/content/text/gemini/reader.hpp

@ -48,6 +48,7 @@ namespace app::browser::main::tab::page::content::text::gemini @@ -48,6 +48,7 @@ namespace app::browser::main::tab::page::content::text::gemini
);
static Glib::ustring link(
const Glib::ustring & REQUEST,
const Glib::ustring & ADDRESS,
const Glib::ustring & DATE,
const Glib::ustring & ALT
@ -68,6 +69,7 @@ namespace app::browser::main::tab::page::content::text::gemini @@ -68,6 +69,7 @@ namespace app::browser::main::tab::page::content::text::gemini
public:
Reader(
const Glib::ustring & REQUEST,
const Glib::ustring & GEMTEXT,
Glib::ustring & title
);

Loading…
Cancel
Save