mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 17:45:28 +00:00
draft gemtext route
This commit is contained in:
parent
af6b1efe32
commit
a73bb3aea6
8 changed files with 118 additions and 9 deletions
1
Makefile
1
Makefile
|
|
@ -14,6 +14,7 @@ SRCS = src/main.cpp\
|
||||||
src/app/browser/main/tab.cpp\
|
src/app/browser/main/tab.cpp\
|
||||||
src/app/browser/main/tab/page.cpp\
|
src/app/browser/main/tab/page.cpp\
|
||||||
src/app/browser/main/tab/page/content.cpp\
|
src/app/browser/main/tab/page/content.cpp\
|
||||||
|
src/app/browser/main/tab/page/content/text/gemini.cpp\
|
||||||
src/app/browser/main/tab/page/navbar.cpp\
|
src/app/browser/main/tab/page/navbar.cpp\
|
||||||
src/app/browser/main/tab/page/navbar/base.cpp\
|
src/app/browser/main/tab/page/navbar/base.cpp\
|
||||||
src/app/browser/main/tab/page/navbar/bookmark.cpp\
|
src/app/browser/main/tab/page/navbar/bookmark.cpp\
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ src/app/browser/main.cpp
|
||||||
src/app/browser/main/tab.cpp
|
src/app/browser/main/tab.cpp
|
||||||
src/app/browser/main/tab/page.cpp
|
src/app/browser/main/tab/page.cpp
|
||||||
src/app/browser/main/tab/page/content.cpp
|
src/app/browser/main/tab/page/content.cpp
|
||||||
|
src/app/browser/main/tab/page/content/text/gemini.cpp
|
||||||
src/app/browser/main/tab/page/navbar.cpp
|
src/app/browser/main/tab/page/navbar.cpp
|
||||||
src/app/browser/main/tab/page/navbar/base.cpp
|
src/app/browser/main/tab/page/navbar/base.cpp
|
||||||
src/app/browser/main/tab/page/navbar/bookmark.cpp
|
src/app/browser/main/tab/page/navbar/bookmark.cpp
|
||||||
|
|
|
||||||
|
|
@ -96,15 +96,39 @@ void Page::update()
|
||||||
[this](const Glib::RefPtr<Gio::AsyncResult> & result)
|
[this](const Glib::RefPtr<Gio::AsyncResult> & result)
|
||||||
{
|
{
|
||||||
// Response
|
// Response
|
||||||
socket_connection->get_input_stream()->read_all_async( // | read_async
|
socket_connection->get_input_stream()->read_async( // | read_all_async
|
||||||
buffer,
|
buffer,
|
||||||
sizeof(buffer) - 1,
|
sizeof(buffer) - 1,
|
||||||
[this](const Glib::RefPtr<Gio::AsyncResult> & result)
|
[this](const Glib::RefPtr<Gio::AsyncResult> & result)
|
||||||
{
|
{
|
||||||
content->set(
|
// Parse meta
|
||||||
|
auto meta = Glib::Regex::split_simple(
|
||||||
|
R"regex(^(\d+)?\s([\w]+\/[\w]+)?)regex",
|
||||||
buffer
|
buffer
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Route by status code
|
||||||
|
if (meta[1] == "20")
|
||||||
|
{
|
||||||
|
// Route by mime type
|
||||||
|
if (meta[2] == "text/gemini")
|
||||||
|
{
|
||||||
|
content->text_gemini(
|
||||||
|
buffer // @TODO
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// @TODO exception
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// @TODO exception
|
||||||
|
}
|
||||||
|
|
||||||
socket_connection->close();
|
socket_connection->close();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
#include <giomm/socketclient.h>
|
#include <giomm/socketclient.h>
|
||||||
#include <giomm/socketconnection.h>
|
#include <giomm/socketconnection.h>
|
||||||
#include <glibmm/refptr.h>
|
#include <glibmm/refptr.h>
|
||||||
|
#include <glibmm/regex.h>
|
||||||
#include <glibmm/ustring.h>
|
#include <glibmm/ustring.h>
|
||||||
#include <gtkmm/box.h>
|
#include <gtkmm/box.h>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include "content.hpp"
|
#include "content.hpp"
|
||||||
|
#include "content/text/gemini.hpp"
|
||||||
|
|
||||||
using namespace app::browser::main::tab::page;
|
using namespace app::browser::main::tab::page;
|
||||||
|
|
||||||
|
|
@ -11,12 +12,44 @@ Content::Content()
|
||||||
set_homogeneous(
|
set_homogeneous(
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
|
widget = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Content::~Content() = default;
|
Content::~Content()
|
||||||
|
{
|
||||||
|
delete widget;
|
||||||
|
};
|
||||||
|
|
||||||
void Content::set(
|
// Public actions
|
||||||
const Glib::ustring & buffer
|
void Content::text_gemini(
|
||||||
|
const Glib::ustring & gemtext
|
||||||
) {
|
) {
|
||||||
// @TODO
|
update(
|
||||||
|
new content::text::Gemini(
|
||||||
|
gemtext
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// @TODO text_plain, picture, video, etc.
|
||||||
|
|
||||||
|
// Private helpers
|
||||||
|
void Content::update(
|
||||||
|
Gtk::Widget * new_widget
|
||||||
|
) {
|
||||||
|
if (widget != nullptr)
|
||||||
|
{
|
||||||
|
remove(
|
||||||
|
* widget
|
||||||
|
);
|
||||||
|
|
||||||
|
delete widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
widget = new_widget;
|
||||||
|
|
||||||
|
append(
|
||||||
|
* widget
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -1,21 +1,28 @@
|
||||||
#ifndef APP_BROWSER_MAIN_TAB_PAGE_CONTENT_HPP
|
#ifndef APP_BROWSER_MAIN_TAB_PAGE_CONTENT_HPP
|
||||||
#define APP_BROWSER_MAIN_TAB_PAGE_CONTENT_HPP
|
#define APP_BROWSER_MAIN_TAB_PAGE_CONTENT_HPP
|
||||||
|
|
||||||
#include <gtkmm/box.h>
|
|
||||||
#include <glibmm/ustring.h>
|
#include <glibmm/ustring.h>
|
||||||
|
#include <gtkmm/box.h>
|
||||||
|
#include <gtkmm/widget.h>
|
||||||
|
|
||||||
namespace app::browser::main::tab::page
|
namespace app::browser::main::tab::page
|
||||||
{
|
{
|
||||||
class Content : public Gtk::Box
|
class Content : public Gtk::Box
|
||||||
{
|
{
|
||||||
|
Gtk::Widget * widget;
|
||||||
|
|
||||||
|
void update(
|
||||||
|
Gtk::Widget * new_widget
|
||||||
|
);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Content();
|
Content();
|
||||||
|
|
||||||
~Content();
|
~Content();
|
||||||
|
|
||||||
void set(
|
void text_gemini(
|
||||||
const Glib::ustring & buffer
|
const Glib::ustring & gemtext
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
21
src/app/browser/main/tab/page/content/text/gemini.cpp
Normal file
21
src/app/browser/main/tab/page/content/text/gemini.cpp
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
#include "gemini.hpp"
|
||||||
|
|
||||||
|
using namespace app::browser::main::tab::page::content::text;
|
||||||
|
|
||||||
|
Gemini::Gemini(
|
||||||
|
const Glib::ustring & gemtext
|
||||||
|
) {
|
||||||
|
set_wrap(
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
set_selectable(
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
set_markup(
|
||||||
|
gemtext // @TODO
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Gemini::~Gemini() = default;
|
||||||
21
src/app/browser/main/tab/page/content/text/gemini.hpp
Normal file
21
src/app/browser/main/tab/page/content/text/gemini.hpp
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
#ifndef APP_BROWSER_MAIN_TAB_PAGE_CONTENT_TEXT_GEMINI_HPP
|
||||||
|
#define APP_BROWSER_MAIN_TAB_PAGE_CONTENT_TEXT_GEMINI_HPP
|
||||||
|
|
||||||
|
#include <glibmm/ustring.h>
|
||||||
|
#include <gtkmm/label.h>
|
||||||
|
|
||||||
|
namespace app::browser::main::tab::page::content::text
|
||||||
|
{
|
||||||
|
class Gemini : public Gtk::Label
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
Gemini(
|
||||||
|
const Glib::ustring & gemtext
|
||||||
|
);
|
||||||
|
|
||||||
|
~Gemini();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // APP_BROWSER_MAIN_TAB_PAGE_CONTENT_TEXT_GEMINI_HPP
|
||||||
Loading…
Add table
Add a link
Reference in a new issue