dust-generators 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/lib/dust/version.rb +1 -1
  2. data/lib/generators/dust/albums/USAGE +8 -0
  3. data/lib/generators/dust/albums/albums_generator.rb +58 -0
  4. data/lib/generators/dust/albums/templates/albums_migration.rb +18 -0
  5. data/lib/generators/dust/albums/templates/app/controllers/albums_controller.rb +50 -0
  6. data/lib/generators/dust/albums/templates/app/controllers/photos_controller.rb +92 -0
  7. data/lib/generators/dust/albums/templates/app/controllers/view_albums_controller.rb +18 -0
  8. data/lib/generators/dust/albums/templates/app/helpers/albums_helper.rb +2 -0
  9. data/lib/generators/dust/albums/templates/app/helpers/photos_helper.rb +2 -0
  10. data/lib/generators/dust/albums/templates/app/helpers/view_albums_helper.rb +2 -0
  11. data/lib/generators/dust/albums/templates/app/models/album.rb +48 -0
  12. data/lib/generators/dust/albums/templates/app/models/photo.rb +18 -0
  13. data/lib/generators/dust/albums/templates/app/views/albums/_form.html.erb +22 -0
  14. data/lib/generators/dust/albums/templates/app/views/albums/_search.html.erb +6 -0
  15. data/lib/generators/dust/albums/templates/app/views/albums/_upload_script.html.erb +39 -0
  16. data/lib/generators/dust/albums/templates/app/views/albums/edit.html.erb +5 -0
  17. data/lib/generators/dust/albums/templates/app/views/albums/index.html.erb +61 -0
  18. data/lib/generators/dust/albums/templates/app/views/albums/new.html.erb +6 -0
  19. data/lib/generators/dust/albums/templates/app/views/albums/show.html.erb +44 -0
  20. data/lib/generators/dust/albums/templates/app/views/albums/show.js.erb +0 -0
  21. data/lib/generators/dust/albums/templates/app/views/photos/_form.html.erb +22 -0
  22. data/lib/generators/dust/albums/templates/app/views/photos/_photo.html.erb +23 -0
  23. data/lib/generators/dust/albums/templates/app/views/photos/edit.html.erb +28 -0
  24. data/lib/generators/dust/albums/templates/app/views/photos/index.html.erb +80 -0
  25. data/lib/generators/dust/albums/templates/app/views/photos/new.html.erb +7 -0
  26. data/lib/generators/dust/albums/templates/app/views/photos/show.html.erb +26 -0
  27. data/lib/generators/dust/albums/templates/app/views/photos/show.js.erb +9 -0
  28. data/lib/generators/dust/albums/templates/app/views/view_albums/index.html.erb +20 -0
  29. data/lib/generators/dust/albums/templates/app/views/view_albums/show.html.erb +20 -0
  30. data/lib/generators/dust/albums/templates/dust_album.css +11 -0
  31. data/lib/generators/dust/albums/templates/images/browse.png +0 -0
  32. data/lib/generators/dust/albums/templates/images/cancel.png +0 -0
  33. data/lib/generators/dust/albums/templates/images/upload.png +0 -0
  34. data/lib/generators/dust/albums/templates/initializers/flash_session_cookie_middleware.rb +19 -0
  35. data/lib/generators/dust/albums/templates/initializers/session_store_middleware.rb +5 -0
  36. data/lib/generators/dust/albums/templates/jquery-1.4.2.js +6240 -0
  37. data/lib/generators/dust/albums/templates/photos_migration.rb +20 -0
  38. data/lib/generators/dust/albums/templates/uploadify/jquery.uploadify.v2.1.0.js +258 -0
  39. data/lib/generators/dust/albums/templates/uploadify/swfobject.js +4 -0
  40. data/lib/generators/dust/albums/templates/uploadify/uploadify.swf +0 -0
  41. data/lib/generators/dust/albums/templates/uploadify.css +84 -0
  42. data/lib/generators/dust/scaffold/scaffold_generator.rb +3 -2
  43. data/lib/generators/dust/scaffold/templates/controller.rb +7 -1
  44. data/lib/generators/dust/scaffold/templates/migration.rb +2 -0
  45. data/lib/generators/dust/scaffold/templates/model.rb +3 -2
  46. data/lib/generators/dust/scaffold/templates/views/erb/_form.html.erb +4 -4
  47. data/lib/generators/dust/scaffold/templates/views/erb/_search.html.erb +1 -1
  48. data/lib/generators/dust/scaffold/templates/views/erb/edit.html.erb +1 -1
  49. data/lib/generators/dust/scaffold/templates/views/erb/index.html.erb +6 -6
  50. data/lib/generators/dust/scaffold/templates/views/erb/show.html.erb +5 -4
  51. metadata +43 -3
@@ -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,7 @@
1
+ <% title "New Photo" %>
2
+
3
+ <%= stylesheet( 'dust_album','uploadify') %>
4
+
5
+ <%= render :partial => 'form' %>
6
+
7
+ <p><%= link_to "Back to List", photos_path %></p>
@@ -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 %>
@@ -0,0 +1,11 @@
1
+ #uploadify h3 { display:block; text-align:center; color:#767D87; font-weight: normal; }
2
+
3
+ tr.even td { background: #fff;}
4
+
5
+ #uploads{overflow:hidden;}
6
+ .photo { text-align:center; float:left; width:75px; margin: 5px; }
7
+
8
+ table.photos{ margin: 0 auto; width:100%; border:1px solid #C5CCD6; }
9
+ tr th { background: #D3DAE6; padding:5px; }
10
+ tr.even td { background: #D3DAE6; padding:15px;}
11
+ tr.odd td { padding:15px;}
@@ -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
@@ -0,0 +1,5 @@
1
+ Rails.application.config.middleware.insert_before(
2
+ ActionDispatch::Session::CookieStore,
3
+ FlashSessionCookieMiddleware,
4
+ Rails.application.config.session_options[:key]
5
+ )