diff --git a/app/controllers/admin/application_controller.rb b/app/controllers/admin/application_controller.rb
index 09de35b..99a9d86 100644
--- a/app/controllers/admin/application_controller.rb
+++ b/app/controllers/admin/application_controller.rb
@@ -1,5 +1,5 @@
class Admin::ApplicationController < ApplicationController
- before_filter :require_user, :require_role_admin
+ before_filter :require_role_admin
end
diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb
index 82d283e..9ca0051 100644
--- a/app/controllers/admin/users_controller.rb
+++ b/app/controllers/admin/users_controller.rb
@@ -1,7 +1,7 @@
class Admin::UsersController < Admin::ApplicationController
def index
- @users = User.find(:all)
+ @users = User.find(:all, :order => "Name, email")
end
def show
@@ -16,7 +16,7 @@ class Admin::UsersController < Admin::ApplicationController
@user = User.new(params[:user])
if @user.save
flash[:notice] = "Account registered!"
- redirect_to [:admin, @user]
+ redirect_to @user
else
render :action => :new
end
@@ -30,7 +30,7 @@ class Admin::UsersController < Admin::ApplicationController
@user = User.find(params[:id])
if @user.update_attributes(params[:user])
flash[:notice] = "Account updated!"
- redirect_to [:admin, @user]
+ redirect_to @user
else
render :action => :edit
end
@@ -39,7 +39,7 @@ class Admin::UsersController < Admin::ApplicationController
def destroy
@user = User.find(params[:id])
if @user.destroy
- redirect_to admin_users_path
+ redirect_to users_path
else
redirect_to @user
end
diff --git a/app/controllers/albums_controller.rb b/app/controllers/albums_controller.rb
index 27092b2..ec8e73a 100644
--- a/app/controllers/albums_controller.rb
+++ b/app/controllers/albums_controller.rb
@@ -1,6 +1,6 @@
class AlbumsController < ApplicationController
- before_filter :require_role_admin, :only => [:untouched, :upload, :new, :create, :edit, :update, :destroy]
+ before_filter :require_role_admin, :only => [:untouched, :new, :create, :edit, :update, :destroy]
def index
if params[:tag_id]
@@ -36,10 +36,6 @@ class AlbumsController < ApplicationController
end
end
- def upload
- @album = Album.find( params[:id])
- end
-
def new
@album = Album.new
end
@@ -62,7 +58,7 @@ class AlbumsController < ApplicationController
def update
@album = Album.find( params[:id])
if @album.update_attributes(params[:album])
- flash[:notice] = "Account updated!"
+ flash[:notice] = "Album updated!"
redirect_to @album
else
render :action => :edit
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 88d4520..a7b81ae 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -26,45 +26,46 @@ class ApplicationController < ActionController::Base
unless current_user && current_user.in_role?(*roles)
store_location
flash[:notice] = "You must have permission to access this page"
- redirect_to new_user_session_url
+ redirect_to account_path
return false
end
+ return true
end
def require_role_admin
- unless current_user && current_user.in_role?("admin")
- store_location
- flash[:notice] = "You must have permission to access this page"
- redirect_to new_user_session_url
- return false
- end
+ return false if !require_user
+ return require_role("admin")
end
def require_permission(permissions = [])
+ return false if !require_user
unless current_user && current_user.has_permission?(*permissions)
store_location
flash[:notice] = "You must have permission to access this page"
- redirect_to new_user_session_url
+ redirect_to account_path
return false
end
+ return true
end
def require_user
unless current_user
store_location
flash[:notice] = "You must be logged in to access this page"
- redirect_to new_user_session_url
+ redirect_to login_path
return false
end
+ return true
end
def require_no_user
if current_user
store_location
- flash[:notice] = "You must be logged out to access this page"
- redirect_to account_url
+ flash[:notice] = "Already logged in. Please logout"
+ redirect_to account_path
return false
end
+ return true
end
def store_location
diff --git a/app/controllers/collections_controller.rb b/app/controllers/collections_controller.rb
index 3a22ad3..1ebf860 100644
--- a/app/controllers/collections_controller.rb
+++ b/app/controllers/collections_controller.rb
@@ -1,7 +1,6 @@
class CollectionsController < ApplicationController
- before_filter :require_role_admin, :only => [:new, :create, :edit, :update, :destroy]
-
+ before_filter :require_role_admin, :only => [:new, :create, :edit, :update, :destroy]
def index
@collections = Collection.find(:all)
respond_to do |format|
@@ -42,7 +41,7 @@ class CollectionsController < ApplicationController
def update
@collection = Collection.find( params[:id])
if @collection.update_attributes(params[:collection])
- flash[:notice] = "collection updated!"
+ flash[:notice] = "Collection updated!"
redirect_to @collection
else
render :action => :edit
diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb
index 1aa2087..4e72940 100644
--- a/app/controllers/photos_controller.rb
+++ b/app/controllers/photos_controller.rb
@@ -1,14 +1,16 @@
class PhotosController < ApplicationController
- before_filter :require_role_admin, :only => [:untouched, :new, :create, :edit, :update, :destroy]
+ before_filter :require_role_admin, :only => [:untouched, :upload, :new, :create, :edit, :update, :destroy]
def index
if params[:tag_id]
@photos = Tag.find_by_title( params[:tag_id] ).photos
+ elsif params[:album_id]
+ @photos = Album.find( params[:album_id]).photos.find(:all)
elsif params[:q]
@photos = Photo.find(:all, :limit => 20, :conditions => [ "Photos.description LIKE :q OR Photos.title LIKE :q OR Photos.Id IN ( SELECT Photo_Id FROM Photo_Tags LEFT OUTER JOIN Tags ON Photo_Tags.Tag_Id = Tags.Id WHERE Tags.Title LIKE :q) ", { :q => '%' + params[:q] + '%' } ], :include => :album )
else
- @photos = Photo.find(:all, :limit => 20)
+ @photos = Photo.find(:all)
end
respond_to do |format|
format.html
@@ -18,7 +20,12 @@ class PhotosController < ApplicationController
end
def untouched
- @photos = Photo.untouched()
+ if params[:album_id]
+ @album = Album.find( params[:album_id])
+ @photos = @album.photos.untouched
+ else
+ @photos = Photo.untouched()
+ end
respond_to do |format|
format.html
format.json { render :json => @photos }
@@ -39,6 +46,10 @@ class PhotosController < ApplicationController
@photo = Photo.new
end
+ def upload
+ @album = Album.find( params[:album_id])
+ end
+
def create
respond_to do |format|
@photo = Photo.new(params[:photo])
@@ -68,15 +79,32 @@ class PhotosController < ApplicationController
@photo = Photo.find( params[:id])
end
+ def edit_multiple
+ if params[:album_id]
+ @photos = Album.find( params[:album_id] ).photos
+ else
+ @photos = Photo.find( params[:photo_ids] )
+ end
+ end
+
def update
@photo = Photo.find( params[:id])
if @photo.update_attributes(params[:photo])
- flash[:notice] = "Account updated!"
+ flash[:notice] = "Photo updated!"
redirect_to @photo
else
render :action => :edit
end
end
+
+ def update_multiple
+ @photos = Photo.find(params[:photo_ids])
+ @photos.each do |photo|
+ photo.update_attributes!(params[:photo].reject { |k,v| v.blank? })
+ end
+ flash[:notice] = "Updated photos!"
+ redirect_to photos_path
+ end
def destroy
@photo = Photo.find( params[:id])
diff --git a/app/controllers/user_sessions_controller.rb b/app/controllers/user_sessions_controller.rb
index 5e08432..acc3e57 100644
--- a/app/controllers/user_sessions_controller.rb
+++ b/app/controllers/user_sessions_controller.rb
@@ -10,9 +10,9 @@ class UserSessionsController < ApplicationController
@user_session = UserSession.new(params[:user_session])
if @user_session.save
flash[:notice] = "Login successful!"
- redirect_back_or_default account_url
+ redirect_back_or_default account_path
else
- render :action => :new
+ render :new
end
end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index bc23287..4ed6f42 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -10,7 +10,7 @@ class UsersController < ApplicationController
@user = User.new(params[:user])
if @user.save
flash[:notice] = "Account registered!"
- redirect_back_or_default account_url
+ redirect_back_or_default account_path
else
render :action => :new
end
@@ -28,7 +28,7 @@ class UsersController < ApplicationController
@user = @current_user # makes our views "cleaner" and more consistent
if @user.update_attributes(params[:user])
flash[:notice] = "Account updated!"
- redirect_to account_url
+ redirect_to account_path
else
render :action => :edit
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 22a7940..e6dc3eb 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1,3 +1,4 @@
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
+
end
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index 2310a24..1062f12 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -1,2 +1,9 @@
module UsersHelper
+ def has_permission?(permissions = [])
+ return current_user && current_user.has_permission?(permissions)
+ end
+
+ def has_role?(roles = [])
+ return current_user && current_user.in_role?(roles)
+ end
end
diff --git a/app/models/album.rb b/app/models/album.rb
index 6253e7a..4397886 100644
--- a/app/models/album.rb
+++ b/app/models/album.rb
@@ -11,13 +11,10 @@ class Album < ActiveRecord::Base
attr_accessor :tag_list
attr_protected :path
+
+ named_scope :untouched, :conditions => "Albums.Id IN ( SELECT DISTINCT Photos.Album_Id FROM Photos WHERE Photos.description IS NULL AND Photos.Id NOT IN ( SELECT Photo_ID FROM Photo_Tags) )"
-
- def self.untouched
- self.find(:all, :conditions => "Albums.Id IN ( SELECT DISTINCT Photos.Album_Id FROM Photos WHERE Photos.description IS NULL AND Photos.Id NOT IN ( SELECT Photo_ID FROM Photo_Tags) )" )
- end
-
def ensure_path
self.path = self.title if !self.path
diff --git a/app/models/photo.rb b/app/models/photo.rb
index 3a639b8..a12adbc 100644
--- a/app/models/photo.rb
+++ b/app/models/photo.rb
@@ -16,12 +16,8 @@ class Photo < ActiveRecord::Base
attr_accessor :tag_list
attr_protected :path
-
-
- def self.untouched
- self.find(:all, :conditions => "Photos.description IS NULL AND Photos.Id NOT IN ( SELECT Photo_ID FROM Photo_Tags)", :include => :album )
- end
+ named_scope :untouched, :conditions => "Photos.description IS NULL AND Photos.Id NOT IN ( SELECT Photo_ID FROM Photo_Tags)", :include => :album
def path_original_public
return APP_CONFIG[:photos_path_public] + self.path
@@ -118,7 +114,7 @@ class Photo < ActiveRecord::Base
self.latitude = photo.GPSLatitude if self.latitude.nil?
self.title = photo.DocumentName if self.title.nil?
self.description = photo.ImageDescription if self.description.nil?
- self.tag_list = (self.tags.empty? ? "" : self.album.tag_list) + " " + (photo.Keywords.map { |tag| tag.gsub(" ", "_") }.join(" ") if !photo.Keywords.nil?)
+ self.tag_list = (self.tags.empty? ? "" : self.album.tag_list) + " " + (photo.Keywords.nil? ? "" : photo.Keywords.map { |tag| tag.gsub(" ", "_") }.join(" "))
end
def exif_write
diff --git a/app/views/admin/users/_form.html.erb b/app/views/admin/users/_form.html.erb
index bf79c8c..c8d582d 100644
--- a/app/views/admin/users/_form.html.erb
+++ b/app/views/admin/users/_form.html.erb
@@ -3,9 +3,4 @@
<%= form.label :email %>
<%= form.text_field :email %>
-
-<%= form.label :password, form.object.new_record? ? nil : "Change password" %>
-<%= form.password_field :password %>
-
-<%= form.label :password_confirmation %>
-<%= form.password_field :password_confirmation %>
\ No newline at end of file
+
\ No newline at end of file
diff --git a/app/views/admin/users/edit.html.erb b/app/views/admin/users/edit.html.erb
index b775ce0..d495b9a 100644
--- a/app/views/admin/users/edit.html.erb
+++ b/app/views/admin/users/edit.html.erb
@@ -1,6 +1,6 @@
Edit Account
-<% form_for [:admin, @user] do |f| %>
+<% form_for @user do |f| %>
<%= f.error_messages %>
<%= render :partial => "form", :object => f %>
<%= f.submit "Update" %>
@@ -10,4 +10,4 @@
:confirm => "Are you sure you want to delete this user?",
:method => :delete) %>
-
<%= link_to "All users", admin_users_path %>
\ No newline at end of file
+
<%= link_to "All users", users_path %>
\ No newline at end of file
diff --git a/app/views/admin/users/index.html.erb b/app/views/admin/users/index.html.erb
index 73e8b36..f30cfc3 100644
--- a/app/views/admin/users/index.html.erb
+++ b/app/views/admin/users/index.html.erb
@@ -1,3 +1,5 @@
<% for user in @users %>
-<%= link_to user.name || user.email , [:admin, user] %>
-<% end %>
\ No newline at end of file
+<%= link_to user.name || user.email , user %>
+<% end %>
+
+
<%= link_to "New user", new_user_path %>
\ No newline at end of file
diff --git a/app/views/admin/users/new.html.erb b/app/views/admin/users/new.html.erb
index 6c54e8c..72387ee 100644
--- a/app/views/admin/users/new.html.erb
+++ b/app/views/admin/users/new.html.erb
@@ -1,7 +1,9 @@
Register
-<% form_for [:admin, @user] do |f| %>
+<% form_for @user do |f| %>
<%= f.error_messages %>
<%= render :partial => "form", :object => f %>
<%= f.submit "Register" %>
-<% end %>
\ No newline at end of file
+<% end %>
+
+
<%= link_to "All users", users_path %>
\ No newline at end of file
diff --git a/app/views/admin/users/show.html.erb b/app/views/admin/users/show.html.erb
index 873181a..bbc6bb1 100644
--- a/app/views/admin/users/show.html.erb
+++ b/app/views/admin/users/show.html.erb
@@ -40,5 +40,5 @@
-<%= link_to 'Edit', edit_admin_user_path(@user) %>
-
<%= link_to "All users", admin_users_path %>
\ No newline at end of file
+<%= link_to 'Edit', edit_user_path(@user) %>
+
<%= link_to "All users", users_path %>
\ No newline at end of file
diff --git a/app/views/albums/index.html.erb b/app/views/albums/index.html.erb
index 889f4b7..328438d 100644
--- a/app/views/albums/index.html.erb
+++ b/app/views/albums/index.html.erb
@@ -1,5 +1,4 @@
Albums
<%= render :partial => @albums %>
-
<%= link_to "New Album", new_album_path %>
-
<%= link_to "All albums", albums_path %>
\ No newline at end of file
+
<%= link_to "New Album", new_album_path %>
\ No newline at end of file
diff --git a/app/views/albums/show.html.erb b/app/views/albums/show.html.erb
index 53e85df..52e97d4 100644
--- a/app/views/albums/show.html.erb
+++ b/app/views/albums/show.html.erb
@@ -3,10 +3,13 @@
<%= link_to image_tag( photo.path_modified_public("album") ), photo %>
<% end %>
<%= @album.description %>
-<% if current_user && current_user.has_permission?("see_album_note") %>
+<% if has_permission?("see_album_note") %>
<%= @album.note %>
<% end %>
+<% if has_role?("admin") %>
<%= link_to "Update album", edit_album_path(@album) %>
-
<%= link_to "Upload photos", upload_album_path(@album) %>
+
<%= link_to "Update photos", edit_multiple_album_photos_path(@album) %>
+
<%= link_to "Upload photos", upload_album_photos_path(@album) %>
+<% end %>
<%= link_to "All albums", albums_path %>
\ No newline at end of file
diff --git a/app/views/albums/test/upload.html.erb b/app/views/albums/test/upload.html.erb
index 4c8de40..18208e6 100644
--- a/app/views/albums/test/upload.html.erb
+++ b/app/views/albums/test/upload.html.erb
@@ -1,729 +1,36 @@
-if ( $('ul.gallery').length ) {
- $('ul.gallery').galleria( {
- clickNext : true,
- insert: "#photo_large",
- onImage: function ( image, caption, thumb ) {
- image.css('display','none').fadeIn()
-
- thumb.parents('li').siblings().children('img.selected').fadeTo(500,0.3)
- thumb.fadeTo('fast',1).addClass('selected')
- $( '#photo_metadata' ).html( 'Update photo details' )
-
- var scrollable = $("#thumbstrip").scrollable()
- scrollable.seekTo( thumb.parents('ul').children().index( thumb.parents('li') ) )
- },
- onThumb: function ( thumb) {
- thumb.css({display:'none',opacity: (thumb.parents('li').is('.active') ? '1' : '0.3') }).fadeIn(1500)
- }
- })
- }
-
- if ( $('#thumbstrip').length ) {
- $('#thumbstrip').scrollable( {
- items : '#thumbs',
- clickable: true,
- keyboard : false
- })
- if ( $('#thumbs li.active').length == 0 ){
- //$('div.scrollable').scrollable().click(0)
- $('#thumbs li:first').addClass('active')
- }
- }
-
<% content_for :javascript do %>
-
-<% end %>
-
-
+
+<% end %>
+
- addImage("http://demo.swfupload.org/v220/applicationdemo/images/" + imageName);
-
- } catch (ex3) {
- this.debug(ex3);
- }
-
-}
-
-
-function addImage(src) {
- var newImg = document.createElement("img");
- newImg.style.margin = "5px";
-
- document.getElementById("thumbnails").appendChild(newImg);
- if (newImg.filters) {
- try {
- newImg.filters.item("DXImageTransform.Microsoft.Alpha").opacity = 0;
- } catch (e) {
- // If it is not set initially, the browser will throw an error. This will set it if it is not set yet.
- newImg.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + 0 + ')';
- }
- } else {
- newImg.style.opacity = 0;
- }
-
- newImg.onload = function () {
- fadeIn(newImg, 0);
- };
- newImg.src = src;
-}
-
-function fadeIn(element, opacity) {
- var reduceOpacityBy = 5;
- var rate = 30; // 15 fps
-
-
- if (opacity < 100) {
- opacity += reduceOpacityBy;
- if (opacity > 100) {
- opacity = 100;
- }
-
- if (element.filters) {
- try {
- element.filters.item("DXImageTransform.Microsoft.Alpha").opacity = opacity;
- } catch (e) {
- // If it is not set initially, the browser will throw an error. This will set it if it is not set yet.
- element.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + opacity + ')';
- }
- } else {
- element.style.opacity = opacity / 100;
- }
- }
-
- if (opacity < 100) {
- setTimeout(function () {
- fadeIn(element, opacity);
- }, rate);
- }
-}
-
-
-
-/* ******************************************
- * FileProgress Object
- * Control object for displaying file info
- * ****************************************** */
-
-function FileProgress(file, targetID) {
- this.fileProgressID = "divFileProgress";
-
- this.fileProgressWrapper = document.getElementById(this.fileProgressID);
- if (!this.fileProgressWrapper) {
- this.fileProgressWrapper = document.createElement("div");
- this.fileProgressWrapper.className = "progressWrapper";
- this.fileProgressWrapper.id = this.fileProgressID;
-
- this.fileProgressElement = document.createElement("div");
- this.fileProgressElement.className = "progressContainer";
-
- var progressCancel = document.createElement("a");
- progressCancel.className = "progressCancel";
- progressCancel.href = "#";
- progressCancel.style.visibility = "hidden";
- progressCancel.appendChild(document.createTextNode(" "));
-
- var progressText = document.createElement("div");
- progressText.className = "progressName";
- progressText.appendChild(document.createTextNode(file.name));
-
- var progressBar = document.createElement("div");
- progressBar.className = "progressBarInProgress";
-
- var progressStatus = document.createElement("div");
- progressStatus.className = "progressBarStatus";
- progressStatus.innerHTML = " ";
-
- this.fileProgressElement.appendChild(progressCancel);
- this.fileProgressElement.appendChild(progressText);
- this.fileProgressElement.appendChild(progressStatus);
- this.fileProgressElement.appendChild(progressBar);
-
- this.fileProgressWrapper.appendChild(this.fileProgressElement);
-
- document.getElementById(targetID).appendChild(this.fileProgressWrapper);
- fadeIn(this.fileProgressWrapper, 0);
-
- } else {
- this.fileProgressElement = this.fileProgressWrapper.firstChild;
- this.fileProgressElement.childNodes[1].firstChild.nodeValue = file.name;
- }
-
- this.height = this.fileProgressWrapper.offsetHeight;
-
-}
-FileProgress.prototype.setProgress = function (percentage) {
- this.fileProgressElement.className = "progressContainer green";
- this.fileProgressElement.childNodes[3].className = "progressBarInProgress";
- this.fileProgressElement.childNodes[3].style.width = percentage + "%";
-};
-FileProgress.prototype.setComplete = function () {
- this.fileProgressElement.className = "progressContainer blue";
- this.fileProgressElement.childNodes[3].className = "progressBarComplete";
- this.fileProgressElement.childNodes[3].style.width = "";
-
-};
-FileProgress.prototype.setError = function () {
- this.fileProgressElement.className = "progressContainer red";
- this.fileProgressElement.childNodes[3].className = "progressBarError";
- this.fileProgressElement.childNodes[3].style.width = "";
-
-};
-FileProgress.prototype.setCancelled = function () {
- this.fileProgressElement.className = "progressContainer";
- this.fileProgressElement.childNodes[3].className = "progressBarError";
- this.fileProgressElement.childNodes[3].style.width = "";
-
-};
-FileProgress.prototype.setStatus = function (status) {
- this.fileProgressElement.childNodes[2].innerHTML = status;
-};
-
-FileProgress.prototype.toggleCancel = function (show, swfuploadInstance) {
- this.fileProgressElement.childNodes[0].style.visibility = show ? "visible" : "hidden";
- if (swfuploadInstance) {
- var fileID = this.fileProgressID;
- this.fileProgressElement.childNodes[0].onclick = function () {
- swfuploadInstance.cancelUpload(fileID);
- return false;
- };
- }
-};
-
-
-
- var swfu;
- window.onload = function () {
- swfu = new SWFUpload({
- // Backend Settings
- upload_url: "<%= new_upload_path_with_session_information %>",
- post_params : {
- 'method' : "_put",
- 'authenticity_token' : '<%= u form_authenticity_token -%>',
- 'photo[album_id]' : "<%= @album.id %>"
- },
-
- // File Upload Settings
- file_size_limit : "2 MB", // 2MB
- file_types : "*.jpg",
- file_types_description : "JPG Images",
- file_upload_limit : "0",
-
- // Event Handler Settings - these functions as defined in Handlers.js
- // The handlers are not part of SWFUpload but are part of my website and control how
- // my website reacts to the SWFUpload events.
- file_queue_error_handler : fileQueueError,
- file_dialog_complete_handler : fileDialogComplete,
- upload_progress_handler : uploadProgress,
- upload_error_handler : uploadError,
- upload_success_handler : uploadSuccess,
- upload_complete_handler : uploadComplete,
-
- // Button Settings
- button_image_url : "http://demo.swfupload.org/v220/applicationdemo/images/SmallSpyGlassWithTransperancy_17x18.png",
- button_placeholder_id : "spanButtonPlaceholder",
- button_width: 180,
- button_height: 18,
- button_text : 'Select Images (2 MB Max)',
- button_text_style : '.button { font-family: Helvetica, Arial, sans-serif; font-size: 12pt; } .buttonSmall { font-size: 10pt; }',
- button_text_top_padding: 0,
- button_text_left_padding: 18,
- button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
- button_cursor: SWFUpload.CURSOR.HAND,
-
- // Flash Settings
- flash_url : "/javascripts/swfupload/Flash/swfupload.swf",
-
- custom_settings : {
- upload_target : "divFileProgressContainer"
- },
-
- // Debug Settings
- debug: false
- });
- };
-
-
-
Application Demo
-
This demo shows how SWFUpload can behave like an AJAX application. Images are uploaded by SWFUpload then some JavaScript is used to display the thumbnails without reloading the page.
- <% form_for(Photo.new) do |f| %>
-
-
-
- <% end %>
-
-
-
diff --git a/app/views/albums/test/upload_first.html.erb b/app/views/albums/test/upload_first.html.erb
new file mode 100644
index 0000000..4c8de40
--- /dev/null
+++ b/app/views/albums/test/upload_first.html.erb
@@ -0,0 +1,729 @@
+if ( $('ul.gallery').length ) {
+ $('ul.gallery').galleria( {
+ clickNext : true,
+ insert: "#photo_large",
+ onImage: function ( image, caption, thumb ) {
+ image.css('display','none').fadeIn()
+
+ thumb.parents('li').siblings().children('img.selected').fadeTo(500,0.3)
+ thumb.fadeTo('fast',1).addClass('selected')
+ $( '#photo_metadata' ).html( 'Update photo details' )
+
+ var scrollable = $("#thumbstrip").scrollable()
+ scrollable.seekTo( thumb.parents('ul').children().index( thumb.parents('li') ) )
+ },
+ onThumb: function ( thumb) {
+ thumb.css({display:'none',opacity: (thumb.parents('li').is('.active') ? '1' : '0.3') }).fadeIn(1500)
+ }
+ })
+ }
+
+ if ( $('#thumbstrip').length ) {
+ $('#thumbstrip').scrollable( {
+ items : '#thumbs',
+ clickable: true,
+ keyboard : false
+ })
+ if ( $('#thumbs li.active').length == 0 ){
+ //$('div.scrollable').scrollable().click(0)
+ $('#thumbs li:first').addClass('active')
+ }
+ }
+
+<% content_for :javascript do %>
+
+<% end %>
+
+
+
+
+
+
Application Demo
+
This demo shows how SWFUpload can behave like an AJAX application. Images are uploaded by SWFUpload then some JavaScript is used to display the thumbnails without reloading the page.
+ <% form_for(Photo.new) do |f| %>
+
+
+
+ <% end %>
+
+
+
diff --git a/app/views/albums/untouched.html.erb b/app/views/albums/untouched.html.erb
index d8c1536..0784daf 100644
--- a/app/views/albums/untouched.html.erb
+++ b/app/views/albums/untouched.html.erb
@@ -1,2 +1,4 @@
Albums
-<%= render :partial => @albums %>
\ No newline at end of file
+<%= render :partial => @albums %>
+
+
<%= link_to "All albums", albums_path %>
\ No newline at end of file
diff --git a/app/views/collections/show.html.erb b/app/views/collections/show.html.erb
index 70b9510..7cec281 100644
--- a/app/views/collections/show.html.erb
+++ b/app/views/collections/show.html.erb
@@ -2,7 +2,7 @@
<%= h @collection.description %>
<%= render :partial => @collection.albums %>
-<% if current_user && current_user.in_role?("admin") %>
+<% if has_role?("admin") %>
<%= link_to "Update collection", edit_collection_path(@collection) %>
<% end %>
<%= link_to "All collections", collections_path %>
\ No newline at end of file
diff --git a/app/views/photos/edit_multiple.html.erb b/app/views/photos/edit_multiple.html.erb
new file mode 100644
index 0000000..3ab793f
--- /dev/null
+++ b/app/views/photos/edit_multiple.html.erb
@@ -0,0 +1 @@
+<%= render :partial => @photos %>
\ No newline at end of file
diff --git a/app/views/photos/show.html.erb b/app/views/photos/show.html.erb
index 797820f..314a0b5 100644
--- a/app/views/photos/show.html.erb
+++ b/app/views/photos/show.html.erb
@@ -4,6 +4,9 @@
Tagged with: <%= @photo.tag_list %>
<%= @photo.description %>
+
+<% if has_role?("admin") %>
<%= link_to "Update photo details", edit_photo_path(@photo) %>
+<% end %>
<%= link_to "Back to #{@photo.album.title}", @photo.album %>
<%= link_to "All albums", albums_path %>
\ No newline at end of file
diff --git a/app/views/photos/untouched.html.erb b/app/views/photos/untouched.html.erb
index 3ab793f..b8c0f5c 100644
--- a/app/views/photos/untouched.html.erb
+++ b/app/views/photos/untouched.html.erb
@@ -1 +1,3 @@
-<%= render :partial => @photos %>
\ No newline at end of file
+<%= render :partial => @photos %>
+
+
<%= link_to "Back to #{@album.title}", @album %>
\ No newline at end of file
diff --git a/app/views/albums/upload.html.erb b/app/views/photos/upload.html.erb
similarity index 95%
rename from app/views/albums/upload.html.erb
rename to app/views/photos/upload.html.erb
index 18208e6..544683a 100644
--- a/app/views/albums/upload.html.erb
+++ b/app/views/photos/upload.html.erb
@@ -34,3 +34,4 @@ $(document).ready(function() {
+
<%= link_to "Back to #{@album.title}", @album %>
\ No newline at end of file
diff --git a/app/views/user_sessions/new.html.erb b/app/views/user_sessions/new.html.erb
index 55e66b6..71b0f2d 100644
--- a/app/views/user_sessions/new.html.erb
+++ b/app/views/user_sessions/new.html.erb
@@ -1,6 +1,6 @@
Login
-<% form_for @user_session, :url => user_session_path do |f| %>
+<% form_for @user_session, :url => authenticate_path do |f| %>
<%= f.error_messages %>
<%= f.label :email %>
<%= f.text_field :email %>
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb
index f4feb2a..eb934ed 100644
--- a/app/views/users/show.html.erb
+++ b/app/views/users/show.html.erb
@@ -40,4 +40,5 @@
-<%= link_to 'Edit', edit_account_path %>
\ No newline at end of file
+<%= link_to 'Edit', edit_account_path %>
+<%= link_to 'Logout', logout_path %>
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index dfabecc..9b7390c 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,19 +1,18 @@
ActionController::Routing::Routes.draw do |map|
- #map.resources :users
- map.resource :user_session
map.resource :account, :controller => "users"
- map.signup "signup", :controller => "users", :action => "new"
map.login "login", :controller => "user_sessions", :action => "new"
+ map.authenticate "authenticate", :controller => "user_sessions", :action => "create"
map.logout "logout", :controller => "user_sessions", :action => "destroy"
- map.resources :photos, :collection => { :untouched => :get }
- map.resources :albums, :collection => { :untouched => :get }, :member => { :upload => :get}, :has_many => [ :photos ]
+ map.resources :photos,
+ :collection => { :untouched => :get, :edit_multiple => :post, :update_multiple => :put, :upload => :get }
+ map.resources :albums, :collection => { :untouched => :get} do |album|
+ album.resources :photos, :collection => { :untouched => :get, :upload => :get, :edit_multiple => :get }
+ end
map.resources :collections
map.resources :tags, :has_many => [ :photos, :albums ]
- map.namespace :admin do |admin|
- admin.resources :users
- end
+ map.resources :users, :controller => "admin/users"
map.root :controller => "collections"