Commit 45f41c2b authored by Aral Balkan's avatar Aral Balkan
Browse files

Cleaned up includes and package.json. Now creating unique file names for the...

Cleaned up includes and package.json. Now creating unique file names for the videos. The video page is now loading the video and showing the poster correctly.
parent c63952aa
express = require 'express' express = require 'express'
multer = require 'multer' multer = require 'multer'
fs = require 'fs' fs = require 'fs'
moment = require 'moment' uuid = require 'node-uuid'
shorthash = require 'shorthash' shorthash = require 'shorthash'
app = express() app = express()
...@@ -13,8 +13,6 @@ app = express() ...@@ -13,8 +13,6 @@ app = express()
# #
videoTemplate = (fs.readFileSync 'templates/video.html').toString() videoTemplate = (fs.readFileSync 'templates/video.html').toString()
console.log videoTemplate
# #
# Use mutler only on the /upload URL # Use mutler only on the /upload URL
# (See https://github.com/expressjs/multer/issues/59) # (See https://github.com/expressjs/multer/issues/59)
...@@ -29,10 +27,14 @@ app.use '/upload', multer { ...@@ -29,10 +27,14 @@ app.use '/upload', multer {
rename: (fieldname, filename) -> rename: (fieldname, filename) ->
# #
# Create a short hash of the unique name so that it is easier to type, etc. # Create a short hash of a unique name so that it is easier to type, etc.
# and isn’t intimidating when the user sees the URL for sharing. # and isn’t intimidating when the user sees the URL for sharing.
# #
return shorthash.unique(fieldname).toLowerCase() uniqueName = uuid.v4() + '-' + Date.now()
console.log 'Unique name = ' + uniqueName
shortUniqueName = shorthash.unique(uniqueName)
console.log 'Short unique name = ' + shortUniqueName
return shortUniqueName
onFileUploadStart: (file) -> onFileUploadStart: (file) ->
# #
...@@ -67,6 +69,11 @@ app.get '/video/:videoName', (request, response) -> ...@@ -67,6 +69,11 @@ app.get '/video/:videoName', (request, response) ->
# Display a video page. # Display a video page.
# #
console.log 'About to display video: ' + request.params.videoName console.log 'About to display video: ' + request.params.videoName
# For dev — remove from production.
videoTemplate = (fs.readFileSync 'templates/video.html').toString()
videoHTML = videoTemplate.replace '{{VIDEO}}', request.params.videoName videoHTML = videoTemplate.replace '{{VIDEO}}', request.params.videoName
console.log videoHTML console.log videoHTML
...@@ -111,6 +118,6 @@ app.post '/upload', (request, response) -> ...@@ -111,6 +118,6 @@ app.post '/upload', (request, response) ->
# Start the server. # Start the server.
# #
server = app.listen 3000, -> server = app.listen 3000, ->
console.log "Listening on port %d", server.address().port console.log "#iamindie Video Campaign — listening on port %d", server.address().port
...@@ -9,11 +9,10 @@ ...@@ -9,11 +9,10 @@
"author": "Aral Balkan", "author": "Aral Balkan",
"license": "GPL-3.0", "license": "GPL-3.0",
"dependencies": { "dependencies": {
"connect-busboy": "0.0.2",
"express": "^4.9.7", "express": "^4.9.7",
"moment": "^2.8.3", "moment": "^2.8.3",
"multer": "^0.1.6", "multer": "^0.1.6",
"shorthash": "0.0.2", "node-uuid": "^1.4.1",
"vid-streamer": "^1.0.0-alpha2" "shorthash": "0.0.2"
} }
} }
...@@ -9,11 +9,17 @@ ...@@ -9,11 +9,17 @@
<body> <body>
<a href='https://ind.ie'><img id='indie-logo' src='/images/hope.png' alt='ind.ie'></a> <a href='https://ind.ie'><img id='indie-logo' src='/images/hope.png' alt='ind.ie'></a>
<h1>#iamindie</h1> <h1><a href='/' style='color:black;'>#iamindie</a></h1>
<video id='video-preview' src='/videos/{{VIDEO}}'></video> <video id='video' src='/videos/{{VIDEO}}' preload='auto' controls></video>
<p>Do you care about freedom, human rights, and democracy? You might just be indie too. <a href='https://ind.ie'>Find out more about Ind.ie</a> and <a href='/'>record your own video</a>.</p> <p>Do you care about freedom, human rights, and democracy? You might just be indie too. <a href='https://ind.ie'>Find out more about Ind.ie</a> and <a href='/'>record your own video</a>.</p>
<script>
// Get the video element to load.
var video = document.getElementById('video');
video.load();
</script>
</body> </body>
</html> </html>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment