orange-more 0.5.8 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/lib/orange-more.rb +1 -7
  2. data/lib/orange-more/administration/cartons/user.rb +4 -1
  3. data/lib/orange-more/administration/middleware/access_control.rb +25 -13
  4. data/lib/orange-more/administration/middleware/site_load.rb +1 -1
  5. data/lib/orange-more/administration/resources/user_resource.rb +15 -1
  6. data/lib/orange-more/analytics/resources/analytics_resource.rb +2 -1
  7. data/lib/orange-more/assets/cartons/asset_carton.rb +26 -2
  8. data/lib/orange-more/assets/resources/asset_resource.rb +81 -15
  9. data/lib/orange-more/blog/cartons/blog_post.rb +3 -3
  10. data/lib/orange-more/contactforms/cartons/{contactforms_carton.rb → contactform_carton.rb} +2 -1
  11. data/lib/orange-more/contactforms/resources/contactforms_resource.rb +15 -13
  12. data/lib/orange-more/contactforms/views/contactforms/contactform.haml +1 -0
  13. data/lib/orange-more/debugger/assets/css/debug_bar.css +1 -0
  14. data/lib/orange-more/pages/resources/page_resource.rb +7 -0
  15. data/lib/orange-more/sitemap/resources/sitemap_resource.rb +6 -1
  16. data/lib/orange-more/slices/resources/slices.rb +9 -5
  17. metadata +6 -53
  18. data/lib/orange-more/adverts.rb +0 -1
  19. data/lib/orange-more/adverts/cartons/adverts_carton.rb +0 -14
  20. data/lib/orange-more/adverts/plugin.rb +0 -13
  21. data/lib/orange-more/adverts/resources/adverts_resource.rb +0 -27
  22. data/lib/orange-more/adverts/views/adverts/adverts.haml +0 -2
  23. data/lib/orange-more/donations.rb +0 -1
  24. data/lib/orange-more/donations/cartons/donation_carton.rb +0 -9
  25. data/lib/orange-more/donations/plugin.rb +0 -12
  26. data/lib/orange-more/donations/resources/donations_resource.rb +0 -51
  27. data/lib/orange-more/donations/views/donations/donate_form.haml +0 -21
  28. data/lib/orange-more/donations/views/donations/donate_thanks.haml +0 -2
  29. data/lib/orange-more/donations/views/donations/paypal_form.haml +0 -13
  30. data/lib/orange-more/events.rb +0 -1
  31. data/lib/orange-more/events/assets/js/events.js +0 -55
  32. data/lib/orange-more/events/cartons/orange_calendar.rb +0 -8
  33. data/lib/orange-more/events/cartons/orange_event.rb +0 -60
  34. data/lib/orange-more/events/plugin.rb +0 -14
  35. data/lib/orange-more/events/resources/calendar_resource.rb +0 -33
  36. data/lib/orange-more/events/resources/event_resource.rb +0 -147
  37. data/lib/orange-more/events/views/calendar/calendar.haml +0 -8
  38. data/lib/orange-more/events/views/events/create.haml +0 -55
  39. data/lib/orange-more/events/views/events/edit.haml +0 -59
  40. data/lib/orange-more/events/views/events/list.haml +0 -13
  41. data/lib/orange-more/events/views/events/show.haml +0 -4
  42. data/lib/orange-more/events/views/events/table_row.haml +0 -17
  43. data/lib/orange-more/members.rb +0 -1
  44. data/lib/orange-more/members/cartons/member_carton.rb +0 -38
  45. data/lib/orange-more/members/plugin.rb +0 -13
  46. data/lib/orange-more/members/resources/members_resource.rb +0 -327
  47. data/lib/orange-more/members/views/members/create.haml +0 -12
  48. data/lib/orange-more/members/views/members/edit.haml +0 -15
  49. data/lib/orange-more/members/views/members/live.show.haml +0 -1
  50. data/lib/orange-more/members/views/members/login.haml +0 -17
  51. data/lib/orange-more/members/views/members/logout.haml +0 -1
  52. data/lib/orange-more/members/views/members/profile.haml +0 -50
  53. data/lib/orange-more/members/views/members/register.haml +0 -37
  54. data/lib/orange-more/subsites.rb +0 -1
  55. data/lib/orange-more/subsites/cartons/subsite.rb +0 -8
  56. data/lib/orange-more/subsites/middleware/subsite_load.rb +0 -29
  57. data/lib/orange-more/subsites/plugin.rb +0 -17
  58. data/lib/orange-more/subsites/resources/subsite_resource.rb +0 -54
  59. data/lib/orange-more/subsites/views/subsites/index.haml +0 -2
  60. data/lib/orange-more/testimonials.rb +0 -1
  61. data/lib/orange-more/testimonials/cartons/testimonials_carton.rb +0 -15
  62. data/lib/orange-more/testimonials/plugin.rb +0 -13
  63. data/lib/orange-more/testimonials/resources/testimonials_resource.rb +0 -42
  64. data/lib/orange-more/testimonials/views/testimonials/testimonials.haml +0 -4
@@ -259,7 +259,12 @@ module Orange
259
259
  if match = route.link_text.match(/^\{([-a-z0-9A-Z_]+)\}$/)
260
260
  resource = route.resource.to_sym
261
261
  return route.link_text unless orange.loaded?(resource)
262
- orange[resource].model_class.get(route.resource_id).__send__(match[1])
262
+ return route.link_text if route.resource_id.blank?
263
+ if my_resource = orange[resource].model_class.get(route.resource_id)
264
+ my_resource.__send__(match[1])
265
+ else
266
+ route.link_text
267
+ end
263
268
  else
264
269
  route.link_text
265
270
  end
@@ -6,12 +6,15 @@ module Orange
6
6
  content = ''
7
7
  resource = (tag.attr['resource'] || :slices).to_sym
8
8
  id = tag.attr['id'] || nil
9
- mode = (tag.attr['mode'] || tag.attr['chunk'] || (id ? :show : :index )).to_sym
9
+ mode = (tag.attr['mode'] || tag.attr['action'] || tag.attr['chunk'] || (id ? :show : :index )).to_sym
10
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, {:attrs => tag.attr}))
11
+ opts = {:attrs => tag.attr, :mode => mode}
12
+ opts.merge!(:id => id) if id
13
+ ret = orange[resource].view(tag.locals.packet, opts)
14
+ if ret.blank?
15
+ content << "resource #{resource} doesn't respond to #{mode}"
13
16
  else
14
- content << "resource #{resource} doesn't respond to #{mode}"
17
+ content << ret
15
18
  end
16
19
  else
17
20
  content << "resource #{resource} not loaded"
@@ -21,7 +24,8 @@ module Orange
21
24
  end
22
25
 
23
26
  def view(packet, *args)
24
- mode = packet['route.resource_action']
27
+ opts = args.extract_options!
28
+ mode = opts[:mode] || packet['route.resource_action']
25
29
  do_view(packet, mode, args.extract_options!)
26
30
  end
27
31
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orange-more
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 7
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 5
9
- - 8
10
- version: 0.5.8
8
+ - 6
9
+ - 0
10
+ version: 0.6.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - David Haslem
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-08 00:00:00 -04:00
18
+ date: 2010-08-23 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -207,11 +207,6 @@ files:
207
207
  - lib/orange-more/administration/views/openid_login.haml
208
208
  - lib/orange-more/administration/views/users/create.haml
209
209
  - lib/orange-more/administration/views/users/edit.haml
210
- - lib/orange-more/adverts.rb
211
- - lib/orange-more/adverts/cartons/adverts_carton.rb
212
- - lib/orange-more/adverts/plugin.rb
213
- - lib/orange-more/adverts/resources/adverts_resource.rb
214
- - lib/orange-more/adverts/views/adverts/adverts.haml
215
210
  - lib/orange-more/analytics.rb
216
211
  - lib/orange-more/analytics/middleware/analytics.rb
217
212
  - lib/orange-more/analytics/plugin.rb
@@ -244,7 +239,7 @@ files:
244
239
  - lib/orange-more/contactforms/assets/js/lib/jquery.form.js
245
240
  - lib/orange-more/contactforms/assets/js/lib/jquery.js
246
241
  - lib/orange-more/contactforms/assets/js/lib/jquery.metadata.js
247
- - lib/orange-more/contactforms/cartons/contactforms_carton.rb
242
+ - lib/orange-more/contactforms/cartons/contactform_carton.rb
248
243
  - lib/orange-more/contactforms/plugin.rb
249
244
  - lib/orange-more/contactforms/resources/contactforms_resource.rb
250
245
  - lib/orange-more/contactforms/views/contactforms/contactform.haml
@@ -257,37 +252,6 @@ files:
257
252
  - lib/orange-more/disqus/plugin.rb
258
253
  - lib/orange-more/disqus/resources/disqus_resource.rb
259
254
  - lib/orange-more/disqus/views/disqus/comment_thread.haml
260
- - lib/orange-more/donations.rb
261
- - lib/orange-more/donations/cartons/donation_carton.rb
262
- - lib/orange-more/donations/plugin.rb
263
- - lib/orange-more/donations/resources/donations_resource.rb
264
- - lib/orange-more/donations/views/donations/donate_form.haml
265
- - lib/orange-more/donations/views/donations/donate_thanks.haml
266
- - lib/orange-more/donations/views/donations/paypal_form.haml
267
- - lib/orange-more/events.rb
268
- - lib/orange-more/events/assets/js/events.js
269
- - lib/orange-more/events/cartons/orange_calendar.rb
270
- - lib/orange-more/events/cartons/orange_event.rb
271
- - lib/orange-more/events/plugin.rb
272
- - lib/orange-more/events/resources/calendar_resource.rb
273
- - lib/orange-more/events/resources/event_resource.rb
274
- - lib/orange-more/events/views/calendar/calendar.haml
275
- - lib/orange-more/events/views/events/create.haml
276
- - lib/orange-more/events/views/events/edit.haml
277
- - lib/orange-more/events/views/events/list.haml
278
- - lib/orange-more/events/views/events/show.haml
279
- - lib/orange-more/events/views/events/table_row.haml
280
- - lib/orange-more/members.rb
281
- - lib/orange-more/members/cartons/member_carton.rb
282
- - lib/orange-more/members/plugin.rb
283
- - lib/orange-more/members/resources/members_resource.rb
284
- - lib/orange-more/members/views/members/create.haml
285
- - lib/orange-more/members/views/members/edit.haml
286
- - lib/orange-more/members/views/members/live.show.haml
287
- - lib/orange-more/members/views/members/login.haml
288
- - lib/orange-more/members/views/members/logout.haml
289
- - lib/orange-more/members/views/members/profile.haml
290
- - lib/orange-more/members/views/members/register.haml
291
255
  - lib/orange-more/news.rb
292
256
  - lib/orange-more/news/cartons/news.rb
293
257
  - lib/orange-more/news/plugin.rb
@@ -330,17 +294,6 @@ files:
330
294
  - lib/orange-more/slices/plugin.rb
331
295
  - lib/orange-more/slices/resources/radius.rb
332
296
  - lib/orange-more/slices/resources/slices.rb
333
- - lib/orange-more/subsites.rb
334
- - lib/orange-more/subsites/cartons/subsite.rb
335
- - lib/orange-more/subsites/middleware/subsite_load.rb
336
- - lib/orange-more/subsites/plugin.rb
337
- - lib/orange-more/subsites/resources/subsite_resource.rb
338
- - lib/orange-more/subsites/views/subsites/index.haml
339
- - lib/orange-more/testimonials.rb
340
- - lib/orange-more/testimonials/cartons/testimonials_carton.rb
341
- - lib/orange-more/testimonials/plugin.rb
342
- - lib/orange-more/testimonials/resources/testimonials_resource.rb
343
- - lib/orange-more/testimonials/views/testimonials/testimonials.haml
344
297
  - README.markdown
345
298
  - spec/orange-core/application_spec.rb
346
299
  - spec/orange-core/carton_spec.rb
@@ -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', 'donations', 'plugin')
@@ -1,9 +0,0 @@
1
- class OrangeDonation < Orange::Carton
2
- id
3
- admin do
4
- title :donor_name, :length => 255
5
- text :donor_company, :length => 255
6
- text :donor_email, :length => 255
7
- text :donation_amount
8
- end
9
- end
@@ -1,12 +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 Donations < Base
6
- views_dir File.join(File.dirname(__FILE__), 'views')
7
-
8
- resource Orange::DonationsResource.new
9
- end
10
- end
11
-
12
- Orange.plugin(Orange::Plugins::Donations.new)
@@ -1,51 +0,0 @@
1
- module Orange
2
- class DonationsResource < Orange::ModelResource
3
- use OrangeDonation
4
- call_me :donations
5
- def stack_init
6
- orange[:admin, true].add_link("Content", :resource => @my_orange_name, :text => 'Donations')
7
- orange[:radius].define_tag "donations" do |tag|
8
- template = tag.attr["template"] || "donate_form"
9
- orange[:donations].form(tag.locals.packet, {:template => template})
10
- end
11
- end
12
-
13
- def form(packet, opts = {})
14
- template = opts[:template].to_sym || :donate_form
15
- packet['route.return_path'] = packet.request.path.to_s
16
- do_view(packet, template, opts)
17
- end
18
-
19
- def donate_cancel(packet, opts = {})
20
- id = packet.session['donation_id']
21
- m = model_class.get(id)
22
- m.destroy!
23
- packet.flash['error'] = "There was an issue completing the process on Paypal."
24
- packet.reroute((packet.flash('reroute.to') || '/'))
25
- end
26
-
27
- def process(packet, opts = {})
28
- params = packet.request.params
29
- route = params.delete('r')
30
- params['donation_amount'] = params['donation_amount'].sub(/\$/, '')
31
- if params['donor_phone'] == '' && packet.request.post? && params['donation_amount'] != '' && params['donation_amount'].to_f > 0
32
- template = "paypal_form"
33
- params.delete('donor_phone')
34
- obj = self.new(packet, {:no_reroute => true, :params => params})
35
- packet.session['donation_id'] = obj.id
36
- packet.flash['reroute.to'] = route
37
- opts[:donation_amount] = params['donation_amount']
38
- opts[:paypal_id] = orange.options['paypal_id'] || ''
39
- do_view(packet, template, opts)
40
- else
41
- packet.flash['error'] = "An error has occurred. Please try your submission again."
42
- packet.reroute(route)
43
- end
44
- end
45
-
46
- def donate_success(packet, opts = {})
47
- template = "donate_thanks"
48
- do_view(packet, template, opts)
49
- end
50
- end
51
- end
@@ -1,21 +0,0 @@
1
- :javascript
2
- $(function(){
3
- $('#donate_form').validate();
4
- });
5
- %p
6
- - if(flash['error'])
7
- .error= flash('error')
8
- %form{ :class => 'donate_form', :id => 'donate_form', :action => route_to(:donations, :process), :method => 'POST' }
9
- %label{ :for => 'donor_name'} Your Name
10
- %input{ :type => 'text', :minlength => '4', :maxlength => '80', :id => 'donor_name', :name => 'donor_name', :class => 'required' }
11
- %div.donor_phone
12
- %label{ :for => 'donor_phone'} Your Phone
13
- %input{ :type => 'text', :minlength => '4', :maxlength => '80', :id => 'donor_phone', :name => 'donor_phone', :value => '' }
14
- %label{ :for => 'donor_company'} Your Company
15
- %input{ :type => 'text', :minlength => '4', :maxlength => '180', :id => 'donor_company', :name => 'donor_company', :value => '' }
16
- %label{ :for => 'donor_email'} Your E-mail
17
- %input{ :type => 'text', :class => 'email', :id => 'donor_email', :name => 'donor_email' }
18
- %label{ :for => 'donation_amount'} Donation Amount: $
19
- %input{ :type => 'text', :class => 'donation_amount', :id => 'donation_amount', :name => 'donation_amount' }
20
- %input{ :type => 'submit', :value => 'Submit' }
21
- %input{ :type => 'hidden', :id => 'r', :name => 'r', :value => packet['route.return_path'] }
@@ -1,2 +0,0 @@
1
- %h3 Thank You!
2
- %p Thanks for your donation!
@@ -1,13 +0,0 @@
1
- %h3 Redirecting to PayPal...
2
- %form{ :id => 'pform', :name => '_xclick', :action => 'https://www.paypal.com/cgi-bin/webscr', :method => "post" }
3
- %input{ :type => 'hidden', :name => 'cmd', :value => "_donations" }
4
- %input{ :type => 'hidden', :name => 'business', :value => paypal_id }
5
- %input{ :type => 'hidden', :name => 'item_name', :value => "WNSF Donation" }
6
- %input{ :type => 'hidden', :name => 'currency_code', :value => "USD" }
7
- %input{ :type => 'hidden', :name => 'amount', :value => donation_amount }
8
- %input{ :type => 'hidden', :name => 'return', :value => 'http://'+packet['route.site_url'] + route_to(:donations, :donate_success) }
9
- %input{ :type => 'hidden', :name => 'cancel_return', :value => 'http://'+packet['route.site_url'] + route_to(:donations, :donate_cancel)}
10
- :javascript
11
- $(function(){
12
- $('#pform').submit();
13
- })
@@ -1 +0,0 @@
1
- require File.join('orange-more', 'events', 'plugin')
@@ -1,55 +0,0 @@
1
- $(function(){
2
- $('.new-venue').hide();
3
- $('.show-venue-details').toggle(venue_details_show, venue_details_hide);
4
- $("#events-venue").change(function(){
5
- if($(this).val() == "new"){
6
- venue_details_blank();
7
- if($('.new-venue').css('display') == 'none') $('.show-venue-details').click();
8
- }
9
- else{
10
- load_venue_details($(this).val());
11
- }
12
- });
13
- $('input[name*=link_to_eventbrite]').change(function(){
14
- if($(this).attr('checked')){
15
- $('p.eventbrite-link').show();
16
- }
17
- else{
18
- $('p.eventbrite-link').hide();
19
- }
20
- });
21
- $('#events-eventbrite-id').change(function(){
22
- load_event_details($(this).val());
23
- });
24
- $("input[name*='location']").change(function(){$("#events-venue").val("new")});
25
- });
26
-
27
- function venue_details_show(){
28
- $('.show-venue-details').text('Hide');
29
- $('.new-venue').show();
30
- }
31
-
32
- function venue_details_hide(){
33
- $('.show-venue-details').text('(Details)');
34
- $('.new-venue').hide();
35
- }
36
-
37
- function load_venue_details(id){
38
- var obj = venues[id];
39
- $("input[name*=location_name]").val(obj.name);
40
- $("input[name*=location_address]").val(obj.address);
41
- $("input[name*=location_address2]").val(obj.address_2);
42
- $("input[name*=location_city]").val(obj.city);
43
- $("input[name*=location_state]").val(obj.region);
44
- $("input[name*=location_zip]").val(obj.postal_code);
45
- }
46
-
47
- function load_event_details(id){
48
- var obj = events[id];
49
- $("input[name*='events[name]']").val(obj.title);
50
- $("textarea[name*=description]").val(obj.description);
51
- }
52
-
53
- function venue_details_blank(){
54
- $("input[name*='location']").val('');
55
- }
@@ -1,8 +0,0 @@
1
- class OrangeCalendar < Orange::SiteCarton
2
- id
3
- admin do
4
- title :name
5
- boolean :main, :default => false, :display_name =>'Main Calendar?'
6
- end
7
- has n, :events, "OrangeEvent"
8
- end
@@ -1,60 +0,0 @@
1
- class OrangeEvent < Orange::Carton
2
- id
3
- admin do
4
- title :name
5
- text :location_name
6
- text :location_address
7
- text :location_address2
8
- text :location_city
9
- text :location_state
10
- text :location_zip
11
- boolean :link_to_eventbrite, :default => false
12
- text :eventbrite_id
13
- fulltext :blurb
14
- fulltext :description
15
- end
16
- orange do
17
- time :starts
18
- time :ends
19
- end
20
-
21
- def starts_time
22
- self.starts.strftime("%I:%M %p")
23
- end
24
- def starts_date
25
- self.starts.strftime("%m/%d/%Y")
26
- end
27
- def ends_time
28
- self.ends.strftime("%I:%M %p")
29
- end
30
- def ends_date
31
- self.ends.strftime("%m/%d/%Y")
32
- end
33
- def date_attr(attribute, datestr = false)
34
- time_attr(attribute, false, datestr)
35
- end
36
-
37
- def attribute_time_get(attribute)
38
- attribute_get(attribute) || Time.now
39
- end
40
- def time_attr(attribute, timestr = false, datestr = false)
41
- date = datestr || attribute_time_get(attribute).strftime("%m/%d/%Y")
42
- time = timestr || attribute_time_get(attribute).strftime("%I:%M %p")
43
- attribute_set(attribute, Time.parse(date + " " + time))
44
- end
45
-
46
- def starts_time=(time)
47
- time_attr(:starts, time)
48
- end
49
- def starts_date=(date)
50
- date_attr(:starts, date)
51
- end
52
- def ends_time=(time)
53
- time_attr(:ends, time)
54
- end
55
- def ends_date=(date)
56
- date_attr(:ends, date)
57
- end
58
-
59
- belongs_to :calendar, "OrangeCalendar", :child_key => [:orange_calendar_id]
60
- end