diff options
| -rw-r--r-- | config.json.example | 1 | ||||
| -rw-r--r-- | public/assets/javascripts/mx/mx.js | 14 | ||||
| -rw-r--r-- | public/assets/javascripts/mx/primitives/mx.text.js | 2 | ||||
| -rw-r--r-- | public/assets/javascripts/mx/primitives/mx.video.js | 4 | ||||
| -rw-r--r-- | public/assets/javascripts/mx/primitives/mx.vimeo.js | 4 | ||||
| -rw-r--r-- | public/assets/javascripts/mx/primitives/mx.youtube.js | 4 | ||||
| -rw-r--r-- | server/index.js | 3 | ||||
| -rw-r--r-- | server/lib/auth/index.js | 10 | ||||
| -rw-r--r-- | server/lib/middleware.js | 11 | ||||
| -rw-r--r-- | server/lib/util.js | 4 | ||||
| -rw-r--r-- | server/repl.js | 17 |
11 files changed, 53 insertions, 21 deletions
diff --git a/config.json.example b/config.json.example index 90df381..6028021 100644 --- a/config.json.example +++ b/config.json.example @@ -3,6 +3,7 @@ "hostName": "lvh.me", "port": 3000, "socketPort": 1337, + "databaseHost": "lvh.me", "pageSize": 10, "env": { "development": 1 } } diff --git a/public/assets/javascripts/mx/mx.js b/public/assets/javascripts/mx/mx.js index 40a5f2e..d59a551 100644 --- a/public/assets/javascripts/mx/mx.js +++ b/public/assets/javascripts/mx/mx.js @@ -162,24 +162,24 @@ var MX = MX || (function (undefined) { Object.defineProperty(this, 'width', { get: function () { return width - || parseInt(self.el.style.width, 10) + || parseInt(self.el.style.width*devicePixelRatio, 10) || 0 }, set: function (val) { width = val - this.el.style.width = width + 'px' + this.el.style.width = (width/devicePixelRatio) + 'px' } }) Object.defineProperty(this, 'height', { get: function () { return height - || parseInt(self.el.style.height, 10) + || parseInt(self.el.style.height*devicePixelRatio, 10) || 0 }, set: function (val) { height = val - this.el.style.height = height + 'px' + this.el.style.height = (height/devicePixelRatio) + 'px' } }) } @@ -302,9 +302,9 @@ var MX = MX || (function (undefined) { + (-this.y).toFixed(floatPrecision) + 'px,' + (-this.z).toFixed(floatPrecision) + 'px) ' + 'scale3d(' - + this.scaleX.toFixed(floatPrecision) + ',' - + this.scaleY.toFixed(floatPrecision) + ',' - + this.scaleZ.toFixed(floatPrecision) + ') ' + + (devicePixelRatio * this.scaleX).toFixed(floatPrecision) + ',' + + (devicePixelRatio * this.scaleY).toFixed(floatPrecision) + ',' + + (devicePixelRatio * this.scaleZ).toFixed(floatPrecision) + ') ' if (rotationTranslation) { transformString += rotationTranslation.before diff --git a/public/assets/javascripts/mx/primitives/mx.text.js b/public/assets/javascripts/mx/primitives/mx.text.js index a0f9283..6b5681b 100644 --- a/public/assets/javascripts/mx/primitives/mx.text.js +++ b/public/assets/javascripts/mx/primitives/mx.text.js @@ -47,7 +47,7 @@ MX.Text = MX.Object3D.extend({ if (! font.color || font.color[0] == "#") { font.color = [0,0,0] } this.inner.style.fontFamily = "'" + font.family + "',sans-serif" - this.el.style.fontSize = (2 * font.size) + "pt" + this.el.style.fontSize = (2 * font.size / devicePixelRatio) + "pt" this.el.style.textAlign = font.align this.el.style.color = rgb_string(font.color) }, diff --git a/public/assets/javascripts/mx/primitives/mx.video.js b/public/assets/javascripts/mx/primitives/mx.video.js index 333e1d2..c281f02 100644 --- a/public/assets/javascripts/mx/primitives/mx.video.js +++ b/public/assets/javascripts/mx/primitives/mx.video.js @@ -31,8 +31,8 @@ MX.Video = MX.Object3D.extend({ this.player.addEventListener("loadedmetadata", this.ready.bind(this)) this.player.addEventListener("error", this.error.bind(this)) this.player.addEventListener("ended", this.finished.bind(this)) - this.player.width = this.width - this.player.height = this.height + this.player.width = "100%" + this.player.height = "100%" this.player.src = this.media.url this.player.load() diff --git a/public/assets/javascripts/mx/primitives/mx.vimeo.js b/public/assets/javascripts/mx/primitives/mx.vimeo.js index e71b105..fe5ce86 100644 --- a/public/assets/javascripts/mx/primitives/mx.vimeo.js +++ b/public/assets/javascripts/mx/primitives/mx.vimeo.js @@ -32,8 +32,8 @@ MX.Vimeo = MX.Object3D.extend({ preload.id = uid preload.setAttribute("src", "//player.vimeo.com/video/" + this.media.token + "?api=1&badge=0&controls=0branding=0&byline=0&portrait=0&title=0&" + loop + "&player_id=" + uid) preload.style.backgroundImage = "url(" + this.media.thumbnail + ")" - preload.style.width = this.media.width + "px" - preload.style.height = this.media.height + "px" + preload.style.width = "100%" + preload.style.height = "100%" preload.style.border = "0" preload.style.pointerEvents = "none" preload.className = "preload" diff --git a/public/assets/javascripts/mx/primitives/mx.youtube.js b/public/assets/javascripts/mx/primitives/mx.youtube.js index 3f342a1..5c92378 100644 --- a/public/assets/javascripts/mx/primitives/mx.youtube.js +++ b/public/assets/javascripts/mx/primitives/mx.youtube.js @@ -31,8 +31,8 @@ MX.Youtube = MX.Object3D.extend({ preload.id = uid preload.style.backgroundImage = "url(" + this.media.thumbnail + ")" preload.style.backgroundSize = "cover" - preload.style.width = this.media.width + "px" - preload.style.height = this.media.height + "px" + preload.style.width = "100%" + preload.style.height = "100%" preload.style.pointerEvents = "none" preload.style.position = "absolute" preload.style.top = "0" diff --git a/server/index.js b/server/index.js index 4fbd8d1..9a9323c 100644 --- a/server/index.js +++ b/server/index.js @@ -20,7 +20,7 @@ var http = require('http'), var app = express() var server -var DATABASE_URI = process.env.MONGOLAB_URI || ('mongodb://' + config.hostName + '/vvalls') +var DATABASE_URI = process.env.MONGOLAB_URI || ('mongodb://' + config.databaseHost + '/vvalls') // @@ -68,6 +68,7 @@ site.setup = function(){ // Essential middleware // app.all('*', middleware.enableCORS); app.all('*', middleware.ensureLocals); + app.all('*', middleware.ensureIP); server = http.createServer(app) server.listen(app.get('port'), function () { diff --git a/server/lib/auth/index.js b/server/lib/auth/index.js index 0c46105..a9a2400 100644 --- a/server/lib/auth/index.js +++ b/server/lib/auth/index.js @@ -86,9 +86,9 @@ var auth = { return res.redirect('/auth/usernameTaken'); } if (! user.created_ip) { - user.created_ip = util.ip2num( req.ip ) + user.created_ip = util.ip2num( req.session.ip ) } - user.last_ip = util.ip2num( req.ip ) + user.last_ip = util.ip2num( req.session.ip ) user.save(function(err, data){ if (err) console.err('error setting ip for user') }) req.logIn(user, function(err) { @@ -111,7 +111,7 @@ var auth = { } user.last_seen = new Date () - user.last_ip = util.ip2num( req.ip ) + user.last_ip = util.ip2num( req.session.ip ) user.save(function(err, data){ if (err) console.err('error setting ip for user') }) req.logIn(user, function(err) { @@ -171,8 +171,8 @@ var auth = { displayName: username, password: password, email: email, - created_ip: util.ip2num( req.ip ), - last_ip: util.ip2num( req.ip ), + created_ip: util.ip2num( req.session.ip ), + last_ip: util.ip2num( req.session.ip ), created_at: new Date (), last_seen: new Date (), } diff --git a/server/lib/middleware.js b/server/lib/middleware.js index 7b37658..4848ab0 100644 --- a/server/lib/middleware.js +++ b/server/lib/middleware.js @@ -33,6 +33,17 @@ var middleware = { } next(); }, + + ensureIP: function (req, res, next) { + if (req.session.ip) { + req.ip = req.session.ip || "127.0.0.1" + } + else if (req.ips) { + req.ip = req.session.ip = req.ips[0] + req.session.save() + } + next() + }, ensureLocals: function (req, res, next) { res.locals.token = req.csrfToken(); diff --git a/server/lib/util.js b/server/lib/util.js index 1f63a30..273d7d1 100644 --- a/server/lib/util.js +++ b/server/lib/util.js @@ -45,7 +45,9 @@ util.cleanQuery = function (query) { } util.ip2num = function(dot) { - var d = dot.split('.'); + console.log(dot); + + var d = (dot || "127.0.0.1").split('.'); return ((((((+d[0])*256)+(+d[1]))*256)+(+d[2]))*256)+(+d[3]); } diff --git a/server/repl.js b/server/repl.js new file mode 100644 index 0000000..ba94d45 --- /dev/null +++ b/server/repl.js @@ -0,0 +1,17 @@ +var DB_HOST = 'localhost' +var mongoose = require('mongoose') +mongoose.connect('mongodb://' + DB_HOST + '/vvalls', {}, function(){ + console.log("vvalls: connected to", DB_HOST) + var repl = require("repl").start({}); + [ "./lib/schemas/User", + "./lib/schemas/Collaborator", + "./lib/schemas/Documentation", + "./lib/schemas/Layout", + "./lib/schemas/Media", + "./lib/schemas/Project", + ].forEach(function(modName){ + // console.log(name, modName) + var namez = modName.split("/"), name = namez[namez.length-1]; + repl.context[name] = require(modName); + }); +}); |
