orange 0.1.8 → 0.1.10
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/README.markdown +1 -0
- data/lib/orange-core/application.rb +13 -11
- data/lib/orange-core/core.rb +32 -0
- data/lib/orange-core/middleware/base.rb +5 -1
- data/lib/orange-core/middleware/database.rb +8 -4
- data/lib/orange-core/middleware/globals.rb +3 -3
- data/lib/orange-core/packet.rb +1 -1
- data/lib/orange-core/resource.rb +6 -2
- data/lib/orange-core/resources/parser.rb +9 -0
- data/lib/orange-core/stack.rb +16 -4
- data/lib/orange-more/administration/middleware/access_control.rb +2 -2
- data/lib/orange-more/assets/resources/asset_resource.rb +7 -8
- data/lib/orange-more/blog/resources/blog_post_resource.rb +1 -1
- data/lib/orange-more/blog/resources/blog_resource.rb +1 -1
- data/lib/orange-more/cloud/resources/cloud_resource.rb +2 -4
- data/lib/orange-more/debugger/middleware/debugger.rb +8 -1
- data/lib/orange-more/debugger/views/debug_bar.haml +20 -1
- data/lib/orange-more/events/cartons/orange_event.rb +7 -1
- data/lib/orange-more/events/resources/calendar_resource.rb +2 -0
- data/lib/orange-more/events/resources/event_resource.rb +33 -1
- data/lib/orange-more/events/views/events/create.haml +2 -1
- data/lib/orange-more/news/resources/news_resource.rb +3 -6
- data/lib/orange-more/pages/resources/page_resource.rb +5 -2
- data/lib/orange-more/sitemap/resources/sitemap_resource.rb +2 -2
- data/lib/orange-more/sitemap/views/default_resource/sitemap_row.haml +27 -0
- data/lib/orange-more/slices/resources/slices.rb +16 -18
- data/lib/orange-more/subsites/resources/subsite_resource.rb +1 -1
- data/lib/orange-more/testimonials/resources/testimonials_resource.rb +12 -13
- data/spec/orange-core/application_spec.rb +37 -0
- data/spec/orange-core/core_spec.rb +4 -4
- data/spec/orange-core/middleware/base_spec.rb +5 -5
- data/spec/orange-core/mock/mock_middleware.rb +4 -0
- data/spec/orange-core/mock/mock_resource.rb +12 -0
- data/spec/orange-core/resource_spec.rb +7 -0
- data/spec/orange-core/stack_spec.rb +48 -0
- metadata +4 -3
data/README.markdown
CHANGED
@@ -103,6 +103,7 @@ Required Gems
|
|
103
103
|
* rack-openid
|
104
104
|
* openid_dm_store
|
105
105
|
* radius
|
106
|
+
* crack
|
106
107
|
|
107
108
|
All dependencies should be loaded if you install the gem except for the datamapper
|
108
109
|
adapter relevant to your set up. If, for example, you want to use a mysql database,
|
@@ -9,17 +9,17 @@ module Orange
|
|
9
9
|
# the self.stack method, which will be used to create a new
|
10
10
|
# Orange::Stack
|
11
11
|
class Application
|
12
|
+
extend ClassInheritableAttributes
|
13
|
+
cattr_accessor :core, :stack_block
|
12
14
|
# Initialize will set the core, and additionally accept any
|
13
15
|
# other options to be added in to the opts array
|
14
16
|
# @param [Orange::Core] core the orange core instance that this application will use
|
15
17
|
# @param [Hash] *opts the optional arguments
|
16
18
|
def initialize(core = false, *opts, &block)
|
17
|
-
@core = core
|
19
|
+
@core = core || self.class.core
|
18
20
|
@options ||= {}
|
19
21
|
@options = Orange::Options.new(*opts, &block).hash.with_defaults(self.class.opts)
|
20
|
-
|
21
|
-
stack_init
|
22
|
-
end
|
22
|
+
core.application(self) # Register self into core
|
23
23
|
init
|
24
24
|
end
|
25
25
|
|
@@ -106,12 +106,14 @@ module Orange
|
|
106
106
|
# Returns an instance of Orange::Stack to be run by Rack
|
107
107
|
#
|
108
108
|
# Usually, you'll call this in the rackup file: `run MyApplication.app`
|
109
|
-
def self.app
|
110
|
-
|
111
|
-
|
112
|
-
|
109
|
+
def self.app(core = false)
|
110
|
+
self.core = core if core
|
111
|
+
self.core ||= Orange::Core.new
|
112
|
+
return self.core.stack unless self.core.stack.blank?
|
113
|
+
if self.stack_block.instance_of?(Proc)
|
114
|
+
Orange::Stack.new self, self.core, &self.stack_block # turn saved proc into a block arg
|
113
115
|
else
|
114
|
-
Orange::Stack.new self,
|
116
|
+
Orange::Stack.new self, self.core
|
115
117
|
end
|
116
118
|
end
|
117
119
|
|
@@ -120,8 +122,8 @@ module Orange
|
|
120
122
|
#
|
121
123
|
# Each call to stack overrides the previous one.
|
122
124
|
def self.stack(core = false, &block)
|
123
|
-
|
124
|
-
|
125
|
+
self.core = core if core
|
126
|
+
self.stack_block = Proc.new # pulls in the block and makes it a proc
|
125
127
|
end
|
126
128
|
end
|
127
129
|
end
|
data/lib/orange-core/core.rb
CHANGED
@@ -65,12 +65,20 @@ module Orange
|
|
65
65
|
def initialize(*args, &block)
|
66
66
|
@options = Options.new(*args, &block).hash.with_defaults(DEFAULT_CORE_OPTIONS)
|
67
67
|
@resources = {}
|
68
|
+
@application = false
|
69
|
+
@stack = false
|
70
|
+
@middleware = []
|
68
71
|
@events = {}
|
69
72
|
@file = __FILE__
|
70
73
|
load(Orange::Parser.new, :parser)
|
71
74
|
load(Orange::Mapper.new, :mapper)
|
72
75
|
load(Orange::PageParts.new, :page_parts)
|
73
76
|
Orange.plugins.each{|p| p.resources.each{|args| load(*args)} if p.has_resources?}
|
77
|
+
self.register(:stack_loaded) do |s|
|
78
|
+
@middleware.each{|m| m.stack_init if m.respond_to?(:stack_init)}
|
79
|
+
@application.stack_init if @application
|
80
|
+
end
|
81
|
+
self.register(:stack_reloading){|s| @middleware = []} # Dump middleware on stack reload
|
74
82
|
# load(Orange::AdminResource.new, :admin)
|
75
83
|
afterLoad
|
76
84
|
self
|
@@ -133,6 +141,26 @@ module Orange
|
|
133
141
|
@resources[name] = resource.set_orange(self, name)
|
134
142
|
end
|
135
143
|
|
144
|
+
# Takes an instance of Orange::Middleware::Base subclass and
|
145
|
+
# keeps it for later. This way we can provide introspection into the
|
146
|
+
# middleware instances (useful for calling stack_init on them)
|
147
|
+
def middleware(middle = false)
|
148
|
+
@middleware << middle if middle
|
149
|
+
@middleware
|
150
|
+
end
|
151
|
+
|
152
|
+
# Takes an instance of Orange::Application and saves it.
|
153
|
+
def application(app = false)
|
154
|
+
@application = app if app
|
155
|
+
@application
|
156
|
+
end
|
157
|
+
|
158
|
+
# Takes an instance of Orange::Stack and saves it.
|
159
|
+
def stack(stack = false)
|
160
|
+
@stack = stack if stack
|
161
|
+
@stack
|
162
|
+
end
|
163
|
+
|
136
164
|
# Convenience self for consistent naming across middleware
|
137
165
|
# @return [Orange::Core] self
|
138
166
|
def orange; self; end
|
@@ -224,5 +252,9 @@ module Orange
|
|
224
252
|
def self.add_pulp(inc)
|
225
253
|
Packet.mixin inc
|
226
254
|
end
|
255
|
+
|
256
|
+
def inspect
|
257
|
+
"#<Orange::Core:0x#{self.object_id.to_s(16)}>"
|
258
|
+
end
|
227
259
|
end
|
228
260
|
end
|
@@ -11,7 +11,9 @@ require 'orange-core/packet'
|
|
11
11
|
module Orange::Middleware
|
12
12
|
class Base
|
13
13
|
# Initialize will set the core and downstream app, then call init
|
14
|
-
# subclasses should override init instead of initialize
|
14
|
+
# subclasses should override init instead of initialize.
|
15
|
+
# If the subclass defines a stack_init, then it will be registered
|
16
|
+
# as a stack_loaded event.
|
15
17
|
# @param [Object] app a downstream app
|
16
18
|
# @param [Orange::Core] core the orange core
|
17
19
|
# @param [optional, Array] args any arguments
|
@@ -19,9 +21,11 @@ module Orange::Middleware
|
|
19
21
|
@app = app
|
20
22
|
@core = core
|
21
23
|
init(*args)
|
24
|
+
core.middleware(self)
|
22
25
|
end
|
23
26
|
|
24
27
|
# A stub method that subclasses can override to handle initialization
|
28
|
+
# For initialization
|
25
29
|
# @return [void]
|
26
30
|
def init(*args)
|
27
31
|
end
|
@@ -5,13 +5,17 @@ module Orange::Middleware
|
|
5
5
|
def init(opts = {})
|
6
6
|
opts = opts.with_defaults(:migration_url => (orange.options[:development_mode] ? '/__ORANGE_DB__/migrate' : false), :no_auto_upgrade => false)
|
7
7
|
orange.mixin Orange::Mixins::DBLoader
|
8
|
-
|
8
|
+
@options = opts
|
9
|
+
end
|
10
|
+
|
11
|
+
def stack_init
|
12
|
+
unless orange.options.has_key?('database') && orange.options['database'] == false
|
9
13
|
db = orange.options['database'] || 'sqlite3::memory:'
|
10
|
-
orange.load_db!(db)
|
11
|
-
orange.upgrade_db! unless
|
14
|
+
orange.load_db!(db)
|
15
|
+
orange.upgrade_db! unless @options[:no_auto_upgrade]
|
12
16
|
end
|
13
|
-
@options = opts
|
14
17
|
end
|
18
|
+
|
15
19
|
def packet_call(packet)
|
16
20
|
path = packet['route.path'] || packet.request.path_info
|
17
21
|
if @options[:migration_url] && @options[:migration_url] == path
|
@@ -2,11 +2,11 @@ require 'orange-core/middleware/base'
|
|
2
2
|
module Orange::Middleware
|
3
3
|
|
4
4
|
class Globals < Base
|
5
|
-
def init(
|
6
|
-
opts =
|
5
|
+
def init(opts = {})
|
6
|
+
opts = opts.with_defaults(:file => "__ORANGE__/config.yml")
|
7
7
|
@file = opts[:file].gsub('__ORANGE__', orange.app_dir)
|
8
8
|
@globals = orange[:parser].yaml(@file) || {}
|
9
|
-
@globals.each{|k,v| orange.options[k] = v
|
9
|
+
@globals.each{|k,v| orange.options[k] = v}
|
10
10
|
end
|
11
11
|
def packet_call(packet)
|
12
12
|
packet['orange.globals'] ||= orange.options
|
data/lib/orange-core/packet.rb
CHANGED
data/lib/orange-core/resource.rb
CHANGED
@@ -15,7 +15,8 @@ module Orange
|
|
15
15
|
def set_orange(orange, name)
|
16
16
|
@orange = orange
|
17
17
|
@my_orange_name = name
|
18
|
-
|
18
|
+
init
|
19
|
+
orange.register(:stack_loaded) { |s| stack_init } if self.respond_to? :stack_init
|
19
20
|
self
|
20
21
|
end
|
21
22
|
|
@@ -23,8 +24,11 @@ module Orange
|
|
23
24
|
raise 'instantiate the resource before calling set orange'
|
24
25
|
end
|
25
26
|
|
27
|
+
def init
|
28
|
+
afterLoad
|
29
|
+
end
|
30
|
+
|
26
31
|
def afterLoad
|
27
|
-
true
|
28
32
|
end
|
29
33
|
|
30
34
|
def self.call_me(name)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'orange-core/core'
|
2
2
|
require 'haml'
|
3
3
|
require 'yaml'
|
4
|
+
require 'crack'
|
4
5
|
|
5
6
|
module Orange
|
6
7
|
class Parser < Resource
|
@@ -60,6 +61,14 @@ module Orange
|
|
60
61
|
require 'hpricot'
|
61
62
|
Hpricot(text)
|
62
63
|
end
|
64
|
+
|
65
|
+
def xml(text)
|
66
|
+
Crack::XML.parse(text)
|
67
|
+
end
|
68
|
+
|
69
|
+
def json(text)
|
70
|
+
Crack::JSON.parse(text)
|
71
|
+
end
|
63
72
|
end
|
64
73
|
|
65
74
|
module Pulp::ParserPulp
|
data/lib/orange-core/stack.rb
CHANGED
@@ -28,8 +28,9 @@ module Orange
|
|
28
28
|
# @param [Symbol] prebuilt the optional prebuilt stack, if one isn't passed as block
|
29
29
|
def initialize(app_class = nil, core = false, prebuilt = :none, &block)
|
30
30
|
@build = Rack::Builder.new
|
31
|
-
@core = Orange::Core.new
|
31
|
+
@core = core || Orange::Core.new
|
32
32
|
@auto_reload = false
|
33
|
+
@middleware = []
|
33
34
|
@recapture = true
|
34
35
|
@main_app = app_class
|
35
36
|
if block_given?
|
@@ -193,9 +194,15 @@ module Orange
|
|
193
194
|
# @return [Object] a full stack of middleware and the exit application,
|
194
195
|
# conforming to Rack guidelines
|
195
196
|
def app
|
196
|
-
|
197
|
-
|
198
|
-
|
197
|
+
if @auto_reload
|
198
|
+
orange.fire(:stack_reloading, @app) if orange.stack # Alert we are rebuilding
|
199
|
+
@app = false # Rebuild no matter what if autoload
|
200
|
+
end
|
201
|
+
unless @app
|
202
|
+
@app = @build.to_app # Build if necessary
|
203
|
+
orange.stack self
|
204
|
+
orange.fire(:stack_loaded, @app)
|
205
|
+
end
|
199
206
|
@app
|
200
207
|
end
|
201
208
|
|
@@ -205,5 +212,10 @@ module Orange
|
|
205
212
|
env['orange.core'] = @core
|
206
213
|
app.call(env)
|
207
214
|
end
|
215
|
+
|
216
|
+
# Debug helping
|
217
|
+
def inspect
|
218
|
+
"#<Orange::Stack:0x#{self.object_id.to_s(16)} @build=#{@build.inspect}, @core=#{@core.inspect}>"
|
219
|
+
end
|
208
220
|
end
|
209
221
|
end
|
@@ -68,11 +68,11 @@ module Orange::Middleware
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def need_to_handle?(packet)
|
71
|
-
@handle && ([@login, @logout].include? packet.request.path)
|
71
|
+
@handle && ([@login, @logout].include? packet.request.path.gsub(/\/$/, ''))
|
72
72
|
end
|
73
73
|
|
74
74
|
def handle_openid(packet)
|
75
|
-
if packet.
|
75
|
+
if packet.request.path.gsub(/\/$/, '') == @logout
|
76
76
|
packet.session['user.id'] = nil
|
77
77
|
packet['user.id'] = nil
|
78
78
|
after = packet.session['user.after_login'].blank? ?
|
@@ -3,15 +3,14 @@ module Orange
|
|
3
3
|
class AssetResource < Orange::ModelResource
|
4
4
|
use Orange::Asset
|
5
5
|
call_me :assets
|
6
|
-
|
6
|
+
|
7
|
+
def stack_init
|
7
8
|
orange[:admin, true].add_link("Content", :resource => @my_orange_name, :text => 'Assets')
|
8
|
-
orange
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
''
|
14
|
-
end
|
9
|
+
orange[:radius, true].context.define_tag "asset" do |tag|
|
10
|
+
if tag.attr['id']
|
11
|
+
(m = model_class.first(:id => tag.attr['id'])) ? m.to_asset_tag : 'Invalid Asset'
|
12
|
+
else
|
13
|
+
''
|
15
14
|
end
|
16
15
|
end
|
17
16
|
end
|
@@ -4,10 +4,8 @@ module Orange
|
|
4
4
|
class CloudResource < Orange::Resource
|
5
5
|
ORANGE_PING_KEY = "c99550a0430eb9054eb4b7ee290664cf"
|
6
6
|
call_me :cloud
|
7
|
-
def
|
8
|
-
orange.
|
9
|
-
options[:ping_fm_key] = orange.options['ping_fm_key'] || false
|
10
|
-
end
|
7
|
+
def stack_init
|
8
|
+
options[:ping_fm_key] = orange.options['ping_fm_key'] || false
|
11
9
|
end
|
12
10
|
|
13
11
|
def microblog(packet, status, opts = {})
|
@@ -32,4 +32,11 @@ module Orange::Pulp::DebuggerHelpers
|
|
32
32
|
Rack::Utils.escape_html(obj.inspect)
|
33
33
|
end
|
34
34
|
end
|
35
|
-
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class Rack::Builder
|
38
|
+
def inspect
|
39
|
+
"#<Rack::Builder:#{self.object_id.to_s(16)} @ins=#{@ins.map{|x| x.instance_of?(Proc)? x.call(nil) : x }.inspect} >"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
@@ -61,4 +61,23 @@
|
|
61
61
|
%tr
|
62
62
|
%td #{h_debug key}
|
63
63
|
%td.code
|
64
|
-
%div #{h_debug val}
|
64
|
+
%div #{h_debug val}
|
65
|
+
%h3#orange-info= 'Orange Core'
|
66
|
+
%table.req
|
67
|
+
%thead
|
68
|
+
%tr
|
69
|
+
%th Variable
|
70
|
+
%th Value
|
71
|
+
%tbody
|
72
|
+
%tr
|
73
|
+
%td Middleware
|
74
|
+
%td.code
|
75
|
+
%div #{h_debug packet.env['orange.core'].middleware}
|
76
|
+
%tr
|
77
|
+
%td Application
|
78
|
+
%td.code
|
79
|
+
%div #{h_debug packet.env['orange.core'].application}
|
80
|
+
%tr
|
81
|
+
%td Stack
|
82
|
+
%td.code
|
83
|
+
%div #{h_debug packet.env['orange.core'].stack}
|
@@ -2,13 +2,19 @@ class OrangeEvent < Orange::Carton
|
|
2
2
|
id
|
3
3
|
admin do
|
4
4
|
title :name
|
5
|
-
text :
|
5
|
+
text :location_name
|
6
|
+
text :location_address
|
7
|
+
text :location_address2
|
8
|
+
text :location_city
|
9
|
+
text :location_state
|
10
|
+
text :location_zip
|
6
11
|
fulltext :description
|
7
12
|
end
|
8
13
|
orange do
|
9
14
|
time :starts
|
10
15
|
time :ends
|
11
16
|
end
|
17
|
+
|
12
18
|
def starts_time
|
13
19
|
self.starts.strftime("%I:%M %p")
|
14
20
|
end
|
@@ -1,10 +1,42 @@
|
|
1
|
+
require 'rest_client'
|
2
|
+
|
1
3
|
module Orange
|
2
4
|
class EventResource < ModelResource
|
5
|
+
# For integration with Eventbrite. Application key needs user
|
6
|
+
# key for full access.
|
7
|
+
ORANGE_EVENTBRITE_KEY = "ODQ5MDMzZWQwOWRl"
|
8
|
+
|
3
9
|
use OrangeEvent
|
4
10
|
call_me :events
|
5
11
|
|
12
|
+
def stack_init
|
13
|
+
options[:eventbrite_key] = orange.options['eventbrite_key'] || false
|
14
|
+
end
|
15
|
+
|
6
16
|
def find_extras(packet, mode, opts = {})
|
7
|
-
{:calendars => OrangeCalendar.all}
|
17
|
+
extras = {:calendars => OrangeCalendar.all}
|
18
|
+
case mode
|
19
|
+
when :create
|
20
|
+
ev = eventbrite_venues
|
21
|
+
extras.merge!(:eventbrite_venues => eventbrite_venues) if options[:eventbrite_key]
|
22
|
+
end
|
23
|
+
extras
|
24
|
+
end
|
25
|
+
|
26
|
+
def post_to_eventbrite
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
def eventbrite_venues
|
31
|
+
list = []
|
32
|
+
begin
|
33
|
+
response = RestClient.get("https://www.eventbrite.com/xml/user_list_venues?app_key=#{ORANGE_EVENTBRITE_KEY}&user_key=#{options[:eventbrite_key]}")
|
34
|
+
xml = orange[:parser].xml(response.body)
|
35
|
+
list = xml["venues"]["venue"].select{|x| !x['country'].blank? }
|
36
|
+
rescue
|
37
|
+
return false
|
38
|
+
end
|
39
|
+
list
|
8
40
|
end
|
9
41
|
end
|
10
42
|
end
|
@@ -19,4 +19,5 @@
|
|
19
19
|
%input{:type => 'text', :id => "#{model_name}-ends", :size => 10, :class => 'date', :name => "#{model_name}[ends_date]", :value => (Time.now + 60*60).strftime("%m/%d/%Y") }
|
20
20
|
at
|
21
21
|
%input{:type => 'text', :name => "#{model_name}[ends_time]", :size => 8, :value => (Time.now + 60*60).strftime("%I:%M %p") }
|
22
|
-
%input{:type => 'submit', :value => 'Save New Event'}
|
22
|
+
%input{:type => 'submit', :value => 'Save New Event'}
|
23
|
+
|
@@ -2,13 +2,10 @@ module Orange
|
|
2
2
|
class NewsResource < Orange::ModelResource
|
3
3
|
use OrangeNews
|
4
4
|
call_me :news
|
5
|
-
def
|
5
|
+
def stack_init
|
6
6
|
orange[:admin, true].add_link("Content", :resource => @my_orange_name, :text => 'News')
|
7
|
-
|
8
|
-
|
9
|
-
orange[:radius, true].context.define_tag "latest_news" do |tag|
|
10
|
-
orange[:news].latest(tag.locals.packet)
|
11
|
-
end
|
7
|
+
orange[:radius, true].context.define_tag "latest_news" do |tag|
|
8
|
+
orange[:news].latest(tag.locals.packet)
|
12
9
|
end
|
13
10
|
end
|
14
11
|
|
@@ -24,12 +24,15 @@ module Orange
|
|
24
24
|
class PageResource < Orange::ModelResource
|
25
25
|
use OrangePage
|
26
26
|
call_me :pages
|
27
|
-
def
|
28
|
-
orange[:admin, true].add_link("Content", :resource => @my_orange_name, :text => 'Pages')
|
27
|
+
def init
|
29
28
|
options[:sitemappable] = true
|
30
29
|
orange.add_pulp(Orange::Pulp::PageHelpers)
|
31
30
|
end
|
32
31
|
|
32
|
+
def stack_init
|
33
|
+
orange[:admin, true].add_link("Content", :resource => @my_orange_name, :text => 'Pages')
|
34
|
+
end
|
35
|
+
|
33
36
|
def publish(packet, opts = {})
|
34
37
|
no_reroute = opts[:no_reroute]
|
35
38
|
if packet.request.post? || !opts.blank?
|
@@ -5,10 +5,10 @@ module Orange
|
|
5
5
|
class SitemapResource < ModelResource
|
6
6
|
use OrangeRoute
|
7
7
|
call_me :sitemap
|
8
|
-
def
|
8
|
+
def stack_init
|
9
9
|
orange[:admin, true].add_link('Content', :resource => @my_orange_name, :text => 'Sitemap')
|
10
|
-
|
11
10
|
end
|
11
|
+
|
12
12
|
def route_actions(packet, opts = {})
|
13
13
|
do_view(packet, :route_actions, opts)
|
14
14
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
- if route
|
2
|
+
.sitemap_item{:class => "sitemap_level_#{route.level}"}
|
3
|
+
- if route.level > 0
|
4
|
+
.move_actions.dent_actions
|
5
|
+
= form_link('Outdent', route_to(:sitemap, route.id, 'outdent'), false, {:method => 'post', :class => 'outdent arrow'}) if route.level > 1
|
6
|
+
%p= ' '
|
7
|
+
.move_actions
|
8
|
+
- if route.previous_sibling
|
9
|
+
= form_link('Up', route_to(:sitemap, route.id, 'higher'), false, {:method => 'post', :class => 'up arrow'})
|
10
|
+
- else
|
11
|
+
%p.disabled_up.arrow= ' '
|
12
|
+
- if route.next_sibling
|
13
|
+
= form_link('Down', route_to(:sitemap, route.id, 'lower'), false, {:method => 'post', :class => 'down arrow'})
|
14
|
+
- else
|
15
|
+
%p.disabled_down.arrow= ' '
|
16
|
+
.move_actions.dent_actions
|
17
|
+
= form_link('Indent', route_to(:sitemap, route.id, 'indent'), false, {:method => 'post', :class => 'indent arrow'}) if route.previous_sibling && route.previous_sibling.level == route.level
|
18
|
+
%p= ' '
|
19
|
+
%h4 #{route.link_text} <span>(#{route.full_path})</span>
|
20
|
+
.linked_to
|
21
|
+
%p
|
22
|
+
Linked to:
|
23
|
+
%a{:href => route.resource.blank? ? '#' : route_to(route.resource, route.resource_id, 'edit')} [#{route.resource}] ##{route.resource_id}
|
24
|
+
.actions
|
25
|
+
= form_link('Delete', route_to(:sitemap, route.id, 'delete'), 'Are you sure you want to delete this?', {:method => 'delete'})
|
26
|
+
%a{:href => route_to(:sitemap, route.id, 'edit')} Edit
|
27
|
+
%br.clear
|
@@ -1,25 +1,23 @@
|
|
1
1
|
module Orange
|
2
2
|
class Slices < Orange::Resource
|
3
3
|
call_me :slices
|
4
|
-
def
|
5
|
-
orange.
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
if orange.
|
12
|
-
|
13
|
-
content << (id ? orange[resource].__send__(mode, tag.locals.packet, :id => id) : orange[resource].__send__(mode, tag.locals.packet))
|
14
|
-
else
|
15
|
-
content << "resource #{resource} doesn't respond to #{mode}"
|
16
|
-
end
|
4
|
+
def stack_init
|
5
|
+
orange[:radius].context.define_tag "slice" do |tag|
|
6
|
+
content = ''
|
7
|
+
resource = (tag.attr['resource'] || :slices).to_sym
|
8
|
+
id = tag.attr['id'] || nil
|
9
|
+
mode = (tag.attr['mode'] || tag.attr['chunk'] || (id ? :show : :index )).to_sym
|
10
|
+
if orange.loaded?(resource)
|
11
|
+
if orange[resource].respond_to?(mode) || resource == :slices
|
12
|
+
content << (id ? orange[resource].__send__(mode, tag.locals.packet, :id => id) : orange[resource].__send__(mode, tag.locals.packet))
|
17
13
|
else
|
18
|
-
content << "resource #{resource}
|
19
|
-
end
|
20
|
-
|
21
|
-
|
22
|
-
|
14
|
+
content << "resource #{resource} doesn't respond to #{mode}"
|
15
|
+
end
|
16
|
+
else
|
17
|
+
content << "resource #{resource} not loaded"
|
18
|
+
end
|
19
|
+
content
|
20
|
+
end
|
23
21
|
end
|
24
22
|
|
25
23
|
|
@@ -2,23 +2,22 @@ module Orange
|
|
2
2
|
class TestimonialsResource < Orange::ModelResource
|
3
3
|
use OrangeTestimonial
|
4
4
|
call_me :testimonials
|
5
|
-
def
|
5
|
+
def stack_init
|
6
6
|
orange[:admin, true].add_link("Content", :resource => @my_orange_name, :text => 'Testimonials')
|
7
|
-
orange.
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
""
|
18
|
-
end
|
7
|
+
orange[:radius].context.define_tag "testimonials" do |tag|
|
8
|
+
if tag.attr["tag"] && model_class.all.count >0
|
9
|
+
m = model_class.with_tag(tag.attr["tag"]).first(:offset => rand(model_class.with_tag(tag.attr["tag"]).count)) #selects testimonial based on tag
|
10
|
+
elsif model_class.all.count > 0
|
11
|
+
m = model_class.first(:offset => rand(model_class.all.count)) #selects a random testimonial
|
12
|
+
end
|
13
|
+
unless m.nil?
|
14
|
+
orange[:testimonials].testimonial(tag.locals.packet, {:model => m })
|
15
|
+
else
|
16
|
+
""
|
19
17
|
end
|
20
18
|
end
|
21
19
|
end
|
20
|
+
|
22
21
|
def testimonial(packet, opts = {})
|
23
22
|
do_view(packet, :testimonials, opts)
|
24
23
|
end
|
@@ -14,6 +14,22 @@ describe Orange::Application do
|
|
14
14
|
@wibble = true
|
15
15
|
end
|
16
16
|
end
|
17
|
+
# allow deep introspection into rack builder
|
18
|
+
class Rack::Builder
|
19
|
+
attr_accessor :ins
|
20
|
+
# introspection into the Builder object's list of items
|
21
|
+
# builder uses Proc magic to chain the middleware together,
|
22
|
+
# so we undo it.
|
23
|
+
def ins_no_procs
|
24
|
+
@ins.map{|x| x.instance_of?(Proc)? x.call(nil) : x }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
class Orange::Stack
|
28
|
+
attr_accessor :build
|
29
|
+
def middlewarez
|
30
|
+
build.ins_no_procs
|
31
|
+
end
|
32
|
+
end
|
17
33
|
end
|
18
34
|
|
19
35
|
def app
|
@@ -126,6 +142,27 @@ describe Orange::Application do
|
|
126
142
|
}.should change(x, :orange)
|
127
143
|
end
|
128
144
|
|
145
|
+
it "should allow setting the core via #app" do
|
146
|
+
c = Orange::Core.new
|
147
|
+
x= MockApplication.app(c)
|
148
|
+
x.orange.should equal(c)
|
149
|
+
end
|
150
|
+
|
151
|
+
it "should allow setting the core via #stack" do
|
152
|
+
c = Orange::Core.new
|
153
|
+
MockApplication.stack(c) do
|
154
|
+
run MockApplication.new(orange)
|
155
|
+
end
|
156
|
+
x= MockApplication.app
|
157
|
+
x.orange.should equal(c)
|
158
|
+
x.middlewarez.first.orange.should equal(c)
|
159
|
+
p = Orange::Packet.new(c, {'orange.core' => c})
|
160
|
+
Orange::Packet.should_receive(:new).with(c, {'orange.core' => c}).and_return(p)
|
161
|
+
lambda{
|
162
|
+
x.call({}) # We don't care about the error, we care about the should_receive
|
163
|
+
}.should raise_error
|
164
|
+
end
|
165
|
+
|
129
166
|
it "should respond correctly to call" do
|
130
167
|
x= MockApplication.new(Orange::Core.new)
|
131
168
|
lambda{
|
@@ -60,9 +60,11 @@ describe Orange::Core do
|
|
60
60
|
c.loaded?(:parser).should be_true
|
61
61
|
end
|
62
62
|
|
63
|
-
it "should have
|
63
|
+
it "should have two events by default" do
|
64
64
|
c= Orange::Core.new
|
65
|
-
c.events.should have(
|
65
|
+
c.events.should have(2).events
|
66
|
+
c.events.should have_key(:stack_reloading)
|
67
|
+
c.events.should have_key(:stack_loaded)
|
66
68
|
end
|
67
69
|
|
68
70
|
it "should return a directory that contains core.rb when calling core_dir" do
|
@@ -167,7 +169,6 @@ describe Orange::Core do
|
|
167
169
|
|
168
170
|
it "should add event to events list when register called" do
|
169
171
|
c= Orange::Core.new
|
170
|
-
c.events.should be_empty
|
171
172
|
c.register(:mock_event) {|x| x }
|
172
173
|
c.events.should_not be_empty
|
173
174
|
c.events.should have_key(:mock_event)
|
@@ -179,7 +180,6 @@ describe Orange::Core do
|
|
179
180
|
|
180
181
|
it "should add events in specified order when registered with position" do
|
181
182
|
c= Orange::Core.new
|
182
|
-
c.events.should be_empty
|
183
183
|
c.register(:mock_event, 5) {|x| '5' }
|
184
184
|
c.events.should_not be_empty
|
185
185
|
c.events.should have_key(:mock_event)
|
@@ -1,18 +1,18 @@
|
|
1
1
|
describe Orange::Middleware::Base do
|
2
2
|
it "should call init after initializing" do
|
3
3
|
lambda{
|
4
|
-
mid = MockOrangeDeathMiddleware.new(nil,
|
4
|
+
mid = MockOrangeDeathMiddleware.new(nil, Orange::Core.new, :foo => 'bar')
|
5
5
|
}.should raise_error(RuntimeError, "middleware_init with foo=bar")
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should create a packet and call packet call" do
|
9
|
-
mid = MockOrangeBasedMiddlewareTwo.new(nil,
|
9
|
+
mid = MockOrangeBasedMiddlewareTwo.new(nil, Orange::Core.new)
|
10
10
|
mid.should_receive(:packet_call).with(an_instance_of(Orange::Packet))
|
11
11
|
mid.call({})
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should pass the packet on by default for packet_call" do
|
15
|
-
mid = MockOrangeBasedMiddlewareTwo.new(nil,
|
15
|
+
mid = MockOrangeBasedMiddlewareTwo.new(nil, Orange::Core.new)
|
16
16
|
mid.should_receive(:pass).with(an_instance_of(Orange::Packet))
|
17
17
|
mid.packet_call(empty_packet)
|
18
18
|
end
|
@@ -23,8 +23,8 @@ describe Orange::Middleware::Base do
|
|
23
23
|
my_hash = {:foo => :bar}
|
24
24
|
app.should_receive(:call).with(my_hash).and_return([{},200,[]])
|
25
25
|
app2.should_receive(:packet_call).with(an_instance_of(Orange::Packet))
|
26
|
-
mid = MockOrangeBasedMiddlewareTwo.new(app,
|
27
|
-
mid2 = MockOrangeBasedMiddlewareTwo.new(app2,
|
26
|
+
mid = MockOrangeBasedMiddlewareTwo.new(app, Orange::Core.new)
|
27
|
+
mid2 = MockOrangeBasedMiddlewareTwo.new(app2, Orange::Core.new)
|
28
28
|
mid.call(my_hash)
|
29
29
|
mid2.call(my_hash)
|
30
30
|
end
|
@@ -13,6 +13,10 @@ class MockMiddleware
|
|
13
13
|
end
|
14
14
|
|
15
15
|
class MockOrangeBasedMiddlewareTwo < Orange::Middleware::Base; end
|
16
|
+
class MockOrangeBasedMiddlewareThree < Orange::Middleware::Base
|
17
|
+
def stack_init
|
18
|
+
end
|
19
|
+
end
|
16
20
|
class MockOrangeDeathMiddleware < Orange::Middleware::Base
|
17
21
|
def init(*args)
|
18
22
|
opts = args.extract_options!
|
@@ -7,6 +7,18 @@ class MockResource < Orange::Resource
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
+
class MockResourceTwo < Orange::Resource
|
11
|
+
def mock_method
|
12
|
+
'MockResource#mock_method'
|
13
|
+
end
|
14
|
+
def afterLoad
|
15
|
+
@options[:mocked] = true
|
16
|
+
end
|
17
|
+
def stack_init
|
18
|
+
true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
10
22
|
class MockHamlParser < Orange::Resource
|
11
23
|
def haml(template, packet, opts)
|
12
24
|
[template, packet, opts]
|
@@ -44,6 +44,13 @@ describe Orange::Resource do
|
|
44
44
|
me.should equal r
|
45
45
|
end
|
46
46
|
|
47
|
+
it "should register for stack_loaded iff stack_init method present" do
|
48
|
+
c = Orange::Core.new
|
49
|
+
c.should_receive(:register).with(:stack_loaded).once
|
50
|
+
mid1 = c.load MockResource.new
|
51
|
+
mid2 = c.load MockResourceTwo.new
|
52
|
+
end
|
53
|
+
|
47
54
|
it "should return an error if setting orange on a class" do
|
48
55
|
lambda {
|
49
56
|
Orange::Resource.set_orange(Orange::Core.new, :mock)
|
@@ -46,6 +46,17 @@ describe Orange::Stack do
|
|
46
46
|
}.should raise_error(RuntimeError, "Mock Exitware")
|
47
47
|
end
|
48
48
|
|
49
|
+
it "should accept a core object in initialization" do
|
50
|
+
c = Orange::Core.new
|
51
|
+
c2 = Orange::Core.new
|
52
|
+
|
53
|
+
x = Orange::Stack.new(nil, c) do
|
54
|
+
run MockExitware.new
|
55
|
+
end
|
56
|
+
x.orange.should equal(c)
|
57
|
+
x.orange.should_not equal(c2)
|
58
|
+
end
|
59
|
+
|
49
60
|
it "should have the use function" do
|
50
61
|
x= Orange::Stack.new do
|
51
62
|
use MockMiddleware
|
@@ -101,6 +112,27 @@ describe Orange::Stack do
|
|
101
112
|
x.app.should eql(x.app)
|
102
113
|
end
|
103
114
|
|
115
|
+
it "should fire the stack events" do
|
116
|
+
c = Orange::Core.new
|
117
|
+
c2 = Orange::Core.new
|
118
|
+
x= Orange::Stack.new(nil, c) do
|
119
|
+
run MockExitware.new
|
120
|
+
end
|
121
|
+
x2= Orange::Stack.new(nil, c2) do
|
122
|
+
auto_reload!
|
123
|
+
run MockExitware.new
|
124
|
+
end
|
125
|
+
c.should_receive(:fire).with(:stack_loaded, anything()).once
|
126
|
+
c.should_receive(:fire).with(:stack_reloading, anything()).exactly(0).times
|
127
|
+
x.app
|
128
|
+
x.app
|
129
|
+
c2.should_receive(:fire).with(:stack_loaded, anything()).exactly(3).times
|
130
|
+
c2.should_receive(:fire).with(:stack_reloading, anything()).twice
|
131
|
+
x2.app
|
132
|
+
x2.app
|
133
|
+
x2.app
|
134
|
+
end
|
135
|
+
|
104
136
|
it "should rebuild stack if auto_reload! set" do
|
105
137
|
x= Orange::Stack.new do
|
106
138
|
auto_reload!
|
@@ -133,6 +165,22 @@ describe Orange::Stack do
|
|
133
165
|
x.middlewarez.select{|y| y.instance_of?(Orange::Middleware::RouteSite)}.should_not be_empty
|
134
166
|
end
|
135
167
|
|
168
|
+
it "should have routing, postrouting and responder middleware hooks" do
|
169
|
+
x = Orange::Stack.new do
|
170
|
+
run MockExitware.new
|
171
|
+
end
|
172
|
+
x.should respond_to(:routing)
|
173
|
+
x.should respond_to(:postrouting)
|
174
|
+
x.should respond_to(:responders)
|
175
|
+
q = mock(:plugins)
|
176
|
+
plugin = mock(:plugin)
|
177
|
+
Orange.should_receive(:plugins).exactly(3).times.and_return(q)
|
178
|
+
q.should_receive(:each).exactly(3).times.and_return([plugin])
|
179
|
+
x.routing
|
180
|
+
x.postrouting
|
181
|
+
x.responders
|
182
|
+
end
|
183
|
+
|
136
184
|
it "should add one less middleware when calling prerouting with opt :no_abstract_format" do
|
137
185
|
x= Orange::Stack.new do
|
138
186
|
no_recapture
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 10
|
9
|
+
version: 0.1.10
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- David Haslem
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-04-05 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -199,6 +199,7 @@ files:
|
|
199
199
|
- lib/orange-more/sitemap/middleware/flex_router.rb
|
200
200
|
- lib/orange-more/sitemap/plugin.rb
|
201
201
|
- lib/orange-more/sitemap/resources/sitemap_resource.rb
|
202
|
+
- lib/orange-more/sitemap/views/default_resource/sitemap_row.haml
|
202
203
|
- lib/orange-more/sitemap/views/sitemap/list.haml
|
203
204
|
- lib/orange-more/sitemap/views/sitemap/route_actions.haml
|
204
205
|
- lib/orange-more/sitemap/views/sitemap/sitemap_links.haml
|