mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-02-06 00:14:13 +00:00
fix redirection handler
This commit is contained in:
parent
0ff182f15d
commit
acfd730c95
@ -219,7 +219,7 @@ impl Tab {
|
|||||||
pub fn save_as(&self, page_position: Option<i32>) {
|
pub fn save_as(&self, page_position: Option<i32>) {
|
||||||
if let Some(item) = self.item(page_position) {
|
if let Some(item) = self.item(page_position) {
|
||||||
item.page.navigation.request.to_download();
|
item.page.navigation.request.to_download();
|
||||||
item::page::load(&item.page, true);
|
item::page::load(&item.page, None, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ impl Tab {
|
|||||||
pub fn source(&self, page_position: Option<i32>) {
|
pub fn source(&self, page_position: Option<i32>) {
|
||||||
if let Some(item) = self.item(page_position) {
|
if let Some(item) = self.item(page_position) {
|
||||||
item.page.navigation.request.to_source();
|
item.page.navigation.request.to_source();
|
||||||
item::page::load(&item.page, true);
|
item::page::load(&item.page, None, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,7 +269,7 @@ impl Tab {
|
|||||||
/// Reload page at `i32` position or selected page on `None` given
|
/// Reload page at `i32` position or selected page on `None` given
|
||||||
pub fn page_reload(&self, page_position: Option<i32>) {
|
pub fn page_reload(&self, page_position: Option<i32>) {
|
||||||
if let Some(item) = self.item(page_position) {
|
if let Some(item) = self.item(page_position) {
|
||||||
item::page::load(&item.page, true);
|
item::page::load(&item.page, None, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,9 +73,8 @@ impl Item {
|
|||||||
|
|
||||||
if let Some(text) = request {
|
if let Some(text) = request {
|
||||||
page.navigation.request.widget.entry.set_text(&text);
|
page.navigation.request.widget.entry.set_text(&text);
|
||||||
|
|
||||||
if is_load {
|
if is_load {
|
||||||
page::load(&page, true);
|
page::load(&page, None, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +110,7 @@ impl Item {
|
|||||||
if let Some(text) = request {
|
if let Some(text) = request {
|
||||||
page.navigation.request.widget.entry.set_text(&text);
|
page.navigation.request.widget.entry.set_text(&text);
|
||||||
}
|
}
|
||||||
page::load(&page, is_history);
|
page::load(&page, None, is_history);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -239,8 +239,6 @@ impl Page {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Private helpers
|
|
||||||
|
|
||||||
// Tools
|
// Tools
|
||||||
|
|
||||||
pub fn migrate(tx: &Transaction) -> Result<(), String> {
|
pub fn migrate(tx: &Transaction) -> Result<(), String> {
|
||||||
@ -301,12 +299,8 @@ fn snap_history(profile: &Profile, navigation: &Navigation, uri: Option<&Uri>) {
|
|||||||
/// Navigate home URL (parsed from current navigation entry)
|
/// Navigate home URL (parsed from current navigation entry)
|
||||||
/// * this method create new history record in memory as defined in `action_page_open` action
|
/// * this method create new history record in memory as defined in `action_page_open` action
|
||||||
pub fn home(page: &Rc<Page>) {
|
pub fn home(page: &Rc<Page>) {
|
||||||
if let Some(url) = page.navigation.home.url() {
|
if let Some(request) = page.navigation.home.url() {
|
||||||
// Update navigation entry
|
load(page, Some(request.as_str()), false);
|
||||||
page.navigation.request.widget.entry.set_text(&url);
|
|
||||||
|
|
||||||
// Load page (with history record)
|
|
||||||
load(page, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,11 +308,7 @@ pub fn home(page: &Rc<Page>) {
|
|||||||
/// * this method does not create new history record in memory
|
/// * this method does not create new history record in memory
|
||||||
pub fn history_back(page: &Rc<Page>) {
|
pub fn history_back(page: &Rc<Page>) {
|
||||||
if let Some(request) = page.navigation.history.back(true) {
|
if let Some(request) = page.navigation.history.back(true) {
|
||||||
// Update navigation entry
|
load(page, Some(request.as_str()), false);
|
||||||
page.navigation.request.widget.entry.set_text(&request);
|
|
||||||
|
|
||||||
// Load page (without history record)
|
|
||||||
load(page, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,16 +316,15 @@ pub fn history_back(page: &Rc<Page>) {
|
|||||||
/// * this method does not create new history record in memory
|
/// * this method does not create new history record in memory
|
||||||
pub fn history_forward(page: &Rc<Page>) {
|
pub fn history_forward(page: &Rc<Page>) {
|
||||||
if let Some(request) = page.navigation.history.forward(true) {
|
if let Some(request) = page.navigation.history.forward(true) {
|
||||||
// Update navigation entry
|
load(page, Some(request.as_str()), false);
|
||||||
page.navigation.request.widget.entry.set_text(&request);
|
|
||||||
|
|
||||||
// Load page (without history record)
|
|
||||||
load(page, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Page load function with recursive redirection support
|
/// Page load function with recursive redirection support
|
||||||
pub fn load(page: &Rc<Page>, is_history: bool) {
|
pub fn load(page: &Rc<Page>, request: Option<&str>, is_history: bool) {
|
||||||
|
use client::response::{Certificate, Failure, Input, Redirect};
|
||||||
|
use client::Response;
|
||||||
|
|
||||||
// Move focus out from navigation entry
|
// Move focus out from navigation entry
|
||||||
page.browser_action
|
page.browser_action
|
||||||
.escape
|
.escape
|
||||||
@ -347,8 +336,6 @@ pub fn load(page: &Rc<Page>, is_history: bool) {
|
|||||||
// Reset widgets
|
// Reset widgets
|
||||||
page.search.unset();
|
page.search.unset();
|
||||||
page.input.unset();
|
page.input.unset();
|
||||||
|
|
||||||
// Update
|
|
||||||
page.status.replace(Status::Loading { time: now() });
|
page.status.replace(Status::Loading { time: now() });
|
||||||
page.title.replace("Loading..".into());
|
page.title.replace("Loading..".into());
|
||||||
page.browser_action.update.activate(Some(&page.id));
|
page.browser_action.update.activate(Some(&page.id));
|
||||||
@ -357,11 +344,13 @@ pub fn load(page: &Rc<Page>, is_history: bool) {
|
|||||||
snap_history(&page.profile, &page.navigation, None); // @TODO
|
snap_history(&page.profile, &page.navigation, None); // @TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
use client::response::{Certificate, Failure, Input, Redirect};
|
let query = match request {
|
||||||
use client::Response;
|
Some(query) => query,
|
||||||
|
None => &page.navigation.request.widget.entry.text(),
|
||||||
|
};
|
||||||
|
|
||||||
page.client
|
page.client
|
||||||
.request(&page.navigation.request.widget.entry.text(), {
|
.request(&query, {
|
||||||
let page = page.clone();
|
let page = page.clone();
|
||||||
move |response| {
|
move |response| {
|
||||||
match response {
|
match response {
|
||||||
@ -457,13 +446,16 @@ pub fn load(page: &Rc<Page>, is_history: bool) {
|
|||||||
},
|
},
|
||||||
Response::Redirect(this) => match this {
|
Response::Redirect(this) => match this {
|
||||||
Redirect::Background(request) => {
|
Redirect::Background(request) => {
|
||||||
println!("{}",request.as_uri());load(&page, false)
|
load(&page, Some(&request.as_uri().to_string()), false)
|
||||||
}, // @TODO
|
},
|
||||||
Redirect::Foreground(request) => {page.navigation
|
Redirect::Foreground(request) => {
|
||||||
|
page.navigation
|
||||||
.request
|
.request
|
||||||
.widget
|
.widget
|
||||||
.entry
|
.entry
|
||||||
.set_text(&request.as_uri().to_string())} // @TODO handle
|
.set_text(&request.as_uri().to_string());
|
||||||
|
load(&page, Some(&request.as_uri().to_string()), false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Response::TextGemini { base, source, is_source_request } => {
|
Response::TextGemini { base, source, is_source_request } => {
|
||||||
let widget = if is_source_request {
|
let widget = if is_source_request {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user