From 27d26adddb59b96ebb3f5f4404c8994332c5ff74 Mon Sep 17 00:00:00 2001 From: Face <69168154+face-hh@users.noreply.github.com> Date: Fri, 7 Jun 2024 18:57:08 +0300 Subject: [PATCH 1/7] version bump --- napture/Cargo.lock | 2 +- napture/Cargo.toml | 2 +- napture/src/main.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/napture/Cargo.lock b/napture/Cargo.lock index 88fb292e..15805902 100644 --- a/napture/Cargo.lock +++ b/napture/Cargo.lock @@ -2121,7 +2121,7 @@ dependencies = [ [[package]] name = "webx" -version = "1.2.2" +version = "1.3.0" dependencies = [ "base64", "chrono", diff --git a/napture/Cargo.toml b/napture/Cargo.toml index 9da098b7..25cae9e1 100644 --- a/napture/Cargo.toml +++ b/napture/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "webx" -version = "1.2.2" +version = "1.3.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/napture/src/main.rs b/napture/src/main.rs index 67623183..4911466d 100644 --- a/napture/src/main.rs +++ b/napture/src/main.rs @@ -495,7 +495,7 @@ fn make_tab( let dialog = gtk::AboutDialog::builder() .modal(true) .program_name("Bussin Napture") - .version("v1.2.2") + .version("v1.3.0") .website("https://github.com/face-hh/webx") .website_label("GitHub") .license_type(gtk::License::Apache20) From 4a77d4e99aa1207eb4380e9084ddc9664492541d Mon Sep 17 00:00:00 2001 From: JanluOfficial <95766563+JanluOfficial@users.noreply.github.com> Date: Fri, 14 Jun 2024 11:20:16 +0200 Subject: [PATCH 2/7] Update not_found.html --- napture/src/resources/not_found.html | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/napture/src/resources/not_found.html b/napture/src/resources/not_found.html index d0154c53..8c2c6620 100644 --- a/napture/src/resources/not_found.html +++ b/napture/src/resources/not_found.html @@ -7,10 +7,12 @@ - -

The website doesn't exist :(

+
+ +

The website doesn't exist :(

- Go to the search engine? + Go to the search engine? +
- \ No newline at end of file + From ddf52fa46f5226ad862762e2de6613e627367471 Mon Sep 17 00:00:00 2001 From: JanluOfficial <95766563+JanluOfficial@users.noreply.github.com> Date: Fri, 14 Jun 2024 11:20:38 +0200 Subject: [PATCH 3/7] Create notfound.css --- napture/src/resources/notfound.css | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 napture/src/resources/notfound.css diff --git a/napture/src/resources/notfound.css b/napture/src/resources/notfound.css new file mode 100644 index 00000000..b1141314 --- /dev/null +++ b/napture/src/resources/notfound.css @@ -0,0 +1,3 @@ +sadge { + align-items: center; +} From 0b1748edf420b357c7dab6363e9f1c162701633a Mon Sep 17 00:00:00 2001 From: JanluOfficial <95766563+JanluOfficial@users.noreply.github.com> Date: Fri, 14 Jun 2024 11:25:36 +0200 Subject: [PATCH 4/7] Delete napture/src/resources/notfound.css --- napture/src/resources/notfound.css | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 napture/src/resources/notfound.css diff --git a/napture/src/resources/notfound.css b/napture/src/resources/notfound.css deleted file mode 100644 index b1141314..00000000 --- a/napture/src/resources/notfound.css +++ /dev/null @@ -1,3 +0,0 @@ -sadge { - align-items: center; -} From c867a62d2110a7836b0c8433ba248ade002b196d Mon Sep 17 00:00:00 2001 From: JanluOfficial <95766563+JanluOfficial@users.noreply.github.com> Date: Fri, 14 Jun 2024 11:25:53 +0200 Subject: [PATCH 5/7] Update not_found.html --- napture/src/resources/not_found.html | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/napture/src/resources/not_found.html b/napture/src/resources/not_found.html index 8c2c6620..042b3fb2 100644 --- a/napture/src/resources/not_found.html +++ b/napture/src/resources/not_found.html @@ -7,12 +7,10 @@ -
- -

The website doesn't exist :(

+ +

The website doesn't exist :(

- Go to the search engine? -
+ Go to the search engine? From f1fdd2713b66488a22190dc2bb73690ac6565552 Mon Sep 17 00:00:00 2001 From: JanluOfficial <95766563+JanluOfficial@users.noreply.github.com> Date: Sun, 16 Jun 2024 18:52:44 +0200 Subject: [PATCH 6/7] Add Has src for image, text for text and size for size. --- napture/src/b9/html.rs | 106 +++++++++++++++++++++++++++++++++-------- 1 file changed, 85 insertions(+), 21 deletions(-) diff --git a/napture/src/b9/html.rs b/napture/src/b9/html.rs index dd757797..c8a6c3a0 100644 --- a/napture/src/b9/html.rs +++ b/napture/src/b9/html.rs @@ -9,8 +9,9 @@ use super::{ use std::{cell::RefCell, fs, rc::Rc, thread}; -use glib::clone; use gtk::{gdk::Display, gdk_pixbuf, gio, glib::Bytes, prelude::*, CssProvider}; +use adw::Avatar; + use html_parser::{Dom, Element, Node, Result}; use lua::Luable; @@ -66,7 +67,7 @@ async fn parse_html(mut url: String) -> Result<(Node, Node)> { Some(head) => head, None => { return Err(html_parser::Error::Parsing( - "Couldn't find head. Invalid HTML?".to_owned(), + "Couetch_imageldn't find head. Invalid HTML?".to_owned(), )) } }; @@ -97,6 +98,7 @@ fn find_element_by_name(elements: &Vec, name: &str) -> Option { None } +#[tokio::main] pub async fn build_ui( tab: Tab, previous_css_provider: Option, @@ -525,7 +527,6 @@ fn render_html( Some(Some(t)) => t.to_string(), _ => "text".to_string(), }; - if input_type == "text" { let entry = gtk::Entry::builder() .placeholder_text( @@ -599,7 +600,6 @@ fn render_html( textview .buffer() .set_text(&decode_html_entities(element.children.first().unwrap_or(&Node::Text(String::new())).text().unwrap_or(""))); - html_view.append(&textview); tags.borrow_mut().push(Tag { @@ -630,10 +630,75 @@ fn render_html( tags.borrow_mut().push(Tag { classes: element.classes.clone(), - widget: Box::new(button), - tied_variables: Vec::new(), + widget: Box::new(button), + tied_variables: Vec::new(), }); } + "avatar" => { + let size_atr = element.attributes.get("size"); + let mut av_size = 48; + if size_atr != None { + match size_atr.unwrap().as_ref().unwrap().as_str() { + "xs" => { + av_size = 16; + } + "s" => { + av_size = 32; + } + "m" => { + av_size = 48; + } + "l" => { + av_size = 64; + } + "xl" => { + av_size = 96; + } + "caseoh" => { + av_size = 1024; + } + _ => { + let size: i32 = size_atr.unwrap().as_ref().unwrap().as_str().parse().unwrap_or(48); + av_size = size.clone(); + } + } + }; + + let avatar = Avatar::builder() + .size(av_size) + .show_initials(true) + .icon_name("avatar-default-symbolic") + .css_name("avatar") + .css_classes(element.classes.clone()) + .build(); + + let text = element.attributes.get("text"); + if text != None { + avatar.set_text(Some(text.unwrap().as_ref().unwrap().as_str())); + } + + let image = element.attributes.get("src"); + if image != None { + let stream = match fetch_image_to_pixbuf(image.clone().unwrap().as_ref().unwrap().to_string()) { + Ok(s) => s, + Err(e) => { + println!("ERROR: Failed to load image: {}", e); + return; + } + }; + avatar.set_custom_image(Some(>k::gdk::Texture::for_pixbuf(&stream))); + }; + + //css.push_str(&avatar.style()); + + html_view.append(&avatar); + + //tags.borrow_mut().push(Tag { + // classes: element.classes.clone(), + // widget: Box::new(Avatar), + // tied_variables: Vec::new(), + //}); + } _ => { println!("INFO: Unknown element: {}", element.name); } @@ -670,28 +735,27 @@ fn render_a( previous_css_provider.unwrap_or(CssProvider::new()), )); - link_button.connect_activate_link(clone!(@strong scroll, @strong rc_css_prov, @strong current_tab, @strong searchbar => move |btn| { + link_button.connect_activate_link(move |btn| { + let scroll = Rc::clone(&scroll); + let css_prov = Rc::clone(&rc_css_prov); + + let current_tab = Rc::clone(¤t_tab); + let searchbar = Rc::clone(&searchbar); + let uri = btn.uri(); - + if !uri.starts_with("buss://") { return glib::Propagation::Proceed; } - + let uri = uri.replace("buss://", ""); + searchbar.borrow_mut().set_text(&uri); - - let scroll = Rc::clone(&scroll); - let css_prov = Rc::clone(&rc_css_prov); - let current_tab = Rc::clone(¤t_tab); - let searchbar = Rc::clone(&searchbar); - - // Spawn an async task - glib::MainContext::default().spawn_local(async move { - crate::handle_search_update(scroll, css_prov, current_tab, searchbar).await; - }); - + + crate::handle_search_update(scroll, css_prov, current_tab, searchbar); + glib::Propagation::Stop - })); + }); css.push_str(&link_button.style()); From 059bdac987eeb42b62ff675c912a5982d61c2a71 Mon Sep 17 00:00:00 2001 From: JanluOfficial <95766563+JanluOfficial@users.noreply.github.com> Date: Sun, 16 Jun 2024 23:17:48 +0200 Subject: [PATCH 7/7] Fixed html.rs --- napture/src/b9/html.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/napture/src/b9/html.rs b/napture/src/b9/html.rs index c8a6c3a0..dd6ba6b4 100644 --- a/napture/src/b9/html.rs +++ b/napture/src/b9/html.rs @@ -67,7 +67,7 @@ async fn parse_html(mut url: String) -> Result<(Node, Node)> { Some(head) => head, None => { return Err(html_parser::Error::Parsing( - "Couetch_imageldn't find head. Invalid HTML?".to_owned(), + "Couldn't find head. Invalid HTML?".to_owned(), )) } };