orange 0.5.5 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (226) hide show
  1. data/lib/orange.rb +2 -5
  2. data/spec/orange_spec.rb +5 -0
  3. data/spec/{orange-core/spec_helper.rb → spec_helper.rb} +0 -0
  4. metadata +28 -235
  5. data/lib/orange-core.rb +0 -8
  6. data/lib/orange-core/application.rb +0 -132
  7. data/lib/orange-core/assets/css/exceptions.css +0 -50
  8. data/lib/orange-core/assets/js/exceptions.js +0 -44
  9. data/lib/orange-core/carton.rb +0 -178
  10. data/lib/orange-core/core.rb +0 -266
  11. data/lib/orange-core/magick.rb +0 -270
  12. data/lib/orange-core/middleware/base.rb +0 -96
  13. data/lib/orange-core/middleware/database.rb +0 -45
  14. data/lib/orange-core/middleware/four_oh_four.rb +0 -45
  15. data/lib/orange-core/middleware/globals.rb +0 -17
  16. data/lib/orange-core/middleware/loader.rb +0 -13
  17. data/lib/orange-core/middleware/rerouter.rb +0 -53
  18. data/lib/orange-core/middleware/restful_router.rb +0 -99
  19. data/lib/orange-core/middleware/route_context.rb +0 -39
  20. data/lib/orange-core/middleware/route_site.rb +0 -51
  21. data/lib/orange-core/middleware/show_exceptions.rb +0 -80
  22. data/lib/orange-core/middleware/static.rb +0 -67
  23. data/lib/orange-core/middleware/static_file.rb +0 -32
  24. data/lib/orange-core/middleware/template.rb +0 -60
  25. data/lib/orange-core/packet.rb +0 -232
  26. data/lib/orange-core/plugin.rb +0 -172
  27. data/lib/orange-core/resource.rb +0 -96
  28. data/lib/orange-core/resources/mapper.rb +0 -36
  29. data/lib/orange-core/resources/model_resource.rb +0 -228
  30. data/lib/orange-core/resources/not_found.rb +0 -10
  31. data/lib/orange-core/resources/page_parts.rb +0 -68
  32. data/lib/orange-core/resources/parser.rb +0 -113
  33. data/lib/orange-core/resources/routable_resource.rb +0 -16
  34. data/lib/orange-core/resources/scaffold.rb +0 -106
  35. data/lib/orange-core/stack.rb +0 -226
  36. data/lib/orange-core/templates/exceptions.haml +0 -111
  37. data/lib/orange-core/views/default_resource/create.haml +0 -4
  38. data/lib/orange-core/views/default_resource/edit.haml +0 -9
  39. data/lib/orange-core/views/default_resource/list.haml +0 -10
  40. data/lib/orange-core/views/default_resource/show.haml +0 -4
  41. data/lib/orange-core/views/default_resource/table_row.haml +0 -7
  42. data/lib/orange-core/views/not_found/404.haml +0 -2
  43. data/lib/orange-more.rb +0 -23
  44. data/lib/orange-more/administration.rb +0 -1
  45. data/lib/orange-more/administration/assets/css/admin.css +0 -286
  46. data/lib/orange-more/administration/assets/css/blueprint-ie.css +0 -35
  47. data/lib/orange-more/administration/assets/css/blueprint-print.css +0 -29
  48. data/lib/orange-more/administration/assets/css/blueprint.css +0 -257
  49. data/lib/orange-more/administration/assets/js/jquery.js +0 -152
  50. data/lib/orange-more/administration/cartons/site.rb +0 -7
  51. data/lib/orange-more/administration/cartons/site_carton.rb +0 -12
  52. data/lib/orange-more/administration/cartons/user.rb +0 -27
  53. data/lib/orange-more/administration/middleware/access_control.rb +0 -156
  54. data/lib/orange-more/administration/middleware/site_load.rb +0 -25
  55. data/lib/orange-more/administration/plugin.rb +0 -23
  56. data/lib/orange-more/administration/resources/admin_resource.rb +0 -27
  57. data/lib/orange-more/administration/resources/site_resource.rb +0 -10
  58. data/lib/orange-more/administration/resources/user_resource.rb +0 -40
  59. data/lib/orange-more/administration/templates/admin.haml +0 -25
  60. data/lib/orange-more/administration/views/openid_login.haml +0 -14
  61. data/lib/orange-more/administration/views/users/create.haml +0 -10
  62. data/lib/orange-more/administration/views/users/edit.haml +0 -15
  63. data/lib/orange-more/adverts.rb +0 -1
  64. data/lib/orange-more/adverts/cartons/adverts_carton.rb +0 -14
  65. data/lib/orange-more/adverts/plugin.rb +0 -13
  66. data/lib/orange-more/adverts/resources/adverts_resource.rb +0 -27
  67. data/lib/orange-more/adverts/views/adverts/adverts.haml +0 -2
  68. data/lib/orange-more/analytics.rb +0 -1
  69. data/lib/orange-more/analytics/middleware/analytics.rb +0 -30
  70. data/lib/orange-more/analytics/plugin.rb +0 -11
  71. data/lib/orange-more/analytics/resources/analytics_resource.rb +0 -42
  72. data/lib/orange-more/assets.rb +0 -1
  73. data/lib/orange-more/assets/cartons/asset_carton.rb +0 -27
  74. data/lib/orange-more/assets/plugin.rb +0 -13
  75. data/lib/orange-more/assets/resources/asset_resource.rb +0 -115
  76. data/lib/orange-more/assets/views/assets/change.haml +0 -1
  77. data/lib/orange-more/assets/views/assets/create.haml +0 -13
  78. data/lib/orange-more/assets/views/assets/insert.haml +0 -1
  79. data/lib/orange-more/blog.rb +0 -1
  80. data/lib/orange-more/blog/cartons/blog.rb +0 -8
  81. data/lib/orange-more/blog/cartons/blog_post.rb +0 -60
  82. data/lib/orange-more/blog/plugin.rb +0 -14
  83. data/lib/orange-more/blog/resources/blog_post_resource.rb +0 -53
  84. data/lib/orange-more/blog/resources/blog_resource.rb +0 -104
  85. data/lib/orange-more/blog/views/blog/blog_archive_view.haml +0 -6
  86. data/lib/orange-more/blog/views/blog/blog_offset_list_view.haml +0 -12
  87. data/lib/orange-more/blog/views/blog/blog_post_view.haml +0 -4
  88. data/lib/orange-more/blog/views/blog/sitemap_row.haml +0 -14
  89. data/lib/orange-more/blog/views/blog_posts/edit.haml +0 -8
  90. data/lib/orange-more/blog/views/blog_posts/show.haml +0 -4
  91. data/lib/orange-more/cloud.rb +0 -1
  92. data/lib/orange-more/cloud/plugin.rb +0 -10
  93. data/lib/orange-more/cloud/resources/cloud_resource.rb +0 -21
  94. data/lib/orange-more/contactforms.rb +0 -1
  95. data/lib/orange-more/contactforms/assets/js/jquery.validate.pack.js +0 -15
  96. data/lib/orange-more/contactforms/assets/js/lib/jquery-1.4.2.js +0 -6240
  97. data/lib/orange-more/contactforms/assets/js/lib/jquery.form.js +0 -660
  98. data/lib/orange-more/contactforms/assets/js/lib/jquery.js +0 -4376
  99. data/lib/orange-more/contactforms/assets/js/lib/jquery.metadata.js +0 -122
  100. data/lib/orange-more/contactforms/cartons/contactforms_carton.rb +0 -12
  101. data/lib/orange-more/contactforms/plugin.rb +0 -13
  102. data/lib/orange-more/contactforms/resources/contactforms_resource.rb +0 -56
  103. data/lib/orange-more/contactforms/views/contactforms/contactform.haml +0 -20
  104. data/lib/orange-more/debugger.rb +0 -1
  105. data/lib/orange-more/debugger/assets/css/debug_bar.css +0 -46
  106. data/lib/orange-more/debugger/middleware/debugger.rb +0 -50
  107. data/lib/orange-more/debugger/plugin.rb +0 -12
  108. data/lib/orange-more/debugger/views/debug_bar.haml +0 -87
  109. data/lib/orange-more/disqus.rb +0 -1
  110. data/lib/orange-more/disqus/plugin.rb +0 -11
  111. data/lib/orange-more/disqus/resources/disqus_resource.rb +0 -9
  112. data/lib/orange-more/disqus/views/disqus/comment_thread.haml +0 -7
  113. data/lib/orange-more/donations.rb +0 -1
  114. data/lib/orange-more/donations/cartons/donation_carton.rb +0 -9
  115. data/lib/orange-more/donations/plugin.rb +0 -12
  116. data/lib/orange-more/donations/resources/donations_resource.rb +0 -51
  117. data/lib/orange-more/donations/views/donations/donate_form.haml +0 -21
  118. data/lib/orange-more/donations/views/donations/donate_thanks.haml +0 -2
  119. data/lib/orange-more/donations/views/donations/paypal_form.haml +0 -13
  120. data/lib/orange-more/events.rb +0 -1
  121. data/lib/orange-more/events/assets/js/events.js +0 -55
  122. data/lib/orange-more/events/cartons/orange_calendar.rb +0 -8
  123. data/lib/orange-more/events/cartons/orange_event.rb +0 -60
  124. data/lib/orange-more/events/plugin.rb +0 -14
  125. data/lib/orange-more/events/resources/calendar_resource.rb +0 -33
  126. data/lib/orange-more/events/resources/event_resource.rb +0 -147
  127. data/lib/orange-more/events/views/calendar/calendar.haml +0 -8
  128. data/lib/orange-more/events/views/events/create.haml +0 -55
  129. data/lib/orange-more/events/views/events/edit.haml +0 -59
  130. data/lib/orange-more/events/views/events/list.haml +0 -13
  131. data/lib/orange-more/events/views/events/show.haml +0 -4
  132. data/lib/orange-more/events/views/events/table_row.haml +0 -17
  133. data/lib/orange-more/members.rb +0 -1
  134. data/lib/orange-more/members/cartons/member_carton.rb +0 -38
  135. data/lib/orange-more/members/plugin.rb +0 -13
  136. data/lib/orange-more/members/resources/members_resource.rb +0 -327
  137. data/lib/orange-more/members/views/members/create.haml +0 -12
  138. data/lib/orange-more/members/views/members/edit.haml +0 -15
  139. data/lib/orange-more/members/views/members/live.show.haml +0 -1
  140. data/lib/orange-more/members/views/members/login.haml +0 -17
  141. data/lib/orange-more/members/views/members/logout.haml +0 -1
  142. data/lib/orange-more/members/views/members/profile.haml +0 -50
  143. data/lib/orange-more/members/views/members/register.haml +0 -37
  144. data/lib/orange-more/news.rb +0 -1
  145. data/lib/orange-more/news/cartons/news.rb +0 -12
  146. data/lib/orange-more/news/plugin.rb +0 -13
  147. data/lib/orange-more/news/resources/news_resource.rb +0 -82
  148. data/lib/orange-more/news/views/news/archive.haml +0 -14
  149. data/lib/orange-more/news/views/news/edit.haml +0 -7
  150. data/lib/orange-more/news/views/news/latest.haml +0 -8
  151. data/lib/orange-more/news/views/news/sitemap_row.haml +0 -14
  152. data/lib/orange-more/pages.rb +0 -1
  153. data/lib/orange-more/pages/cartons/page_carton.rb +0 -14
  154. data/lib/orange-more/pages/cartons/page_version_carton.rb +0 -12
  155. data/lib/orange-more/pages/plugin.rb +0 -13
  156. data/lib/orange-more/pages/resources/page_resource.rb +0 -179
  157. data/lib/orange-more/pages/views/pages/edit.haml +0 -34
  158. data/lib/orange-more/pages/views/pages/show.haml +0 -6
  159. data/lib/orange-more/sitemap.rb +0 -1
  160. data/lib/orange-more/sitemap/assets/img/sitemap_down.png +0 -0
  161. data/lib/orange-more/sitemap/assets/img/sitemap_down_d.png +0 -0
  162. data/lib/orange-more/sitemap/assets/img/sitemap_indent.png +0 -0
  163. data/lib/orange-more/sitemap/assets/img/sitemap_indent_d.png +0 -0
  164. data/lib/orange-more/sitemap/assets/img/sitemap_outdent.png +0 -0
  165. data/lib/orange-more/sitemap/assets/img/sitemap_outdent_d.png +0 -0
  166. data/lib/orange-more/sitemap/assets/img/sitemap_up.png +0 -0
  167. data/lib/orange-more/sitemap/assets/img/sitemap_up_d.png +0 -0
  168. data/lib/orange-more/sitemap/assets/js/sitemap.js +0 -11
  169. data/lib/orange-more/sitemap/cartons/route.rb +0 -43
  170. data/lib/orange-more/sitemap/middleware/flex_router.rb +0 -25
  171. data/lib/orange-more/sitemap/plugin.rb +0 -17
  172. data/lib/orange-more/sitemap/resources/sitemap_resource.rb +0 -295
  173. data/lib/orange-more/sitemap/views/default_resource/sitemap_row.haml +0 -30
  174. data/lib/orange-more/sitemap/views/sitemap/breadcrumb.haml +0 -12
  175. data/lib/orange-more/sitemap/views/sitemap/list.haml +0 -4
  176. data/lib/orange-more/sitemap/views/sitemap/one_level.haml +0 -7
  177. data/lib/orange-more/sitemap/views/sitemap/route_actions.haml +0 -15
  178. data/lib/orange-more/sitemap/views/sitemap/sitemap_links.haml +0 -14
  179. data/lib/orange-more/sitemap/views/sitemap/table_row.haml +0 -30
  180. data/lib/orange-more/sitemap/views/sitemap/two_level.haml +0 -13
  181. data/lib/orange-more/slices.rb +0 -1
  182. data/lib/orange-more/slices/middleware/radius_parser.rb +0 -24
  183. data/lib/orange-more/slices/plugin.rb +0 -15
  184. data/lib/orange-more/slices/resources/radius.rb +0 -117
  185. data/lib/orange-more/slices/resources/slices.rb +0 -35
  186. data/lib/orange-more/subsites.rb +0 -1
  187. data/lib/orange-more/subsites/cartons/subsite.rb +0 -8
  188. data/lib/orange-more/subsites/middleware/subsite_load.rb +0 -29
  189. data/lib/orange-more/subsites/plugin.rb +0 -17
  190. data/lib/orange-more/subsites/resources/subsite_resource.rb +0 -54
  191. data/lib/orange-more/subsites/views/subsites/index.haml +0 -2
  192. data/lib/orange-more/testimonials.rb +0 -1
  193. data/lib/orange-more/testimonials/cartons/testimonials_carton.rb +0 -15
  194. data/lib/orange-more/testimonials/plugin.rb +0 -13
  195. data/lib/orange-more/testimonials/resources/testimonials_resource.rb +0 -42
  196. data/lib/orange-more/testimonials/views/testimonials/testimonials.haml +0 -4
  197. data/spec/orange-core/application_spec.rb +0 -183
  198. data/spec/orange-core/carton_spec.rb +0 -136
  199. data/spec/orange-core/core_spec.rb +0 -248
  200. data/spec/orange-core/magick_spec.rb +0 -96
  201. data/spec/orange-core/middleware/base_spec.rb +0 -38
  202. data/spec/orange-core/middleware/globals_spec.rb +0 -3
  203. data/spec/orange-core/middleware/rerouter_spec.rb +0 -3
  204. data/spec/orange-core/middleware/restful_router_spec.rb +0 -3
  205. data/spec/orange-core/middleware/route_context_spec.rb +0 -3
  206. data/spec/orange-core/middleware/route_site_spec.rb +0 -3
  207. data/spec/orange-core/middleware/show_exceptions_spec.rb +0 -3
  208. data/spec/orange-core/middleware/static_file_spec.rb +0 -3
  209. data/spec/orange-core/middleware/static_spec.rb +0 -3
  210. data/spec/orange-core/mock/mock_app.rb +0 -16
  211. data/spec/orange-core/mock/mock_carton.rb +0 -43
  212. data/spec/orange-core/mock/mock_core.rb +0 -2
  213. data/spec/orange-core/mock/mock_middleware.rb +0 -25
  214. data/spec/orange-core/mock/mock_mixins.rb +0 -19
  215. data/spec/orange-core/mock/mock_model_resource.rb +0 -47
  216. data/spec/orange-core/mock/mock_pulp.rb +0 -24
  217. data/spec/orange-core/mock/mock_resource.rb +0 -26
  218. data/spec/orange-core/mock/mock_router.rb +0 -10
  219. data/spec/orange-core/orange_spec.rb +0 -19
  220. data/spec/orange-core/packet_spec.rb +0 -203
  221. data/spec/orange-core/resource_spec.rb +0 -96
  222. data/spec/orange-core/resources/mapper_spec.rb +0 -5
  223. data/spec/orange-core/resources/model_resource_spec.rb +0 -246
  224. data/spec/orange-core/resources/parser_spec.rb +0 -5
  225. data/spec/orange-core/resources/routable_resource_spec.rb +0 -5
  226. 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.
@@ -1 +0,0 @@
1
- require File.join('orange-more', 'adverts', 'plugin')
@@ -1,14 +0,0 @@
1
- class OrangeAdvert < Orange::Carton
2
- id
3
- admin do
4
- title :title
5
- asset :asset_id
6
- text :link
7
- text :alt_text
8
- end
9
-
10
- def self.with_tag(tag)
11
- all(:tags.like => "%#{tag}%")
12
- end
13
-
14
- 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 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,2 +0,0 @@
1
- %a{ :href => model.link, :target => "_blank", :rel => "external" }
2
- = orange[:assets].asset_html(packet, model.asset_id)
@@ -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
@@ -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'}