wheels 0.0.22 → 0.0.23
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 +1 -1
- data/app/controllers/pages_controller.rb +66 -1
- data/app/helpers/application_helper.rb +13 -0
- data/app/helpers/pages_helper.rb +8 -6
- data/app/models/access_control_entry.rb +7 -2
- data/app/models/page.rb +6 -1
- data/app/views/loadbehind/_destroy.js.haml +3 -0
- data/app/views/loadbehind/_edit.js.haml +4 -0
- data/app/views/loadbehind/_errors.html.haml +5 -0
- data/app/views/loadbehind/_growl_template.html.haml +65 -0
- data/app/views/loadbehind/_show_box.html.haml +9 -0
- data/app/views/loadbehind/_view.js.haml +5 -0
- data/app/views/loadbehind/growl.js.haml +4 -0
- data/app/views/loadbehind/index.js.haml +4 -0
- data/app/views/pages/_child_pages_links.html.haml +5 -0
- data/app/views/pages/_form.html.haml +2 -2
- data/app/views/pages/_show_attachment.html.haml +6 -0
- data/app/views/pages/_show_small.html.haml +2 -0
- data/app/views/pages/create.js.haml +2 -0
- data/app/views/pages/edit.html.haml +12 -0
- data/app/views/pages/index.html.haml +2 -1
- data/app/views/pages/show.html.haml +18 -3
- data/app/views/pages/update.js.haml +3 -0
- data/lib/wheels/flash_session_cookie_middleware.rb +21 -0
- data/lib/wheels/routes.rb +3 -4
- data/lib/wheels.rb +1 -0
- data/wheels.gemspec +17 -2
- metadata +19 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.23
|
@@ -1,11 +1,28 @@
|
|
1
1
|
class PagesController < InheritedResources::Base
|
2
|
+
respond_to :js, :html
|
3
|
+
ajax_loading
|
4
|
+
belongs_to :parent, :optional=>true, :collection_name => :children,
|
5
|
+
:parent_class=>Page, :param=>:page_id, :instance_name=>:parent_page
|
6
|
+
before_filter :set_collection_name
|
7
|
+
|
8
|
+
def set_collection_name
|
9
|
+
if params[:page_id]
|
10
|
+
self.resources_configuration[:self][:collection_name] = :children
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
before_filter :authenticate_user!, :except=>[:index, :show]
|
16
|
+
before_filter :maybe_authenticate, :only=>[:index, :show]
|
2
17
|
before_filter :resource, :only=>[:update, :show, :destroy, :edit]
|
3
|
-
|
18
|
+
|
4
19
|
has_scope :tagged_with, :as => :tag
|
5
20
|
has_scope :accessible_by, :type=>:boolean, :default=>true do |c,s|
|
6
21
|
s.accessible_by(c.current_ability)
|
7
22
|
end
|
8
23
|
|
24
|
+
authorize_resource
|
25
|
+
|
9
26
|
def resource
|
10
27
|
page_id = params[:id]
|
11
28
|
if page_id.is_numeric?
|
@@ -13,6 +30,54 @@ class PagesController < InheritedResources::Base
|
|
13
30
|
else
|
14
31
|
@page ||= Page.where(["lower(pages.title) = ?", page_id.downcase.gsub(/[_]/, ' ')]).first
|
15
32
|
end
|
33
|
+
@attachments ||= @page.attachments
|
34
|
+
@page
|
35
|
+
end
|
36
|
+
|
37
|
+
def maybe_authenticate
|
38
|
+
authenticate_user! if params[:a]
|
39
|
+
end
|
40
|
+
|
41
|
+
def show
|
42
|
+
show! do |format|
|
43
|
+
set_children
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def edit
|
48
|
+
edit! do |format|
|
49
|
+
set_children
|
50
|
+
@attachment = Attachment.new(:page=>@page)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def create
|
55
|
+
create! { (@parent_page ? page_child_path(@parent_page, @page) : @page) }
|
56
|
+
end
|
57
|
+
|
58
|
+
def new
|
59
|
+
new! do |format|
|
60
|
+
set_children
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def update
|
65
|
+
update! do |format|
|
66
|
+
if params[:child_id]
|
67
|
+
@parent_page = @page
|
68
|
+
@page = Page.find(params[:child_id])
|
69
|
+
@page.parent = @parent_page
|
70
|
+
@page.save
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def set_children
|
76
|
+
if @parent_page
|
77
|
+
@children = @parent_page.children
|
78
|
+
else
|
79
|
+
@children = @page.children
|
80
|
+
end
|
16
81
|
end
|
17
82
|
end
|
18
83
|
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module ApplicationHelper
|
2
|
+
def menu_item(name, href)
|
3
|
+
content_tag(:li, content_tag(:a, content_tag(:span, name), :href=>href))
|
4
|
+
end
|
5
|
+
def include_ckeditor
|
6
|
+
content_for :head do
|
7
|
+
javascript_include_tag('/ckeditor/ckeditor.js',
|
8
|
+
'/ckeditor/adapters/jquery.js',
|
9
|
+
"galleries/configure_ckeditor.js")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
data/app/helpers/pages_helper.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
module PagesHelper
|
2
|
-
def
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
end
|
2
|
+
def form_url
|
3
|
+
@parent_page ? page_children_path(@parent_page) : page_path(@page)
|
4
|
+
end
|
5
|
+
def form_object
|
6
|
+
@parent_page ? [@parent_page, @page] : @page
|
8
7
|
end
|
9
8
|
|
9
|
+
def to_html_options(pages)
|
10
|
+
pages.map{|p| [p.title, p.id]}
|
11
|
+
end
|
10
12
|
end
|
11
13
|
|
@@ -50,8 +50,13 @@ class AccessControlEntry < ActiveRecord::Base
|
|
50
50
|
|
51
51
|
def configure(ability)
|
52
52
|
raise "I only like Ability" unless ability.class==Ability
|
53
|
-
|
54
|
-
|
53
|
+
if self.can
|
54
|
+
puts "can #{verb.to_sym.inspect}, #{resource.inspect}, #{options.inspect}"
|
55
|
+
ability.can verb.to_sym, resource, options
|
56
|
+
else
|
57
|
+
puts "cannot #{verb.to_sym.inspect}, #{resource.inspect}, #{options.inspect}"
|
58
|
+
ability.cannot verb.to_sym, resource, options
|
59
|
+
end
|
55
60
|
end
|
56
61
|
|
57
62
|
def self.can(verb, resource, options={})
|
data/app/models/page.rb
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
class Page < ActiveRecord::Base
|
2
|
-
has_many :
|
2
|
+
has_many :attachments
|
3
|
+
validates_presence_of :title
|
4
|
+
belongs_to :parent, :class_name=>'Page', :foreign_key=>'parent_id'
|
5
|
+
has_many :children, :class_name=>'Page', :foreign_key=>'parent_id'
|
3
6
|
acts_as_taggable
|
7
|
+
|
8
|
+
scope :orphans, where(:parent_id=>nil)
|
4
9
|
end
|
5
10
|
|
@@ -0,0 +1,65 @@
|
|
1
|
+
:css
|
2
|
+
.growl_box {
|
3
|
+
width: 225px;
|
4
|
+
border: 0px;
|
5
|
+
cellpadding: 0px;
|
6
|
+
cellspacing: 0px;
|
7
|
+
}
|
8
|
+
.growl_top {
|
9
|
+
background-image: url(/images/growl/growl_top.png);
|
10
|
+
width: 225px;
|
11
|
+
height: 49px;
|
12
|
+
background-repeat: no-repeat;
|
13
|
+
color: #fff;
|
14
|
+
}
|
15
|
+
.growl_top_img {
|
16
|
+
max-width: 25px;
|
17
|
+
max-height: 25px;
|
18
|
+
text-align: center;
|
19
|
+
margin-left: 19px;
|
20
|
+
margin-top: 19px;
|
21
|
+
}
|
22
|
+
.growl_title {
|
23
|
+
font-size: 18px;
|
24
|
+
margin: 0pt;
|
25
|
+
margin-left: 5px;
|
26
|
+
margin-bottom: 10px;
|
27
|
+
display: inline;
|
28
|
+
}
|
29
|
+
td.growl_content {
|
30
|
+
background-image: url(/images/growl/growl_repeat.png);
|
31
|
+
width: 225px;
|
32
|
+
background-repeat: repeat-y;
|
33
|
+
color: #ddd;
|
34
|
+
}
|
35
|
+
|
36
|
+
p.growl_content {
|
37
|
+
margin: 20px;
|
38
|
+
}
|
39
|
+
.growl_bottom {
|
40
|
+
background-image: url(/images/growl/growl_bottom.png);
|
41
|
+
background-repeat: no-repeat;
|
42
|
+
width: 225px;
|
43
|
+
height: 27px;
|
44
|
+
vertical-align: top;
|
45
|
+
horizontal-align: right;
|
46
|
+
}
|
47
|
+
a.growl_close {
|
48
|
+
margin-right: 25px;
|
49
|
+
font-size: 10px;
|
50
|
+
color: #fff;
|
51
|
+
text-align: right;
|
52
|
+
}
|
53
|
+
|
54
|
+
%table.growl_box
|
55
|
+
%tr
|
56
|
+
%td.growl_top
|
57
|
+
%img.growl_top_img{:src=>"%image%"}
|
58
|
+
%h1.growl_title %title%
|
59
|
+
%tr
|
60
|
+
%td.growl_content
|
61
|
+
%p.growl_content %message%
|
62
|
+
%tr
|
63
|
+
%td.growl_bottom
|
64
|
+
a.growl_close{:href=>"#", :onclick=>"return false;" :rel=>"close"} Close
|
65
|
+
|
@@ -1,13 +1,13 @@
|
|
1
1
|
- include_ckeditor
|
2
2
|
|
3
|
-
=
|
3
|
+
= render :partial => "child_pages_links"
|
4
|
+
= form_for form_object, :url=>form_url do |f|
|
4
5
|
-if @page.errors.any?
|
5
6
|
#errorExplanation
|
6
7
|
%h2= "#{pluralize(@page.errors.count, "error")} prohibited this page from being saved:"
|
7
8
|
%ul
|
8
9
|
- @page.errors.full_messages.each do |msg|
|
9
10
|
%li= msg
|
10
|
-
|
11
11
|
.field
|
12
12
|
= f.label :title
|
13
13
|
= f.text_field :title
|
@@ -2,6 +2,18 @@
|
|
2
2
|
|
3
3
|
= render 'form'
|
4
4
|
|
5
|
+
= content_for :sidebar do
|
6
|
+
%ul#attachments_list
|
7
|
+
%li.sidebar_title Files
|
8
|
+
- @page.attachments.each do |attachment|
|
9
|
+
= render :partial => "attachments/show", :locals=>{:a=>(@attachment=attachment)}
|
10
|
+
= render :partial=>'attachments/form'
|
11
|
+
|
12
|
+
= form_for form_object, :url=>form_url, :remote=>true do |f|
|
13
|
+
= select_tag :child_id, options_for_select(to_html_options(Page.orphans))
|
14
|
+
= f.submit "Add Child"
|
15
|
+
= link_to "New Child Page", new_page_path(:page_id=>@page.id), :confirm=>"Adding a child page will leave this page without saving. Only continue if you have no unsaved changes."
|
5
16
|
= link_to 'Show', @page
|
6
17
|
\|
|
7
18
|
= link_to 'Back', pages_path
|
19
|
+
|
@@ -1,8 +1,23 @@
|
|
1
1
|
%h1= resource.title
|
2
2
|
.page_content!= resource.body
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
= render :partial => "child_pages_links"
|
5
|
+
|
6
6
|
- if can? :manage, @page
|
7
|
-
=
|
7
|
+
= content_for :sidebar do
|
8
|
+
%ul
|
9
|
+
%li.sidebar_title Manage This Page
|
10
|
+
%li= link_to 'Edit', edit_page_path(@page)
|
11
|
+
%li= link_to 'Edit Access', access_control_entries_path(:resource_class=>"Page", :resource_id=>@page.id)
|
12
|
+
|
13
|
+
- if @parent_page
|
14
|
+
= content_for :links do
|
15
|
+
%li= link_to "< #{@parent_page.title}", @parent_page
|
16
|
+
|
17
|
+
- unless @page.attachments.empty?
|
18
|
+
= content_for :sidebar do
|
19
|
+
%ul#attachments_list
|
20
|
+
%li.sidebar_title Files
|
21
|
+
- @page.attachments.each do |attachment|
|
22
|
+
= render :partial => "attachments/show", :locals=>{:a=>(@attachment=attachment)}
|
8
23
|
|
@@ -0,0 +1,21 @@
|
|
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
|
+
::Rack::Utils.escape(req.params[@session_key]) ].
|
14
|
+
join('=').freeze unless req.params[@session_key].nil?
|
15
|
+
env['HTTP_ACCEPT'] = "#{req.params['_http_accept']}".
|
16
|
+
freeze unless req.params['_http_accept'].nil?
|
17
|
+
end
|
18
|
+
@app.call(env)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
data/lib/wheels/routes.rb
CHANGED
@@ -22,10 +22,9 @@ module ActionDispatch::Routing
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
resources :pages
|
26
|
-
|
27
|
-
|
28
|
-
resources :pages
|
25
|
+
resources :pages do
|
26
|
+
resources :attachments
|
27
|
+
resources :children, :controller=>"pages", :as => "children"
|
29
28
|
end
|
30
29
|
|
31
30
|
scope "/admin" do
|
data/lib/wheels.rb
CHANGED
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.
|
8
|
+
s.version = "0.0.23"
|
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-
|
12
|
+
s.date = %q{2010-08-18}
|
13
13
|
s.description = %q{Call rails generate wheels.}
|
14
14
|
s.email = %q{tgannon@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
|
|
31
31
|
"app/controllers/profiles_controller.rb",
|
32
32
|
"app/controllers/users_controller.rb",
|
33
33
|
"app/helpers/access_control_entries_helper.rb",
|
34
|
+
"app/helpers/application_helper.rb",
|
34
35
|
"app/helpers/blogs_helper.rb",
|
35
36
|
"app/helpers/discussions_helper.rb",
|
36
37
|
"app/helpers/forums_helper.rb",
|
@@ -102,11 +103,24 @@ Gem::Specification.new do |s|
|
|
102
103
|
"app/views/images/update.js.haml",
|
103
104
|
"app/views/layouts/application.html.haml",
|
104
105
|
"app/views/layouts/image_dialog.html.haml",
|
106
|
+
"app/views/loadbehind/_destroy.js.haml",
|
107
|
+
"app/views/loadbehind/_edit.js.haml",
|
108
|
+
"app/views/loadbehind/_errors.html.haml",
|
109
|
+
"app/views/loadbehind/_growl_template.html.haml",
|
110
|
+
"app/views/loadbehind/_show_box.html.haml",
|
111
|
+
"app/views/loadbehind/_view.js.haml",
|
112
|
+
"app/views/loadbehind/growl.js.haml",
|
113
|
+
"app/views/loadbehind/index.js.haml",
|
114
|
+
"app/views/pages/_child_pages_links.html.haml",
|
105
115
|
"app/views/pages/_form.html.haml",
|
116
|
+
"app/views/pages/_show_attachment.html.haml",
|
117
|
+
"app/views/pages/_show_small.html.haml",
|
118
|
+
"app/views/pages/create.js.haml",
|
106
119
|
"app/views/pages/edit.html.haml",
|
107
120
|
"app/views/pages/index.html.haml",
|
108
121
|
"app/views/pages/new.html.haml",
|
109
122
|
"app/views/pages/show.html.haml",
|
123
|
+
"app/views/pages/update.js.haml",
|
110
124
|
"app/views/profiles/_form.html.haml",
|
111
125
|
"app/views/profiles/edit.html.haml",
|
112
126
|
"app/views/profiles/index.html.haml",
|
@@ -173,6 +187,7 @@ Gem::Specification.new do |s|
|
|
173
187
|
"lib/wheels/action_view_helper_extensions.rb",
|
174
188
|
"lib/wheels/active_record_extensions.rb",
|
175
189
|
"lib/wheels/active_record_user_extensions.rb",
|
190
|
+
"lib/wheels/flash_session_cookie_middleware.rb",
|
176
191
|
"lib/wheels/routes.rb",
|
177
192
|
"lib/wheels/user.rb",
|
178
193
|
"lib/wheels/wheels_engine.rb",
|
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:
|
4
|
+
hash: 49
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 23
|
10
|
+
version: 0.0.23
|
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
|
+
date: 2010-08-18 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -56,6 +56,7 @@ files:
|
|
56
56
|
- app/controllers/profiles_controller.rb
|
57
57
|
- app/controllers/users_controller.rb
|
58
58
|
- app/helpers/access_control_entries_helper.rb
|
59
|
+
- app/helpers/application_helper.rb
|
59
60
|
- app/helpers/blogs_helper.rb
|
60
61
|
- app/helpers/discussions_helper.rb
|
61
62
|
- app/helpers/forums_helper.rb
|
@@ -127,11 +128,24 @@ files:
|
|
127
128
|
- app/views/images/update.js.haml
|
128
129
|
- app/views/layouts/application.html.haml
|
129
130
|
- app/views/layouts/image_dialog.html.haml
|
131
|
+
- app/views/loadbehind/_destroy.js.haml
|
132
|
+
- app/views/loadbehind/_edit.js.haml
|
133
|
+
- app/views/loadbehind/_errors.html.haml
|
134
|
+
- app/views/loadbehind/_growl_template.html.haml
|
135
|
+
- app/views/loadbehind/_show_box.html.haml
|
136
|
+
- app/views/loadbehind/_view.js.haml
|
137
|
+
- app/views/loadbehind/growl.js.haml
|
138
|
+
- app/views/loadbehind/index.js.haml
|
139
|
+
- app/views/pages/_child_pages_links.html.haml
|
130
140
|
- app/views/pages/_form.html.haml
|
141
|
+
- app/views/pages/_show_attachment.html.haml
|
142
|
+
- app/views/pages/_show_small.html.haml
|
143
|
+
- app/views/pages/create.js.haml
|
131
144
|
- app/views/pages/edit.html.haml
|
132
145
|
- app/views/pages/index.html.haml
|
133
146
|
- app/views/pages/new.html.haml
|
134
147
|
- app/views/pages/show.html.haml
|
148
|
+
- app/views/pages/update.js.haml
|
135
149
|
- app/views/profiles/_form.html.haml
|
136
150
|
- app/views/profiles/edit.html.haml
|
137
151
|
- app/views/profiles/index.html.haml
|
@@ -198,6 +212,7 @@ files:
|
|
198
212
|
- lib/wheels/action_view_helper_extensions.rb
|
199
213
|
- lib/wheels/active_record_extensions.rb
|
200
214
|
- lib/wheels/active_record_user_extensions.rb
|
215
|
+
- lib/wheels/flash_session_cookie_middleware.rb
|
201
216
|
- lib/wheels/routes.rb
|
202
217
|
- lib/wheels/user.rb
|
203
218
|
- lib/wheels/wheels_engine.rb
|