kit_cms 2.3.20 → 2.3.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. data/app/assets/images/kit/toolbar/smile.png +0 -0
  2. data/app/assets/images/kit/toolbar/wink.gif +0 -0
  3. data/app/assets/images/kit/toolbar/wink.png +0 -0
  4. data/app/assets/javascripts/codemirror/editor.js +55 -17
  5. data/app/assets/javascripts/codemirror/jquery.js +0 -1
  6. data/app/assets/javascripts/codemirror/ruby.js +196 -0
  7. data/app/assets/javascripts/jquery.js +3036 -2838
  8. data/app/assets/javascripts/kit/utilities.js +655 -586
  9. data/app/assets/stylesheets/codemirror/style.css +1 -1
  10. data/app/assets/stylesheets/codemirror/theme.css +23 -3
  11. data/app/assets/stylesheets/kit/calendar.css +6 -1
  12. data/app/assets/stylesheets/kit/cms/cms.css +36 -0
  13. data/app/assets/stylesheets/kit/forums.css +5 -1
  14. data/app/assets/stylesheets/kit/kit.css +3 -1
  15. data/app/controllers/account_controller.rb +306 -0
  16. data/app/controllers/ad_controller.rb +2 -0
  17. data/app/controllers/admin/ad_units_controller.rb +1 -1
  18. data/app/controllers/admin/ad_zones_controller.rb +15 -0
  19. data/app/controllers/admin/ads_controller.rb +5 -0
  20. data/app/controllers/admin/block_controller.rb +1 -65
  21. data/app/controllers/admin/blocks_controller.rb +2 -0
  22. data/app/controllers/admin/content_controller.rb +3 -1
  23. data/app/controllers/admin/dashboard_controller.rb +28 -4
  24. data/app/controllers/admin/dj_controller.rb +45 -0
  25. data/app/controllers/admin/help_controller.rb +1 -1
  26. data/app/controllers/admin/html_asset_controller.rb +0 -12
  27. data/app/controllers/admin/q_controller.rb +120 -0
  28. data/app/controllers/admin/user_controller.rb +4 -4
  29. data/app/controllers/api_controller.rb +34 -0
  30. data/app/controllers/calendar_controller.rb +1 -1
  31. data/app/controllers/form_controller.rb +3 -3
  32. data/app/controllers/forum_controller.rb +39 -29
  33. data/app/controllers/kit_controller.rb +42 -15
  34. data/app/controllers/pages_controller.rb +25 -5
  35. data/app/controllers/q_controller.rb +235 -0
  36. data/app/controllers/repo_controller.rb +7 -0
  37. data/app/controllers/user_controller.rb +14 -10
  38. data/app/controllers/utility_controller.rb +1 -1
  39. data/app/helpers/account_helper.rb +47 -0
  40. data/app/helpers/admin/layouts_helper.rb +8 -0
  41. data/app/helpers/admin/page_templates_helper.rb +8 -0
  42. data/app/helpers/ads_helper.rb +11 -12
  43. data/app/helpers/calendar_helper.rb +6 -2
  44. data/app/helpers/form_data_helper.rb +1 -1
  45. data/app/helpers/form_helper.rb +8 -0
  46. data/app/helpers/forum_helper.rb +5 -1
  47. data/app/helpers/kit_helper.rb +65 -35
  48. data/app/helpers/kit_modules_helper.rb +4 -0
  49. data/app/helpers/user_helper.rb +0 -28
  50. data/app/jobs/page_link_job.rb +34 -0
  51. data/app/jobs/queue_job.rb +134 -0
  52. data/app/mailers/notification.rb +10 -0
  53. data/app/mailers/queue_mailer.rb +13 -0
  54. data/app/models/ad.rb +6 -6
  55. data/app/models/ad_unit.rb +1 -1
  56. data/app/models/ad_zone.rb +4 -0
  57. data/app/models/block.rb +1 -1
  58. data/app/models/delayed_job.rb +3 -0
  59. data/app/models/form.rb +16 -4
  60. data/app/models/html_asset.rb +19 -4
  61. data/app/models/html_asset_usage.rb +3 -0
  62. data/app/models/html_assetable.rb +4 -0
  63. data/app/models/layout.rb +36 -6
  64. data/app/models/newsletter.rb +1 -1
  65. data/app/models/page.rb +36 -2
  66. data/app/models/page_link.rb +5 -0
  67. data/app/models/page_template.rb +22 -2
  68. data/app/models/preference.rb +1 -1
  69. data/app/models/q_event.rb +12 -0
  70. data/app/models/q_klass.rb +5 -0
  71. data/app/models/q_message.rb +9 -0
  72. data/app/models/q_publisher.rb +35 -0
  73. data/app/models/q_subscription.rb +7 -0
  74. data/app/models/q_user.rb +29 -0
  75. data/app/models/q_users_method.rb +6 -0
  76. data/app/models/q_users_publisher.rb +6 -0
  77. data/app/models/user.rb +127 -19
  78. data/app/models/user_login.rb +4 -0
  79. data/app/validators/email_validator.rb +14 -0
  80. data/app/views/account/_edit.html.haml +40 -0
  81. data/app/views/account/_edit_intro.html.haml +3 -0
  82. data/app/views/account/_forgotten.html.haml +20 -0
  83. data/app/views/account/_forgotten_intro.html.haml +5 -0
  84. data/app/views/account/_sign_in.html.haml +31 -0
  85. data/app/views/account/_sign_in_intro.html.haml +4 -0
  86. data/app/views/account/_sign_up.html.haml +51 -0
  87. data/app/views/account/_sign_up_intro.html.haml +4 -0
  88. data/app/views/account/edit.html.haml +1 -0
  89. data/app/views/account/forgotten.html.haml +1 -0
  90. data/app/views/account/sign_in.html.haml +2 -0
  91. data/app/views/account/sign_up.html.haml +1 -0
  92. data/app/views/ad/_buy.html.haml +2 -1
  93. data/app/views/admin/ad_zones/_form.html.haml +1 -1
  94. data/app/views/admin/ad_zones/show.html.haml +2 -0
  95. data/app/views/admin/blocks/_form.html.haml +11 -1
  96. data/app/views/admin/dashboard/broken_links.html.haml +9 -0
  97. data/app/views/admin/dashboard/system.html.haml +11 -0
  98. data/app/views/admin/dj/index.html.haml +43 -0
  99. data/app/views/admin/form/_form.html.haml +15 -10
  100. data/app/views/admin/group/index.html.haml +1 -1
  101. data/app/views/admin/help/edit.html.haml +1 -1
  102. data/app/views/admin/html_asset/show.html.haml +9 -2
  103. data/app/views/admin/layouts/show.html.haml +10 -16
  104. data/app/views/admin/page_templates/_form.html.haml +9 -17
  105. data/app/views/admin/page_templates/show.html.haml +5 -4
  106. data/app/views/admin/q/events.html.haml +26 -0
  107. data/app/views/admin/q/index.html.haml +28 -0
  108. data/app/views/admin/q/klasses.html.haml +61 -0
  109. data/app/views/admin/q/messages.html.haml +37 -0
  110. data/app/views/admin/q/show.html.haml +98 -0
  111. data/app/views/admin/q/subscriptions.html.haml +26 -0
  112. data/app/views/admin/q/users.html.haml +27 -0
  113. data/app/views/admin/snippet/edit.html.erb +1 -1
  114. data/app/views/admin/snippet/new.html.erb +1 -1
  115. data/app/views/admin/stylesheet/show.html.haml +1 -1
  116. data/app/views/admin/user/index.html.erb +15 -6
  117. data/app/views/admin/user/view.html.erb +5 -4
  118. data/app/views/admin/views/_form.html.haml +3 -3
  119. data/app/views/calendar/_buy_tickets.html.haml +1 -1
  120. data/app/views/calendar/_calendar_entry.html.haml +1 -1
  121. data/app/views/calendar/_month.html.haml +7 -7
  122. data/app/views/form/_show.html.haml +1 -1
  123. data/app/views/forum/_add_post.html.haml +7 -8
  124. data/app/views/forum/_mod_thread.js.erb +46 -6
  125. data/app/views/forum/_post_moderation.html.haml +2 -1
  126. data/app/views/forum/_post_preview.html.haml +1 -9
  127. data/app/views/forum/_post_scripts.js.erb +29 -5
  128. data/app/views/forum/fetch_raw.html.haml +1 -0
  129. data/app/views/forum/moderate.html.haml +1 -0
  130. data/app/views/forum/topic_index.html.haml +4 -0
  131. data/app/views/notification/{event.txt.erb → event.text.erb} +0 -0
  132. data/app/views/notification/forgotten_password.text.erb +2 -0
  133. data/app/views/pages/content_edit.html.haml +1 -1
  134. data/app/views/pages/info.html.erb +13 -2
  135. data/app/views/pages/links.html.haml +63 -0
  136. data/app/views/user/edit_profile.html.haml +1 -1
  137. data/app/views/utility/_cm_editor.html.erb +13 -10
  138. data/app/views/utility/_cm_toolbar_markdown.html.haml +8 -1
  139. data/app/views/utility/_menu.html.haml +4 -0
  140. data/app/views/utility/mercury_html.html.haml +1 -0
  141. data/config/initializers/elastic_search.rb +6 -3
  142. data/config/initializers/extend_controller.rb +3 -0
  143. data/config/initializers/string.rb +9 -6
  144. data/config/initializers/warden.rb +49 -0
  145. data/config/locales/en.yml +29 -1
  146. data/config/routes.rb +35 -2
  147. data/lib/kit_cms.rb +7 -2
  148. data/lib/tasks/kit.rake +90 -2
  149. metadata +139 -27
  150. data/app/controllers/user/confirmations_controller.rb +0 -11
  151. data/app/controllers/user/passwords_controller.rb +0 -13
  152. data/app/controllers/user/registrations_controller.rb +0 -110
  153. data/app/controllers/user/sessions_controller.rb +0 -33
  154. data/app/controllers/user/unlocks_controller.rb +0 -13
  155. data/app/views/devise/_links.erb +0 -25
  156. data/app/views/devise/confirmations/new.html.erb +0 -12
  157. data/app/views/devise/mailer/confirmation_instructions.html.erb +0 -5
  158. data/app/views/devise/mailer/reset_password_instructions.html.erb +0 -8
  159. data/app/views/devise/mailer/unlock_instructions.html.erb +0 -7
  160. data/app/views/devise/passwords/edit.html.erb +0 -16
  161. data/app/views/devise/passwords/new.html.erb +0 -12
  162. data/app/views/devise/registrations/edit.html.erb +0 -28
  163. data/app/views/devise/registrations/new.html.erb +0 -18
  164. data/app/views/devise/sessions/new.html.erb +0 -18
  165. data/app/views/devise/shared/_links.erb +0 -25
  166. data/app/views/devise/unlocks/new.html.erb +0 -12
  167. data/app/views/pages/links.html.erb +0 -8
  168. data/app/views/user/shared/_links.erb +0 -25
  169. data/config/initializers/devise.rb +0 -196
  170. data/config/initializers/devise_extender.rb +0 -39
@@ -0,0 +1,235 @@
1
+ class QController < ApiController
2
+ before_filter :publisher_authenticate, :except=>[:token, :extauth, :auth, :messages, :subscribe, :unsubscribe]
3
+ before_filter :user_authenticate, :only=>[:messages, :subscribe, :unsubscribe]
4
+
5
+ # notification messages
6
+ # params: auth_id, user_id, session_token
7
+ # optional: after (date/time)
8
+ # status
9
+ # page (paginated results)
10
+ # per (number per page, default 10)
11
+ # limit (default 100)
12
+ # min_id (IDs must be greater than this)
13
+ def messages
14
+ s = @quser.q_messages.sys(_sid).includes(:q_publisher).order("id desc")
15
+ s = s.where(["created_at > ?", params[:after]]) if params[:after]
16
+ s = s.where(["status = ?", params[:status]]) if params[:status]
17
+ s = s.where(["id > ?", params[:min_id]]) if params[:min_id]
18
+ s = s.limit(params[:limit] || 100)
19
+ s = s.page(params[:page]).per(params[:per] || 10) if params[:page]
20
+
21
+ r = []
22
+ s.all.each do |ss|
23
+ r << { :id=>ss.id, :status=>ss.status, :h1=>ss.h1, :h2=>ss.h2, :body=>ss.body, :publisher=>ss.q_publisher.name, :created_at=>ss.created_at }
24
+ unless params[:nomark]
25
+ ss.status = "OK"
26
+ ss.save
27
+ end
28
+ end
29
+ logger.debug r.to_json
30
+ render :json=>r, :callback=>params[:callback]
31
+ end
32
+
33
+ # call client's authentication URL with whatever params are passed to this method
34
+ # returns: if auth URL returns status code 200, return the same as "register" would return
35
+ # else, return whatever the auth URL returned
36
+ def extauth
37
+ head :error
38
+ end
39
+
40
+ # authenticate an already-registered user, and potentially set their notification method
41
+ # params: auth_id
42
+ # user: id
43
+ # password: unencrypted
44
+ def auth
45
+ @publisher = QPublisher.sys(_sid).where(:auth_id=>params[:auth_id]).first
46
+
47
+ quser = @publisher.q_users.sys(_sid).where(:id=>params[:user_id]).first
48
+
49
+ if quser && quser.password == params[:password]
50
+ update_notification(quser)
51
+ quser.generate_session_token
52
+ quser.save
53
+ render :json=>{:error=>nil, :session=>quser.session_token}, :callback=>params[:callback]
54
+ else
55
+ render :json=>{:error=>"Incorrect username or password"}, :callback=>params[:callback]
56
+ end
57
+ end
58
+
59
+ # send system_id and password to get a token which can be use for token authentication (if publisher auth method is token) or encrypting requests (if publisher auth method is digest)
60
+ # params: auth_id, auth_secret
61
+ # returns: token
62
+ def token
63
+ publisher = QPublisher.sys(_sid).where(:auth_id=>params[:auth_id]).first
64
+
65
+ if publisher && publisher.auth_secret == params[:auth_secret]
66
+ render :json=>{:auth_id=>publisher.auth_id, :token=>publisher.token}
67
+ else
68
+ head :forbidden
69
+ end
70
+ end
71
+
72
+ # associate a user ID with a notification method/address
73
+ # params: user (the external ID by which the user is known)
74
+ # auth_id (the publisher auth ID)
75
+ # method (the notification method)
76
+ # address (the address at which they can be notified)
77
+ # encrypted_password (optional, to allow direct authentication, should already be bcrypted)
78
+ # password (optional, to allow direct authentication, will be bcrypted)
79
+ def register
80
+ quser = @publisher.q_users.sys(_sid).where(:q_external_id=>params[:user]).first
81
+
82
+ if quser
83
+ if quser.password != params[:password]
84
+ head :forbidden
85
+ return
86
+ else
87
+ quser.password = params[:new_password] if params[:new_password]
88
+ end
89
+ else
90
+ quser = QUser.new
91
+ quser.system_id = _sid
92
+ quser.q_publisher = @publisher.id
93
+ quser.q_external_id = params[:user]
94
+ quser.encrypted_password = params[:encrypted_password] if params[:encrypted_password]
95
+ end
96
+
97
+ update_notification(quser)
98
+ quser.save
99
+ unless quser.q_external_id
100
+ quser.q_external_id = quser.id
101
+ quser.save
102
+ end
103
+ render :json=>{:id=>quser.q_external_id}, :callback=>params[:callback]
104
+ end
105
+
106
+
107
+ # deregistered a User ID with a notification method/address - i.e. destroy the user account
108
+ # params: user (the external ID by which the user is known)
109
+ def deregister
110
+ quser = @publisher.q_users.sys(_sid).where(:q_external_id=>params[:user]).first
111
+
112
+ quser.destroy
113
+ head :ok
114
+ end
115
+
116
+ # subscribe to a topic (i.e. receive a notification when that topic happens)
117
+ # params: user (the external ID by which the user is known)
118
+ # topic (the topic to which is being subscribed)
119
+ def subscribe
120
+ quser = @publisher.q_users.sys(_sid).where(:q_external_id=>params[:user]).first
121
+
122
+ unless quser
123
+ head :bad_request
124
+ return
125
+ end
126
+
127
+ qs = QSubscription.sys(_sid).where(:q_publisher_id=>@publisher.id).where(:q_user_id=>quser.id).where(:topic=>params[:topic]).first
128
+ unless qs
129
+ qs = QSubscription.new
130
+ qs.system_id = _sid
131
+ qs.q_publisher = @publisher
132
+ qs.q_user = quser
133
+ qs.topic = params[:topic]
134
+ qs.save
135
+ end
136
+
137
+ render :json=>{:subscription=>qs.id}
138
+ end
139
+
140
+ # unsubscribe from topic (i.e. stop receiving notifications when a topic happens)
141
+ # params: user (the external ID by which the user is known)
142
+ # topic (the topic to which is being unsubscribed)
143
+ def unsubscribe
144
+ quser = @publisher.q_users.sys(_sid).where(:q_external_id=>params[:user]).first
145
+
146
+ unless quser
147
+ head :bad_request
148
+ return
149
+ end
150
+
151
+ qs = QSubscription.sys(_sid).where(:q_publisher_id=>@publisher.id).where(:q_user_id=>quser.id).where(:topic=>params[:topic]).first
152
+
153
+ qs.destroy
154
+
155
+ head :ok
156
+ end
157
+
158
+ def event
159
+ event = QEvent.create(:system_id=>_sid, :q_publisher_id=>@publisher.id,
160
+ :topic=>params[:topic], :data=>params[:data],
161
+ :klass=>params[:class])
162
+
163
+ render :json=>{:event=>event.id}
164
+ end
165
+
166
+ private
167
+
168
+ def user_authenticate
169
+ if params[:auth_id] && params[:user_id]
170
+ @publisher = QPublisher.sys(_sid).where(:auth_id=>params[:auth_id]).first
171
+ @quser = @publisher.q_users.sys(_sid).where(:id=>params[:user_id]).first if @publisher
172
+ end
173
+
174
+ unless @publisher && @quser
175
+ head :forbidden
176
+ return
177
+ end
178
+
179
+ return true if @quser.session_token && @quser.session_token == params[:session_token]
180
+ return publisher_authenticate
181
+ end
182
+
183
+ def publisher_authenticate
184
+ @publisher ||= QPublisher.sys(_sid).where(:auth_id=>params[:auth_id]).first
185
+
186
+ auth = false
187
+
188
+ if @publisher.auth_method=='token'
189
+ auth = authenticate_token
190
+ elsif @publisher.auth_method=='digest'
191
+ auth = authenticate_digest
192
+ end
193
+
194
+ if auth
195
+ return true
196
+ else
197
+ head :forbidden
198
+ return false
199
+ end
200
+ end
201
+
202
+ # encrypt, using the token, the digest_secret, the user ID (or '0'), the topic (or '0')
203
+ def authenticate_digest
204
+ return false unless params[:digest]
205
+ aes = FastAES.new(@publisher.token)
206
+ data = aes.decrypt(params[:digest]).split('-')
207
+ # logger.debug "*** #{data[0]} #{data[1]} #{data[2]}"
208
+ return false unless data[0] == @publisher.digest_secret
209
+ return false unless data[1] == params[:user] unless data[1]=='0'
210
+ return false unless data[2] == params[:topic] unless data[2]=='0'
211
+ return true
212
+ end
213
+
214
+ def authenticate_token
215
+ if @publisher.token == params[:token]
216
+ return true
217
+ else
218
+ return false
219
+ end
220
+ end
221
+
222
+ def update_notification(quser)
223
+ quser.notification_method = params[:method] if params[:method]
224
+ if params[:method]=='twitter'
225
+ quser.twitter_handle = params[:address]
226
+ elsif params[:method]=='email'
227
+ quser.email = params[:address]
228
+ elsif params[:method]=='ios'
229
+ quser.ios_device_token = params[:address]
230
+ end
231
+
232
+ return quser
233
+ end
234
+ end
235
+
@@ -0,0 +1,7 @@
1
+ class RepoController < KitController
2
+
3
+ def index
4
+ @blocks = Block.sys(_sid).where(:repo=>1).all
5
+ end
6
+
7
+ end
@@ -1,15 +1,12 @@
1
1
  class UserController < KitController
2
2
 
3
- layout Preference.get_cached!(0,"user_profile_layout", "application")
4
- append_view_path Layout.resolver
5
-
6
- before_filter :authenticate_user!
3
+ before_filter :authenticate
7
4
 
8
5
  def preferences
9
6
  @page_title = 'Preferences'
10
7
  @user = current_user
11
8
 
12
-
9
+ render "preferences", :layout=>profile_layout
13
10
  end
14
11
 
15
12
  def profile
@@ -28,9 +25,11 @@ class UserController < KitController
28
25
  def edit_profile
29
26
  form = Preference.get_cached(_sid, 'user_profile_edit_form')
30
27
  if form.not_blank?
31
- render :inline=>form, :layout=>Preference.get_cached!(0,"user_profile_layout", "application") #TODO sub in auth token
28
+ render :inline=>form, :layout=>profile_layout # Preference.get_cached!(0,"user_profile_layout", "application") #TODO sub in auth token
32
29
  return
33
30
  end
31
+
32
+ render "edit_profile", :layout=>profile_layout
34
33
  end
35
34
 
36
35
  def attribute
@@ -135,7 +134,7 @@ class UserController < KitController
135
134
  end
136
135
  end
137
136
 
138
- kit_render "preferences", :layout=>Preference.get_cached!(_sid,"user_profile_layout", "application")
137
+ kit_render "preferences", :layout=>profile_layout
139
138
  end
140
139
 
141
140
  private
@@ -144,11 +143,16 @@ class UserController < KitController
144
143
  render :text=>"User not found" and return unless @user
145
144
 
146
145
  form = Preference.get_cached(_sid, "user_profile_#{owner ? 'owner' : 'view'}_form")
146
+
147
147
  if form.not_blank?
148
- render :inline=>form, :layout=>Preference.get_cached!(0,"user_profile_layout", "application")
148
+ render :inline=>form, :layout=>profile_layout
149
149
  else
150
- render "user_profile"
150
+ render "user_profile", :layout=>profile_layout
151
151
  end
152
152
  end
153
-
153
+
154
+ def profile_layout
155
+ Layout.preference(_sid, 'user_profile_layout').path
156
+ end
157
+
154
158
  end
@@ -27,7 +27,7 @@ class UtilityController < KitController
27
27
  end
28
28
 
29
29
  def markdown_preview
30
- render :text=>params[:body].sanitise.friendly_format.html_safe
30
+ render :text=>params[:body].sanitise.friendly_format({:smilies=>true}).html_safe
31
31
  end
32
32
 
33
33
  def design_history
@@ -0,0 +1,47 @@
1
+ module AccountHelper
2
+ include KitHelper
3
+
4
+ def users_have_profiles?
5
+ UserAttribute.sys(_sid).where(:owner_editable=>1).count>0
6
+ end
7
+
8
+ def account_forgotten(options = {})
9
+ render :partial=>"account/forgotten", :locals=>{:options=>options}
10
+ end
11
+
12
+ def account_sign_in_form(options = {})
13
+ render :partial=>"account/sign_in", :locals=>{:options=>options}
14
+ end
15
+
16
+ def account_sign_up_form(options = {})
17
+ render :partial=>"account/sign_up", :locals=>{:options=>options}
18
+ end
19
+
20
+ def account_edit_form(options = {})
21
+ render :partial=>"account/edit", :locals=>{:options=>options}
22
+ end
23
+
24
+ def sign_up_url
25
+ sys_pref("account_sign_up_url") || "/users/sign_up"
26
+ end
27
+
28
+ def sign_in_url
29
+ sys_pref("account_sign_in_url") || "/users/sign_in"
30
+ end
31
+
32
+ def sign_out_url
33
+ sys_pref("account_sign_out_url") || "/users/sign_out"
34
+ end
35
+
36
+ def forgotten_url
37
+ sys_pref("account_forgotten_url") || "/users/forgotten"
38
+ end
39
+
40
+ def reset_url
41
+ sys_pref("account_reset_url") || "/users/reset"
42
+ end
43
+
44
+ def account_reset_failed(options = {})
45
+ render :partial=>"account/account_reset_failed", :locals=>{:options=>options}
46
+ end
47
+ end
@@ -1,2 +1,10 @@
1
1
  module Admin::LayoutsHelper
2
+
3
+ def layout_asset_selected(asset)
4
+ if @layout && @layout.id!=nil
5
+ @layout.html_assets.include?(asset)
6
+ else
7
+ false
8
+ end
9
+ end
2
10
  end
@@ -1,5 +1,13 @@
1
1
  module Admin::PageTemplatesHelper
2
2
 
3
+ def page_template_asset_selected(asset)
4
+ if @page_template && @page_template.id!=nil
5
+ @page_template.html_assets.include?(asset)
6
+ else
7
+ false
8
+ end
9
+ end
10
+
3
11
  def show_html_assets(list, type)
4
12
  return '' unless list
5
13
  o = ''
@@ -28,6 +28,7 @@ module AdsHelper
28
28
  end
29
29
 
30
30
  def kit_ad_by_unit(unit_id, options = {})
31
+ return "[[ads may appear here]]" if params[:edit]
31
32
  begin
32
33
  possible_zones = []
33
34
  highest_priority = nil
@@ -43,7 +44,7 @@ module AdsHelper
43
44
  if possible_zones.length>0
44
45
  return kit_ad_by_zone(possible_zones, options)
45
46
  else
46
- return "[[no zones found]]"
47
+ return nil
47
48
  end
48
49
  rescue Exception => e
49
50
  logger.error e.message
@@ -68,17 +69,15 @@ module AdsHelper
68
69
  end
69
70
 
70
71
  def kit_ad(id, options = {})
71
- begin
72
- ad = Ad.sys(_sid).where(:id=>id).includes(:ad_zones).first
73
-
74
- ad = Ad.ensure_ad(ad)
75
- ad.impress
76
- ad.render
77
- rescue Exception => e
78
- e.message
79
- end
80
-
81
-
72
+ begin
73
+ ad = Ad.sys(_sid).where(:id=>id).includes(:ad_zones).first
74
+
75
+ ad = Ad.ensure_ad(ad)
76
+ ad.impress
77
+ ad.render
78
+ rescue Exception => e
79
+ e.message
80
+ end
82
81
  end
83
82
 
84
83
  def zone_with_price(zone)
@@ -129,6 +129,7 @@ module CalendarHelper
129
129
  entries = {}
130
130
  days_in_this_month = days_in_month(month)
131
131
 
132
+ logger.debug "**** days in month #{month} #{days_in_this_month}"
132
133
  for i in 1..days_in_this_month do
133
134
  entries[i] = []
134
135
  end
@@ -160,8 +161,11 @@ module CalendarHelper
160
161
  end
161
162
  end
162
163
 
163
- def days_in_month(d)
164
- (Date.new(d.year, 12, 31) << (12-d.month)).day
164
+ COMMON_YEAR_DAYS_IN_MONTH = [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
165
+
166
+ def days_in_month(month, year = Time.now.year)
167
+ return 29 if month == 2 && Date.gregorian_leap?(year)
168
+ COMMON_YEAR_DAYS_IN_MONTH[month]
165
169
  end
166
170
 
167
171
  def regions_list