Spina: A Ruby on Rails CMS – Part 2

Spina has been updated a lot since I've written these articles. Commands may have changed since and I will do my best to write new articles on Spina soon !

Hi, this is Part 2 of a serie of articles about Spina, you may want to check out Part 1 - Spina: A Ruby on Rails CMS first if you are new to Spina and want to get started with it !

In this section we will see how to configure our Spina app to create our own theme with it’s different page templates ! Let’s build a blog !!

Creating a Spina Theme

After installing Spina, and if you chose to use the Demo theme, you will have two files in config/initializers/themes, a default.rb and a demo.rb. I recommend deleting these later, since it might through you an error since your pages are using one of these at the moment.

This is how our New page panel will look like for our Post page creation.

You can go and create a new file in this folder with your own theme name, I’ll be calling it labs.rb.

Ok so we now have our theme configured. However we need to add page_parts, templates and a custom page.
The following code snippets will go right after self.title = 'Labs'.

Let’s add some page_parts. If you look at the demo theme you can see 8 page_parts that are all the available page_parts on Spina (Line, Text, Photo, Photo collection, Attachment, Attachment collection, Structure and Color). In our case we are building a simple blog, therefore we only need 3 parts: an excerpt (Text), a content (Text) and a thumbnail (Photo).

Writting `%w(excerpt thumbnail content)` is the same as writting `["excerpt", "thumbnail", "content"]`. It's just a shortcut.

And finally we will add a custom_pages, that will be our Homepage. It seems to be a bug with Spina, but every time you update your Preferences, it regenerates all the defined custom_pages if they don’t exist. And unfortunately I didn’t manage to not to define any custom_pages. That’s why we will only define the Homepage which will always be existent on our website.