aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNerdyPepper <[email protected]>2018-06-24 06:10:24 +0100
committerNerdyPepper <[email protected]>2018-06-24 06:10:24 +0100
commiteaa4f3dea59a5743b89e8cd5f71c7cfb7abdc9af (patch)
treef36fa1152fecb089e20e3fafd6aabc9e666bf531 /src
parent171a260bd100f6cfc436146baad4284f04ee03e9 (diff)
Articles now have titles
Diffstat (limited to 'src')
-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}