summary refs log tree commit diff
diff options
context:
space:
mode:
authorJorik Schellekens <joriks@matrix.org>2019-07-30 19:07:52 +0100
committerJorik Schellekens <joriks@matrix.org>2019-08-28 15:59:53 +0100
commit4163c254497c71a9922870b1e96892d93fef0572 (patch)
tree79234e6782d43db49cf65ace212f4fecbab5ee08
parentSet up initial endpoints for backend server. (diff)
downloadsynapse-4163c254497c71a9922870b1e96892d93fef0572.tar.xz
Set up fronted as a react project.
-rw-r--r--synapse_topology/view/server/__init__.py14
-rw-r--r--synapse_topology/view/webui/.babelrc6
-rw-r--r--synapse_topology/view/webui/.gitignore2
-rw-r--r--synapse_topology/view/webui/fonts/LiberationSans-Bold.ttfbin0 -> 353936 bytes
-rw-r--r--synapse_topology/view/webui/fonts/LiberationSans-BoldItalic.ttfbin0 -> 349724 bytes
-rw-r--r--synapse_topology/view/webui/fonts/LiberationSans-Italic.ttfbin0 -> 355608 bytes
-rw-r--r--synapse_topology/view/webui/fonts/LiberationSans-Regular.ttfbin0 -> 350200 bytes
-rw-r--r--synapse_topology/view/webui/fonts/SIL Open Font License.txt46
-rw-r--r--synapse_topology/view/webui/index.html13
-rw-r--r--synapse_topology/view/webui/js/Action.jsx6
-rw-r--r--synapse_topology/view/webui/js/ActionButton.jsx5
-rw-r--r--synapse_topology/view/webui/js/App.jsx18
-rw-r--r--synapse_topology/view/webui/js/api/api.js41
-rw-r--r--synapse_topology/view/webui/js/api/constants.js13
-rw-r--r--synapse_topology/view/webui/js/index.jsx5
-rw-r--r--synapse_topology/view/webui/less/main.less54
-rw-r--r--synapse_topology/view/webui/less/themes.less7
-rw-r--r--synapse_topology/view/webui/package.json37
-rw-r--r--synapse_topology/view/webui/webpack.config.babel.js55
19 files changed, 322 insertions, 0 deletions
diff --git a/synapse_topology/view/server/__init__.py b/synapse_topology/view/server/__init__.py
new file mode 100644
index 0000000000..5a93a18aa9
--- /dev/null
+++ b/synapse_topology/view/server/__init__.py
@@ -0,0 +1,14 @@
+from os.path import abspath, dirname, join
+
+from klein import Klein
+
+from twisted.web.static import File
+
+app = Klein()
+
+
+@app.route("/topology_webui/", branch=True)
+def server_webui(request):
+    client_path = abspath(join(dirname(abspath(__file__)), "../webui"))
+    print(client_path)
+    return File(client_path)
diff --git a/synapse_topology/view/webui/.babelrc b/synapse_topology/view/webui/.babelrc
new file mode 100644
index 0000000000..66134c259a
--- /dev/null
+++ b/synapse_topology/view/webui/.babelrc
@@ -0,0 +1,6 @@
+{
+    "presets": [
+        "@babel/preset-env",
+	"@babel/preset-react",
+    ]
+}
diff --git a/synapse_topology/view/webui/.gitignore b/synapse_topology/view/webui/.gitignore
new file mode 100644
index 0000000000..f06235c460
--- /dev/null
+++ b/synapse_topology/view/webui/.gitignore
@@ -0,0 +1,2 @@
+node_modules
+dist
diff --git a/synapse_topology/view/webui/fonts/LiberationSans-Bold.ttf b/synapse_topology/view/webui/fonts/LiberationSans-Bold.ttf
new file mode 100644
index 0000000000..4581ebf3ee
--- /dev/null
+++ b/synapse_topology/view/webui/fonts/LiberationSans-Bold.ttf
Binary files differdiff --git a/synapse_topology/view/webui/fonts/LiberationSans-BoldItalic.ttf b/synapse_topology/view/webui/fonts/LiberationSans-BoldItalic.ttf
new file mode 100644
index 0000000000..bfbcd26b55
--- /dev/null
+++ b/synapse_topology/view/webui/fonts/LiberationSans-BoldItalic.ttf
Binary files differdiff --git a/synapse_topology/view/webui/fonts/LiberationSans-Italic.ttf b/synapse_topology/view/webui/fonts/LiberationSans-Italic.ttf
new file mode 100644
index 0000000000..fcdab8850b
--- /dev/null
+++ b/synapse_topology/view/webui/fonts/LiberationSans-Italic.ttf
Binary files differdiff --git a/synapse_topology/view/webui/fonts/LiberationSans-Regular.ttf b/synapse_topology/view/webui/fonts/LiberationSans-Regular.ttf
new file mode 100644
index 0000000000..626dd9364f
--- /dev/null
+++ b/synapse_topology/view/webui/fonts/LiberationSans-Regular.ttf
Binary files differdiff --git a/synapse_topology/view/webui/fonts/SIL Open Font License.txt b/synapse_topology/view/webui/fonts/SIL Open Font License.txt
new file mode 100644
index 0000000000..f2473f9cce
--- /dev/null
+++ b/synapse_topology/view/webui/fonts/SIL Open Font License.txt
@@ -0,0 +1,46 @@
+Digitized data copyright (c) 2010 Google Corporation
+	with Reserved Font Arimo, Tinos and Cousine.
+Copyright (c) 2012 Red Hat, Inc.
+	with Reserved Font Name Liberation.
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting, or substituting -- in part or in whole -- any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment.
+
+"Author" refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission.
+
+5) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
\ No newline at end of file
diff --git a/synapse_topology/view/webui/index.html b/synapse_topology/view/webui/index.html
new file mode 100644
index 0000000000..0d206e0bfb
--- /dev/null
+++ b/synapse_topology/view/webui/index.html
@@ -0,0 +1,13 @@
+<html>
+
+<head>
+    <meta charset="utf-8">
+    <title>Topology - The synapse configuration tool</title>
+</head>
+
+<body>
+    <div id="content" />
+    <script src="dist/bundle.js" type="text/javascript"></script>
+</body>
+
+</html>
\ No newline at end of file
diff --git a/synapse_topology/view/webui/js/Action.jsx b/synapse_topology/view/webui/js/Action.jsx
new file mode 100644
index 0000000000..bdfc99778f
--- /dev/null
+++ b/synapse_topology/view/webui/js/Action.jsx
@@ -0,0 +1,6 @@
+import React from 'react';
+
+import style from '../less/main.less';
+
+export default (props) =>
+    <div className={style.action}>{props.children}</div>
\ No newline at end of file
diff --git a/synapse_topology/view/webui/js/ActionButton.jsx b/synapse_topology/view/webui/js/ActionButton.jsx
new file mode 100644
index 0000000000..d43c12b93e
--- /dev/null
+++ b/synapse_topology/view/webui/js/ActionButton.jsx
@@ -0,0 +1,5 @@
+import React from 'react';
+
+export default (props) => (
+    <button>{props.text.toUpperCase()}</button>
+)
\ No newline at end of file
diff --git a/synapse_topology/view/webui/js/App.jsx b/synapse_topology/view/webui/js/App.jsx
new file mode 100644
index 0000000000..e8432fb841
--- /dev/null
+++ b/synapse_topology/view/webui/js/App.jsx
@@ -0,0 +1,18 @@
+import React, { Component } from 'react';
+
+import style from '../less/main.less';
+import ActionButton from './ActionButton.jsx';
+import Action from './Action.jsx';
+
+export default class App extends Component {
+    componentDidMount() {
+    }
+
+    render() {
+        return <Action>
+            <h1>Synapse Topology</h1>
+            <p>Let's get started.</p>
+            <div><ActionButton text="SETUP"></ActionButton></div>
+        </Action>
+    }
+}
\ No newline at end of file
diff --git a/synapse_topology/view/webui/js/api/api.js b/synapse_topology/view/webui/js/api/api.js
new file mode 100644
index 0000000000..1454c6e844
--- /dev/null
+++ b/synapse_topology/view/webui/js/api/api.js
@@ -0,0 +1,41 @@
+import fetchAbsolute from 'fetch-absolute';
+import {
+    API_URL,
+    SERVER_NAME,
+    SECRET_KEY,
+    CONFIG,
+    CONFIG_SOMETHING,
+} from './constants';
+
+const fetchAbs = fetchAbsolute(fetch)(API_URL)
+
+const get_server_name = () => {
+    fetchAbs(SERVER_NAME)
+        .then(res => res.json())
+};
+
+const post_server_name = () => {
+
+};
+
+const get_secret_key = () => {
+    fetchAbs(SECRET_KEY)
+        .then(res => res.json())
+
+};
+
+const get_config = () => {
+
+};
+
+const post_config = () => {
+
+};
+
+export {
+    get_server_name,
+    post_server_name,
+    get_secret_key,
+    get_config,
+    post_config,
+}
\ No newline at end of file
diff --git a/synapse_topology/view/webui/js/api/constants.js b/synapse_topology/view/webui/js/api/constants.js
new file mode 100644
index 0000000000..dce1eb3227
--- /dev/null
+++ b/synapse_topology/view/webui/js/api/constants.js
@@ -0,0 +1,13 @@
+const API_URL = "http://localhost:8889/";
+const SERVER_NAME = "/servername";
+const SECRET_KEY = "/secretkey";
+const CONFIG = "/config";
+const CONFIG_SOMETHING = "/config_something";
+
+export {
+    API_URL,
+    SERVER_NAME,
+    SECRET_KEY,
+    CONFIG,
+    CONFIG_SOMETHING,
+}
\ No newline at end of file
diff --git a/synapse_topology/view/webui/js/index.jsx b/synapse_topology/view/webui/js/index.jsx
new file mode 100644
index 0000000000..0f4f65dab8
--- /dev/null
+++ b/synapse_topology/view/webui/js/index.jsx
@@ -0,0 +1,5 @@
+import React from 'react';
+import ReactDom from 'react-dom';
+import App from './App';
+
+ReactDom.render(<App />, document.getElementById("content"));
\ No newline at end of file
diff --git a/synapse_topology/view/webui/less/main.less b/synapse_topology/view/webui/less/main.less
new file mode 100644
index 0000000000..c6824971bf
--- /dev/null
+++ b/synapse_topology/view/webui/less/main.less
@@ -0,0 +1,54 @@
+@import url('./themes.less');
+
+@font-face {
+  font-family: 'LiberationSansBold';
+  src: url('../fonts/LiberationSans-Bold.ttf') format('truetype');
+}
+
+.theme {
+  .dark();
+}
+
+html {
+  box-sizing: border-box;
+  font-family: 'LiberationSansBold';
+  font-size: 2rem;
+}
+
+*, *:before, *:after {
+  box-sizing: inherit;
+}
+
+body {
+  .theme();
+  background-color: @secondary;
+  color: @font;
+}
+
+.action {
+  .theme();
+  margin: 0 20% 0 20%;
+  display: flex;
+  flex-direction: column;
+  text-align: center;
+  justify-content: space-evenly;
+  height: 100%;
+
+  button {
+    border-radius: 0.5rem;
+    font-size: 1rem;
+    padding: 0.6rem;
+    color: @font;
+    background-color: @highlight;
+    border: none;
+    display: inline-block;
+    text-transform: capitalize;
+    font-style: bold;
+  }
+}
+
+h1 {
+  .theme();
+  font-size: 2rem;
+  color: @highlight;
+}
\ No newline at end of file
diff --git a/synapse_topology/view/webui/less/themes.less b/synapse_topology/view/webui/less/themes.less
new file mode 100644
index 0000000000..040170bf09
--- /dev/null
+++ b/synapse_topology/view/webui/less/themes.less
@@ -0,0 +1,7 @@
+.dark {
+    @primary: #0e1111;
+    @secondary: #232b2b;
+    @borders: #3b444b;
+    @font:  #f9f9f9;
+    @highlight: #4AEFF0;
+}
\ No newline at end of file
diff --git a/synapse_topology/view/webui/package.json b/synapse_topology/view/webui/package.json
new file mode 100644
index 0000000000..7122a42ae9
--- /dev/null
+++ b/synapse_topology/view/webui/package.json
@@ -0,0 +1,37 @@
+{
+  "name": "synapse_topology_webui",
+  "version": "0.0.0",
+  "description": "A simple webui for initialising the synapse startup",
+  "main": "index.js",
+  "author": "Jorik Schellekens (matrix.org)",
+  "license": "Apache-2.0",
+  "private": true,
+  "devDependencies": {
+    "@babel/cli": "^7.5.5",
+    "@babel/core": "^7.5.5",
+    "@babel/node": "^7.5.5",
+    "@babel/preset-env": "^7.5.5",
+    "@babel/preset-react": "^7.0.0",
+    "@babel/register": "^7.5.5",
+    "babel-loader": "^8.0.6",
+    "css-loader": "^3.1.0",
+    "file-loader": "^4.1.0",
+    "html-webpack-plugin": "^3.2.0",
+    "less": "^3.9.0",
+    "less-loader": "^5.0.0",
+    "react": "^16.8.6",
+    "react-dom": "^16.8.6",
+    "style-loader": "^0.23.1",
+    "webpack": "^4.38.0",
+    "webpack-cli": "^3.3.6",
+    "webpack-dev-server": "^3.7.2"
+  },
+  "scripts": {
+    "build": "webpack -p --progress --config webpack.config.babel.js",
+    "dev-build": "webpack --progress -d --config webpack.config.babel.js",
+    "watch": "webpack --progress -d --config webpack.config.babel.js --watch"
+  },
+  "dependencies": {
+    "fetch-absolute": "^1.0.0"
+  }
+}
diff --git a/synapse_topology/view/webui/webpack.config.babel.js b/synapse_topology/view/webui/webpack.config.babel.js
new file mode 100644
index 0000000000..2d018ac623
--- /dev/null
+++ b/synapse_topology/view/webui/webpack.config.babel.js
@@ -0,0 +1,55 @@
+import 'webpack';
+import { Path } from 'path';
+
+export default {
+  entry:  __dirname + '/js/index.jsx',
+  output: {
+    path: __dirname + '/dist',
+    filename: 'bundle.js',
+  },
+  resolve: {
+    extensions: ['.js', '.jsx', '.css']
+  },
+  module: {
+    rules:[
+      {
+        test: /\.jsx$/,
+        exclude: /node_modules/,
+        use: ['babel-loader'],
+      },
+      {
+        test: /\.less$/,
+        use: [
+	  {
+	    loader: 'style-loader',
+	  },
+	  {
+            loader: 'css-loader',
+            options: {
+              sourceMap: true,
+              modules: {
+		  localIdentName: '[local]___[hash:base64:5]'
+	      }
+	    },
+          },
+	  {
+	    loader: 'less-loader',
+	  },
+	],
+      },
+      {
+        test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
+        use: [
+          {
+            loader: 'file-loader',
+            options: {
+              name: '[name].[ext]',
+              outputPath: 'fonts/'
+            }
+          }
+        ]
+      }
+    ]
+  },
+};
+