0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Content blocks in Rails
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 1.9
~> 4.1.0
>= 4.0.5
 Project Readme

ContentBlock

Build Status Coverage Status Code Climate Dependency Status Gem Version

A block, as used within this gem, is a section of content (either an image, simple text, or rich text that includes markup). This gem allows you to create these different types of blocks, and place them throughout the site. You can then give the administrative users of the site access to edit these blocks.

Requirements / Caveats

  • Your app must already have functional devise installation
  • Your app must already have functional cancancan installation
  • Your app must already have functional ckeditor installation
  • Your User must have a role field
  • Administrators must be identified by having a role value of 'admin'
  • Your app needs to handle the display of notice messages, should they exist
  • Only rich blocks are available - image & simple text blocks have not been added, yet

Installation

Add this line to your application's Gemfile:

gem 'content_block'

Have bundler install the gem:

bundle

Run the installer:

rails generate content_block:install

Optionally, you can copy over the view files in order to have direct control on the admin appearance:

rails generate content_block:views

Usage

You can manage the blocks by visiting the /content-block/admin URL as an admin. That page links out to each block-type's simple CRUD interface.

To use a block in your view without displaying its title (IDENTIFIER is either the name or the id of the block to be displayed):

<%= rich_block('IDENTIFIER') %>

For example, if a block has an id of '1' and a name of 'content page', it can be displayed with either <%= rich_block(1) %> or <%= rich_block('content page') %>.

To use a block in your view and display its title (IDENTIFIER is either the name or the id of the block to be displayed & TAG is the HTML tag you'd like the title to be wrapped in):

<%= rich_block_with_title('IDENTIFIER', 'TAG') %>

For example, if a block has an id of '1' and you want to display its title in an <h4> tag, then it would be displayed with <%= rich_block_with_title(1, 'h4') %>.

Contributing

  1. Fork it ( http://github.com/commonmedia/content_block/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request