Hammer

You can use Chisel with Hammer, to build content-driven static sites.

We've added support to the current Hammer app through the hammer.json configuration.

In the 🆕 Hammer 🔨 we'll be providing a dedicated UI for this.

To try out Chisel and Hammer together in the current Hammer for Mac app, you need to install the development branch of the Hammer gem. You do this with the following command in the terminal, this is just until we merge this into the latest branch.

ruby -e "path='/Applications/Hammer.app/'; branch='merged_latest_chisel'; $(curl -fsSL https://raw.githubusercontent.com/Beachio/hammer-gem/merged_latest_chisel/scripts/high-siera_update.rb)"

The current latest version will be 5.4.7.3

Hammer.json Setup

In order to use your Chisel Content inside of Hammer, you need to setup your account and content mappings.

Inside hammer.json, create a new object:


{
"chisel":{}
}

Chisel Instance Credentials

Firstly, we need to tell Hammer where your Parse-Server backend is hosted. This could be run locally at http://localhost:xxxx/parse or at a remote hosting address. For example if you are hosting your Parse Server using our simple Forge hosting service, then the URL would be something like

http://dockerhost.forge-parse-server.c66.me:0001/parse

{ "chisel":{ "parse_server_url":"https://dockerhost.forge-parse-server.c66.me:0001/parse" } }

Next is your Parse App ID, the unique identifier for your Parse Server instance.


{
"chisel":{
    "parse_server_url":"https://dockerhost.forge-parse-server.c66.me:0001/parse",
    "parse_app_id":"123456789123456789"
  }
}

Then finally, in terms of authorisation options, you have a couple of possibilities.

Email / Password


{
"chisel":{
    "parse_server_url":"https://dockerhost.forge-parse-server.c66.me:0001/parse",
    "parse_app_id":"123456789123456789",
    "login":"[email protected]",
    "password":"mysecurepassword"
  }
}

It's not great practise to use your plaintext password, so we'd generally recommend the next method.

Session Token

You can obtain your Session Token from your Chisel app.


{
"chisel":{
    "parse_server_url":"https://dockerhost.forge-parse-server.c66.me:0001/parse",
    "parse_app_id":"123456789123456789",
    "session_token": "123456789123456789"
  }
}

Chisel Site Info

We need to identify our specific Chisel site, using site_id


{
"chisel":{
    "parse_server_url":"http://dockerhost.forge-parse-server.c66.me:0001/parse",
    "parse_app_id":"123456789123456789",
    "session_token": "123456789123456789",
    "site_id":"123456"
  }
}

Use Cache

If you are making lots of frequent changes to your Hammer project markup, styles etc. then waiting for a full build of your site can be a little cumbersome and will affect your productivity. When you're focussed on the coding part and you have stabilised the content, for the time being at least, then you can tell Hammer to use a cached version of the Chisel content, which it will store locally, resulting in much faster build times.

This is useful for working offline, or if you have a slow network connection - for example when you're working from the Beach house or on a train to the beach!!


{
"chisel":{
    "parse_server_url":"http://dockerhost.forge-parse-server.c66.me:0001/parse",
    "parse_app_id":"123456789123456789",
    "session_token": "123456789123456789",
    "site_id":"123456",
    "use_cache": true
  }
}

Content Model Mapping

Now that's all done, we need create our mappings to our Chisel content models, so that we can use them inside our templates.

Let's take a simple example, assuming we have a model called Page inside Chisel. We start by adding our contentTypes object. Inside this object we create pages, which is the plural of our Page model. This is the convention we will typically use for our mappings - singular model, plural variable.


"contentTypes":{
    "pages":{
        "name":"Page"
      }
    }

If you have no further configuration to do, you can also use the shorthand version


"contentTypes":{
    "pages":"Page"
 }

From here, we get to the commonly used additional options

"renderOnBuild":true - tells hammer to build a new html page for each instance of this model, requires a template

"template":"templates/_page.slim" - the template that us used to create each new page for each model instance

"urlAliasSource":"Slug" - the name of the html page hammer will create can be set using a certain field in your content model, the Slug field is perfect for this.

"urlAliasPrefix":"pages" - when hammer builds the html page, you can specify where you want the page to be located, default would be in the root folder. In this example, our new pages will be put into the pages/ directory.

So, in the end, we end up with something like this…


{
"chisel": {
    "site_id":"123456",
    "parse_app_id":"123456789123456789",
    "parse_server_url":"https://dockerhost.forge-parse-server.c66.me:0001/parse",
    "session_token": "123456789123456789",
    "contentTypes":{
    "pages":{
        "name":"Page",
        "renderOnBuild":true,
        "template":"templates/_page.slim",
        "urlAliasSource":"Slug",
        "urlAliasPrefix":"pages"
      }
    }
  }
}