Cleaned up Glitch-specific

This commit is contained in:
Marcus Noble 2020-04-13 13:17:44 +01:00
parent 7f5ec3e395
commit 1ef7b12f1e
5 changed files with 24 additions and 1412 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
node_modules
.glitch-assets

View File

@ -1,7 +0,0 @@
{"name":"drag-in-files.svg","date":"2016-10-22T16:17:49.954Z","url":"https://cdn.hyperdev.com/drag-in-files.svg","type":"image/svg","size":7646,"imageWidth":276,"imageHeight":276,"thumbnail":"https://cdn.hyperdev.com/drag-in-files.svg","thumbnailWidth":276,"thumbnailHeight":276,"dominantColor":"rgb(102, 153, 205)","uuid":"adSBq97hhhpFNUna"}
{"name":"click-me.svg","date":"2016-10-23T16:17:49.954Z","url":"https://cdn.hyperdev.com/click-me.svg","type":"image/svg","size":7116,"imageWidth":276,"imageHeight":276,"thumbnail":"https://cdn.hyperdev.com/click-me.svg","thumbnailWidth":276,"thumbnailHeight":276,"dominantColor":"rgb(243, 185, 186)","uuid":"adSBq97hhhpFNUnb"}
{"name":"paste-me.svg","date":"2016-10-24T16:17:49.954Z","url":"https://cdn.hyperdev.com/paste-me.svg","type":"image/svg","size":7242,"imageWidth":276,"imageHeight":276,"thumbnail":"https://cdn.hyperdev.com/paste-me.svg","thumbnailWidth":276,"thumbnailHeight":276,"dominantColor":"rgb(42, 179, 185)","uuid":"adSBq97hhhpFNUnc"}
{"uuid":"adSBq97hhhpFNUna","deleted":true}
{"uuid":"adSBq97hhhpFNUnb","deleted":true}
{"uuid":"adSBq97hhhpFNUnc","deleted":true}
{"name":"Game-show-buzzer-sound-effect.mp3","date":"2020-04-09T16:57:28.374Z","url":"https://cdn.glitch.com/81aebabf-079d-4504-b844-d90d643962c4%2FGame-show-buzzer-sound-effect.mp3","type":"audio/mpeg","size":70136,"thumbnail":"https://cdn.glitch.com/81aebabf-079d-4504-b844-d90d643962c4%2Fthumbnails%2FGame-show-buzzer-sound-effect.mp3","thumbnailWidth":210,"thumbnailHeight":210,"uuid":"yN2JIbEQPO4yxL0N"}

13
Dockerfile Normal file
View File

@ -0,0 +1,13 @@
FROM node:12
WORKDIR /app
ADD package.json .
RUN npm install
ADD . .
ENV PORT=80
EXPOSE 80
CMD npm start

View File

@ -16,7 +16,7 @@ app.use(Fingerprint({
}));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.urlencoded({ extended: true }));
app.engine('handlebars', exphbs());
app.set('view engine', 'handlebars');
@ -24,7 +24,7 @@ app.set('view engine', 'handlebars');
app.use(express.static("public"));
app.get("/", (request, response) => {
response.render('index', {
response.render('index', {
layout: false,
suggestedTitle: randomWords({exactly: 1, wordsPerString: 3, separator: '-', maxLength: 5})
});
@ -33,13 +33,10 @@ app.get("/", (request, response) => {
app.get("/:roomId/join", (request, response) => {
let room = rooms.getOrCreateRoom(request.params.roomId.toLowerCase());
let participant = room.participants.find(p => p.participantId === request.fingerprint.hash);
console.log(request.fingerprint.hash);
console.log(participant);
if (participant) {
response.render('room', {
layout: false,
layout: false,
room: request.params.roomId.toLowerCase(),
name: participant.participantName,
participantName: participant.participantName,
@ -48,7 +45,7 @@ app.get("/:roomId/join", (request, response) => {
});
} else {
response.render('join', {layout: false, room: request.params.roomId.toLowerCase()});
}
}
});
app.get("/:roomId/audience", (request, response) => {
@ -69,7 +66,7 @@ const wss = new WebSocket.Server({ server });
wss.on('connection', (ws, req) => {
let roomId = req.url.substring(1).toLowerCase();
if (roomId.includes("/audience")) {
roomId = roomId.replace("/audience", "");
rooms.addAudienceWS(roomId, ws);
@ -86,11 +83,11 @@ wss.on('connection', (ws, req) => {
rooms.buzz(roomId, participant);
}
});
ws.on('close', () => {
if (participant) {
rooms.removeParticipant(roomId, participant.participantId);
rooms.removeParticipant(roomId, participant.participantId);
}
});
}
});
});

File diff suppressed because it is too large Load Diff