aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.rs20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs
index d38d474..aa10691 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -3,8 +3,9 @@ extern crate serde_json;
3extern crate cursive; 3extern crate cursive;
4 4
5use cursive::Cursive; 5use cursive::Cursive;
6use cursive::align::HAlign;
6use cursive::traits::*; 7use cursive::traits::*;
7use cursive::views::{TextView, Dialog, EditView, SelectView}; 8use cursive::views::{TextView, Dialog, EditView, SelectView, LinearLayout, DummyView};
8 9
9pub mod content; 10pub mod content;
10use content::*; 11use content::*;
@@ -57,17 +58,22 @@ fn search(s: &mut Cursive){
57fn on_submit(s: &mut Cursive, name: &String) { 58fn on_submit(s: &mut Cursive, name: &String) {
58 s.pop_layer(); 59 s.pop_layer();
59 60
60 let title = name.replace(" ", "_"); 61 let heading: String = name.clone();
61 let url = query_url_gen(&title); 62 let url = query_url_gen(&name.replace(" ", "_"));
62 let res = reqwest::get(&url).unwrap(); 63 let res = reqwest::get(&url).unwrap();
63 64
64 let mut extract = String::new(); 65 let mut extract = String::new();
65 66
66 match content::get_extract(res) { 67 match get_extract(res) {
67
68 Ok(x) => extract = x, 68 Ok(x) => extract = x,
69 Err(e) => pop_error(s, content::handler(e)) 69 Err(e) => pop_error(s, handler(e))
70 }; 70 };
71 71
72 s.add_layer(TextView::new(extract)); 72 s.add_layer(
73 LinearLayout::vertical()
74 .child(TextView::new(heading).h_align(HAlign::Center))
75 .child(DummyView.fixed_height(1))
76 .child(TextView::new(extract)
77 .fixed_width(85))
78 );
73} 79}