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(
// Set content driver // Set content driver
pageContent->update( pageContent->update(
page::Content::TEXT_GEMINI, page::Content::TEXT_GEMINI,
pageNavigation->get_request_text(),
buffer buffer
); );

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

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

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

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

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

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

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

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

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

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

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

@ -3,6 +3,7 @@
using namespace app::browser::main::tab::page::content::text::gemini; using namespace app::browser::main::tab::page::content::text::gemini;
Reader::Reader( Reader::Reader(
const Glib::ustring & REQUEST,
const Glib::ustring & GEMTEXT, const Glib::ustring & GEMTEXT,
Glib::ustring & title Glib::ustring & title
) { ) {
@ -47,6 +48,7 @@ Reader::Reader(
{ {
markup.append( markup.append(
Make::link( Make::link(
REQUEST,
address, address,
date, date,
alt alt
@ -245,6 +247,7 @@ Glib::ustring Reader::Make::header(
} }
Glib::ustring Reader::Make::link( Glib::ustring Reader::Make::link(
const Glib::ustring & BASE,
const Glib::ustring & ADDRESS, const Glib::ustring & ADDRESS,
const Glib::ustring & DATE, const Glib::ustring & DATE,
const Glib::ustring & ALT const Glib::ustring & ALT
@ -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( return Glib::ustring::sprintf(
"<a href=\"%s\" title=\"%s\">%s</a>\n", "<a href=\"%s\" title=\"%s\">%s</a>\n",
Glib::Markup::escape_text( 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( Glib::Markup::escape_text(
ADDRESS 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
); );
static Glib::ustring link( static Glib::ustring link(
const Glib::ustring & REQUEST,
const Glib::ustring & ADDRESS, const Glib::ustring & ADDRESS,
const Glib::ustring & DATE, const Glib::ustring & DATE,
const Glib::ustring & ALT const Glib::ustring & ALT
@ -68,6 +69,7 @@ namespace app::browser::main::tab::page::content::text::gemini
public: public:
Reader( Reader(
const Glib::ustring & REQUEST,
const Glib::ustring & GEMTEXT, const Glib::ustring & GEMTEXT,
Glib::ustring & title Glib::ustring & title
); );

Loading…
Cancel
Save