orange 0.2.7 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -105,6 +105,8 @@ Required Gems
105
105
  * radius
106
106
  * crack
107
107
  * eventbright
108
+ * spreedly
109
+ * hominid
108
110
 
109
111
  All dependencies should be loaded if you install the gem except for the datamapper
110
112
  adapter relevant to your set up. If, for example, you want to use a mysql database,
@@ -40,7 +40,7 @@ module Orange
40
40
  packet['reroute.to']
41
41
  # Parsing for orange urls or something
42
42
  when :orange
43
- packet.route_to(packet['reroute.to'], packet['reroute.args', []])
43
+ packet.route_to(packet['reroute.to'], *packet['reroute.args', []])
44
44
  else
45
45
  packet['reroute.to']
46
46
  end
@@ -10,7 +10,8 @@ module Orange
10
10
  def route_to(packet, resource, *args)
11
11
  opts = args.extract_options!
12
12
  packet = DefaultHash.new unless packet
13
- context = opts[:context] || packet['route.context', nil]
13
+ context = opts[:context]
14
+ context = packet['route.context', nil] unless (context || (packet['route.context'] == :live))
14
15
  site = packet['route.faked_site'] ? packet['route.site_url', nil] : nil
15
16
  args.unshift(resource)
16
17
  args.unshift(context)
@@ -103,11 +103,11 @@ module Orange
103
103
  def new(packet, opts = {})
104
104
  no_reroute = opts.delete(:no_reroute)
105
105
  if packet.request.post? || !opts.blank?
106
- params = opts.with_defaults(packet.request.params[@my_orange_name.to_s] || {})
107
- beforeNew(packet, params)
108
- obj = onNew(packet, params)
109
- afterNew(packet, obj, params)
110
- obj.save if obj
106
+ params = opts.with_defaults(opts.delete(:params) || packet.request.params[@my_orange_name.to_s] || {})
107
+ before = beforeNew(packet, params)
108
+ obj = onNew(packet, params) if before
109
+ afterNew(packet, obj, params) if before
110
+ obj.save if obj && before
111
111
  end
112
112
  packet.reroute(@my_orange_name, :orange) unless (packet.request.xhr? || no_reroute)
113
113
  obj || false
@@ -121,6 +121,7 @@ module Orange
121
121
  # A callback for before a new item is created
122
122
  # @param [Orange::Packet] packet the packet being routed
123
123
  def beforeNew(packet, opts = {})
124
+ true
124
125
  end
125
126
 
126
127
  # A callback for after a new item is created
@@ -137,14 +138,15 @@ module Orange
137
138
  if packet.request.delete? || !opts.blank?
138
139
  id = opts.delete(:resource_id) || packet['route.resource_id']
139
140
  m = model_class.get(packet['route.resource_id'])
140
- beforeDelete(packet, m, opts)
141
- onDelete(packet, m, opts) if m
142
- afterDelete(packet, m, opts)
141
+ before = beforeDelete(packet, m, opts)
142
+ onDelete(packet, m, opts) if m && before
143
+ afterDelete(packet, m, opts) if before
143
144
  end
144
145
  packet.reroute(@my_orange_name, :orange) unless (packet.request.xhr? || no_reroute)
145
146
  end
146
147
 
147
148
  def beforeDelete(packet, obj, opts = {})
149
+ true
148
150
  end
149
151
 
150
152
  # Delete object
@@ -160,18 +162,20 @@ module Orange
160
162
  def save(packet, opts = {})
161
163
  no_reroute = opts.delete(:no_reroute)
162
164
  if packet.request.post? || !opts.blank?
163
- params = opts.with_defaults(packet.request.params[@my_orange_name.to_s] || {})
164
- m = model_class.get(packet['route.resource_id'])
165
+ my_id = opts.delete(:resource_id) || packet['route.resource_id']
166
+ m = opts.delete(:model) || model_class.get(my_id)
167
+ params = opts.with_defaults(opts.delete(:params) || packet.request.params[@my_orange_name.to_s] || {})
165
168
  if m
166
- beforeSave(packet, m, params)
167
- onSave(packet, m, params)
168
- afterSave(packet, m, params)
169
+ before = beforeSave(packet, m, params)
170
+ onSave(packet, m, params) if before
171
+ afterSave(packet, m, params) if before
169
172
  end
170
173
  end
171
174
  packet.reroute(@my_orange_name, :orange) unless (packet.request.xhr? || no_reroute)
172
175
  end
173
176
 
174
177
  def beforeSave(packet, obj, opts = {})
178
+ true
175
179
  end
176
180
 
177
181
  def onSave(packet, obj, opts = {})
data/lib/orange-more.rb CHANGED
@@ -16,4 +16,5 @@ require File.join(libdir, 'orange-more', 'adverts')
16
16
  require File.join(libdir, 'orange-more', 'cloud')
17
17
  require File.join(libdir, 'orange-more', 'debugger')
18
18
  require File.join(libdir, 'orange-more', 'subsites')
19
- require File.join(libdir, 'orange-more', 'events')
19
+ require File.join(libdir, 'orange-more', 'events')
20
+ require File.join(libdir, 'orange-more', 'members')
@@ -42,12 +42,29 @@ module Orange
42
42
  extras
43
43
  end
44
44
 
45
+ def synchronize_attendees(packet, params = {})
46
+ no_reroute = params.delete(:no_reroute)
47
+ params = params.with_defaults(:resource_id => packet['route.resource_id'])
48
+ if packet.request.post? && orange.loaded?(:members) &&
49
+ event_orange = model_class.get(params[:resource_id])
50
+ event = eventbrite_user.events.select{|e| e.id.to_s == event_orange.eventbrite_id}.first
51
+ orange[:members, true].add_attendee_group(packet, "Eventbrite Attendee", "#{event.title} - #{event.id}")
52
+ emails = event.attendees.map{|a| a.email}
53
+ orange[:members, true].batch_update_interest_mailchimp(packet, emails, "Eventbrite Attendee", "#{event.title} - #{event.id}")
54
+ end
55
+ packet.reroute(@my_orange_name, :orange, packet['route.resource_id']) unless no_reroute
56
+ end
57
+
58
+ # Todo - eventbrite crashes when date in past
45
59
  def beforeNew(packet, params = {})
46
60
  eventbrite_synchronize(packet, params)
61
+ true
47
62
  end
48
63
 
64
+ # Todo - eventbrite crashes when date in past
49
65
  def beforeSave(packet, model, params = {})
50
66
  eventbrite_synchronize(packet, params)
67
+ true
51
68
  end
52
69
 
53
70
  def eventbrite_synchronize(packet, params = {})
@@ -2,4 +2,7 @@
2
2
  - for event in list
3
3
  .event
4
4
  %h2 #{event.name}
5
- .description= event.description
5
+ .description
6
+ = event.blurb
7
+
8
+ %a{:href => route_to(:events, event.id)} Learn More
@@ -54,5 +54,6 @@
54
54
  at
55
55
  %input{:type => 'text', :name => "#{model_name}[ends_time]", :size => 8, :value => model.ends_time }
56
56
  %input{:type => 'submit', :value => 'Save Event'}
57
+ = form_link('Synchronize Eventbrite Attendees to Mailchimp', route_to(model_name, model.id, 'synchronize_attendees'))
57
58
  - else
58
59
  %p Couldn't find the event.
@@ -0,0 +1,4 @@
1
+ -# Given a list of events...
2
+ .event
3
+ %h2 #{model.name}
4
+ .description= model.description
@@ -0,0 +1 @@
1
+ require File.join('orange-more', 'members', 'plugin')
@@ -0,0 +1,39 @@
1
+ require 'md5'
2
+
3
+ class OrangeMember < Orange::Carton
4
+ id
5
+ front do
6
+ text :first_name
7
+ text :last_name
8
+ text :email
9
+ text :position
10
+ text :company
11
+ end
12
+ text :hashed_password
13
+ text :salt
14
+ text :reset_token
15
+ property :reset_on, DateTime
16
+
17
+ def password=(val)
18
+ salt = self.salt
19
+ attribute_set(:hashed_password, Digest::MD5.hexdigest("#{salt}orange-is-awesome#{val}"))
20
+ end
21
+
22
+ def salt
23
+ my_salt = attribute_get(:salt)
24
+ unless(my_salt)
25
+ my_salt = Digest::MD5.hexdigest(Time.now.iso8601)
26
+ attribute_set(:salt, my_salt)
27
+ end
28
+ my_salt
29
+ end
30
+
31
+ def reset!
32
+ token = Digest::MD5.hexdigest(Time.now.iso8601)
33
+ # Invalidate password
34
+ attribute_set(:hashed_password, Digest::MD5.hexdigest("#{salt}#{token}"))
35
+ attribute_set(:reset_on, DateTime)
36
+ attribute_set(:reset_token, token)
37
+ end
38
+
39
+ end
@@ -0,0 +1,13 @@
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 Members < Base
6
+ views_dir File.join(File.dirname(__FILE__), 'views')
7
+
8
+ resource Orange::MembersResource.new
9
+ end
10
+ end
11
+
12
+ Orange.plugin(Orange::Plugins::Members.new)
13
+
@@ -0,0 +1,291 @@
1
+ require 'spreedly'
2
+ require 'hominid'
3
+
4
+ module Orange
5
+ class MembersResource < Orange::ModelResource
6
+ use OrangeMember
7
+ call_me :members
8
+ def stack_init
9
+ options[:spreedly_key] = orange.options['spreedly_key'] || false
10
+ options[:spreedly_plan] = orange.options['spreedly_plan'] || false
11
+ options[:spreedly_site] = orange.options['spreedly_site'] || false
12
+ options[:mailchimp_key] = orange.options["mailchimp_key"] || false
13
+ options[:mailchimp_list] = orange.options["mailchimp_list"] || false
14
+ options[:mailchimp_interests] = orange.options["mailchimp_interests"] || false
15
+ Spreedly.configure(options[:spreedly_site], options[:spreedly_key]) if options[:spreedly_key]
16
+
17
+ orange[:admin, true].add_link("Settings", :resource => @my_orange_name, :text => 'Members')
18
+ orange[:radius, true].define_tag "if_member" do |tag|
19
+ packet = tag.locals.packet
20
+ if packet.session["member"]
21
+ tag.expand
22
+ else
23
+ if(tag.attr["else_view"])
24
+ orange[:members].do_view(packet, tag.attr["else_view"].to_sym)
25
+ else
26
+ ""
27
+ end
28
+ end
29
+ end
30
+ orange[:radius, true].define_tag "if_paid_member" do |tag|
31
+ packet = tag.locals.packet
32
+ if packet.session["member"] && orange[:members].paid?(packet, packet.session["member"])
33
+ tag.expand
34
+ else
35
+ if(tag.attr["else_view"])
36
+ orange[:members].do_view(packet, tag.attr["else_view"].to_sym)
37
+ else
38
+ ""
39
+ end
40
+ end
41
+ end
42
+ orange[:radius, true].define_tag "unless_member" do |tag|
43
+ packet = tag.locals.packet
44
+ unless packet.session["member"]
45
+ tag.expand
46
+ else
47
+ ""
48
+ end
49
+ end
50
+ end
51
+
52
+ def hominid
53
+ @hominid ||= Hominid::Base.new({:api_key => options[:mailchimp_key]}) if options[:mailchimp_key]
54
+ end
55
+
56
+ def hominid_list
57
+ @hominid_list ||= hominid.find_list_by_id(options[:mailchimp_list]) if options[:mailchimp_list] && hominid
58
+ end
59
+
60
+
61
+
62
+ def paid?(packet, member)
63
+ unless member.is_a? model_class
64
+ member = model_class.get(member)
65
+ end
66
+ subscriber = Spreedly::Subscriber.find(member.id)
67
+ subscriber ? subscriber.active? : false
68
+ end
69
+
70
+ def subscription_url(packet, member)
71
+ unless member.is_a? model_class
72
+ member = model_class.get(member)
73
+ end
74
+ Spreedly.subscribe_url(member.id, options[:spreedly_plan])
75
+ end
76
+
77
+ def list_groups(packet)
78
+ hominid.call("listInterestGroupings", options[:mailchimp_list]).select{|g| options[:mailchimp_interests].include? g["name"]}
79
+ end
80
+
81
+ def list_groups_for_email(packet, email)
82
+ chimp_info = hominid.member_info(options[:mailchimp_list], email)
83
+ end
84
+ #
85
+ # def add_to_mailchimp(packet, member_params)
86
+ # email = member_params[:email]
87
+ # fname = member_params[:first_name]
88
+ # lname = member_params[:last_name]
89
+ # interests = member_params[:groups].map{|key, val|
90
+ # { "name" => key, "groups" => groups.map{|str| str.gsub(/,/, "\,")}.join(",") }
91
+ # }
92
+ # hominid.subscribe(options[:mailchimp_list], email, {:FNAME => fname, :LNAME => lname, :INTERESTS => interests}, {:update_existing => true})
93
+ # end
94
+
95
+ def synchronize_with_mailchimp(packet, member_params)
96
+ email = member_params["email"]
97
+ old_email = member_params["old_email"] || email
98
+ fname = member_params["first_name"] || ''
99
+ lname = member_params["last_name"] || ''
100
+ interests = member_params["groups"].blank? ? [] : member_params["groups"].map{|key, val|
101
+ { "name" => key, "groups" => val.reject{|str| str.blank? }.map{|str| str.gsub(/,/, '\,')}.join(",") }
102
+ }
103
+ hominid.subscribe(options[:mailchimp_list], old_email, {:FNAME => fname, :LNAME => lname, :GROUPINGS => interests}, {:update_existing => true})
104
+ end
105
+
106
+ def batch_update_interest_mailchimp(packet, emails, grouping_name, groups)
107
+ interests = [{ "name" => grouping_name, "groups" => groups }]
108
+ emails = emails.map{|e| {:EMAIL => e, :GROUPINGS => interests}}
109
+ hominid.subscribe_many(options[:mailchimp_list], emails, {:double_opt_in => true, :update_existing => true, :replace_interests => false})
110
+ end
111
+
112
+ def add_attendee_group(packet, grouping_name, name, limit = 15)
113
+ list = options[:mailchimp_list]
114
+ my_groups = hominid.call("listInterestGroupings", list)
115
+ grouping = my_groups.select{|a| a["name"] == grouping_name}.first
116
+ if grouping
117
+ # Return true if already in the list.
118
+ return true if grouping["groups"].select{|a| a["name"] == name }.size > 0
119
+
120
+ # Keep group size manageable
121
+ if grouping["groups"].size > limit
122
+ remove = grouping["groups"].shift
123
+ hominid.call("listInterestGroupDel", list, remove["name"], grouping["id"])
124
+ end
125
+ hominid.call("listInterestGroupAdd", list, name, grouping["id"])
126
+ else
127
+ hominid.call("listInterestGroupingAdd", list, grouping_name, "checkboxes", [name] )
128
+ end
129
+ end
130
+
131
+ def unsubscribe_from_mailchimp(packet, email)
132
+ hominid.unsubscribe(options[:mailchimp_list], email)
133
+ end
134
+
135
+ def member_list_groups(packet, member)
136
+ # Can give member id, hydrate to member before continuing.
137
+ unless member.is_a? model_class
138
+ member = model_class.get(member)
139
+ end
140
+
141
+ end
142
+
143
+ def login(packet, opts = {})
144
+ if packet.request.post?
145
+ params = packet.request.params["members"]
146
+ login = params["login_email"]
147
+ password = params["login_password"]
148
+ tester = model_class.new({:password => password})
149
+ member = model_class.first({:email => login})
150
+ if member && tester.hashed_password == member.hashed_password
151
+ packet.session["member"] = member.id
152
+ packet.reroute(@my_orange_name, :orange, :profile)
153
+ else
154
+ packet.flash("error", "Invalid email or password")
155
+ do_view(packet, :login, opts)
156
+ end
157
+ else
158
+ do_view(packet, :login, opts)
159
+ end
160
+ end
161
+
162
+ def register(packet, opts = {})
163
+ if packet.request.post?
164
+ params = packet.request.params["members"]
165
+
166
+ member = model_class.first(:email => params["email"])
167
+ if member
168
+ # Existing member... do they already have password?
169
+ if member.hashed_password.blank?
170
+ # A member who is part of the mailing list, but hasn't
171
+ # set a password
172
+ email = params.delete("email")
173
+ mailing_list = params.delete("email_subscribe")
174
+ groups = params.delete("groups")
175
+ save(packet, {:resource_id => member.id, :params => params, :no_reroute => true})
176
+ member = model_class.first(:email => email)
177
+ if member.hashed_password.blank?
178
+ # Problem, stay on registration
179
+ do_view(packet, :register, opts.merge(:list_groups => list_groups(packet)))
180
+ else
181
+ packet.flash("info", "Looks like this email address was already on our mailing list. Please take the time to correct our details about you.")
182
+ packet.session["member"] = member.id
183
+ # Synchronize with the mailchimp account.
184
+ params.merge!("groups" => groups)
185
+ synchronize_with_mailchimp(packet, params.merge("groups" => groups, "email" => email)) if mailing_list
186
+ packet.reroute(@my_orange_name, :orange, :profile)
187
+ end
188
+ else
189
+ # A person trying to sign up with an email that already
190
+ # has a password
191
+ packet.flash("error", "Looks like this email address already has an account. Try logging in instead.")
192
+ packet.reroute(@my_orange_name, :orange, :login)
193
+ end
194
+ else
195
+ # New member time!
196
+ mailing_list = params.delete("email_subscribe")
197
+ groups = params.delete("groups")
198
+ new(packet, {:no_reroute => true, :params => params})
199
+ # success ?
200
+ member = model_class.first(:email => params["email"])
201
+ if member
202
+ packet.session["member"] = member.id
203
+ params.merge!("groups" => groups)
204
+ synchronize_with_mailchimp(packet, params.merge("groups" => groups)) if mailing_list
205
+ packet.flash("info", "You've successfully created an account. Please take the time to fill in more details about yourself.")
206
+ packet.reroute(@my_orange_name, :orange, :profile)
207
+ else
208
+ # Problem, stay on registration
209
+ do_view(packet, :register, opts.merge(:list_groups => list_groups(packet)))
210
+ end
211
+ end # End pre-existing member if
212
+ else
213
+ do_view(packet, :register, opts.merge(:list_groups => list_groups(packet)))
214
+ end
215
+ end
216
+
217
+ def logout(packet, opts = {})
218
+ packet.session["member"] = nil
219
+ do_view(packet, :logout, opts)
220
+ end
221
+
222
+ def profile(packet, opts = {})
223
+ no_reroute = opts.delete(:no_reroute)
224
+ # login check
225
+ unless packet.session["member"]
226
+ packet.flash("error", "You must log in to view this page")
227
+ packet.reroute(@my_orange_name, :orange, :login)
228
+ end
229
+
230
+ if packet.request.post?
231
+ params = packet.request.params["members"]
232
+ if params["current_password"].blank?
233
+ # Can't change password without confirming current
234
+ params.delete("password")
235
+ params.delete("repeat_password")
236
+ password_change = false
237
+ else
238
+ password_change = true
239
+ end
240
+ member = model_class.get(packet.session["member"])
241
+ check = model_class.new(:password => params.delete("current_password"))
242
+ if !password_change || member.hashed_password == check.hashed_password
243
+
244
+ mailing_list = params.delete("email_subscribe")
245
+ groups = params.delete("groups")
246
+ old_email = member.email
247
+ save(packet, {:resource_id => packet.session["member"], :no_reroute => true, :params => params})
248
+ if mailing_list == "1"
249
+ synchronize_with_mailchimp(packet, params.merge("groups" => groups, "old_email" => old_email))
250
+ else
251
+ unsubscribe_from_mailchimp(packet, params["email"])
252
+ end
253
+ else
254
+ packet.flash("error", "Your old password was not input correctly")
255
+ end
256
+ end
257
+ member = model_class.get(packet.session["member"])
258
+ opts[:model] = member
259
+ do_view(packet, :profile, opts.merge(:list_groups => list_groups(packet)))
260
+ end
261
+
262
+
263
+ def beforeNew(packet, params)
264
+ unless params["password"] == params["repeat_password"]
265
+ packet.flash("error", "New password does not match repeated password")
266
+ return false
267
+ end
268
+ unless params["password"].blank? || params["password"].size >= 6
269
+ packet.flash("error", "Password should be over 6 characters")
270
+ return false
271
+ end
272
+ params.delete("password") if params["password"].blank?
273
+ params.delete("repeat_password")
274
+ true
275
+ end
276
+
277
+ def beforeSave(packet, m, params)
278
+ unless params["password"] == params["repeat_password"]
279
+ packet.flash("error", "New password does not match repeated password")
280
+ return false
281
+ end
282
+ unless params["password"].blank? || params["password"].size >= 6
283
+ packet.flash("error", "Password should be over 6 characters")
284
+ return false
285
+ end
286
+ params.delete("password") if params["password"].blank?
287
+ params.delete("repeat_password")
288
+ true
289
+ end
290
+ end
291
+ end
@@ -0,0 +1,12 @@
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
+ %p
5
+ %label{:for => "my_password"} Password
6
+ %br
7
+ %input{:id => "my_password", :type => "password", :name => "#{model_name}[password]"}
8
+ %p
9
+ %label{:for => "my_repeat_password"} Repeat Password
10
+ %br
11
+ %input{:id => "my_repeat_password", :type => "password", :name => "#{model_name}[repeat_password]"}
12
+ %input{:type => 'submit', :value => 'Save New Item'}
@@ -0,0 +1,15 @@
1
+ - if model
2
+ %form{:action => packet.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
+ %p
6
+ %label{:for => "my_password"} Password
7
+ %br
8
+ %input{:id => "my_password", :type => "password", :name => "#{model_name}[password]"}
9
+ %p
10
+ %label{:for => "my_repeat_password"} Repeat Password
11
+ %br
12
+ %input{:id => "my_repeat_password", :type => "password", :name => "#{model_name}[repeat_password]"}
13
+ %input{:type => 'submit', :value => 'Save Changes'}
14
+ - else
15
+ %p Couldn't find the item you're looking for.
@@ -0,0 +1 @@
1
+ %p You don't have permission to view this.
@@ -0,0 +1,17 @@
1
+ %form{:action => packet.route_to(model_name, 'login'), :method => 'post'}
2
+ - if(packet.flash['error'])
3
+ .error
4
+ %p= packet.flash('error')
5
+ %p
6
+ %label Email
7
+ %br
8
+ %input{:type => "text", :name => "members[login_email]"}
9
+ %p
10
+ %label Password
11
+ %br
12
+ %input{:type => "password", :name => "members[login_password]"}
13
+ %input{:type => "submit", :value => "Log in"}
14
+ %hr
15
+ %p
16
+ Not a member? You can
17
+ %a{:href => route_to(model_name, 'register')} register here
@@ -0,0 +1 @@
1
+ %p You have been logged out.
@@ -0,0 +1,50 @@
1
+ - if model
2
+ %form{:action => packet.route_to(model_name, 'profile'), :method => 'post'}
3
+ - if(packet.flash['error'])
4
+ .error
5
+ %p= packet.flash('error')
6
+ - if(packet.flash['info'])
7
+ .info
8
+ %p= packet.flash('info')
9
+ - for prop in props
10
+ %p!= view_attribute(prop, model_name, :label => true, :value => model.attribute_get(prop[:name]))
11
+ %fieldset
12
+ %legend Change Password
13
+ %p You only need to fill out the following information if you want to change your password
14
+ %p
15
+ %label{:for => "my_currrent_password"} Current Password
16
+ %br
17
+ %input{:id => "my_currrent_password", :type => "password", :name => "#{model_name}[current_password]"}
18
+ %p
19
+ %label{:for => "my_password"} Password
20
+ %br
21
+ %input{:id => "my_password", :type => "password", :name => "#{model_name}[password]"}
22
+ %p
23
+ %label{:for => "my_repeat_password"} Repeat Password
24
+ %br
25
+ %input{:id => "my_repeat_password", :type => "password", :name => "#{model_name}[repeat_password]"}
26
+ %fieldset
27
+ %legend Mailing Lists
28
+ %p
29
+ %input{:type => "hidden", :name => "members[email_subscribe]", :value => "0"}
30
+ %input{:type => "checkbox", :name => "members[email_subscribe]", :value => "1"}
31
+ Sign up for the mailing list?
32
+ %p We separate our mailing list into multiple topics to avoid spamming our users with unwanted emails. Choose the information you would like to receive email about.
33
+ - for group in list_groups
34
+ %h2= group["name"].capitalize
35
+ %input{:type => "hidden", :name => "members[groups][#{group['name']}][]", :value => ""}
36
+ - for opt in group["groups"]
37
+ %p
38
+ %input{:type => "checkbox", :name => "members[groups][#{group['name']}][]", :value => opt["name"]}
39
+ = opt["name"]
40
+ %fieldset
41
+ %legend Payment
42
+ - if(orange[:members].paid?(packet, model))
43
+ %p Thanks for supporting the WNSF. You can keep your subscription up to date below:
44
+ %a{:href => orange[:members].subscription_url(packet, model)} Make a payment
45
+ - else
46
+ %p To access parts of this site, you'll need to be a supporting member.
47
+ %a{:href => orange[:members].subscription_url(packet, model)} You can become a supporting member here.
48
+ %input{:type => 'submit', :value => 'Save Changes'}
49
+ - else
50
+ %p Couldn't find the item you're looking for.
@@ -0,0 +1,31 @@
1
+ %form{:action => packet.route_to(model_name, 'register'), :method => 'post'}
2
+ - if(packet.flash['error'])
3
+ .error
4
+ %p= packet.flash('error')
5
+ %p Fill out the following details to register for an account.
6
+ %p
7
+ %label Email
8
+ %br
9
+ %input{:type => "text", :name => "members[email]"}
10
+ %p
11
+ %label Password
12
+ %br
13
+ %input{:type => "password", :name => "members[password]"}
14
+ %p
15
+ %label Repeat Password
16
+ %br
17
+ %input{:type => "password", :name => "members[repeat_password]"}
18
+ %fieldset
19
+ %legend Mailing Lists
20
+ %p
21
+ %input{:type => "checkbox", :name => "members[email_subscribe]", :value => "1"}
22
+ Sign up for the mailing list?
23
+ %p We separate our mailing list into multiple topics to avoid spamming our users with unwanted emails. Choose the information you would like to receive email about.
24
+ - for group in list_groups
25
+ %h2= group["name"].capitalize
26
+ %input{:type => "hidden", :name => "members[groups][#{group['name']}][]", :value => ""}
27
+ - for opt in group["groups"]
28
+ %p
29
+ %input{:type => "checkbox", :name => "members[groups][#{group['name']}][]", :value => opt["name"]}
30
+ = opt["name"]
31
+ %input{:type => "submit", :value => "Register"}
@@ -19,6 +19,7 @@ module Orange
19
19
  :link_text => 'Orange News Archive'
20
20
  )
21
21
  end
22
+ true
22
23
  end
23
24
 
24
25
  def sitemap_row(packet, opts = {})
@@ -7,6 +7,17 @@ module Orange
7
7
  call_me :sitemap
8
8
  def stack_init
9
9
  orange[:admin, true].add_link('Content', :resource => @my_orange_name, :text => 'Sitemap')
10
+ orange[:radius, true].define_tag "link" do |tag|
11
+ packet = tag.locals.packet
12
+ slug = tag.expand
13
+ route = orange[:sitemap].find_route(packet, {:slug => slug})
14
+ route = orange[:sitemap].find_route(packet, {:link_text => slug}) unless route
15
+
16
+ full_path = route ? route.full_path : "#not-found"
17
+ link_text = route ? route.link_text : "(Broken link tag)"
18
+ link_text = tag.attr["text"] if tag.attr["text"]
19
+ "<a href='#{full_path}'>#{link_text}</a>"
20
+ end
10
21
  end
11
22
 
12
23
  def route_actions(packet, opts = {})
@@ -135,6 +146,15 @@ module Orange
135
146
  model_class.all(keys)
136
147
  end
137
148
 
149
+ def find_route(packet, opts = {})
150
+ site_id = packet['site'].id
151
+ subsite_id = packet['subsite'].blank? ? nil : packet['subsite'].id
152
+ # First try subsite, if necessary
153
+ m = model_class.first(opts.merge(:orange_site_id => subsite_id)) if subsite_id
154
+ m = model_class.first(opts.merge(:orange_site_id => site_id)) unless m
155
+ m
156
+ end
157
+
138
158
  def add_link_for(packet)
139
159
  linky = ['add_route']
140
160
  linky << (packet['subsite'].blank? ? (packet['site'].blank? ? '0' : packet['site'].id) : packet['subsite'].id)
@@ -1,5 +1,12 @@
1
- %p
2
- - for a in model.ancestors
3
- %a{:href => a.full_path}= a.link_text
1
+ - if model
2
+ %p
3
+ - for a in model.ancestors
4
+ %a{:href => a.full_path}= a.link_text
5
+ &gt;
6
+ %span.here= model.link_text
7
+ - else # Possibly a restful route
8
+ %p
9
+ - home = orange[:sitemap].home(packet)
10
+ %a{:href => home.full_path}= home.link_text
4
11
  &gt;
5
- %span.here= model.link_text
12
+ %span.here= packet['route.resource'].to_s.capitalize
@@ -37,7 +37,8 @@ module Orange
37
37
  def route_to(packet, resource, *args)
38
38
  opts = args.extract_options!
39
39
  packet = DefaultHash.new unless packet
40
- context = opts[:context] || packet['route.context', nil]
40
+ context = opts[:context]
41
+ context = packet['route.context', nil] unless (context || (packet['route.context'] == :live))
41
42
  site = packet['route.faked_site'] ? packet['route.site_url', nil] : nil
42
43
  args.unshift(resource)
43
44
  args.unshift(orange[:subsites].url_for(packet).gsub(/^\//, '').gsub(/\/$/, '')) if(packet['subsite'])
@@ -8,7 +8,7 @@ module Orange
8
8
  packet = tag.locals.packet
9
9
  if tag.attr["tag"] && for_site(packet).with_tag(tag.attr["tag"]).count >0
10
10
  m = for_site(packet).with_tag(tag.attr["tag"]).first(:offset => rand(for_site(packet).with_tag(tag.attr["tag"]).count)) #selects testimonial based on tag
11
- elsif for_site(packet).count > 0
11
+ elsif for_site(packet).count > 0 && !tag.attr.include?("tag")
12
12
  m = for_site(packet).first(:offset => rand(for_site(packet).count)) #selects a random testimonial
13
13
  end
14
14
  unless m.nil?
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 7
9
- version: 0.2.7
8
+ - 8
9
+ version: 0.2.8
10
10
  platform: ruby
11
11
  authors:
12
12
  - David Haslem
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-15 00:00:00 -04:00
17
+ date: 2010-05-18 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -179,7 +179,19 @@ files:
179
179
  - lib/orange-more/events/views/events/create.haml
180
180
  - lib/orange-more/events/views/events/edit.haml
181
181
  - lib/orange-more/events/views/events/list.haml
182
+ - lib/orange-more/events/views/events/show.haml
182
183
  - lib/orange-more/events/views/events/table_row.haml
184
+ - lib/orange-more/members.rb
185
+ - lib/orange-more/members/cartons/member_carton.rb
186
+ - lib/orange-more/members/plugin.rb
187
+ - lib/orange-more/members/resources/members_resource.rb
188
+ - lib/orange-more/members/views/members/create.haml
189
+ - lib/orange-more/members/views/members/edit.haml
190
+ - lib/orange-more/members/views/members/live.show.haml
191
+ - lib/orange-more/members/views/members/login.haml
192
+ - lib/orange-more/members/views/members/logout.haml
193
+ - lib/orange-more/members/views/members/profile.haml
194
+ - lib/orange-more/members/views/members/register.haml
183
195
  - lib/orange-more/news.rb
184
196
  - lib/orange-more/news/cartons/news.rb
185
197
  - lib/orange-more/news/plugin.rb