Giter Club home page Giter Club logo

blocky's Introduction

Blocky

Code Climate

Blocky is a Ruby gem for adding editable content blocks to a Rails project.

Installation

Add this line to your application's Gemfile:

gem "blocky"

Install the Blocky gem with Bundler:

bundle install

Use the install generator to set up Blocky:

rails g blocky:install

Run the installed database migrations to add the required tables:

rake db:migrate

Usage

View Helper

To create a content block, simply use the blocky helper and specify a content key in your ERB template. Each content key must be unique across your entire application for each content block that has unique content.

<%= blocky(:contact_info) %>

You can specify a block of HTML to be loaded into the content block the first time the that content key is loaded. This means you won't have a bunch of empty content blocks in development when a new developer spins up the app for the first time.

<%= blocky(:product_faq) do %>
  <h1>Frequently Asked Questions</h1>
  <ul>
    <li>How do I add content blocks?</li>
    <li>How do I edit my content blocks?</li>
  </ul>
<% end %>

Active Admin

Blocky registers the content blocks with Active Admin to provide the editing interface. Everything works best if you are using Active Admin and if current_admin_user is used to return an authenticated user who can manage the content blocks when signed in.

If you're not using Active Admin, it should be pretty easy to create a simple interface for managing your content blocks. The reason the old admin interface was removed was to simplify the project and remove authorization methods that don't belong in this gem.

Contributing

  1. Fork it
  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

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.