diff --git a/public/src/forum/admin/themes.js b/public/src/forum/admin/themes.js
index 1378237916..54d0140be2 100644
--- a/public/src/forum/admin/themes.js
+++ b/public/src/forum/admin/themes.js
@@ -7,7 +7,7 @@ var nodebb_admin = (function(nodebb_admin) {
themes.render = function(bootswatch) {
var themeFrag = document.createDocumentFragment(),
themeEl = document.createElement('li'),
- themeContainer = document.querySelector('#content .themes'),
+ themeContainer = document.querySelector('#bootstrap_themes'),
numThemes = bootswatch.themes.length;
for(var x=0;x' +
+ '
' +
+ '
' +
+ ' ' +
+ '' +
+ '
' +
+ '
' + themes[x].name + '
' +
+ '
' + themes[x].description + '
' +
+ '
' +
+ '';
+ themeFrag.appendChild(liEl.cloneNode(true));
+ }
+
+ instListEl.innerHTML = '';
+ instListEl.appendChild(themeFrag);
+ });
+ socket.emit('api:admin:themes.getInstalled');
})();
\ No newline at end of file
diff --git a/public/templates/admin/themes.tpl b/public/templates/admin/themes.tpl
index df8da9b1e1..fb4aaefe6a 100644
--- a/public/templates/admin/themes.tpl
+++ b/public/templates/admin/themes.tpl
@@ -1,12 +1,20 @@
Themes
+
Custom Themes
+
+ The following themes are currently installed in this NodeBB instance.
+
+
+ - Checking for installed themes...
+
+
Bootswatch Themes
NodeBB Themes are powered by Bootswatch, a repository containing themes built
with Bootstrap as a base theme.
-
+
diff --git a/public/themes/.gitignore b/public/themes/.gitignore
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/src/meta.js b/src/meta.js
index 70b7d11ee9..c0e868569b 100644
--- a/src/meta.js
+++ b/src/meta.js
@@ -1,6 +1,8 @@
var utils = require('./../public/src/utils.js'),
RDB = require('./redis.js'),
- async = require('async');
+ async = require('async'),
+ path = require('path'),
+ fs = require('fs');
(function(Meta) {
Meta.config = {
@@ -42,4 +44,37 @@ var utils = require('./../public/src/utils.js'),
RDB.hdel('config', field);
}
}
+
+ Meta.themes = {
+ get: function(callback) {
+ var themePath = path.join(__dirname, '../', 'public/themes');
+ fs.readdir(themePath, function(err, files) {
+ var themeArr = [];
+ async.each(files, function(file, next) {
+ fs.lstat(path.join(themePath, file), function(err, stats) {
+ if(stats.isDirectory()) {
+ var themeDir = file,
+ themeConfPath = path.join(themePath, themeDir, 'theme.json');
+
+ fs.exists(themeConfPath, function(exists) {
+ if (exists) {
+ fs.readFile(themeConfPath, function(err, conf) {
+ conf = JSON.parse(conf);
+ conf.src = global.nconf.get('url') + 'themes/' + themeDir + '/' + conf.src;
+ themeArr.push(conf);
+ next();
+ });
+ }
+ });
+ } else next();
+ });
+ }, function(err) {
+ callback(err, themeArr);
+ });
+ });
+ },
+ saveViaGithub: function(repo_url, callback) {
+ // ...
+ }
+ }
}(exports));
\ No newline at end of file
diff --git a/src/websockets.js b/src/websockets.js
index 07a9143851..837ea8f3f1 100644
--- a/src/websockets.js
+++ b/src/websockets.js
@@ -614,6 +614,12 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }),
else
socket.emit('api:admin.user.search', null);
});
+
+ socket.on('api:admin:themes.getInstalled', function() {
+ meta.themes.get(function(err, themeArr) {
+ socket.emit('api:admin:themes.getInstalled', themeArr);
+ });
+ });
});
}(SocketIO));