aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNerdyPepper <[email protected]>2018-07-06 15:53:02 +0100
committerNerdyPepper <[email protected]>2018-07-06 15:53:02 +0100
commitb57367e72754474d38a08a7aa3e75823971ee4a5 (patch)
tree4c0e1319c62bab793b85ac5c358d5c60a20eed46 /src
parentc86eb64d34fb185215bb8924e52f5e4af08ba2aa (diff)
Simplify article layer
Diffstat (limited to 'src')
-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}