mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-03-13 06:01:21 +00:00
move request route action to the page level
This commit is contained in:
parent
85115c1267
commit
c31cf21149
@ -1,7 +1,4 @@
|
||||
use gtk::{
|
||||
glib::{GString, Regex, RegexCompileFlags, RegexMatchFlags, Uri, UriFlags},
|
||||
Box, Orientation,
|
||||
};
|
||||
use gtk::{Box, Orientation};
|
||||
|
||||
pub struct Content {
|
||||
widget: Box,
|
||||
@ -15,33 +12,6 @@ impl Content {
|
||||
}
|
||||
}
|
||||
|
||||
// Actions
|
||||
pub fn reload(&self, request_text: GString) {
|
||||
/*let _uri = */
|
||||
match Uri::parse(&request_text, UriFlags::NONE) {
|
||||
Ok(uri) => {
|
||||
println!("Parsed URI: {}", uri); // @TODO
|
||||
}
|
||||
Err(_) => {
|
||||
// Request contain host substring
|
||||
if Regex::match_simple(
|
||||
r"regex(^[^\/\s]+\.[\w]{2,})regex",
|
||||
request_text.clone(),
|
||||
RegexCompileFlags::DEFAULT,
|
||||
RegexMatchFlags::DEFAULT,
|
||||
) {
|
||||
let request_text = format!("gemini://{request_text}");
|
||||
// @TODO reload
|
||||
} else {
|
||||
Uri::escape_string(&request_text, None, false);
|
||||
let request_text = format!("gemini://tlgs.one/search?{request_text}");
|
||||
// @TODO reload
|
||||
}
|
||||
}
|
||||
};
|
||||
// @TODO
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &Box {
|
||||
&self.widget
|
||||
|
@ -4,7 +4,11 @@ mod navigation;
|
||||
use content::Content;
|
||||
use navigation::Navigation;
|
||||
|
||||
use gtk::{glib::GString, prelude::BoxExt, Box, Orientation};
|
||||
use gtk::{
|
||||
glib::{GString, Regex, RegexCompileFlags, RegexMatchFlags, Uri, UriFlags},
|
||||
prelude::BoxExt,
|
||||
Box, Orientation,
|
||||
};
|
||||
|
||||
pub struct Page {
|
||||
widget: Box,
|
||||
@ -38,7 +42,29 @@ impl Page {
|
||||
|
||||
// Actions
|
||||
pub fn reload(&self) {
|
||||
self.content.reload(self.navigation.request_text());
|
||||
let request_text = self.navigation.request_text();
|
||||
/*let _uri = */
|
||||
match Uri::parse(&request_text, UriFlags::NONE) {
|
||||
Ok(uri) => {
|
||||
println!("Parsed URI: {}", uri); // @TODO
|
||||
}
|
||||
Err(_) => {
|
||||
// Request contain host substring
|
||||
if Regex::match_simple(
|
||||
r"regex(^[^\/\s]+\.[\w]{2,})regex",
|
||||
request_text.clone(),
|
||||
RegexCompileFlags::DEFAULT,
|
||||
RegexMatchFlags::DEFAULT,
|
||||
) {
|
||||
let request_text = format!("gemini://{request_text}");
|
||||
// @TODO reload
|
||||
} else {
|
||||
Uri::escape_string(&request_text, None, false);
|
||||
let request_text = format!("gemini://tlgs.one/search?{request_text}");
|
||||
// @TODO reload
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub fn update(&self) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user