aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs
index d41e6b2..c59a3f1 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -64,23 +64,26 @@ fn search(s: &mut Cursive){
64fn on_submit(s: &mut Cursive, name: &String) { 64fn on_submit(s: &mut Cursive, name: &String) {
65 s.pop_layer(); 65 s.pop_layer();
66 66
67 // get article data
67 let heading: String = name.clone(); 68 let heading: String = name.clone();
68 let url = query_url_gen(&name.replace(" ", "_")); 69 let url = query_url_gen(&name.replace(" ", "_"));
69 let res = reqwest::get(&url).unwrap(); 70 let res = reqwest::get(&url).unwrap();
70 let mut extract = String::new(); 71 let mut extract = String::new();
71 72
73 // handle errors if any
72 match get_extract(res) { 74 match get_extract(res) {
73 Ok(x) => extract = x, 75 Ok(x) => extract = x,
74 Err(e) => pop_error(s, handler(e)) 76 Err(e) => pop_error(s, handler(e))
75 }; 77 };
76 78
79 // get the act together
80 let mut article = TextView::new(heading);
81 article.append(String::from("\n\n"));
82 article.append(extract_formatter(extract));
77 s.add_layer( 83 s.add_layer(
78 Dialog::around( 84 OnEventView::new(
79 OnEventView::new(TextView::new(extract_formatter(extract))) 85 article.fixed_width(72)
80 .on_event('t', |s| match s.pop_layer() { _ => () })
81 ) 86 )
82 .title(heading) 87 .on_event('t', |s| match s.pop_layer() { _ => () })
83 .padding_right(2)
84 .padding_left(2)
85 ); 88 );
86} 89}