Commit 3a813cc8 authored by Martin Markech's avatar Martin Markech
Browse files

refactoring views

parent 247c685c
...@@ -6,21 +6,18 @@ __Photo gallery engine for Refinery CMS.__ ...@@ -6,21 +6,18 @@ __Photo gallery engine for Refinery CMS.__
This version of refinerycms-photo-gallery supports Rails 3.2.x and Refinery CMS ~> 2.0.3. This version of refinerycms-photo-gallery supports Rails 3.2.x and Refinery CMS ~> 2.0.3.
Client side image resizing with Plupload is possible on Firefox 3.5+ (with fixed quality) and Chrome.
Safari doesn't support direct data access to the selected files. Opera 12.00 + supports drag&drop and also client side image resizing.
## Features ## Features
* Multiple photo uploading with [Plupload](http://www.plupload.com/) 1.5.4 * Multiple photo uploading with [Plupload](http://www.plupload.com/) 1.5.4
* Support for multiple runtimes (because of bug now works only HTML5): HTML5, Flash, Gears, Silverlight, HTML4 * Currently supported HTML5 runtime, flash implementation is broken
* Client side photo resizing to do faster uploading on slow connections * Client side photo resizing to do faster uploading on slow connections
* Server side resizing with Carrierwave * Server side resizing with Carrierwave
* Attach album to page. One album can be attached to many pages.
* Grouping albums to collections. Album can be placed in one or more collections. * Grouping albums to collections. Album can be placed in one or more collections.
* Ajax photo edit during uploading * Ajaxified photo editation during uploading
* Reading EXIF records from file - GPS latitude/longitude, photo title, photo description (In Linux you can put EXIF data using [digiKam](www.digikam.org/) ) * Reading EXIF records from file - GPS latitude/longitude, photo title, photo description (In Linux you can put EXIF data using [digiKam](www.digikam.org/) )
* Multiple photo editing at once * Multiple photo editing at once
* Fully configurable, fully translatable, searchable * Fully configurable, searchable
* Using [Fancybox](http://fancyapps.com/fancybox/) 2.0.6 for frontend image slideshow. Read Fancybox license before you * Using [Fancybox](http://fancyapps.com/fancybox/) 2.0.6 for frontend image slideshow. Read Fancybox license before you
use it on profit websites. use it on profit websites.
* Fragment caching on frontend * Fragment caching on frontend
...@@ -55,11 +52,10 @@ TODO ...@@ -55,11 +52,10 @@ TODO
Gem is fully translated to slovak and english. Plupload is translated to 24 languages. You can add your own to Gem is fully translated to slovak and english. Plupload is translated to 24 languages. You can add your own to
photo_gallery/app/assets/javascripts/refinery/photo_gallery/admin/plupload/i18n and enable it in config.plupload_locale photo_gallery/app/assets/javascripts/refinery/photo_gallery/admin/plupload/i18n and enable it in config.plupload_locale
## Browser support
Client side image resizing with Plupload is possible on Firefox 3.5+ (with fixed quality) and Chrome.
Safari doesn't support direct data access to the selected files. Opera 12.00 + supports drag&drop and also client side image resizing.
## Working status
This is development snapshot. It is not suitable to production now, I'm going to fix bug list and todo list and then I will create stable branch/version.
But gem works, so if you want, feel free to try it and contribute :).
## Installation ## Installation
...@@ -77,7 +73,7 @@ Instructions for installation you can find under [www.sno.phy.queensu.ca/~phil/e ...@@ -77,7 +73,7 @@ Instructions for installation you can find under [www.sno.phy.queensu.ca/~phil/e
Open up your ``Gemfile`` and add at the bottom this line: Open up your ``Gemfile`` and add at the bottom this line:
```ruby ```ruby
gem 'refinerycms-photo-gallery', '~> 0.0.3.dev', :git => 'git://github.com/Matho/refinerycms-photo-gallery.git' gem 'refinerycms-photo-gallery', '~> 0.1.0', :git => 'git://github.com/Matho/refinerycms-photo-gallery.git', :branch=>'2-0-stable'
``` ```
Now, run Now, run
......
...@@ -2,7 +2,6 @@ module Refinery ...@@ -2,7 +2,6 @@ module Refinery
module PhotoGallery module PhotoGallery
module Admin module Admin
class CollectionsController < ::Refinery::AdminController class CollectionsController < ::Refinery::AdminController
cache_sweeper CollectionSweeper
crudify :'refinery/photo_gallery/collection', :order => "created_at DESC" , :xhr_paging => true crudify :'refinery/photo_gallery/collection', :order => "created_at DESC" , :xhr_paging => true
end end
......
module Refinery
module PhotoGallery
class CollectionsController < ::ApplicationController
include PhotoGalleryHelper
helper :'refinery/photo_gallery/photo_gallery'
def index
@collections = Collection.has_albums
@albums = Album.with_collection_id
respond_to do |format|
format.html
end
end
def show
@collections = Collection.has_albums
@albums = Album.with_collection_id
@albums_for_collection = Album.find_by_collection_id(params[:id])
respond_to do |format|
format.html
end
end
end
end
end
...@@ -2,58 +2,8 @@ module Refinery ...@@ -2,58 +2,8 @@ module Refinery
module PhotoGallery module PhotoGallery
module PhotoGalleryHelper module PhotoGalleryHelper
def message_albums_length_is_zero
if @albums.nil?
t('.no_albums')
end
end
def message_photos_length_is_zero
if @photos.nil?
t('.no_photos')
end
end
def message_collections_length_is_zero
if @collections.nil?
t('.no_collections')
end
end
def generate_photo_gallery_menu( collections, albums, options = {} )
content_tag(:ul, options[:ul] ) do
collections.each do |collection|
if params[:collection_id].present? && params[:id].present? # in albums controller
collection_id = params[:collection_id]
elsif params[:id].present? #in collection controller
collection_id = params[:id]
else
collection_id = 0 #only ensure initialization
end
# TODO if equals, set class="selected"
concat(content_tag(:li, options[:li]) do
concat(link_to collection.title, refinery.photo_gallery_collection_path(collection))
concat(content_tag(:ul ) do
# render albums, which belongs to collection
if !albums.blank?
albums.select{|album| album.collection_id == collection.id.to_s }.each do |album|
concat(content_tag(:li, options[:li] ) do
link_to album.title, refinery.photo_gallery_collection_album_path({:id=> album.id, :collection_id => collection.id})
end )
end
end
end )
end)
end
end
end
end
end end
end end
end
module Refinery module Refinery
class AlbumPage < Refinery::Core::BaseModel class AlbumPage < Refinery::Core::BaseModel
belongs_to Refinery::PhotoGallery::Album.table_name belongs_to :album , :class_name => Refinery::PhotoGallery::Album
belongs_to :page, :polymorphic => true belongs_to :page, :polymorphic => true
......
...@@ -20,6 +20,8 @@ module Refinery ...@@ -20,6 +20,8 @@ module Refinery
"#{id}-#{title.parameterize}" "#{id}-#{title.parameterize}"
end end
private private
def set_title def set_title
......
...@@ -7,17 +7,14 @@ module Refinery ...@@ -7,17 +7,14 @@ module Refinery
def sweep_album(album) def sweep_album(album)
expire_fragment("refinery/photo_gallery/albums/#{album.id}") expire_fragment("refinery/photo_gallery/albums/#{album.id}")
expire_fragment("refinery/photo_gallery/submenu")
end end
def sweep_album_with_photos(album) def sweep_album_with_photos(album)
sweep_album(album) sweep_album(album)
# only file store supports regexp # only file store supports regexp
# TODO DRY
begin begin
# This is slow, but I was unable to get the actual cache folder path. # This is slow, but I was unable to get the actual cache folder path.
# TODO This should be replaced with FileUtils.rm to get better speed
expire_fragment( %r{refinery/photo_gallery/albums/#{photo.album_id}/page_\d*}) expire_fragment( %r{refinery/photo_gallery/albums/#{photo.album_id}/page_\d*})
rescue NotImplementedError rescue NotImplementedError
Rails.cache.clear Rails.cache.clear
......
module Refinery
module PhotoGallery
module Admin
class CollectionSweeper < ActionController::Caching::Sweeper
observe Collection
def sweep_collection(collection)
expire_fragment("refinery/photo_gallery/submenu")
end
alias_method :after_create, :sweep_collection
alias_method :after_update, :sweep_collection
alias_method :after_destroy, :sweep_collection
end
end
end
end
<% cache "refinery/photo_gallery/albums/#{params[:id]}/page_#{params[:page]}" do %> <% cache "refinery/photo_gallery/albums/#{params[:id]}/page_#{params[:page]}" do %>
<%= will_paginate @photos %> <%= will_paginate @page.album.photos.page(params[:page]) %>
<div style="clear:both;"></div> <div style="clear:both;"></div>
<% @photos.each_with_index do |photo, index| %> <% @page.album.photos.each_with_index do |photo, index| %>
<div class="column portfolio-item"> <div class="column portfolio-item">
<div class="portfolio-thumbnail-image"> <div class="portfolio-thumbnail-image">
<%# :width => Refinery::PhotoGallery.album_dimensions[0], :height => Refinery::PhotoGallery.album_dimensions[1] %>
<%= link_to (image_tag photo.file.album.url, :width => Refinery::PhotoGallery.album_dimensions[0], :height => Refinery::PhotoGallery.album_dimensions[1] ), photo.file.single.url, { <%= link_to (image_tag photo.file.album.url ), photo.file.single.url, {
:target=> "_blank", :target=> "_blank",
:class=>"fancybox", :class=>"fancybox",
:data =>{:title=> photo_description(photo,@photos, index)}, :data =>{:title=> t('.image') + ' ' + (index + 1 ).to_s + '/' + @page.album.photos.length.to_s + ' ' + photo.title + '<br/><br/>' + photo.description},
:rel=>"group", :rel=>"group",
:title=> photo.title } %> :title=> photo.title } %>
</div> </div>
...@@ -19,5 +19,5 @@ ...@@ -19,5 +19,5 @@
<div style="clear:both;"></div> <div style="clear:both;"></div>
<%= will_paginate @photos %> <%= will_paginate @page.album.photos.page(params[:page]) %>
<% end %> <% end %>
<% cache "refinery/photo_gallery/albums/#{params[:id]}" do %>
<h2 >
<%= @page.album.title %>
</h2>
<div>
<%= raw @page.album.description %>
</div>
<% end %>
<div id="photo_gallery">
<%= render :partial => "/refinery/photo_gallery/albums/photos" %>
</div>
<% content_for :body_content_right do %>
<%= message_photos_length_is_zero %>
<% cache "refinery/photo_gallery/albums/#{params[:id]}" do %>
<h1 class="single-thumbnail-title post-title-color gdl-title">
<%= @album.title %>
</h1>
<div>
<%= raw @album.description %>
</div>
<% end %>
<div id="photo_gallery">
<%= render :partial => "photos" %>
</div>
<% end %>
<% content_for :body_content_left do %>
<%= render :partial=> "refinery/photo_gallery/shared/submenu" %>
<% end %>
<%= render :partial=> "refinery/photo_gallery/shared/layout" %>
<% content_for :body_content_right do %>
<%= message_collections_length_is_zero %>
<% end %>
<% content_for :body_content_left do %>
<%= render :partial=> "refinery/photo_gallery/shared/submenu" %>
<% end %>
<%= render :partial=> "refinery/photo_gallery/shared/layout" %>
\ No newline at end of file
<% content_for :body_content_right do %>
<%= message_albums_length_is_zero %>
<ul style="list-style-type: disc;">
<% @albums_for_collection.each do |album| %>
<li><%= link_to album.title, refinery.photo_gallery_collection_album_path(:collection_id=> params[:id], :id => album.id) %></li>
<%#TODO image thumbnail + description? %>
<%#= link_to (image_tag photo.file.album.url), photo.file.single.url %>
<% end %>
</ul>
<% end %>
<% content_for :body_content_left do %>
<%= render :partial=> "refinery/photo_gallery/shared/submenu" %>
<% end %>
<%= render :partial=> "refinery/photo_gallery/shared/layout" %>
\ No newline at end of file
<div class="content-wrapper sidebar-included left-sidebar">
<div class="clear"></div>
<div class="gdl-page-float-left">
<div class="gdl-page-item">
<div class="sixteen columns mt0">
<%= yield(:body_content_right) %>
</div>
</div>
<div class="five columns mt0 gdl-left-sidebar">
<div class="left-sidebar-wrapper gdl-divider">
<%= yield(:body_content_left) %>
</div>
</div>
</div>
<div class="clear"></div>
</div>
<% cache "refinery/photo_gallery/submenu" do %>
<div class="custom-sidebar gdl-divider">
<%= generate_photo_gallery_menu(@collections, @albums, {:ul => {:class => "", :id=>"submenu" }}) %>
</div>
<div class="pt30"></div>
<% end %>
...@@ -27,6 +27,6 @@ module Refinery ...@@ -27,6 +27,6 @@ module Refinery
require 'refinery/photo_gallery/engine' require 'refinery/photo_gallery/engine'
require 'refinery/photo_gallery/configuration' require 'refinery/photo_gallery/configuration'
require 'refinery/photo_gallery/extensions/pages_extension' require 'refinery/photo_gallery/extensions/pages_extension'
require 'refinery/photo_gallery/extensions/pages_helper_extension' require 'refinery/photo_gallery/extensions/pages_controller_extension'
end end
end end
\ No newline at end of file
module Refinery
module PhotoGallery
module Extensions
module PagesController
def load_helpers
=begin
Refinery::PagesController.class_eval do
include Refinery::PhotoGallery::PhotoGalleryHelper
helper :'refinery/photo_gallery/photo_gallery'
end
=end
end
end
end
end
end
...@@ -4,6 +4,8 @@ module Refinery ...@@ -4,6 +4,8 @@ module Refinery
module Pages module Pages
def has_one_page_album def has_one_page_album
has_one :album_page, :as => :page has_one :album_page, :as => :page
has_one :album, :through => :album_page
accepts_nested_attributes_for :album_page accepts_nested_attributes_for :album_page
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment