Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Adding New UI to dapps
Browse files Browse the repository at this point in the history
  • Loading branch information
tomusdrw committed Sep 21, 2016
1 parent a0b2f7e commit e26ae7f
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 18 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion dapps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,17 @@ ethcore-devtools = { path = "../devtools" }
ethcore-rpc = { path = "../rpc" }
ethcore-util = { path = "../util" }
https-fetch = { path = "../util/https-fetch" }
parity-dapps = { git = "https://github.com/ethcore/parity-ui.git", version = "1.4" }
parity-ui = { path = "./ui" }
parity-dapps-glue = { path = "./js-glue" }

### DEPRECATED
# List of apps
parity-dapps = { git = "https://github.com/ethcore/parity-ui.git", version = "1.4" }
parity-dapps-status = { git = "https://github.com/ethcore/parity-ui.git", version = "1.4" }
parity-dapps-home = { git = "https://github.com/ethcore/parity-ui.git", version = "1.4" }
parity-dapps-wallet = { git = "https://github.com/ethcore/parity-ui.git", version = "1.4", optional = true }
### /DEPRECATED

mime_guess = { version = "1.6.1" }
clippy = { version = "0.0.90", optional = true}

Expand All @@ -45,6 +51,7 @@ nightly = ["serde_macros"]
dev = ["clippy", "ethcore-rpc/dev", "ethcore-util/dev"]

use-precompiled-js = [
"parity-ui/use-precompiled-js",
"parity-dapps-status/use-precompiled-js",
"parity-dapps-home/use-precompiled-js",
"parity-dapps-wallet/use-precompiled-js"
Expand Down
57 changes: 55 additions & 2 deletions dapps/src/apps/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
use endpoint::{Endpoints, Endpoint};
use page::PageEndpoint;
use proxypac::ProxyPac;
use parity_dapps::WebApp;
use parity_dapps::{self, WebApp};
use parity_dapps_glue::WebApp as NewWebApp;

mod cache;
mod fs;
Expand All @@ -27,6 +28,7 @@ pub mod manifest;

extern crate parity_dapps_status;
extern crate parity_dapps_home;
extern crate parity_ui;

pub const DAPPS_DOMAIN : &'static str = ".parity";
pub const RPC_PATH : &'static str = "rpc";
Expand Down Expand Up @@ -57,9 +59,13 @@ pub fn all_endpoints(dapps_path: String) -> Endpoints {
pages.insert("home".into(), Box::new(
PageEndpoint::new_safe_to_embed(parity_dapps_home::App::default())
));
// NOTE [ToDr] Dapps will be currently embeded on 8180
pages.insert("ui".into(), Box::new(
PageEndpoint::new_safe_to_embed(NewUi::default())
));
pages.insert("proxy".into(), ProxyPac::boxed());
insert::<parity_dapps_status::App>(&mut pages, "parity");
insert::<parity_dapps_status::App>(&mut pages, "status");
insert::<parity_dapps_status::App>(&mut pages, "parity");

// Optional dapps
wallet_page(&mut pages);
Expand All @@ -78,3 +84,50 @@ fn wallet_page(_pages: &mut Endpoints) {}
fn insert<T : WebApp + Default + 'static>(pages: &mut Endpoints, id: &str) {
pages.insert(id.to_owned(), Box::new(PageEndpoint::new(T::default())));
}

// TODO [ToDr] Temporary wrapper until we get rid of old built-ins.
use std::collections::HashMap;

struct NewUi {
app: parity_ui::App,
files: HashMap<&'static str, parity_dapps::File>,
}

impl Default for NewUi {
fn default() -> Self {
let app = parity_ui::App::default();
let files = {
let mut files = HashMap::new();
for (k, v) in &app.files {
files.insert(*k, parity_dapps::File {
path: v.path,
content: v.content,
content_type: v.content_type,
});
}
files
};

NewUi {
app: app,
files: files,
}
}
}

impl WebApp for NewUi {
fn file(&self, path: &str) -> Option<&parity_dapps::File> {
self.files.get(path)
}

fn info(&self) -> parity_dapps::Info {
let info = self.app.info();
parity_dapps::Info {
name: info.name,
version: info.version,
author: info.author,
description: info.description,
icon_url: info.icon_url,
}
}
}
5 changes: 4 additions & 1 deletion dapps/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,17 @@ extern crate jsonrpc_core;
extern crate jsonrpc_http_server;
extern crate mime_guess;
extern crate rustc_serialize;
extern crate parity_dapps;
extern crate https_fetch;
extern crate ethcore_rpc;
extern crate ethcore_util as util;
extern crate linked_hash_map;
#[cfg(test)]
extern crate ethcore_devtools as devtools;

extern crate parity_dapps_glue;
// TODO [ToDr] - Deprecate when we get rid of old dapps.
extern crate parity_dapps;

mod endpoint;
mod apps;
mod page;
Expand Down
6 changes: 3 additions & 3 deletions dapps/ui/src/lib.rs.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use parity_dapps_glue::{WebApp, File, Info};
#[derive(WebAppFiles)]
#[webapp(path = "./web")]
pub struct App {
files: HashMap<&'static str, File>,
pub files: HashMap<&'static str, File>,
}

impl Default for App {
Expand All @@ -40,10 +40,10 @@ impl WebApp for App {

fn info(&self) -> Info {
Info {
name: "Parity Home Screen",
name: "Parity UI",
version: env!("CARGO_PKG_VERSION"),
author: "Ethcore <admin@ethcore.io>",
description: "Home Screen and injectable topbar for Parity Dapps.",
description: "New UI for Parity. (Experimental)",
icon_url: "icon.png",
}
}
Expand Down
6 changes: 3 additions & 3 deletions dapps/ui/src/web/gavcoin.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
</head>
<body>
<div id="container"></div>
<script src="/commons.js"></script>
<script src="/parity.js"></script>
<script src="/gavcoin.js"></script>
<script src="commons.js"></script>
<script src="parity.js"></script>
<script src="gavcoin.js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion dapps/ui/src/web/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dapps/ui/src/web/parity.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dapps/ui/src/web/registry.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
</head>
<body>
<div id="container"></div>
<script src="/commons.js"></script>
<script src="/parity.js"></script>
<script src="/registry.js"></script>
<script src="commons.js"></script>
<script src="parity.js"></script>
<script src="registry.js"></script>
</body>
</html>
6 changes: 3 additions & 3 deletions dapps/ui/src/web/tokenreg.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
</head>
<body>
<div id="container"></div>
<script src="/commons.js"></script>
<script src="/parity.js"></script>
<script src="/tokenreg.js"></script>
<script src="commons.js"></script>
<script src="parity.js"></script>
<script src="tokenreg.js"></script>
</body>
</html>

0 comments on commit e26ae7f

Please sign in to comment.