Giter VIP home page Giter VIP logo

cms's Introduction

About

A Rails engine which adds a simple cms to your rails project.

Installation

Add the following to your Gemfile:

gem 'cms', git: '[email protected]:sewa/cms.git', branch: 'master'

Copy and run migrations:

rake cms:install:migrations
rake db:migrate

Mount the engine:

mount Cms::Engine, at: '/cms'

Start the rails server and access the cms with:

http://localhost:3000/cms

Howto use

The cms consists of three different types of entities.

  • Cms::ContentNode
  • Cms::ContentComponent
  • Cms::ContentAttribute

In the following section i will give an overview over each of these entities.

Cms::ContentNode

The engine expects all content nodes to be placed in app/models/content_nodes. Here is an example:

class ExampleNode < Cms::ContentNode

  template 'page'

  child_nodes :all

  use_components :all

  content_group :content do
    content_attribute :heading, :string
    content_attribute :body, :text
    content_attribute :rotator, :image_list
  end

end

Let's discuss the class methods:

template

is used to tell the client which template should be rendered.

child_nodes :all

tells the engine that this page can have all page types as subnodes. Other possible values are:

child_nodes except: ['ExampleNode', ...]
child_nodes only: ['ExampleNode', ...]

If child_nodes is not defined the page can't have any childpages.

The same options you have with use_components:

use_components :all
use_components except: ['ExampleComponent', ...]
use_components only: ['ExampleComponent', ...]

To define a grouping of attributes use:

content_group :content

And finally the actual content is defined with:

content_attribute :name, :type

Cms::ContentComponent

class ExampleComponent < Cms::ContentComponent

  content_attribute :heading, :string
  content_attribute :body, :text
  content_attribute :rotator, :image_list

end

Cms::ContentAttribute

class ExampleAttribute < Cms::ContentComponent

  content_type :string

end

Authentication

The cms has no build in authentication.

It uses cancan for authorization, the rest is up to you.

To hook your user into the cms you have to create the initializer config/initializers/cms.rb and add the following code to it:

Cms.user_class = 'Your user class'
Cms.user_roles_attribute = 'your roles method on user'

cms's People

Contributors

sewa avatar alexnm avatar

Stargazers

Matthias Georgi avatar Marco Kuhn avatar

Watchers

 avatar

Forkers

alexnm promptus

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.