diff --git a/package.json b/package.json index d4f8c1e..4251e87 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "body-parser": "~1.8.1", "compression": "^1.2.2", "connect-flash": "^0.1.1", + "connect-browserify": "^3.2.1", "cookie-parser": "~1.3.3", "crypto-js": "^3.1.2-5", "debug": "~2.0.0", @@ -48,7 +49,6 @@ }, "devDependencies": { "browserify": "^7.0.0", - "connect-browserify": "^3.2.1", "should": "^4.3.0", "mocha": "^2.0.1", "envify": "^3.2.0", diff --git a/public/images/grid.svg b/public/images/grid.svg new file mode 100644 index 0000000..140cb89 --- /dev/null +++ b/public/images/grid.svg @@ -0,0 +1,56 @@ + diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css index 24821f7..9af324c 100644 --- a/public/stylesheets/style.css +++ b/public/stylesheets/style.css @@ -138,7 +138,13 @@ h3 { margin-bottom: 10px; } .not-found { - opacity: 0.3; + opacity: 0.5; +} +.loading { + position: absolute; + top: 33%; + left: 33%; + width: 33%; } .service-link { text-align: center; diff --git a/routes/search.js b/routes/search.js index da19e5e..61b977b 100644 --- a/routes/search.js +++ b/routes/search.js @@ -16,8 +16,7 @@ module.exports = function(req, res, next) { var searching = false; if (!url.host) { - req.flash('search-error', 'Paste a music link above to find and share the matches'); - res.redirect('/'); + res.json({error:{message:"You need to submit a url."}}); } else { var items = {}; for (var id in services) { @@ -34,16 +33,14 @@ module.exports = function(req, res, next) { services[id].lookupId(result.id, result.type).then(function(item) { items[id] = item; req.db.matches.save({_id:id + "$$" + result.id, created_at: new Date(), services:items}).then(function() { - setTimeout(function() { - res.json(item); - }, 1000) + res.json(item); }); }); } }, function(error) { if (error.code == "ETIMEDOUT") { error = new Error("Error talking to music service"); - error.status = "502"; + error.status = 502; next(error); } else if (!error || !error.status) { error = new Error("An unexpected error happenend"); diff --git a/routes/share.js b/routes/share.js index 8b4ac6b..24b60db 100644 --- a/routes/share.js +++ b/routes/share.js @@ -60,10 +60,6 @@ module.exports = function(req, res, next) { }); shares.sort(function(a, b) { - return !a.id || !b.id; - }).sort(function(a, b) { - return !a.streamUrl || b.streamUrl; - }).sort(function(a, b) { return a.type == "video" && b.type != "video"; }); diff --git a/views/home.jsx b/views/home.jsx index e91bef9..e36675c 100644 --- a/views/home.jsx +++ b/views/home.jsx @@ -47,8 +47,7 @@ var SearchForm = React.createClass({ return; } request.post('/search').send({url:url}).end(function(res) { - console.log(res) - that.transitionTo("/" + res.body.service + "/" + res.body.type + "/" + res.body.id); + that.transitionTo("share", res.body); }); }, @@ -69,8 +68,16 @@ var SearchForm = React.createClass({ module.exports = React.createClass({ getInitialState: function () { + // Use this only on first page load, refresh whenever we navigate back. + if (this.props.recents) { + var recents = this.props.recents; + delete this.props.recents; + return { + recents: recents + }; + } return { - recents: this.props.recents + recents: [] }; }, @@ -104,7 +111,7 @@ module.exports = React.createClass({
-