This might still be relevant.
https://community.nodebb.org/topic/2830/developing-a-child-theme-vs-forking-an-existing-theme
yariplus
Posts
-
baseTheme causing issues? -
How to update each X seconds a widget?I recommend sockets.
This is the way I do it. There's probably better ways, I'm a noob.
I put a listener on my client js,
socket.on('whatever', function(data) { // Update any widgets using data. });
and set a timer in my server code and do:
SocketIO.in("online_users").emit('whatever', {somevalue: getWhateverValue()});
-
Override templates in nodebb-widget-essentials@ethanwu I just submitted the changes needed here.
nodebb-widget-essentials/library.js at 79b92dd812298689d7d939a2b6e105e4095c2a20 · NodeBB/nodebb-widget-essentials
Several basic widgets bundled together in one package including 'HTML', 'Markdown', 'Recent Replies', 'Active Users', and 'Moderators' - nodebb-widget-essentials/library.js at 79b92dd812298689d7d939a2b6e105e4095c2a20 · NodeBB/nodebb-widget-essentials
GitHub (github.com)
If you want to use it right away, you can just replace the widget-essentials
library.js
file with mine until it is updated. -
Have a background while content has a different background@Codejet Your right bracket is drunk.
-
Custom PHP PageThat code would go in you server js.
Example:
(function(module) { "use strict"; var TeamSpeakClient = require("node-teamspeak"), util = require("util"); var Plugin = {}; // static:app.load Plugin.init = function(params, callback) { var app = params.router, middleware = params.middleware, controllers = params.controllers; var cl = new TeamSpeakClient("##SERVERIP###"); cl.send("login", {client_login_name: "##USERNAME##", client_login_password: "##PASSWORD##"}, function(err, response, rawResponse){ cl.send("use", {sid: 1}, function(err, response, rawResponse){ cl.send("clientinfo", {clid: "##CLIENTID##"} ,function(err, response, rawResponse){ console.log(util.inspect(response)); }); }); }); callback(); }; module.exports = Plugin; }(module));
To talk between, use Sockets like so:
(function(module) { "use strict"; var TeamSpeakClient = require("node-teamspeak"), util = require("util"); var SocketPlugins = module.parent.require('./socket.io/plugins'); var Plugin = {}; // static:app.load Plugin.init = function(params, callback) { var app = params.router, middleware = params.middleware, controllers = params.controllers; // Define a namespace for your socket listener SocketPlugins.YourPlugin = { // Define the listener formSubmit: function (socket, data, next) { // data is your form results, as an array. console.log(data[0].value); // Prints the value of the first item in your form. var cl = new TeamSpeakClient("##SERVERIP###"); cl.send("login", {client_login_name: "##USERNAME##", client_login_password: "##PASSWORD##"}, function(err, response, rawResponse){ cl.send("use", {sid: 1}, function(err, response, rawResponse){ cl.send("clientinfo", {clid: "##CLIENTID##"} ,function(err, response, rawResponse){ console.log(util.inspect(response)); // Send a response back to the client. next(null, {whatever: datayouwant}); }); }); }); } }; callback(); }; module.exports = Plugin; }(module));
client js:
<form>...</form> <script> $( "form" ).submit(function( event ) { socket.emit( 'plugins.YourPlugin.formSubmit', $( this ).serializeArray(), function (err, data) { if (data) console.log("Got response from server."); }); event.preventDefault(); }); </script>
Check out the socket.io docs and jquery docs.
-
imgur image upload fail - nodebb V1.1.2 , redactor V1.4.2 , imgur V1.0.16Please try the updated version 1.4.3 and let me know if it works for you.
-
How to access to public dir in my custom themeYou can use the plugin.json file.
In nodebb-theme-lavender for example, plugin.json has:
"staticDirs": { "vendor": "static/vendor" },
there is a file called masonry.js that can accessed at
http://yourdomain.com/plugins/nodebb-theme-lavender/vendor/masonry.js
So in your case, you can use in your plugin.json
"staticDirs": { "fonts": "static/fonts" },
and access it at
http://yourdomain.com/plugins/nodebb-theme-yourtheme/fonts/thefont.ttf
you can do multiple routes with staticDirs like:
"staticDirs": { "fonts": "static/fonts", "scripts": "static/js" },
or make the whole directory reachable like:
"staticDirs": { "static": "static" },
The later is what I usually do.
-
Custom PHP Page@DavidPS You want to use JQuery selectors.
Something like this.
Edit fiddle - JSFiddle - Code Playgroundzap
Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle code editor.
(jsfiddle.net)
-
Embeds disabled in widgets?@tigger Possibly, if your site uses https and the movie is http.
-
Custom PHP PageOn the server, in your socket function, socket.uid is the user's identifier, and it is 0 (false) for guests. So, just return an error when it's 0.
formSubmit: functio6n (socket, data, next) { if (!socket.uid) return next(true); // real user, do stuff here next(null, {real: data}); }
and check for errors in the client js
socket.emit( 'plugins.YourPlugin.formSubmit', $( this ).serializeArray(), function (err, data) { if (err) return; if (data) { // do stuff } });
and if you need to check the user in the client for some reason, it is in the variable
app.user.uid
-
Performance Improvement@charles Other than the github issues list, there isn't an official list.
I would put any specific performance problems you are experiencing in a github issue.
-
Custom PHP PageSure, you do that where you declare your custom route.
function renderSink(req, res, next) { if (!req.uid) return res.redirect('/login'); // Do normal stuff. res.render('demo', someData); } module.exports = function(app, middleware, controllers) { app.get('/demo', middleware.buildHeader, renderSink); app.get('/api/demo', renderSink); };
More info here: http://expressjs.com/4x/api.html#res.redirect
-
Full width pagesCSS rule should do it.
.container { width: 100% !important; }
-
find objects with wildcardNo way to do it with redis, without creating a separate set or sortedset. Look in user/create.js for how nbb does it, there's like 8+ sets created that track user object fields, like 'users:reputation' which relates users' uids with their reputation score. You need to query the wanted reputation scores with getSortedSetByScore() and send the resulting uid array to getObjects().
You need to create sets like that one if you want to quickly query objects for a field value. Also, the object and the sets are not implicitly linked. Whenever the object field changes, you also need to update the set.
-
US Election today#freepony
-
Widgets zones in themes@Nicolas said:
But in ACP, you can specify widget zones for Groups' Detail Page.
Where is a magic?A very naughty manual add in the admin script:
https://github.com/NodeBB/NodeBB/blob/a054353b6c9896693bfb9c64e7e389380bff1ea1/src/widgets/admin.js#L12-L19 -
Help NodeBB doesn't work after upgrade to 1.3.0It looks like you may have too many processes running. Have you tried rebooting your system or increasing the processes limit?
-
Getting a valid session for a Socket.IO appWith v1.0.0, Socket.IO now requires a valid session cookie. My apps no longer work since they are not in a browser and I don't know how/if I can get a valid cookie? I'm using socket.io-client-java.
-
nodebb concept theme v2@rod Not sure about anywhere on the page, but for repeating elements like that, I think I could do that with some very minor changes to the widgets system.
-
Getting a valid session for a Socket.IO appHmm, I'm stuck. I have a feeling there's no way to connect to the forum using socket.io only now from my Java app. Maybe it will work if I send an initial connection via http... but this is a bit inconvenient since I only send messages to my
plugins.*
namespace.