orange 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +1 -1
- data/lib/orange-core/middleware/database.rb +22 -3
- data/lib/orange-core/middleware/globals.rb +2 -3
- data/lib/orange-core/packet.rb +34 -0
- data/lib/orange-core/resources/page_parts.rb +2 -2
- data/lib/orange-more.rb +5 -1
- data/lib/orange-more/administration/middleware/access_control.rb +2 -1
- data/lib/orange-more/administration/resources/user_resource.rb +4 -0
- data/lib/orange-more/assets/resources/asset_resource.rb +1 -1
- data/lib/orange-more/blog.rb +1 -0
- data/lib/orange-more/blog/cartons/blog.rb +10 -0
- data/lib/orange-more/blog/cartons/blog_post.rb +55 -0
- data/lib/orange-more/blog/plugin.rb +14 -0
- data/lib/orange-more/blog/resources/blog_post_resource.rb +57 -0
- data/lib/orange-more/blog/resources/blog_resource.rb +99 -0
- data/lib/orange-more/blog/views/blog/blog_archive_view.haml +6 -0
- data/lib/orange-more/blog/views/blog/blog_offset_list_view.haml +12 -0
- data/lib/orange-more/blog/views/blog/blog_post_view.haml +4 -0
- data/lib/orange-more/blog/views/blog/sitemap_row.haml +14 -0
- data/lib/orange-more/blog/views/blog_posts/edit.haml +8 -0
- data/lib/orange-more/cloud.rb +1 -0
- data/lib/orange-more/cloud/plugin.rb +10 -0
- data/lib/orange-more/cloud/resources/cloud_resource.rb +22 -0
- data/lib/orange-more/debugger.rb +1 -0
- data/lib/orange-more/debugger/assets/css/debug_bar.css +46 -0
- data/lib/orange-more/debugger/middleware/debugger.rb +35 -0
- data/lib/orange-more/debugger/plugin.rb +12 -0
- data/lib/orange-more/debugger/views/debug_bar.haml +64 -0
- data/lib/orange-more/disqus.rb +1 -0
- data/lib/orange-more/disqus/plugin.rb +11 -0
- data/lib/orange-more/disqus/resources/disqus_resource.rb +9 -0
- data/lib/orange-more/disqus/views/disqus/comment_thread.haml +7 -0
- data/lib/orange-more/sitemap/resources/sitemap_resource.rb +30 -2
- data/lib/orange-more/sitemap/views/sitemap/route_actions.haml +15 -0
- data/lib/orange-more/sitemap/views/sitemap/two_level.haml +3 -2
- data/lib/orange-more/slices/resources/radius.rb +1 -0
- metadata +26 -2
data/README.markdown
CHANGED
@@ -6,7 +6,7 @@ and the power of Rails. Orange is being developed by Orange Sparkle Ball, inc
|
|
6
6
|
for our own use. Our main focus is on creating a super-extensible CMS
|
7
7
|
with Orange, but we're trying to make the components as reusable as possible. Our
|
8
8
|
intention is to be ready to use Orange for most client website builds by
|
9
|
-
|
9
|
+
May 2010.
|
10
10
|
|
11
11
|
**Note**: Orange is still in the alpha stage. Test coverage is lack-luster at best.
|
12
12
|
Tread carefully.
|
@@ -2,12 +2,23 @@ require 'orange-core/middleware/base'
|
|
2
2
|
module Orange::Middleware
|
3
3
|
|
4
4
|
class Database < Base
|
5
|
-
def init(
|
5
|
+
def init(opts = {})
|
6
|
+
opts = opts.with_defaults(:migration_url => (orange.options[:development_mode] ? '/__ORANGE_DB__/migrate' : false))
|
6
7
|
orange.mixin Orange::Mixins::DBLoader
|
8
|
+
orange.register(:stack_loaded) do |stack|
|
9
|
+
db = orange.options['database'] || 'sqlite3::memory:'
|
10
|
+
orange.load_db!(db)
|
11
|
+
orange.upgrade_db!
|
12
|
+
end
|
13
|
+
@options = opts
|
7
14
|
end
|
8
15
|
def packet_call(packet)
|
9
|
-
|
10
|
-
|
16
|
+
path = packet['route.path'] || packet.request.path_info
|
17
|
+
if @options[:migration_url] && @options[:migration_url] == path
|
18
|
+
orange.migrate_db!
|
19
|
+
after = packet.session['flash.redirect_to'] ? packet.session['flash.redirect_to'] : '/'
|
20
|
+
packet.reroute(after)
|
21
|
+
end
|
11
22
|
pass packet
|
12
23
|
end
|
13
24
|
end
|
@@ -17,6 +28,14 @@ end
|
|
17
28
|
module Orange::Mixins::DBLoader
|
18
29
|
def load_db!(url)
|
19
30
|
DataMapper.setup(:default, url)
|
31
|
+
end
|
32
|
+
|
33
|
+
def migrate_db!
|
34
|
+
DataMapper.auto_migrate!
|
35
|
+
end
|
36
|
+
|
37
|
+
def upgrade_db!
|
20
38
|
DataMapper.auto_upgrade!
|
21
39
|
end
|
40
|
+
|
22
41
|
end
|
@@ -6,11 +6,10 @@ module Orange::Middleware
|
|
6
6
|
opts = args.extract_options!.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
10
|
end
|
10
11
|
def packet_call(packet)
|
11
|
-
|
12
|
-
globs.merge! orange.options
|
13
|
-
packet['orange.globals'] = globs.merge @globals
|
12
|
+
packet['orange.globals'] ||= orange.options
|
14
13
|
pass packet
|
15
14
|
end
|
16
15
|
|
data/lib/orange-core/packet.rb
CHANGED
@@ -167,6 +167,40 @@ module Orange
|
|
167
167
|
router.route(self)
|
168
168
|
end
|
169
169
|
|
170
|
+
# Pulls options set out of the packet and places them into
|
171
|
+
# a hash. Options are retrieved from POST, GET, and route.resource_path
|
172
|
+
# and take that order of precedence (POST overrides GET, etc)
|
173
|
+
# @param [Array] key_list an array of keys to retrieve and merge together
|
174
|
+
# in order of precedence. :GET and :POST for request vars, the rest
|
175
|
+
# are keys directly available on packet
|
176
|
+
# @return [Hash] A hash of options set in the packet
|
177
|
+
def extract_opts(key_list = [:POST, :GET, 'route.resource_path'])
|
178
|
+
opts = {}
|
179
|
+
key_list.reverse.each do |key|
|
180
|
+
case key
|
181
|
+
when :GET then opts.merge! packet.request.GET
|
182
|
+
when :POST then opts.merge! packet.request.POST
|
183
|
+
else
|
184
|
+
opts.merge!(packet[key, {}].kind_of?(String) ? url_to_hash(packet[key]) : packet[key, {}])
|
185
|
+
end
|
186
|
+
end
|
187
|
+
opts
|
188
|
+
end
|
189
|
+
|
190
|
+
# Converts a url path to a hash with symbol keys. URL must
|
191
|
+
# be in /key/val/key/val/etc format
|
192
|
+
def url_to_hash(url)
|
193
|
+
parts = url.split('/')
|
194
|
+
hash = {}
|
195
|
+
while !parts.blank?
|
196
|
+
key = parts.shift
|
197
|
+
key = parts.shift if key.blank?
|
198
|
+
val = parts.shift
|
199
|
+
hash[key.to_sym] = val unless key.blank? or val.blank?
|
200
|
+
end
|
201
|
+
hash
|
202
|
+
end
|
203
|
+
|
170
204
|
# Method Missing allows defining custom methods
|
171
205
|
def method_missing(id, *args)
|
172
206
|
matched = false
|
@@ -27,7 +27,7 @@ module Orange
|
|
27
27
|
part(packet)[:css] = part(packet)[:css] + "<link rel=\"stylesheet\" href=\"#{file}\" type=\"text/css\" media=\"screen\" charset=\"utf-8\" />"
|
28
28
|
end
|
29
29
|
packet[:css_files] ||= []
|
30
|
-
packet[:css_files]
|
30
|
+
packet[:css_files].insert((opts[:position] ? opts[:position] : -1), file)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -43,7 +43,7 @@ module Orange
|
|
43
43
|
part(packet)[:js] = part(packet)[:js] + "<script src=\"#{file}\" type=\"text/javascript\"></script>"
|
44
44
|
end
|
45
45
|
packet[:js_files] ||= []
|
46
|
-
packet[:js_files]
|
46
|
+
packet[:js_files].insert((opts[:position] ? opts[:position] : -1), file)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
data/lib/orange-more.rb
CHANGED
@@ -7,4 +7,8 @@ require File.join(libdir, 'orange-more', 'administration')
|
|
7
7
|
require File.join(libdir, 'orange-more', 'assets')
|
8
8
|
require File.join(libdir, 'orange-more', 'pages')
|
9
9
|
require File.join(libdir, 'orange-more', 'sitemap')
|
10
|
-
require File.join(libdir, 'orange-more', 'slices')
|
10
|
+
require File.join(libdir, 'orange-more', 'slices')
|
11
|
+
require File.join(libdir, 'orange-more', 'blog')
|
12
|
+
require File.join(libdir, 'orange-more', 'disqus')
|
13
|
+
require File.join(libdir, 'orange-more', 'cloud')
|
14
|
+
require File.join(libdir, 'orange-more', 'debugger')
|
@@ -32,6 +32,7 @@ module Orange::Middleware
|
|
32
32
|
|
33
33
|
def packet_call(packet)
|
34
34
|
packet['user.id'] ||= (packet.session['user.id'] || false)
|
35
|
+
packet['user'] = orange[:users].user_for(packet) unless packet['user.id'].blank?
|
35
36
|
if @openid && need_to_handle?(packet)
|
36
37
|
ret = handle_openid(packet)
|
37
38
|
return ret unless ret.blank? # unless handle_openid returns false, exit immediately
|
@@ -46,7 +47,7 @@ module Orange::Middleware
|
|
46
47
|
|
47
48
|
def access_allowed?(packet)
|
48
49
|
return true unless @locked.include?(packet['route.context'])
|
49
|
-
if packet['user.id']
|
50
|
+
if packet['user.id'] || packet['orange.globals']['main_user'] == false
|
50
51
|
if @single && (packet['user.id'] == packet['orange.globals']['main_user'])
|
51
52
|
true
|
52
53
|
elsif @single
|
@@ -6,7 +6,7 @@ module Orange
|
|
6
6
|
def afterLoad
|
7
7
|
orange[:admin, true].add_link("Content", :resource => @my_orange_name, :text => 'Assets')
|
8
8
|
orange.register(:stack_loaded) do
|
9
|
-
orange[:radius].context.define_tag "asset" do |tag|
|
9
|
+
orange[:radius, true].context.define_tag "asset" do |tag|
|
10
10
|
if tag.attr['id']
|
11
11
|
(m = model_class.first(:id => tag.attr['id'])) ? m.to_asset_tag : 'Invalid Asset'
|
12
12
|
else
|
@@ -0,0 +1 @@
|
|
1
|
+
require File.join('orange-more', 'blog', 'plugin')
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'dm-timestamps'
|
2
|
+
module Orange
|
3
|
+
class BlogPost < Orange::Carton
|
4
|
+
id
|
5
|
+
front do
|
6
|
+
title :title
|
7
|
+
fulltext :body
|
8
|
+
end
|
9
|
+
admin do
|
10
|
+
fulltext :summary
|
11
|
+
end
|
12
|
+
orange do
|
13
|
+
boolean :published, :default => false
|
14
|
+
text :slug
|
15
|
+
text :author
|
16
|
+
end
|
17
|
+
|
18
|
+
property :created_at, DateTime
|
19
|
+
property :published_at, DateTime
|
20
|
+
property :updated_at, DateTime
|
21
|
+
belongs_to :blog, "Orange::Blog"
|
22
|
+
|
23
|
+
def title=(t)
|
24
|
+
self.attribute_set('title', t)
|
25
|
+
self.attribute_set('slug', t.downcase.gsub(/[^a-z0-9-]+$/, ''))
|
26
|
+
end
|
27
|
+
|
28
|
+
def publish
|
29
|
+
self.published_at = Time.now
|
30
|
+
self.published = true
|
31
|
+
end
|
32
|
+
|
33
|
+
def publish!
|
34
|
+
self.published_at = Time.now
|
35
|
+
self.published = true
|
36
|
+
self.save
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.year_and_month(yr, mnth)
|
40
|
+
all(:published_at.gte => DateTime.new(yr, mnth, 1), :published_at.lt => DateTime.new(yr, mnth + 1, 1))
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.slug(slug)
|
44
|
+
first(:slug => slug)
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.published
|
48
|
+
all(:published => true)
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.draft
|
52
|
+
all(:published => false)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Dir.glob(File.join(File.dirname(__FILE__), 'cartons', '*.rb')).each {|f| require f }
|
2
|
+
Dir.glob(File.join(File.dirname(__FILE__), 'resources', '*.rb')).each {|f| require f }
|
3
|
+
|
4
|
+
module Orange::Plugins
|
5
|
+
class Blog < Base
|
6
|
+
views_dir File.join(File.dirname(__FILE__), 'views')
|
7
|
+
|
8
|
+
resource Orange::BlogResource.new
|
9
|
+
resource Orange::BlogPostResource.new
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
Orange.plugin(Orange::Plugins::Blog.new)
|
14
|
+
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Orange
|
2
|
+
class BlogResource < Orange::ModelResource
|
3
|
+
use Orange::BlogPost
|
4
|
+
call_me :blog_posts
|
5
|
+
def afterLoad
|
6
|
+
orange[:admin, true].add_link("Content", :resource => @my_orange_name, :text => 'Blog')
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
def publish(packet, *opts)
|
11
|
+
if packet.request.post?
|
12
|
+
m = model_class.get(packet['route.resource_id'])
|
13
|
+
if m
|
14
|
+
# orange[:cloud, true].microblog(packet, "I just posted a test blog post.")
|
15
|
+
m.publish!
|
16
|
+
end
|
17
|
+
end
|
18
|
+
packet.reroute(@my_orange_name, :orange)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Creates a new model object and saves it (if a post), then reroutes to the main page
|
22
|
+
# @param [Orange::Packet] packet the packet being routed
|
23
|
+
def new(packet, *opts)
|
24
|
+
if packet.request.post?
|
25
|
+
params = packet.request.params[@my_orange_name.to_s]
|
26
|
+
params[:published] = false
|
27
|
+
params[:author] = packet['user', false] ? packet['user'].name : "Author"
|
28
|
+
|
29
|
+
blog = Orange::Blog.first(:orange_site => packet['site'])
|
30
|
+
blog.posts.new(params)
|
31
|
+
blog.save
|
32
|
+
end
|
33
|
+
packet.reroute(@my_orange_name, :orange)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Saves updates to an object specified by packet['route.resource_id'], then reroutes to main
|
37
|
+
# @param [Orange::Packet] packet the packet being routed
|
38
|
+
def save(packet, *opts)
|
39
|
+
if packet.request.post?
|
40
|
+
m = model_class.get(packet['route.resource_id'])
|
41
|
+
if m
|
42
|
+
params = packet.request.params[@my_orange_name.to_s]
|
43
|
+
m.update(params)
|
44
|
+
m.blog = Orange::Blog.first(:orange_site => packet['site'])
|
45
|
+
m.save
|
46
|
+
end
|
47
|
+
end
|
48
|
+
packet.reroute(@my_orange_name, :orange)
|
49
|
+
end
|
50
|
+
|
51
|
+
def find_list(packet, mode, id =false)
|
52
|
+
blog = orange[:blog].blog_for_site(packet, packet['site'].id)
|
53
|
+
blog.posts
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
module Orange
|
2
|
+
class BlogPostResource < Orange::ModelResource
|
3
|
+
use Orange::Blog
|
4
|
+
call_me :blog
|
5
|
+
def afterLoad
|
6
|
+
orange[:admin, true].add_link("Settings", :resource => @my_orange_name, :text => 'Blog')
|
7
|
+
end
|
8
|
+
|
9
|
+
def sitemap_row(packet, opts = {})
|
10
|
+
do_view(packet, :sitemap_row, opts)
|
11
|
+
end
|
12
|
+
|
13
|
+
def blog_view(packet, opts = {})
|
14
|
+
resource_path = packet['route.resource_path']
|
15
|
+
if resource_path.blank?
|
16
|
+
blog_list_view(packet, opts)
|
17
|
+
elsif resource_path =~ /^\/page/
|
18
|
+
blog_offset_list_view(packet, opts)
|
19
|
+
elsif resource_path =~ /^\/archives?/
|
20
|
+
blog_archive_view(packet, opts)
|
21
|
+
else
|
22
|
+
blog_post_view(packet, opts)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def blog_post_view(packet, opts = {})
|
27
|
+
resource_path = packet['route.resource_path']
|
28
|
+
blog = Orange::Blog.first(:orange_site_id => packet['site'].id)
|
29
|
+
opts.merge!( :blog_url => blog_url_for(packet))
|
30
|
+
parts = resource_path.split('/')
|
31
|
+
unless parts.size < 4
|
32
|
+
post = blog.posts.year_and_month(parts[1].to_i, parts[2].to_i).slug(parts[3])
|
33
|
+
end
|
34
|
+
if post
|
35
|
+
do_view(packet, :blog_post_view, opts.merge({:model => post}))
|
36
|
+
else
|
37
|
+
"Not found"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def blog_url_for(packet)
|
42
|
+
blog = Orange::Blog.first(:orange_site_id => packet['site'].id)
|
43
|
+
blog_url = orange[:sitemap, true].url_for(packet, :orange_site_id => blog.orange_site_id, :resource => :blog, :resource_id => blog.id, :resource_action => :blog_view)
|
44
|
+
blog_url.gsub!(/\/$/, '')
|
45
|
+
end
|
46
|
+
|
47
|
+
def blog_offset_list_view(packet, opts = {})
|
48
|
+
opts.merge!(packet.extract_opts)
|
49
|
+
opts.merge!( :blog_url => blog_url_for(packet))
|
50
|
+
blog = Orange::Blog.first(:orange_site_id => packet['site'].id)
|
51
|
+
opts[:page] = opts[:page].to_i unless opts[:page].blank?
|
52
|
+
page = opts[:page].blank? ? 0 : opts[:page] - 1
|
53
|
+
opts[:list] = blog.posts.published.all(:order => :published_at.desc,
|
54
|
+
:limit => 5,
|
55
|
+
:offset => (5*page)
|
56
|
+
)
|
57
|
+
opts[:pages] = (blog.posts.published.count / 5) + 1
|
58
|
+
do_list_view(packet, :blog_offset_list_view, opts)
|
59
|
+
end
|
60
|
+
|
61
|
+
def blog_list_view(packet, opts = {})
|
62
|
+
blog_offset_list_view(packet, opts.merge!({:page => 1}))
|
63
|
+
end
|
64
|
+
|
65
|
+
def blog_archive_view(packet, opts = {})
|
66
|
+
opts.merge!( :blog_url => blog_url_for(packet))
|
67
|
+
do_list_view(packet, :blog_archive_view, opts)
|
68
|
+
end
|
69
|
+
|
70
|
+
def blog_for_site(packet, site_id)
|
71
|
+
blog = Orange::Blog.first(:orange_site_id => packet['site'].id)
|
72
|
+
unless blog
|
73
|
+
blog = Orange::Blog.new
|
74
|
+
blog.title = 'An Orange Hosted Blog'
|
75
|
+
blog.orange_site = packet['site']
|
76
|
+
blog.save
|
77
|
+
orange[:sitemap, true].add_route_for(packet,
|
78
|
+
:orange_site_id => packet['site'].id,
|
79
|
+
:resource => :blog,
|
80
|
+
:resource_id => blog.id,
|
81
|
+
:resource_action => :blog_view,
|
82
|
+
:slug => 'blog',
|
83
|
+
:link_text => 'Orange Blog'
|
84
|
+
)
|
85
|
+
end
|
86
|
+
blog
|
87
|
+
end
|
88
|
+
|
89
|
+
def find_list(packet, mode, id =false)
|
90
|
+
blog = orange[:blog].blog_for_site(packet, packet['site'].id)
|
91
|
+
case mode
|
92
|
+
when :blog_list_view then blog.posts.published.all(:order => :published_at.desc, :limit => 5)
|
93
|
+
when :blog_archive_view then blog.posts.published
|
94
|
+
else Orange::Blog.all
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
.blog_posts
|
2
|
+
- for post in list
|
3
|
+
.blog_post
|
4
|
+
%h2
|
5
|
+
%a{:href => "#{blog_url}/#{post.created_at.year}/#{post.created_at.month}/#{post.slug}"}= post.title
|
6
|
+
%h3.posted_by Posted by #{post.author}
|
7
|
+
.blog_post_body= post.summary.blank? ? post.body : post.summary
|
8
|
+
.blog_nav
|
9
|
+
- if page > 1
|
10
|
+
%a.newer{:href => "#{blog_url}/page/#{page-1}"} Newer Posts
|
11
|
+
- if page < pages
|
12
|
+
%a.older{:href => "#{blog_url}/page/#{page+1}"} Older Posts
|
@@ -0,0 +1,14 @@
|
|
1
|
+
- if route
|
2
|
+
.sitemap_item{:class => "sitemap_level_#{route.level}"}
|
3
|
+
- if route.level > 0
|
4
|
+
= orange[:sitemap].route_actions(packet, :model => route)
|
5
|
+
%h4 #{route.link_text} <span>(#{route.full_path})</span>
|
6
|
+
.linked_to
|
7
|
+
%p
|
8
|
+
Blog titled "#{model.title}"
|
9
|
+
%br
|
10
|
+
%a{:href => route_to(:blog_posts, 'create')} Add New Blog Post
|
11
|
+
.actions
|
12
|
+
= form_link('Delete', route_to(:sitemap, route.id, 'delete'), 'Are you sure you want to delete this?', {:method => 'delete'})
|
13
|
+
%a{:href => route_to(:sitemap, route.id, 'edit')} Edit
|
14
|
+
%br.clear
|
@@ -0,0 +1,8 @@
|
|
1
|
+
- if model
|
2
|
+
%form{:action => route_to(model_name, model[:id], 'save'), :method => 'post'}
|
3
|
+
- for prop in props
|
4
|
+
%p~ view_attribute(prop, model_name, :label => true, :value => model.attribute_get(prop[:name]))
|
5
|
+
%input{:type => 'submit', :value => 'Save Changes'}
|
6
|
+
= form_link('Publish', packet.route_to(model_name, model[:id], 'publish'))
|
7
|
+
- else
|
8
|
+
%p Couldn't find the item you're looking for.
|
@@ -0,0 +1 @@
|
|
1
|
+
require File.join('orange-more', 'cloud', 'plugin')
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rest_client'
|
2
|
+
|
3
|
+
module Orange
|
4
|
+
class CloudResource < Orange::Resource
|
5
|
+
ORANGE_PING_KEY = "c99550a0430eb9054eb4b7ee290664cf"
|
6
|
+
call_me :cloud
|
7
|
+
def afterLoad
|
8
|
+
orange.register(:stack_loaded) do |stack|
|
9
|
+
options[:ping_fm_key] = orange.options[:ping_fm_key] || false
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def microblog(packet, status, opts = {})
|
14
|
+
params = { :api_key => ORANGE_PING_KEY,
|
15
|
+
:user_app_key => options[:ping_fm_key],
|
16
|
+
:post_method => "microblog",
|
17
|
+
:body => status}.merge(opts)
|
18
|
+
# Thread.new {
|
19
|
+
xml_result = RestClient.post("http://api.ping.fm/v1/user.post", params) if params[:user_app_key]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require File.join('orange-more', 'debugger', 'plugin')
|
@@ -0,0 +1,46 @@
|
|
1
|
+
/* @override http://localhost:4321/assets/_debugger_/css/debug_bar.css */
|
2
|
+
|
3
|
+
body{
|
4
|
+
margin: 0;
|
5
|
+
margin-bottom: 500px;
|
6
|
+
}
|
7
|
+
#debug_bar{
|
8
|
+
position: fixed;
|
9
|
+
bottom: 0;
|
10
|
+
background-color: #333;
|
11
|
+
width: 100%;
|
12
|
+
font: medium "Lucida Grande", Lucida, Verdana, sans-serif;
|
13
|
+
}
|
14
|
+
#debug_bar h1{
|
15
|
+
margin-left: 1em;
|
16
|
+
font-size: 1em;
|
17
|
+
display: inline-block;
|
18
|
+
color: #eb8336;
|
19
|
+
}
|
20
|
+
|
21
|
+
#debug_bar ul{
|
22
|
+
display: inline-block;
|
23
|
+
list-style: none;
|
24
|
+
margin: 0;
|
25
|
+
}
|
26
|
+
|
27
|
+
#debug_bar ul li{
|
28
|
+
display: inline-block;
|
29
|
+
margin: 1em;
|
30
|
+
}
|
31
|
+
|
32
|
+
#debug_bar ul li a{
|
33
|
+
color: white;
|
34
|
+
}
|
35
|
+
#debug_bar #requestinfo{
|
36
|
+
display: none;
|
37
|
+
height: 300px;
|
38
|
+
overflow: auto;
|
39
|
+
background: white;
|
40
|
+
margin: 2em 3em;
|
41
|
+
padding: 1em 3em;
|
42
|
+
}
|
43
|
+
|
44
|
+
#debug_bar #requestinfo.show{
|
45
|
+
display: block;
|
46
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'orange-core/middleware/base'
|
2
|
+
|
3
|
+
module Orange::Middleware
|
4
|
+
class Debugger < Base
|
5
|
+
def init(opts = {})
|
6
|
+
orange.add_pulp Orange::Pulp::DebuggerHelpers if orange.options[:development_mode]
|
7
|
+
end
|
8
|
+
|
9
|
+
# Passes packet then parses the return
|
10
|
+
def packet_call(packet)
|
11
|
+
if orange.options[:development_mode]
|
12
|
+
packet.session['flash.redirect_to'] = packet.request.path
|
13
|
+
packet.add_css('debug_bar.css', :module => '_debugger_')
|
14
|
+
end
|
15
|
+
pass packet
|
16
|
+
if orange.options[:development_mode]
|
17
|
+
bar = orange[:parser].haml('debug_bar.haml', packet)
|
18
|
+
packet[:content] = packet[:content].gsub('</body>', bar + '</body>')
|
19
|
+
end
|
20
|
+
packet.finish
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
module Orange::Pulp::DebuggerHelpers
|
27
|
+
def h(obj) # :nodoc:
|
28
|
+
case obj
|
29
|
+
when String
|
30
|
+
Rack::Utils.escape_html(obj)
|
31
|
+
else
|
32
|
+
Rack::Utils.escape_html(obj.inspect)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Dir.glob(File.join(File.dirname(__FILE__), 'middleware', '*.rb')).each {|f| require f }
|
2
|
+
|
3
|
+
module Orange::Plugins
|
4
|
+
class Debugger < Base
|
5
|
+
views_dir File.join(File.dirname(__FILE__), 'views')
|
6
|
+
assets_dir File.join(File.dirname(__FILE__), 'assets')
|
7
|
+
prerouter Orange::Middleware::Debugger
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
Orange.plugin(Orange::Plugins::Debugger.new)
|
12
|
+
|
@@ -0,0 +1,64 @@
|
|
1
|
+
#debug_bar
|
2
|
+
%h1 Debugger
|
3
|
+
%ul
|
4
|
+
%li
|
5
|
+
%a.requestinfo{:href => '#', :onclick => 'jQuery("#debug_bar #requestinfo").toggleClass("show"); return false'} Request Info
|
6
|
+
%li
|
7
|
+
%a{:href => '/__ORANGE_DB__/migrate'} Reinitialize Database
|
8
|
+
#requestinfo
|
9
|
+
%h2 Request information
|
10
|
+
- for var in [:GET, :POST, :cookies]
|
11
|
+
%h3{:id => "#{var.to_s.downcase}-info"}= "#{var.to_s}"
|
12
|
+
- unless packet.request.__send__(var).empty?
|
13
|
+
%table.req
|
14
|
+
%thead
|
15
|
+
%tr
|
16
|
+
%th Variable
|
17
|
+
%th Value
|
18
|
+
%tbody
|
19
|
+
- packet.request.__send__(var).sort_by { |k, v| k.to_s }.each do |key, val|
|
20
|
+
%tr
|
21
|
+
%td #{key}
|
22
|
+
%td.code
|
23
|
+
%div #{val.inspect}
|
24
|
+
- else
|
25
|
+
%p No #{var.to_s} data.
|
26
|
+
%h3#env-info Rack ENV
|
27
|
+
%table.req
|
28
|
+
%thead
|
29
|
+
%tr
|
30
|
+
%th Variable
|
31
|
+
%th Value
|
32
|
+
%tbody
|
33
|
+
- packet.env.sort_by { |k, v| k.to_s }.each do |key, val|
|
34
|
+
- unless key =~ /^orange\./
|
35
|
+
%tr
|
36
|
+
%td #{h key}
|
37
|
+
%td.code
|
38
|
+
%div #{h val}
|
39
|
+
%h3#orange-info Orange ENV
|
40
|
+
%table.req
|
41
|
+
%thead
|
42
|
+
%tr
|
43
|
+
%th Variable
|
44
|
+
%th Value
|
45
|
+
%tbody
|
46
|
+
- packet.env['orange.env'].sort_by { |k, v| k.to_s }.each do |key, val|
|
47
|
+
- if(![:request, :headers, :content].include?(key))
|
48
|
+
%tr
|
49
|
+
%td #{h key}
|
50
|
+
%td.code
|
51
|
+
%div #{h val}
|
52
|
+
%h3#orange-info= 'Orange<br /> Response'
|
53
|
+
%table.req
|
54
|
+
%thead
|
55
|
+
%tr
|
56
|
+
%th Variable
|
57
|
+
%th Value
|
58
|
+
%tbody
|
59
|
+
- packet.env['orange.env'].sort_by { |k, v| k.to_s }.each do |key, val|
|
60
|
+
- if([:headers, :content].include?(key))
|
61
|
+
%tr
|
62
|
+
%td #{h key}
|
63
|
+
%td.code
|
64
|
+
%div #{h val}
|
@@ -0,0 +1 @@
|
|
1
|
+
require File.join('orange-more', 'disqus', 'plugin')
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Dir.glob(File.join(File.dirname(__FILE__), 'resources', '*.rb')).each {|f| require f }
|
2
|
+
|
3
|
+
module Orange::Plugins
|
4
|
+
class Disqus < Base
|
5
|
+
views_dir File.join(File.dirname(__FILE__), 'views')
|
6
|
+
resource Orange::DisqusResource.new
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
Orange.plugin(Orange::Plugins::Disqus.new)
|
11
|
+
|
@@ -0,0 +1,7 @@
|
|
1
|
+
.disqus_comments
|
2
|
+
- if packet['orange.globals'][:development_mode]
|
3
|
+
%script{:type => 'text/javascript'} var disqus_developer = 1;
|
4
|
+
#disqus_thread
|
5
|
+
%script{:type => 'text/javascript', :src => 'http://disqus.com/forums/orangesparkleball/embed.js'}
|
6
|
+
%noscript
|
7
|
+
%a{:href => 'http://disqus.com/forums/orangesparkleball/?url=ref'} View the discussion thread
|
@@ -9,6 +9,9 @@ module Orange
|
|
9
9
|
orange[:admin, true].add_link('Content', :resource => @my_orange_name, :text => 'Sitemap')
|
10
10
|
|
11
11
|
end
|
12
|
+
def route_actions(packet, opts = {})
|
13
|
+
do_view(packet, :route_actions, opts)
|
14
|
+
end
|
12
15
|
|
13
16
|
def route(packet)
|
14
17
|
resource = packet['route.resource']
|
@@ -90,8 +93,8 @@ module Orange
|
|
90
93
|
packet.reroute(@my_orange_name, :orange)
|
91
94
|
end
|
92
95
|
|
93
|
-
def home(packet)
|
94
|
-
site_id = packet['site'].id
|
96
|
+
def home(packet, opts = {})
|
97
|
+
site_id = opts[:orange_site_id] || packet['site'].id
|
95
98
|
model_class.home_for_site(site_id) || model_class.create_home_for_site(site_id)
|
96
99
|
end
|
97
100
|
|
@@ -115,6 +118,19 @@ module Orange
|
|
115
118
|
packet.route_to(:sitemap, linky.join('/') )
|
116
119
|
end
|
117
120
|
|
121
|
+
def add_route_for(packet, opts = {})
|
122
|
+
unless opts.blank?
|
123
|
+
me = model_class.new(opts)
|
124
|
+
me.save
|
125
|
+
me.move(:into => home(packet, opts))
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def url_for(packet, opts = {})
|
130
|
+
m = model_class.first(opts)
|
131
|
+
m ? m.full_path : '#not_found'
|
132
|
+
end
|
133
|
+
|
118
134
|
def add_route(packet, opts = {})
|
119
135
|
args = packet['route.resource_path'].split('/')
|
120
136
|
args.shift
|
@@ -143,6 +159,18 @@ module Orange
|
|
143
159
|
home(packet).self_and_descendants
|
144
160
|
end
|
145
161
|
|
162
|
+
def table_row(packet, opts ={})
|
163
|
+
opts[:route] = opts[:model] || find_one(packet, :table_row, opts[:id])
|
164
|
+
resource = opts[:route].resource
|
165
|
+
resource = resource.to_sym if resource
|
166
|
+
if resource && orange[resource].respond_to?(:sitemap_row)
|
167
|
+
opts.delete(:model)
|
168
|
+
orange[resource].sitemap_row(packet, opts.merge(:resource_name => resource, :id => opts[:route].resource_id))
|
169
|
+
else
|
170
|
+
do_view(packet, :table_row, opts)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
146
174
|
def sitemap_links(packet, opts = {})
|
147
175
|
packet.add_js('sitemap.js', :module => '_orange_')
|
148
176
|
opts.with_defaults!({:list => routes_for(packet) })
|
@@ -0,0 +1,15 @@
|
|
1
|
+
.move_actions.dent_actions
|
2
|
+
= form_link('Outdent', route_to(:sitemap, model.id, 'outdent'), false, {:method => 'post', :class => 'outdent arrow'}) if model.level > 1
|
3
|
+
%p= ' '
|
4
|
+
.move_actions
|
5
|
+
- if model.previous_sibling
|
6
|
+
= form_link('Up', route_to(:sitemap, model.id, 'higher'), false, {:method => 'post', :class => 'up arrow'})
|
7
|
+
- else
|
8
|
+
%p.disabled_up.arrow= ' '
|
9
|
+
- if model.next_sibling
|
10
|
+
= form_link('Down', route_to(:sitemap, model.id, 'lower'), false, {:method => 'post', :class => 'down arrow'})
|
11
|
+
- else
|
12
|
+
%p.disabled_down.arrow= ' '
|
13
|
+
.move_actions.dent_actions
|
14
|
+
= form_link('Indent', route_to(:sitemap, model.id, 'indent'), false, {:method => 'post', :class => 'indent arrow'}) if model.previous_sibling && model.previous_sibling.level == model.level
|
15
|
+
%p= ' '
|
@@ -1,11 +1,12 @@
|
|
1
1
|
%ul.nav
|
2
2
|
%li.first
|
3
3
|
%a{:href => model.full_path} Home
|
4
|
-
- for item in model.
|
4
|
+
- for item in model.children
|
5
|
+
- next unless item.show_in_nav
|
5
6
|
%li
|
6
7
|
%a{:href => item.full_path}= item.link_text
|
7
8
|
- unless item.descendants.empty?
|
8
9
|
%ul.subnav
|
9
|
-
- for x in item.
|
10
|
+
- for x in item.children
|
10
11
|
%li
|
11
12
|
%a{:href => x.full_path}= x.link_text
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: orange
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Haslem
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02-
|
12
|
+
date: 2010-02-26 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -121,6 +121,29 @@ files:
|
|
121
121
|
- lib/orange-more/assets/plugin.rb
|
122
122
|
- lib/orange-more/assets/resources/asset_resource.rb
|
123
123
|
- lib/orange-more/assets/views/assets/create.haml
|
124
|
+
- lib/orange-more/blog.rb
|
125
|
+
- lib/orange-more/blog/cartons/blog.rb
|
126
|
+
- lib/orange-more/blog/cartons/blog_post.rb
|
127
|
+
- lib/orange-more/blog/plugin.rb
|
128
|
+
- lib/orange-more/blog/resources/blog_post_resource.rb
|
129
|
+
- lib/orange-more/blog/resources/blog_resource.rb
|
130
|
+
- lib/orange-more/blog/views/blog/blog_archive_view.haml
|
131
|
+
- lib/orange-more/blog/views/blog/blog_offset_list_view.haml
|
132
|
+
- lib/orange-more/blog/views/blog/blog_post_view.haml
|
133
|
+
- lib/orange-more/blog/views/blog/sitemap_row.haml
|
134
|
+
- lib/orange-more/blog/views/blog_posts/edit.haml
|
135
|
+
- lib/orange-more/cloud.rb
|
136
|
+
- lib/orange-more/cloud/plugin.rb
|
137
|
+
- lib/orange-more/cloud/resources/cloud_resource.rb
|
138
|
+
- lib/orange-more/debugger.rb
|
139
|
+
- lib/orange-more/debugger/assets/css/debug_bar.css
|
140
|
+
- lib/orange-more/debugger/middleware/debugger.rb
|
141
|
+
- lib/orange-more/debugger/plugin.rb
|
142
|
+
- lib/orange-more/debugger/views/debug_bar.haml
|
143
|
+
- lib/orange-more/disqus.rb
|
144
|
+
- lib/orange-more/disqus/plugin.rb
|
145
|
+
- lib/orange-more/disqus/resources/disqus_resource.rb
|
146
|
+
- lib/orange-more/disqus/views/disqus/comment_thread.haml
|
124
147
|
- lib/orange-more/pages.rb
|
125
148
|
- lib/orange-more/pages/cartons/page_carton.rb
|
126
149
|
- lib/orange-more/pages/cartons/page_version_carton.rb
|
@@ -142,6 +165,7 @@ files:
|
|
142
165
|
- lib/orange-more/sitemap/plugin.rb
|
143
166
|
- lib/orange-more/sitemap/resources/sitemap_resource.rb
|
144
167
|
- lib/orange-more/sitemap/views/sitemap/list.haml
|
168
|
+
- lib/orange-more/sitemap/views/sitemap/route_actions.haml
|
145
169
|
- lib/orange-more/sitemap/views/sitemap/sitemap_links.haml
|
146
170
|
- lib/orange-more/sitemap/views/sitemap/table_row.haml
|
147
171
|
- lib/orange-more/sitemap/views/sitemap/two_level.haml
|