Skip to content

Commit

Permalink
Merge pull request #46 from stzups/dev
Browse files Browse the repository at this point in the history
v0.3 Architecture rework
  • Loading branch information
griffinht authored Apr 5, 2021
2 parents 8a8c3ff + 510de40 commit f384493
Show file tree
Hide file tree
Showing 138 changed files with 3,353 additions and 2,407 deletions.
57 changes: 48 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
##v0.1
## v0.1
Add real time drawing

- Change file structure and how files are served
- Fix custom invite URL
- Automatic connection

##v0.2
## v0.2
Basic functionality to allow for more features to be added
- Instant live documents
- Data persistence
- User identity, separation between browser client and user

###v0.2.1
### v0.2.1
Room to document based model

- Add sidebar
Expand All @@ -18,14 +21,14 @@ Room to document based model
- Event based WebSocketHandler
- Change how URLs work

###v0.2.2
### v0.2.2
Add document opening/closing

- Change how queued packets work
- Documents are saved before closed
- Change protocol again

###v0.2.3
### v0.2.3
Flat file data persistence

- Remove ConsoleManager
Expand All @@ -35,7 +38,7 @@ Flat file data persistence
- Complete rework of config system
- SSL support

###v0.2.4
### v0.2.4
User identity

- Change URL parsing
Expand All @@ -44,19 +47,55 @@ User identity
- Sessions are linked to documents
- Improve toString debug

###v0.2.5
### v0.2.5
Multiple clients per user

- Change how sessions are handled
- Clean up script loading
- Fix hashcode issues

###v0.2.6
### v0.2.6
Design

- Clean up CSS
- Add changelog
- Add invite/connected users toolbar
- "Fix" canvas resize
- Change/clean up config system
- Improve client debug
- Better local user with different handshake
- Better local user with different handshake

## v0.3
Architecture rework

### v0.3.1
SQL data persistence

- Dockerized server with Maven dependencies
- Add environment variable config method
- Fix send rate of client
- Remove flatfile, add runtime (in memory only) and PostgresSQL database
- Move frontend to independent HTTP server (nginx)

### v0.3.2
Rework protocol, document serialization

- Canvas objects instead of points
- Rename packets to messages
- Add better serialization/deserialization methods

### v0.3.3
Rework db, implement document persistence

- Canvas is saved in db
- Rework user authentication

### v0.3.4
Document update/delete operations, overhaul db and config

- Fix changes not being saved on canvas close
- Fix canvas serialization
- Fix connected clients list
- Add db creation scripts into version control
- Overhaul config - improve exceptions
- Add document update and delete functionality
51 changes: 1 addition & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,4 @@ welcome to the board project

name pending

This project is separated into the server (`board-server`) and the client (`board-web-client`). All files inside `board-web-client` can be served to the browser and are therefore public.

You will need to build and run the `board-server` project before using or contributing to the client or server.

## Building `board-server`

`board-server` is an HTTP/WebSocket server written in Java 8. Make sure you have the Java 8 JDK and [Apache Maven](https://maven.apache.org/index.html) installed on your system before attempting to build the project.

#### Build Steps
- Clone this repository to your local machine
- Run `mvn clean package` in `board-server` to generate server artifact in the newly created `target` folder

Modifying `board-server` will require you to recompile the project and restart the server.

Modifying `board-web-client` only requires you to refresh your browser. If you do not see your new changes, then use `ctrl+F5` to also reset your browser cache.

## Running `board-server`

Once you have built `board-server`, you may run it using using the following command:

java -jar board-server-xxx.jar --ssl.keystore http

- This starts an HTTP/WebSocket server listening on port 80, which you can connect in your browser at [http://localhost](http://localhost).
- All WebSocket connections run on the same port as the HTTP server, and should connect to [ws://localhost/websocket](ws://localhost/websocket).
- Stop the server gracefully to save persistent data (`ctrl+c` on Windows terminals). Killing the process may result in data loss from any unsaved persistent data.

### Properties

These can be set in several different ways:

##### `board.properties`
Create a file called `board.properties` in the working directory of the server and format as the following

key=value
other.key=value with spaces

##### Command line arguments

java -jar board-server-xxx.jar --key value --other.key "value with spaces"
File indicates a relative (<working directory>/folder/file.ext) or absolute path (C:/folder/file.ext)

| Flag | Type | Default | Description |
| --- | ---- | ------- | ----------- |
| ssl.keystore.path | file | (required) | Path to the PKCS12 `mykeystore.pfx` containing the private key for the server. Set to `http` to use HTTP without SSL encryption |
| ssl.passphrase | string | (optional) | Passphrase for `mykeystore.pfx` |
| document.root.path | file | documentRoot | Should be set to where `board-web-client` is. HTTP requests to a directory (`localhost` or `localhost/folder/`) will be served the `index.html` file of those directories HTTP requests to a file that do not specify an extension (`localhost/file`) will be served a `.html` that corresponds to the requested name
| data.root.path | file | data | Sets the folder location of the flat file storage |
| debug.log.traffic | boolean | false | Will print network throughput (read/write) into the console |
| autosave.interval | integer (seconds) | -1 | Sets how often flat file storage will be saved to disk, or negative value to disable |
| http.cache.time | integer (seconds) | 0 | How long before a cached item expires. Set to 0 for development purposes so refreshing the page will always load your new changes (equivalent of `crtl+f5`) |
Make sure to check out the [Quick Start guide](https://github.com/stzups/Board/wiki/Quick-Start).
2 changes: 2 additions & 0 deletions board-database/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM postgres
COPY init.sql /docker-entrypoint-initdb.d/
43 changes: 43 additions & 0 deletions board-database/init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
CREATE DATABASE board;

-- Connect to board database (currently on default postgres database)
\c board
REVOKE CONNECT ON DATABASE board FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM PUBLIC;

CREATE USER board_room PASSWORD 'changeme';
GRANT CONNECT ON DATABASE board TO board_room;
GRANT USAGE ON SCHEMA public TO board_room;

-- Create tables and grant permissions
CREATE TABLE users(
id bigint NOT NULL,
owned_documents bigint[] NOT NULL,
shared_documents bigint[] NOT NULL,
PRIMARY KEY (id)
);
GRANT SELECT, INSERT, UPDATE ON users TO board_room;

CREATE TABLE documents(
id bigint NOT NULL,
owner bigint NOT NULL,
name varchar(64) not null,
PRIMARY KEY (id)
);
GRANT SELECT, INSERT, UPDATE, DELETE ON documents TO board_room;

CREATE TABLE canvases(
document bigint NOT NULL,
data bytea NOT NULL,
PRIMARY KEY (document)
);
GRANT SELECT, INSERT, UPDATE, DELETE ON canvases TO board_room;

CREATE TABLE persistent_user_sessions(
id bigint NOT NULL,
"user" bigint NOT NULL,
creation_time timestamp,
hashed_token bytea NOT NULL,
PRIMARY KEY (id)
);
GRANT SELECT, INSERT, DELETE ON persistent_user_sessions TO board_room;
10 changes: 10 additions & 0 deletions board-frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#
# Nginx
#
FROM nginx

COPY nginx.conf /etc/nginx/nginx.conf

WORKDIR /user/share/nginx/html

COPY html .
Binary file added board-frontend/html/assets/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<head>
<meta charset="UTF-8">
<title>Board | Empty board</title>
<link rel="stylesheet" href="/style.css">
<link rel="stylesheet" href="/index.css">
<script src="/scripts/main.js"></script>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="index.css">
<script src="scripts/main.js"></script>
</head>
<body>
<aside>
Expand Down
File renamed without changes.
27 changes: 27 additions & 0 deletions board-frontend/html/scripts/Client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export default class Client {
constructor(id, user) {
this.id = id;
this.user = user;
//tooltip
this.icon = document.createElement('img');
this.icon.setAttribute('src', 'assets/default.png');
this.icon.addEventListener('mouseenter', (event) => {
let rect = this.icon.getBoundingClientRect();
this.iconTooltip.style.visibility = 'visible';
this.iconTooltip.style.top = rect.top + 'px';
this.iconTooltip.style.left = rect.left + -50 + 'px';
})
this.icon.addEventListener('mouseleave', (event) => {
this.iconTooltip.style.visibility = 'hidden';
})
this.iconTooltip = document.createElement('div');
if (user != null) {
this.iconTooltip.innerText = user.id;
}
this.iconTooltip.style.position = 'absolute';
this.iconTooltip.style.visibility = 'hidden';
this.iconTooltip.style.zIndex = '1000';
this.iconTooltip.style.color = 'black';
document.getElementsByTagName('body')[0].parentNode.appendChild(this.iconTooltip);
}
}
Loading

0 comments on commit f384493

Please sign in to comment.