Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
francis-du committed Jan 20, 2021
1 parent b124b26 commit efec48f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/common/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl HttpClient for ProxyClient {
{
let client = match std::env::var("PROXY") {
Ok(proxy_url) => {
info!("proxy with {}", &proxy_url);
info!("Using proxy {}", &proxy_url);
let client;
if proxy_url.contains("https://") {
client = reqwest::Client::builder()
Expand Down Expand Up @@ -67,8 +67,8 @@ pub fn set_proxy() -> Result<(), reqwest::Error> {
match json["proxy"].as_str() {
None => {}
Some(proxy) => {
std::env::set_var("PROXY", format!("http:://{}", &proxy));
info!("Setup proxy http://{}", proxy);
info!("Setup proxy http://{}", &proxy);
std::env::set_var("PROXY", format!("http://{}", proxy));
}
};

Expand Down
6 changes: 3 additions & 3 deletions src/handler/get_handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use log::{error, info};
use rand::{thread_rng, Rng};
use serde::{Deserialize, Serialize};
use tide::Request;
use wikipedia::Wikipedia;
use wikipedia::{Wikipedia};

use crate::common::network::ProxyClient;
use crate::common::semantics;
Expand Down Expand Up @@ -67,7 +67,7 @@ pub async fn search(req: Request<()>) -> tide::Result {
let language = semantics::identify(query.words.clone());
wiki.set_base_url(format!("https://{}.wikipedia.org/w/api.php", language).as_str());
}
info!("Base URL => {}", wiki.base_url());
info!("Wikipedia api address {}", wiki.base_url());

// data processing
let words = query.words.as_str();
Expand Down Expand Up @@ -106,7 +106,7 @@ pub async fn search(req: Request<()>) -> tide::Result {
}
}
Err(err) => {
error!("search keyword {} wiki error - {:?}", words.clone(), err);
error!("Search keyword `{}` wiki error,type => {:?}", words.clone(), err);
}
};
response.push(wiki_info);
Expand Down
8 changes: 4 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ enum SubCommand {
async fn main() -> tide::Result<()> {
let opts: Opts = Opts::from_args();

if opts.proxy {
network::set_proxy()?;
}

match opts.debug {
true => {
match Logger::default().level("debug").setup() {
Expand All @@ -81,6 +77,10 @@ async fn main() -> tide::Result<()> {
}
}

if opts.proxy {
network::set_proxy()?;
}

match opts.subcmd {
SubCommand::App => {
app::APP::new()
Expand Down
7 changes: 1 addition & 6 deletions src/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ <h1>Wiki Search</h1>
}

function search(words) {
document.getElementById("main").style.display = "none";
// document.getElementById("main").style.display = "none";
document.getElementById("loading").style.display = "";

$.ajax({
Expand All @@ -276,11 +276,6 @@ <h1>Wiki Search</h1>
});
}

function switchSearch() {
document.getElementById("chart").style.display = "none";
document.getElementById("main").style.display = "";
}

function draw(data) {
document.getElementById("chart").style.height = "100%";
document.getElementById("chart").style.width = "100%";
Expand Down

0 comments on commit efec48f

Please sign in to comment.