diff --git a/modules/flashy/flashy.js b/modules/flashy/flashy.js new file mode 100644 index 0000000..407dba0 --- /dev/null +++ b/modules/flashy/flashy.js @@ -0,0 +1,35 @@ +/** + * Module Name: Flashy + * Description: Makes pages with flashing text and that innit. + */ + +var _ = require('underscore')._; + +var flashy = function(dbot) { + this.colourMap = { + 'red': 'FF0000' + }; + + this.commands = { + '~flashy': function(event) { + var colour = event.params[1]; + var text = event.params[2]; + + if(_.has(this.colourMap, colour)) { + dbot.t('url', { + 'host': dbot.config.web.webHost, + 'port': dbot.config.web.webPort, + 'path': 'flashy/' + colour + '/' + encodeURIComponent(text) + }); + } else { + event.reply('no such colour brah'); + } + } + }; + + this.commands['~flashy'].regex = [/^~qadd ([\d\w-]+[\d\w\s-]*)[ ]?=[ ]?(.+)$/, 3]; +}; + +exports.fetch = function(dbot) { + return new flashy(dbot); +}; diff --git a/modules/flashy/pages.js b/modules/flashy/pages.js new file mode 100644 index 0000000..5b09dd8 --- /dev/null +++ b/modules/flashy/pages.js @@ -0,0 +1,21 @@ +var _ = require('underscore')._; + +var pages = function(dbot) { + return { + '/flashy/:colour/:text': function(req, res) { + if(!_.has(this.colourMap, req.params.colour)) { + req.params.colour = 'red'; + } + var colour = this.colourMap[req.params.colour]; + res.render('flashy', { + 'name': dbot.config.name, + 'colour': colour, + 'text': text + }); + } + }; +}; + +exports.fetch = function(dbot) { + return pages(dbot); +}; diff --git a/views/flashy/flashy.jade b/views/flashy/flashy.jade new file mode 100644 index 0000000..8a13036 --- /dev/null +++ b/views/flashy/flashy.jade @@ -0,0 +1,8 @@ +!!! 5 +html(lang='en') + head + meta(charset='utf-8') + link(rel='stylesheet', type='text/css', href='/styles.css') + title #{name} web interface + body + div.container