diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 20 |
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; | |||
3 | extern crate cursive; | 3 | extern crate cursive; |
4 | 4 | ||
5 | use cursive::Cursive; | 5 | use cursive::Cursive; |
6 | use cursive::align::HAlign; | ||
6 | use cursive::traits::*; | 7 | use cursive::traits::*; |
7 | use cursive::views::{TextView, Dialog, EditView, SelectView}; | 8 | use cursive::views::{TextView, Dialog, EditView, SelectView, LinearLayout, DummyView}; |
8 | 9 | ||
9 | pub mod content; | 10 | pub mod content; |
10 | use content::*; | 11 | use content::*; |
@@ -57,17 +58,22 @@ fn search(s: &mut Cursive){ | |||
57 | fn on_submit(s: &mut Cursive, name: &String) { | 58 | fn 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 | } |