[beta] Updating UI (#1778)

* Updating UI

* Fix for building without UI
This commit is contained in:
Tomasz Drwięga
2016-07-31 12:54:02 +02:00
committed by Arkadiy Paronyan
parent 03fad0869e
commit 8b658b257f
8 changed files with 70 additions and 57 deletions

View File

@@ -18,9 +18,11 @@ env_logger = "0.3"
ws = { git = "https://github.com/ethcore/ws-rs.git", branch = "stable" }
ethcore-util = { path = "../util" }
ethcore-rpc = { path = "../rpc" }
parity-minimal-sysui = { git = "https://github.com/ethcore/parity-dapps-minimal-sysui-rs.git", version = "0.2.0" }
parity-dapps-signer = { git = "https://github.com/ethcore/parity-ui.git", version = "0.6", optional = true}
clippy = { version = "0.0.77", optional = true}
[features]
dev = ["clippy"]
ui = ["parity-dapps-signer"]
use-precompiled-js = ["parity-dapps-signer/use-precompiled-js"]

View File

@@ -51,7 +51,8 @@ extern crate ethcore_util as util;
extern crate ethcore_rpc as rpc;
extern crate jsonrpc_core;
extern crate ws;
extern crate parity_minimal_sysui as sysui;
#[cfg(feature = "ui")]
extern crate parity_dapps_signer as signer;
mod authcode_store;
mod ws_server;

View File

@@ -17,7 +17,6 @@
//! Session handlers factory.
use ws;
use sysui;
use authcode_store::AuthCodes;
use std::path::{PathBuf, Path};
use std::sync::Arc;
@@ -25,6 +24,26 @@ use std::str::FromStr;
use jsonrpc_core::IoHandler;
use util::H256;
#[cfg(feature = "ui")]
mod signer {
use signer;
pub fn handle(req: &str) -> Option<signer::File> {
signer::handle(req)
}
}
#[cfg(not(feature = "ui"))]
mod signer {
pub struct File {
pub content: String,
pub mime: String,
}
pub fn handle(_req: &str) -> Option<File> {
None
}
}
fn origin_is_allowed(self_origin: &str, header: Option<&Vec<u8>>) -> bool {
match header {
None => false,
@@ -111,7 +130,7 @@ impl ws::Handler for Session {
}
// Otherwise try to serve a page.
Ok(sysui::handle(req.resource())
Ok(signer::handle(req.resource())
.map_or_else(
// return 404 not found
|| add_headers(ws::Response::not_found("Not found".into()), "text/plain"),