orange 0.5.5 → 0.5.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/orange.rb +2 -5
- data/spec/orange_spec.rb +5 -0
- data/spec/{orange-core/spec_helper.rb → spec_helper.rb} +0 -0
- metadata +28 -235
- data/lib/orange-core.rb +0 -8
- data/lib/orange-core/application.rb +0 -132
- data/lib/orange-core/assets/css/exceptions.css +0 -50
- data/lib/orange-core/assets/js/exceptions.js +0 -44
- data/lib/orange-core/carton.rb +0 -178
- data/lib/orange-core/core.rb +0 -266
- data/lib/orange-core/magick.rb +0 -270
- data/lib/orange-core/middleware/base.rb +0 -96
- data/lib/orange-core/middleware/database.rb +0 -45
- data/lib/orange-core/middleware/four_oh_four.rb +0 -45
- data/lib/orange-core/middleware/globals.rb +0 -17
- data/lib/orange-core/middleware/loader.rb +0 -13
- data/lib/orange-core/middleware/rerouter.rb +0 -53
- data/lib/orange-core/middleware/restful_router.rb +0 -99
- data/lib/orange-core/middleware/route_context.rb +0 -39
- data/lib/orange-core/middleware/route_site.rb +0 -51
- data/lib/orange-core/middleware/show_exceptions.rb +0 -80
- data/lib/orange-core/middleware/static.rb +0 -67
- data/lib/orange-core/middleware/static_file.rb +0 -32
- data/lib/orange-core/middleware/template.rb +0 -60
- data/lib/orange-core/packet.rb +0 -232
- data/lib/orange-core/plugin.rb +0 -172
- data/lib/orange-core/resource.rb +0 -96
- data/lib/orange-core/resources/mapper.rb +0 -36
- data/lib/orange-core/resources/model_resource.rb +0 -228
- data/lib/orange-core/resources/not_found.rb +0 -10
- data/lib/orange-core/resources/page_parts.rb +0 -68
- data/lib/orange-core/resources/parser.rb +0 -113
- data/lib/orange-core/resources/routable_resource.rb +0 -16
- data/lib/orange-core/resources/scaffold.rb +0 -106
- data/lib/orange-core/stack.rb +0 -226
- data/lib/orange-core/templates/exceptions.haml +0 -111
- data/lib/orange-core/views/default_resource/create.haml +0 -4
- data/lib/orange-core/views/default_resource/edit.haml +0 -9
- data/lib/orange-core/views/default_resource/list.haml +0 -10
- data/lib/orange-core/views/default_resource/show.haml +0 -4
- data/lib/orange-core/views/default_resource/table_row.haml +0 -7
- data/lib/orange-core/views/not_found/404.haml +0 -2
- data/lib/orange-more.rb +0 -23
- data/lib/orange-more/administration.rb +0 -1
- data/lib/orange-more/administration/assets/css/admin.css +0 -286
- data/lib/orange-more/administration/assets/css/blueprint-ie.css +0 -35
- data/lib/orange-more/administration/assets/css/blueprint-print.css +0 -29
- data/lib/orange-more/administration/assets/css/blueprint.css +0 -257
- data/lib/orange-more/administration/assets/js/jquery.js +0 -152
- data/lib/orange-more/administration/cartons/site.rb +0 -7
- data/lib/orange-more/administration/cartons/site_carton.rb +0 -12
- data/lib/orange-more/administration/cartons/user.rb +0 -27
- data/lib/orange-more/administration/middleware/access_control.rb +0 -156
- data/lib/orange-more/administration/middleware/site_load.rb +0 -25
- data/lib/orange-more/administration/plugin.rb +0 -23
- data/lib/orange-more/administration/resources/admin_resource.rb +0 -27
- data/lib/orange-more/administration/resources/site_resource.rb +0 -10
- data/lib/orange-more/administration/resources/user_resource.rb +0 -40
- data/lib/orange-more/administration/templates/admin.haml +0 -25
- data/lib/orange-more/administration/views/openid_login.haml +0 -14
- data/lib/orange-more/administration/views/users/create.haml +0 -10
- data/lib/orange-more/administration/views/users/edit.haml +0 -15
- data/lib/orange-more/adverts.rb +0 -1
- data/lib/orange-more/adverts/cartons/adverts_carton.rb +0 -14
- data/lib/orange-more/adverts/plugin.rb +0 -13
- data/lib/orange-more/adverts/resources/adverts_resource.rb +0 -27
- data/lib/orange-more/adverts/views/adverts/adverts.haml +0 -2
- data/lib/orange-more/analytics.rb +0 -1
- data/lib/orange-more/analytics/middleware/analytics.rb +0 -30
- data/lib/orange-more/analytics/plugin.rb +0 -11
- data/lib/orange-more/analytics/resources/analytics_resource.rb +0 -42
- data/lib/orange-more/assets.rb +0 -1
- data/lib/orange-more/assets/cartons/asset_carton.rb +0 -27
- data/lib/orange-more/assets/plugin.rb +0 -13
- data/lib/orange-more/assets/resources/asset_resource.rb +0 -115
- data/lib/orange-more/assets/views/assets/change.haml +0 -1
- data/lib/orange-more/assets/views/assets/create.haml +0 -13
- data/lib/orange-more/assets/views/assets/insert.haml +0 -1
- data/lib/orange-more/blog.rb +0 -1
- data/lib/orange-more/blog/cartons/blog.rb +0 -8
- data/lib/orange-more/blog/cartons/blog_post.rb +0 -60
- data/lib/orange-more/blog/plugin.rb +0 -14
- data/lib/orange-more/blog/resources/blog_post_resource.rb +0 -53
- data/lib/orange-more/blog/resources/blog_resource.rb +0 -104
- data/lib/orange-more/blog/views/blog/blog_archive_view.haml +0 -6
- data/lib/orange-more/blog/views/blog/blog_offset_list_view.haml +0 -12
- data/lib/orange-more/blog/views/blog/blog_post_view.haml +0 -4
- data/lib/orange-more/blog/views/blog/sitemap_row.haml +0 -14
- data/lib/orange-more/blog/views/blog_posts/edit.haml +0 -8
- data/lib/orange-more/blog/views/blog_posts/show.haml +0 -4
- data/lib/orange-more/cloud.rb +0 -1
- data/lib/orange-more/cloud/plugin.rb +0 -10
- data/lib/orange-more/cloud/resources/cloud_resource.rb +0 -21
- data/lib/orange-more/contactforms.rb +0 -1
- data/lib/orange-more/contactforms/assets/js/jquery.validate.pack.js +0 -15
- data/lib/orange-more/contactforms/assets/js/lib/jquery-1.4.2.js +0 -6240
- data/lib/orange-more/contactforms/assets/js/lib/jquery.form.js +0 -660
- data/lib/orange-more/contactforms/assets/js/lib/jquery.js +0 -4376
- data/lib/orange-more/contactforms/assets/js/lib/jquery.metadata.js +0 -122
- data/lib/orange-more/contactforms/cartons/contactforms_carton.rb +0 -12
- data/lib/orange-more/contactforms/plugin.rb +0 -13
- data/lib/orange-more/contactforms/resources/contactforms_resource.rb +0 -56
- data/lib/orange-more/contactforms/views/contactforms/contactform.haml +0 -20
- data/lib/orange-more/debugger.rb +0 -1
- data/lib/orange-more/debugger/assets/css/debug_bar.css +0 -46
- data/lib/orange-more/debugger/middleware/debugger.rb +0 -50
- data/lib/orange-more/debugger/plugin.rb +0 -12
- data/lib/orange-more/debugger/views/debug_bar.haml +0 -87
- data/lib/orange-more/disqus.rb +0 -1
- data/lib/orange-more/disqus/plugin.rb +0 -11
- data/lib/orange-more/disqus/resources/disqus_resource.rb +0 -9
- data/lib/orange-more/disqus/views/disqus/comment_thread.haml +0 -7
- data/lib/orange-more/donations.rb +0 -1
- data/lib/orange-more/donations/cartons/donation_carton.rb +0 -9
- data/lib/orange-more/donations/plugin.rb +0 -12
- data/lib/orange-more/donations/resources/donations_resource.rb +0 -51
- data/lib/orange-more/donations/views/donations/donate_form.haml +0 -21
- data/lib/orange-more/donations/views/donations/donate_thanks.haml +0 -2
- data/lib/orange-more/donations/views/donations/paypal_form.haml +0 -13
- data/lib/orange-more/events.rb +0 -1
- data/lib/orange-more/events/assets/js/events.js +0 -55
- data/lib/orange-more/events/cartons/orange_calendar.rb +0 -8
- data/lib/orange-more/events/cartons/orange_event.rb +0 -60
- data/lib/orange-more/events/plugin.rb +0 -14
- data/lib/orange-more/events/resources/calendar_resource.rb +0 -33
- data/lib/orange-more/events/resources/event_resource.rb +0 -147
- data/lib/orange-more/events/views/calendar/calendar.haml +0 -8
- data/lib/orange-more/events/views/events/create.haml +0 -55
- data/lib/orange-more/events/views/events/edit.haml +0 -59
- data/lib/orange-more/events/views/events/list.haml +0 -13
- data/lib/orange-more/events/views/events/show.haml +0 -4
- data/lib/orange-more/events/views/events/table_row.haml +0 -17
- data/lib/orange-more/members.rb +0 -1
- data/lib/orange-more/members/cartons/member_carton.rb +0 -38
- data/lib/orange-more/members/plugin.rb +0 -13
- data/lib/orange-more/members/resources/members_resource.rb +0 -327
- data/lib/orange-more/members/views/members/create.haml +0 -12
- data/lib/orange-more/members/views/members/edit.haml +0 -15
- data/lib/orange-more/members/views/members/live.show.haml +0 -1
- data/lib/orange-more/members/views/members/login.haml +0 -17
- data/lib/orange-more/members/views/members/logout.haml +0 -1
- data/lib/orange-more/members/views/members/profile.haml +0 -50
- data/lib/orange-more/members/views/members/register.haml +0 -37
- data/lib/orange-more/news.rb +0 -1
- data/lib/orange-more/news/cartons/news.rb +0 -12
- data/lib/orange-more/news/plugin.rb +0 -13
- data/lib/orange-more/news/resources/news_resource.rb +0 -82
- data/lib/orange-more/news/views/news/archive.haml +0 -14
- data/lib/orange-more/news/views/news/edit.haml +0 -7
- data/lib/orange-more/news/views/news/latest.haml +0 -8
- data/lib/orange-more/news/views/news/sitemap_row.haml +0 -14
- data/lib/orange-more/pages.rb +0 -1
- data/lib/orange-more/pages/cartons/page_carton.rb +0 -14
- data/lib/orange-more/pages/cartons/page_version_carton.rb +0 -12
- data/lib/orange-more/pages/plugin.rb +0 -13
- data/lib/orange-more/pages/resources/page_resource.rb +0 -179
- data/lib/orange-more/pages/views/pages/edit.haml +0 -34
- data/lib/orange-more/pages/views/pages/show.haml +0 -6
- data/lib/orange-more/sitemap.rb +0 -1
- data/lib/orange-more/sitemap/assets/img/sitemap_down.png +0 -0
- data/lib/orange-more/sitemap/assets/img/sitemap_down_d.png +0 -0
- data/lib/orange-more/sitemap/assets/img/sitemap_indent.png +0 -0
- data/lib/orange-more/sitemap/assets/img/sitemap_indent_d.png +0 -0
- data/lib/orange-more/sitemap/assets/img/sitemap_outdent.png +0 -0
- data/lib/orange-more/sitemap/assets/img/sitemap_outdent_d.png +0 -0
- data/lib/orange-more/sitemap/assets/img/sitemap_up.png +0 -0
- data/lib/orange-more/sitemap/assets/img/sitemap_up_d.png +0 -0
- data/lib/orange-more/sitemap/assets/js/sitemap.js +0 -11
- data/lib/orange-more/sitemap/cartons/route.rb +0 -43
- data/lib/orange-more/sitemap/middleware/flex_router.rb +0 -25
- data/lib/orange-more/sitemap/plugin.rb +0 -17
- data/lib/orange-more/sitemap/resources/sitemap_resource.rb +0 -295
- data/lib/orange-more/sitemap/views/default_resource/sitemap_row.haml +0 -30
- data/lib/orange-more/sitemap/views/sitemap/breadcrumb.haml +0 -12
- data/lib/orange-more/sitemap/views/sitemap/list.haml +0 -4
- data/lib/orange-more/sitemap/views/sitemap/one_level.haml +0 -7
- data/lib/orange-more/sitemap/views/sitemap/route_actions.haml +0 -15
- data/lib/orange-more/sitemap/views/sitemap/sitemap_links.haml +0 -14
- data/lib/orange-more/sitemap/views/sitemap/table_row.haml +0 -30
- data/lib/orange-more/sitemap/views/sitemap/two_level.haml +0 -13
- data/lib/orange-more/slices.rb +0 -1
- data/lib/orange-more/slices/middleware/radius_parser.rb +0 -24
- data/lib/orange-more/slices/plugin.rb +0 -15
- data/lib/orange-more/slices/resources/radius.rb +0 -117
- data/lib/orange-more/slices/resources/slices.rb +0 -35
- data/lib/orange-more/subsites.rb +0 -1
- data/lib/orange-more/subsites/cartons/subsite.rb +0 -8
- data/lib/orange-more/subsites/middleware/subsite_load.rb +0 -29
- data/lib/orange-more/subsites/plugin.rb +0 -17
- data/lib/orange-more/subsites/resources/subsite_resource.rb +0 -54
- data/lib/orange-more/subsites/views/subsites/index.haml +0 -2
- data/lib/orange-more/testimonials.rb +0 -1
- data/lib/orange-more/testimonials/cartons/testimonials_carton.rb +0 -15
- data/lib/orange-more/testimonials/plugin.rb +0 -13
- data/lib/orange-more/testimonials/resources/testimonials_resource.rb +0 -42
- data/lib/orange-more/testimonials/views/testimonials/testimonials.haml +0 -4
- data/spec/orange-core/application_spec.rb +0 -183
- data/spec/orange-core/carton_spec.rb +0 -136
- data/spec/orange-core/core_spec.rb +0 -248
- data/spec/orange-core/magick_spec.rb +0 -96
- data/spec/orange-core/middleware/base_spec.rb +0 -38
- data/spec/orange-core/middleware/globals_spec.rb +0 -3
- data/spec/orange-core/middleware/rerouter_spec.rb +0 -3
- data/spec/orange-core/middleware/restful_router_spec.rb +0 -3
- data/spec/orange-core/middleware/route_context_spec.rb +0 -3
- data/spec/orange-core/middleware/route_site_spec.rb +0 -3
- data/spec/orange-core/middleware/show_exceptions_spec.rb +0 -3
- data/spec/orange-core/middleware/static_file_spec.rb +0 -3
- data/spec/orange-core/middleware/static_spec.rb +0 -3
- data/spec/orange-core/mock/mock_app.rb +0 -16
- data/spec/orange-core/mock/mock_carton.rb +0 -43
- data/spec/orange-core/mock/mock_core.rb +0 -2
- data/spec/orange-core/mock/mock_middleware.rb +0 -25
- data/spec/orange-core/mock/mock_mixins.rb +0 -19
- data/spec/orange-core/mock/mock_model_resource.rb +0 -47
- data/spec/orange-core/mock/mock_pulp.rb +0 -24
- data/spec/orange-core/mock/mock_resource.rb +0 -26
- data/spec/orange-core/mock/mock_router.rb +0 -10
- data/spec/orange-core/orange_spec.rb +0 -19
- data/spec/orange-core/packet_spec.rb +0 -203
- data/spec/orange-core/resource_spec.rb +0 -96
- data/spec/orange-core/resources/mapper_spec.rb +0 -5
- data/spec/orange-core/resources/model_resource_spec.rb +0 -246
- data/spec/orange-core/resources/parser_spec.rb +0 -5
- data/spec/orange-core/resources/routable_resource_spec.rb +0 -5
- data/spec/orange-core/stack_spec.rb +0 -232
@@ -1,40 +0,0 @@
|
|
1
|
-
module Orange
|
2
|
-
class UserResource < Orange::ModelResource
|
3
|
-
use OrangeUser
|
4
|
-
call_me :users
|
5
|
-
def afterLoad
|
6
|
-
orange[:admin].add_link("Settings", :resource => @my_orange_name, :text => 'Users')
|
7
|
-
end
|
8
|
-
|
9
|
-
def access_allowed?(packet, user)
|
10
|
-
u = model_class.first(:open_id => user)
|
11
|
-
return false unless u
|
12
|
-
u.allowed?(packet)
|
13
|
-
end
|
14
|
-
|
15
|
-
def user_for(packet)
|
16
|
-
model_class.first(:open_id => packet['user.id'])
|
17
|
-
end
|
18
|
-
|
19
|
-
def onNew(packet, opts = {})
|
20
|
-
params = opts
|
21
|
-
sites = params.delete 'sites'
|
22
|
-
m = model_class.new(params)
|
23
|
-
m.save
|
24
|
-
sites.each{|k,v| s = OrangeSite.first(:id => k); m.orange_sites << s if s} if sites
|
25
|
-
m
|
26
|
-
end
|
27
|
-
|
28
|
-
def onSave(packet, obj, params ={})
|
29
|
-
sites = params.delete 'sites'
|
30
|
-
obj.update(params)
|
31
|
-
obj.orange_sites = []
|
32
|
-
sites.each{|k,v| s = OrangeSite.first(:id => k); obj.orange_sites << s if s} if sites
|
33
|
-
obj.save
|
34
|
-
end
|
35
|
-
|
36
|
-
def find_extras(packet, mode)
|
37
|
-
{:sites => OrangeSite.all}
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
!!! xml
|
2
|
-
!!!
|
3
|
-
%html
|
4
|
-
%head
|
5
|
-
%title= part[:title, 'Orange Site']
|
6
|
-
= part[:css]
|
7
|
-
= part[:js]
|
8
|
-
%body
|
9
|
-
#body
|
10
|
-
.header
|
11
|
-
ORANGE
|
12
|
-
.container
|
13
|
-
#inner-body
|
14
|
-
.sidebar.span_5
|
15
|
-
- orange[:admin].links(packet).each do |k, section|
|
16
|
-
.sidebar_section
|
17
|
-
%h3= k
|
18
|
-
%ul
|
19
|
-
- for link in section
|
20
|
-
%li
|
21
|
-
%a{:href => link[:href], :style => "background-image: url(#{link[:icon]})"}= link[:text]
|
22
|
-
.span_7.last
|
23
|
-
= yield
|
24
|
-
.footer
|
25
|
-
%banana
|
@@ -1,14 +0,0 @@
|
|
1
|
-
%html
|
2
|
-
%head
|
3
|
-
%title Woah.
|
4
|
-
%body
|
5
|
-
%h2 Wait a minute...
|
6
|
-
%p You'll need to log in before you can continue. Use your OpenID.
|
7
|
-
%p (You can use a Google account to log in. Put https://www.google.com/accounts/o8/id in the box below.)
|
8
|
-
- if(flash['error'])
|
9
|
-
.error= flash('error')
|
10
|
-
%form{:action => '', :method => 'POST'}
|
11
|
-
%input{:type => 'text', :name => 'openid_identifier'}
|
12
|
-
%input{:type => 'submit', :value => 'Log in'}
|
13
|
-
|
14
|
-
|
@@ -1,10 +0,0 @@
|
|
1
|
-
%form{:action => "#{packet.route_to(model_name, 'new')}", :method => 'post'}
|
2
|
-
- for prop in props
|
3
|
-
%p= view_attribute(prop, model_name, :label => true)
|
4
|
-
%fieldset
|
5
|
-
%h4 Permission to Edit:
|
6
|
-
- for site in sites
|
7
|
-
%p
|
8
|
-
#{site.name}
|
9
|
-
%input{:type => 'checkbox', :name => "#{model_name}[sites][#{site.id}]", :value => site.id}
|
10
|
-
%input{:type => 'submit', :value => 'Save New Item'}
|
@@ -1,15 +0,0 @@
|
|
1
|
-
- if model
|
2
|
-
- if resource.options[:sitemappable, false]
|
3
|
-
= orange[:sitemap, true].sitemap_links(packet, {:slug_me => orange[:sitemap, true].slug_for(model, props)})
|
4
|
-
%form{:action => packet.route_to(model_name, model[:id], 'save'), :method => 'post'}
|
5
|
-
- for prop in props
|
6
|
-
%p!= view_attribute(prop, model_name, :label => true, :value => model.attribute_get(prop[:name]))
|
7
|
-
%fieldset
|
8
|
-
%h4 Permission to Edit:
|
9
|
-
- for site in sites
|
10
|
-
%p
|
11
|
-
#{site.name}
|
12
|
-
%input{:type => 'checkbox', :name => "#{model_name}[sites][#{site.id}]", :value => site.id, :checked => (model.orange_sites.include?(site) ? 'checked' : nil)}
|
13
|
-
%input{:type => 'submit', :value => 'Save Changes'}
|
14
|
-
- else
|
15
|
-
%p Couldn't find the item you're looking for.
|
data/lib/orange-more/adverts.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require File.join('orange-more', 'adverts', 'plugin')
|
@@ -1,13 +0,0 @@
|
|
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 Adverts < Base
|
6
|
-
views_dir File.join(File.dirname(__FILE__), 'views')
|
7
|
-
|
8
|
-
resource Orange::AdvertsResource.new
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
Orange.plugin(Orange::Plugins::Adverts.new)
|
13
|
-
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module Orange
|
2
|
-
class AdvertsResource < Orange::ModelResource
|
3
|
-
use OrangeAdvert
|
4
|
-
call_me :adverts
|
5
|
-
def stack_init
|
6
|
-
orange[:admin, true].add_link("Content", :resource => @my_orange_name, :text => 'Advertisements')
|
7
|
-
orange[:radius].define_tag "adverts" do |tag|
|
8
|
-
if tag.attr["tag"] && model_class.with_tag(tag.attr["tag"]).count >0
|
9
|
-
m = model_class.with_tag(tag.attr["tag"]).first(:offset => rand(model_class.with_tag(tag.attr["tag"]).count)) #selects advert based on tag
|
10
|
-
elsif model_class.all.count > 0
|
11
|
-
m = model_class.first(:offset => rand(model_class.all.count)) #selects a random advert
|
12
|
-
end
|
13
|
-
unless m.nil?
|
14
|
-
template = tag.attr["template"] || "adverts"
|
15
|
-
orange[:adverts].advert(tag.locals.packet, {:model => m, :template => template})
|
16
|
-
else
|
17
|
-
""
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def advert(packet, opts = {})
|
23
|
-
template = opts[:template].to_sym || :adverts
|
24
|
-
do_view(packet, template, opts)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
require File.join('orange-more', 'analytics', 'plugin')
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'orange-core/middleware/base'
|
2
|
-
|
3
|
-
module Orange::Middleware
|
4
|
-
class Analytics < Base
|
5
|
-
|
6
|
-
# Passes packet then parses the return
|
7
|
-
def packet_call(packet)
|
8
|
-
pass packet
|
9
|
-
ga_key = orange.options['google_analytics_key'] || false
|
10
|
-
if packet['route.context'] == :live && ga_key
|
11
|
-
ga = "<script type=\"text/javascript\">
|
12
|
-
|
13
|
-
var _gaq = _gaq || [];
|
14
|
-
_gaq.push(['_setAccount', '"+ga_key+"']);
|
15
|
-
_gaq.push(['_trackPageview']);
|
16
|
-
|
17
|
-
(function() {
|
18
|
-
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
19
|
-
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
20
|
-
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
21
|
-
})();
|
22
|
-
|
23
|
-
</script>"
|
24
|
-
packet[:content] = packet[:content].sub(/.*<\/head>$/, ga + '</head>')
|
25
|
-
end
|
26
|
-
packet.finish
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
Dir.glob(File.join(File.dirname(__FILE__), 'resources', '*.rb')).each {|f| require f }
|
2
|
-
Dir.glob(File.join(File.dirname(__FILE__), 'middleware', '*.rb')).each {|f| require f }
|
3
|
-
|
4
|
-
module Orange::Plugins
|
5
|
-
class Analytics < Base
|
6
|
-
resource Orange::AnalyticsResource.new
|
7
|
-
prerouter Orange::Middleware::Analytics
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
Orange.plugin(Orange::Plugins::Analytics.new)
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'gattica'
|
2
|
-
|
3
|
-
module Orange
|
4
|
-
class AnalyticsResource < Orange::Resource
|
5
|
-
call_me :analytics
|
6
|
-
def stack_init
|
7
|
-
options[:email] = orange.options['ga_email']
|
8
|
-
options[:password] = orange.options['ga_password']
|
9
|
-
end
|
10
|
-
|
11
|
-
def gattica
|
12
|
-
return false unless options[:email]
|
13
|
-
@gattica ||= Gattica.new(options)
|
14
|
-
end
|
15
|
-
|
16
|
-
def pageviews(route, opts = {})
|
17
|
-
return "No GA" unless gattica
|
18
|
-
r = route.to_s
|
19
|
-
# Strip trailing slash if present. GA doesn't like it.
|
20
|
-
if r.rindex('/') > 0
|
21
|
-
r[r.rindex('/')] = ''
|
22
|
-
end
|
23
|
-
# authenticate with the API via email/password
|
24
|
-
ga = gattica
|
25
|
-
accounts = ga.accounts
|
26
|
-
ga.profile_id = accounts.first.profile_id
|
27
|
-
views = ""
|
28
|
-
data = ga.get({ :start_date => '2009-01-01',
|
29
|
-
:end_date => Time.now.localtime.strftime("%Y-%m-%d"),
|
30
|
-
:dimensions => ['pagePath'],
|
31
|
-
:metrics => ['pageviews'],
|
32
|
-
:filters => ['pagePath == '+route.to_s[0..-1]]
|
33
|
-
}.merge(opts))
|
34
|
-
unless data.points.length == 0
|
35
|
-
views = data.points[0].metrics[0][:pageviews]
|
36
|
-
views
|
37
|
-
else
|
38
|
-
0
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
data/lib/orange-more/assets.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require File.join('orange-more', 'assets', 'plugin')
|
@@ -1,27 +0,0 @@
|
|
1
|
-
class OrangeAsset < Orange::Carton
|
2
|
-
id
|
3
|
-
admin do
|
4
|
-
title :name, :length => 255
|
5
|
-
text :caption, :length => 255
|
6
|
-
end
|
7
|
-
orange do
|
8
|
-
string :path, :length => 255
|
9
|
-
string :mime_type
|
10
|
-
string :secondary_path, :length => 255, :required => false
|
11
|
-
string :secondary_mime_type
|
12
|
-
end
|
13
|
-
|
14
|
-
def file_path
|
15
|
-
File.join('', 'assets', 'uploaded', path)
|
16
|
-
end
|
17
|
-
|
18
|
-
def to_s
|
19
|
-
<<-DOC
|
20
|
-
{"id": #{self.id}, "html": "#{self.to_asset_tag}"}
|
21
|
-
DOC
|
22
|
-
end
|
23
|
-
|
24
|
-
def to_asset_tag(alt = "")
|
25
|
-
"<img src='#{file_path}' border='0' alt='#{alt}' />"
|
26
|
-
end
|
27
|
-
end
|
@@ -1,13 +0,0 @@
|
|
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 Assets < Base
|
6
|
-
views_dir File.join(File.dirname(__FILE__), 'views')
|
7
|
-
|
8
|
-
resource Orange::AssetResource.new
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
Orange.plugin(Orange::Plugins::Assets.new)
|
13
|
-
|
@@ -1,115 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
module Orange
|
3
|
-
class Orange::Carton
|
4
|
-
# Define a helper for input type="text" type database stuff
|
5
|
-
# Show in a context if wrapped in one of the helpers
|
6
|
-
def self.asset(name, opts = {})
|
7
|
-
add_scaffold(name, :asset, Integer, opts)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
class AssetResource < Orange::ModelResource
|
12
|
-
use OrangeAsset
|
13
|
-
call_me :assets
|
14
|
-
|
15
|
-
def stack_init
|
16
|
-
orange[:admin, true].add_link("Content", :resource => @my_orange_name, :text => 'Assets')
|
17
|
-
orange[:radius, true].define_tag "asset" do |tag|
|
18
|
-
if tag.attr['id']
|
19
|
-
(m = model_class.first(:id => tag.attr['id'])) ? m.to_asset_tag : 'Invalid Asset'
|
20
|
-
else
|
21
|
-
''
|
22
|
-
end
|
23
|
-
end
|
24
|
-
orange[:scaffold].add_scaffold_type(:asset) do |name, val, opts|
|
25
|
-
if opts[:show]
|
26
|
-
opts[:model].to_asset_tag
|
27
|
-
else
|
28
|
-
packet = opts[:packet]
|
29
|
-
|
30
|
-
asset_html = val ? orange[:assets].asset_html(packet, val) : ""
|
31
|
-
ret = "<input type=\"hidden\" value=\"#{val}\" name=\"#{opts[:model_name]}[#{name}]\" />"
|
32
|
-
if val.blank?
|
33
|
-
ret += "<span class='asset_preview'></span><a class='insert_asset' rel=\"#{opts[:model_name]}[#{name}]\" href='/admin/assets/insert'>Insert Asset</a>"
|
34
|
-
else
|
35
|
-
ret += "<span class='asset_preview'>#{asset_html}</span><a class='insert_asset' rel=\"#{opts[:model_name]}[#{name}]\" href='/admin/assets/#{val}/change'>Change Asset</a>"
|
36
|
-
end
|
37
|
-
ret = "<label for=''>#{opts[:display_name]}</label><br />" + ret if opts[:label]
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def onNew(packet, params = {})
|
43
|
-
m = false
|
44
|
-
if(file = params['file'][:tempfile])
|
45
|
-
file_path = orange.app_dir('assets','uploaded', params['file'][:filename]) if params['file'][:filename]
|
46
|
-
# Check for secondary file (useful for videos/images with thumbnails)
|
47
|
-
if(params['file2'] && secondary = params['file2'][:tempfile])
|
48
|
-
secondary_path = orange.app_dir('assets','uploaded', params['file2'][:filename])
|
49
|
-
else
|
50
|
-
secondary_path = nil
|
51
|
-
end
|
52
|
-
# Move the files
|
53
|
-
FileUtils.cp(file.path, file_path)
|
54
|
-
FileUtils.chmod(0644, file_path)
|
55
|
-
FileUtils.cp(secondary.path, secondary_path) if secondary_path
|
56
|
-
FileUtils.chmod(0644, secondary_path) if secondary_path
|
57
|
-
|
58
|
-
params['path'] = params['file'][:filename] if file_path
|
59
|
-
params['secondary_path'] = params['file2'][:filename] if secondary_path
|
60
|
-
params['mime_type'] = params['file'][:type] if file_path
|
61
|
-
params['secondary_mime_type'] = params['file2'][:type] if secondary_path
|
62
|
-
params.delete('file')
|
63
|
-
params.delete('file2')
|
64
|
-
|
65
|
-
m = model_class.new(params)
|
66
|
-
end
|
67
|
-
m
|
68
|
-
end
|
69
|
-
|
70
|
-
# Creates a new model object and saves it (if a post), then reroutes to the main page
|
71
|
-
# @param [Orange::Packet] packet the packet being routed
|
72
|
-
def new(packet, opts = {})
|
73
|
-
no_reroute = opts.delete(:no_reroute)
|
74
|
-
xhr = packet.request.xhr? || packet.request.params["fake_xhr"]
|
75
|
-
if packet.request.post? || !opts.blank?
|
76
|
-
params = opts.with_defaults(opts.delete(:params) || packet.request.params[@my_orange_name.to_s] || {})
|
77
|
-
before = beforeNew(packet, params)
|
78
|
-
obj = onNew(packet, params) if before
|
79
|
-
afterNew(packet, obj, params) if before
|
80
|
-
obj.save if obj && before
|
81
|
-
end
|
82
|
-
packet.reroute(@my_orange_name, :orange) unless (xhr || no_reroute)
|
83
|
-
packet['template.disable'] = true if xhr
|
84
|
-
(xhr ? obj.to_s : obj) || false
|
85
|
-
end
|
86
|
-
|
87
|
-
def insert(packet, opts = {})
|
88
|
-
do_view(packet, :insert, opts)
|
89
|
-
end
|
90
|
-
|
91
|
-
def change(packet, opts = {})
|
92
|
-
do_view(packet, :change, opts)
|
93
|
-
end
|
94
|
-
|
95
|
-
def find_extras(packet, mode, opts = {})
|
96
|
-
{:list => model_class.all}
|
97
|
-
end
|
98
|
-
|
99
|
-
def onDelete(packet, m, opts = {})
|
100
|
-
begin
|
101
|
-
FileUtils.rm(orange.app_dir('assets','uploaded', m.path)) if m.path
|
102
|
-
FileUtils.rm(orange.app_dir('assets','uploaded', m.secondary_path)) if m.secondary_path
|
103
|
-
rescue
|
104
|
-
# Problem deleting file
|
105
|
-
end
|
106
|
-
m.destroy if m
|
107
|
-
end
|
108
|
-
|
109
|
-
def asset_html(packet, id = false)
|
110
|
-
id ||= packet['route.resource_id']
|
111
|
-
m = model_class.get(id)
|
112
|
-
m ? m.to_asset_tag : false
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
%h2 Change an Asset
|
@@ -1,13 +0,0 @@
|
|
1
|
-
%form{:action => "#{packet.route_to(model_name, 'new')}", :method => 'post', :enctype=>"multipart/form-data"}
|
2
|
-
- for prop in props
|
3
|
-
- next if [:path, :secondary_path].include?(prop[:name])
|
4
|
-
%p= view_attribute(prop, model_name, :label => true)
|
5
|
-
%p
|
6
|
-
%label File
|
7
|
-
%br
|
8
|
-
%input{:type => 'file', :name => "#{model_name}[file]"}
|
9
|
-
%p
|
10
|
-
%label Secondary File
|
11
|
-
%br
|
12
|
-
%input{:type => 'file', :name => "#{model_name}[file2]"}
|
13
|
-
%input{:type => 'submit', :value => 'Save New Item'}
|