Spartan

Spartan is the complete API and Database Layer that the Tilas Publishing Platform is built on. Lantern (the CMS platform) and Titan (The Website Platform) both speak to it via REST webservices to provide all the features of the end to end publishing and blogging frontends.


Settings up Spartan on your Server:


Prerequisites:

Spartan Software Installation (Source Setup)

For below example, let assume our new app is called "funnycats"

Environment Variables:

DB Setup:

If everything worked you should see a success message like so: "Success: DB system has been set up."

Run the Tests:

All the tests should pass.

Updating server ports (optional step; if not done it will default to port 4000):

Start your app:

Read the documentation:

SPARTAN IS NOW UP AND READY TO SERVE BOTH TITAN AND LANTERN. YOUR NEXT STEP WOULD BE TO SETUP TITAN.


Development Tips


Debugging: To effectively debug your nodeJS app, I prefer to use node-inspector which pretty much lets your perform JavaScript debugging like you are used to in Chrome Dev Tools. To debug this app using node-inspector do this:

$ node --debug app.js // start your app in debug mode

$ node --debug-brk app.js // or to to pause script on first line do this

Now:

$ node-inspector & //launch the inspector

Read more here : https://greenido.wordpress.com/2013/08/27/debug-nodejs-like-a-pro/

Logging This app uses Bunyan for logging. This is a very advanced logging system that stores machine readable logs if needed. When the app runs, user friendly logs are spit out on the console to log our all trace (info and above), but it can be setup to only log to a file instead of the console or log on warns and above. There are more advanced use cases as well.

To prob apps in production, more here : https://www.joyent.com/blog/node-js-in-production-runtime-log-snooping

Read more here : https://github.com/trentm/node-bunyan


Collection, Schemas and Mappings:


Content Objects

Content Objects are basically the content data objects that populate the website, i.e. these objects end up being individual content web pages.

Collections

The DB has the following Collections:

settings

Here is where all the API runtime settings are stored.

authors

Here is where all your content author names are stored.

tags

Here is where all your content tag names are stored.

lists

Here is where we store the editorial lists like trending and popular.

assets

All images assets are stored here. Assets are used by Stories.

stories

Stories are the Content Objects, i.e the end up being the web pages you see in the website or they are used to create the content of the web pages. There are 2 types of stories: Articles and Tiles. Articles are your standard content articles/blog posts and Tiles are basically stand alone images that is read as a story. For e.g. Quote Images or Meme images are tiles.

Content Object Schema

The below describes the database Schema of Tiles, Articles and Assets.

Tile:

"_id" : ObjectId("")
"cat" : 1                        // category
"oTy" : 1                        // objType
"cOn" : 1435888483592            // createdOn    
"uOn" : 0                        // updatedOn
"sId" : "N1go943D"                // shortId
"sTi" : "things..."                // storyTitle
"txt" : "<p>You"                // text
"atr" : 0                        // author
"tgP" : 1                        // tagPrimary
"tgs" : [11,18]                    // tags
"tgM" : [15,16]                    // tagsMeta
"iUl" : "https://PVEP.jpg"        // imgUrl
"src" : "[text](link)"            // source
"pUl" : "/a/N1go943D/asdas"        // publicUrl
"aSh" : 0                        // autoSharable
"fbS" : 0                        // fbSharedOn
"pub" : 1                        // published

Article

"_id" : ObjectId("")
"cat" : 1                        // category
"oTy" : 1                        // objType
"cOn" : 1435888483592            // createdOn    
"uOn" : 0                        // updatedOn
"sId" : "N1go943D"                // shortId
"sTi" : "things..."                // storyTitle
"blb" : "Le..."                    // blob
"txt" : "<p>Your html test"        // text
"atr" : 0                        // author
"tgP" : 1                        // tagPrimary
"tgs" : [11,18]                    // tags
"tgM" : [15,16]                    // tagsMeta
"iUl" : "https://PVEP.jpg"        // imgUrl
"iSc" : "[text](link)"            // imgUrlSource
"src" : "[text](link)"            // source
"pUl" : "/a/N1go943D/asdas"        // publicUrl
"sTg" : "marley quotes,lovely"    // SEO Tags
"aSh" : 0                        // autoSharable
"fbS" : 0                        // fbSharedOn
"pub" : 1                        // published

Asset

"_id" : ObjectId("")
"oTy" : 1                        // objType
"cOn" : 1435888483592            // createdOn    
"tgs" : [11,18]                    // tags
"aUl" : "https://PVEP.jpg"        // assetUrl
"src" : "[text](link)"            // source

Object Type / Category Mappings

Objects that belong to the Stories collection have individual types that is then used to indentify them. The mapping is stored in the oTy property.

oTy in (Stories) Maps to:

oTy in (Assets) Maps to:

By default front end is configured to support the following categories, you will see these mappings appear in the cat property of Articles and Tiles.

Category Mapping