How to use the blog.set function in blog

To help you get started, we’ve selected a few blog examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github davidmerfield / Blot / app / clients / dropbox / routes / change_dropbox / save-credentials.js View on Github external
// console.log('HERE!');

      // return res.redirect('/folder/change-dropbox');
    }

    // Save the old credentials in the session temporarily
    // so we can copy the files from the old acount in future
    req.session.old_credentials = req.blog.credentials;

    var updates = {dropbox: req.blog.dropbox};

    updates.dropbox.id = new_account_id;
    updates.dropbox.token = token;
    updates.dropbox.cursor = '';

    Blog.set(blogID, updates, function(err){

      if (err) return next(err);

      res.redirect('/folder/change-dropbox/copy-files');
    });
  });
};
github davidmerfield / Blot / app / dashboard / routes / preferences / index.js View on Github external
.post(saveRedirects, form, function(req, res, next){

      var blog = req.blog;
      var blogID = blog.id;
      var updates = req.body;

      Blog.set(blogID, updates, function(err, changes){

        if (err) return next(err);

        if (changes && changes.length)
          res.message({success: 'Made changes successfully!'});

        // We now need to save every entry so that
        // changes to permalink format take effect.
        if (changes.indexOf('timeZone') > -1 ||
            changes.indexOf('dateDisplay') > -1 ||
            changes.indexOf('permalink') > -1) {
          resaveEntries(blogID, function(){});
        }

        // We need to build all the blog's entries if the user
        // has changed any of the plugins or their permalink
github davidmerfield / Blot / app / dashboard / routes / settings / save / finish.js View on Github external
module.exports = function(req, res, next) {
  var blog = req.blog;
  var blogID = blog.id;
  var updates = req.updates || {};
  var redirect = req.body.redirect || req.path;

  Blog.set(blogID, updates, function(errors, changes) {

    if (errors)
      for (var i in errors)
        if (errors[i] instanceof Error)
          return next(errors[i]);

    if (errors) return next(errors);


    // We now need to save every entry so that
    // changes to permalink format take effect.
    if (
      changes.indexOf("timeZone") > -1 ||
      changes.indexOf("dateDisplay") > -1 ||
      changes.indexOf("permalink") > -1
    ) {
github davidmerfield / Blot / app / clients / dropbox / routes / sync / .index.js View on Github external
buildFromFolder(blog.id, function(err){

          if (err) return callback(err);

          blog.dropbox.cursor = latest_cursor;

          Blog.set(blogID, blog, function(err){

            if (err) return callback(err);

            // No we make sure that the changes
            // from dropbox conform to what we expect
            // There was a bug where json.parse(json.string(change))
            // was not equal to the change. so we do this in advance
            callback(null, changes);
          });
        });
      });
github davidmerfield / Blot / app / sync / dropbox / index.js View on Github external
changes = changes.concat(res.changes || []);

        // If Dropbox says there are more changes
        // we get them before returning the callback.
        // This is important because a rename could
        // be split across two pages of file events.
        if (more) return client.delta(newState, onFetch);

        // Nothing has changed so we leave early
        if (!changes.length) return callback();

        // We save the state before dealing with the changes
        // to avoid an infinite loop if one of these changes
        // causes an exception. If sync enounters an exception
        // it will verify the folder at a later date
        Blog.set(blogID, {folderState: newState}, function(err){

          if (err) throw err;

          // No we make sure that the changes
          // from dropbox conform to what we expect
          // There was a bug where json.parse(json.string(change))
          // was not equal to the change. so we do this in advance
          changes = changes.map(model);

          time('handle');

          handle(blog, client, changes, function(err){

            time.end('handle');

            callback(err);
github davidmerfield / Blot / scripts / blog / use-cdn / index.js View on Github external
Blog.get({ id: blogID }, function(err, blog) {
    if (err) return callback(err);

    if (blog.avatar.indexOf(AVATAR_DIRECTORY) !== 0) return callback();

    var avatar = config.cdn.origin + "/" + blog.id + blog.avatar;

    console.log(colors.dim("Blog: " + blogID + " -", blog.avatar));
    console.log(colors.dim("Blog: " + blogID) + " +", avatar);

    Blog.set(blogID, { avatar: avatar }, callback);
  });
}
github davidmerfield / Blot / app / dashboard / routes / settings / save / theme.js View on Github external
Template.getMetadata(templateID, function(err, template) {
      if (err || !template) return next(err || new Error("No template"));

      Blog.set(blogID, updates, function(errors, changed) {
        if (errors && errors.template) {
          res.message(req.path, new Error(errors.template));
        } else if (changed.indexOf("template") > -1) {
          res.message(req.path, "Changed your template to " + template.name);
        }
      });
    });
};
github davidmerfield / Blot / app / dashboard / routes / theme / index.js View on Github external
Template.getMetadata(templateID, function(err, template){

        if (err || !template) return next(err || new Error("No template"));

        Blog.set(blogID, updates, function (errors, changed) {

          if (errors && errors.template) {

            res.message(req.path, new Error(errors.template));

          } else if (changed.indexOf('template') > -1) {

            res.message(req.path, 'Changed your template to ' + template.name);
          }

        });
      });
    });
github davidmerfield / Blot / app / routes / dashboard / account / disable-account.js View on Github external
forEach(user.blogs, function(blogID, nextBlog){

        Blog.set(blogID, {isDisabled: shouldDisable}, nextBlog);

      }, function(){
github davidmerfield / Blot / app / dashboard / routes / account / cancel.js View on Github external
forEach(user.blogs, function(blogID, nextBlog){

              Blog.set(blogID, {isDisabled: isDisabled}, nextBlog);

            }, function(){

blog

I've just started development on this node module. When i'm done, it will be a generic blog backend for new users to use and try out!

ISC
Latest version published 5 years ago

Package Health Score

40 / 100
Full package analysis

Popular blog functions