mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 17:45:28 +00:00
implement page reload on request auto-routed
This commit is contained in:
parent
c31cf21149
commit
cdf3dbcf04
3 changed files with 25 additions and 5 deletions
|
|
@ -49,19 +49,25 @@ impl Page {
|
||||||
println!("Parsed URI: {}", uri); // @TODO
|
println!("Parsed URI: {}", uri); // @TODO
|
||||||
}
|
}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
// Request contain host substring
|
// Try interpret host manually
|
||||||
if Regex::match_simple(
|
if Regex::match_simple(
|
||||||
r"regex(^[^\/\s]+\.[\w]{2,})regex",
|
r"regex(^[^\/\s]+\.[\w]{2,})regex",
|
||||||
request_text.clone(),
|
request_text.clone(),
|
||||||
RegexCompileFlags::DEFAULT,
|
RegexCompileFlags::DEFAULT,
|
||||||
RegexMatchFlags::DEFAULT,
|
RegexMatchFlags::DEFAULT,
|
||||||
) {
|
) {
|
||||||
let request_text = format!("gemini://{request_text}");
|
// Seems request contain some host substring
|
||||||
// @TODO reload
|
self.navigation.set_request_text(
|
||||||
|
&GString::from(format!("gemini://{request_text}")),
|
||||||
|
true, // activate (page reload) @TODO validate new uri instead?
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
|
// Plain text given, make search request to default provider
|
||||||
Uri::escape_string(&request_text, None, false);
|
Uri::escape_string(&request_text, None, false);
|
||||||
let request_text = format!("gemini://tlgs.one/search?{request_text}");
|
self.navigation.set_request_text(
|
||||||
// @TODO reload
|
&GString::from(format!("gemini://tlgs.one/search?{request_text}")),
|
||||||
|
true, // activate (page reload)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,11 @@ impl Navigation {
|
||||||
self.bookmark.update();
|
self.bookmark.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Setters
|
||||||
|
pub fn set_request_text(&self, value: &GString, activate: bool) {
|
||||||
|
self.request.set_text(value, activate);
|
||||||
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
pub fn widget(&self) -> &Box {
|
pub fn widget(&self) -> &Box {
|
||||||
&self.widget
|
&self.widget
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,15 @@ impl Request {
|
||||||
// @TODO animate progress fraction
|
// @TODO animate progress fraction
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Setters
|
||||||
|
pub fn set_text(&self, value: &GString, activate: bool) {
|
||||||
|
self.widget.set_text(value);
|
||||||
|
|
||||||
|
if activate {
|
||||||
|
self.widget.activate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
pub fn widget(&self) -> &Entry {
|
pub fn widget(&self) -> &Entry {
|
||||||
&self.widget
|
&self.widget
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue