Skip to content

johnmcneilstudio/keystonejs-demo-jms

Repository files navigation

brew install node
brew install mongodb
npm install -g yo
npm install -g generator-keystone


yo keystone


Sample Generator script

Welcome to KeystoneJS.

? What is the name of your project? Studio CMS
? Would you like to use Jade, Nunjucks, Twig or Handlebars for templates? [jade | nunjucks | twig | hbs] jade
? Which CSS pre-processor would you like? [less | sass | stylus] sass
? Would you like to include a Blog? Yes
? Would you like to include an Image Gallery? Yes
? Would you like to include a Contact Form? Yes
? What would you like to call the User model? User
? Enter an email address for the first Admin user: syoung@johnmcneilstudio.com
? Enter a password for the first Admin user:
 Please use a temporary password as it will be saved in plain text and change it after the first login. admin
? Would you like to include gulp or grunt? [gulp | grunt | none] gulp
? Would you like to create a new directory for your project? No
? ------------------------------------------------
    KeystoneJS integrates with Mandrill (from Mailchimp) for email sending.
    Would you like to include Email configuration in your project? No
? ------------------------------------------------
    KeystoneJS integrates with Cloudinary for image upload, resizing and
    hosting. See http://keystonejs.com/docs/configuration/#services-cloudinary for more info.

    CloudinaryImage fields are used by the blog and gallery templates.

    You can skip this for now (we'll include demo account details)

    Please enter your Cloudinary URL:
? ------------------------------------------------
    Finally, would you like to include extra code comments in
    your project? If you're new to Keystone, these may be helpful. Yes

=======

Including posts and galleries in the scaffolding will provide a couple of starter content types.

Initial Structure of the site
+-models
+-public
+-routes
+-templates
+-updates

'models' contains Javascript files defining the content types to be served.
There is one file per content type. http://keystonejs.com/docs/database/

'public' contains static assets

'routes' contain your applications views and controllers.

'routes/views' will contain javascript files, again one per model.
These files contain application login to interact models and render views.
If you are fluent in MVC these files could be considered the 'controllers' in the app.
So the name might be misleading, but don't let the smooth taste fool you.
KeystoneJS describes itself as MV* for those keeping score.

'templates' has one folder 'views'

'updates' contains scripts to used to update data.
These seem to be analogous to Rails migrations but it remains to be seen if these are as robust.

========

Cool. Things seem to be working. I can add content. And view my site. Now what?
Lets push it to the cloud for the world to see. Okay. Done. Let's take a look.

http://keystonejs-demo-jms.herokuapp.com/ returns an error.
Cloudinary is not configured according to Heroku logs.
Cloudinary breaks because there is no '.env' file.
This file contains two lines at this stage.
.env is gitignored as it should be.
But it contains the Cloudinary configuration (a Cloudinary url) and a cookie secret.
And without these things the app seems unhappy.

heroku config:set to the rescue. The values in .env can be set in this manner.

heroku config:set COOKIE_SECRET=4b6...
heroku config:set CLOUDINARY_URL: cloudinary://3337...

These values will correspond to the values in .env after setup.

Now we need a MongoDB instance

> heroku addons:create mongolab:sandbox

After installation:

> heroku config

=== keystonejs-demo-jms Config Vars
CLOUDINARY_URL: cloudinary://333779167276662:_8jbSi9FB3sWYrfimcl8VKh34rI@keystone-demo
COOKIE_SECRET:  4b617d824a81d5b347083f068cab2fb483bc66a3b585a2c3244c92747dde6b6f15f6c2b77800d0bbdae142c47ae280de5e7c3c3cfee8d4208456f09ceef2ee09
MONGODB_URI:    mongodb://heroku_1w13v94f:n95vkjffediq5460c0n04sfsvv@ds145355.mlab.com:45355/heroku_1w13v94f
MONGOLAB_URI:   mongodb://heroku_1w13v94f:n95vkjffediq5460c0n04sfsvv@ds145355.mlab.com:45355/heroku_1w13v94f

Duplicated the MONGODB_URI environment variable provided by the mlab MongoDB addon as 'MONGOLAB_URI'.
KeystoneJS is looking for MONGOLAB_URI value.
Another quirk. Still keeping the faith...

But now we are installed.
None of the above is necessary for development now that the instance is up.

On to customizing...

========

The default page container is a file templates/views/layouts/default.hbs
We chose handlebars as our templating engine so our templates are handlebars templates with .hbs extensions.

The home page content is in /templates/views/index.hbs

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published