orange 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/orange/cartons/page_carton.rb +4 -2
- data/lib/orange/cartons/page_version_carton.rb +3 -1
- data/lib/orange/middleware/access_control.rb +3 -3
- data/lib/orange/resources/not_found.rb +1 -0
- data/lib/orange/resources/page_resource.rb +27 -5
- data/lib/orange/views/pages/edit.haml +14 -10
- metadata +1 -1
@@ -1,12 +1,14 @@
|
|
1
1
|
require 'dm-timestamps'
|
2
|
-
|
2
|
+
require 'orange/cartons/site_carton'
|
3
3
|
module Orange
|
4
|
-
class Page < Orange::
|
4
|
+
class Page < Orange::SiteCarton
|
5
5
|
id
|
6
6
|
front do
|
7
7
|
title :title
|
8
8
|
fulltext :body
|
9
9
|
end
|
10
|
+
boolean :published, :default => false
|
11
|
+
|
10
12
|
property :updated_at, DateTime
|
11
13
|
has n, :versions, "Orange::PageVersion"
|
12
14
|
end
|
@@ -1,10 +1,12 @@
|
|
1
1
|
require 'dm-timestamps'
|
2
|
+
require 'orange/cartons/site_carton'
|
2
3
|
module Orange
|
3
|
-
class PageVersion < Orange::
|
4
|
+
class PageVersion < Orange::SiteCarton
|
4
5
|
id
|
5
6
|
title :title
|
6
7
|
fulltext :body
|
7
8
|
property :updated_at, DateTime
|
9
|
+
boolean :published
|
8
10
|
property :version, Integer, :default => 0
|
9
11
|
belongs_to :orange_page, "Orange::Page"
|
10
12
|
end
|
@@ -76,7 +76,7 @@ module Orange::Middleware
|
|
76
76
|
after = packet.session['user.after_login'].blank? ?
|
77
77
|
'/' : packet.session['user.after_login']
|
78
78
|
packet.reroute(after)
|
79
|
-
false
|
79
|
+
return false
|
80
80
|
end
|
81
81
|
packet.reroute('/') if packet['user.id'] # Reroute to index if we're logged in.
|
82
82
|
|
@@ -135,12 +135,12 @@ module Orange::Middleware
|
|
135
135
|
)
|
136
136
|
)
|
137
137
|
packet[:content] = 'Got openID?'
|
138
|
-
packet.finish
|
138
|
+
return packet.finish
|
139
139
|
end
|
140
140
|
# Show login form, if necessary
|
141
141
|
else
|
142
142
|
packet[:content] = orange[:parser].haml('openid_login.haml', packet)
|
143
|
-
packet.finish
|
143
|
+
return packet.finish
|
144
144
|
end
|
145
145
|
end # end handle_openid
|
146
146
|
end
|
@@ -7,12 +7,33 @@ module Orange
|
|
7
7
|
options[:sitemappable] = true
|
8
8
|
|
9
9
|
end
|
10
|
+
|
11
|
+
def publish(packet, *opts)
|
12
|
+
if packet.request.post?
|
13
|
+
m = model_class.get(packet['route.resource_id'])
|
14
|
+
if m
|
15
|
+
params = {}
|
16
|
+
params[:published] = true
|
17
|
+
m.update(params)
|
18
|
+
params = m.attributes.merge(params)
|
19
|
+
params.delete(:id)
|
20
|
+
max = m.versions.max(:version) || 0
|
21
|
+
m.versions.new(params.merge(:version => max + 1))
|
22
|
+
m.save
|
23
|
+
end
|
24
|
+
end
|
25
|
+
packet.reroute(@my_orange_name, :orange)
|
26
|
+
end
|
27
|
+
|
10
28
|
# Creates a new model object and saves it (if a post), then reroutes to the main page
|
11
29
|
# @param [Orange::Packet] packet the packet being routed
|
12
30
|
def new(packet, *opts)
|
13
31
|
if packet.request.post?
|
14
|
-
|
15
|
-
|
32
|
+
params = packet.request.params[@my_orange_name.to_s]
|
33
|
+
params[:published] = false
|
34
|
+
m = model_class.new(params)
|
35
|
+
m.orange_site = packet['site']
|
36
|
+
# m.versions.new(params.merge(:version => 1))
|
16
37
|
m.save
|
17
38
|
end
|
18
39
|
packet.reroute(@my_orange_name, :orange)
|
@@ -24,9 +45,10 @@ module Orange
|
|
24
45
|
if packet.request.post?
|
25
46
|
m = model_class.get(packet['route.resource_id'])
|
26
47
|
if m
|
27
|
-
|
28
|
-
|
29
|
-
m.
|
48
|
+
params = packet.request.params[@my_orange_name.to_s]
|
49
|
+
params[:published] = false
|
50
|
+
m.update(params)
|
51
|
+
m.orange_site = packet['site']
|
30
52
|
m.save
|
31
53
|
end
|
32
54
|
end
|
@@ -3,17 +3,21 @@
|
|
3
3
|
= orange[:sitemap, true].sitemap_links(packet, {:slug_me => orange[:sitemap, true].slug_for(model, props)})
|
4
4
|
%form{:action => route_to(model_name, model[:id], 'save'), :method => 'post'}
|
5
5
|
- for prop in props
|
6
|
-
%p
|
6
|
+
%p~ view_attribute(prop, model_name, :label => true, :value => model.attribute_get(prop[:name]))
|
7
7
|
%input{:type => 'submit', :value => 'Save Changes'}
|
8
|
+
= route_to(model_name, model[:id], 'publish')
|
9
|
+
= form_link('Publish', packet.route_to(model_name, model[:id], 'publish'))
|
8
10
|
%h3 Versions
|
9
|
-
|
10
|
-
%li
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
%ul
|
12
|
+
%li (Current Draft)
|
13
|
+
- for version in model.versions.all(:order => :version.desc, :limit=> 3)
|
14
|
+
%li
|
15
|
+
.version_container
|
16
|
+
%span.version_info
|
17
|
+
%strong Version #{version.version}
|
18
|
+
%span.version_info
|
19
|
+
Last Updated: #{version.updated_at}
|
20
|
+
%span.version_info
|
21
|
+
%a{:href => route_to(model_name, model[:id], 'edit', "version", version.version)}Edit
|
18
22
|
- else
|
19
23
|
%p Couldn't find the item you're looking for.
|