dust_albums 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +13 -0
- data/Gemfile.lock +36 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +59 -0
- data/app/controllers/albums_controller.rb +50 -0
- data/app/controllers/photos_controller.rb +92 -0
- data/app/controllers/view_albums_controller.rb +18 -0
- data/app/helpers/albums_helper.rb +2 -0
- data/app/helpers/photos_helper.rb +2 -0
- data/app/helpers/view_albums_helper.rb +2 -0
- data/app/models/album.rb +48 -0
- data/app/models/photo.rb +18 -0
- data/app/views/albums/_form.html.erb +22 -0
- data/app/views/albums/_search.html.erb +6 -0
- data/app/views/albums/_upload_script.html.erb +39 -0
- data/app/views/albums/edit.html.erb +5 -0
- data/app/views/albums/index.html.erb +61 -0
- data/app/views/albums/new.html.erb +6 -0
- data/app/views/albums/show.html.erb +44 -0
- data/app/views/albums/show.js.erb +0 -0
- data/app/views/photos/_form.html.erb +22 -0
- data/app/views/photos/_photo.html.erb +23 -0
- data/app/views/photos/edit.html.erb +28 -0
- data/app/views/photos/index.html.erb +80 -0
- data/app/views/photos/new.html.erb +7 -0
- data/app/views/photos/show.html.erb +26 -0
- data/app/views/photos/show.js.erb +9 -0
- data/app/views/view_albums/index.html.erb +20 -0
- data/app/views/view_albums/show.html.erb +20 -0
- data/config/routes.rb +10 -0
- data/lib/dust_albums.rb +5 -0
- data/lib/dust_albums/engine.rb +13 -0
- data/lib/dust_albums/middleware.rb +19 -0
- data/lib/dust_albums/version.rb +11 -0
- data/lib/generators/dust_album/USAGE +8 -0
- data/lib/generators/dust_album/dust_album_generator.rb +39 -0
- data/lib/generators/dust_album/templates/albums_migration.rb +18 -0
- data/lib/generators/dust_album/templates/dust_album.css +11 -0
- data/lib/generators/dust_album/templates/images/browse.png +0 -0
- data/lib/generators/dust_album/templates/images/cancel.png +0 -0
- data/lib/generators/dust_album/templates/images/upload.png +0 -0
- data/lib/generators/dust_album/templates/initializers/flash_session_cookie_middleware.rb +19 -0
- data/lib/generators/dust_album/templates/initializers/session_store_middleware.rb +5 -0
- data/lib/generators/dust_album/templates/jquery-1.4.2.js +6240 -0
- data/lib/generators/dust_album/templates/photos_migration.rb +20 -0
- data/lib/generators/dust_album/templates/uploadify.css +84 -0
- data/lib/generators/dust_album/templates/uploadify/jquery.uploadify.v2.1.0.js +258 -0
- data/lib/generators/dust_album/templates/uploadify/swfobject.js +4 -0
- data/lib/generators/dust_album/templates/uploadify/uploadify.swf +0 -0
- data/test/helper.rb +18 -0
- data/test/test_dust_albums.rb +7 -0
- metadata +173 -0
@@ -0,0 +1,61 @@
|
|
1
|
+
<% title "Albums" %>
|
2
|
+
<% heading "Albums" %>
|
3
|
+
|
4
|
+
<%= stylesheet 'dust_album', 'uploadify' %>
|
5
|
+
|
6
|
+
<div class="button_bar">
|
7
|
+
<%= render :partial => 'albums/search' %>
|
8
|
+
<%=link_to 'new page', new_album_path, :class => 'newfile tip', :title => "New Album" %>
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<div class='photolist'>
|
12
|
+
|
13
|
+
<%= will_paginate @albums %>
|
14
|
+
|
15
|
+
<table class="photos">
|
16
|
+
<tr style='color:#222;'>
|
17
|
+
<th></th>
|
18
|
+
<th>
|
19
|
+
Album Title
|
20
|
+
</th>
|
21
|
+
<th>
|
22
|
+
Created At
|
23
|
+
</th>
|
24
|
+
<th></th>
|
25
|
+
</tr>
|
26
|
+
<% @albums.each do |album| %>
|
27
|
+
<tr class='<%= cycle('odd', 'even')%>'>
|
28
|
+
|
29
|
+
<td>
|
30
|
+
<% if album.photos.empty? %>
|
31
|
+
<%= link_to "add photos to #{album.title}", album %>
|
32
|
+
<% else %>
|
33
|
+
<% @photo = album.photos.find(:first) %>
|
34
|
+
<%= link_to image_tag(@photo.file.url(:thumb)), album %>
|
35
|
+
<% end -%>
|
36
|
+
</td>
|
37
|
+
<td>
|
38
|
+
<%= album.title%>
|
39
|
+
</td>
|
40
|
+
<td>
|
41
|
+
<%= album.created_at.to_s(:m_d_y) %>
|
42
|
+
</td>
|
43
|
+
<td>
|
44
|
+
<div style='float:right'>
|
45
|
+
<%=link_to '', edit_album_path(album), :class => 'edit' %>
|
46
|
+
<%=link_to "", album, :confirm => 'Are you sure?', :method => :delete, :class => 'destroy' %>
|
47
|
+
</div>
|
48
|
+
</td>
|
49
|
+
</tr>
|
50
|
+
<% end %>
|
51
|
+
|
52
|
+
</table>
|
53
|
+
|
54
|
+
|
55
|
+
</div>
|
56
|
+
|
57
|
+
<div class="clear"></div>
|
58
|
+
|
59
|
+
<%= will_paginate @albums %>
|
60
|
+
|
61
|
+
|
@@ -0,0 +1,44 @@
|
|
1
|
+
<% title h(@album.title) %>
|
2
|
+
<% heading h(@album.title.titleize) %>
|
3
|
+
|
4
|
+
<%= stylesheet( 'dust_album','uploadify') %>
|
5
|
+
|
6
|
+
<%= render :partial => "upload_script" %>
|
7
|
+
|
8
|
+
<div class="item">
|
9
|
+
|
10
|
+
<div class='manage'>
|
11
|
+
<%= link_to "", edit_album_path(@album), :class => 'edit' %>
|
12
|
+
<%= link_to "", @album, :confirm => 'Are you sure?', :method => :delete, :class => 'destroy' %>
|
13
|
+
</div>
|
14
|
+
|
15
|
+
<%= simple_format(h(@album.desc)) %>
|
16
|
+
</div>
|
17
|
+
|
18
|
+
<div class="item">
|
19
|
+
|
20
|
+
<h3 id="photos_count"><%= pluralize(@album.photos.size, "Photo")%> <% unless @album.photos.empty? %> | <%= link_to "Manage Photos", photos_path %> <% end %></h3>
|
21
|
+
<div id="uploads">
|
22
|
+
<%= render @album.photos %>
|
23
|
+
</div>
|
24
|
+
|
25
|
+
<div class="clear"></div>
|
26
|
+
|
27
|
+
</div>
|
28
|
+
|
29
|
+
<% content_for :left do -%>
|
30
|
+
|
31
|
+
<div id="uploadify">
|
32
|
+
<h3>Add Photos to <%= @album.title.titleize %></h3>
|
33
|
+
<% form_for @new_photo, :html => {:multipart => true} do |f| %>
|
34
|
+
|
35
|
+
<%= f.hidden_field :album_id, "value" => @album.id %>
|
36
|
+
<div class="uploadifyButtons">
|
37
|
+
<%= image_submit_tag "Upload.png", :id => "photo_submit", :name => 'commit' %> <%= f.file_field :file %>
|
38
|
+
<div class='clear'></div>
|
39
|
+
</div>
|
40
|
+
<% end %>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<% end -%>
|
44
|
+
|
File without changes
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<%= stylesheet( 'dust_album','uploadify') %>
|
2
|
+
|
3
|
+
<% form_for @photo, :validations => true do |f| %>
|
4
|
+
<%= f.error_messages %>
|
5
|
+
<p>
|
6
|
+
<%= f.label :title %><br />
|
7
|
+
<%= f.text_field :title %>
|
8
|
+
</p>
|
9
|
+
<p>
|
10
|
+
<%= f.label :desc %><br />
|
11
|
+
<%= f.text_area :desc %>
|
12
|
+
</p>
|
13
|
+
<p>
|
14
|
+
<%= f.label :date_shot %><br />
|
15
|
+
<%= f.date_select :date_shot %>
|
16
|
+
</p>
|
17
|
+
<p>
|
18
|
+
<%= f.label :location %><br />
|
19
|
+
<%= f.text_field :location %>
|
20
|
+
</p>
|
21
|
+
<p><%= f.submit %></p>
|
22
|
+
<% end %>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<div class="photo">
|
2
|
+
<script type="text/javascript" charset="utf-8">
|
3
|
+
$("a.settings").fancybox({
|
4
|
+
'showCloseButton' : false,
|
5
|
+
'transitionIn' : 'elastic',
|
6
|
+
'transitionOut' : 'elastic',
|
7
|
+
'speedIn' : 400,
|
8
|
+
'speedOut' : 200,
|
9
|
+
'hideOnContentClick': false,
|
10
|
+
'overlayOpacity' : 0.6,
|
11
|
+
'overlayColor' : '#000',
|
12
|
+
'opacity' : 'true'
|
13
|
+
});
|
14
|
+
</script>
|
15
|
+
<%= image_tag photo.file.url(:thumb), :height => '50' %>
|
16
|
+
<p>
|
17
|
+
<%= photo.title %> <br />
|
18
|
+
<% unless photo.date_shot.blank? %>
|
19
|
+
(<%= photo.date_shot %>)
|
20
|
+
<% end -%>
|
21
|
+
<%= link_to "Edit Photo", edit_photo_path(photo, :format => :html, :edit => 'photo'), :class => "settings", :title => "Photo Settings" %>
|
22
|
+
</p>
|
23
|
+
</div>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<% title "Edit Photo" %>
|
2
|
+
|
3
|
+
<% if params[:edit] == 'photo' %>
|
4
|
+
<script type="text/javascript" charset="utf-8">
|
5
|
+
|
6
|
+
var options = {
|
7
|
+
success: showFlash,
|
8
|
+
data: {format: 'js'},
|
9
|
+
clearForm: true
|
10
|
+
};
|
11
|
+
|
12
|
+
$('.edit_photo').ajaxForm(options);
|
13
|
+
|
14
|
+
$("#photo_submit").click(function () {
|
15
|
+
$("#fancybox-inner").fadeTo("slow", 0.1);
|
16
|
+
$.fancybox.showActivity();
|
17
|
+
});
|
18
|
+
|
19
|
+
function showFlash() {
|
20
|
+
$("#status").html("Success, Your settings have been saved");
|
21
|
+
$('#status').fadeIn().delay(2000).slideUp('slow');
|
22
|
+
$.fancybox.close();
|
23
|
+
$("#fancybox-inner").fadeTo("slow", 1);
|
24
|
+
}
|
25
|
+
</script>
|
26
|
+
<% end -%>
|
27
|
+
|
28
|
+
<%= render :partial => 'form' %>
|
@@ -0,0 +1,80 @@
|
|
1
|
+
<% title "Photos" %>
|
2
|
+
|
3
|
+
<%= stylesheet( 'dust_album','uploadify') %>
|
4
|
+
<%= javascript( 'uploadify/jquery.uploadify.v2.1.0' ) %>
|
5
|
+
|
6
|
+
<script type="text/javascript" charset="utf-8">
|
7
|
+
$(document).ready(function() {
|
8
|
+
$(function () { // this line makes sure this code runs on page load
|
9
|
+
$('.checkall').click(function () {
|
10
|
+
$(this).parents('form:eq(0)').find(':checkbox').attr('checked', this.checked);
|
11
|
+
});
|
12
|
+
});
|
13
|
+
});
|
14
|
+
</script>
|
15
|
+
|
16
|
+
<%= will_paginate @photos %>
|
17
|
+
|
18
|
+
<% @photo_albums.sort.each do |title, photos| %>
|
19
|
+
<div class='photolist'>
|
20
|
+
<h1><%= link_to title, album_path(photos.first.album) %></h1>
|
21
|
+
|
22
|
+
<%= form_for(:photo, :url => delete_photos_path) do %>
|
23
|
+
|
24
|
+
<table class='photos'>
|
25
|
+
<tr style='color:#222;'>
|
26
|
+
<th>
|
27
|
+
|
28
|
+
</th>
|
29
|
+
<th></th>
|
30
|
+
<th>
|
31
|
+
File Name
|
32
|
+
</th>
|
33
|
+
<th>
|
34
|
+
File Size
|
35
|
+
</th>
|
36
|
+
<th>
|
37
|
+
Created At
|
38
|
+
</th>
|
39
|
+
</tr>
|
40
|
+
<% for photo in photos %>
|
41
|
+
<%= hidden_field_tag :album_id, photo.album.id %>
|
42
|
+
<tr class='<%= cycle('odd', 'even')%>'>
|
43
|
+
<td>
|
44
|
+
<%= check_box_tag "photo_ids[]", photo.id %>
|
45
|
+
</td>
|
46
|
+
<td>
|
47
|
+
<%= link_to image_tag(photo.file.url(:thumb), :height => "30"), photo.file.url(:original), :rel => title, :id => 'single_image' %>
|
48
|
+
|
49
|
+
<div style="display:none"><div id="<%=photo.id%>"><%= image_tag(photo.file.url(:original)) %></div></div>
|
50
|
+
</td>
|
51
|
+
<td>
|
52
|
+
<%= photo.file_file_name %>
|
53
|
+
</td>
|
54
|
+
<td>
|
55
|
+
<%= number_to_human_size(photo.file_file_size) %>
|
56
|
+
</td>
|
57
|
+
<td>
|
58
|
+
<%= photo.created_at.to_s(:m_d_y) %>
|
59
|
+
</td>
|
60
|
+
</tr>
|
61
|
+
<% end %>
|
62
|
+
<tr class='odd'>
|
63
|
+
<td colspan='5'>
|
64
|
+
<input type="checkbox" class="checkall"> Check all
|
65
|
+
<%= submit_tag "Delete checked" %>
|
66
|
+
</td>
|
67
|
+
</tr>
|
68
|
+
</table>
|
69
|
+
|
70
|
+
|
71
|
+
<% end -%>
|
72
|
+
|
73
|
+
</div>
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
<% end %>
|
78
|
+
|
79
|
+
<%= will_paginate @photos %>
|
80
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<% title "Photo" %>
|
2
|
+
|
3
|
+
<%= stylesheet( 'dust_album','uploadify') %>
|
4
|
+
|
5
|
+
<p>
|
6
|
+
<strong>Title:</strong>
|
7
|
+
<%=h @photo.title %>
|
8
|
+
</p>
|
9
|
+
<p>
|
10
|
+
<strong>Desc:</strong>
|
11
|
+
<%=h @photo.desc %>
|
12
|
+
</p>
|
13
|
+
<p>
|
14
|
+
<strong>Date Shot:</strong>
|
15
|
+
<%=h @photo.date_shot %>
|
16
|
+
</p>
|
17
|
+
<p>
|
18
|
+
<strong>Location:</strong>
|
19
|
+
<%=h @photo.location %>
|
20
|
+
</p>
|
21
|
+
|
22
|
+
<p>
|
23
|
+
<%= link_to "Edit", edit_photo_path(@photo) %> |
|
24
|
+
<%= link_to "Destroy", @photo, :confirm => 'Are you sure?', :method => :delete %> |
|
25
|
+
<%= link_to "View All", photos_path %>
|
26
|
+
</p>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
$('#photos_count').html('<%= pluralize(@total_uploads.count, "Photo") %> | <%= link_to "Manage Photos", photos_path %>');
|
2
|
+
$('#uploads').append("<%= escape_javascript(render(:partial => "photos/photo", :locals => {:photo => @photo})) %>");
|
3
|
+
$("a#inline").fancybox({
|
4
|
+
'transitionIn' : 'elastic',
|
5
|
+
'transitionOut' : 'elastic',
|
6
|
+
'speedIn' : 200,
|
7
|
+
'speedOut' : 200,
|
8
|
+
'hideOnContentClick': false
|
9
|
+
});
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<% title "All Albums" %>
|
2
|
+
<% heading "All Albums" %>
|
3
|
+
|
4
|
+
<% content_for :head do -%>
|
5
|
+
<%= stylesheet_link_tag 'dust_album' %>
|
6
|
+
<% end -%>
|
7
|
+
|
8
|
+
<%= will_paginate @albums %>
|
9
|
+
|
10
|
+
<% @albums.each do |album| %>
|
11
|
+
<div class="photo">
|
12
|
+
<% unless album.photos.empty? %>
|
13
|
+
<% @photo = album.photos.find(:first) %>
|
14
|
+
<%= link_to image_tag(@photo.file.url(:thumb)), view_album_path(album.filename) %>
|
15
|
+
<% end -%>
|
16
|
+
</div>
|
17
|
+
<% end -%>
|
18
|
+
<div class="clear"></div>
|
19
|
+
|
20
|
+
<%= will_paginate @albums %>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<% title @album.title %>
|
2
|
+
<% heading @album.title %>
|
3
|
+
<%= @album.desc %>
|
4
|
+
|
5
|
+
<% content_for :head do -%>
|
6
|
+
<%= stylesheet_link_tag 'dust_album' %>
|
7
|
+
<% end -%>
|
8
|
+
|
9
|
+
<%= will_paginate @photos %>
|
10
|
+
|
11
|
+
<div id="uploads">
|
12
|
+
<% @photos.each do |photo| %>
|
13
|
+
<div class="photo">
|
14
|
+
<%= link_to image_tag(photo.file.url(:thumb), :alt => photo.title), photo.file.url(:original), :id => 'single_image' %>
|
15
|
+
</div>
|
16
|
+
<% end -%>
|
17
|
+
</div>
|
18
|
+
<div class="clear"></div>
|
19
|
+
|
20
|
+
<%= will_paginate @photos %>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
|
3
|
+
resources :photos
|
4
|
+
|
5
|
+
resources :albums
|
6
|
+
|
7
|
+
match 'all/albums' => 'view_albums#index', :as => :view_albums
|
8
|
+
match 'photos-for/:filename' => 'view_albums#show', :as => :view_album
|
9
|
+
match 'photos/destroy' => 'photos#destroy', :as => :delete_photos
|
10
|
+
end
|
data/lib/dust_albums.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'dust_albums'
|
2
|
+
require "rails"
|
3
|
+
|
4
|
+
module DustAlbums
|
5
|
+
class Engine < Rails::Engine
|
6
|
+
#initializer "dust_albums_engine.add_middleware" do |app|
|
7
|
+
# app.middleware.insert_before(
|
8
|
+
# ActionDispatch::Cookies,
|
9
|
+
# "DustAlbums::Middleware",
|
10
|
+
# app.config.send(:session_options)[:key])
|
11
|
+
#end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rack/utils'
|
2
|
+
|
3
|
+
class FlashSessionCookieMiddleware
|
4
|
+
def initialize(app, session_key = '_session_id')
|
5
|
+
@app = app
|
6
|
+
@session_key = session_key
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
if env['HTTP_USER_AGENT'] =~ /^(Adobe|Shockwave) Flash/
|
11
|
+
req = Rack::Request.new(env)
|
12
|
+
env['HTTP_COOKIE'] = [ @session_key,
|
13
|
+
req.params[@session_key] ].join('=').freeze unless req.params[@session_key].nil?
|
14
|
+
env['HTTP_ACCEPT'] = "#{req.params['_http_accept']}".freeze unless req.params['_http_accept'].nil?
|
15
|
+
end
|
16
|
+
|
17
|
+
@app.call(env)
|
18
|
+
end
|
19
|
+
end
|