mirror of
https://github.com/thelounge/thelounge
synced 2024-11-26 05:50:22 +00:00
Add models and plugins
This commit is contained in:
parent
7370b10c22
commit
8e4cdc3e9f
41 changed files with 6385 additions and 26 deletions
17
Gruntfile.js
17
Gruntfile.js
|
@ -1,6 +1,13 @@
|
|||
module.exports = function(grunt) {
|
||||
var files = ["*.js", "lib/*"];
|
||||
var files = [
|
||||
"./lib/**/*.js",
|
||||
"./client/js/shout.js"
|
||||
];
|
||||
grunt.initConfig({
|
||||
watch: {
|
||||
files: files,
|
||||
tasks: ["jshint"]
|
||||
},
|
||||
jshint: {
|
||||
files: files
|
||||
},
|
||||
|
@ -10,18 +17,14 @@ module.exports = function(grunt) {
|
|||
"client/js/components.min.js": ["client/components/*.js"]
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
files: files,
|
||||
tasks: ["default"]
|
||||
}
|
||||
});
|
||||
["jshint", "uglify", "watch"]
|
||||
["watch", "jshint", "uglify"]
|
||||
.forEach(function(task) {
|
||||
grunt.loadNpmTasks("grunt-contrib-" + task);
|
||||
});
|
||||
grunt.registerTask(
|
||||
"default",
|
||||
["jshint", "uglify"]
|
||||
["uglify"]
|
||||
);
|
||||
};
|
||||
|
|
0
README.md
Normal file
0
README.md
Normal file
6172
client/components/socket.io.js
Normal file
6172
client/components/socket.io.js
Normal file
File diff suppressed because it is too large
Load diff
4
client/js/components.min.js
vendored
4
client/js/components.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1,3 +1,4 @@
|
|||
$(function() {
|
||||
// ..
|
||||
var socket = io();
|
||||
socket.emit("h", "hello");
|
||||
});
|
||||
|
|
3
config.js
Normal file
3
config.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
port: 9000
|
||||
};
|
2
index.js
2
index.js
|
@ -1,3 +1,3 @@
|
|||
process.chdir(__dirname);
|
||||
var shout = require("./lib/shout");
|
||||
new shout();
|
||||
shout();
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
var _ = require("lodash");
|
||||
|
||||
module.exports = Chan;
|
||||
|
||||
Chan.Type = {
|
||||
CHANNEL: "channel",
|
||||
LOBBY: "lobby",
|
||||
QUERY: "query"
|
||||
};
|
||||
|
||||
function Chan(attr) {
|
||||
_.merge(this, _.extend({
|
||||
id: global.id = ++global.id || 1,
|
||||
type: Chan.Type.CHANNEL,
|
||||
name: "",
|
||||
messages: [],
|
||||
users: []
|
||||
}));
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
module.exports = Client;
|
||||
|
||||
function Client(attr) {
|
||||
_.merge(this, _.extend({
|
||||
name: "",
|
||||
sockets: null,
|
||||
networks: []
|
||||
}, attr));
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
var _ = require("lodash");
|
||||
var moment = require("moment");
|
||||
|
||||
Msg.Type = {
|
||||
ERROR: "error",
|
||||
JOIN: "join",
|
||||
KICK: "kick",
|
||||
MESSAGE: "message",
|
||||
MODE: "mode",
|
||||
MOTD: "motd",
|
||||
NICK: "nick",
|
||||
NOTICE: "notice",
|
||||
PART: "part",
|
||||
QUIT: "quit",
|
||||
TOPIC: "topic",
|
||||
WHOIS: "whois"
|
||||
};
|
||||
|
||||
module.exports = Msg;
|
||||
|
||||
function Msg(attr) {
|
||||
_.merge(this, _.extend({
|
||||
type: Msg.Type.MESSAGE,
|
||||
time: moment().format("HH:mm"),
|
||||
from: "",
|
||||
text: ""
|
||||
}, attr));
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
var _ = require("lodash");
|
||||
|
||||
module.exports = Network;
|
||||
|
||||
function Network(attr) {
|
||||
_.merge(this, _.extend({
|
||||
id: global.id = ++global.id || 1,
|
||||
connected: false,
|
||||
slate: null,
|
||||
host: "",
|
||||
name: capitalize(this.host.split(".")[1]) || this.host,
|
||||
channels: []
|
||||
}, attr));
|
||||
}
|
||||
|
||||
function capitalize(str) {
|
||||
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
var _ = require("lodash");
|
||||
|
||||
module.exports = User;
|
||||
|
||||
function User(attr) {
|
||||
_.merge(this, _.extend({
|
||||
mode: "",
|
||||
name: ""
|
||||
}, attr));
|
||||
}
|
2
lib/plugins/inputs/action.js
Normal file
2
lib/plugins/inputs/action.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
module.exports = function() {
|
||||
};
|
2
lib/plugins/inputs/connect.js
Normal file
2
lib/plugins/inputs/connect.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
module.exports = function() {
|
||||
};
|
2
lib/plugins/inputs/invite.js
Normal file
2
lib/plugins/inputs/invite.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
module.exports = function() {
|
||||
};
|
2
lib/plugins/inputs/join.js
Normal file
2
lib/plugins/inputs/join.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
module.exports = function() {
|
||||
};
|
2
lib/plugins/inputs/kick.js
Normal file
2
lib/plugins/inputs/kick.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
module.exports = function() {
|
||||
};
|
2
lib/plugins/inputs/mode.js
Normal file
2
lib/plugins/inputs/mode.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
module.exports = function() {
|
||||
};
|
2
lib/plugins/inputs/msg.js
Normal file
2
lib/plugins/inputs/msg.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
module.exports = function() {
|
||||
};
|
2
lib/plugins/inputs/nick.js
Normal file
2
lib/plugins/inputs/nick.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
module.exports = function() {
|
||||
};
|
2
lib/plugins/inputs/notice.js
Normal file
2
lib/plugins/inputs/notice.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
module.exports = function() {
|
||||
};
|
2
lib/plugins/inputs/part.js
Normal file
2
lib/plugins/inputs/part.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
module.exports = function() {
|
||||
};
|
2
lib/plugins/inputs/quit.js
Normal file
2
lib/plugins/inputs/quit.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
module.exports = function() {
|
||||
};
|
2
lib/plugins/inputs/raw.js
Normal file
2
lib/plugins/inputs/raw.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
module.exports = function() {
|
||||
};
|
2
lib/plugins/inputs/topic.js
Normal file
2
lib/plugins/inputs/topic.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
module.exports = function() {
|
||||
};
|
2
lib/plugins/inputs/whois.js
Normal file
2
lib/plugins/inputs/whois.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
module.exports = function() {
|
||||
};
|
2
lib/plugins/irc-events/errors.js
Normal file
2
lib/plugins/irc-events/errors.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
module.exports = function() {
|
||||
};
|
2
lib/plugins/irc-events/join.js
Normal file
2
lib/plugins/irc-events/join.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
module.exports = function() {
|
||||
};
|
2
lib/plugins/irc-events/kick.js
Normal file
2
lib/plugins/irc-events/kick.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
module.exports = function() {
|
||||
};
|
2
lib/plugins/irc-events/message.js
Normal file
2
lib/plugins/irc-events/message.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
module.exports = function() {
|
||||
};
|
2
lib/plugins/irc-events/mode.js
Normal file
2
lib/plugins/irc-events/mode.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
module.exports = function() {
|
||||
};
|
2
lib/plugins/irc-events/motd.js
Normal file
2
lib/plugins/irc-events/motd.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
module.exports = function() {
|
||||
};
|
2
lib/plugins/irc-events/names.js
Normal file
2
lib/plugins/irc-events/names.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
module.exports = function() {
|
||||
};
|
2
lib/plugins/irc-events/nick.js
Normal file
2
lib/plugins/irc-events/nick.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
module.exports = function() {
|
||||
};
|
2
lib/plugins/irc-events/notice.js
Normal file
2
lib/plugins/irc-events/notice.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
module.exports = function() {
|
||||
};
|
2
lib/plugins/irc-events/part.js
Normal file
2
lib/plugins/irc-events/part.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
module.exports = function() {
|
||||
};
|
2
lib/plugins/irc-events/quit.js
Normal file
2
lib/plugins/irc-events/quit.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
module.exports = function() {
|
||||
};
|
2
lib/plugins/irc-events/topic.js
Normal file
2
lib/plugins/irc-events/topic.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
module.exports = function() {
|
||||
};
|
2
lib/plugins/irc-events/welcome.js
Normal file
2
lib/plugins/irc-events/welcome.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
module.exports = function() {
|
||||
};
|
2
lib/plugins/irc-events/whois.js
Normal file
2
lib/plugins/irc-events/whois.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
module.exports = function() {
|
||||
};
|
68
lib/shout.js
68
lib/shout.js
|
@ -1,20 +1,58 @@
|
|||
var _ = require("lodash");
|
||||
var connect = require("connect");
|
||||
var config = require("../config") || {};
|
||||
var http = require("connect");
|
||||
var io = require("socket.io");
|
||||
|
||||
module.exports = Shout;
|
||||
var sockets = null;
|
||||
var clients = [];
|
||||
|
||||
/**
|
||||
* @class
|
||||
*/
|
||||
function Shout() {
|
||||
this.listen();
|
||||
}
|
||||
var inputs = [
|
||||
"action",
|
||||
"connect",
|
||||
"invite",
|
||||
"join",
|
||||
"kick",
|
||||
"mode",
|
||||
"msg",
|
||||
"nick",
|
||||
"notice",
|
||||
"part",
|
||||
"quit",
|
||||
"raw",
|
||||
"topic",
|
||||
"whois"
|
||||
];
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
Shout.prototype.listen = function() {
|
||||
var http = connect()
|
||||
.use(connect.static("client"))
|
||||
.listen(9000);
|
||||
var events = [
|
||||
"errors",
|
||||
"join",
|
||||
"kick",
|
||||
"mode",
|
||||
"motd",
|
||||
"message",
|
||||
"names",
|
||||
"nick",
|
||||
"notice",
|
||||
"part",
|
||||
"quit",
|
||||
"topic",
|
||||
"welcome",
|
||||
"whois"
|
||||
];
|
||||
|
||||
module.exports = function() {
|
||||
sockets = io(http().use(http.static("client")).listen(config.port || 9000));
|
||||
sockets.on("connection", function(socket) {
|
||||
init(socket);
|
||||
});
|
||||
};
|
||||
|
||||
var init = function(socket, client) {
|
||||
if (!client) {
|
||||
} else {
|
||||
}
|
||||
};
|
||||
|
||||
var auth = function(data) {
|
||||
// ..
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue