dust-generators 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +0 -1
- data/Gemfile.lock +0 -18
- data/Rakefile +1 -1
- data/lib/dust/version.rb +1 -1
- data/rails_generators/dust_albums/USAGE +8 -0
- data/rails_generators/dust_albums/dust_albums_generator.rb +127 -0
- data/rails_generators/dust_albums/templates/README +11 -0
- data/rails_generators/dust_albums/templates/app/controllers/albums_controller.rb +56 -0
- data/rails_generators/dust_albums/templates/app/controllers/photos_controller.rb +89 -0
- data/rails_generators/dust_albums/templates/app/controllers/view_albums_controller.rb +17 -0
- data/rails_generators/dust_albums/templates/app/helpers/albums_helper.rb +2 -0
- data/rails_generators/dust_albums/templates/app/helpers/photos_helper.rb +2 -0
- data/rails_generators/dust_albums/templates/app/helpers/view_albums_helper.rb +2 -0
- data/rails_generators/dust_albums/templates/app/models/album.rb +42 -0
- data/rails_generators/dust_albums/templates/app/models/photo.rb +18 -0
- data/rails_generators/dust_albums/templates/app/views/albums/_form.html.erb +52 -0
- data/rails_generators/dust_albums/templates/app/views/albums/_search.html.erb +6 -0
- data/rails_generators/dust_albums/templates/app/views/albums/_upload_script.html.erb +37 -0
- data/rails_generators/dust_albums/templates/app/views/albums/edit.html.erb +5 -0
- data/rails_generators/dust_albums/templates/app/views/albums/index.html.erb +61 -0
- data/rails_generators/dust_albums/templates/app/views/albums/manage.html.erb +65 -0
- data/rails_generators/dust_albums/templates/app/views/albums/new.html.erb +6 -0
- data/rails_generators/dust_albums/templates/app/views/albums/show.html.erb +51 -0
- data/rails_generators/dust_albums/templates/app/views/albums/show.js.erb +1 -0
- data/rails_generators/dust_albums/templates/app/views/photos/_form.html.erb +23 -0
- data/rails_generators/dust_albums/templates/app/views/photos/_photo.html.erb +25 -0
- data/rails_generators/dust_albums/templates/app/views/photos/_search.html.erb +6 -0
- data/rails_generators/dust_albums/templates/app/views/photos/array.js.erb +3 -0
- data/rails_generators/dust_albums/templates/app/views/photos/edit.html.erb +28 -0
- data/rails_generators/dust_albums/templates/app/views/photos/index.html.erb +85 -0
- data/rails_generators/dust_albums/templates/app/views/photos/new.html.erb +7 -0
- data/rails_generators/dust_albums/templates/app/views/photos/show.html.erb +26 -0
- data/rails_generators/dust_albums/templates/app/views/photos/show.js.erb +9 -0
- data/rails_generators/dust_albums/templates/app/views/view_albums/index.html.erb +27 -0
- data/rails_generators/dust_albums/templates/app/views/view_albums/show.html.erb +31 -0
- data/rails_generators/dust_albums/templates/images/browse.png +0 -0
- data/rails_generators/dust_albums/templates/images/cancel.png +0 -0
- data/rails_generators/dust_albums/templates/images/save_position.png +0 -0
- data/rails_generators/dust_albums/templates/images/upload.png +0 -0
- data/rails_generators/dust_albums/templates/initializers/flash_session_cookie_middleware.rb +17 -0
- data/rails_generators/dust_albums/templates/initializers/session_store_middleware.rb +1 -0
- data/rails_generators/dust_albums/templates/javascript/dragsort.js +288 -0
- data/rails_generators/dust_albums/templates/javascript/dust_album.js +19 -0
- data/rails_generators/dust_albums/templates/javascript/uploadify/jquery.uploadify.v2.1.0.js +258 -0
- data/rails_generators/dust_albums/templates/javascript/uploadify/swfobject.js +4 -0
- data/rails_generators/dust_albums/templates/javascript/uploadify/uploadify.swf +0 -0
- data/rails_generators/dust_albums/templates/migration/albums_migration.rb +38 -0
- data/rails_generators/dust_albums/templates/stylesheets/dust_album.css +16 -0
- data/rails_generators/dust_albums/templates/stylesheets/dust_album_app.css +15 -0
- data/rails_generators/dust_albums/templates/stylesheets/uploadify.css +84 -0
- data/rails_generators/dust_config/USAGE +23 -0
- data/rails_generators/dust_config/dust_config_generator.rb +32 -0
- data/rails_generators/dust_config/templates/config.yml +8 -0
- data/rails_generators/dust_config/templates/load_config.rb +2 -0
- data/rails_generators/dust_scaffold/USAGE +51 -0
- data/rails_generators/dust_scaffold/dust_scaffold_generator.rb +232 -0
- data/rails_generators/dust_scaffold/templates/actions/create.rb +9 -0
- data/rails_generators/dust_scaffold/templates/actions/destroy.rb +6 -0
- data/rails_generators/dust_scaffold/templates/actions/edit.rb +3 -0
- data/rails_generators/dust_scaffold/templates/actions/index.rb +3 -0
- data/rails_generators/dust_scaffold/templates/actions/new.rb +3 -0
- data/rails_generators/dust_scaffold/templates/actions/show.rb +3 -0
- data/rails_generators/dust_scaffold/templates/actions/update.rb +9 -0
- data/rails_generators/dust_scaffold/templates/controller.rb +3 -0
- data/rails_generators/dust_scaffold/templates/fixtures.yml +9 -0
- data/rails_generators/dust_scaffold/templates/helper.rb +2 -0
- data/rails_generators/dust_scaffold/templates/migration.rb +16 -0
- data/rails_generators/dust_scaffold/templates/model.rb +3 -0
- data/rails_generators/dust_scaffold/templates/tests/rspec/actions/create.rb +11 -0
- data/rails_generators/dust_scaffold/templates/tests/rspec/actions/destroy.rb +6 -0
- data/rails_generators/dust_scaffold/templates/tests/rspec/actions/edit.rb +4 -0
- data/rails_generators/dust_scaffold/templates/tests/rspec/actions/index.rb +4 -0
- data/rails_generators/dust_scaffold/templates/tests/rspec/actions/new.rb +4 -0
- data/rails_generators/dust_scaffold/templates/tests/rspec/actions/show.rb +4 -0
- data/rails_generators/dust_scaffold/templates/tests/rspec/actions/update.rb +11 -0
- data/rails_generators/dust_scaffold/templates/tests/rspec/controller.rb +8 -0
- data/rails_generators/dust_scaffold/templates/tests/rspec/model.rb +7 -0
- data/rails_generators/dust_scaffold/templates/tests/shoulda/actions/create.rb +13 -0
- data/rails_generators/dust_scaffold/templates/tests/shoulda/actions/destroy.rb +8 -0
- data/rails_generators/dust_scaffold/templates/tests/shoulda/actions/edit.rb +6 -0
- data/rails_generators/dust_scaffold/templates/tests/shoulda/actions/index.rb +6 -0
- data/rails_generators/dust_scaffold/templates/tests/shoulda/actions/new.rb +6 -0
- data/rails_generators/dust_scaffold/templates/tests/shoulda/actions/show.rb +6 -0
- data/rails_generators/dust_scaffold/templates/tests/shoulda/actions/update.rb +13 -0
- data/rails_generators/dust_scaffold/templates/tests/shoulda/controller.rb +5 -0
- data/rails_generators/dust_scaffold/templates/tests/shoulda/model.rb +7 -0
- data/rails_generators/dust_scaffold/templates/tests/testunit/actions/create.rb +11 -0
- data/rails_generators/dust_scaffold/templates/tests/testunit/actions/destroy.rb +6 -0
- data/rails_generators/dust_scaffold/templates/tests/testunit/actions/edit.rb +4 -0
- data/rails_generators/dust_scaffold/templates/tests/testunit/actions/index.rb +4 -0
- data/rails_generators/dust_scaffold/templates/tests/testunit/actions/new.rb +4 -0
- data/rails_generators/dust_scaffold/templates/tests/testunit/actions/show.rb +4 -0
- data/rails_generators/dust_scaffold/templates/tests/testunit/actions/update.rb +11 -0
- data/rails_generators/dust_scaffold/templates/tests/testunit/controller.rb +5 -0
- data/rails_generators/dust_scaffold/templates/tests/testunit/model.rb +7 -0
- data/rails_generators/dust_scaffold/templates/views/erb/_form.html.erb +10 -0
- data/rails_generators/dust_scaffold/templates/views/erb/edit.html.erb +14 -0
- data/rails_generators/dust_scaffold/templates/views/erb/index.html.erb +29 -0
- data/rails_generators/dust_scaffold/templates/views/erb/new.html.erb +7 -0
- data/rails_generators/dust_scaffold/templates/views/erb/show.html.erb +20 -0
- data/rails_generators/dust_scaffold/templates/views/haml/_form.html.haml +10 -0
- data/rails_generators/dust_scaffold/templates/views/haml/edit.html.haml +14 -0
- data/rails_generators/dust_scaffold/templates/views/haml/index.html.haml +25 -0
- data/rails_generators/dust_scaffold/templates/views/haml/new.html.haml +7 -0
- data/rails_generators/dust_scaffold/templates/views/haml/show.html.haml +20 -0
- metadata +127 -33
@@ -0,0 +1,51 @@
|
|
1
|
+
<% title h(@album.title) %>
|
2
|
+
|
3
|
+
<%= stylesheet( 'dust_album','uploadify') %>
|
4
|
+
|
5
|
+
|
6
|
+
<% content_for :javascipts do %>
|
7
|
+
<%= javascript_include_tag 'dragsort', 'dust_album' %>
|
8
|
+
<% end -%>
|
9
|
+
|
10
|
+
<%= render :partial => "upload_script" %>
|
11
|
+
|
12
|
+
<div class="item">
|
13
|
+
|
14
|
+
<div class='manage'>
|
15
|
+
<%= link_to "", edit_album_path(@album), :class => 'edit' %>
|
16
|
+
<%= link_to "", @album, :confirm => 'Are you sure?', :method => :delete, :class => 'destroy' %>
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<h1>
|
20
|
+
<%= link_to @album.title, view_album_path(@album.filename) %>
|
21
|
+
</h1>
|
22
|
+
<%= simple_format(h(@album.desc)) %>
|
23
|
+
|
24
|
+
</div>
|
25
|
+
|
26
|
+
<div class="item">
|
27
|
+
|
28
|
+
<h3 id="photos_count"><%= pluralize(@album.photos.size, "Photo")%> <% unless @album.photos.empty? %> | <%= link_to "Select Photos For Deletion", manage_photos_path(@album), :class => 'settings' %> | <%= link_to 're-Order Photos', photos_path, :id => 'order_photos' %> <% end %></h3>
|
29
|
+
<ul id="uploads">
|
30
|
+
<%= render :partial => @album.photos.roots, :photo => @photo %>
|
31
|
+
</ul>
|
32
|
+
|
33
|
+
<div class="clear"></div>
|
34
|
+
</div>
|
35
|
+
|
36
|
+
<% content_for :left do -%>
|
37
|
+
|
38
|
+
<div id="uploadify">
|
39
|
+
<h3>Add Photos to <%= @album.title.titleize %></h3>
|
40
|
+
<% form_for @new_photo, :html => {:multipart => true} do |f| %>
|
41
|
+
|
42
|
+
<%= f.hidden_field :album_id, "value" => @album.id %>
|
43
|
+
<div class="uploadifyButtons">
|
44
|
+
<%= image_submit_tag "Upload.png", :id => "photo_submit", :name => 'commit' %> <%= f.file_field :file %>
|
45
|
+
<div class='clear'></div>
|
46
|
+
</div>
|
47
|
+
<% end %>
|
48
|
+
</div>
|
49
|
+
|
50
|
+
<% end -%>
|
51
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
$('#uploads').html("<%= escape_javascript(render(@album.photos.roots, :photo => @photo)) %>");
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<%= stylesheet( 'dust_album','uploadify') %>
|
2
|
+
|
3
|
+
<% form_for @photo, :validations => true do |f| %>
|
4
|
+
<%= f.error_messages %>
|
5
|
+
<div class="item">
|
6
|
+
<p>
|
7
|
+
<%= f.label :title %><br />
|
8
|
+
<%= f.text_field :title, :class => 'field' %>
|
9
|
+
</p>
|
10
|
+
</div>
|
11
|
+
|
12
|
+
<div class="item">
|
13
|
+
<p>
|
14
|
+
<%= f.label :desc %><br />
|
15
|
+
<%= f.text_area :desc, :class => 'field' %>
|
16
|
+
</p>
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<div class="item">
|
20
|
+
<p><%= f.submit %></p>
|
21
|
+
</div>
|
22
|
+
|
23
|
+
<% end %>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<li id="<%= "photo_#{photo.id}" %>">
|
2
|
+
<div class="photo <%= "photo_#{photo.id}" %>">
|
3
|
+
<script type="text/javascript" charset="utf-8">
|
4
|
+
$("a.settings").fancybox({
|
5
|
+
'showCloseButton' : false,
|
6
|
+
'transitionIn' : 'elastic',
|
7
|
+
'transitionOut' : 'elastic',
|
8
|
+
'speedIn' : 400,
|
9
|
+
'speedOut' : 200,
|
10
|
+
'hideOnContentClick': false,
|
11
|
+
'overlayOpacity' : 0.6,
|
12
|
+
'overlayColor' : '#000',
|
13
|
+
'opacity' : 'true'
|
14
|
+
});
|
15
|
+
</script>
|
16
|
+
<%= image_tag photo.file.url(:thumb), :height => '50' %>
|
17
|
+
<p>
|
18
|
+
<%= truncate photo.title, :length => 23 %> <br />
|
19
|
+
<% unless photo.date_shot.blank? %>
|
20
|
+
(<%= photo.date_shot %>)
|
21
|
+
<% end -%>
|
22
|
+
<%= link_to "Edit Photo", edit_photo_path(photo.id)+'?edit=photo', :class => "settings", :title => "Photo Settings" %>
|
23
|
+
</p>
|
24
|
+
</div>
|
25
|
+
</li>
|
@@ -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,85 @@
|
|
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
|
+
<div class="button_bar">
|
17
|
+
<%= render :partial => 'search' %>
|
18
|
+
</div>
|
19
|
+
|
20
|
+
|
21
|
+
<%= will_paginate @photos %>
|
22
|
+
|
23
|
+
<% @photo_albums.sort.each do |title, photos| %>
|
24
|
+
<div class='photolist'>
|
25
|
+
<h1><%= link_to title, album_path(photos.first.album) %></h1>
|
26
|
+
|
27
|
+
<% form_for :photo, :url => {:action => 'destroy'} do %>
|
28
|
+
|
29
|
+
<table class='photos'>
|
30
|
+
<tr style='color:#222;'>
|
31
|
+
<th>
|
32
|
+
|
33
|
+
</th>
|
34
|
+
<th></th>
|
35
|
+
<th>
|
36
|
+
File Name
|
37
|
+
</th>
|
38
|
+
<th>
|
39
|
+
File Size
|
40
|
+
</th>
|
41
|
+
<th>
|
42
|
+
Created At
|
43
|
+
</th>
|
44
|
+
</tr>
|
45
|
+
<% for photo in photos %>
|
46
|
+
<%= hidden_field_tag :album_id, photo.album.id %>
|
47
|
+
<tr class='<%= cycle('odd', 'even')%>'>
|
48
|
+
<td>
|
49
|
+
<%= check_box_tag "photo_ids[]", photo.id %>
|
50
|
+
</td>
|
51
|
+
<td>
|
52
|
+
<%= link_to image_tag(photo.file.url(:thumb), :height => "30"), photo.file.url(:original), :rel => title, :id => 'single_image' %>
|
53
|
+
|
54
|
+
<div style="display:none"><div id="<%=photo.id%>"><%= image_tag(photo.file.url(:original)) %></div></div>
|
55
|
+
</td>
|
56
|
+
<td>
|
57
|
+
<%= photo.file_file_name %>
|
58
|
+
</td>
|
59
|
+
<td>
|
60
|
+
<%= number_to_human_size(photo.file_file_size) %>
|
61
|
+
</td>
|
62
|
+
<td>
|
63
|
+
<%= photo.created_at.to_s(:m_d_y) %>
|
64
|
+
</td>
|
65
|
+
</tr>
|
66
|
+
<% end %>
|
67
|
+
<tr class='odd'>
|
68
|
+
<td colspan='5'>
|
69
|
+
<input type="checkbox" class="checkall"> Check all
|
70
|
+
<%= submit_tag "Delete checked" %>
|
71
|
+
</td>
|
72
|
+
</tr>
|
73
|
+
</table>
|
74
|
+
|
75
|
+
|
76
|
+
<% end -%>
|
77
|
+
|
78
|
+
</div>
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
<% end %>
|
83
|
+
|
84
|
+
<%= will_paginate @photos %>
|
85
|
+
|
@@ -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(@album.photos.size, "Photo")%> | <%= link_to "Select Photos For Deletion", manage_photos_path(@album), :class => 'settings' %> | <%= link_to 're-Order Photos', photos_path, :id => 'order_photos' %> ');
|
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,27 @@
|
|
1
|
+
<% title "All Albums" %>
|
2
|
+
<% heading "Dresen Landscaping Project Gallery" %>
|
3
|
+
|
4
|
+
<%= will_paginate @albums %>
|
5
|
+
|
6
|
+
<% @albums.each do |album| %>
|
7
|
+
<div class="album_thumb">
|
8
|
+
<% unless album.photos.empty? %>
|
9
|
+
|
10
|
+
<% @photo = album.photos.find(:first) %>
|
11
|
+
|
12
|
+
<% link_to view_album_path(album.filename), :style => 'float:left; ' do %>
|
13
|
+
<%= image_tag @photo.file.url(:thumb), :alt => album.heading %>
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
<p>
|
17
|
+
<%= link_to album.title, view_album_path(album.filename) %><br />
|
18
|
+
<%= truncate(album.desc, :length => 100) %>
|
19
|
+
<%= link_to "Read More", view_album_path(album.filename) unless album.desc.blank? %>
|
20
|
+
</p>
|
21
|
+
|
22
|
+
<% end -%>
|
23
|
+
</div>
|
24
|
+
<% end -%>
|
25
|
+
<div class="clear"></div>
|
26
|
+
|
27
|
+
<%= will_paginate @albums %>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<% title @album.title %>
|
2
|
+
<% heading @album.heading %>
|
3
|
+
|
4
|
+
<% content_for :head do %>
|
5
|
+
<%= stylesheet_link_tag 'dust_album_app' %>
|
6
|
+
<% end -%>
|
7
|
+
|
8
|
+
<%= @album.desc %>
|
9
|
+
|
10
|
+
<%= will_paginate @photos %>
|
11
|
+
|
12
|
+
<div id="uploads">
|
13
|
+
<% @photos.each do |photo| %>
|
14
|
+
<div class="photo">
|
15
|
+
<%= link_to image_tag(photo.file.url(:thumb), :alt => photo.desc), photo.file.url(:large), :class => 'group', :rel => "#{@album.title}" %><br />
|
16
|
+
<%= truncate photo.title, :length => 23 %>
|
17
|
+
</div>
|
18
|
+
<% end -%>
|
19
|
+
</div>
|
20
|
+
<div class="clear"></div>
|
21
|
+
|
22
|
+
<%= will_paginate @photos %>
|
23
|
+
|
24
|
+
<% if permitted_to? :manage, :albums %>
|
25
|
+
<p>
|
26
|
+
<%= link_to "Manage Photos", @album %> |
|
27
|
+
<%= link_to "Edit", edit_album_path(@album) %> |
|
28
|
+
<%= link_to "Destroy", @album, :confirm => 'Are you sure?', :method => :delete %> |
|
29
|
+
<%= link_to "View All", albums_path %>
|
30
|
+
</p>
|
31
|
+
<% end %>
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,17 @@
|
|
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}=#{req.params[@session_key]}".freeze unless req.params[@session_key].nil?
|
13
|
+
end
|
14
|
+
|
15
|
+
@app.call(env)
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
ActionController::Dispatcher.middleware.insert_before(ActionController::Session::CookieStore, FlashSessionCookieMiddleware, ActionController::Base.session_options[:key])
|
@@ -0,0 +1,288 @@
|
|
1
|
+
// jQuery List DragSort v0.4
|
2
|
+
// Website: http://dragsort.codeplex.com/
|
3
|
+
// License: http://dragsort.codeplex.com/license
|
4
|
+
|
5
|
+
(function($) {
|
6
|
+
|
7
|
+
$.fn.dragsort = function(options) {
|
8
|
+
var opts = $.extend({}, $.fn.dragsort.defaults, options);
|
9
|
+
var lists = [];
|
10
|
+
var list = null, lastPos = null;
|
11
|
+
if (this.selector)
|
12
|
+
$("head").append("<style type='text/css'>" + (this.selector.split(",").join(" " + opts.dragSelector + ",") + " " + opts.dragSelector) + " { cursor: pointer; }</style>");
|
13
|
+
|
14
|
+
this.each(function(i, cont) {
|
15
|
+
|
16
|
+
if ($(cont).is("table") && $(cont).children().size() == 1 && $(cont).children().is("tbody"))
|
17
|
+
cont = $(cont).children().get(0);
|
18
|
+
|
19
|
+
var newList = {
|
20
|
+
draggedItem: null,
|
21
|
+
placeHolderItem: null,
|
22
|
+
pos: null,
|
23
|
+
offset: null,
|
24
|
+
offsetLimit: null,
|
25
|
+
scroll: null,
|
26
|
+
container: cont,
|
27
|
+
|
28
|
+
init: function() {
|
29
|
+
$(this.container).attr("data-listIdx", i).mousedown(this.grabItem).find(opts.dragSelector).css("cursor", "pointer");
|
30
|
+
$(this.container).children(opts.itemSelector).each(function(j) { $(this).attr("data-itemIdx", j); });
|
31
|
+
},
|
32
|
+
|
33
|
+
grabItem: function(e) {
|
34
|
+
if (e.which != 1 || $(e.target).is(opts.dragSelectorExclude))
|
35
|
+
return;
|
36
|
+
|
37
|
+
var elm = e.target;
|
38
|
+
while (!$(elm).is("[data-listIdx='" + $(this).attr("data-listIdx") + "'] " + opts.dragSelector)) {
|
39
|
+
if (elm == this) return;
|
40
|
+
elm = elm.parentNode;
|
41
|
+
}
|
42
|
+
|
43
|
+
if (list != null && list.draggedItem != null)
|
44
|
+
list.dropItem();
|
45
|
+
|
46
|
+
$(e.target).css("cursor", "move");
|
47
|
+
|
48
|
+
list = lists[$(this).attr("data-listIdx")];
|
49
|
+
list.draggedItem = $(elm).closest(opts.itemSelector);
|
50
|
+
var mt = parseInt(list.draggedItem.css("marginTop"));
|
51
|
+
var ml = parseInt(list.draggedItem.css("marginLeft"));
|
52
|
+
list.offset = list.draggedItem.offset();
|
53
|
+
list.offset.top = e.pageY - list.offset.top + (isNaN(mt) ? 0 : mt) - 1;
|
54
|
+
list.offset.left = e.pageX - list.offset.left + (isNaN(ml) ? 0 : ml) - 1;
|
55
|
+
|
56
|
+
if (!opts.dragBetween) {
|
57
|
+
var containerHeight = $(list.container).outerHeight() == 0 ? Math.max(1, Math.round(0.5 + $(list.container).children(opts.itemSelector).size() * list.draggedItem.outerWidth() / $(list.container).outerWidth())) * list.draggedItem.outerHeight() : $(list.container).outerHeight();
|
58
|
+
list.offsetLimit = $(list.container).offset();
|
59
|
+
list.offsetLimit.right = list.offsetLimit.left + $(list.container).outerWidth() - list.draggedItem.outerWidth();
|
60
|
+
list.offsetLimit.bottom = list.offsetLimit.top + containerHeight - list.draggedItem.outerHeight();
|
61
|
+
}
|
62
|
+
|
63
|
+
var h = list.draggedItem.height();
|
64
|
+
var w = list.draggedItem.width();
|
65
|
+
var orig = list.draggedItem.attr("style");
|
66
|
+
list.draggedItem.attr("data-origStyle", orig ? orig : "");
|
67
|
+
if (opts.itemSelector == "tr") {
|
68
|
+
list.draggedItem.children().each(function() { $(this).width($(this).width()); });
|
69
|
+
list.placeHolderItem = list.draggedItem.clone().attr("data-placeHolder", true);
|
70
|
+
list.draggedItem.after(list.placeHolderItem);
|
71
|
+
list.placeHolderItem.children().each(function() { $(this).css({ borderWidth:0, width: $(this).width() + 1, height: $(this).height() + 1 }).html(" "); });
|
72
|
+
} else {
|
73
|
+
list.draggedItem.after(opts.placeHolderTemplate);
|
74
|
+
list.placeHolderItem = list.draggedItem.next().css({ height: h, width: w }).attr("data-placeHolder", true);
|
75
|
+
}
|
76
|
+
list.draggedItem.css({ position: "absolute", opacity: 0.8, "z-index": 999, height: h, width: w });
|
77
|
+
|
78
|
+
$(lists).each(function(i, l) { l.createDropTargets(); l.buildPositionTable(); });
|
79
|
+
|
80
|
+
list.scroll = { moveX: 0, moveY: 0, maxX: $(document).width() - $(window).width(), maxY: $(document).height() - $(window).height() };
|
81
|
+
list.scroll.scrollY = window.setInterval(function() {
|
82
|
+
if (opts.scrollContainer != window) {
|
83
|
+
$(opts.scrollContainer).scrollTop($(opts.scrollContainer).scrollTop() + list.scroll.moveY);
|
84
|
+
return;
|
85
|
+
}
|
86
|
+
var t = $(opts.scrollContainer).scrollTop();
|
87
|
+
if (list.scroll.moveY > 0 && t < list.scroll.maxY || list.scroll.moveY < 0 && t > 0) {
|
88
|
+
$(opts.scrollContainer).scrollTop(t + list.scroll.moveY);
|
89
|
+
list.draggedItem.css("top", list.draggedItem.offset().top + list.scroll.moveY + 1);
|
90
|
+
}
|
91
|
+
}, 10);
|
92
|
+
list.scroll.scrollX = window.setInterval(function() {
|
93
|
+
if (opts.scrollContainer != window) {
|
94
|
+
$(opts.scrollContainer).scrollLeft($(opts.scrollContainer).scrollLeft() + list.scroll.moveX);
|
95
|
+
return;
|
96
|
+
}
|
97
|
+
var l = $(opts.scrollContainer).scrollLeft();
|
98
|
+
if (list.scroll.moveX > 0 && l < list.scroll.maxX || list.scroll.moveX < 0 && l > 0) {
|
99
|
+
$(opts.scrollContainer).scrollLeft(l + list.scroll.moveX);
|
100
|
+
list.draggedItem.css("left", list.draggedItem.offset().left + list.scroll.moveX + 1);
|
101
|
+
}
|
102
|
+
}, 10);
|
103
|
+
|
104
|
+
list.setPos(e.pageX, e.pageY);
|
105
|
+
$(document).bind("selectstart", list.stopBubble); //stop ie text selection
|
106
|
+
$(document).bind("mousemove", list.swapItems);
|
107
|
+
$(document).bind("mouseup", list.dropItem);
|
108
|
+
if (opts.scrollContainer != window)
|
109
|
+
$(window).bind("DOMMouseScroll mousewheel", list.wheel);
|
110
|
+
return false; //stop moz text selection
|
111
|
+
},
|
112
|
+
|
113
|
+
setPos: function(x, y) {
|
114
|
+
var top = y - this.offset.top;
|
115
|
+
var left = x - this.offset.left;
|
116
|
+
|
117
|
+
if (!opts.dragBetween) {
|
118
|
+
top = Math.min(this.offsetLimit.bottom, Math.max(top, this.offsetLimit.top));
|
119
|
+
left = Math.min(this.offsetLimit.right, Math.max(left, this.offsetLimit.left));
|
120
|
+
}
|
121
|
+
|
122
|
+
this.draggedItem.parents().each(function() {
|
123
|
+
if ($(this).css("position") != "static" && (!$.browser.mozilla || $(this).css("display") != "table")) {
|
124
|
+
var offset = $(this).offset();
|
125
|
+
top -= offset.top;
|
126
|
+
left -= offset.left;
|
127
|
+
return false;
|
128
|
+
}
|
129
|
+
});
|
130
|
+
|
131
|
+
if (opts.scrollContainer == window) {
|
132
|
+
y -= $(window).scrollTop();
|
133
|
+
x -= $(window).scrollLeft();
|
134
|
+
y = Math.max(0, y - $(window).height() + 5) + Math.min(0, y - 5);
|
135
|
+
x = Math.max(0, x - $(window).width() + 5) + Math.min(0, x - 5);
|
136
|
+
} else {
|
137
|
+
var cont = $(opts.scrollContainer);
|
138
|
+
var offset = cont.offset();
|
139
|
+
y = Math.max(0, y - cont.height() - offset.top) + Math.min(0, y - offset.top);
|
140
|
+
x = Math.max(0, x - cont.width() - offset.left) + Math.min(0, x - offset.left);
|
141
|
+
}
|
142
|
+
|
143
|
+
list.scroll.moveX = x == 0 ? 0 : x * opts.scrollSpeed / Math.abs(x);
|
144
|
+
list.scroll.moveY = y == 0 ? 0 : y * opts.scrollSpeed / Math.abs(y);
|
145
|
+
|
146
|
+
this.draggedItem.css({ top: top, left: left });
|
147
|
+
},
|
148
|
+
|
149
|
+
wheel: function(e) {
|
150
|
+
if (($.browser.safari || $.browser.mozilla) && list && opts.scrollContainer != window) {
|
151
|
+
var cont = $(opts.scrollContainer);
|
152
|
+
var offset = cont.offset();
|
153
|
+
if (e.pageX > offset.left && e.pageX < offset.left + cont.width() && e.pageY > offset.top && e.pageY < offset.top + cont.height()) {
|
154
|
+
var delta = e.detail ? e.detail * 5 : e.wheelDelta / -2;
|
155
|
+
cont.scrollTop(cont.scrollTop() + delta);
|
156
|
+
e.preventDefault();
|
157
|
+
}
|
158
|
+
}
|
159
|
+
},
|
160
|
+
|
161
|
+
buildPositionTable: function() {
|
162
|
+
var item = this.draggedItem == null ? null : this.draggedItem.get(0);
|
163
|
+
var pos = [];
|
164
|
+
$(this.container).children(opts.itemSelector).each(function(i, elm) {
|
165
|
+
if (elm != item) {
|
166
|
+
var loc = $(elm).offset();
|
167
|
+
loc.right = loc.left + $(elm).width();
|
168
|
+
loc.bottom = loc.top + $(elm).height();
|
169
|
+
loc.elm = elm;
|
170
|
+
pos.push(loc);
|
171
|
+
}
|
172
|
+
});
|
173
|
+
this.pos = pos;
|
174
|
+
},
|
175
|
+
|
176
|
+
dropItem: function() {
|
177
|
+
if (list.draggedItem == null)
|
178
|
+
return;
|
179
|
+
|
180
|
+
$(list.container).find(opts.dragSelector).css("cursor", "pointer");
|
181
|
+
list.placeHolderItem.before(list.draggedItem);
|
182
|
+
|
183
|
+
var orig = list.draggedItem.attr("data-origStyle");
|
184
|
+
if (orig == "")
|
185
|
+
list.draggedItem.removeAttr("style");
|
186
|
+
else
|
187
|
+
list.draggedItem.attr("style", orig);
|
188
|
+
list.draggedItem.removeAttr("data-origStyle");
|
189
|
+
list.placeHolderItem.remove();
|
190
|
+
|
191
|
+
$("[data-dropTarget]").remove();
|
192
|
+
|
193
|
+
window.clearInterval(list.scroll.scrollY);
|
194
|
+
window.clearInterval(list.scroll.scrollX);
|
195
|
+
|
196
|
+
var changed = false;
|
197
|
+
$(lists).each(function() {
|
198
|
+
$(this.container).children(opts.itemSelector).each(function(j) {
|
199
|
+
if (parseInt($(this).attr("data-itemIdx")) != j) {
|
200
|
+
changed = true;
|
201
|
+
$(this).attr("data-itemIdx", j);
|
202
|
+
}
|
203
|
+
});
|
204
|
+
});
|
205
|
+
if (changed)
|
206
|
+
opts.dragEnd.apply(list.draggedItem);
|
207
|
+
list.draggedItem = null;
|
208
|
+
$(document).unbind("selectstart", list.stopBubble);
|
209
|
+
$(document).unbind("mousemove", list.swapItems);
|
210
|
+
$(document).unbind("mouseup", list.dropItem);
|
211
|
+
if (opts.scrollContainer != window)
|
212
|
+
$(window).unbind("DOMMouseScroll mousewheel", list.wheel);
|
213
|
+
return false;
|
214
|
+
},
|
215
|
+
|
216
|
+
stopBubble: function() { return false; },
|
217
|
+
|
218
|
+
swapItems: function(e) {
|
219
|
+
if (list.draggedItem == null)
|
220
|
+
return false;
|
221
|
+
|
222
|
+
list.setPos(e.pageX, e.pageY);
|
223
|
+
|
224
|
+
var ei = list.findPos(e.pageX, e.pageY);
|
225
|
+
var nlist = list;
|
226
|
+
for (var i = 0; ei == -1 && opts.dragBetween && i < lists.length; i++) {
|
227
|
+
ei = lists[i].findPos(e.pageX, e.pageY);
|
228
|
+
nlist = lists[i];
|
229
|
+
}
|
230
|
+
|
231
|
+
if (ei == -1 || $(nlist.pos[ei].elm).attr("data-placeHolder"))
|
232
|
+
return false;
|
233
|
+
|
234
|
+
if (lastPos == null || lastPos.top > list.draggedItem.offset().top || lastPos.left > list.draggedItem.offset().left)
|
235
|
+
$(nlist.pos[ei].elm).before(list.placeHolderItem);
|
236
|
+
else
|
237
|
+
$(nlist.pos[ei].elm).after(list.placeHolderItem);
|
238
|
+
|
239
|
+
$(lists).each(function(i, l) { l.createDropTargets(); l.buildPositionTable(); });
|
240
|
+
lastPos = list.draggedItem.offset();
|
241
|
+
return false;
|
242
|
+
},
|
243
|
+
|
244
|
+
findPos: function(x, y) {
|
245
|
+
for (var i = 0; i < this.pos.length; i++) {
|
246
|
+
if (this.pos[i].left < x && this.pos[i].right > x && this.pos[i].top < y && this.pos[i].bottom > y)
|
247
|
+
return i;
|
248
|
+
}
|
249
|
+
return -1;
|
250
|
+
},
|
251
|
+
|
252
|
+
createDropTargets: function() {
|
253
|
+
if (!opts.dragBetween)
|
254
|
+
return;
|
255
|
+
|
256
|
+
$(lists).each(function() {
|
257
|
+
var ph = $(this.container).find("[data-placeHolder]");
|
258
|
+
var dt = $(this.container).find("[data-dropTarget]");
|
259
|
+
if (ph.size() > 0 && dt.size() > 0)
|
260
|
+
dt.remove();
|
261
|
+
else if (ph.size() == 0 && dt.size() == 0) {
|
262
|
+
//list.placeHolderItem.clone().removeAttr("data-placeHolder") crashes in IE7 and jquery 1.5.1 (doesn't in jquery 1.4.2 or IE8)
|
263
|
+
$(this.container).append(list.placeHolderItem.removeAttr("data-placeHolder").clone().attr("data-dropTarget", true));
|
264
|
+
list.placeHolderItem.attr("data-placeHolder", true);
|
265
|
+
}
|
266
|
+
});
|
267
|
+
}
|
268
|
+
};
|
269
|
+
|
270
|
+
newList.init();
|
271
|
+
lists.push(newList);
|
272
|
+
});
|
273
|
+
|
274
|
+
return this;
|
275
|
+
};
|
276
|
+
|
277
|
+
$.fn.dragsort.defaults = {
|
278
|
+
itemSelector: "li",
|
279
|
+
dragSelector: "li",
|
280
|
+
dragSelectorExclude: "input, textarea, a[href]",
|
281
|
+
dragEnd: function() { },
|
282
|
+
dragBetween: false,
|
283
|
+
placeHolderTemplate: "<li> </li>",
|
284
|
+
scrollContainer: window,
|
285
|
+
scrollSpeed: 5
|
286
|
+
};
|
287
|
+
|
288
|
+
})(jQuery);
|