mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
move request route action to the page level
This commit is contained in:
parent
85115c1267
commit
c31cf21149
2 changed files with 29 additions and 33 deletions
|
|
@ -1,7 +1,4 @@
|
||||||
use gtk::{
|
use gtk::{Box, Orientation};
|
||||||
glib::{GString, Regex, RegexCompileFlags, RegexMatchFlags, Uri, UriFlags},
|
|
||||||
Box, Orientation,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub struct Content {
|
pub struct Content {
|
||||||
widget: Box,
|
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
|
// Getters
|
||||||
pub fn widget(&self) -> &Box {
|
pub fn widget(&self) -> &Box {
|
||||||
&self.widget
|
&self.widget
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,11 @@ mod navigation;
|
||||||
use content::Content;
|
use content::Content;
|
||||||
use navigation::Navigation;
|
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 {
|
pub struct Page {
|
||||||
widget: Box,
|
widget: Box,
|
||||||
|
|
@ -38,7 +42,29 @@ impl Page {
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
pub fn reload(&self) {
|
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) {
|
pub fn update(&self) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue