Lightweight pluggable CMS in Node.js with a RESTful API
Create app.js
for your project:
var showcase = require('showcase');
showcase.initialize({
"database": {
"dialect": "mysql",
"host": "localhost",
"database": "cms",
"username": "cms",
"password": "cms"
},
"files": {
"tmp_path": "/var/tmp",
"storage_path": "/var/tmp"
},
"port": 3000
});
showcase.run();
Initialize the database schema:
$ node --harmony-generators app schema-sync
Initialize the application fixtures data:
$ node --harmony-generators app fixtures-sync
Start your server:
$ PORT=4000 node --harmony-generators app run
Once your app is running, create an admin user and log in. Then create a workspace, then create some collections, and start adding items.
Node version 0.11.3 is recommended. Showcase requires support for ES6 generators, so node v0.11.2 or greater. You may also try your luck with gnode and node v0.10.x. Also note that if you need sqlite support, node v0.11.3 is the latest supported version of node for that library.
Start by creating a new workspace. A workspace can have an administrator, and will contain a set of collections. You may often want to create a workspace per website, or per project.
Within a workspace, create collections. A collection is a set of like items. Other CMSs might call a collection a "content type" or "custom post type". In a relational database, a collection would be analogous to a table. Define a collection and its fields, and then use the admin interface to add items.
Access and modify data in collections through the built-in RESTful API.
Initialize the application, given a set of options:
Specify database connection details under the database
key:
database.dialect
can bemysql
,postgres
, orsqlite
database.storage
specifies the file on disk for thesqlite
dialectdatabase.host
specifies the database connection hostdatabase.port
specifies the database connection portdatabase.database
specifies the database database namedatabase.username
sepcifies the database usernamedatabase.password
specifies the database passworddatabase.logging
is a boolean to specify whether to log each database querydatabase.define
is a passthrough to Sequelize's default model definitions for any extra customization
Under the hood these are sent through to the Sequelize constructor.
files.tmp_path
specifies where incoming uploaded files should be stored during transferfiles.storage_path
specifies long term storage where uploaded files should reside
Register a custom field. Supplied field
should be an object specifying the following keys:
An object containing configuration information for the field. Specify the following options:
name
- name of the custom field typeinflate
- function to populate item value from stored field data; acceptsfield
,data
,models
, andcallback
parameterspreview
- function to provide a lightweight preview of the data for rendering in HTML lists; accepts adata
parameter containing the stored datavalidator
- function to validate input
A string containing CSS to style field elements
A string containing JavaScript library code to be executed on forms containing this field
A Swig template for rendering the form field
Start up the server. Specify the HTTP port either via a PORT
environment variable, or through a port
key in options sent to showcase.initialize
.
Subscribe to change events through showcase.radio
, an event emitter. For example to log changes to items:
showcase.radio.on('itemUpdate', function(item) {
console.log("item was updated ", item);
})
Fires when an item is updated. Receives the updated item as a parameter.
Fires when an item is created. Receives the nascent item as a parameter.
Fires when at item is destroyed. Receives the moribund item as a parameter.
Copyright (c) 2013-2014 David Chester [email protected]
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.