Skip to content

Instantly share code, notes, and snippets.

View psychobunny's full-sized avatar
❤️
Making forums great again™

Andrew Rodrigues psychobunny

❤️
Making forums great again™
View GitHub Profile
@psychobunny
psychobunny / theme.css
Last active August 29, 2015 13:56
Lavender Theme - Color Scheme Modifications (Dark Grey)
.panel-default > .panel-heading {
border-color: #333
}
.btn-primary, .btn-primary:hover, .btn-primary:focus, .btn-primary:active, .btn-primary.active, .open .dropdown-toggle.btn-primary {
background-color: #333;
border-color: #222;
}
.btn-default, .btn-default:hover, .btn-default:focus, .btn-default:active, .btn-default.active, .open .dropdown-toggle.btn-default {
@psychobunny
psychobunny / paypal.html
Last active August 29, 2015 13:56
[nodebb-script-paypal-donate] Paypal Donate button widget for NodeBB Forums
<div style="text-align: center"><p><strong>Do you like NodeBB? Please Donate :)</strong></p><br />
<!-- START: Replace with your paypal donation code -->
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHJwYJKoZIhvcNAQcEoIIHGDCCBxQCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYBFi12ZAJHfeEyLrxaSfrwrOZgGpd8BP9MCZKb8+wTha6cOSsL7O8W9R2NiiVasFnLWz/njFNk9aDV5x1gvkm58evKD5E52OTs5pULFNQkBYf2ZOCGdiL42Hqfug9UlzO2/eT/lX6oqO8wD+aivyxZXscHJFZW8g3GZ8i+t3Nta7jELMAkGBSsOAwIaBQAwgaQGCSqGSIb3DQEHATAUBggqhkiG9w0DBwQIF7YF1/9fHT+AgYC8XAFuZaTGDbX0ddXtGIppC7elXJ1Z/qXmZUQX7Mfs5OP6BacTDMPdqxhGm3wlXCs0vji4i3zoE3TH8EahY2LmsGCGKOo10N7FWsA8SNuoE7pRjkSdHnDUabzDnqmu0xgwU5Csg/4MZvPHO8loQx3/IUPlcm6
@psychobunny
psychobunny / webserver.js
Created February 28, 2014 21:36
webserver.js
/* Main */
app.get('/', app.buildHeader, controllers.home);
app.get('/api/home', app.prepareAPI, controllers.home);
app.get('/login', app.buildHeader, controllers.login);
app.get('/api/login', app.prepareAPI, controllers.login);
app.get('/register', app.buildHeader, controllers.register);
app.get('/api/register', app.prepareAPI, controllers.register);
@psychobunny
psychobunny / webserver.js
Last active August 29, 2015 13:56
webserver.js middlewares
async.series({
currentThemeData: function(next) {
db.getObjectFields('config', ['theme:type', 'theme:id', 'theme:staticDir', 'theme:templates'], function(err, themeData) {
next(err, themeData);
});
},
themesData: function(next) {
meta.themes.get(function(err, themes) {
next(err, themes);
});
@psychobunny
psychobunny / index.js
Created March 1, 2014 21:59
middleware/index.js
var templates = require('./../../public/src/templates'),
translator = require('./../../public/src/translator'),
middleware = require('./middleware'),
meta = require('./../meta'),
db = require('./../database'),
auth = require('./../routes/authentication'),
async = require('async'),
path = require('path'),
fs = require('fs'),
nconf = require('nconf'),
@psychobunny
psychobunny / conversion.MD
Created May 3, 2014 21:00
Converting HBS to templates.js syntax

Use this in a text editor that supports regex search (like Sublime Text)

Find all

\{\{#if ([\S]*)\}\}([\s\S]*?)\{\{else\}\}([\s\S]*?)\{\{/if\}\}

Replace With

<!-- IF $1 -->$2<!-- ELSE -->$3<!-- ENDIF $1 -->
@psychobunny
psychobunny / plugin.js
Last active August 29, 2015 14:01
Plugin example: Custom API homepage for NodeBB, returns topics instead of posts per category
var async = require('async'),
categories = module.parent.require('./categories');
var Plugin = {};
function renderHomepage(req, res, next) {
var uid = req.user ? req.user.uid : 0;
/*
* For reference, this is taken straight from controllers/index.js (controllers.home)
{
"categories": [
{
"cid": "1",
"name": "Announcements",
"description": "Announcements regarding our community",
"icon": "fa-bullhorn",
"bgColor": "#0059B2",
"color": "#fff",
"slug": "1/announcements",
{
"id": "nodebb-plugin-blog-comments",
"name": "NodeBB Blog Comments",
"description": "Lets NodeBB act as a comments engine/widget for your blog.",
"url": "https://github.com/psychobunny/nodebb-plugin-blog-comments",
"library": "./library.js",
"hooks": [
{
"hook": "filter:admin.header.build", "method": "addAdminLink"
},
@psychobunny
psychobunny / mongo-ltrim.js
Created July 28, 2014 18:17
redis-like LTRIM for mongodb
module.listLTrim = function(key, start, stop, callback) {
module.getListRange(key, start, stop, function(err, value) {
if(err) {
if(typeof callback === 'function') {
return callback(err);
}
return;
}
db.collection('objects').update({_key: key }, {$set: value}, function(err, result) {