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,12 +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
- %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'}
@@ -1,15 +0,0 @@
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.
@@ -1 +0,0 @@
1
- %p You don't have permission to view this.
@@ -1,17 +0,0 @@
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
@@ -1 +0,0 @@
1
- %p You have been logged out.
@@ -1,50 +0,0 @@
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.
@@ -1,37 +0,0 @@
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.registration-name
11
- %label Name*
12
- %br
13
- *Ignore this field unless you are a spam robot.
14
- %br
15
- %input{:type => "text", :name => "members[name]"}
16
- %p
17
- %label Password
18
- %br
19
- %input{:type => "password", :name => "members[password]"}
20
- %p
21
- %label Repeat Password
22
- %br
23
- %input{:type => "password", :name => "members[repeat_password]"}
24
- %fieldset
25
- %legend Mailing Lists
26
- %p
27
- %input{:type => "checkbox", :name => "members[email_subscribe]", :value => "1"}
28
- Sign up for the mailing list?
29
- %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.
30
- - for group in list_groups
31
- %h2= group["name"].capitalize
32
- %input{:type => "hidden", :name => "members[groups][#{group['name']}][]", :value => ""}
33
- - for opt in group["groups"]
34
- %p
35
- %input{:type => "checkbox", :name => "members[groups][#{group['name']}][]", :value => opt["name"]}
36
- = opt["name"]
37
- %input{:type => "submit", :value => "Register"}
@@ -1 +0,0 @@
1
- require File.join('orange-more', 'news', 'plugin')
@@ -1,12 +0,0 @@
1
- require 'dm-timestamps'
2
- class OrangeNews < Orange::Carton
3
- id
4
- front do
5
- title :title, :length => 255
6
- text :link, :length => 255
7
- fulltext :description
8
- end
9
-
10
- property :created_at, DateTime
11
- property :updated_at, DateTime
12
- 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 News < Base
6
- views_dir File.join(File.dirname(__FILE__), 'views')
7
-
8
- resource Orange::NewsResource.new
9
- end
10
- end
11
-
12
- Orange.plugin(Orange::Plugins::News.new)
13
-
@@ -1,82 +0,0 @@
1
- module Orange
2
- class NewsResource < Orange::ModelResource
3
- use OrangeNews
4
- call_me :news
5
- def stack_init
6
- orange[:admin, true].add_link("Content", :resource => @my_orange_name, :text => 'News')
7
- orange[:radius, true].define_tag "latest_news" do |tag|
8
- orange[:news].latest(tag.locals.packet)
9
- end
10
- end
11
-
12
- def beforeNew(packet, opts = {})
13
- unless OrangeRoute.first(:resource => 'news', :orange_site_id => packet['site'].id)
14
- orange[:sitemap, true].add_route_for(packet,
15
- :orange_site_id => packet['site'].id,
16
- :resource => :news,
17
- :resource_action => :archive,
18
- :slug => 'news-archive',
19
- :link_text => 'Orange News Archive'
20
- )
21
- end
22
- true
23
- end
24
-
25
- def link_for(packet, news)
26
- match = news.link.match(/\[(\d+)\]/)
27
- if match
28
- orange[:sitemap, true].to_href(packet, match[1].to_i)
29
- else
30
- news.link
31
- end
32
- end
33
-
34
- def sitemap_row(packet, opts = {})
35
- do_view(packet, :sitemap_row, opts)
36
- end
37
-
38
- def news_view(packet, opts = {})
39
- resource_path = packet['route.resource_path']
40
- if resource_path.blank?
41
- archive_view(packet, opts)
42
- elsif resource_path =~ /^\/page/
43
- archive(packet, opts)
44
- else
45
- archive_view(packet, opts)
46
- end
47
- end
48
-
49
- def latest(packet, opts = {})
50
- limit = packet['news.latest_news_limit', 3]
51
- do_list_view(packet, :latest, {
52
- :list => model_class.all(:order => :updated_at.desc, :limit => limit)
53
- })
54
- end
55
-
56
- def archive(packet, opts = {})
57
- opts.merge!(packet.extract_opts)
58
- opts.merge!( :archive_url => archive_url(packet))
59
- opts[:page] = opts[:page].blank? ? 1 : opts[:page].to_i
60
- page = opts[:page].blank? ? 0 : opts[:page] - 1
61
- opts[:list] = model_class.all(:order => [:updated_at.desc],
62
- :limit => 5,
63
- :offset => (5*page)
64
- )
65
- opts[:pages] = (model_class.count / 5) + 1
66
- do_list_view(packet, :archive, opts)
67
- end
68
-
69
- def archive_view(packet, opts = {})
70
- archive(packet, opts.merge!({:page => 1}))
71
- end
72
-
73
- def archive_url(packet)
74
- url = orange[:sitemap, true].url_for(packet, :resource => :news, :resource_action => :archive)
75
- url.gsub!(/\/$/, '')
76
- end
77
-
78
- def find_list(packet, mode, opts = {})
79
- model_class.all(:order => [:updated_at.desc]) || []
80
- end
81
- end
82
- end
@@ -1,14 +0,0 @@
1
- .news_items
2
- - for news in list
3
- .news_item
4
- %h2.news_title
5
- %a{:href => (resource.link_for(packet, news))} #{news.title}
6
- .news_description
7
- = news.description
8
- %p
9
- %a{:href => (resource.link_for(packet, news)), :class => 'view_story'} View Story &raquo;
10
- .news_nav
11
- - if page > 1
12
- %a.newer{:href => "#{archive_url}/page/#{page-1}"} Newer Posts
13
- - if page < pages
14
- %a.older{:href => "#{archive_url}/page/#{page+1}"} Older Posts
@@ -1,7 +0,0 @@
1
- - if model
2
- %form{:action => 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
- %input{:type => 'submit', :value => 'Save Changes'}
6
- - else
7
- %p Couldn't find the item you're looking for.
@@ -1,8 +0,0 @@
1
- - list.each do |news|
2
- .news_item
3
- %p.news_title
4
- %a{:href => (resource.link_for(packet, news))} #{news.title}
5
- .news_description
6
- = news.description
7
- %p
8
- %a{:href => (resource.link_for(packet, news)), :class => 'view_story'} View Story &raquo;
@@ -1,14 +0,0 @@
1
- - if route
2
- .sitemap_item{:class => "sitemap_level_#{route.level}"}
3
- - if route.level > 0
4
- = orange[:sitemap].route_actions(packet, :model => route)
5
- %h4 #{route.link_text} <span>(#{route.full_path})</span>
6
- .linked_to
7
- %p
8
- News Archive
9
- %br
10
- %a{:href => route_to(:news, 'create')} Add New News Post
11
- .actions
12
- = form_link('Delete', route_to(:sitemap, route.id, 'delete'), 'Are you sure you want to delete this?', {:method => 'delete'})
13
- %a{:href => route_to(:sitemap, route.id, 'edit')} Edit
14
- %br.clear
@@ -1 +0,0 @@
1
- require File.join('orange-more', 'pages', 'plugin')
@@ -1,14 +0,0 @@
1
- require 'dm-timestamps'
2
- require 'orange-more/administration/cartons/site_carton'
3
-
4
- class OrangePage < Orange::SiteCarton
5
- id
6
- front do
7
- title :title, :length => 255
8
- fulltext :body
9
- end
10
- boolean :published, :default => false
11
-
12
- property :updated_at, DateTime
13
- has n, :versions, "OrangePageVersion"
14
- end
@@ -1,12 +0,0 @@
1
- require 'dm-timestamps'
2
- require 'orange-more/administration/cartons/site_carton'
3
-
4
- class OrangePageVersion < Orange::SiteCarton
5
- id
6
- title :title, :length => 255
7
- fulltext :body
8
- property :updated_at, DateTime
9
- boolean :published
10
- property :version, Integer, :default => 0
11
- belongs_to :orange_page, "OrangePage"
12
- 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 Pages < Base
6
- views_dir File.join(File.dirname(__FILE__), 'views')
7
-
8
- resource Orange::PageResource.new
9
- end
10
- end
11
-
12
- Orange.plugin(Orange::Plugins::Pages.new)
13
-
@@ -1,179 +0,0 @@
1
- module Orange
2
- module Pulp::PageHelpers
3
- def fuzzy_time(from_time)
4
- to_time = Time.new
5
- from_time = from_time.to_time if from_time.respond_to?(:to_time)
6
- to_time = to_time.to_time if to_time.respond_to?(:to_time)
7
- distance_in_minutes = (((to_time - from_time).abs)/60).round
8
- distance_in_seconds = ((to_time - from_time).abs).round
9
- case distance_in_minutes
10
- when 0..1
11
- return distance_in_minutes == 0 ? "Less than 1 minute ago" : "About 1 minute ago"
12
- when 2..44 then "#{distance_in_minutes} minutes ago"
13
- when 45..89 then "An hour ago"
14
- when 90..1439 then "#{(distance_in_minutes.to_f / 60.0).round} hours ago"
15
- when 1440..2879 then "Yesterday"
16
- when 2880..43199 then "#{(distance_in_minutes / 1440).round} days ago"
17
- when 43200..86399 then "1 Month ago"
18
- when 86400..525599 then "#{(distance_in_minutes / 43200).round} months ago"
19
- when 525600..1051199 then "1 year ago"
20
- else "Over #{(distance_in_minutes / 525600).round} years ago"
21
- end
22
- end
23
- end
24
- class PageResource < Orange::ModelResource
25
- use OrangePage
26
- call_me :pages
27
- def init
28
- options[:sitemappable] = true
29
- orange.add_pulp(Orange::Pulp::PageHelpers)
30
- end
31
-
32
- def stack_init
33
- orange[:admin, true].add_link("Content", :resource => @my_orange_name, :text => 'Pages')
34
- end
35
-
36
- def publish(packet, opts = {})
37
- no_reroute = opts[:no_reroute]
38
- if packet.request.post? || !opts.blank?
39
- my_id = opts[:resource_id] || packet['route.resource_id']
40
- m = opts[:model] || model_class.get(my_id)
41
- if m
42
- params = {}
43
- params[:published] = true
44
- m.update(params)
45
-
46
- params = m.attributes.merge(params)
47
- params.delete(:id)
48
- max = m.versions.max(:version) || 0
49
- m.versions.new(params.merge(:version => max + 1))
50
- m.save
51
-
52
- r = orange[:sitemap, true].routes_for(packet, :resource_id => m.id, :resource => @my_orange_name, :orange_site_id => m.orange_site.id)
53
- # Add route if none.
54
- if (r.blank? && orange.loaded?(:sitemap))
55
-
56
- route_hash = {
57
- :orange_site_id => m.orange_site.id,
58
- :resource => @my_orange_name,
59
- :resource_id => m.id,
60
- :slug => orange[:sitemap].slug_for(m, params),
61
- :show_in_nav => false,
62
- :link_text => "{title}"
63
- }
64
- parents = orange[:sitemap].routes_for(packet, :resource => '', :resource_id => '', :slug => "pages", :orange_site_id => m.orange_site.id)
65
- route_hash[:parent] = parents.first unless parents.blank?
66
- orange[:sitemap].add_route_for(packet, route_hash)
67
- end
68
- end
69
- end
70
- packet.reroute(@my_orange_name, :orange) unless (packet.request.xhr? || no_reroute)
71
- end
72
-
73
- # Creates a new model object and saves it (if a post), then reroutes to the main page
74
- # @param [Orange::Packet] packet the packet being routed
75
- def onNew(packet, params = {})
76
- params[:published] = false
77
- m = model_class.new(params)
78
- m.orange_site = (packet['subsite', false] ? packet['subsite'] : packet['site']) unless m.orange_site
79
- # m.versions.new(params.merge(:version => 1))
80
- m
81
- end
82
-
83
- # Saves updates to an object specified by packet['route.resource_id'], then reroutes to main
84
- # @param [Orange::Packet] packet the packet being routed
85
- def onSave(packet, m, params = {})
86
- r = orange[:sitemap, true].routes_for(packet, :resource_id => m.id, :resource => @my_orange_name, :orange_site_id => m.orange_site.id)
87
- # Add route if none.
88
- if (r.blank? && orange.loaded?(:sitemap))
89
- route_hash = {
90
- :orange_site_id => m.orange_site.id,
91
- :resource => @my_orange_name,
92
- :resource_id => m.id,
93
- :slug => orange[:sitemap].slug_for(m, params),
94
- :show_in_nav => false,
95
- :link_text => "{title}"
96
- }
97
- parents = orange[:sitemap].routes_for(packet, :resource => '', :resource_id => '', :slug => "pages", :orange_site_id => m.orange_site.id)
98
- route_hash[:parent] = parents.first unless parents.blank?
99
- orange[:sitemap].add_route_for(packet, route_hash)
100
- end
101
- if (params["published"] == "1")
102
- params["published"] = true
103
- m.orange_site = (packet['subsite', false] ? packet['subsite'] : packet['site']) unless m.orange_site
104
-
105
- m.update(params)
106
- orange[:pages].publish(packet, :no_reroute => true, :model => m)
107
- else
108
- params["published"] = false
109
- m.orange_site = (packet['subsite', false] ? packet['subsite'] : packet['site']) unless m.orange_site
110
- m.update(params)
111
- end
112
- end
113
-
114
- def find_list(packet, mode)
115
- model_class.all(:orange_site => packet['site']) || []
116
- end
117
-
118
- # Returns a single object found by the model class, given an id.
119
- # If id isn't given, we return false.
120
- # @param [Orange::Packet] packet the packet we are returning a view for
121
- # @param [Symbol] mode the mode we are trying to view (used to find template name)
122
- # @param [Numeric] id the id to lookup on the model class
123
- # @return [Object] returns an object of type set by #use, if one found with same id
124
- def find_one(packet, mode, id = false)
125
- return false unless id
126
- m = model_class.get(id)
127
- if packet['route.resource_path',''] =~ /version\//
128
- parts = packet['route.resource_path'].split('/')
129
- version = parts[2]
130
- v = m.versions.first(:version => version)
131
- if v
132
- attrs = v.attributes
133
- [:version, :orange_page_id, :page_id, :id].each { |i| attrs.delete(i) }
134
- m.attributes = attrs
135
- end
136
- end # end if version
137
- if mode == :show
138
- case packet['route.context']
139
- when :live
140
- # Automatically set title, if possible
141
- unless orange[:page_parts].part(packet)[:title] != ''
142
- orange[:page_parts].part(packet)[:title] = m.title + " - " + packet['site'].name
143
- end
144
- m = m.versions.last(:published => '1')
145
- raise Orange::NotFoundException unless m
146
- when :preview
147
- # Automatically set title, if possible
148
- unless orange[:page_parts].part(packet)[:title] != ''
149
- orange[:page_parts].part(packet)[:title] = m.title + " - " + packet['site'].name
150
- end
151
- m
152
- end
153
- end # end if show
154
- m
155
- end
156
-
157
- def find_extras(packet, mode, opts = {})
158
- case mode
159
- when :edit
160
- return {:routes => orange[:sitemap, true].routes_for(packet)}
161
- else {}
162
- end
163
- end
164
-
165
- def routes(packet, opts = {})
166
- model = opts if opts.is_a? model_class
167
- model ||= opts[:model] || model_class.get(opts[:resource_id])
168
- orange[:sitemap].routes_for(packet, {:resource => :pages, :resource_id => model.id})
169
- end
170
-
171
- def sitemap_row(packet, opts = {})
172
- do_view(packet, :sitemap_row, opts)
173
- end
174
-
175
- def route_for(packet, id, opts = {})
176
- return orange[:sitemap].url_for(packet, {:resource => 'pages', :resource_id => id})
177
- end
178
- end
179
- end