Skip to content

Commit

Permalink
better readme
Browse files Browse the repository at this point in the history
  • Loading branch information
kristianmandrup committed Aug 21, 2012
1 parent 3a406ce commit d1d09e7
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
60 changes: 60 additions & 0 deletions README.md
Expand Up @@ -109,6 +109,66 @@ You just have to change 5000 to the value you want (milliseconds).


See [galleria.io](http://galleria.io) for more info. See [galleria.io](http://galleria.io) for more info.


## Extras

This gem is a Rails 3+ engine.

Some *HAML* views (partials) are included in `app/views/gallery`

## Rails views usage

```ruby
class PropertiesController < ApplicationController
def show
@property = property
end

protected

def property
Hashie::Mash.new title: 'A beautiful property',
description: decription,
photos: photos
end

def description
%q{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent mauris arcu, auctor ac rhoncus non, libero. Nulla dolor velit, volutpat a bibendum ut, hendrerit id mi. Pellentesque convallis erat in mi interdum rutrum. Phasellus interdum velit nulla.
}
end

def photos
@photos ||= Photos.new nil, photo_class: Property::Photo
5.times do
@photos.pages << 6.times.map {|n| (Kernel.rand(7) + 1).to_s }
end
@photos
end
end
```

Then in your `properties/show.html.haml`:

```haml
render partial: 'gallery/responsive', locals: { photos: @property.photos }
```

And so on...

## View helpers

There are also some view helpers included in `rails-gallery/view_helper.rb`

`gallery_image type, photo`

Example:

```haml
- photos.each do |photo|
= gallery_image :responsive, photo`
```

Enjoy!

## Contributing to rails-gallery ## Contributing to rails-gallery


* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet. * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
Expand Down
1 change: 1 addition & 0 deletions lib/rails-gallery/engine.rb
Expand Up @@ -2,6 +2,7 @@ module RailsGallery
module Rails module Rails
class Engine < ::Rails::Engine class Engine < ::Rails::Engine
initializer 'rails gallery' do initializer 'rails gallery' do
ActionView::Base.send :include, RailsGallery::ViewHelper
end end
end end
end end
Expand Down

0 comments on commit d1d09e7

Please sign in to comment.