commit e05af17db9daf2e612e4435cc784772a6caec6d2 Author: Ezerous Date: Mon Apr 23 12:22:23 2018 +0300 Initial commit diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..6313b56 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dd40e6f --- /dev/null +++ b/.gitignore @@ -0,0 +1,26 @@ +# See https://help.github.com/ignore-files/ for more about ignoring files. + +# Node +/node_modules +package-lock.json + +# Testing +/coverage + +# Production +/build +/src/build + +# Misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Jetbrains +.idea diff --git a/README.md b/README.md new file mode 100644 index 0000000..06c9e71 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Apella + +*Note: This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app).* diff --git a/contracts/Forum.sol b/contracts/Forum.sol new file mode 100644 index 0000000..3732646 --- /dev/null +++ b/contracts/Forum.sol @@ -0,0 +1,88 @@ +pragma solidity ^0.4.17; + +contract Forum { + + //----------------------------------------USER---------------------------------------- + struct User { + string userName; // TODO: set an upper bound instead of arbitrary string + // TODO: orbitDBAddress; + uint[] topicIDs; // IDs of the topics the user created + uint[] postIDs; // IDs of the posts the user created + } + + mapping (address => User) users; + mapping (string => address) userAddresses; + + function signUp(string userName) public returns (bool) { // Also allows user to update his name - TODO: his previous name will appear as taken + require(!isUserNameTaken(userName)); + users[msg.sender] = User(userName, new uint[](0), new uint[](0)); + userAddresses[userName] = msg.sender; + return true; + } + + function login() public view returns (string) { + require (hasUserSignedUp(msg.sender)); + return users[msg.sender].userName; + } + + function getUsername(address userAddress) public view returns (string) { + return users[userAddress].userName; + } + + function getUserAddress(string userName) public view returns (address) { + return userAddresses[userName]; + } + + function hasUserSignedUp(address userAddress) public view returns (bool) { + if (bytes(getUsername(userAddress)).length!=0) + return true; + return false; + } + + function isUserNameTaken(string userName) public view returns (bool) { + if (getUserAddress(userName)!=0) + return true; + return false; + } + + //----------------------------------------TOPIC---------------------------------------- + struct Topic { + uint topicID; + address author; + uint timestamp; + uint[] postIDs; + } + + struct Post { + uint postID; + address author; + uint timestamp; + } + + uint numTopics; // Total number of topics + uint numPosts; // Total number of posts + + mapping (uint => Topic) topics; + mapping (uint => Post) posts; + + function createTopic() public returns (uint topicID) { + require(hasUserSignedUp(msg.sender)); // Only registered users can create topics + topicID = numTopics++; + topics[topicID] = Topic(topicID, msg.sender, block.timestamp, new uint[](0)); + users[msg.sender].topicIDs.push(topicID); + } + + function createPost(uint topicID) public returns (uint postID) { + require(hasUserSignedUp(msg.sender)); // Only registered users can create posts + require(topicID + + + + + + + + + + Apella + + + +
+ + + diff --git a/public/manifest.json b/public/manifest.json new file mode 100644 index 0000000..0bcfdd4 --- /dev/null +++ b/public/manifest.json @@ -0,0 +1,15 @@ +{ + "short_name": "Apella", + "name": "Apella", + "icons": [ + { + "src": "favicon.ico", + "sizes": "64x64 32x32 24x24 16x16", + "type": "image/x-icon" + } + ], + "start_url": "./index.html", + "display": "standalone", + "theme_color": "#000000", + "background_color": "#ffffff" +} diff --git a/src/App.css b/src/App.css new file mode 100644 index 0000000..d6e66c0 --- /dev/null +++ b/src/App.css @@ -0,0 +1,68 @@ +/* PAGE */ + +body, +.pure-g [class*=pure-u] { + font-family: 'Open Sans', sans-serif; +} + +h1, h2, h3 { + font-family: 'Oswald', 'Arial Narrow', sans-serif; +} + +code { + display: block; + margin: 20px 0 15px 0; + padding: 10px; + background: #eee; +} + +.container { + box-sizing: border-box; + width: 100%; + padding: 45px 20px; +} + +.pure-button-primary { + background-color: #0c1a2b; +} + +.pure-button-primary:hover { + background-color: #233e5e; +} + +.pure-form input[type="text"]:focus { + border-color: #0c1a2b; +} + +/* NAVBAR */ + +.navbar { + position: fixed; + padding: 5px; + background: #0c1a2b; + font-family: 'Oswald', 'Arial Narrow', sans-serif; +} + +.navbar a { + color: #fff; +} + +.navbar a:active, +.navbar a:focus, +.navbar a:hover { + background: #233e5e; +} + +.navbar .pure-menu-heading { + font-weight: bold; + text-transform: none; +} + +.navbar .navbar-right { + float: right; +} + +.navbar .uport-logo { + height: 16px; + margin-right: 10px; +} diff --git a/src/App.js b/src/App.js new file mode 100644 index 0000000..41c5ef9 --- /dev/null +++ b/src/App.js @@ -0,0 +1,52 @@ +import React, { Component } from 'react' +import { Link } from 'react-router' +import { HiddenOnlyAuth, VisibleOnlyAuth } from './util/wrappers.js' + +// UI Components +import LoginButtonContainer from './user/ui/loginbutton/LoginButtonContainer' + +// Styles +import './css/oswald.css' +import './css/open-sans.css' +import './css/pure-min.css' +import './App.css' + +class App extends Component { + render() { + const OnlyAuthLinks = VisibleOnlyAuth(() => + +
  • + Dashboard +
  • +
  • + Profile +
  • +
    + ); + + const OnlyGuestLinks = HiddenOnlyAuth(() => + +
  • + Sign Up +
  • + +
    + ); + + return ( +
    + + + {this.props.children} +
    + ); + } +} + +export default App diff --git a/src/App.test.js b/src/App.test.js new file mode 100644 index 0000000..a754b20 --- /dev/null +++ b/src/App.test.js @@ -0,0 +1,9 @@ +import React from 'react'; +import ReactDOM from 'react-dom'; +import App from './App'; + +it('renders without crashing', () => { + const div = document.createElement('div'); + ReactDOM.render(, div); + ReactDOM.unmountComponentAtNode(div); +}); diff --git a/src/css/open-sans.css b/src/css/open-sans.css new file mode 100644 index 0000000..0672095 --- /dev/null +++ b/src/css/open-sans.css @@ -0,0 +1,13 @@ +@font-face { + font-family: 'Open Sans'; + font-weight: 400; + font-style: normal; + src: url('../fonts/Open-Sans-regular/Open-Sans-regular.eot'); + src: url('../fonts/Open-Sans-regular/Open-Sans-regular.eot?#iefix') format('embedded-opentype'), + local('Open Sans'), + local('Open-Sans-regular'), + url('../fonts/Open-Sans-regular/Open-Sans-regular.woff2') format('woff2'), + url('../fonts/Open-Sans-regular/Open-Sans-regular.woff') format('woff'), + url('../fonts/Open-Sans-regular/Open-Sans-regular.ttf') format('truetype'), + url('../fonts/Open-Sans-regular/Open-Sans-regular.svg#OpenSans') format('svg'); +} diff --git a/src/css/oswald.css b/src/css/oswald.css new file mode 100644 index 0000000..4c03361 --- /dev/null +++ b/src/css/oswald.css @@ -0,0 +1,27 @@ +@font-face { + font-family: 'Oswald'; + font-weight: 300; + font-style: normal; + src: url('../fonts/Oswald-300/Oswald-300.eot'); + src: url('../fonts/Oswald-300/Oswald-300.eot?#iefix') format('embedded-opentype'), + local('Oswald Light'), + local('Oswald-300'), + url('../fonts/Oswald-300/Oswald-300.woff2') format('woff2'), + url('../fonts/Oswald-300/Oswald-300.woff') format('woff'), + url('../fonts/Oswald-300/Oswald-300.ttf') format('truetype'), + url('../fonts/Oswald-300/Oswald-300.svg#Oswald') format('svg'); +} + +@font-face { + font-family: 'Oswald'; + font-weight: 400; + font-style: normal; + src: url('../fonts/Oswald-regular/Oswald-regular.eot'); + src: url('../fonts/Oswald-regular/Oswald-regular.eot?#iefix') format('embedded-opentype'), + local('Oswald Regular'), + local('Oswald-regular'), + url('../fonts/Oswald-regular/Oswald-regular.woff2') format('woff2'), + url('../fonts/Oswald-regular/Oswald-regular.woff') format('woff'), + url('../fonts/Oswald-regular/Oswald-regular.ttf') format('truetype'), + url('../fonts/Oswald-regular/Oswald-regular.svg#Oswald') format('svg'); +} diff --git a/src/css/pure-min.css b/src/css/pure-min.css new file mode 100644 index 0000000..f93fe3f --- /dev/null +++ b/src/css/pure-min.css @@ -0,0 +1,11 @@ +/*! +Pure v0.6.2 +Copyright 2013 Yahoo! +Licensed under the BSD License. +https://github.com/yahoo/pure/blob/master/LICENSE.md +*/ +/*! +normalize.css v^3.0 | MIT License | git.io/normalize +Copyright (c) Nicolas Gallagher and Jonathan Neal +*/ +/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */.pure-button:focus,a:active,a:hover{outline:0}.pure-table,table{border-collapse:collapse;border-spacing:0}html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}abbr[title]{border-bottom:1px dotted}b,optgroup,strong{font-weight:700}dfn{font-style:italic}h1{font-size:2em;margin:.67em 0}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{box-sizing:content-box;height:0}pre,textarea{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}.pure-button,input{line-height:normal}button{overflow:visible}button,select{text-transform:none}button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{height:auto}input[type=search]{-webkit-appearance:textfield;box-sizing:content-box}.pure-button,.pure-form input:not([type]),.pure-menu{box-sizing:border-box}input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{-webkit-appearance:none}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend,td,th{padding:0}legend{border:0}.hidden,[hidden]{display:none!important}.pure-img{max-width:100%;height:auto;display:block}.pure-g{letter-spacing:-.31em;text-rendering:optimizespeed;font-family:FreeSans,Arimo,"Droid Sans",Helvetica,Arial,sans-serif;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-flow:row wrap;-ms-flex-flow:row wrap;flex-flow:row wrap;-webkit-align-content:flex-start;-ms-flex-line-pack:start;align-content:flex-start}@media all and (-ms-high-contrast:none),(-ms-high-contrast:active){table .pure-g{display:block}}.opera-only :-o-prefocus,.pure-g{word-spacing:-.43em}.pure-u,.pure-u-1,.pure-u-1-1,.pure-u-1-12,.pure-u-1-2,.pure-u-1-24,.pure-u-1-3,.pure-u-1-4,.pure-u-1-5,.pure-u-1-6,.pure-u-1-8,.pure-u-10-24,.pure-u-11-12,.pure-u-11-24,.pure-u-12-24,.pure-u-13-24,.pure-u-14-24,.pure-u-15-24,.pure-u-16-24,.pure-u-17-24,.pure-u-18-24,.pure-u-19-24,.pure-u-2-24,.pure-u-2-3,.pure-u-2-5,.pure-u-20-24,.pure-u-21-24,.pure-u-22-24,.pure-u-23-24,.pure-u-24-24,.pure-u-3-24,.pure-u-3-4,.pure-u-3-5,.pure-u-3-8,.pure-u-4-24,.pure-u-4-5,.pure-u-5-12,.pure-u-5-24,.pure-u-5-5,.pure-u-5-6,.pure-u-5-8,.pure-u-6-24,.pure-u-7-12,.pure-u-7-24,.pure-u-7-8,.pure-u-8-24,.pure-u-9-24{letter-spacing:normal;word-spacing:normal;vertical-align:top;text-rendering:auto;display:inline-block;zoom:1}.pure-g [class*=pure-u]{font-family:sans-serif}.pure-u-1-24{width:4.1667%}.pure-u-1-12,.pure-u-2-24{width:8.3333%}.pure-u-1-8,.pure-u-3-24{width:12.5%}.pure-u-1-6,.pure-u-4-24{width:16.6667%}.pure-u-1-5{width:20%}.pure-u-5-24{width:20.8333%}.pure-u-1-4,.pure-u-6-24{width:25%}.pure-u-7-24{width:29.1667%}.pure-u-1-3,.pure-u-8-24{width:33.3333%}.pure-u-3-8,.pure-u-9-24{width:37.5%}.pure-u-2-5{width:40%}.pure-u-10-24,.pure-u-5-12{width:41.6667%}.pure-u-11-24{width:45.8333%}.pure-u-1-2,.pure-u-12-24{width:50%}.pure-u-13-24{width:54.1667%}.pure-u-14-24,.pure-u-7-12{width:58.3333%}.pure-u-3-5{width:60%}.pure-u-15-24,.pure-u-5-8{width:62.5%}.pure-u-16-24,.pure-u-2-3{width:66.6667%}.pure-u-17-24{width:70.8333%}.pure-u-18-24,.pure-u-3-4{width:75%}.pure-u-19-24{width:79.1667%}.pure-u-4-5{width:80%}.pure-u-20-24,.pure-u-5-6{width:83.3333%}.pure-u-21-24,.pure-u-7-8{width:87.5%}.pure-u-11-12,.pure-u-22-24{width:91.6667%}.pure-u-23-24{width:95.8333%}.pure-u-1,.pure-u-1-1,.pure-u-24-24,.pure-u-5-5{width:100%}.pure-button{display:inline-block;zoom:1;white-space:nowrap;vertical-align:middle;text-align:center;cursor:pointer;-webkit-user-drag:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.pure-button::-moz-focus-inner{padding:0;border:0}.pure-button-group{letter-spacing:-.31em;text-rendering:optimizespeed}.opera-only :-o-prefocus,.pure-button-group{word-spacing:-.43em}.pure-button{font-family:inherit;font-size:100%;padding:.5em 1em;color:#444;color:rgba(0,0,0,.8);border:1px solid #999;border:transparent;background-color:#E6E6E6;text-decoration:none;border-radius:2px}.pure-button-hover,.pure-button:focus,.pure-button:hover{filter:alpha(opacity=90);background-image:-webkit-linear-gradient(transparent,rgba(0,0,0,.05) 40%,rgba(0,0,0,.1));background-image:linear-gradient(transparent,rgba(0,0,0,.05) 40%,rgba(0,0,0,.1))}.pure-button-active,.pure-button:active{box-shadow:0 0 0 1px rgba(0,0,0,.15) inset,0 0 6px rgba(0,0,0,.2) inset;border-color:#000\9}.pure-button-disabled,.pure-button-disabled:active,.pure-button-disabled:focus,.pure-button-disabled:hover,.pure-button[disabled]{border:none;background-image:none;filter:alpha(opacity=40);opacity:.4;cursor:not-allowed;box-shadow:none;pointer-events:none}.pure-button-hidden{display:none}.pure-button-primary,.pure-button-selected,a.pure-button-primary,a.pure-button-selected{background-color:#0078e7;color:#fff}.pure-button-group .pure-button{letter-spacing:normal;word-spacing:normal;vertical-align:top;text-rendering:auto;margin:0;border-radius:0;border-right:1px solid #111;border-right:1px solid rgba(0,0,0,.2)}.pure-button-group .pure-button:first-child{border-top-left-radius:2px;border-bottom-left-radius:2px}.pure-button-group .pure-button:last-child{border-top-right-radius:2px;border-bottom-right-radius:2px;border-right:none}.pure-form input[type=password],.pure-form input[type=email],.pure-form input[type=url],.pure-form input[type=date],.pure-form input[type=month],.pure-form input[type=time],.pure-form input[type=datetime],.pure-form input[type=datetime-local],.pure-form input[type=week],.pure-form input[type=tel],.pure-form input[type=color],.pure-form input[type=number],.pure-form input[type=search],.pure-form input[type=text],.pure-form select,.pure-form textarea{padding:.5em .6em;display:inline-block;border:1px solid #ccc;box-shadow:inset 0 1px 3px #ddd;border-radius:4px;vertical-align:middle;box-sizing:border-box}.pure-form input:not([type]){padding:.5em .6em;display:inline-block;border:1px solid #ccc;box-shadow:inset 0 1px 3px #ddd;border-radius:4px}.pure-form input[type=color]{padding:.2em .5em}.pure-form input:not([type]):focus,.pure-form input[type=password]:focus,.pure-form input[type=email]:focus,.pure-form input[type=url]:focus,.pure-form input[type=date]:focus,.pure-form input[type=month]:focus,.pure-form input[type=time]:focus,.pure-form input[type=datetime]:focus,.pure-form input[type=datetime-local]:focus,.pure-form input[type=week]:focus,.pure-form input[type=tel]:focus,.pure-form input[type=color]:focus,.pure-form input[type=number]:focus,.pure-form input[type=search]:focus,.pure-form input[type=text]:focus,.pure-form select:focus,.pure-form textarea:focus{outline:0;border-color:#129FEA}.pure-form input[type=file]:focus,.pure-form input[type=checkbox]:focus,.pure-form input[type=radio]:focus{outline:#129FEA auto 1px}.pure-form .pure-checkbox,.pure-form .pure-radio{margin:.5em 0;display:block}.pure-form input:not([type])[disabled],.pure-form input[type=password][disabled],.pure-form input[type=email][disabled],.pure-form input[type=url][disabled],.pure-form input[type=date][disabled],.pure-form input[type=month][disabled],.pure-form input[type=time][disabled],.pure-form input[type=datetime][disabled],.pure-form input[type=datetime-local][disabled],.pure-form input[type=week][disabled],.pure-form input[type=tel][disabled],.pure-form input[type=color][disabled],.pure-form input[type=number][disabled],.pure-form input[type=search][disabled],.pure-form input[type=text][disabled],.pure-form select[disabled],.pure-form textarea[disabled]{cursor:not-allowed;background-color:#eaeded;color:#cad2d3}.pure-form input[readonly],.pure-form select[readonly],.pure-form textarea[readonly]{background-color:#eee;color:#777;border-color:#ccc}.pure-form input:focus:invalid,.pure-form select:focus:invalid,.pure-form textarea:focus:invalid{color:#b94a48;border-color:#e9322d}.pure-form input[type=file]:focus:invalid:focus,.pure-form input[type=checkbox]:focus:invalid:focus,.pure-form input[type=radio]:focus:invalid:focus{outline-color:#e9322d}.pure-form select{height:2.25em;border:1px solid #ccc;background-color:#fff}.pure-form select[multiple]{height:auto}.pure-form label{margin:.5em 0 .2em}.pure-form fieldset{margin:0;padding:.35em 0 .75em;border:0}.pure-form legend{display:block;width:100%;padding:.3em 0;margin-bottom:.3em;color:#333;border-bottom:1px solid #e5e5e5}.pure-form-stacked input:not([type]),.pure-form-stacked input[type=password],.pure-form-stacked input[type=email],.pure-form-stacked input[type=url],.pure-form-stacked input[type=date],.pure-form-stacked input[type=month],.pure-form-stacked input[type=time],.pure-form-stacked input[type=datetime],.pure-form-stacked input[type=datetime-local],.pure-form-stacked input[type=week],.pure-form-stacked input[type=tel],.pure-form-stacked input[type=color],.pure-form-stacked input[type=file],.pure-form-stacked input[type=number],.pure-form-stacked input[type=search],.pure-form-stacked input[type=text],.pure-form-stacked label,.pure-form-stacked select,.pure-form-stacked textarea{display:block;margin:.25em 0}.pure-form-aligned .pure-help-inline,.pure-form-aligned input,.pure-form-aligned select,.pure-form-aligned textarea,.pure-form-message-inline{display:inline-block;vertical-align:middle}.pure-form-aligned textarea{vertical-align:top}.pure-form-aligned .pure-control-group{margin-bottom:.5em}.pure-form-aligned .pure-control-group label{text-align:right;display:inline-block;vertical-align:middle;width:10em;margin:0 1em 0 0}.pure-form-aligned .pure-controls{margin:1.5em 0 0 11em}.pure-form .pure-input-rounded,.pure-form input.pure-input-rounded{border-radius:2em;padding:.5em 1em}.pure-form .pure-group fieldset{margin-bottom:10px}.pure-form .pure-group input,.pure-form .pure-group textarea{display:block;padding:10px;margin:0 0 -1px;border-radius:0;position:relative;top:-1px}.pure-form .pure-group input:focus,.pure-form .pure-group textarea:focus{z-index:3}.pure-form .pure-group input:first-child,.pure-form .pure-group textarea:first-child{top:1px;border-radius:4px 4px 0 0;margin:0}.pure-form .pure-group input:first-child:last-child,.pure-form .pure-group textarea:first-child:last-child{top:1px;border-radius:4px;margin:0}.pure-form .pure-group input:last-child,.pure-form .pure-group textarea:last-child{top:-2px;border-radius:0 0 4px 4px;margin:0}.pure-form .pure-group button{margin:.35em 0}.pure-form .pure-input-1{width:100%}.pure-form .pure-input-3-4{width:75%}.pure-form .pure-input-2-3{width:66%}.pure-form .pure-input-1-2{width:50%}.pure-form .pure-input-1-3{width:33%}.pure-form .pure-input-1-4{width:25%}.pure-form .pure-help-inline,.pure-form-message-inline{display:inline-block;padding-left:.3em;color:#666;vertical-align:middle;font-size:.875em}.pure-form-message{display:block;color:#666;font-size:.875em}@media only screen and (max-width :480px){.pure-form button[type=submit]{margin:.7em 0 0}.pure-form input:not([type]),.pure-form input[type=password],.pure-form input[type=email],.pure-form input[type=url],.pure-form input[type=date],.pure-form input[type=month],.pure-form input[type=time],.pure-form input[type=datetime],.pure-form input[type=datetime-local],.pure-form input[type=week],.pure-form input[type=tel],.pure-form input[type=color],.pure-form input[type=number],.pure-form input[type=search],.pure-form input[type=text],.pure-form label{margin-bottom:.3em;display:block}.pure-group input:not([type]),.pure-group input[type=password],.pure-group input[type=email],.pure-group input[type=url],.pure-group input[type=date],.pure-group input[type=month],.pure-group input[type=time],.pure-group input[type=datetime],.pure-group input[type=datetime-local],.pure-group input[type=week],.pure-group input[type=tel],.pure-group input[type=color],.pure-group input[type=number],.pure-group input[type=search],.pure-group input[type=text]{margin-bottom:0}.pure-form-aligned .pure-control-group label{margin-bottom:.3em;text-align:left;display:block;width:100%}.pure-form-aligned .pure-controls{margin:1.5em 0 0}.pure-form .pure-help-inline,.pure-form-message,.pure-form-message-inline{display:block;font-size:.75em;padding:.2em 0 .8em}}.pure-menu-fixed{position:fixed;left:0;top:0;z-index:3}.pure-menu-item,.pure-menu-list{position:relative}.pure-menu-list{list-style:none;margin:0;padding:0}.pure-menu-item{padding:0;margin:0;height:100%}.pure-menu-heading,.pure-menu-link{display:block;text-decoration:none;white-space:nowrap}.pure-menu-horizontal{width:100%;white-space:nowrap}.pure-menu-horizontal .pure-menu-list{display:inline-block}.pure-menu-horizontal .pure-menu-heading,.pure-menu-horizontal .pure-menu-item,.pure-menu-horizontal .pure-menu-separator{display:inline-block;zoom:1;vertical-align:middle}.pure-menu-item .pure-menu-item{display:block}.pure-menu-children{display:none;position:absolute;left:100%;top:0;margin:0;padding:0;z-index:3}.pure-menu-horizontal .pure-menu-children{left:0;top:auto;width:inherit}.pure-menu-active>.pure-menu-children,.pure-menu-allow-hover:hover>.pure-menu-children{display:block;position:absolute}.pure-menu-has-children>.pure-menu-link:after{padding-left:.5em;content:"\25B8";font-size:small}.pure-menu-horizontal .pure-menu-has-children>.pure-menu-link:after{content:"\25BE"}.pure-menu-scrollable{overflow-y:scroll;overflow-x:hidden}.pure-menu-scrollable .pure-menu-list{display:block}.pure-menu-horizontal.pure-menu-scrollable .pure-menu-list{display:inline-block}.pure-menu-horizontal.pure-menu-scrollable{white-space:nowrap;overflow-y:hidden;overflow-x:auto;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;padding:.5em 0}.pure-menu-horizontal.pure-menu-scrollable::-webkit-scrollbar{display:none}.pure-menu-horizontal .pure-menu-children .pure-menu-separator,.pure-menu-separator{background-color:#ccc;height:1px;margin:.3em 0}.pure-menu-horizontal .pure-menu-separator{width:1px;height:1.3em;margin:0 .3em}.pure-menu-horizontal .pure-menu-children .pure-menu-separator{display:block;width:auto}.pure-menu-heading{text-transform:uppercase;color:#565d64}.pure-menu-link{color:#777}.pure-menu-children{background-color:#fff}.pure-menu-disabled,.pure-menu-heading,.pure-menu-link{padding:.5em 1em}.pure-menu-disabled{opacity:.5}.pure-menu-disabled .pure-menu-link:hover{background-color:transparent}.pure-menu-active>.pure-menu-link,.pure-menu-link:focus,.pure-menu-link:hover{background-color:#eee}.pure-menu-selected .pure-menu-link,.pure-menu-selected .pure-menu-link:visited{color:#000}.pure-table{empty-cells:show;border:1px solid #cbcbcb}.pure-table caption{color:#000;font:italic 85%/1 arial,sans-serif;padding:1em 0;text-align:center}.pure-table td,.pure-table th{border-left:1px solid #cbcbcb;border-width:0 0 0 1px;font-size:inherit;margin:0;overflow:visible;padding:.5em 1em}.pure-table td:first-child,.pure-table th:first-child{border-left-width:0}.pure-table thead{background-color:#e0e0e0;color:#000;text-align:left;vertical-align:bottom}.pure-table td{background-color:transparent}.pure-table-odd td,.pure-table-striped tr:nth-child(2n-1) td{background-color:#f2f2f2}.pure-table-bordered td{border-bottom:1px solid #cbcbcb}.pure-table-bordered tbody>tr:last-child>td{border-bottom-width:0}.pure-table-horizontal td,.pure-table-horizontal th{border-width:0 0 1px;border-bottom:1px solid #cbcbcb}.pure-table-horizontal tbody>tr:last-child>td{border-bottom-width:0} diff --git a/src/fonts/Open-Sans-regular/LICENSE.txt b/src/fonts/Open-Sans-regular/LICENSE.txt new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/src/fonts/Open-Sans-regular/LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/src/fonts/Open-Sans-regular/Open-Sans-regular.eot b/src/fonts/Open-Sans-regular/Open-Sans-regular.eot new file mode 100644 index 0000000..1d98e6e Binary files /dev/null and b/src/fonts/Open-Sans-regular/Open-Sans-regular.eot differ diff --git a/src/fonts/Open-Sans-regular/Open-Sans-regular.svg b/src/fonts/Open-Sans-regular/Open-Sans-regular.svg new file mode 100644 index 0000000..052c59f --- /dev/null +++ b/src/fonts/Open-Sans-regular/Open-Sans-regular.svg @@ -0,0 +1,1637 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/fonts/Open-Sans-regular/Open-Sans-regular.ttf b/src/fonts/Open-Sans-regular/Open-Sans-regular.ttf new file mode 100644 index 0000000..0dae9c3 Binary files /dev/null and b/src/fonts/Open-Sans-regular/Open-Sans-regular.ttf differ diff --git a/src/fonts/Open-Sans-regular/Open-Sans-regular.woff b/src/fonts/Open-Sans-regular/Open-Sans-regular.woff new file mode 100644 index 0000000..ac2b2c6 Binary files /dev/null and b/src/fonts/Open-Sans-regular/Open-Sans-regular.woff differ diff --git a/src/fonts/Open-Sans-regular/Open-Sans-regular.woff2 b/src/fonts/Open-Sans-regular/Open-Sans-regular.woff2 new file mode 100644 index 0000000..402dfd7 Binary files /dev/null and b/src/fonts/Open-Sans-regular/Open-Sans-regular.woff2 differ diff --git a/src/fonts/Oswald-300/LICENSE.txt b/src/fonts/Oswald-300/LICENSE.txt new file mode 100644 index 0000000..6022786 --- /dev/null +++ b/src/fonts/Oswald-300/LICENSE.txt @@ -0,0 +1,93 @@ +Copyright 2016 The Oswald Project Authors (contact@sansoxygen.com) + +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. diff --git a/src/fonts/Oswald-300/Oswald-300.eot b/src/fonts/Oswald-300/Oswald-300.eot new file mode 100644 index 0000000..781ea9a Binary files /dev/null and b/src/fonts/Oswald-300/Oswald-300.eot differ diff --git a/src/fonts/Oswald-300/Oswald-300.svg b/src/fonts/Oswald-300/Oswald-300.svg new file mode 100644 index 0000000..76ebcb6 --- /dev/null +++ b/src/fonts/Oswald-300/Oswald-300.svg @@ -0,0 +1,335 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/fonts/Oswald-300/Oswald-300.ttf b/src/fonts/Oswald-300/Oswald-300.ttf new file mode 100644 index 0000000..27d4a08 Binary files /dev/null and b/src/fonts/Oswald-300/Oswald-300.ttf differ diff --git a/src/fonts/Oswald-300/Oswald-300.woff b/src/fonts/Oswald-300/Oswald-300.woff new file mode 100644 index 0000000..9b6a3a1 Binary files /dev/null and b/src/fonts/Oswald-300/Oswald-300.woff differ diff --git a/src/fonts/Oswald-300/Oswald-300.woff2 b/src/fonts/Oswald-300/Oswald-300.woff2 new file mode 100644 index 0000000..9389252 Binary files /dev/null and b/src/fonts/Oswald-300/Oswald-300.woff2 differ diff --git a/src/fonts/Oswald-regular/LICENSE.txt b/src/fonts/Oswald-regular/LICENSE.txt new file mode 100644 index 0000000..6022786 --- /dev/null +++ b/src/fonts/Oswald-regular/LICENSE.txt @@ -0,0 +1,93 @@ +Copyright 2016 The Oswald Project Authors (contact@sansoxygen.com) + +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. diff --git a/src/fonts/Oswald-regular/Oswald-regular.eot b/src/fonts/Oswald-regular/Oswald-regular.eot new file mode 100644 index 0000000..5f24736 Binary files /dev/null and b/src/fonts/Oswald-regular/Oswald-regular.eot differ diff --git a/src/fonts/Oswald-regular/Oswald-regular.svg b/src/fonts/Oswald-regular/Oswald-regular.svg new file mode 100644 index 0000000..82fe3f9 --- /dev/null +++ b/src/fonts/Oswald-regular/Oswald-regular.svg @@ -0,0 +1,347 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/fonts/Oswald-regular/Oswald-regular.ttf b/src/fonts/Oswald-regular/Oswald-regular.ttf new file mode 100644 index 0000000..1a414c5 Binary files /dev/null and b/src/fonts/Oswald-regular/Oswald-regular.ttf differ diff --git a/src/fonts/Oswald-regular/Oswald-regular.woff b/src/fonts/Oswald-regular/Oswald-regular.woff new file mode 100644 index 0000000..5b327f5 Binary files /dev/null and b/src/fonts/Oswald-regular/Oswald-regular.woff differ diff --git a/src/fonts/Oswald-regular/Oswald-regular.woff2 b/src/fonts/Oswald-regular/Oswald-regular.woff2 new file mode 100644 index 0000000..1fb723a Binary files /dev/null and b/src/fonts/Oswald-regular/Oswald-regular.woff2 differ diff --git a/src/index.css b/src/index.css new file mode 100644 index 0000000..b4cc725 --- /dev/null +++ b/src/index.css @@ -0,0 +1,5 @@ +body { + margin: 0; + padding: 0; + font-family: sans-serif; +} diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..0c2ee1b --- /dev/null +++ b/src/index.js @@ -0,0 +1,54 @@ +import React from 'react'; +import ReactDOM from 'react-dom'; +import { Router, Route, IndexRoute, browserHistory } from 'react-router' +import { Provider } from 'react-redux' +import { syncHistoryWithStore } from 'react-router-redux' +import { UserIsAuthenticated, UserIsNotAuthenticated } from './util/wrappers.js' +import getWeb3 from "./util/web3/getWeb3"; + +// Layouts +import App from './App' +import Home from './layouts/home/Home' +import Dashboard from './layouts/dashboard/Dashboard' +import SignUp from './user/layouts/signup/SignUp' +import Profile from './user/layouts/profile/Profile' + + +import './index.css'; //??? +// Redux Store +import store from './store' + +// ServiceWorker +import registerServiceWorker from './registerServiceWorker'; + +// Initialize react-router-redux. +const history = syncHistoryWithStore(browserHistory, store); + +// Initialize web3 and set in Redux. +getWeb3 + .then(results => { + console.log('Web3 initialized!') + }) + .catch(() => { + console.log('Error in web3 initialization.') + }); + + + +ReactDOM.render(( + + + + + + + + + + + ), + document.getElementById('root') +); + +registerServiceWorker(); + diff --git a/src/layouts/dashboard/Dashboard.js b/src/layouts/dashboard/Dashboard.js new file mode 100644 index 0000000..b2ae92d --- /dev/null +++ b/src/layouts/dashboard/Dashboard.js @@ -0,0 +1,23 @@ +import React, { Component } from 'react' + +class Dashboard extends Component { + constructor(props, { authData }) { + super(props); + authData = this.props + } + + render() { + return( +
    +
    +
    +

    Dashboard

    +

    Congratulations {this.props.authData.name}! If you're seeing this page, you've logged in with your own smart contract successfully.

    +
    +
    +
    + ) + } +} + +export default Dashboard diff --git a/src/layouts/home/Home.js b/src/layouts/home/Home.js new file mode 100644 index 0000000..eb409e1 --- /dev/null +++ b/src/layouts/home/Home.js @@ -0,0 +1,18 @@ +import React, { Component } from 'react' + +class Home extends Component { + render() { + return( +
    +
    +
    +

    Welcome!

    +

    Lorem ipsum dolor sit amet, tempor vitae vivamus senectus id risus, nulla in, urna sed vitae at ac. Parturient fringilla vestibulum, vitae metus tempus, augue sollicitudin, faucibus scelerisque suspendisse, consectetuer massa fermentum tellus interdum neque. Luctus euismod, nam sodales, non aliquam luctus lorem tellus, habitasse porttitor fusce sed mauris omnis massa, mauris felis pede sodales ligula semper. Amet ut id voluptatum. Nunc amet sem, fusce wisi interdum, et a. Fusce dolor augue in non aliquam, id vestibulum, lacinia diam ante sit felis et, viverra velit, nulla sociosqu autem.

    +
    +
    +
    + ) + } +} + +export default Home diff --git a/src/reducer.js b/src/reducer.js new file mode 100644 index 0000000..2af2517 --- /dev/null +++ b/src/reducer.js @@ -0,0 +1,12 @@ +import { combineReducers } from 'redux' +import { routerReducer } from 'react-router-redux' +import userReducer from './user/userReducer' +import web3Reducer from './util/web3/web3Reducer' + +const reducer = combineReducers({ + routing: routerReducer, + user: userReducer, + web3: web3Reducer +}); + +export default reducer diff --git a/src/registerServiceWorker.js b/src/registerServiceWorker.js new file mode 100644 index 0000000..a3e6c0c --- /dev/null +++ b/src/registerServiceWorker.js @@ -0,0 +1,117 @@ +// In production, we register a service worker to serve assets from local cache. + +// This lets the app load faster on subsequent visits in production, and gives +// it offline capabilities. However, it also means that developers (and users) +// will only see deployed updates on the "N+1" visit to a page, since previously +// cached resources are updated in the background. + +// To learn more about the benefits of this model, read https://goo.gl/KwvDNy. +// This link also includes instructions on opting out of this behavior. + +const isLocalhost = Boolean( + window.location.hostname === 'localhost' || + // [::1] is the IPv6 localhost address. + window.location.hostname === '[::1]' || + // 127.0.0.1/8 is considered localhost for IPv4. + window.location.hostname.match( + /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ + ) +); + +export default function register() { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { + // The URL constructor is available in all browsers that support SW. + const publicUrl = new URL(process.env.PUBLIC_URL, window.location); + if (publicUrl.origin !== window.location.origin) { + // Our service worker won't work if PUBLIC_URL is on a different origin + // from what our page is served on. This might happen if a CDN is used to + // serve assets; see https://github.com/facebookincubator/create-react-app/issues/2374 + return; + } + + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + + if (isLocalhost) { + // This is running on localhost. Lets check if a service worker still exists or not. + checkValidServiceWorker(swUrl); + + // Add some additional logging to localhost, pointing developers to the + // service worker/PWA documentation. + navigator.serviceWorker.ready.then(() => { + console.log( + 'This web app is being served cache-first by a service ' + + 'worker. To learn more, visit https://goo.gl/SC7cgQ' + ); + }); + } else { + // Is not local host. Just register service worker + registerValidSW(swUrl); + } + }); + } +} + +function registerValidSW(swUrl) { + navigator.serviceWorker + .register(swUrl) + .then(registration => { + registration.onupdatefound = () => { + const installingWorker = registration.installing; + installingWorker.onstatechange = () => { + if (installingWorker.state === 'installed') { + if (navigator.serviceWorker.controller) { + // At this point, the old content will have been purged and + // the fresh content will have been added to the cache. + // It's the perfect time to display a "New content is + // available; please refresh." message in your web app. + console.log('New content is available; please refresh.'); + } else { + // At this point, everything has been precached. + // It's the perfect time to display a + // "Content is cached for offline use." message. + console.log('Content is cached for offline use.'); + } + } + }; + }; + }) + .catch(error => { + console.error('Error during service worker registration:', error); + }); +} + +function checkValidServiceWorker(swUrl) { + // Check if the service worker can be found. If it can't reload the page. + fetch(swUrl) + .then(response => { + // Ensure service worker exists, and that we really are getting a JS file. + if ( + response.status === 404 || + response.headers.get('content-type').indexOf('javascript') === -1 + ) { + // No service worker found. Probably a different app. Reload the page. + navigator.serviceWorker.ready.then(registration => { + registration.unregister().then(() => { + window.location.reload(); + }); + }); + } else { + // Service worker found. Proceed as normal. + registerValidSW(swUrl); + } + }) + .catch(() => { + console.log( + 'No internet connection found. App is running in offline mode.' + ); + }); +} + +export function unregister() { + if ('serviceWorker' in navigator) { + navigator.serviceWorker.ready.then(registration => { + registration.unregister(); + }); + } +} diff --git a/src/store.js b/src/store.js new file mode 100644 index 0000000..0c98744 --- /dev/null +++ b/src/store.js @@ -0,0 +1,22 @@ +import { browserHistory } from 'react-router' +import { createStore, applyMiddleware, compose } from 'redux' +import thunkMiddleware from 'redux-thunk' +import { routerMiddleware } from 'react-router-redux' +import reducer from './reducer' + +// Redux DevTools (see also https://github.com/zalmoxisus/redux-devtools-extension#12-advanced-store-setup) +const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose; + +const routingMiddleware = routerMiddleware(browserHistory); + +const store = createStore( + reducer, + composeEnhancers( + applyMiddleware( + thunkMiddleware, + routingMiddleware + ) + ) +); + +export default store diff --git a/src/user/layouts/profile/Profile.js b/src/user/layouts/profile/Profile.js new file mode 100644 index 0000000..6dfb688 --- /dev/null +++ b/src/user/layouts/profile/Profile.js @@ -0,0 +1,20 @@ +import React, { Component } from 'react' +import ProfileFormContainer from '../../ui/profileform/ProfileFormContainer' + +class Profile extends Component { + render() { + return( +
    +
    +
    +

    Profile

    +

    Edit your account details here.

    + +
    +
    +
    + ) + } +} + +export default Profile diff --git a/src/user/layouts/signup/SignUp.js b/src/user/layouts/signup/SignUp.js new file mode 100644 index 0000000..069e379 --- /dev/null +++ b/src/user/layouts/signup/SignUp.js @@ -0,0 +1,20 @@ +import React, { Component } from 'react' +import SignUpFormContainer from '../../ui/signupform/SignUpFormContainer' + +class SignUp extends Component { + render() { + return( +
    +
    +
    +

    Sign Up

    +

    We've got your wallet information, simply input your name and your account is made!

    + +
    +
    +
    + ) + } +} + +export default SignUp diff --git a/src/user/ui/loginbutton/LoginButton.js b/src/user/ui/loginbutton/LoginButton.js new file mode 100644 index 0000000..6ba658b --- /dev/null +++ b/src/user/ui/loginbutton/LoginButton.js @@ -0,0 +1,11 @@ +import React from 'react' + +const LoginButton = ({ onLoginUserClick }) => { + return( +
  • + onLoginUserClick(event)}>Login +
  • + ) +}; + +export default LoginButton diff --git a/src/user/ui/loginbutton/LoginButtonActions.js b/src/user/ui/loginbutton/LoginButtonActions.js new file mode 100644 index 0000000..994cedc --- /dev/null +++ b/src/user/ui/loginbutton/LoginButtonActions.js @@ -0,0 +1,69 @@ +import ForumContract from '../../../build/contracts/Forum.json' +import { browserHistory } from 'react-router' +import store from '../../../store' + +const contract = require('truffle-contract'); + +export const USER_LOGGED_IN = 'USER_LOGGED_IN'; +function userLoggedIn(user) { + return { + type: USER_LOGGED_IN, + payload: user + } +} + +export function loginUser() { + let web3 = store.getState().web3.web3Instance; + + // Double-check web3's status. + if (typeof web3 !== 'undefined') { + + return function(dispatch) { + // Using truffle-contract we create the authentication object. + const authentication = contract(ForumContract); + authentication.setProvider(web3.currentProvider); + + // Declaring this for later so we can chain functions on Authentication. + let authenticationInstance; + + // Get current ethereum wallet. + web3.eth.getCoinbase((error, coinbase) => { + // Log errors, if any. + if (error) { + console.error(error); + } + + authentication.deployed().then(function(instance) { + authenticationInstance = instance; + + // Attempt to login user. + authenticationInstance.login({from: coinbase}) + .then(function(result) { + // If no error, login user. + console.log("Login successful: " + JSON.parse(result)); + dispatch(userLoggedIn({"name": JSON.parse(result)})); + + // Used a manual redirect here as opposed to a wrapper. + // This way, once logged in a user can still access the home page. + let currentLocation = browserHistory.getCurrentLocation(); + + if ('redirect' in currentLocation.query) + return browserHistory.push(decodeURIComponent(currentLocation.query.redirect)); + + + return browserHistory.push('/dashboard') + }) + .catch(function(result) { + // If error, go to signup page. + console.error('Wallet ' + coinbase + ' does not have an account!'); + console.error('Error: ' + result); + + return browserHistory.push('/signup') + }) + }) + }) + } + } else { + console.error('Web3 is not initialized.'); + } +} diff --git a/src/user/ui/loginbutton/LoginButtonContainer.js b/src/user/ui/loginbutton/LoginButtonContainer.js new file mode 100644 index 0000000..244876c --- /dev/null +++ b/src/user/ui/loginbutton/LoginButtonContainer.js @@ -0,0 +1,23 @@ +import { connect } from 'react-redux' +import LoginButton from './LoginButton' +import { loginUser } from './LoginButtonActions' + +const mapStateToProps = (state, ownProps) => { + return {} +}; + +const mapDispatchToProps = (dispatch) => { + return { + onLoginUserClick: (event) => { + event.preventDefault(); + dispatch(loginUser()); + } + } +}; + +const LoginButtonContainer = connect( + mapStateToProps, + mapDispatchToProps +)(LoginButton); + +export default LoginButtonContainer diff --git a/src/user/ui/profileform/ProfileForm.js b/src/user/ui/profileform/ProfileForm.js new file mode 100644 index 0000000..2ec114c --- /dev/null +++ b/src/user/ui/profileform/ProfileForm.js @@ -0,0 +1,42 @@ +import React, { Component } from 'react' + +class ProfileForm extends Component { + constructor(props) { + super(props); + + this.state = { + name: this.props.name + } + } + + onInputChange(event) { + this.setState({ name: event.target.value }) + } + + handleSubmit(event) { + event.preventDefault(); + + if (this.state.name.length < 2) + return alert('Please fill in your name.'); + + this.props.onProfileFormSubmit(this.state.name, event) + } + + render() { + return( +
    +
    + + + This is a required field. + +
    + + +
    +
    + ) + } +} + +export default ProfileForm diff --git a/src/user/ui/profileform/ProfileFormActions.js b/src/user/ui/profileform/ProfileFormActions.js new file mode 100644 index 0000000..a895303 --- /dev/null +++ b/src/user/ui/profileform/ProfileFormActions.js @@ -0,0 +1,56 @@ +import ForumContract from '../../../build/contracts/Forum.json' +import store from '../../../store' + +const contract = require('truffle-contract'); + +export const USER_UPDATED = 'USER_UPDATED'; +function userUpdated(user) { + return { + type: USER_UPDATED, + payload: user + } +} + +export function updateUser(name) { + let web3 = store.getState().web3.web3Instance; + + // Double-check web3's status. + if (typeof web3 !== 'undefined') { + + return function(dispatch) { + // Using truffle-contract we create the authentication object. + const authentication = contract(ForumContract); + authentication.setProvider(web3.currentProvider); + + // Declaring this for later so we can chain functions on Authentication. + let authenticationInstance; + + // Get current ethereum wallet. + web3.eth.getCoinbase((error, coinbase) => { + // Log errors, if any. + if (error) { + console.error(error); + } + + authentication.deployed().then(function(instance) { + authenticationInstance = instance; + + // Attempt to login user. + authenticationInstance.signUp(JSON.stringify(name), {from: coinbase}) + .then(function(result) { + console.log("SignUp/name update successful: " + name); + // If no error, update user. + dispatch(userUpdated({"name": name})); + + return alert('Name updated!') + }) + .catch(function(result) { + // If error... + }) + }) + }) + } + } else { + console.error('Web3 is not initialized.'); + } +} diff --git a/src/user/ui/profileform/ProfileFormContainer.js b/src/user/ui/profileform/ProfileFormContainer.js new file mode 100644 index 0000000..bda66a9 --- /dev/null +++ b/src/user/ui/profileform/ProfileFormContainer.js @@ -0,0 +1,25 @@ +import { connect } from 'react-redux' +import ProfileForm from './ProfileForm' +import { updateUser } from './ProfileFormActions' + +const mapStateToProps = (state, ownProps) => { + return { + name: state.user.data.name + } +}; + +const mapDispatchToProps = (dispatch) => { + return { + onProfileFormSubmit: (name, event) => { + event.preventDefault(); + dispatch(updateUser(name)) + } + } +}; + +const ProfileFormContainer = connect( + mapStateToProps, + mapDispatchToProps +)(ProfileForm); + +export default ProfileFormContainer diff --git a/src/user/ui/signupform/SignUpForm.js b/src/user/ui/signupform/SignUpForm.js new file mode 100644 index 0000000..c5f6cc8 --- /dev/null +++ b/src/user/ui/signupform/SignUpForm.js @@ -0,0 +1,44 @@ +import React, { Component } from 'react' + +class SignUpForm extends Component { + constructor(props) { + super(props); + + this.state = { + name: '' + } + } + + onInputChange(event) { + this.setState({ name: event.target.value }) + } + + handleSubmit(event) { + event.preventDefault(); + + if (this.state.name.length < 2) + { + return alert('Please fill in your name.') + } + + this.props.onSignUpFormSubmit(this.state.name) + } + + render() { + return( +
    +
    + + + This is a required field. + +
    + + +
    +
    + ) + } +} + +export default SignUpForm diff --git a/src/user/ui/signupform/SignUpFormActions.js b/src/user/ui/signupform/SignUpFormActions.js new file mode 100644 index 0000000..3fcdb09 --- /dev/null +++ b/src/user/ui/signupform/SignUpFormActions.js @@ -0,0 +1,45 @@ +import ForumContract from '../../../build/contracts/Forum.json' +import { loginUser } from '../loginbutton/LoginButtonActions' +import store from '../../../store' + +const contract = require('truffle-contract'); + +export function signUpUser(name) { + let web3 = store.getState().web3.web3Instance; + + // Double-check web3's status. + if (typeof web3 !== 'undefined') { + + return function(dispatch) { + // Using truffle-contract we create the authentication object. + const authentication = contract(ForumContract); + authentication.setProvider(web3.currentProvider); + + // Declaring this for later so we can chain functions on Authentication. + let authenticationInstance; + + // Get current ethereum wallet. + web3.eth.getCoinbase((error, coinbase) => { + // Log errors, if any. + if (error) + console.error(error); + + authentication.deployed().then(function(instance) { + authenticationInstance = instance; + + // Attempt to sign up user. + authenticationInstance.signUp(JSON.stringify(name), {from: coinbase}) + .then(function(result) { + // If no error, login user. + return dispatch(loginUser()) + }) + .catch(function(result) { + console.log("SignUp error: " + result); + }) + }) + }) + } + } else { + console.error('Web3 is not initialized.'); + } +} diff --git a/src/user/ui/signupform/SignUpFormContainer.js b/src/user/ui/signupform/SignUpFormContainer.js new file mode 100644 index 0000000..358db7d --- /dev/null +++ b/src/user/ui/signupform/SignUpFormContainer.js @@ -0,0 +1,22 @@ +import { connect } from 'react-redux' +import SignUpForm from './SignUpForm' +import { signUpUser } from './SignUpFormActions' + +const mapStateToProps = (state, ownProps) => { + return {} +}; + +const mapDispatchToProps = (dispatch) => { + return { + onSignUpFormSubmit: (name) => { + dispatch(signUpUser(name)) + } + } +}; + +const SignUpFormContainer = connect( + mapStateToProps, + mapDispatchToProps +)(SignUpForm); + +export default SignUpFormContainer diff --git a/src/user/userReducer.js b/src/user/userReducer.js new file mode 100644 index 0000000..0904126 --- /dev/null +++ b/src/user/userReducer.js @@ -0,0 +1,22 @@ +const initialState = { + data: null +}; + +const userReducer = (state = initialState, action) => { + if (action.type === 'USER_LOGGED_IN' || action.type === 'USER_UPDATED') + { + return Object.assign({}, state, { + data: action.payload + }) + } + + if (action.type === 'USER_LOGGED_OUT') + { + return Object.assign({}, state, { + data: null + }) + } + return state; +}; + +export default userReducer diff --git a/src/util/web3/getWeb3.js b/src/util/web3/getWeb3.js new file mode 100644 index 0000000..33d0ca7 --- /dev/null +++ b/src/util/web3/getWeb3.js @@ -0,0 +1,51 @@ +import store from '../../store' +import Web3 from 'web3' + +export const WEB3_INITIALIZED = 'WEB3_INITIALIZED'; +function web3Initialized(results) { + return { + type: WEB3_INITIALIZED, + payload: results + } +} + +let getWeb3 = new Promise(function(resolve, reject) { + // Wait for loading completion to avoid race conditions with web3 injection timing. + window.addEventListener('load', function(dispatch) { + var results; + var web3 = window.web3; + + // Checking if Web3 has been injected by the browser (Mist/MetaMask) + if (typeof web3 !== 'undefined') { + // Use Mist/MetaMask's provider. + web3 = new Web3(web3.currentProvider); + + results = { + web3Instance: web3 + }; + + console.log('Injected web3 detected.'); + + resolve(store.dispatch(web3Initialized(results))) + } else { + + // Fallback to localhost if no web3 injection. + + var provider = new Web3.providers.HttpProvider('http://localhost:8545'); + + web3 = new Web3(provider); + + results = { + web3Instance: web3 + }; + + console.log('No web3 instance injected, using Local web3.'); + + resolve(store.dispatch(web3Initialized(results))) + } + + // TODO: Error checking. + }) +}); + +export default getWeb3 \ No newline at end of file diff --git a/src/util/web3/web3Reducer.js b/src/util/web3/web3Reducer.js new file mode 100644 index 0000000..be08027 --- /dev/null +++ b/src/util/web3/web3Reducer.js @@ -0,0 +1,16 @@ +const initialState = { + web3Instance: null +}; + +const web3Reducer = (state = initialState, action) => { + if (action.type === 'WEB3_INITIALIZED') + { + return Object.assign({}, state, { + web3Instance: action.payload.web3Instance + }) + } + + return state +}; + +export default web3Reducer diff --git a/src/util/wrappers.js b/src/util/wrappers.js new file mode 100644 index 0000000..04a1571 --- /dev/null +++ b/src/util/wrappers.js @@ -0,0 +1,34 @@ +import { UserAuthWrapper } from 'redux-auth-wrapper' +import { routerActions } from 'react-router-redux' + +// Layout Component Wrappers +export const UserIsAuthenticated = UserAuthWrapper({ + authSelector: state => state.user.data, + redirectAction: routerActions.replace, + failureRedirectPath: '/', // '/login' by default. + wrapperDisplayName: 'UserIsAuthenticated' +}); + +export const UserIsNotAuthenticated = UserAuthWrapper({ + authSelector: state => state.user, + redirectAction: routerActions.replace, + failureRedirectPath: (state, ownProps) => ownProps.location.query.redirect || '/dashboard', + wrapperDisplayName: 'UserIsNotAuthenticated', + predicate: user => user.data === null, + allowRedirectBack: false +}); + +// UI Component Wrappers +export const VisibleOnlyAuth = UserAuthWrapper({ + authSelector: state => state.user, + wrapperDisplayName: 'VisibleOnlyAuth', + predicate: user => user.data, + FailureComponent: null +}); + +export const HiddenOnlyAuth = UserAuthWrapper({ + authSelector: state => state.user, + wrapperDisplayName: 'HiddenOnlyAuth', + predicate: user => user.data === null, + FailureComponent: null +}); diff --git a/test/TestForum.sol b/test/TestForum.sol new file mode 100644 index 0000000..7202eba --- /dev/null +++ b/test/TestForum.sol @@ -0,0 +1,62 @@ +pragma solidity ^0.4.17; + +import "truffle/Assert.sol"; +import "truffle/DeployedAddresses.sol"; +import "../contracts/Forum.sol"; + +contract TestForum { + Forum forumContract = Forum(DeployedAddresses.Forum()); + + function testUserCanSignUp() public { + //Try to sign up + bool expected = true; + bool userSignUpStatus = forumContract.signUp("MrAwesome"); + Assert.equal(userSignUpStatus, expected, "Sign-up failed"); + } + + function testHasUserSignedUp() public { + //Check if sign-up succeeded + address myAddress = this; + require(forumContract.hasUserSignedUp(myAddress)); + } + + /* function testGetUsername() public { + //require (forumContract.getUsername(this) == "MrAwesome"); + } */ + + function testGetUserAddress() public { + //Try to get user address from user-name + address expected = this; + address userAddress = forumContract.getUserAddress("MrAwesome"); + Assert.equal(userAddress, expected, "Getting user address from user-name failed"); + } + + function testIsUserNameTaken() public view { + //Try to test if a user-name is taken + bool expected = false; + bool result = forumContract.isUserNameTaken("somethingElse"); + Assert.equal(result, expected, "Testing if user-name is taken failed"); + + /* expected = true; + result = forumContract.isUserNameTaken("MrAwesome"); + Assert.equal(result, expected, "Testing if user-name is taken failed"); */ + } + + /* function testCreateTopic() public { + uint expected = 1; + uint topicId = forumContract.createTopic(); + Assert.equal(topicId, expected, "whatevs"); + } + + function testCreatePost() public { + uint expected = 1; + uint postId = forumContract.createPost(1); + Assert.equal(postId, expected, "whatevs"); + } */ + + /* function testGetTopicPosts() public { + } */ + + /* function test () public { + } */ +} \ No newline at end of file diff --git a/truffle.js b/truffle.js new file mode 100644 index 0000000..a308ced --- /dev/null +++ b/truffle.js @@ -0,0 +1,17 @@ +module.exports = { + // See + // for more about customizing your Truffle configuration! + networks: { + development: { + host: "localhost", + port: 8545, + network_id: "*" // Match any network id + } + }, + solc: { + optimizer: { + enabled: true, + runs: 500 + } + } +};