Project

semistatic

0.0
No commit activity in last 3 years
No release in over 3 years
Simple embeded page creator. Should I be called CMS? Not sure.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Project Readme

Semistatic

This project rocks and uses MIT-LICENSE.

On the application route file

  Rails.application.routes.draw do
    match ':slug.html' => 'semistatic/page_view#show', as: :page
    mount Semistatic::Engine => "/admin"
  end

The config file

  #config/semistatic.yaml
  pages:
    about:
      parts:
        title:
          type: String
        body:
          type: Html
    profile:
      parts:
        avatar:
          type: image
          # paperclip styles. Use the original key to set the image size
          styles:
            original: 200x200>
            thumb: 50x50>
        about:
          type: html
        slogan:
          type: string

The templates

Create the templates inside app/views/templates. Use the the @presenter instance val to ouput the field content with <%= @presenter.output(:field_name) %>

about page: app/views/layouts/templates/about.html.erb

  <h1><%= @presenter.output(:page_title) %></h1>

  <div class="body">
    <%= @presenter.output(:body) %>
  </div>

profile page: app/views/layouts/templates/profile.html.erb

  <h1><%= @presenter.output(:page_title) %></h1>

  <figure>
    <%= @presenter.output(:avatar) %>
  </figure>

  <p class="slogan"><%= @presenter.output(:slogan) %></p>

  <div class="about"><%= @presenter.output(:about) %></div>

Overriding the controller

Semistatic uses the ActiveSupport::Concearn pattern to extend its functionalities.

To override, say, the crud controller, should create a file app/controllers/semistatic/pages_controller.rb with the following content:

  # app/controllers/semistatic/pages_controller.rb

  module Semistatic
    class PartsController < ApplicationController
      include Semistatic::Concerns::Controller::PartsController

      included do
        before_filter :require_authentication
      end
    end
  end