nodebb-plugin-shoutbox
Advanced tools
Comparing version 0.0.7 to 0.0.8
@@ -9,4 +9,3 @@ var async = require('async'), | ||
db = module.parent.require('./database'), | ||
winston = module.parent.require('winston'), | ||
webserver = module.parent.require('./webserver'), | ||
templates = module.parent.require('../public/src/templates'), | ||
SocketIndex = module.parent.require('./socket.io/index'), | ||
@@ -44,2 +43,6 @@ ModulesSockets = module.parent.require('./socket.io/modules'); | ||
} | ||
}, | ||
"api": function(callback) { | ||
//Seriously can't think of a better name atm | ||
callback({}); | ||
} | ||
@@ -85,3 +88,3 @@ }; | ||
callback: function(req, res, callback) { | ||
callback({}); | ||
Shoutbox.config.api(callback); | ||
} | ||
@@ -95,2 +98,4 @@ }); | ||
Shoutbox.widget.template = partial.toString(); | ||
callback(null, custom_routes); | ||
@@ -102,3 +107,3 @@ }); | ||
return scripts.concat([ | ||
'plugins/shoutbox/js/main.js' | ||
'plugins/nodebb-plugin-shoutbox/public/js/main.js' | ||
]); | ||
@@ -139,2 +144,26 @@ } | ||
Shoutbox.widget = { | ||
"template": '', | ||
"define": function(widgets, callback) { | ||
widgets.push({ | ||
widget: "shoutbox", | ||
name: "Shoutbox", | ||
description: "Shoutbox widget.", | ||
content: "" | ||
}); | ||
callback(null, widgets); | ||
}, | ||
"render": function(widget, callback) { | ||
//We don't do anything fancy for now | ||
//This is because we have to maintain compatible with /shoutbox | ||
var html = ''; | ||
if (widget.uid !== 0) { | ||
html = templates.prepare(Shoutbox.widget.template).parse({}); | ||
} | ||
//Remove any container | ||
widget.data.container = ''; | ||
callback(null, html); | ||
} | ||
} | ||
Shoutbox.sockets = { | ||
@@ -141,0 +170,0 @@ "get": function(socket, data, callback) { |
{ | ||
"name": "nodebb-plugin-shoutbox", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "NodeBB Shoutbox Plugin", | ||
@@ -5,0 +5,0 @@ "main": "library.js", |
@@ -5,4 +5,3 @@ { | ||
"description": "NodeBB Plugin Shoutbox", | ||
"minver": "0.3", | ||
"url": "https://github.com/BitBangersCode/nodebb-plugin-shoutbox", | ||
"url": "https://github.com/MrWaffle/nodebb-plugin-shoutbox", | ||
"library": "./library.js", | ||
@@ -15,10 +14,13 @@ "hooks": [ | ||
{ "hook": "filter:scripts.get", "method": "init.global.addScripts", "callbacked": false }, | ||
{ "hook": "filter:widgets.getWidgets", "method": "widget.define", "callbacked": true }, | ||
{ "hook": "filter:widget.render:shoutbox", "method": "widget.render", "callbacked": true }, | ||
{ "hook": "action:app.load", "method": "init.load", "callbacked": false } | ||
], | ||
"staticDirs": { | ||
"shoutbox": "./public" | ||
"public": "./public" | ||
}, | ||
"css": [ | ||
"shoutbox/css/style.css" | ||
] | ||
"less": [ | ||
"public/less/style.less" | ||
], | ||
"minver": "0.4.0" | ||
} |
@@ -5,3 +5,3 @@ $(document).ready(function() { | ||
requirejs([ | ||
'plugins/shoutbox/js/shoutbox.js' | ||
'plugins/nodebb-plugin-shoutbox/public/js/shoutbox.js' | ||
], function(shoutBox) { | ||
@@ -8,0 +8,0 @@ shoutBox.base.init(data.url); |
@@ -51,3 +51,3 @@ define(['string'], function(S) { | ||
if (url === "") { | ||
box.utils.createShoutbox(function(success) { | ||
box.utils.prepareShoutbox(function(success) { | ||
if (success) { | ||
@@ -81,9 +81,11 @@ load(callback); | ||
"addShout": function(shoutBox, shout) { | ||
var shoutContent = shoutBox.find('#shoutbox-content'); | ||
if (shoutContent.find('div[id^="shoutbox-shout"]').length === 0) { | ||
shoutContent.html(''); | ||
if (shout && shout.sid) { | ||
var shoutContent = shoutBox.find('#shoutbox-content'); | ||
if (shoutContent.find('div[id^="shoutbox-shout"]').length === 0) { | ||
shoutContent.html(''); | ||
} | ||
shoutContent.append(box.base.parseShout(shout)); | ||
box.base.scrollToBottom(shoutContent); | ||
box.vars.lastSid = shout.sid; | ||
} | ||
shoutContent.append(box.base.parseShout(shout)); | ||
box.base.scrollToBottom(shoutContent); | ||
box.vars.lastSid = shout.sid; | ||
} | ||
@@ -136,18 +138,5 @@ }; | ||
box.utils = { | ||
"createShoutbox": function(callback) { | ||
"prepareShoutbox": function(callback) { | ||
box.utils.getConfig(function() { | ||
templates.preload_template('shoutbox', function() { | ||
var partial = templates['shoutbox'].parse({}); | ||
var loc = box.vars.config.pagePosition; | ||
if (loc !== 'none') { | ||
if (loc === 'top') { | ||
$(partial).insertBefore('.home'); | ||
} else if (loc === 'bottom') { | ||
$(partial).insertBefore('.footer-stats'); | ||
} | ||
callback(true); | ||
} else { | ||
callback(false); | ||
} | ||
}); | ||
callback(true); | ||
}); | ||
@@ -284,3 +273,3 @@ }, | ||
bootbox.prompt("Enter edited message", function(result) { | ||
if (result === cur || result === null) { | ||
if (result === orig || result === null) { | ||
return; | ||
@@ -287,0 +276,0 @@ } |
Sorry, the diff of this file is not supported yet
42645
989