summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornatrixaeria <janng@gmx.de>2019-05-29 21:51:49 +0200
committernatrixaeria <janng@gmx.de>2019-05-29 21:51:49 +0200
commitbf0137c3fc6093df085b9d95cd251b7f67d94815 (patch)
tree435f024e02e4f0bd867d1ca5a829d3ef19a97545
parenta6d2d62fae44b6d8c96e51055f7222bc679efc48 (diff)
Create webhogg project directory
-rw-r--r--WebInterface/wasm/webhogg/Cargo.toml29
-rwxr-xr-xWebInterface/wasm/webhogg/deploy2
-rw-r--r--WebInterface/wasm/webhogg/index.html24
-rw-r--r--WebInterface/wasm/webhogg/lighttpd.config29
-rw-r--r--WebInterface/wasm/webhogg/loader.js2
-rwxr-xr-xWebInterface/wasm/webhogg/run3
-rw-r--r--WebInterface/wasm/webhogg/src/app.rs15
-rw-r--r--WebInterface/wasm/webhogg/src/client_logger.rs46
-rw-r--r--WebInterface/wasm/webhogg/src/lib.rs25
-rw-r--r--WebInterface/wasm/webhogg/src/webhogg_exception.rs25
-rw-r--r--WebInterface/wasm/webhogg/target/.rustc_info.json1
11 files changed, 201 insertions, 0 deletions
diff --git a/WebInterface/wasm/webhogg/Cargo.toml b/WebInterface/wasm/webhogg/Cargo.toml
new file mode 100644
index 0000000..4342a68
--- /dev/null
+++ b/WebInterface/wasm/webhogg/Cargo.toml
@@ -0,0 +1,29 @@
+[package]
+name = "webhogg"
+version = "0.1.0"
+authors = [
+ "natrixaeria",
+ "TrueDoctor"
+]
+edition = "2018"
+
+[lib]
+crate-type = ["cdylib"]
+
+[dependencies]
+wasm-bindgen = "0.2"
+log = "0.4"
+fern = "0.5"
+
+[dependencies.web-sys]
+version = "0.3.22"
+features = [
+ 'Document',
+ 'Element',
+ 'HtmlCanvasElement',
+ 'WebGl2RenderingContext',
+ 'WebGlShader',
+ 'WebGlProgram',
+ 'WebGlBuffer',
+ 'Window'
+]
diff --git a/WebInterface/wasm/webhogg/deploy b/WebInterface/wasm/webhogg/deploy
new file mode 100755
index 0000000..13d1d0a
--- /dev/null
+++ b/WebInterface/wasm/webhogg/deploy
@@ -0,0 +1,2 @@
+#!/bin/sh
+lighttpd -f ./lighttpd.config
diff --git a/WebInterface/wasm/webhogg/index.html b/WebInterface/wasm/webhogg/index.html
new file mode 100644
index 0000000..ce09537
--- /dev/null
+++ b/WebInterface/wasm/webhogg/index.html
@@ -0,0 +1,24 @@
+<!doctype html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <title>webhogg</title>
+ <script src='loader.js' type='module'></script>
+ <style>
+ body {
+ margin: 0;
+ background: black;
+ }
+ #canvas {
+ width: 100%;
+ height: 100%;
+ }
+ img {
+ background: violet;
+ }
+ </style>
+ </head>
+ <body>
+ <canvas id='canvas'></canvas>
+ </body>
+</html>
diff --git a/WebInterface/wasm/webhogg/lighttpd.config b/WebInterface/wasm/webhogg/lighttpd.config
new file mode 100644
index 0000000..406b009
--- /dev/null
+++ b/WebInterface/wasm/webhogg/lighttpd.config
@@ -0,0 +1,29 @@
+server.http-parseopts = (
+ "header-strict" => "enable",
+ "host-strict" => "enable",
+ "host-normalize" => "enable",
+ "url-normalize" => "enable",
+ "url-normalize-unreserved" => "enable",
+ "url-normalize-required" => "enable",
+ "url-ctrls-reject" => "enable",
+ "url-path-2f-decode" => "enable",
+ "url-path-dotseg-remove" => "enable",
+ "url-query-20-plus" => "enable"
+)
+
+server.document-root = "/home/jan/projects/DiscoBot/WebInterface/wasm/webhogg"
+server.port = 8080
+dir-listing.activate = "enable"
+index-file.names = ( "index.html" )
+mimetype.assign = (
+ ".html" => "text/html",
+ ".txt" => "text/plain",
+ ".css" => "text/css",
+ ".js" => "application/x-javascript",
+ ".jpg" => "image/jpeg",
+ ".jpeg" => "image/jpeg",
+ ".gif" => "image/gif",
+ ".png" => "image/png",
+ ".wasm" => "application/wasm",
+ "" => "application/octet-stream"
+)
diff --git a/WebInterface/wasm/webhogg/loader.js b/WebInterface/wasm/webhogg/loader.js
new file mode 100644
index 0000000..81ecbc7
--- /dev/null
+++ b/WebInterface/wasm/webhogg/loader.js
@@ -0,0 +1,2 @@
+import {default as init} from './pkg/webhogg.js'
+init('./pkg/webhogg_bg.wasm');
diff --git a/WebInterface/wasm/webhogg/run b/WebInterface/wasm/webhogg/run
new file mode 100755
index 0000000..1da1e35
--- /dev/null
+++ b/WebInterface/wasm/webhogg/run
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+wasm-pack build --release --target web
diff --git a/WebInterface/wasm/webhogg/src/app.rs b/WebInterface/wasm/webhogg/src/app.rs
new file mode 100644
index 0000000..bee7c08
--- /dev/null
+++ b/WebInterface/wasm/webhogg/src/app.rs
@@ -0,0 +1,15 @@
+use crate::webhogg_exception::WebhoggException;
+
+pub struct WebhoggApplication {
+}
+
+impl WebhoggApplication {
+ pub fn new() -> Result<Self, WebhoggException> {
+ Ok(Self {
+ })
+ }
+
+ pub fn run(&mut self) -> Result<(), WebhoggException> {
+ Ok(())
+ }
+}
diff --git a/WebInterface/wasm/webhogg/src/client_logger.rs b/WebInterface/wasm/webhogg/src/client_logger.rs
new file mode 100644
index 0000000..f71918f
--- /dev/null
+++ b/WebInterface/wasm/webhogg/src/client_logger.rs
@@ -0,0 +1,46 @@
+use wasm_bindgen::prelude::*;
+
+#[wasm_bindgen]
+extern "C" {
+ #[wasm_bindgen(js_namespace=console, js_name=debug)]
+ fn __console_debug_colored2(f: &str, c1: &str, c2: &str);
+ #[wasm_bindgen(js_namespace=console, js_name=info)]
+ fn __console_info_colored2(f: &str, c1: &str, c2: &str);
+ #[wasm_bindgen(js_namespace=console, js_name=warn)]
+ fn __console_warn_colored2(f: &str, c1: &str, c2: &str);
+ #[wasm_bindgen(js_namespace=console, js_name=error)]
+ fn __console_error_colored2(f: &str, c1: &str, c2: &str);
+}
+
+fn log(rec: &log::Record) {
+ let log_fn = match rec.level() {
+ log::Level::Trace | log::Level::Debug => __console_debug_colored2,
+ log::Level::Info => __console_info_colored2,
+ log::Level::Warn => __console_warn_colored2,
+ log::Level::Error => __console_error_colored2,
+ };
+ log_fn(&format!("{}", rec.args()),
+ &format!("color: {}", match rec.level() {
+ log::Level::Trace => "violet",
+ log::Level::Debug => "blue",
+ log::Level::Info => "green",
+ log::Level::Warn => "orange",
+ log::Level::Error => "red"
+ }), "");
+}
+
+pub fn init_logger() {
+ fern::Dispatch::new().format(|out, message, record|{
+ out.finish(format_args!(
+ "%c{}%c {} > {}",
+ record.level(),
+ record.target(),
+ message
+ )
+ )
+ })
+ .level(log::LevelFilter::Debug)
+ .chain(fern::Output::call(log))
+ .apply().unwrap();
+}
+
diff --git a/WebInterface/wasm/webhogg/src/lib.rs b/WebInterface/wasm/webhogg/src/lib.rs
new file mode 100644
index 0000000..8b75ee1
--- /dev/null
+++ b/WebInterface/wasm/webhogg/src/lib.rs
@@ -0,0 +1,25 @@
+mod client_logger;
+mod webhogg_exception;
+mod app;
+
+use wasm_bindgen::prelude::*;
+use app::WebhoggApplication as App;
+
+#[macro_use]
+extern crate log;
+
+fn run_application() {
+ match App::new().and_then(|mut app| app.run()) {
+ Ok(_) => info!("program terminated successfully"),
+ Err(e) => error!("program terminated with failure > {}", e)
+ }
+}
+
+#[wasm_bindgen(start)]
+pub fn entry() {
+ client_logger::init_logger();
+
+ info!("begin running wasm application");
+
+ run_application()
+}
diff --git a/WebInterface/wasm/webhogg/src/webhogg_exception.rs b/WebInterface/wasm/webhogg/src/webhogg_exception.rs
new file mode 100644
index 0000000..eac67c7
--- /dev/null
+++ b/WebInterface/wasm/webhogg/src/webhogg_exception.rs
@@ -0,0 +1,25 @@
+use std::error::Error;
+
+#[derive(Debug)]
+pub enum WebhoggException {
+}
+
+impl Error for WebhoggException {
+ fn description(&self) -> &str {
+ "webhogg exception"
+ }
+
+ fn cause(&self) -> Option<&dyn Error> {
+ self.source()
+ }
+
+ fn source(&self) -> Option<&(dyn Error + 'static)> {
+ None
+ }
+}
+
+impl std::fmt::Display for WebhoggException {
+ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+ write!(f, "WebhoggException: {}", self.description())
+ }
+}
diff --git a/WebInterface/wasm/webhogg/target/.rustc_info.json b/WebInterface/wasm/webhogg/target/.rustc_info.json
new file mode 100644
index 0000000..94a43da
--- /dev/null
+++ b/WebInterface/wasm/webhogg/target/.rustc_info.json
@@ -0,0 +1 @@
+{"rustc_fingerprint":7082560745936267572,"outputs":{"1617349019360157463":["___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/jan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\ndebug_assertions\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n",""],"6217262102979750783":["___.wasm\nlib___.rlib\n___.wasm\nlib___.a\n/home/jan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\ndebug_assertions\nproc_macro\ntarget_arch=\"wasm32\"\ntarget_endian=\"little\"\ntarget_env=\"\"\ntarget_os=\"unknown\"\ntarget_pointer_width=\"32\"\ntarget_vendor=\"unknown\"\n","warning: dropping unsupported crate type `dylib` for target `wasm32-unknown-unknown`\n\nwarning: dropping unsupported crate type `proc-macro` for target `wasm32-unknown-unknown`\n\n"],"1164083562126845933":["rustc 1.34.1 (fc50f328b 2019-04-24)\nbinary: rustc\ncommit-hash: fc50f328b0353b285421b8ff5d4100966387a997\ncommit-date: 2019-04-24\nhost: x86_64-unknown-linux-gnu\nrelease: 1.34.1\nLLVM version: 8.0\n",""]},"successes":{}} \ No newline at end of file