diff --git a/ladder.jade b/ladder.jade new file mode 100644 index 0000000..41e14fb --- /dev/null +++ b/ladder.jade @@ -0,0 +1,71 @@ +//- + title: __self.title, + slogan: __self.slogan, + logo: __self.logo, + twitter: __self.twitter, +//- + +doctype html +html(lang="en") + head + title= title + link(rel='stylesheet', href='/lib/uikit/css/uikit.almost-flat.min.css') + link(rel='stylesheet', href='/css/app.css') + script(src='/lib/jquery.js') + script(src='/lib/uikit/js/uikit.min.js') + body + div.uk-grid + div.uk-width-1-1 + div.uk-grid + div.uk-width-1-4 + img(src='/img/#{logo}') + div.uk-width-2-4 + // bigimagelogo + h1.uk-text-center #{title}
#{slogan} + div.uk-width-1-4 + img.flip(src='/img/#{logo}') + div.uk-width-1-1 + nav.uk-navbar + ul.uk-navbar-nav.uk-navbar-center + li: a(href='http://www.twitch.tv/#{title}'): img(src='/img/twitch.png', alt='Stream') + li: a(href='#') Home + li: a(href='#') Ladder + li: a(href='#') Chat Stats + 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 + div.uk-grid + br + br + div.uk-width-1-2 + div.uk-panel.uk-panel-box + h2 #{title} is + span#status offline. + div#streambox + div.uk-width-1-2 + div.uk-panel.uk-panel-box + table.uk-table.uk-table-hover.uk-table-striped + caption Top 10 Potato Farmers + thead + tr + th Viewer + th Potatoes + tbody + each row in rows + tr + td #{row.user} + td #{row.points} + + script. + $(document).ready(function(){ + $.getJSON('https://api.twitch.tv/kraken/streams/#{title}?callback=?', function(data){ + if(data.stream) { + $('#status').empty().append('online!'); + $("#streambox").append("Game: "+data.stream.game+"
"); + $("#streambox").append("Viewers: "+data.stream.viewers+"
"); + $("#streambox").append("

");; + } else { + $("#streambox").append("

Offline

"); + } + }); + }); diff --git a/lib/initialize.js b/lib/initialize.js index a2d4525..0289fd6 100644 --- a/lib/initialize.js +++ b/lib/initialize.js @@ -38,10 +38,18 @@ exports.initialize = function(options) { modpowers : config.currency.modpowers, chatterbonus: config.currency.chatterbonus }); + web = require('./web.js')(db, { + port : config.web.port, + title : config.twitch.channel, + slogan : config.web.slogan, + logo : config.web.logo, + twitter : config.web.twitter + }); //-------- Start ------- irc.start(); db.start(); + web.start(); currency.start(); if (config.commands === true) commands.start(); @@ -58,4 +66,5 @@ exports.initialize = function(options) { irc.on('message', function (msg) { irc.queue(msg); }); + }; diff --git a/lib/irc.js b/lib/irc.js index d942539..b91b07d 100644 --- a/lib/irc.js +++ b/lib/irc.js @@ -371,4 +371,4 @@ IRC.prototype.monitor_queue = function() { module.exports = function (options) { return new IRC(options); -}; \ No newline at end of file +}; diff --git a/lib/web.js b/lib/web.js new file mode 100644 index 0000000..05c36b5 --- /dev/null +++ b/lib/web.js @@ -0,0 +1,61 @@ +var express = require('express'), + https = require('https'); + +//---- Construct ---- +function WEB(db, options) { + var __self = this; + + __self.db = db; + + __self.port = options.port || 9000; + __self.title = options.title; + __self.slogan = options.slogan; + __self.logo = options.logo; + __self.twitter = options.twitter; +} + +// ---- Methods ---- +WEB.prototype.start = function () { + var __self = this; + __self.srv = express(); + __self.srv.set('view engine', 'jade'); + __self.srv.set('views', 'web/templates'); + __self.srv.use(express.static('./web/public')); + + + // ---- 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, + }); + }); + }); + __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 + }); + }); + }); + + __self.srv.listen(__self.port); + console.log('Started website at '+__self.port); + +}; + +module.exports = function (db, options) { + return new WEB(db, options); +}; diff --git a/node_modules/jade/.npmignore b/node_modules/jade/.npmignore new file mode 100644 index 0000000..fdc7b89 --- /dev/null +++ b/node_modules/jade/.npmignore @@ -0,0 +1,14 @@ +test +support +benchmarks +examples +lib-cov +coverage.html +.gitmodules +.travis.yml +History.md +Makefile +test/ +support/ +benchmarks/ +examples/ diff --git a/node_modules/jade/LICENSE b/node_modules/jade/LICENSE new file mode 100644 index 0000000..8ad0e0d --- /dev/null +++ b/node_modules/jade/LICENSE @@ -0,0 +1,22 @@ +(The MIT License) + +Copyright (c) 2009-2010 TJ Holowaychuk + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/node_modules/jade/README.md b/node_modules/jade/README.md new file mode 100644 index 0000000..2b6de93 --- /dev/null +++ b/node_modules/jade/README.md @@ -0,0 +1,161 @@ +# [![Jade - template engine ](http://i.imgur.com/5zf2aVt.png)](http://jade-lang.com/) + +Full documentation is at [jade-lang.com](http://jade-lang.com/) + + Jade is a high performance template engine heavily influenced by [Haml](http://haml-lang.com) + and implemented with JavaScript for [node](http://nodejs.org). For discussion join the [Google Group](http://groups.google.com/group/jadejs). + + You can test drive Jade online [here](http://naltatis.github.com/jade-syntax-docs). + + [![Build Status](https://travis-ci.org/visionmedia/jade.png?branch=master)](https://travis-ci.org/visionmedia/jade) + [![Dependency Status](https://gemnasium.com/visionmedia/jade.png)](https://gemnasium.com/visionmedia/jade) + [![NPM version](https://badge.fury.io/js/jade.png)](http://badge.fury.io/js/jade) + +## Announcements + +**Deprecation of implicit script/style text-only:** + + Jade version 0.31.0 deprecated implicit text only support for scripts and styles. To fix this all you need to do is add a `.` character after the script or style tag. + + It is hoped that this change will make Jade easier for newcomers to learn without affecting the power of the language or leading to excessive verboseness. + + If you have a lot of Jade files that need fixing you can use [fix-jade](https://github.com/ForbesLindesay/fix-jade) to attempt to automate the process. + +**Command line option change:** + +since `v0.31.0`, `-o` is preferred for `--out` where we used `-O` before. + +## Installation + +via npm: + +```bash +$ npm install jade +``` + +## Syntax + +Jade is a clean, whitespace sensitive syntax for writing html. Here is a simple example: + +```jade +doctype html +html(lang="en") + head + title= pageTitle + script(type='text/javascript'). + if (foo) bar(1 + 5) + body + h1 Jade - node template engine + #container.col + if youAreUsingJade + p You are amazing + else + p Get on it! + p. + Jade is a terse and simple templating language with a + strong focus on performance and powerful features. +``` + +becomes + + +```html + + + + Jade + + + +

Jade - node template engine

+
+

You are amazing

+

Jade is a terse and simple templating language with a strong focus on performance and powerful features.

+
+ + +``` + +The official [jade tutorial](http://jade-lang.com/tutorial/) is a great place to start. While that (and the syntax documentation) is being finished, you can view some of the old documentation [here](https://github.com/visionmedia/jade/blob/master/jade.md) and [here](https://github.com/visionmedia/jade/blob/master/jade-language.md) + +## API + +For full API, see [jade-lang.com/api](http://jade-lang.com/api/) + +```js +var jade = require('jade'); + +// compile +var fn = jade.compile('string of jade', options); +var html = fn(locals); + +// render +var html = jade.render('string of jade', merge(options, locals)); + +// renderFile +var html = jade.renderFile('filename.jade', merge(options, locals)); +``` + +### Options + + - `filename` Used in exceptions, and required when using includes + - `compileDebug` When `false` no debug instrumentation is compiled + - `pretty` Add pretty-indentation whitespace to output _(false by default)_ + +## Browser Support + + The latest version of jade can be download for the browser in standalone form from [here](https://github.com/visionmedia/jade/raw/master/jade.js). It only supports the very latest browsers though, and is a large file. It is recommended that you pre-compile your jade templates to JavaScript and then just use the [runtime.js](https://github.com/visionmedia/jade/raw/master/runtime.js) library on the client. + + To compile a template for use on the client using the command line, do: + +```console +$ jade --client --no-debug filename.jade +``` + +which will produce `filename.js` containing the compiled template. + +## Command Line + +After installing the latest version of [node](http://nodejs.org/), install with: + +```console +$ npm install jade -g +``` + +and run with + +```console +$ jade --help +``` + +## Additional Resources + +Tutorials: + + - cssdeck interactive [Jade syntax tutorial](http://cssdeck.com/labs/learning-the-jade-templating-engine-syntax) + - cssdeck interactive [Jade logic tutorial](http://cssdeck.com/labs/jade-templating-tutorial-codecast-part-2) + - in [Japanese](http://blog.craftgear.net/4f501e97c1347ec934000001/title/10%E5%88%86%E3%81%A7%E3%82%8F%E3%81%8B%E3%82%8Bjade%E3%83%86%E3%83%B3%E3%83%97%E3%83%AC%E3%83%BC%E3%83%88%E3%82%A8%E3%83%B3%E3%82%B8%E3%83%B3) + + +Implementations in other languages: + + - [php](http://github.com/everzet/jade.php) + - [scala](http://scalate.fusesource.org/versions/snapshot/documentation/scaml-reference.html) + - [ruby](https://github.com/slim-template/slim) + - [python](https://github.com/SyrusAkbary/pyjade) + - [java](https://github.com/neuland/jade4j) + +Other: + + - [Emacs Mode](https://github.com/brianc/jade-mode) + - [Vim Syntax](https://github.com/digitaltoad/vim-jade) + - [TextMate Bundle](http://github.com/miksago/jade-tmbundle) + - [Coda/SubEtha syntax Mode](https://github.com/aaronmccall/jade.mode) + - [Screencasts](http://tjholowaychuk.com/post/1004255394/jade-screencast-template-engine-for-nodejs) + - [html2jade](https://github.com/donpark/html2jade) converter + +## License + +MIT diff --git a/node_modules/jade/Readme_zh-cn.md b/node_modules/jade/Readme_zh-cn.md new file mode 100644 index 0000000..160ea0e --- /dev/null +++ b/node_modules/jade/Readme_zh-cn.md @@ -0,0 +1,1285 @@ +# Jade - 模板引擎 + +Jade 是一个高性能的模板引擎,它深受 [Haml](http://haml-lang.com) 影响,它是用 JavaScript 实现的, 并且可以供 [Node](http://nodejs.org) 使用. + +翻译: [草依山](http://jser.me) 等 + +## 声明 + +从 Jade `v0.31.0` 开始放弃了对于 `" +| !{html} +``` + +内联标签同样可以使用文本块来包含文本: + +```jade +label + | Username: + input(name='user[name]') +``` + +或者直接使用标签文本: + +```jade +label Username: + input(name='user[name]') +``` + +_只_ 包含文本的标签,比如 ` + + +

My Site

+

Welcome to my super lame site.

+ + + +``` + +前面已经提到,`include` 可以包含比如 HTML 或者 CSS 这样的内容。给定一个扩展名后,Jade 不会把这个文件当作一个 Jade 源代码,并且会把它当作一个普通文本包含进来: + +``` +html + head + //- css and js have simple filters that wrap them in +