Gallery-slice is a project mainly written in Ruby, based on the MIT license.
Merb slice, which adds gallery functionality to your app (early development, bugs inside ;])
Now, you can simply install gallery slice and have galleries in your app! You can have common galleries, or, associate photos to your model! It is very easy, and transparent for users. (now, you can only add galeries :(, but I'm developing now) To associate with your resource (i will simplyfy it soon):
A slice for the Merb framework.
gallery-slice
|-- LICENSE
|-- README
|-- Rakefile [1]
|-- TODO
|-- app [2]
| |-- controllers
| | |-- application.rb
| | -- main.rb | |-- helpers | |
-- application_helper.rb
| -- views | |-- layout | |
-- gallery-slice.html.erb [3]
| -- main |
-- index.html.erb
|-- lib
| |-- gallery-slice
| | |-- merbtasks.rb [4]
| | -- slicetasks.rb [5] |
-- gallery-slice.rb [6]
|-- log
| -- merb_test.log |-- public [7] | |-- javascripts | |
-- master.js
| -- stylesheets |
-- master.css
|-- spec [8]
| |-- gallery-slice_spec.rb
| |-- controllers
| | -- main_spec.rb |
-- spec_helper.rb
-- stubs [9]
-- app
-- controllers |-- application.rb
-- main.rb
To see all available tasks for GallerySlice run:
rake -T slices:gallery_slice
Instructions for installation:
file: config/init.rb
dependency 'gallery-slice'
Merb::Plugins.config[:merb_slices] = { :queue => ["GallerySlice", ...] }
Merb::BootLoader.before_app_loads do
Merb::Slices::config[:gallery_slice][:option] = value
end
file: config/router.rb
add_slice(:GallerySlice)
add_slice(:GallerySlice, 'foo') # same as :path => 'foo'
add_slice(:GallerySlice, :path => ':lang')
slice(:GallerySlice)
Normally you should also run the following rake task:
rake slices:gallery_slice:install
You can put your application-level overrides in:
host-app/slices/gallery-slice/app - controllers, models, views ...
Templates are located in this order:
You can use the host application's layout by configuring the gallery-slice slice in a before_app_loads block:
Merb::Slices.config[:gallery_slice] = { :layout => :application }
By default :gallery_slice is used. If you need to override stylesheets or javascripts, just specify your own files in your layout instead/in addition to the ones supplied (if any) in host-app/public/slices/gallery-slice.
In any case don't edit those files directly as they may be clobbered any time rake gallery_slice:install is run.
Merb-Slices is a Merb plugin for using and creating application 'slices' which help you modularize your application. Usually these are reuseable extractions from your main app. In effect, a Slice is just like a regular Merb MVC application, both in functionality as well as in structure.
When you generate a Slice stub structure, a module is setup to serve as a namespace for your controller, models, helpers etc. This ensures maximum encapsulation. You could say a Slice is a mixture between a Merb plugin (a Gem) and a Merb application, reaping the benefits of both.
A host application can 'mount' a Slice inside the router, which means you have full over control how it integrates. By default a Slice's routes are prefixed by its name (a router :namespace), but you can easily provide your own prefix or leave it out, mounting it at the root of your url-schema. You can even mount a Slice multiple times and give extra parameters to customize an instance's behaviour.
A Slice's Application controller uses controller_for_slice to setup slice specific behaviour, which mainly affects cascaded view handling. Additionaly, this method is available to any kind of controller, so it can be used for Merb Mailer too for example.
There are many ways which let you customize a Slice's functionality and appearance without ever touching the Gem-level code itself. It's not only easy to add template/layout overrides, you can also add/modify controllers, models and other runtime code from within the host application.
To create your own Slice run this (somewhere outside of your merb app):
$ merb-gen slice