wheels 0.0.25 → 0.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.25
1
+ 0.0.26
@@ -0,0 +1,16 @@
1
+ class AttachmentsController < InheritedResources::Base
2
+ respond_to :html, :js
3
+ belongs_to :page
4
+ before_filter :authenticate_user!
5
+ ajax_loading
6
+
7
+ def index
8
+ index! do |format|
9
+ @attachment = @page.attachments.build
10
+ end
11
+ end
12
+ def create
13
+ create! {collection_url}
14
+ end
15
+ end
16
+
@@ -11,18 +11,16 @@ class PagesController < InheritedResources::Base
11
11
  end
12
12
  end
13
13
 
14
-
15
- before_filter :authenticate_user!, :except=>[:index, :show]
16
- before_filter :maybe_authenticate, :only=>[:index, :show]
14
+ before_filter :authenticate_user!, :except=>[:show]
15
+ before_filter :maybe_authenticate, :only=>[:show]
17
16
  before_filter :resource, :only=>[:update, :show, :destroy, :edit]
17
+ authorize_resource
18
18
 
19
19
  has_scope :tagged_with, :as => :tag
20
20
  has_scope :accessible_by, :type=>:boolean, :default=>true do |c,s|
21
21
  s.accessible_by(c.current_ability)
22
22
  end
23
23
 
24
- authorize_resource
25
-
26
24
  def resource
27
25
  page_id = params[:id]
28
26
  if page_id.is_numeric?
@@ -35,7 +33,9 @@ class PagesController < InheritedResources::Base
35
33
  end
36
34
 
37
35
  def maybe_authenticate
38
- authenticate_user! if params[:a]
36
+ unless user_signed_in?
37
+ authenticate_user! unless current_ability.can? :read, resource
38
+ end
39
39
  end
40
40
 
41
41
  def show
@@ -0,0 +1,10 @@
1
+ class Attachment < ActiveRecord::Base
2
+ validates_presence_of :file, :page_id
3
+ belongs_to :page
4
+
5
+ has_attached_file :file,
6
+ :storage => :s3,
7
+ :s3_credentials => "#{Rails.root}/config/amazon_s3.yml",
8
+ :path => "/attachments/:filename"
9
+ end
10
+
data/app/models/user.rb CHANGED
@@ -4,6 +4,11 @@ class User < ActiveRecord::Base
4
4
  has_many :blogs, :dependent => :destroy
5
5
  has_one :profile, :dependent => :destroy
6
6
  has_many :galleries, :dependent => :destroy
7
+ has_many :access_control_entries, :dependent=>:destroy
8
+
9
+ def self.nobody
10
+ User.new(:role=>"Nobody")
11
+ end
7
12
 
8
13
  def create_profile
9
14
  Profile.create(:user=>self) unless self.profile
@@ -36,12 +41,7 @@ class User < ActiveRecord::Base
36
41
  self.confirmed_at = DateTime::now
37
42
  save
38
43
  end
44
+ devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable, :token_authenticatable, :lockable, :timeoutable
39
45
 
40
- # Include default devise modules. Others available are:
41
- # :token_authenticatable, :confirmable, :lockable and :timeoutable
42
- devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :token_authenticatable, :confirmable, :lockable, :timeoutable
43
-
44
- # Setup accessible (or protected) attributes for your model
45
- attr_accessible :email, :password, :password_confirmation
46
46
  end
47
47
 
@@ -0,0 +1,35 @@
1
+ -if resource.errors.any?
2
+ #errorExplanation
3
+ %h2= "#{pluralize(resource.errors.count, "error")} prohibited this image from being saved:"
4
+ %ul
5
+ - resource.errors.full_messages.each do |msg|
6
+ %li= msg
7
+
8
+ = form_for [@page, @attachment], :html=>{:multipart=>true} do |f|
9
+ = f.file_field :file, :id=>"file_input"
10
+ = f.submit "Upload File", :id=>"upload_button"
11
+
12
+ = content_for :head do
13
+ = javascript_include_tag *%w(swfobject jquery.uploadify)
14
+ :javascript
15
+ $(function() {
16
+ $('#upload_button').hide();
17
+ $('#file_input').uploadify ({
18
+ script : '#{page_attachments_path(@page, :container=>'attachments_list')}',
19
+ uploader : '/uploadify.swf',
20
+ fileDataName : 'attachment[file]',
21
+ multi : true,
22
+ auto : true,
23
+ buttonText : 'New File',
24
+ cancelImg : '/images/uploadify/cancel.png',
25
+ onComplete : function(a, b, c, response){ eval(response); },
26
+ scriptData : {
27
+ '_http_accept': 'application/javascript',
28
+ '_method': 'post',
29
+ '#{session_key_name}' : encodeURIComponent('#{u cookies[session_key_name]}'),
30
+ 'authenticity_token': encodeURIComponent('#{raw form_authenticity_token}'),
31
+ 'session_encoded': '#{make_session_string}',
32
+ }
33
+ });
34
+ });
35
+
@@ -0,0 +1,9 @@
1
+
2
+ %ul#attachments_list
3
+ - @attachments.each do |attachment|
4
+ %li{:id=>attachment.element_id}
5
+ .file_link= link_to attachment.file.original_filename, attachment.file.url
6
+ .file_size= number_to_human_size attachment.file.size
7
+
8
+ = render :partial=>'form'
9
+
@@ -0,0 +1,6 @@
1
+ %li
2
+ %ul{:id=>@attachment.element_id}
3
+ %li= link_to @attachment.file.original_filename, @attachment.file.url
4
+ %li Size: #{number_to_human_size @attachment.file.size}
5
+ %li Modified: #{@attachment.updated_at.try(:strftime, "%D %R")}
6
+
@@ -0,0 +1,3 @@
1
+ $('#attachments_list').append(#{raw render_js('show')});
2
+ = render :partial => "loadbehind/view"
3
+
@@ -0,0 +1,3 @@
1
+ $('##{container}').remove;
2
+ = render :partial => "loadbehind/destroy"
3
+
@@ -0,0 +1,3 @@
1
+ $('##{container}').#{ajax_function}(#{raw render_js('form')});
2
+ = render :partial => "loadbehind/edit"
3
+
@@ -0,0 +1,2 @@
1
+ = render :partial => "index"
2
+
@@ -0,0 +1,3 @@
1
+ $('##{container}').#{ajax_function}(#{raw render_js('index')});
2
+ = render :partial => "loadbehind/view"
3
+
@@ -0,0 +1,3 @@
1
+
2
+ = render :partial => "form"
3
+
@@ -0,0 +1,3 @@
1
+ $('##{container}').#{ajax_function}(#{raw render_js('form')});
2
+ = render :partial => "loadbehind/edit"
3
+
@@ -0,0 +1,2 @@
1
+ = render :partial => "show"
2
+
@@ -0,0 +1,3 @@
1
+ $('##{container}').#{ajax_function}(#{raw render_js('show')});
2
+ = render :partial => "loadbehind/view"
3
+
@@ -0,0 +1,3 @@
1
+ $('##{container}').#{ajax_function}(#{raw render_js('show')});
2
+ = render :partial => "loadbehind/view"
3
+
@@ -0,0 +1,20 @@
1
+
2
+
3
+ = content_for :sidebar do
4
+ %ul
5
+ %li.sidebar_title Control Panel
6
+ %li
7
+ Upload a file to this page.
8
+ = render :partial=>'attachments/form'
9
+ %li
10
+ Set an existing page as a child of current one
11
+ = form_for form_object, :url=>form_url, :remote=>true do |f|
12
+ = select_tag :child_id, options_for_select(to_html_options(Page.orphans))
13
+ = f.submit "Add Child"
14
+ %li
15
+ Set permissions >>
16
+ = link_to 'Edit Access', access_control_entries_path(:resource_class=>"Page", :resource_id=>@page.id), |
17
+ :confirm => "Are you sure? Any unsaved changes on this page should be saved before leaving."
18
+ %li= link_to 'New Page as child', new_page_child_path(@page), |
19
+ :confirm => "Are you sure? Any unsaved changes on this page should be saved before leaving."
20
+
@@ -1,20 +1,16 @@
1
1
  %h1 Editing page
2
2
 
3
-
4
3
  = render 'form'
5
4
 
5
+ = link_to 'Show', @page
6
+ \|
7
+ = link_to 'Back', pages_path
8
+
6
9
  = content_for :sidebar do
7
10
  %ul#attachments_list
8
11
  %li.sidebar_title Files
9
12
  - @page.attachments.each do |attachment|
10
13
  = render :partial => "attachments/show", :locals=>{:a=>(@attachment=attachment)}
11
- = render :partial=>'attachments/form'
12
14
 
13
- = form_for form_object, :url=>form_url, :remote=>true do |f|
14
- = select_tag :child_id, options_for_select(to_html_options(Page.orphans))
15
- = f.submit "Add Child"
16
-
17
- = link_to 'Show', @page
18
- \|
19
- = link_to 'Back', pages_path
15
+ = render :partial => "control_panel"
20
16
 
data/wheels.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{wheels}
8
- s.version = "0.0.25"
8
+ s.version = "0.0.26"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tyler Gannon"]
12
- s.date = %q{2010-08-18}
12
+ s.date = %q{2010-08-19}
13
13
  s.description = %q{Call rails generate wheels.}
14
14
  s.email = %q{tgannon@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
21
21
  "Rakefile",
22
22
  "VERSION",
23
23
  "app/controllers/access_control_entries_controller.rb",
24
+ "app/controllers/attachments_controller.rb",
24
25
  "app/controllers/blogs_controller.rb",
25
26
  "app/controllers/discussions_controller.rb",
26
27
  "app/controllers/forum_messages_controller.rb",
@@ -38,6 +39,7 @@ Gem::Specification.new do |s|
38
39
  "app/helpers/pages_helper.rb",
39
40
  "app/models/ability.rb",
40
41
  "app/models/access_control_entry.rb",
42
+ "app/models/attachment.rb",
41
43
  "app/models/blog.rb",
42
44
  "app/models/discussion.rb",
43
45
  "app/models/forum.rb",
@@ -64,6 +66,19 @@ Gem::Specification.new do |s|
64
66
  "app/views/access_control_entries/show.html.haml",
65
67
  "app/views/access_control_entries/show.js.haml",
66
68
  "app/views/access_control_entries/update.js.haml",
69
+ "app/views/attachments/_form.html.haml",
70
+ "app/views/attachments/_index.html.haml",
71
+ "app/views/attachments/_show.html.haml",
72
+ "app/views/attachments/create.js.haml",
73
+ "app/views/attachments/destroy.js.haml",
74
+ "app/views/attachments/edit.js.haml",
75
+ "app/views/attachments/index.html.haml",
76
+ "app/views/attachments/index.js.haml",
77
+ "app/views/attachments/new.html.haml",
78
+ "app/views/attachments/new.js.haml",
79
+ "app/views/attachments/show.html.haml",
80
+ "app/views/attachments/show.js.haml",
81
+ "app/views/attachments/update.js.haml",
67
82
  "app/views/blogs/_form.html.haml",
68
83
  "app/views/blogs/edit.html.haml",
69
84
  "app/views/blogs/index.html.haml",
@@ -112,6 +127,7 @@ Gem::Specification.new do |s|
112
127
  "app/views/loadbehind/growl.js.haml",
113
128
  "app/views/loadbehind/index.js.haml",
114
129
  "app/views/pages/_child_pages_links.html.haml",
130
+ "app/views/pages/_control_panel.html.haml",
115
131
  "app/views/pages/_form.html.haml",
116
132
  "app/views/pages/_form_fields.html.haml",
117
133
  "app/views/pages/_show_attachment.html.haml",
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wheels
3
3
  version: !ruby/object:Gem::Version
4
- hash: 45
4
+ hash: 43
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 25
10
- version: 0.0.25
9
+ - 26
10
+ version: 0.0.26
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tyler Gannon
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-18 00:00:00 -07:00
18
+ date: 2010-08-19 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -46,6 +46,7 @@ files:
46
46
  - Rakefile
47
47
  - VERSION
48
48
  - app/controllers/access_control_entries_controller.rb
49
+ - app/controllers/attachments_controller.rb
49
50
  - app/controllers/blogs_controller.rb
50
51
  - app/controllers/discussions_controller.rb
51
52
  - app/controllers/forum_messages_controller.rb
@@ -63,6 +64,7 @@ files:
63
64
  - app/helpers/pages_helper.rb
64
65
  - app/models/ability.rb
65
66
  - app/models/access_control_entry.rb
67
+ - app/models/attachment.rb
66
68
  - app/models/blog.rb
67
69
  - app/models/discussion.rb
68
70
  - app/models/forum.rb
@@ -89,6 +91,19 @@ files:
89
91
  - app/views/access_control_entries/show.html.haml
90
92
  - app/views/access_control_entries/show.js.haml
91
93
  - app/views/access_control_entries/update.js.haml
94
+ - app/views/attachments/_form.html.haml
95
+ - app/views/attachments/_index.html.haml
96
+ - app/views/attachments/_show.html.haml
97
+ - app/views/attachments/create.js.haml
98
+ - app/views/attachments/destroy.js.haml
99
+ - app/views/attachments/edit.js.haml
100
+ - app/views/attachments/index.html.haml
101
+ - app/views/attachments/index.js.haml
102
+ - app/views/attachments/new.html.haml
103
+ - app/views/attachments/new.js.haml
104
+ - app/views/attachments/show.html.haml
105
+ - app/views/attachments/show.js.haml
106
+ - app/views/attachments/update.js.haml
92
107
  - app/views/blogs/_form.html.haml
93
108
  - app/views/blogs/edit.html.haml
94
109
  - app/views/blogs/index.html.haml
@@ -137,6 +152,7 @@ files:
137
152
  - app/views/loadbehind/growl.js.haml
138
153
  - app/views/loadbehind/index.js.haml
139
154
  - app/views/pages/_child_pages_links.html.haml
155
+ - app/views/pages/_control_panel.html.haml
140
156
  - app/views/pages/_form.html.haml
141
157
  - app/views/pages/_form_fields.html.haml
142
158
  - app/views/pages/_show_attachment.html.haml