spiderfw 0.5.19 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (255) hide show
  1. data/CHANGELOG +7 -0
  2. data/VERSION +1 -1
  3. data/apps/core/auth/lib/rbac.rb +7 -2
  4. data/apps/core/auth/models/mixins/rbac_provider.rb +66 -4
  5. data/apps/core/components/assets.rb +63 -33
  6. data/apps/core/components/public/js/jquery/{jquery-1.4.3.js → jquery-1.5.2.js} +2617 -1126
  7. data/apps/core/components/public/js/jquery/jquery-tools-1.2.5/overlay/overlay.apple.js +155 -0
  8. data/apps/core/components/public/js/jquery/jquery-tools-1.2.5/overlay/overlay.js +293 -0
  9. data/apps/core/components/public/js/jquery/jquery-tools-1.2.5/scrollable/scrollable.js +335 -0
  10. data/apps/core/components/public/js/jquery/jquery-tools-1.2.5/tabs/tabs.css +59 -0
  11. data/apps/core/components/public/js/jquery/jquery-tools-1.2.5/tabs/tabs.js +283 -0
  12. data/apps/core/components/public/js/jquery/jquery-tools-1.2.5/toolbox/toolbox.expose.js +224 -0
  13. data/apps/core/components/public/js/jquery/jquery-tools-1.2.5/tooltip/tooltip.dynamic.js +150 -0
  14. data/apps/core/components/public/js/jquery/jquery-tools-1.2.5/tooltip/tooltip.js +343 -0
  15. data/apps/core/components/public/js/jquery/jquery-tools-1.2.5/tooltip/tooltip.slide.js +78 -0
  16. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4 → jquery-ui-1.8.11}/css/Aristo/images/button_bg.png +0 -0
  17. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4 → jquery-ui-1.8.11}/css/Aristo/images/datepicker.gif +0 -0
  18. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4 → jquery-ui-1.8.11}/css/Aristo/images/icon_sprite.png +0 -0
  19. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4 → jquery-ui-1.8.11}/css/Aristo/images/progress_bar.gif +0 -0
  20. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4 → jquery-ui-1.8.11}/css/Aristo/images/slider_h_bg.gif +0 -0
  21. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4 → jquery-ui-1.8.11}/css/Aristo/images/slider_handles.png +0 -0
  22. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4 → jquery-ui-1.8.11}/css/Aristo/images/slider_v_bg.gif +0 -0
  23. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4 → jquery-ui-1.8.11}/css/Aristo/images/tab_bg.gif +0 -0
  24. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4 → jquery-ui-1.8.11}/css/Aristo/images/the_gradient.gif +0 -0
  25. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4 → jquery-ui-1.8.11}/css/Aristo/images/ui-anim_basic_16x16.gif +0 -0
  26. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4 → jquery-ui-1.8.11}/css/Aristo/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  27. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4 → jquery-ui-1.8.11}/css/Aristo/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  28. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4 → jquery-ui-1.8.11}/css/Aristo/images/ui-bg_flat_10_000000_40x100.png +0 -0
  29. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4 → jquery-ui-1.8.11}/css/Aristo/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  30. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4 → jquery-ui-1.8.11}/css/Aristo/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  31. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4 → jquery-ui-1.8.11}/css/Aristo/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  32. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4 → jquery-ui-1.8.11}/css/Aristo/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  33. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4 → jquery-ui-1.8.11}/css/Aristo/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  34. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4 → jquery-ui-1.8.11}/css/Aristo/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  35. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4 → jquery-ui-1.8.11}/css/Aristo/images/ui-icons_222222_256x240.png +0 -0
  36. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4 → jquery-ui-1.8.11}/css/Aristo/images/ui-icons_228ef1_256x240.png +0 -0
  37. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4 → jquery-ui-1.8.11}/css/Aristo/images/ui-icons_ef8c08_256x240.png +0 -0
  38. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4 → jquery-ui-1.8.11}/css/Aristo/images/ui-icons_ffd27a_256x240.png +0 -0
  39. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4 → jquery-ui-1.8.11}/css/Aristo/images/ui-icons_ffffff_256x240.png +0 -0
  40. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4 → jquery-ui-1.8.11}/css/Aristo/jquery-ui.custom.css +0 -0
  41. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-af.js +0 -0
  42. data/apps/core/components/public/js/jquery/jquery-ui-1.8.11/ui/i18n/jquery.ui.datepicker-ar-DZ.js +23 -0
  43. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-ar.js +7 -8
  44. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-az.js +0 -0
  45. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-bg.js +0 -0
  46. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-bs.js +0 -0
  47. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-ca.js +0 -0
  48. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-cs.js +0 -0
  49. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-da.js +0 -0
  50. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-de.js +0 -0
  51. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-el.js +0 -0
  52. data/apps/core/components/public/js/jquery/jquery-ui-1.8.11/ui/i18n/jquery.ui.datepicker-en-AU.js +23 -0
  53. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-en-GB.js +0 -0
  54. data/apps/core/components/public/js/jquery/jquery-ui-1.8.11/ui/i18n/jquery.ui.datepicker-en-NZ.js +23 -0
  55. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-eo.js +0 -0
  56. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-es.js +0 -0
  57. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-et.js +0 -0
  58. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-eu.js +0 -0
  59. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-fa.js +0 -0
  60. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-fi.js +0 -0
  61. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-fo.js +0 -0
  62. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-fr-CH.js +0 -0
  63. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-fr.js +12 -10
  64. data/apps/core/components/public/js/jquery/jquery-ui-1.8.11/ui/i18n/jquery.ui.datepicker-gl.js +23 -0
  65. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-he.js +0 -0
  66. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-hr.js +0 -0
  67. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-hu.js +1 -1
  68. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-hy.js +0 -0
  69. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-id.js +0 -0
  70. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-is.js +0 -0
  71. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-it.js +0 -0
  72. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-ja.js +0 -0
  73. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-ko.js +0 -0
  74. data/apps/core/components/public/js/jquery/jquery-ui-1.8.11/ui/i18n/jquery.ui.datepicker-kz.js +23 -0
  75. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-lt.js +0 -0
  76. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-lv.js +0 -0
  77. data/apps/core/components/public/js/jquery/jquery-ui-1.8.11/ui/i18n/jquery.ui.datepicker-ml.js +23 -0
  78. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-ms.js +0 -0
  79. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-nl.js +0 -0
  80. data/apps/core/components/public/js/jquery/jquery-ui-1.8.11/ui/i18n/jquery.ui.datepicker-no.js +23 -0
  81. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-pl.js +0 -0
  82. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-pt-BR.js +0 -0
  83. data/apps/core/components/public/js/jquery/jquery-ui-1.8.11/ui/i18n/jquery.ui.datepicker-pt.js +22 -0
  84. data/apps/core/components/public/js/jquery/jquery-ui-1.8.11/ui/i18n/jquery.ui.datepicker-rm.js +21 -0
  85. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-ro.js +0 -0
  86. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-ru.js +1 -1
  87. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-sk.js +0 -0
  88. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-sl.js +0 -0
  89. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-sq.js +0 -0
  90. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-sr-SR.js +0 -0
  91. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-sr.js +0 -0
  92. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-sv.js +0 -0
  93. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-ta.js +0 -0
  94. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-th.js +1 -1
  95. data/apps/core/components/public/js/jquery/jquery-ui-1.8.11/ui/i18n/jquery.ui.datepicker-tj.js +23 -0
  96. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-tr.js +0 -0
  97. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-uk.js +0 -0
  98. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-vi.js +0 -0
  99. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-zh-CN.js +0 -0
  100. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-zh-HK.js +0 -0
  101. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/i18n/jquery.ui.datepicker-zh-TW.js +0 -0
  102. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/jquery.effects.blind.js +3 -3
  103. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/jquery.effects.bounce.js +3 -3
  104. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/jquery.effects.clip.js +3 -3
  105. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/jquery.effects.core.js +48 -15
  106. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/jquery.effects.drop.js +3 -3
  107. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/jquery.effects.explode.js +2 -2
  108. data/apps/core/components/public/js/jquery/jquery-ui-1.8.11/ui/jquery.effects.fade.js +32 -0
  109. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/jquery.effects.fold.js +3 -3
  110. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/jquery.effects.highlight.js +2 -2
  111. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/jquery.effects.pulsate.js +2 -2
  112. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/jquery.effects.scale.js +4 -4
  113. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/jquery.effects.shake.js +3 -3
  114. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/jquery.effects.slide.js +4 -4
  115. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/jquery.effects.transfer.js +2 -2
  116. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/jquery.ui.accordion.js +33 -20
  117. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/jquery.ui.autocomplete.js +104 -42
  118. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/jquery.ui.button.js +35 -13
  119. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/jquery.ui.core.js +111 -84
  120. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/jquery.ui.datepicker.js +87 -46
  121. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/jquery.ui.dialog.js +105 -75
  122. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/jquery.ui.draggable.js +17 -15
  123. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/jquery.ui.droppable.js +5 -5
  124. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/jquery.ui.mouse.js +16 -11
  125. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/jquery.ui.position.js +51 -32
  126. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/jquery.ui.progressbar.js +24 -10
  127. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/jquery.ui.resizable.js +7 -7
  128. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/jquery.ui.selectable.js +3 -3
  129. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/jquery.ui.slider.js +9 -7
  130. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/jquery.ui.sortable.js +22 -20
  131. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/jquery.ui.tabs.js +15 -14
  132. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → jquery-ui-1.8.11}/ui/jquery.ui.widget.js +50 -25
  133. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → plugins/bsmselect}/GPL-LICENSE.txt +1 -1
  134. data/apps/core/components/public/js/jquery/{jquery-ui-1.8.4/development-bundle → plugins/bsmselect}/MIT-LICENSE.txt +3 -7
  135. data/apps/core/components/public/js/jquery/plugins/bsmselect/README.md +185 -0
  136. data/apps/core/components/public/js/jquery/plugins/bsmselect/css/jquery.bsmselect.css +64 -0
  137. data/apps/core/components/public/js/jquery/plugins/bsmselect/js/jquery.bsmselect.compatibility.js +60 -0
  138. data/apps/core/components/public/js/jquery/plugins/bsmselect/js/jquery.bsmselect.js +381 -0
  139. data/apps/core/components/public/js/jquery/plugins/bsmselect/js/jquery.bsmselect.sortable.js +49 -0
  140. data/apps/core/components/public/js/plugins/sortable.js +16 -7
  141. data/apps/core/components/public/js/spider.js +60 -41
  142. data/apps/core/components/widgets/admin/admin.shtml +1 -1
  143. data/apps/core/components/widgets/list/list.shtml +2 -2
  144. data/apps/core/components/widgets/month_calendar/month_calendar.shtml +23 -20
  145. data/apps/core/components/widgets/switcher/switcher.rb +77 -21
  146. data/apps/core/components/widgets/switcher/templates/default.shtml +8 -0
  147. data/apps/core/components/widgets/switcher/templates/table.shtml +15 -0
  148. data/apps/core/components/widgets/table/table.rb +4 -1
  149. data/apps/core/components/widgets/table/table.shtml +10 -8
  150. data/apps/core/forms/public/css/form.css +9 -1
  151. data/apps/core/forms/public/date_time.js +14 -2
  152. data/apps/core/forms/public/input.js +1 -1
  153. data/apps/core/forms/public/select.js +4 -3
  154. data/apps/core/forms/tags/element_row.erb +11 -2
  155. data/apps/core/forms/widgets/inputs/date_time/date_time.rb +9 -0
  156. data/apps/core/forms/widgets/inputs/date_time/date_time.shtml +1 -1
  157. data/apps/core/forms/widgets/inputs/html_area/html_area.shtml +2 -2
  158. data/apps/core/forms/widgets/inputs/input/input.rb +0 -3
  159. data/apps/core/forms/widgets/inputs/select/select.shtml +2 -2
  160. data/apps/messenger/backends/email/sendmail.rb +20 -0
  161. data/apps/messenger/backends/email/smtp.rb +12 -14
  162. data/apps/messenger/backends/email/test.rb +20 -0
  163. data/apps/messenger/config/options.rb +9 -9
  164. data/apps/messenger/config/test.config.yml +2 -0
  165. data/apps/messenger/controllers/mixins/messenger_helper.rb +41 -15
  166. data/apps/messenger/lib/email_backend.rb +10 -0
  167. data/apps/messenger/messenger.rb +45 -26
  168. data/apps/messenger/test/features/attachments.feature +26 -0
  169. data/apps/messenger/test/features/messenger_helper.feature +31 -0
  170. data/apps/messenger/test/features/sending_email.feature +10 -0
  171. data/apps/messenger/test/features/step_definitions/common_steps.rb +11 -0
  172. data/apps/messenger/test/features/step_definitions/email_steps.rb +98 -0
  173. data/apps/messenger/test/features/support/env.rb +11 -0
  174. data/apps/messenger/test/files/test_file1.txt +1 -0
  175. data/apps/messenger/test/lib/controllers/mail_test_controller.rb +34 -0
  176. data/apps/messenger/test/templates/email/multipart.html.erb +1 -0
  177. data/apps/messenger/test/templates/email/multipart.txt.erb +1 -0
  178. data/apps/messenger/test/templates/email/simple.erb +1 -0
  179. data/apps/messenger/test/templates/email/vars.erb +1 -0
  180. data/lib/spiderfw/cmd/cmd.rb +4 -0
  181. data/lib/spiderfw/cmd/commands/webserver.rb +12 -59
  182. data/lib/spiderfw/config/configuration.rb +4 -0
  183. data/lib/spiderfw/config/options/spider.rb +25 -8
  184. data/lib/spiderfw/controller/controller.rb +10 -4
  185. data/lib/spiderfw/controller/first_responder.rb +6 -20
  186. data/lib/spiderfw/controller/http_controller.rb +2 -1
  187. data/lib/spiderfw/controller/mixins/http_mixin.rb +12 -1
  188. data/lib/spiderfw/controller/mixins/visual.rb +3 -16
  189. data/lib/spiderfw/env.rb +1 -1
  190. data/lib/spiderfw/http/server.rb +178 -2
  191. data/lib/spiderfw/model/base_model.rb +142 -111
  192. data/lib/spiderfw/model/data_type.rb +15 -0
  193. data/lib/spiderfw/model/datatypes/decimal.rb +8 -0
  194. data/lib/spiderfw/model/datatypes/pk.rb +29 -0
  195. data/lib/spiderfw/model/datatypes.rb +1 -0
  196. data/lib/spiderfw/model/element.rb +5 -1
  197. data/lib/spiderfw/model/extended_models/managed.rb +1 -1
  198. data/lib/spiderfw/model/junction.rb +23 -0
  199. data/lib/spiderfw/model/mappers/db_mapper.rb +96 -80
  200. data/lib/spiderfw/model/mappers/document_mapper.rb +315 -0
  201. data/lib/spiderfw/model/mappers/mapper.rb +164 -75
  202. data/lib/spiderfw/model/mixins/list.rb +1 -0
  203. data/lib/spiderfw/model/mixins/versioned.rb +63 -27
  204. data/lib/spiderfw/model/model.rb +36 -9
  205. data/lib/spiderfw/model/query_funcs.rb +3 -0
  206. data/lib/spiderfw/model/query_set.rb +21 -1
  207. data/lib/spiderfw/model/storage/base_storage.rb +259 -6
  208. data/lib/spiderfw/model/storage/{db/db_connection_pool.rb → connection_pool.rb} +25 -21
  209. data/lib/spiderfw/model/storage/db/adapters/mysql.rb +25 -5
  210. data/lib/spiderfw/model/storage/db/adapters/oracle.rb +1 -1
  211. data/lib/spiderfw/model/storage/db/connectors/jdbc_oracle.rb +2 -2
  212. data/lib/spiderfw/model/storage/db/connectors/oci8.rb +3 -4
  213. data/lib/spiderfw/model/storage/db/db_storage.rb +18 -219
  214. data/lib/spiderfw/model/storage/document/adapters/mongodb.rb +307 -0
  215. data/lib/spiderfw/model/storage/document/document.rb +7 -0
  216. data/lib/spiderfw/model/storage/document/document_storage.rb +34 -0
  217. data/lib/spiderfw/model/storage.rb +23 -11
  218. data/lib/spiderfw/model/unit_of_work.rb +45 -22
  219. data/lib/spiderfw/spider.rb +660 -0
  220. data/lib/spiderfw/templates/blocks/html.rb +4 -2
  221. data/lib/spiderfw/templates/blocks/run.rb +1 -1
  222. data/lib/spiderfw/templates/blocks/tag_if.rb +1 -1
  223. data/lib/spiderfw/templates/blocks/widget.rb +1 -1
  224. data/lib/spiderfw/templates/layout.rb +29 -5
  225. data/lib/spiderfw/templates/template.rb +72 -7
  226. data/lib/spiderfw/templates/template_blocks.rb +1 -1
  227. data/lib/spiderfw/test/capybara.rb +7 -0
  228. data/lib/spiderfw/test/cucumber.rb +12 -0
  229. data/lib/spiderfw/test/page_object.rb +29 -0
  230. data/lib/spiderfw/test/spec.rb +20 -0
  231. data/lib/spiderfw/test/stubs/mapper_stub.rb +18 -0
  232. data/lib/spiderfw/test/stubs/storage_stub.rb +23 -0
  233. data/lib/spiderfw/test/unit.rb +23 -0
  234. data/lib/spiderfw/test.rb +89 -0
  235. data/lib/spiderfw/utils/json.rb +6 -0
  236. data/lib/spiderfw/utils/logger.rb +17 -4
  237. data/lib/spiderfw/utils/loggers/apache_commons_logger.rb +61 -0
  238. data/lib/spiderfw/utils/monkey/date_time.rb +2 -2
  239. data/lib/spiderfw/utils/monkey/module.rb +3 -1
  240. data/lib/spiderfw/utils/profiling.rb +2 -2
  241. data/lib/spiderfw/widget/widget.rb +31 -13
  242. data/lib/spiderfw.rb +1 -597
  243. data/spider.gemspec +9 -10
  244. metadata +193 -132
  245. data/apps/admin/_init.rb +0 -9
  246. data/apps/admin/controllers/admin_controller.rb +0 -12
  247. data/apps/admin/widgets/dashboard_widget/dashboard_widget.rb +0 -8
  248. data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/development-bundle/AUTHORS.txt +0 -30
  249. data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/development-bundle/ui/i18n/jquery-ui-i18n.js +0 -1176
  250. data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/development-bundle/ui/i18n/jquery.ui.datepicker-no.js +0 -23
  251. data/apps/core/components/public/js/jquery/jquery-ui-1.8.4/development-bundle/version.txt +0 -1
  252. data/apps/core/components/public/js/jquery/plugins/asmselect/jquery.asmselect.css +0 -64
  253. data/apps/core/components/public/js/jquery/plugins/asmselect/jquery.asmselect.js +0 -407
  254. data/apps/core/components/widgets/switcher/switcher.shtml +0 -17
  255. data/apps/master/po/master.pot +0 -400
@@ -31,7 +31,20 @@ module Spider
31
31
  @subclasses ||= []
32
32
  @subclasses << subclass
33
33
  super
34
+ # Do some magic to try and infer the widget's path, considering intermediate superclass callers
35
+ cnt = 0
36
+ s = subclass.superclass
37
+ while s != Spider::Widget
38
+ if caller[cnt].split(':')[-1] =~ /inherited/
39
+ cnt += 1
40
+ end
41
+ s = s.superclass
42
+
43
+ end
44
+ file = caller[cnt].split(':')[0]
45
+ subclass.instance_variable_set("@widget_path", File.dirname(file))
34
46
  end
47
+
35
48
 
36
49
  def attribute(name, params={})
37
50
  # TODO: implement, this is just a placeholder
@@ -101,24 +114,21 @@ module Spider
101
114
  @scene_elements
102
115
  end
103
116
 
104
- def template_path_parent(val=nil)
105
- # FIXME: damn! find a better way!
106
- @template_path_parent = val if val
107
- return @template_path_parent || app.path+'/widgets'
108
- end
109
-
110
117
  def template_path
111
- p = template_path_parent+'/'+Inflector.underscore(self.to_s.split('::')[-1])
112
- return p+'/templates' if (File.exist?(p+'/templates'))
113
- return p
118
+ return @template_path if @template_path
119
+ @template_path = @widget_path
120
+ @template_path += '/templates' if ::File.directory?(@template_path+'/templates')
121
+ @template_path
114
122
  end
115
123
 
116
- def default_template
117
- Spider::Inflector.underscore(self.name).split('/')[-1]
124
+ def default_template(val=nil)
125
+ @default_template = val if val
126
+ @default_template ||= Spider::Inflector.underscore(self.name).split('/')[-1]
127
+ @default_template
118
128
  end
119
129
 
120
130
  def relative_url
121
- template_path[template_path_parent.length+1..-1]
131
+ ::File.dirname(@widget_path)
122
132
  end
123
133
 
124
134
  def route_url
@@ -806,14 +816,22 @@ module Spider
806
816
  "#{self.widget_target}&_we=#{name}"+(params.map{|p| "&_wp[]=#{p}"}).join('')
807
817
  end
808
818
 
819
+ def widget_action_u(name, *params)
820
+ "#{self.widget_target}&_we=#{name}"+(params.map{|p| "&_wp%5B%5D=#{p}"}).join('')
821
+ end
822
+
809
823
  def widget_params(params)
810
- "#{self[:request][:path]}?"+params.map{ |k, v| "_w#{self[:widget][:param]}[#{k}]=#{v}"}.join('&')
824
+ "#{self[:request][:path]}?"+params.map{ |k, v| "_w#{self[:widget][:param]}%5B#{k}%5D=#{v}"}.join('&')
811
825
  end
812
826
 
813
827
  def widget_param(name)
814
828
  "_w#{self[:widget][:param]}[#{name}]"
815
829
  end
816
830
 
831
+ def widget_param_u(name)
832
+ "_w#{self[:widget][:param]}%5B#{name}%5D"
833
+ end
834
+
817
835
  end
818
836
 
819
837
  end
data/lib/spiderfw.rb CHANGED
@@ -1,600 +1,4 @@
1
- require 'spiderfw/env'
1
+ require 'spiderfw/spider'
2
2
 
3
- require 'rubygems'
4
- require 'find'
5
- require 'fileutils'
6
- require 'pathname'
7
- require 'spiderfw/autoload'
8
- require 'spiderfw/requires'
9
3
 
10
- require 'spiderfw/version'
11
-
12
-
13
- module Spider
14
-
15
- class << self
16
- # Everything here must be thread safe!!!
17
-
18
- # An instance of the shared logger.
19
- attr_reader :logger
20
- # An hash of registered Spider::App, indexed by name.
21
- attr_reader :apps
22
- # An hash of registred Spider::App modules, indexed by path.
23
- attr_reader :apps_by_path
24
- # An hash of registred Spider::App modules, indexed by short name (name without namespace).
25
- attr_reader :apps_by_short_name
26
- # The current runmode (test, devel or production).
27
- attr_reader :runmode
28
- # An hash of runtime paths.
29
- # :root:: The base runtime path.
30
- # :apps:: Apps folder.
31
- # :core_apps:: Spider apps folder.
32
- # :config:: Config folder.
33
- # :views:: Runtime views folder.
34
- # :var:: Var folder. Must be writable. Contains cache, logs, and other files written by the server.
35
- # :data:: Data folder. Holds static and dynamic files. Some subdirs may have to be writable.
36
- # :certs:: Certificates folder.
37
- # ::tmp:: Temp folder. Must be writable.
38
- # ::log:: Log location.
39
- attr_reader :paths
40
- # Current Home
41
- attr_reader :home
42
- # Registered resource types
43
- attr_reader :resource_types
44
- # Main site
45
- attr_accessor :site
46
-
47
- # Initializes the runtime environment. This method is called when spider is required. Apps may implement
48
- # an app_init method, that will be called after Spider::init is done.
49
- def init(force=false)
50
- return if @init_done && !force
51
- @paths = {}
52
- @apps_to_load = []
53
- @apps ||= {}
54
- @apps_by_path ||= {}
55
- @apps_by_short_name ||= {}
56
- @loaded_apps = {}
57
- @root = $SPIDER_RUN_PATH
58
- @home = Home.new(@root)
59
- Locale.default = Spider.conf.get('i18n.default_locale')
60
- @resource_types = {}
61
- register_resource_type(:views, :extensions => ['shtml'])
62
- setup_paths(@root)
63
- all_apps = find_all_apps
64
- all_apps.each do |path|
65
- opts = File.join(path, 'config/options.rb')
66
- require opts if File.exist?(opts)
67
- end
68
- @runmode = nil
69
- self.runmode = $SPIDER_RUNMODE if $SPIDER_RUNMODE
70
- load_configuration File.join($SPIDER_PATH, 'config')
71
- load_configuration File.join(@root, 'config')
72
- start_loggers
73
- # @controller = Controller
74
- @paths[:spider] = $SPIDER_PATH
75
-
76
- if ($SPIDER_CONFIG_SETS)
77
- $SPIDER_CONFIG_SETS.each{ |set| @configuration.include_set(set) }
78
- end
79
- init_file = File.join($SPIDER_RUN_PATH, 'init.rb')
80
- if File.exist?(init_file)
81
- @home.instance_eval(File.read(init_file), init_file)
82
- end
83
- @logger.close(STDERR)
84
- @logger.open(STDERR, Spider.conf.get('debug.console.level')) if Spider.conf.get('debug.console.level')
85
- GetText::LocalePath.memoize_clear # since new paths have been added to GetText
86
- @apps.each do |name, mod|
87
- GetText.bindtextdomain(mod.short_name) if File.directory?(mod.path+'/po')
88
- mod.app_init if mod.respond_to?(:app_init)
89
- end
90
- @init_done=true
91
- end
92
-
93
- #
94
- # def stop
95
- # @apps.each do |name, mod|
96
- # mod.app_stop if mod.respond_to?(:app_stop)
97
- # end
98
- # end
99
-
100
-
101
- # Invoked before a server is started. Apps may implement the app_startup method, that will be called.
102
- def startup
103
- unless File.exists?(File.join(Spider.paths[:root], 'init.rb'))
104
- raise "The server must be started from the root directory"
105
- end
106
- if (Spider.conf.get('template.cache.reload_on_restart'))
107
- FileUtils.touch("#{Spider.paths[:tmp]}/templates_reload.txt")
108
- end
109
- if domain = Spider.conf.get('site.domain')
110
- ssl_port = Spider.conf.get('site.ssl') ? Spider.conf.get('site.ssl_port') : nil
111
- Spider.site = Site.new(domain, Spider.conf.get('site.port'), ssl_port)
112
- elsif File.exists?(Site.cache_file)
113
- Spider.site = Site.load_cache
114
- end
115
- if (Spider.conf.get('request.mutex'))
116
- mutex_requests!
117
- end
118
- @apps.each do |name, mod|
119
- mod.app_startup if mod.respond_to?(:app_startup)
120
- end
121
- @startup_done = true
122
- end
123
-
124
- def startup_done?
125
- @startup_done
126
- end
127
-
128
- # Invoked when a server is shutdown. Apps may implement the app_shutdown method, that will be called.
129
- def shutdown
130
- return unless Thread.current == Thread.main
131
- Debugger.post_mortem = false if Object.const_defined?(:Debugger) && Debugger.post_mortem?
132
- @apps.each do |name, mod|
133
- mod.app_shutdown if mod.respond_to?(:app_shutdown)
134
- end
135
- end
136
-
137
- def current
138
- Spider::Request.current
139
- end
140
-
141
- def request_started
142
- @request_mutex.lock if (@request_mutex)
143
- Spider::Request.current = {
144
- :_start => Time.now
145
- }
146
- end
147
-
148
- def request_finished
149
- # Spider.logger.info("Done in #{(Time.now - Spider::Request.current[:_start])*1000}ms")
150
- Spider::Request.reset_current
151
- @request_mutex.unlock if (@request_mutex)
152
- end
153
-
154
- def mutex_requests!
155
- @request_mutex = Mutex.new
156
- end
157
-
158
- def request_mutex
159
- @request_mutex
160
- end
161
-
162
- def request_mutex=(val)
163
- @request_mutex = val
164
- end
165
-
166
-
167
- # Closes any open loggers, and opens new ones based on configured settings.
168
- def start_loggers
169
- @logger = Spider::Logger
170
- @logger.close_all
171
- @logger.open(STDERR, Spider.conf.get('debug.console.level')) if Spider.conf.get('debug.console.level')
172
- begin
173
- FileUtils.mkpath(@paths[:log]) unless File.exist?(@paths[:log])
174
- rescue => exc
175
- @logger.error("Unable to create log folder")
176
- end
177
- if (File.exist?(@paths[:log]))
178
- @logger.open(File.join(@paths[:log], 'error.log'), :ERROR) if Spider.conf.get('log.errors')
179
- if (Spider.conf.get('log.debug.level'))
180
- @logger.open(File.join(@paths[:log], 'debug.log'), Spider.conf.get('log.debug.level'))
181
- end
182
- end
183
- $LOG = @logger
184
- end
185
-
186
- # Sets the default paths (see #paths).
187
- def setup_paths(root)
188
- @paths[:root] = root
189
- @paths[:apps] = File.join(root, 'apps')
190
- @paths[:core_apps] = File.join($SPIDER_PATH, 'apps')
191
- @paths[:config] = File.join(root, 'config')
192
- @paths[:layouts] = File.join(root, 'layouts')
193
- @paths[:var] = File.join(root, 'var')
194
- @paths[:certs] = File.join(@paths[:config], 'certs')
195
- @paths[:tmp] = File.join(root, 'tmp')
196
- @paths[:data] = File.join(root, 'data')
197
- @paths[:log] = File.join(@paths[:var], 'log')
198
- end
199
-
200
- # Finds an app by name, looking in paths[:apps] and paths[:core_apps]. Returns the found path.
201
- def find_app(name)
202
- path = nil
203
- [@paths[:apps], @paths[:core_apps]].each do |base|
204
- test = File.join(base, name)
205
- if File.exist?(File.join(test, '_init.rb'))
206
- path = test
207
- break
208
- end
209
- end
210
- return path
211
- end
212
-
213
- def find_apps(name)
214
- [@paths[:apps], @paths[:core_apps]].each do |base|
215
- test = File.join(base, name)
216
- if File.exist?(test)
217
- return find_apps_in_folder(test)
218
- end
219
- end
220
- end
221
-
222
- def load_app(name)
223
- paths = find_apps(name)
224
- paths.each do |path|
225
- load_app_at_path(path)
226
- end
227
- end
228
-
229
- def load_app_at_path(path)
230
- return if @loaded_apps[path]
231
- relative_path = path
232
- if path.index(Spider.paths[:root])
233
- home = Pathname.new(Spider.paths[:root])
234
- pname = Pathname.new(path)
235
- relative_path = pname.relative_path_from(home).to_s
236
- end
237
- @loaded_apps[path] = true
238
- last_name = File.basename(path)
239
- app_files = ['_init.rb', last_name+'.rb', 'cmd.rb']
240
- app_files.each{ |f| require File.join(relative_path, f) if File.exist?(File.join(path, f)) }
241
- GetText::LocalePath.add_default_rule(File.join(path, "data/locale/%{lang}/LC_MESSAGES/%{name}.mo"))
242
- end
243
-
244
- def load_apps(*l)
245
- l.each do |app|
246
- load_app(app)
247
- end
248
- end
249
-
250
- def load_all_apps
251
- find_all_apps.each do |path|
252
- load_app_at_path(path)
253
- end
254
- end
255
-
256
- def find_all_apps
257
- app_paths = []
258
- Find.find(@paths[:core_apps], @paths[:apps]) do |path|
259
- if (File.basename(path) == '_init.rb')
260
- app_paths << File.dirname(path)
261
- Find.prune
262
- elsif File.exist?(File.join(path, '_init.rb'))
263
- app_paths << path
264
- Find.prune
265
- end
266
- end
267
- return app_paths
268
- end
269
-
270
- def find_apps_in_folder(path)
271
- return unless File.directory?(path)
272
- return [path] if File.exist?(File.join(path, '_init.rb'))
273
- found = []
274
- Dir.new(path).each do |f|
275
- next if f[0].chr == '.'
276
- found_path = File.join(path, f)
277
- if File.exist?(File.join(found_path, '/_init.rb'))
278
- found << found_path
279
- else
280
- found += find_apps_in_folder(found_path)
281
- end
282
- end
283
- return found
284
- end
285
-
286
- def add_app(mod)
287
- @apps[mod.name] = mod
288
- @apps_by_path[mod.relative_path] = mod
289
- @apps_by_short_name[mod.short_name] = mod
290
- end
291
-
292
- def app?(path_or_name)
293
- return true if @apps_by_path[path_or_name]
294
- return true if @apps_by_short_name[path_or_name]
295
- return false
296
- end
297
-
298
- def load_configuration(path)
299
- return unless File.directory?(path)
300
- opts = File.join(path, 'options.rb')
301
- require opts if File.exist?(opts)
302
- Dir.new(path).each do |f|
303
- f.untaint # FIXME: security parse
304
- case f
305
- when /^\./
306
- next
307
- when /\.(yaml|yml)$/
308
- begin
309
- @configuration.load_yaml(File.join(path, f))
310
- rescue ConfigurationException => exc
311
- if (exc.type == :yaml)
312
- @logger.error("Configuration file #{path+f} is not valid YAML")
313
- else
314
- raise
315
- end
316
- end
317
- end
318
- end
319
- end
320
-
321
- # Returns the default controller.
322
- def controller
323
- require 'spiderfw/controller/spider_controller'
324
- SpiderController
325
- end
326
-
327
- # Sets routes on the #controller for the given apps.
328
- def route_apps(*apps)
329
- options = {}
330
- if apps[-1].is_a?(Hash)
331
- options = apps.pop
332
- end
333
- @route_apps = apps.empty? ? true : apps
334
- if (@route_apps)
335
- apps_to_route = @route_apps == true ? self.apps.values : @route_apps.map{ |name| self.apps[name] }
336
- end
337
- if options[:except]
338
- apps_to_route.reject{ |app| options[:except].include?(app) }
339
- end
340
- if (apps_to_route)
341
- apps_to_route.each{ |app| @home.controller.route_app(app) }
342
- end
343
- end
344
-
345
- # Adds a resource type
346
- # name must be a symbol, extensions an array of extensions (strings, without the dot) for this resource.
347
- # Options may be:
348
- # :extensions an array of possible extensions. If given, find_resource will try appending the extensions
349
- # when looking for the file.
350
- # :path the path of the resource relative to resource root; if not given, name will be used.
351
- #
352
- def register_resource_type(name, options={})
353
- @resource_types[name] = {
354
- :extensions => options[:extensions],
355
- :path => options[:path] || name.to_s
356
- }
357
- end
358
-
359
- def path
360
- $SPIDER_PATH
361
- end
362
-
363
- def relative_path
364
- '/spider'
365
- end
366
-
367
- # Returns the full path of a resource.
368
- # resource_type may be :views, or any other type registered with #register_resource_type
369
- # path is the path of the resource, relative to the resource folder
370
- # cur_path, if provided, is the current working path
371
- # owner_class, if provided, must respond to *app*
372
- #
373
- # Will look for the resource in the runtime root first, than in the
374
- # app's :"#{resource_type}_path", and finally in the spider folder.
375
- def find_resource(resource_type, path, cur_path=nil, owner_classes=nil, search_paths=[])
376
- owner_classes = [owner_classes] unless owner_classes.is_a?(Enumerable)
377
- # FIXME: security check for allowed paths?
378
- def first_found(extensions, path)
379
- extensions.each do |ext|
380
- full = path
381
- full += '.'+ext if ext
382
- return full if (File.exist?(full))
383
- end
384
- return nil
385
- end
386
-
387
- search_paths ||= []
388
- owner_classes.each do |owner_class| # FIXME: refactor
389
- next if owner_class.is_a?(Spider::Home) # home is already checked for other owner_classes
390
- # FIXME: maybe it shouldn't get here?
391
- owner_class = nil if owner_class == NilClass
392
- resource_config = @resource_types[resource_type]
393
- raise "Unknown resource type #{resource_type}" unless resource_config
394
- resource_rel_path = resource_config[:path]
395
- extensions = [nil] + resource_config[:extensions]
396
- path.strip!
397
- if (path[0..3] == 'ROOT')
398
- path.sub!(/^ROOT/, Spider.paths[:root])
399
- return Resource.new(path, @home)
400
- elsif (path[0..5] == 'SPIDER')
401
- path.sub!(/^SPIDER/, $SPIDER_PATH)
402
- return Resource.new(path, self)
403
- elsif (cur_path)
404
- if (path[0..1] == './')
405
- return Resource.new(first_found(extensions, cur_path+path[1..-1]), owner_class)
406
- elsif (path[0..1] == '../')
407
- return Resource.new(first_found(extensions, File.dirname(cur_path)+path[2..-1]), owner_class)
408
- end
409
- end
410
- app = nil
411
- path_app = nil
412
- if (path[0].chr == '/')
413
- first_part = path[1..-1].split('/')[0]
414
- Spider.apps_by_path.each do |p, a|
415
- if path.index(p+'/') == 1 # FIXME: might not be correct
416
- #if first_part == p
417
- path_app = a
418
- path = path[p.length+2..-1]
419
- break
420
- end
421
- end
422
- app = path_app
423
- elsif owner_class <= Spider::App
424
- app = owner_class
425
- else
426
- app = owner_class.app if (owner_class && owner_class.app)
427
- end
428
- return Resource.new(cur_path+'/'+path, owner_class) if cur_path && File.exist?(cur_path+'/'+path) # !app
429
- raise "Can't find owner app for resource #{path}" unless app
430
- search_locations = resource_search_locations(resource_type, app)
431
- search_paths.each do |p|
432
- p = [p, owner_class] unless p.is_a?(Array)
433
- search_locations << p
434
- end
435
- search_locations.each do |p|
436
- found = first_found(extensions, p[0]+'/'+path)
437
- next if found == cur_path
438
- definer = path_app || p[1]
439
- return Resource.new(found, definer) if found
440
- end
441
- end
442
- return Resource.new(path)
443
- end
444
-
445
- def resource_search_locations(resource_type, app=nil)
446
- resource_config = @resource_types[resource_type]
447
- resource_rel_path = resource_config[:path]
448
- app_rel_path = app && app.respond_to?(:relative_path) ? app.relative_path : nil
449
- root_search = File.join(Spider.paths[:root], resource_rel_path)
450
- root_search = File.join(root_search, app_rel_path) if app_rel_path
451
- # unless cur_path && cur_path == File.join(root_search, path)
452
- search_locations = [[root_search, @home]]
453
- # end
454
- if app
455
- if app.respond_to?("#{resource_type}_path")
456
- search_locations << [app.send("#{resource_type}_path"), app]
457
- else
458
- search_locations << [File.join(app.path, resource_rel_path), app]
459
- end
460
- end
461
- spider_path = File.join($SPIDER_PATH, resource_rel_path)
462
- search_locations << [spider_path, self]
463
- search_locations
464
- end
465
-
466
- def list_resources(resource_type, owner_class=nil, start=nil, search_paths = [])
467
- app = nil
468
- if owner_class <= Spider::App
469
- app = owner_class
470
- else
471
- app = owner_class.app if (owner_class && owner_class.app)
472
- end
473
- search_locations = resource_search_locations(resource_type, app)
474
- resource_config = @resource_types[resource_type]
475
- extensions = resource_config[:extensions]
476
- search_paths.each do |p|
477
- p = [p, owner_class] unless p.is_a?(Array)
478
- search_locations << p
479
- end
480
- res = []
481
- search_locations.reverse.each do |p|
482
- pname = Pathname.new(p[0])
483
- base = p[0]
484
- base = File.join(base, start) if start
485
- extensions.each do |ext|
486
- Dir.glob(File.join(base, "*.#{ext}")).each do |f|
487
- res << (Pathname.new(f).relative_path_from(pname)).to_s
488
- end
489
- end
490
- end
491
- res.uniq
492
-
493
- end
494
-
495
- def find_resource_path(resource_type, path, cur_path=nil, owner_classes=nil, search_paths=[])
496
- res = find_resource(resource_type, path, cur_path, owner_classes, search_paths)
497
- return res ? res.path : nil
498
- end
499
-
500
-
501
- # Source file management
502
-
503
- def sources_in_dir(path)
504
- loaded = []
505
- $".each do |file|
506
- basename = File.basename(file)
507
- next if (basename == 'spider.rb' || basename == 'options.rb')
508
- if (file[0..path.length-1] == path)
509
- loaded.push(file)
510
- else
511
- $:.each do |dir|
512
- file_path = File.join(dir, file)
513
- if (file_path =~ /^#{path}/) # FileTest.exists?(file_path) &&
514
- loaded.push(file_path)
515
- end
516
- end
517
- end
518
- end
519
- return loaded
520
- end
521
-
522
- def reload_sources_in_dir(dir)
523
- self.sources_in_dir(dir).each do |file|
524
- load(file)
525
- end
526
- end
527
-
528
- def reload_sources
529
- logger.debug("Reloading sources")
530
- crit = Thread.critical
531
- Thread.critical = true
532
- $".each do |file|
533
- if file =~ /^(#{$SPIDER_RUN_PATH}|apps)/
534
- # logger.debug("RELOADING #{file}")
535
- load(file)
536
- else
537
- # logger.debug("SKIPPING #{file}")
538
- end
539
- end
540
- Thread.critical = crit
541
- end
542
-
543
- def runmode=(mode)
544
- raise "Can't change runmode" if @runmode
545
- @runmode = mode
546
- @configuration.include_set(mode)
547
- if mode == 'devel' || File.exists?(File.join($SPIDER_RUN_PATH,'tmp', 'debug.txt'))
548
- init_debug
549
- end
550
- if (mode != 'production')
551
- Spider.paths[:var] = File.join(Spider.paths[:var], mode)
552
- end
553
- end
554
-
555
- def init_debug
556
- begin
557
- require 'ruby-debug'
558
- if File.exists?(File.join($SPIDER_RUN_PATH,'tmp', 'debug.txt'))
559
- Debugger.wait_connection = true
560
- Debugger.start_remote
561
- File.delete(File.join($SPIDER_RUN_PATH,'tmp', 'debug.txt'))
562
- else
563
- Debugger.start
564
- end
565
- rescue LoadError, RuntimeError; end
566
- end
567
-
568
- def locale
569
- Locale.current[0]
570
- end
571
-
572
- def i18n(l = self.locale)
573
- Spider::I18n.provider(l)
574
- end
575
-
576
- def test_setup
577
- end
578
-
579
- def test_teardown
580
- end
581
-
582
- def _test_setup
583
- @apps.each do |name, mod|
584
- mod.test_setup if mod.respond_to?(:test_setup)
585
- end
586
- end
587
-
588
- def _test_teardown
589
- @apps.each do |name, mod|
590
- mod.test_teardown if mod.respond_to?(:test_teardown)
591
- end
592
- end
593
-
594
- end
595
-
596
- end
597
-
598
- # load instead of require for reload_sources to work correctly
599
- load 'spiderfw/config/options/spider.rb'
600
4
  Spider::init()