From eaa4f3dea59a5743b89e8cd5f71c7cfb7abdc9af Mon Sep 17 00:00:00 2001 From: NerdyPepper Date: Sun, 24 Jun 2018 10:40:24 +0530 Subject: Articles now have titles --- src/main.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src') 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; extern crate cursive; use cursive::Cursive; +use cursive::align::HAlign; use cursive::traits::*; -use cursive::views::{TextView, Dialog, EditView, SelectView}; +use cursive::views::{TextView, Dialog, EditView, SelectView, LinearLayout, DummyView}; pub mod content; use content::*; @@ -57,17 +58,22 @@ fn search(s: &mut Cursive){ fn on_submit(s: &mut Cursive, name: &String) { s.pop_layer(); - let title = name.replace(" ", "_"); - let url = query_url_gen(&title); + let heading: String = name.clone(); + let url = query_url_gen(&name.replace(" ", "_")); let res = reqwest::get(&url).unwrap(); let mut extract = String::new(); - match content::get_extract(res) { - + match get_extract(res) { Ok(x) => extract = x, - Err(e) => pop_error(s, content::handler(e)) + Err(e) => pop_error(s, handler(e)) }; - s.add_layer(TextView::new(extract)); + s.add_layer( + LinearLayout::vertical() + .child(TextView::new(heading).h_align(HAlign::Center)) + .child(DummyView.fixed_height(1)) + .child(TextView::new(extract) + .fixed_width(85)) + ); } -- cgit v1.2.3