Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
eyesore- committed Jan 14, 2017
2 parents f19b23b + 724d88a commit 79d12db
Show file tree
Hide file tree
Showing 11 changed files with 192 additions and 37 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ RUN go get github.com/gorilla/mux
RUN go get github.com/gorilla/websocket
RUN go install github.com/tesis-lab/tesis/editor

RUN go run certMaker.go

RUN webpack

# Run the server command by default when the container starts.
ENTRYPOINT /go/bin/editor

# Document that the service listens on port 8000.
EXPOSE 8000
EXPOSE 8443
19 changes: 19 additions & 0 deletions Neville.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,22 @@ To start server run:
go run editor/*.go
```
from root.

## Deployment with Docker
Assuming the dockerfile is ok, docker hub will build a new image each time we push a new version to the main repo. Deployment on digital ocean is trivial. Choose the "Docker 1.12.5, Ubuntu 16.04" droplet, once it's been created, SSH in and run:
```
docker run -p 443:8443 tesislab/tesis
```
And docker will download and run the latest build exposing port 443 (which is bound to 8443 from the internals of docker).
*nb: builds take ~10min on docker hub, so if you've just pushed, give it time to build the latest image.

If you have previously run an image, docker will cache it locally. At present there doesn't seem to be an elegant way to handle this (big thread on docker github about it), so to get the latest you need to remove the version you have, then get the new one, so run:
```
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
```
to stop then remove all containers, then you can just remove the image:
```
docker rmi tesislab/tesis
```
then just run the docker run above.
4 changes: 2 additions & 2 deletions certMaker.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
)

var (
host = flag.String("host", "127.0.0.1:8443", "Comma-separated hostnames and IPs to generate a certificate for")
host = flag.String("host", "104.236.11.110:8443, 127.0.0.1:8443", "Comma-separated hostnames and IPs to generate a certificate for")
validFrom = flag.String("start-date", "Mon Jan 6 23:54:57 2017", "Mon Jan 6 15:04:05 2016")
validFor = flag.Duration("duration", 365*24*time.Hour, "Duration that certificate is valid for")
isCA = flag.Bool("ca", true, "whether this cert should be its own Certificate Authority")
Expand Down Expand Up @@ -158,4 +158,4 @@ func main() {
pem.Encode(keyOut, pemBlockForKey(priv))
keyOut.Close()
log.Print("written key.pem\n")
}
}
10 changes: 5 additions & 5 deletions client/js/main_content.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// Created by Duncan on 12.29.2016
// Methods for main_content.vu
// HTTP calls ect.
import Utils from '../js/utils.js'
// Methods for main_content.vue
import Utils from '../js/utils.js';
import _ from 'underscore';

module.exports = {
// Function adds each charactor to input
update(e) {
this.input = e.target.value
this.input = e.target.value;
},
wsSend() {
this.ws.send(this.input);
_.debounce(() => { this.ws.send(this.input) }, 500)();
},
// On each keyup counts amount of words on document
wordCounter() {
Expand Down
8 changes: 4 additions & 4 deletions client/main.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// <!-- Created by Duncan on 12.28.2016 -->
import Vue from 'vue'
import VueRouter from 'vue-router'
import MainContent from './vue-components/main_content.vue'
import Utils from './js/utils.js'
import Vue from 'vue';
import VueRouter from 'vue-router';
import MainContent from './vue-components/main_content.vue';
import Utils from './js/utils.js';

Vue.use(VueRouter);

Expand Down
24 changes: 24 additions & 0 deletions client/styles/style.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<<<<<<< HEAD
=======
/*<!-- Created by Duncan on 12.28.2016 -->*/
>>>>>>> 724d88a4db4f68b65bf4c6f5fb1500c7b15dd56b
*, *::before, *::after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
Expand All @@ -9,4 +13,24 @@ html, body{
}
body{
padding-top: 13vh;
<<<<<<< HEAD
=======
}
.float-l {
float: left;
}
.float-r {
float: right;
}

.float-l {
float: left;
}

.float-r {
float: right;
}
.pad-top-8 {
padding-top: 8em;
>>>>>>> 724d88a4db4f68b65bf4c6f5fb1500c7b15dd56b
}
102 changes: 102 additions & 0 deletions client/vue-components/main_content.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
<div class="content">

<div class="content-left">
<<<<<<< HEAD
<p>This area is for live data about text</p>
</div>
<!-- end live data area -->
<!-- text field -->
<div class="content-right float-r">
=======
<VideoComponent id="video" :wsRTC="wsRTC" :answer="answer"></VideoComponent>
<div class="doc-info" v-if="count > 0">
<div>{{ count }} words</div>
Expand All @@ -13,7 +20,24 @@
</div>

<div class="content-right">
<<<<<<< HEAD
<div id="editor"></div>
=======
<!-- Markdown editor -->
<!-- Doesn't really compile markdown yet -->
>>>>>>> d18605cce8f35fc3b8f68f53381b6ac4d2abe005
<div id="editor">
<textarea id="content"
:value="input"
@input="update"
@input.ws-send="wsSend"
@keyup.delete="wordCounter"
@keyup.space="wordCounter"
@keyup.enter="wordCounter(true)">
</textarea>
</div>
<!-- end editor -->
>>>>>>> 724d88a4db4f68b65bf4c6f5fb1500c7b15dd56b
</div>

</div>
Expand All @@ -23,7 +47,14 @@
<script>
import Navbar from './navbar.vue'
import Methods from '../js/main_content.js'
<<<<<<< HEAD
=======
import VideoComponent from './video_component.vue'
<<<<<<< HEAD
=======
// HTTP calls ect.
>>>>>>> d18605cce8f35fc3b8f68f53381b6ac4d2abe005
>>>>>>> 724d88a4db4f68b65bf4c6f5fb1500c7b15dd56b
import Utils from '../js/utils.js'
import {textStats, docSubscribe} from '../js/editor.js'
import sharedb from 'sharedb/lib/client'
Expand All @@ -33,14 +64,34 @@
export default {
created() {
<<<<<<< HEAD
let chance = new Chance()
let c = this.$route.params.channel
this.URI = c !== undefined && /^\w{5}$/.test(c) ? c : chance.word({length: 5})
=======
// get params from URL (if provided)
let c = this.$route.params.channel;
<<<<<<< HEAD
// set URI to params or generated 5 char unique.
let URI = c !== undefined && /^\w{5}$/.test(c) ? c : chance.word({length: 5});
// create websocket with unique address.
this.ws = new WebSocket(`ws:https://${window.location.host}/ws/${URI}`);
// update URL display. I still think we can do this with router somehow :S
window.history.pushState(window.location.origin, '/', URI);
=======
// set URI to params or generated 5 char unique.
let URI = c !== undefined && /^\w{5}$/.test(c) ? c : chance.word({length: 5});
// create websocket with unique address.
this.ws = new WebSocket(`wss:https://${window.location.host}/ws/${URI}`);
>>>>>>> 724d88a4db4f68b65bf4c6f5fb1500c7b15dd56b
//create RTC websocket
this.wsRTC = new WebSocket(`wss:https://${window.location.host}/ws/${this.URI}rtc`);
// update URL display. I still think we can do this with router somehow :S
<<<<<<< HEAD
window.history.pushState(window.location.origin, '/', this.URI);
},
mounted() {
Expand All @@ -50,6 +101,17 @@
// For testing reconnection
window.disconnect = function() {
connection.close();
=======
window.history.pushState(window.location.origin, '/', URI);
>>>>>>> d18605cce8f35fc3b8f68f53381b6ac4d2abe005
// Whenever we receive a message, update textarea
this.ws.onmessage = e => {
if (e.data !== this.input) {
this.input = e.data;
this.wordCounter();
}
>>>>>>> 724d88a4db4f68b65bf4c6f5fb1500c7b15dd56b
}
window.connect = function(URI) {
let socket = new WebSocket(`ws:https://${window.location.host}`);
Expand Down Expand Up @@ -89,6 +151,7 @@
}
</script>
<<<<<<< HEAD
<style scoped>
.main-content{
width: 100vw;
Expand Down Expand Up @@ -124,3 +187,42 @@ code {
color: #f66;
}
</style>
=======
<style>
.main-content{
width: 100vw;
}
.content-right{
width: 70vw;
height: 87vh;
}
.content-left{
position: fixed;
width: 30vw;
}
html, body{
margin: 0;
color: #333;
font-family: 'Monaco', courier, monospace;
}
#editor {
height: 100%
}
textarea, #editor div {
width: 100%;
height: 100%;
vertical-align: top;
padding: 0 20px;
}
textarea {
border: none;
resize: none;
outline: none;
font-size: 1em;
padding: 20px;
}
code {
color: #f66;
}
</style>
>>>>>>> 724d88a4db4f68b65bf4c6f5fb1500c7b15dd56b
42 changes: 20 additions & 22 deletions client/vue-components/navbar.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<!-- Created by Duncan on 12.28.2016 -->
<template>
<nav class="navbar navbar-fixed-top">
<div class="left-nav">
<div class="nav-left">
</div>
<div class="title">
<p>Untitled</p>
<span>Untitled</span>
</div>
<div class="avatar-area">
<!-- can change fullname to image.//size throws an error however it is working?! -->
<avatar fullname="Duncan Nevin" color="rgb(0, 0, 0)" size="20"></avatar>

</div>
</nav>
</template>
Expand All @@ -27,38 +26,37 @@
</script>

<style>
.navbar{
display: table;
z-index: 0;
.navbar {
display: inline-flex;
background-color: rgb(24, 24, 24);
height: 8em;
width: 100vw;
border: transparent;
height: 13vh;
margin: 0;
border: none;
}
.nav-left {
display: flex;
width: 30vw;
}
.title{
display: table-cell;
height: 100%;
color: rgb(255, 255, 255);
font-weight: normal;
text-align: center;
vertical-align: middle;
display: flex;
width: 50vw;
color: #FFF;
align-items: center;
justify-content: center;
}
.avatar-area{
display: table-cell;
text-align: right;
vertical-align: middle;
padding-right: 2em;
}
.avatar{
cursor: pointer;
}
.glyphicon{
color: rgb(255, 255, 255);
}
<<<<<<< HEAD
=======
.left-nav{
position: relative;
display: table-cell;
height: 100%;
width: 30vw;
}
>>>>>>> d18605cce8f35fc3b8f68f53381b6ac4d2abe005
</style>
4 changes: 2 additions & 2 deletions client/vue-components/tool_bar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
position: fixed;
display: table-cell;
z-index: 10;
top: 8em;
top: 15vh;
background-color: rgb(54, 54, 54);
display: table-cell;
margin: 0;
Expand Down Expand Up @@ -101,4 +101,4 @@
.left-side:hover .count{
left: 0;
}
</style>
</style>
10 changes: 10 additions & 0 deletions editor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,22 @@ func main() {
// serve index.html to root, or any path we don't recognise.
r.HandleFunc("/", serveIndex)
r.NotFoundHandler = http.HandlerFunc(serveIndex)
<<<<<<< HEAD

// start 'er up.
log.Fatal(http.ListenAndServe(":8000", r))
=======

// start 'er up.
log.Fatal(http.ListenAndServeTLS(PORTSSL, PUBLIC_KEY, PRIV_KEY, r))
// log.Fatal(http.ListenAndServe(":8000", http.HandlerFunc(redirectToHttps)))
}

func serveIndex(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "client/index.html")
>>>>>>> d18605cce8f35fc3b8f68f53381b6ac4d2abe005
}

func serveIndex(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "client/index.html")
}
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = {
// publicPath: 'dist/',
path: './client/dist',
publicPath: 'client/dist/',
filename:'build.js',
filename: 'build.js',
},
resolve: {
// NPM by default installs Runtime Only version, which will not compile html templates
Expand Down

0 comments on commit 79d12db

Please sign in to comment.