Repository URL to install this package:
| 
      
     
      
        
        
        Version: 
        
         
  
        
    
          
          0.6.0  ▾
        
         
  
      
        
      
  
      
  
     | 
| app | 
| config | 
| db | 
| lib | 
| README.md | 
| Rakefile | 
Asset Management Library for the Neoteric Design CMS
Neoteric CMS gems are served from a private host. Replace SECURE_GEMHOST with the source address.
# Gemfile source SECURE_GEMHOST do gem 'scrapbook' end
$ bundle install $ rails g scrapbook:install $ rake db:migrate
Scrapbook is built to attach assets to a parent model. The first step is to identify these attachment points, and register them so Scrapbook knows about them. Scrapbook's configuration block provides an easy and consolidated place to do this.
Contexts are required to have a name, and a target_resolution. Set the many flag to true to allow adding a collection of assets. Optionally provide a human-friendly label.
# config/initializers/scrapbook.rb config.register_context :carousel_items, many: true, target_resolution: [800,0] config.register_context :hero, label: "Hero Image" target_resolution: [800,0]
Next, add the scrapbook to your model.
class Page has_scrapbook :hero end
Note, contexts are meant to be reusable. Say you have Pages, NewsPosts, and Events, all of which have a hero image. They can all share the same hero context. Define once, use anywhere!
To use the scrapbook input widget, you'll need the following:
For convenience these are packaged in a dependencies folder if you don't want or need to include them in a different way.
# active_admin.js.coffee #= require scrapbook/dependencies/vuejs-2.0.3.js #= require scrapbook/dependencies/sortable.js #= require scrapbook/dependencies/vue-draggable.js #= require scrapbook/parents
Then, initialize the widget
# active_admin.js.coffee
Also include the parents stylesheet to get lookin' nice.
// active_admin.css.scss @import "scrapbook/parents";
You'll need to whitelist the appropriate id parameters in your controller. These follow standard Rails conventions. Examle:
Singular: :hero_id
Many: carousel_item_ids: []
And the payoff for all that set up; all you have to do for each scrapbook is this:
<%= f.input :hero, as: :scrapbook %>
<%= scrapbook_image_tag @page.hero %>
<%= @page.hero.file_url %>
Scrapbook includes a dummy app for testing and development. It is located at
spec/dummy
Database is set up like a normal Rails app. Also run it with in the TEST
environment just to be safe.
$ rails db:create db:migrate $ rails db:create db:migrate env=TEST
Boot the dummy app with:
$ cd spec/dummy $ rails s
In the base directory.
$ rspec
Coverage reports are available at coverage/index.html