From d09a53197ecbefe3655ae57847920a195cba0bfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 12 Feb 2015 15:03:46 -0500 Subject: [PATCH] closes #2570 --- install/data/footer.json | 10 ++++++++++ src/install.js | 26 +++++++++++++++++++------- 2 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 install/data/footer.json diff --git a/install/data/footer.json b/install/data/footer.json new file mode 100644 index 0000000000..69d55448ac --- /dev/null +++ b/install/data/footer.json @@ -0,0 +1,10 @@ +[ + { + "widget": "html", + "data" : { + "html": "", + "title":"", + "container":"" + } + } +] \ No newline at end of file diff --git a/src/install.js b/src/install.js index 61f4bc56c0..45d44d75ad 100644 --- a/src/install.js +++ b/src/install.js @@ -394,13 +394,13 @@ function createWelcomePost(next) { fs.readFile(path.join(__dirname, '../', 'install/data/welcome.md'), next); }, function(next) { - db.sortedSetCard('topics:tid', next); + db.getObjectField('global', 'topicCount', next); } ], function(err, results) { var content = results[0], numTopics = results[1]; - if (numTopics === 0) { + if (!parseInt(numTopics, 10)) { Topics.post({ uid: 1, cid: 2, @@ -430,12 +430,24 @@ function enableDefaultPlugins(next) { function setCopyrightWidget(next) { var db = require('./database'); - - db.init(function(err) { - if (!err) { - db.setObjectField('widgets:global', 'footer', "[{\"widget\":\"html\",\"data\":{\"html\":\"\",\"title\":\"\",\"container\":\"\"}}]", next); + async.parallel({ + footerJSON: function(next) { + fs.readFile(path.join(__dirname, '../', 'install/data/footer.json'), next); + }, + footer: function(next) { + db.getObjectField('widgets:global', 'footer', next); } - }); + }, function(err, results) { + if (err) { + return next(err); + } + + if (!results.footer && results.footerJSON) { + db.setObjectField('widgets:global', 'footer', results.footerJSON.toString(), next); + } else { + next(); + } + }); } install.setup = function (callback) {