How to use widget-cms - 10 common examples

To help you get started, we’ve selected a few widget-cms 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 qawemlilo / nodeza / test / event.js View on Github external
"use strict";

const should = require('chai').should();
const app = require('widget-cms');
const NodeEvent = app.getModel('Event');
const eventsData = require('../sql/data/events');
const moment = require('moment');


describe('Event', function(){

  var eventData = eventsData[0];
  var event = new NodeEvent();


  describe('#set #save', function() {
    it('should create a new event', function(done){

      event.set(eventData);

      event.save()
github qawemlilo / nodeza / test / meetup.js View on Github external
"use strict";

const should = require('chai').should();
const app = require('widget-cms');
const Meetup = app.getModel('Meetup');
const meetupsData = require('../sql/data/meetups');



describe('Meetup', function(){

  let meetupData = meetupsData[0];
  let meetup = new Meetup();


  describe('#set #save', function() {
    it('should create a new meetup', function(done){

      meetup.set(meetupData);

      meetup.save()
github qawemlilo / nodeza / test / roles.js View on Github external
"use strict";

const should = require('chai').should();
const app = require('widget-cms');
const User = app.getModel('User');

describe('Roles', function(){

  describe('#fetch', function() {
    it('should fetch a role from a user', function(done){
      User.forge({id: 1})
      .fetch({withRelated: ['role']})
      .then(function(user) {
        let role = user.related('role');

        role.get('id').should.equal(3);
        role.get('name').should.equal('Super Administrator');
        done();
      })
      .catch(function (error) {
        done(error);
github qawemlilo / nodeza / test / user.js View on Github external
"use strict";

const should = require('chai').should();
const app = require('widget-cms');
const User = app.getModel('User');


function createFakeUser() {
  let user = {};

  user.name = 'John Doe';
  user.email = 'user_' + Date.now() + '@none.com';
  user.password = 'juliet';
  user.role_id = 1;

  return user;
}


describe('User', function(){
github qawemlilo / nodeza / bots / twit.js View on Github external
client.post('statuses/update', { status: tweet }, function(err, data, response) {
    if (err) {
      console.error(err)
    }
    else {
      const Tweet = App.getModel('Tweet');

      Tweet.forge({type: type, payload: payload})
      .save()
      .then(function (tweet) {
        console.error('Tweet saved to db')
      })
      .catch(function (error) {
        console.error(error)
      });
    }

  });
}
github qawemlilo / nodeza / controllers / messages.js View on Github external
postMessageToAll: async function(req, res, next) {
    req.assert('message', 'Message must be at least 12 characters long').len(2);

    let errors = req.validationErrors();

    if (errors) {
      req.flash('errors', errors);
      return res.redirect('back');
    }

    try {
      let Users = App.getCollection('Users');
      let Conversation = App.getModel('Conversation');
      let Message = App.getModel('Message');

      let from = req.user;
      let allusers = await Users.forge().query('where', 'id', '!=', from.get('id')).fetch();

      allusers.each(function (user) {
        let sentmessage = sendMessage(req.user, user, req.body.message, req.headers.host);
      });

      return res.redirect('back');
    }
    catch (e) {
      console.error(e);
      return res.redirect('back');
    }
  }
github qawemlilo / nodeza / controllers / messages.js View on Github external
postMessageToAll: async function(req, res, next) {
    req.assert('message', 'Message must be at least 12 characters long').len(2);

    let errors = req.validationErrors();

    if (errors) {
      req.flash('errors', errors);
      return res.redirect('back');
    }

    try {
      let Users = App.getCollection('Users');
      let Conversation = App.getModel('Conversation');
      let Message = App.getModel('Message');

      let from = req.user;
      let allusers = await Users.forge().query('where', 'id', '!=', from.get('id')).fetch();

      allusers.each(function (user) {
        let sentmessage = sendMessage(req.user, user, req.body.message, req.headers.host);
      });

      return res.redirect('back');
    }
    catch (e) {
      console.error(e);
      return res.redirect('back');
    }
  }
});
github qawemlilo / nodeza / controllers / dashboard.js View on Github external
"use strict";


const App = require('widget-cms');
const Categories = App.getCollection('Categories');
const Posts = App.getCollection('Posts');
const Post = App.getModel('Post');
const User = App.getModel('User');


function processTags(tags) {
  if (!tags) {
    return [{name: 'uncategorised'}];
  }

  tags = tags.split(',');

  tags = tags.map(function (tag) {
    return {name: tag.trim()};
  });

  return tags;
}
github qawemlilo / nodeza / collections / tags.js View on Github external
"use strict";

/**
 * Blog tags collection
**/

const App = require('widget-cms');
const Tag = App.getModel('Tag');



const Tags = App.Collection.extend({

  model: Tag,


  limit: 5,


  /**
   * Fetches featured front page posts
  */
  fetchTags: function (limit, options) {
github qawemlilo / nodeza / collections / roles.js View on Github external
"use strict";

/**
 * Users collection
**/

const App = require('widget-cms');
const Role = App.getModel('Role');


const Roles = App.Collection.extend({

  model: Role

});


module.exports = App.addCollection('Roles', Roles);

widget-cms

A highly modular Node.js application framework

MIT
Latest version published 4 years ago

Package Health Score

36 / 100
Full package analysis

Popular widget-cms functions