diff --git a/lib/web.js b/lib/web.js index 4ccabe6..bf93716 100644 --- a/lib/web.js +++ b/lib/web.js @@ -23,43 +23,42 @@ WEB.prototype.start = function () { __self.srv.set('views', 'web/templates'); __self.srv.use(express.static('./web/public')); + __self.render_opts = { + title: __self.title, + slogan: __self.slogan, + logo: __self.logo, + twitter: __self.twitter, + }; + // ---- Routes ----- __self.srv.get('/', function(req, res) { //lets get the top 5 sql = 'SELECT * FROM viewers ORDER BY points DESC LIMIT 10;'; __self.db.execute(sql, function(rows) { - res.render('index', { - title: __self.title, - slogan: __self.slogan, - logo: __self.logo, - twitter: __self.twitter, - rows: rows, - }); + var opts = __self.render_opts; + opts.rows = rows; + res.render('index', opts); }); }); __self.srv.get('/ladder', function(req, res) { //get the whole viewer list sql = 'SELECT * FROM viewers ORDER BY points DESC;'; __self.db.execute(sql, function(rows) { - res.render('ladder', { - title: __self.title, - slogan: __self.slogan, - logo: __self.logo, - twitter: __self.twitter, - rows: rows, - }); + var opts = __self.render_opts; + opts.rows = rows; + res.render('ladder', opts); }); }); __self.srv.get('/stats', function(req, res) { - //get the whole viewer list - res.render('stats', { - title: __self.title, - slogan: __self.slogan, - logo: __self.logo, - twitter: __self.twitter, - statdir: __self.statdir, - }); + var opts = __self.render_opts; + opts.statdir = __self.statdir; + res.render('stats', opts); + }); + + /* Raw data for android app */ + __self.srv.get('/fanart', function(req, res) { + res.render('fanart', __self.render_opts); }); __self.srv.get('/api/test', function(req, res) { res.send("Hey, its Potatr. This data was pulled from the web."); diff --git a/web/public/css/app.css b/web/public/css/app.css index da15755..88821e1 100644 --- a/web/public/css/app.css +++ b/web/public/css/app.css @@ -18,3 +18,7 @@ .uk-search-field, .uk-search-field::-moz-placeholder { color: #FFFFFF; } + +#fan-art > a { + margin: 8px; +} diff --git a/web/templates/fanart.jade b/web/templates/fanart.jade new file mode 100755 index 0000000..d094b6e --- /dev/null +++ b/web/templates/fanart.jade @@ -0,0 +1,32 @@ +extends layout +block content + div.uk-grid + br + br + div.uk-width-1-1.uk-text-center + h1 Potato Fan Art + div.uk-width-1-1 + div#fan-art.uk-panel.uk-panel-box + +block postscript + script. + var art = [ + { + url: "https://pbs.twimg.com/media/BjxJdEFCcAAO15X.png:large", + user: "Hraugur", + user_link: "https://twitter.com/Hraugur" + }, + { + url: "https://pbs.twimg.com/media/BjxJdEFCcAAO15X.png:large", + user: "Hraugur", + user_link: "https://twitter.com/Hraugur" + }, + ]; + + var $holder = $(".uk-panel-box"); + art.forEach(function(elem) { + var $thumb = $(""); + $thumb.append(""); + $thumb.append("
"); + $holder.append($thumb); + }); diff --git a/web/templates/layout.jade b/web/templates/layout.jade index 3180cb3..304bf2b 100755 --- a/web/templates/layout.jade +++ b/web/templates/layout.jade @@ -42,6 +42,7 @@ html(lang="en") li: a(href='/') Home li: a(href='/ladder') Ladder li: a(href='/stats') Chat Stats + li: a(href='/fanart') Fan Art li: a(href='http://www.twitter.com/#{twitter}'): img(src='/img/twitter.gif', alt='Twitter') div.uk-width-1-1 div.uk-container.uk-container-center