diff --git a/.gitignore b/.gitignore index db4bc39..6ea9f26 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,5 @@ Capfile public/thumbs public/uploads vendor/cache -.idea \ No newline at end of file +.idea +.sass-cache \ No newline at end of file diff --git a/.sass-cache/53c0ce4446c54bca21eabbfde8aea9e680be8c1a/jquery.plupload.queue.scssc b/.sass-cache/53c0ce4446c54bca21eabbfde8aea9e680be8c1a/jquery.plupload.queue.scssc deleted file mode 100644 index f8a7c61..0000000 Binary files a/.sass-cache/53c0ce4446c54bca21eabbfde8aea9e680be8c1a/jquery.plupload.queue.scssc and /dev/null differ diff --git a/.sass-cache/fb46dcf1b33fcd526ffc989de0c2b6e51630b35f/jquery.plupload.queue.scssc b/.sass-cache/fb46dcf1b33fcd526ffc989de0c2b6e51630b35f/jquery.plupload.queue.scssc deleted file mode 100644 index df4cc05..0000000 Binary files a/.sass-cache/fb46dcf1b33fcd526ffc989de0c2b6e51630b35f/jquery.plupload.queue.scssc and /dev/null differ diff --git a/.sass-cache/fb46dcf1b33fcd526ffc989de0c2b6e51630b35f/jquery.ui.plupload.scssc b/.sass-cache/fb46dcf1b33fcd526ffc989de0c2b6e51630b35f/jquery.ui.plupload.scssc deleted file mode 100644 index a9d253b..0000000 Binary files a/.sass-cache/fb46dcf1b33fcd526ffc989de0c2b6e51630b35f/jquery.ui.plupload.scssc and /dev/null differ diff --git a/Gemfile b/Gemfile index d6c1456..a0b3297 100644 --- a/Gemfile +++ b/Gemfile @@ -9,6 +9,7 @@ gem 'princely' gem 'jquery-rails' gem 'jquery-ui-rails' gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git' +gem 'ajaxful_rating_jquery', :git => 'git://github.com/baxang/ajaxful_rating_jquery.git'#, :branch => 'rails3' gem 'configatron', :git => 'git://github.com/markbates/configatron.git' gem 'plupload-rails', :git => 'git://github.com/bryanmig/plupload-rails.git' gem 'sequel', :git => 'git://github.com/jeremyevans/sequel.git' diff --git a/Gemfile.lock b/Gemfile.lock index 3de58f5..c5f6b62 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,9 @@ +GIT + remote: git://github.com/baxang/ajaxful_rating_jquery.git + revision: b4a2c760cdbad9cd865fb18667d14045018287ed + specs: + ajaxful_rating_jquery (3.0.0.beta3) + GIT remote: git://github.com/bryanmig/plupload-rails.git revision: 6d07d0f7e05d0b3fdc9b03b49d3a7c3aa1cd703b @@ -251,6 +257,7 @@ PLATFORMS ruby DEPENDENCIES + ajaxful_rating_jquery! cancan carrierwave (= 0.6.2) coffee-rails diff --git a/app/assets/images/ajaxful_rating/star.png b/app/assets/images/ajaxful_rating/star.png new file mode 100644 index 0000000..1e58c5d Binary files /dev/null and b/app/assets/images/ajaxful_rating/star.png differ diff --git a/app/assets/images/ajaxful_rating/star_small.png b/app/assets/images/ajaxful_rating/star_small.png new file mode 100644 index 0000000..1ec7f99 Binary files /dev/null and b/app/assets/images/ajaxful_rating/star_small.png differ diff --git a/app/assets/images/rails.png b/app/assets/images/rails.png deleted file mode 100644 index d5edc04..0000000 Binary files a/app/assets/images/rails.png and /dev/null differ diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 87ab0a9..75efd5c 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -6,6 +6,7 @@ // //= require jquery //= require jquery_ujs +//= require jquery.easing.1.3 //= require twitter/bootstrap //= require plupload //= require jquery.plupload.queue diff --git a/app/assets/stylesheets/ajaxful_rating.css.scss b/app/assets/stylesheets/ajaxful_rating.css.scss new file mode 100644 index 0000000..d17a8fa --- /dev/null +++ b/app/assets/stylesheets/ajaxful_rating.css.scss @@ -0,0 +1,91 @@ +/* +* Style by Rogie http://www.komodomedia.com/blog/2007/01/css-star-rating-redux/ +*/ + +.ajaxful-rating, +.ajaxful-rating a:hover, +.ajaxful-rating a:active, +.ajaxful-rating a:focus, +.ajaxful-rating .show-value { + background: url("/assets/ajaxful_rating/star.png") left -1000px repeat-x; +} + +.ajaxful-rating { + position: relative; +/*width: 125px; this is setted dynamically */ + height: 25px; + overflow: hidden; + list-style: none; + margin: 0; + padding: 0; + background-position: left top; +} + +.ajaxful-rating li { + display: inline; +} + +.ajaxful-rating a, +.ajaxful-rating span, +.ajaxful-rating .show-value { + position: absolute; + top: 0; + left: 0; + text-indent: -1000em; + height: 25px; + line-height: 25px; + outline: none; + overflow: hidden; + border: none; +} + +.ajaxful-rating a:hover, +.ajaxful-rating a:active, +.ajaxful-rating a:focus { + background-position: left bottom; +} + +/* This section is generated dynamically. +Just add a call to the helper method 'ajaxful_rating_style' within +the head tags in your main layout +.ajaxful-rating .stars-1{ +width: 20%; +z-index: 6; +} +.ajaxful-rating .stars-2{ +width: 40%; +z-index: 5; +} +.ajaxful-rating .stars-3{ +width: 60%; +z-index: 4; +} +.ajaxful-rating .stars-4{ +width: 80%; +z-index: 3; +} +.ajaxful-rating .stars-5{ +width: 100%; +z-index: 2; +} +*/ +.ajaxful-rating .show-value { + z-index: 1; + background-position: left center; +} + +/* smaller star */ +.ajaxful-rating.small { +/*width: 50px; this is setted dynamically */ + height: 10px; +} + +.ajaxful-rating.small, +.ajaxful-rating.small a:hover, +.ajaxful-rating.small a:active, +.ajaxful-rating.small a:focus, +.ajaxful-rating.small .show-value { + background-image: url("/assets/ajaxful_rating/star_small.png"); + line-height: 10px; + height: 10px; +} diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 424cc96..594993b 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -3,4 +3,12 @@ *= require_tree . *= require jquery.plupload.queue *= require bootstrap_and_overrides - */ \ No newline at end of file + */ + +.ajaxful-rating-wrapper{ + float: right; +} + +.view-btn{ + display: inline; +} \ No newline at end of file diff --git a/app/controllers/collections_controller.rb b/app/controllers/collections_controller.rb index 18d300e..0878ad1 100644 --- a/app/controllers/collections_controller.rb +++ b/app/controllers/collections_controller.rb @@ -4,7 +4,9 @@ class CollectionsController < ApplicationController def index - @collections = Collection.joins(:albums => :photos).group_for.order('collections.title') + @collections = Collection.includes(:albums => :photos).where("photos.id NOT NULL").group_for.order('collections.title') + @popular_photos = Photo.visible.order('rating_average asc').limit(10) + respond_to do |format| format.html format.json { render :json => @collections } @@ -59,5 +61,11 @@ class CollectionsController < ApplicationController redirect_to @collection end end + + def rate + @collection = Collection.find(params[:id]) + @collection.rate(params[:stars], current_user, params[:dimension]) + render :json => {:id => @collection.wrapper_dom_id(params), :width => 125} + end end diff --git a/app/models/album.rb b/app/models/album.rb index 3f0728f..583b7c0 100644 --- a/app/models/album.rb +++ b/app/models/album.rb @@ -1,6 +1,8 @@ class Album < ActiveRecord::Base extend Ext::GroupFor + ajaxful_rateable :stars => 5, :cache_column => :rating_average + has_many :photos, :dependent => :destroy has_many :collection_albums has_many :collections, :through => :collection_albums diff --git a/app/models/collection.rb b/app/models/collection.rb index 666248f..cc728e7 100644 --- a/app/models/collection.rb +++ b/app/models/collection.rb @@ -1,6 +1,8 @@ class Collection < ActiveRecord::Base extend Ext::GroupFor + ajaxful_rateable :stars => 5, :cache_column => :rating_average + has_many :collection_albums has_many :albums, :through => :collection_albums attr_accessor :album_list diff --git a/app/models/photo.rb b/app/models/photo.rb index 552ab39..755de96 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -1,19 +1,21 @@ class Photo < ActiveRecord::Base extend Ext::GroupFor + ajaxful_rateable :stars => 5, :cache_column => :rating_average + belongs_to :album has_many :photo_tags, :dependent => :destroy has_many :tags, :through => :photo_tags mount_uploader :attachment, FileUploader - before_create :exif_read before_update :exif_write after_create :set_title attr_accessor :tag_list - + + scope :visible, where(:public => true) scope :untouched, :conditions => "photos.description IS NULL AND photos.id NOT IN ( SELECT photo_id FROM photo_tags)", :include => :album scope :previous, lambda { |p,a| { :conditions => ["id < :id AND album_Id = :album ", { :id => p, :album => a } ], :limit => 1, :order => "id DESC"} } scope :next, lambda { |p,a| { :conditions => ["id > :id AND album_Id = :album ", { :id => p, :album => a } ], :limit => 1, :order => "id ASC"} } diff --git a/app/models/rate.rb b/app/models/rate.rb new file mode 100644 index 0000000..4ff8248 --- /dev/null +++ b/app/models/rate.rb @@ -0,0 +1,7 @@ +class Rate < ActiveRecord::Base + belongs_to :rater, :class_name => "User" + belongs_to :rateable, :polymorphic => true + validates_numericality_of :stars, :minimum => 1 + + attr_accessible :rate, :dimension +end diff --git a/app/models/secret_link_observer.rb b/app/models/secret_link_observer.rb new file mode 100644 index 0000000..ede8ccd --- /dev/null +++ b/app/models/secret_link_observer.rb @@ -0,0 +1,7 @@ +class SecretLinkObserver < ActiveRecord::Observer + observe :collection, :album, :photo + + def before_create(record) + record.url = ::SecureRandom.hex(16) + end +end diff --git a/app/models/user.rb b/app/models/user.rb index 780cc4e..ed69172 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -4,6 +4,8 @@ class User < ActiveRecord::Base attr_accessible :id, :name, :second_name, :surname, :email, :password, :password_confirmation, :remember_me, :userpic + ajaxful_rater + mount_uploader :userpic, UserpicUploader has_and_belongs_to_many :roles diff --git a/app/uploaders/file_uploader.rb b/app/uploaders/file_uploader.rb index e38b330..6084b5f 100644 --- a/app/uploaders/file_uploader.rb +++ b/app/uploaders/file_uploader.rb @@ -64,22 +64,38 @@ class FileUploader < CarrierWave::Uploader::Base end end - version :preview do - process :resize_to_fit => [210, 210] + ###################################################################################################################### + # Note + # The default grid system provided in Bootstrap utilizes 12 columns that + # render out at widths of 724px, 940px (default without responsive CSS included), and 1170px. + # Below 767px viewports, the columns become fluid and stack vertically. + + version :middle do + process :resize_to_fit => [724, 500] def store_dir ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}/#{model.id}" end end - version :single do - process :resize_to_limit => [950, 950] + version :large do + process :resize_to_fit => [940, 500] def store_dir ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}/#{model.id}" end end + version :largest do + process :resize_to_fit => [1170, 500] + + def store_dir + ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}/#{model.id}" + end + end + ###################################################################################################################### + + # Add a white list of extensions which are allowed to be uploaded, # for images you might use something like this: def extension_white_list diff --git a/app/uploaders/userpic_uploader.rb b/app/uploaders/userpic_uploader.rb index 888b822..0e2e856 100644 --- a/app/uploaders/userpic_uploader.rb +++ b/app/uploaders/userpic_uploader.rb @@ -9,6 +9,13 @@ class UserpicUploader < CarrierWave::Uploader::Base "#{::SecureRandom.hex(8)}#{File.extname(original_filename).downcase}" if original_filename end + version :mini do + process :resize_to_fit => [50, 50] + + def store_dir + "#{ENV['STORAGE_PATH']}/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}/mini" + end + end version :small do process :resize_to_fit => [100, 100] diff --git a/app/views/collections/index.html.erb b/app/views/collections/index.html.erb index 3c6ea58..478fa3a 100644 --- a/app/views/collections/index.html.erb +++ b/app/views/collections/index.html.erb @@ -1,25 +1,31 @@ -<% @collections.in_groups_of(4).compact.each do |group| %> - <% unless group.compact.empty? %> -
This is a template for a simple marketing or informational website. It includes a large callout called the hero - unit and three supporting pieces of content. Use it as a starting point to create something more unique.
- -