From ea73fe7a0c117806a780b1bc8cf0ad0008ee17fc Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Tue, 20 Aug 2013 09:34:00 -0300 Subject: [PATCH] WIP: add songs by others --- lyricsnode/app.js | 19 ++++++++++--------- lyricsnode/routes/round.js | 34 +++++++++++++++++++++++++--------- lyricsnode/views/index.html | 22 ++++++++++++++++++---- 3 files changed, 53 insertions(+), 22 deletions(-) diff --git a/lyricsnode/app.js b/lyricsnode/app.js index 3d47e42..1415ec1 100644 --- a/lyricsnode/app.js +++ b/lyricsnode/app.js @@ -3,22 +3,22 @@ * Module dependencies. */ -var express = require('express') - , round = require('./routes/round') - , http = require('http') - , path = require('path') - , cons = require('consolidate') - , swig = require('swig'); +var express = require('express'); +var round = require('./routes/round'); +var http = require('http'); +var path = require('path'); +var cons = require('consolidate'); +var swig = require('swig'); var app = express(); // all environments -app.engine('.html', cons.swig) +app.engine('.html', cons.swig); swig.init({ - root: path.join(__dirname, 'views'), + root: path.join(__dirname, 'views'), cache: false, allowErrors: true -}) +}); app.set('port', process.env.PORT || 3000); app.set('views', path.join(__dirname, 'views')); @@ -36,6 +36,7 @@ if ('development' == app.get('env')) { } app.get('/', round.index); +app.post('/round/others/', round.others); http.createServer(app).listen(app.get('port'), function(){ console.log('Express server listening on port ' + app.get('port')); diff --git a/lyricsnode/routes/round.js b/lyricsnode/routes/round.js index 10b95cb..16b3dbb 100644 --- a/lyricsnode/routes/round.js +++ b/lyricsnode/routes/round.js @@ -25,6 +25,10 @@ function acronymize(phrase) { return letters.join(''); } +/*********************************************************************** + * Main page + **********************************************************************/ + /** * Pick a song */ @@ -42,24 +46,27 @@ function getSong(res) { throw err; } + console.log('Retrieving artist for song...') db.get('SELECT * FROM artists WHERE id = ' + song.artist, function (err, artist) { if (err) { throw err; } + console.log('Retrieving lyrics for song... ') db.get('SELECT * FROM lyrics WHERE song = ' + song.id, function (err, lyrics) { if (err) { throw err; } - var params = {title: 'Round', - lyrics: lyrics.lyrics, - song_title: song.title, - song_artist: artist.name, - acronym_title: acronymize(song.title), - acronym_artist: acronymize(artist.name), - id: song.id - }; + var params = { + title: 'Round', + lyrics: lyrics.lyrics, + song_title: song.title, + song_artist: artist.name, + acronym_title: acronymize(song.title), + acronym_artist: acronymize(artist.name), + id: song.id + }; res.render('index', params); }); }); @@ -69,4 +76,13 @@ function getSong(res) { exports.index = function (req, res) { getSong(res); -}; \ No newline at end of file +}; + + +/*********************************************************************** + * Support for the small box with the "others" picks + **********************************************************************/ +exports.others = function (req, res) { + console.log('Artist: ' + req.body.artist); + console.log('Song: ' + req.body.song); +}; diff --git a/lyricsnode/views/index.html b/lyricsnode/views/index.html index 1114776..bb90e37 100644 --- a/lyricsnode/views/index.html +++ b/lyricsnode/views/index.html @@ -1,7 +1,7 @@ {% extends "base.html" %} {% macro other %} -
+
- +
@@ -104,3 +102,19 @@ } {% endblock %} + +{% block scripts %} + +{% endblock scripts %}