spacedrop / spacedrop

An open-source CMS in JavaScript, built with Meteor and React.
http://spacedropcms.org
Other
123 stars 35 forks source link

SpaceDrop

An open-source CMS in JavaScript, built with Meteor and React.

Achievement unlocked, you found us.

Hands to you for Googling and finding us, the next step is up to you. Become a co-author and member of the die-hards controlling SpaceDrop's future direction, by forking and creating a PR that gets committed.

API examples

Below APIs are functional, more APIs are coming soon!

Menu API

Create route to view content of type node.

SD.Menu.route({
  path: 'node/:nid',
  component: SD.Views.Node,
  subscriptions: {
    'node.node': ['nid']
  }
})

Permission API

Create permission to access published content.

SD.Permission.permission({
  name: 'access content',
  title: 'View published content'
});

Create a role with limited permissions.

SD.Permission.role({
  name: 'guest',
  permissions: {
    'access content': 1
  }
});

Entity API

Create an entity of type "node".

let Node = class extends SD.Structure.Entity {
  constructor({ name, schema = {}, indexes = {} }) {
    super({
      type: 'node',
      bundle: name,
      schema: _.extend({
        nid: {
          type: Number,
          optional: true,
          autoValue: () => {
            return this.collection.find().count() + 1;
          }
        },
        bundle: {
          type: String,
          optional: true,
          autoValue: function() {
            return name;
          }
        },
        title: {
          type: String
        }
      }, schema)
    });

    // Ensure index for entity type node.
    Node._ensureIndex('nid', {unique: 1});
  }
}

// Export Node to packages and application.
SD.Structure.Node = Node;

Node API

Create a content type (bundle) with the name "page".

let Page = new SD.Structure.Node({
  name: 'page',
  schema: {
    body: {
      type: String
    }
  }
});

List all pages (nodes of content type "page").

let nodes = Page.find();

List all nodes regardless of content type (bundle).

let nodes = SD.Structure.Node.find();

Help improve these APIs! Fork and create a pull request, when it gets committed you'll be added as member of the die-hards and help decide the future for this project.

Sub-projects