spiderfw 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) hide show
  1. data/CHANGELOG +5 -0
  2. data/VERSION +1 -1
  3. data/apps/core/auth/lib/rbac.rb +15 -0
  4. data/apps/core/auth/models/mixins/rbac_provider.rb +28 -10
  5. data/apps/core/auth/po/it/spider_auth.po +3 -2
  6. data/apps/core/auth/po/spider_auth.pot +3 -2
  7. data/apps/core/auth/views/login.shtml +1 -1
  8. data/apps/core/components/po/it/spider_components.po +11 -12
  9. data/apps/core/components/po/spider_components.pot +11 -10
  10. data/apps/core/components/public/css/crud.css +4 -0
  11. data/apps/core/components/public/js/jquery/jquery-ui-1.8.11/css/Aristo/jquery-ui.custom.css +1 -0
  12. data/apps/core/components/public/js/jquery/plugins/bsmselect/README.md +1 -0
  13. data/apps/core/components/public/js/jquery/plugins/bsmselect/js/jquery.bsmselect.js +11 -11
  14. data/apps/core/components/public/js/jquery/plugins/jquery.form.js +325 -154
  15. data/apps/core/components/public/js/spider.js +6 -0
  16. data/apps/core/components/widgets/admin/admin.rb +44 -1
  17. data/apps/core/components/widgets/crud/crud.rb +48 -27
  18. data/apps/core/components/widgets/crud/crud.shtml +5 -3
  19. data/apps/core/components/widgets/table/table.rb +3 -3
  20. data/apps/core/forms/po/it/spider_forms.po +4 -4
  21. data/apps/core/forms/po/spider_forms.pot +4 -3
  22. data/apps/core/forms/public/ckeditor/CHANGES.html +1295 -0
  23. data/apps/core/forms/public/ckeditor/INSTALL.html +92 -0
  24. data/apps/core/forms/public/ckeditor/LICENSE.html +1334 -0
  25. data/apps/core/forms/public/ckeditor/adapters/jquery.js +2 -2
  26. data/apps/core/forms/public/ckeditor/ckeditor.js +141 -133
  27. data/apps/core/forms/public/ckeditor/ckeditor_basic.js +8 -0
  28. data/apps/core/forms/public/ckeditor/ckeditor_basic_source.js +20 -0
  29. data/apps/core/forms/public/ckeditor/ckeditor_source.js +25 -0
  30. data/apps/core/forms/public/ckeditor/config.js +11 -0
  31. data/apps/core/forms/public/ckeditor/contents.css +23 -0
  32. data/apps/core/forms/public/ckeditor/lang/_languages.js +2 -2
  33. data/apps/core/forms/public/ckeditor/lang/_translationstatus.txt +58 -57
  34. data/apps/core/forms/public/ckeditor/lang/af.js +2 -2
  35. data/apps/core/forms/public/ckeditor/lang/ar.js +2 -2
  36. data/apps/core/forms/public/ckeditor/lang/bg.js +2 -2
  37. data/apps/core/forms/public/ckeditor/lang/bn.js +2 -2
  38. data/apps/core/forms/public/ckeditor/lang/bs.js +2 -2
  39. data/apps/core/forms/public/ckeditor/lang/ca.js +2 -2
  40. data/apps/core/forms/public/ckeditor/lang/cs.js +2 -2
  41. data/apps/core/forms/public/ckeditor/lang/cy.js +2 -2
  42. data/apps/core/forms/public/ckeditor/lang/da.js +2 -2
  43. data/apps/core/forms/public/ckeditor/lang/de.js +2 -2
  44. data/apps/core/forms/public/ckeditor/lang/el.js +2 -2
  45. data/apps/core/forms/public/ckeditor/lang/en-au.js +2 -2
  46. data/apps/core/forms/public/ckeditor/lang/en-ca.js +2 -2
  47. data/apps/core/forms/public/ckeditor/lang/en-gb.js +2 -2
  48. data/apps/core/forms/public/ckeditor/lang/en.js +2 -2
  49. data/apps/core/forms/public/ckeditor/lang/eo.js +2 -2
  50. data/apps/core/forms/public/ckeditor/lang/es.js +2 -2
  51. data/apps/core/forms/public/ckeditor/lang/et.js +2 -2
  52. data/apps/core/forms/public/ckeditor/lang/eu.js +2 -2
  53. data/apps/core/forms/public/ckeditor/lang/fa.js +2 -2
  54. data/apps/core/forms/public/ckeditor/lang/fi.js +2 -2
  55. data/apps/core/forms/public/ckeditor/lang/fo.js +2 -2
  56. data/apps/core/forms/public/ckeditor/lang/fr-ca.js +2 -2
  57. data/apps/core/forms/public/ckeditor/lang/fr.js +2 -2
  58. data/apps/core/forms/public/ckeditor/lang/gl.js +2 -2
  59. data/apps/core/forms/public/ckeditor/lang/gu.js +2 -2
  60. data/apps/core/forms/public/ckeditor/lang/he.js +2 -2
  61. data/apps/core/forms/public/ckeditor/lang/hi.js +2 -2
  62. data/apps/core/forms/public/ckeditor/lang/hr.js +2 -2
  63. data/apps/core/forms/public/ckeditor/lang/hu.js +2 -2
  64. data/apps/core/forms/public/ckeditor/lang/is.js +2 -2
  65. data/apps/core/forms/public/ckeditor/lang/it.js +2 -2
  66. data/apps/core/forms/public/ckeditor/lang/ja.js +2 -2
  67. data/apps/core/forms/public/ckeditor/lang/ka.js +6 -0
  68. data/apps/core/forms/public/ckeditor/lang/km.js +2 -2
  69. data/apps/core/forms/public/ckeditor/lang/ko.js +2 -2
  70. data/apps/core/forms/public/ckeditor/lang/lt.js +2 -2
  71. data/apps/core/forms/public/ckeditor/lang/lv.js +2 -2
  72. data/apps/core/forms/public/ckeditor/lang/mn.js +2 -2
  73. data/apps/core/forms/public/ckeditor/lang/ms.js +2 -2
  74. data/apps/core/forms/public/ckeditor/lang/nb.js +2 -2
  75. data/apps/core/forms/public/ckeditor/lang/nl.js +2 -2
  76. data/apps/core/forms/public/ckeditor/lang/no.js +2 -2
  77. data/apps/core/forms/public/ckeditor/lang/pl.js +2 -2
  78. data/apps/core/forms/public/ckeditor/lang/pt-br.js +2 -2
  79. data/apps/core/forms/public/ckeditor/lang/pt.js +2 -2
  80. data/apps/core/forms/public/ckeditor/lang/ro.js +2 -2
  81. data/apps/core/forms/public/ckeditor/lang/ru.js +2 -2
  82. data/apps/core/forms/public/ckeditor/lang/sk.js +2 -2
  83. data/apps/core/forms/public/ckeditor/lang/sl.js +2 -2
  84. data/apps/core/forms/public/ckeditor/lang/sr-latn.js +2 -2
  85. data/apps/core/forms/public/ckeditor/lang/sr.js +2 -2
  86. data/apps/core/forms/public/ckeditor/lang/sv.js +2 -2
  87. data/apps/core/forms/public/ckeditor/lang/th.js +2 -2
  88. data/apps/core/forms/public/ckeditor/lang/tr.js +2 -2
  89. data/apps/core/forms/public/ckeditor/lang/uk.js +2 -2
  90. data/apps/core/forms/public/ckeditor/lang/vi.js +2 -2
  91. data/apps/core/forms/public/ckeditor/lang/zh-cn.js +2 -2
  92. data/apps/core/forms/public/ckeditor/lang/zh.js +2 -2
  93. data/apps/core/forms/public/ckeditor/plugins/a11yhelp/dialogs/a11yhelp.js +2 -2
  94. data/apps/core/forms/public/ckeditor/plugins/a11yhelp/lang/en.js +2 -2
  95. data/apps/core/forms/public/ckeditor/plugins/a11yhelp/lang/he.js +1 -1
  96. data/apps/core/forms/public/ckeditor/plugins/about/dialogs/about.js +2 -2
  97. data/apps/core/forms/public/ckeditor/plugins/adobeair/plugin.js +6 -0
  98. data/apps/core/forms/public/ckeditor/plugins/ajax/plugin.js +6 -0
  99. data/apps/core/forms/public/ckeditor/plugins/autogrow/plugin.js +2 -2
  100. data/apps/core/forms/public/ckeditor/plugins/bbcode/plugin.js +9 -0
  101. data/apps/core/forms/public/ckeditor/plugins/clipboard/dialogs/paste.js +3 -3
  102. data/apps/core/forms/public/ckeditor/plugins/colordialog/dialogs/colordialog.js +3 -3
  103. data/apps/core/forms/public/ckeditor/plugins/devtools/lang/en.js +6 -0
  104. data/apps/core/forms/public/ckeditor/plugins/devtools/plugin.js +6 -0
  105. data/apps/core/forms/public/ckeditor/plugins/dialog/dialogDefinition.js +1 -1
  106. data/apps/core/forms/public/ckeditor/plugins/div/dialogs/div.js +1 -1
  107. data/apps/core/forms/public/ckeditor/plugins/docprops/dialogs/docprops.js +10 -0
  108. data/apps/core/forms/public/ckeditor/plugins/docprops/plugin.js +6 -0
  109. data/apps/core/forms/public/ckeditor/plugins/find/dialogs/find.js +4 -4
  110. data/apps/core/forms/public/ckeditor/plugins/flash/dialogs/flash.js +4 -4
  111. data/apps/core/forms/public/ckeditor/plugins/forms/dialogs/button.js +2 -2
  112. data/apps/core/forms/public/ckeditor/plugins/forms/dialogs/checkbox.js +2 -2
  113. data/apps/core/forms/public/ckeditor/plugins/forms/dialogs/form.js +2 -2
  114. data/apps/core/forms/public/ckeditor/plugins/forms/dialogs/hiddenfield.js +2 -2
  115. data/apps/core/forms/public/ckeditor/plugins/forms/dialogs/radio.js +2 -2
  116. data/apps/core/forms/public/ckeditor/plugins/forms/dialogs/select.js +4 -4
  117. data/apps/core/forms/public/ckeditor/plugins/forms/dialogs/textarea.js +2 -2
  118. data/apps/core/forms/public/ckeditor/plugins/forms/dialogs/textfield.js +2 -3
  119. data/apps/core/forms/public/ckeditor/plugins/iframe/dialogs/iframe.js +7 -0
  120. data/apps/core/forms/public/ckeditor/plugins/iframe/images/placeholder.png +0 -0
  121. data/apps/core/forms/public/ckeditor/plugins/iframedialog/plugin.js +2 -2
  122. data/apps/core/forms/public/ckeditor/plugins/image/dialogs/image.js +8 -8
  123. data/apps/core/forms/public/ckeditor/plugins/link/dialogs/anchor.js +2 -2
  124. data/apps/core/forms/public/ckeditor/plugins/link/dialogs/link.js +7 -7
  125. data/apps/core/forms/public/ckeditor/plugins/liststyle/dialogs/liststyle.js +1 -1
  126. data/apps/core/forms/public/ckeditor/plugins/pastefromword/filter/default.js +7 -6
  127. data/apps/core/forms/public/ckeditor/plugins/pastetext/dialogs/pastetext.js +2 -2
  128. data/apps/core/forms/public/ckeditor/plugins/placeholder/dialogs/placeholder.js +6 -0
  129. data/apps/core/forms/public/ckeditor/plugins/placeholder/lang/en.js +6 -0
  130. data/apps/core/forms/public/ckeditor/plugins/placeholder/lang/he.js +6 -0
  131. data/apps/core/forms/public/ckeditor/plugins/placeholder/placeholder.gif +0 -0
  132. data/apps/core/forms/public/ckeditor/plugins/placeholder/plugin.js +6 -0
  133. data/apps/core/forms/public/ckeditor/plugins/scayt/dialogs/options.js +4 -4
  134. data/apps/core/forms/public/ckeditor/plugins/scayt/dialogs/toolbar.css +1 -1
  135. data/apps/core/forms/public/ckeditor/plugins/smiley/dialogs/smiley.js +3 -3
  136. data/apps/core/forms/public/ckeditor/plugins/specialchar/dialogs/specialchar.js +3 -3
  137. data/apps/core/forms/public/ckeditor/plugins/specialchar/lang/en.js +6 -0
  138. data/apps/core/forms/public/ckeditor/plugins/styles/styles/default.js +1 -1
  139. data/apps/core/forms/public/ckeditor/plugins/stylesheetparser/plugin.js +6 -0
  140. data/apps/core/forms/public/ckeditor/plugins/table/dialogs/table.js +3 -3
  141. data/apps/core/forms/public/ckeditor/plugins/tableresize/plugin.js +2 -2
  142. data/apps/core/forms/public/ckeditor/plugins/tabletools/dialogs/tableCell.js +4 -4
  143. data/apps/core/forms/public/ckeditor/plugins/templates/dialogs/templates.js +2 -2
  144. data/apps/core/forms/public/ckeditor/plugins/templates/templates/default.js +1 -1
  145. data/apps/core/forms/public/ckeditor/plugins/uicolor/dialogs/uicolor.js +1 -1
  146. data/apps/core/forms/public/ckeditor/plugins/uicolor/lang/en.js +1 -1
  147. data/apps/core/forms/public/ckeditor/plugins/uicolor/lang/he.js +1 -1
  148. data/apps/core/forms/public/ckeditor/plugins/uicolor/plugin.js +1 -1
  149. data/apps/core/forms/public/ckeditor/plugins/uicolor/yui/assets/yui.css +1 -1
  150. data/apps/core/forms/public/ckeditor/plugins/uicolor/yui/yui.js +1 -1
  151. data/apps/core/forms/public/ckeditor/plugins/wsc/dialogs/ciframe.html +1 -1
  152. data/apps/core/forms/public/ckeditor/plugins/wsc/dialogs/tmpFrameset.html +1 -1
  153. data/apps/core/forms/public/ckeditor/plugins/wsc/dialogs/wsc.css +1 -1
  154. data/apps/core/forms/public/ckeditor/plugins/wsc/dialogs/wsc.js +3 -3
  155. data/apps/core/forms/public/ckeditor/plugins/xml/plugin.js +6 -0
  156. data/apps/core/forms/public/ckeditor/skins/kama/dialog.css +5 -5
  157. data/apps/core/forms/public/ckeditor/skins/kama/editor.css +9 -8
  158. data/apps/core/forms/public/ckeditor/skins/kama/icons.png +0 -0
  159. data/apps/core/forms/public/ckeditor/skins/kama/icons_rtl.png +0 -0
  160. data/apps/core/forms/public/ckeditor/skins/kama/skin.js +3 -3
  161. data/apps/core/forms/public/ckeditor/skins/kama/templates.css +1 -1
  162. data/apps/core/forms/public/ckeditor/themes/default/theme.js +4 -4
  163. data/apps/core/forms/public/css/form.css +1 -0
  164. data/apps/core/forms/public/css/html_area.css +3 -0
  165. data/apps/core/forms/public/html_area.js +4 -4
  166. data/apps/core/forms/public/search_select.js +2 -2
  167. data/apps/core/forms/public/select.js +5 -5
  168. data/apps/core/forms/tags/element_label.erb +5 -2
  169. data/apps/core/forms/tags/element_row.erb +7 -6
  170. data/apps/core/forms/tags/row.erb +6 -4
  171. data/apps/core/forms/widgets/form/form.rb +5 -4
  172. data/apps/core/forms/widgets/inputs/html_area/html_area.rb +10 -4
  173. data/apps/core/forms/widgets/inputs/html_area/html_area.shtml +1 -0
  174. data/apps/core/forms/widgets/inputs/select/select.rb +18 -5
  175. data/apps/core/forms/widgets/inputs/select/select.shtml +3 -0
  176. data/apps/master/po/master.pot +408 -0
  177. data/apps/messenger/po/it/spider_messenger.po +6 -10
  178. data/apps/messenger/po/spider_messenger.pot +2 -1
  179. data/blueprints/home/{Gemfile → Gemfile.disabled} +0 -0
  180. data/lib/spiderfw/config/configuration.rb +5 -0
  181. data/lib/spiderfw/config/options/spider.rb +2 -2
  182. data/lib/spiderfw/controller/controller.rb +4 -1
  183. data/lib/spiderfw/controller/mixins/http_mixin.rb +2 -0
  184. data/lib/spiderfw/create.rb +9 -5
  185. data/lib/spiderfw/model/base_model.rb +32 -9
  186. data/lib/spiderfw/model/condition.rb +7 -0
  187. data/lib/spiderfw/model/datatypes/text.rb +3 -1
  188. data/lib/spiderfw/model/mappers/db_mapper.rb +19 -5
  189. data/lib/spiderfw/model/mappers/mapper.rb +1 -1
  190. data/lib/spiderfw/model/mixins/tree.rb +2 -1
  191. data/lib/spiderfw/model/query_set.rb +14 -13
  192. data/lib/spiderfw/model/storage/db/adapters/mysql.rb +7 -2
  193. data/lib/spiderfw/model/storage/db/db_schema.rb +4 -2
  194. data/lib/spiderfw/model/storage/db/db_storage.rb +4 -4
  195. data/lib/spiderfw/model/unit_of_work.rb +3 -1
  196. data/lib/spiderfw/templates/blocks/html.rb +2 -2
  197. data/lib/spiderfw/templates/blocks/lambda.rb +25 -0
  198. data/lib/spiderfw/templates/blocks/recurse.rb +41 -0
  199. data/lib/spiderfw/templates/blocks/widget.rb +2 -3
  200. data/lib/spiderfw/templates/layout.rb +20 -3
  201. data/lib/spiderfw/templates/template.rb +35 -29
  202. data/lib/spiderfw/templates/template_blocks.rb +6 -0
  203. data/lib/spiderfw/widget/widget.rb +2 -1
  204. metadata +35 -5
@@ -962,11 +962,13 @@ module Spider; module Model
962
962
 
963
963
  # Returns the model actually defining element_name; that could be the model
964
964
  # itself, a superclass, or an integrated model.
965
- def self.first_definer(element_name, type)
966
- if (@extended_models && @extended_models[self.superclass] && self.superclass.elements[element_name] && self.superclass.elements[element_name].type == type)
965
+ def self.first_definer(element_name, type=nil)
966
+ type ||= self.elements[element_name].type
967
+ if @extended_models && @extended_models[self.superclass] && self.superclass.elements[element_name] && \
968
+ self.superclass.elements[element_name].type == type
967
969
  return self.superclass.first_definer(element_name, type)
968
970
  end
969
- if (self.attributes[:integrated_models])
971
+ if self.attributes[:integrated_models]
970
972
  self.attributes[:integrated_models].keys.each do |mod|
971
973
  return mod.first_definer(element_name, type) if (mod.elements[element_name] && mod.elements[element_name].type == type)
972
974
  end
@@ -1117,6 +1119,12 @@ module Spider; module Model
1117
1119
  return self.where
1118
1120
  end
1119
1121
 
1122
+ # Returns a queryset with the objects that should be shown to the user. By default
1123
+ # returns self.all
1124
+ def self.list
1125
+ return self.all
1126
+ end
1127
+
1120
1128
  # Constructs a Query based on params, and returns a QuerySet
1121
1129
  # Allowed parameters are:
1122
1130
  # * a Query object
@@ -1276,9 +1284,10 @@ module Spider; module Model
1276
1284
  # Returns a new instance for given element name.
1277
1285
  def instantiate_element(name)
1278
1286
  element = self.class.elements[name]
1279
- if (element.model?)
1280
- if (element.multiple?)
1287
+ if element.model?
1288
+ if element.multiple?
1281
1289
  val = QuerySet.static(element.model)
1290
+ val.modified = true
1282
1291
  else
1283
1292
  val = element.type.new
1284
1293
  val.autoload = autoload?
@@ -1292,8 +1301,11 @@ module Spider; module Model
1292
1301
 
1293
1302
  # Prepares an object that is being set as a child.
1294
1303
  def prepare_child(name, obj)
1295
- return obj if obj.nil?
1296
1304
  element = self.class.elements[name]
1305
+ if obj.nil?
1306
+ obj = QuerySet.static(element.model) if element.multiple?
1307
+ return obj
1308
+ end
1297
1309
  if (element.model?)
1298
1310
  # convert between junction and real type if needed
1299
1311
  if element.attributes[:junction]
@@ -1763,8 +1775,11 @@ module Spider; module Model
1763
1775
  return false unless integrated = get_no_load(element.integrated_from)
1764
1776
  return integrated.element_modified?(element.integrated_from_element)
1765
1777
  end
1766
- if element_has_value?(element) && (val = get(element)).respond_to?(:modified?)
1767
- return val.modified?
1778
+ if element_has_value?(element)
1779
+ val = get(element)
1780
+ # don't call modified? on QuerySets, since we don't need to query sub objects (this could lead to infinite loops)
1781
+ return val.modified if val.is_a?(QuerySet)
1782
+ return val.modified? if val.respond_to?(:modified?)
1768
1783
  end
1769
1784
  return false
1770
1785
  end
@@ -1782,7 +1797,9 @@ module Spider; module Model
1782
1797
  self.class.elements_array.select{ |el|
1783
1798
  element_has_value?(el) && (el.type.is_a?(Spider::DataType) || el.multiple?)
1784
1799
  }.each do |el|
1785
- return true if get(el).modified?
1800
+ obj = get(el)
1801
+ check = obj.is_a?(QuerySet) ? obj.modified : obj.modified?
1802
+ return true if check
1786
1803
  end
1787
1804
  return false
1788
1805
  end
@@ -1798,6 +1815,12 @@ module Spider; module Model
1798
1815
  request.each do |key, val| # FIXME: go deep
1799
1816
  key = key.name if key.is_a?(Element)
1800
1817
  @_modified_elements[key] = true
1818
+ el = self.class.elements[key.to_sym]
1819
+ next unless el
1820
+ if el.integrated? && sub = self.get(el.integrated_from)
1821
+ sub.set_modified(el.integrated_from_element)
1822
+ end
1823
+
1801
1824
  end
1802
1825
  end
1803
1826
 
@@ -391,8 +391,15 @@ module Spider; module Model
391
391
 
392
392
  module ConditionMixin # :nodoc:
393
393
 
394
+ def __el(meth)
395
+ __create_condition_element(meth)
396
+ end
394
397
 
395
398
  def method_missing(meth, *arguments)
399
+ __create_condition_element(meth)
400
+ end
401
+
402
+ def __create_condition_element(meth)
396
403
  if (meth == :q)
397
404
  return ConditionElementCreator.new
398
405
  end
@@ -7,4 +7,6 @@ module Spider; module DataTypes
7
7
  end
8
8
 
9
9
 
10
- end; end
10
+ end; end
11
+
12
+ Spider::Text = Spider::DataTypes::Text
@@ -890,17 +890,27 @@ module Spider; module Model; module Mappers
890
890
  prev_task = nil
891
891
  set.each do |set_obj|
892
892
  sub_task = MapperTask.new(set_obj, :save)
893
- set_obj.set_modified(element.reverse) if element.reverse
894
893
  if set_obj.class.attributes[:sub_model] && delete_ass
895
894
  set_obj.class.primary_keys.each{ |pk| set_obj.set(pk, nil) }
896
895
  end
897
896
  if prev_task
898
897
  deps << [sub_task, prev_task]
899
- elsif delete_ass
900
- deps << [sub_task, delete_ass]
901
898
  else
902
899
  deps << [sub_task, task]
903
900
  end
901
+ if delete_ass
902
+ del_dep = set_obj
903
+ if element.reverse
904
+ set_obj.set_modified(element.reverse)
905
+ el = set_obj.class.elements[element.reverse]
906
+ # ensure the real owner is added as a dependency
907
+ while el.integrated?
908
+ del_dep = set_obj.get(el.integrated_from)
909
+ el = del_dep.class.elements[el.integrated_from_element]
910
+ end
911
+ end
912
+ deps << [MapperTask.new(del_dep, :save), delete_ass]
913
+ end
904
914
  prev_task = sub_task
905
915
  end
906
916
  else
@@ -967,6 +977,10 @@ module Spider; module Model; module Mappers
967
977
  @storage.column_type(type, attributes)
968
978
  end
969
979
 
980
+ def storage_column_attributes(type, attributes)
981
+ @storage.column_attributes(type, attributes)
982
+ end
983
+
970
984
  def base_type(type)
971
985
  if type <= Spider::DataTypes::PK
972
986
  Fixnum
@@ -998,7 +1012,7 @@ module Spider; module Model; module Mappers
998
1012
  storage_type = base_type(element.type)
999
1013
  db_attributes = column.attributes if column
1000
1014
  if (!db_attributes || db_attributes.empty?)
1001
- db_attributes = @storage.column_attributes(storage_type, element.attributes)
1015
+ db_attributes = storage_column_attributes(storage_type, element.attributes)
1002
1016
  db_attributes.merge(element.attributes[:db]) if (element.attributes[:db])
1003
1017
  if (element.attributes[:autoincrement] && !db_attributes[:autoincrement])
1004
1018
  schema.set_sequence(element.name, @storage.sequence_name("#{schema.table}_#{element.name}"))
@@ -1151,7 +1165,7 @@ module Spider; module Model; module Mappers
1151
1165
 
1152
1166
  # Returns a create table structure description.
1153
1167
  def create_table(table_name, schema, attributes) # :nodoc:
1154
- fields = schema[:fields_order].map do |f|
1168
+ fields = schema[:fields_order].uniq.map do |f|
1155
1169
  details = schema[:columns][f.name]
1156
1170
  {
1157
1171
  :name => f.name,
@@ -603,7 +603,7 @@ module Spider; module Model
603
603
  query.request.keys.each do |k, v|
604
604
  set.element_loaded(k) if have_references?(k)
605
605
  end
606
- set.each do |obj|
606
+ set.each_current do |obj|
607
607
  next if merged[obj.object_id]
608
608
  query.request.keys.each do |element_name|
609
609
  el = @model.elements[element_name]
@@ -19,6 +19,7 @@ module Spider; module Model
19
19
  q = Query.new(c)
20
20
  q.order_by(left_el)
21
21
  res = element.model.find(q)
22
+ return [] unless res
22
23
  right_stack = []
23
24
  res.each do |obj|
24
25
  if (right_stack.length > 0)
@@ -89,7 +90,7 @@ module Spider; module Model
89
90
  end
90
91
 
91
92
  define_method("#{name}_all") do
92
- qs = QuerySet.new(self)
93
+ qs = QuerySet.static(self)
93
94
  self.send("#{name}_roots").each do |root|
94
95
  qs += root.tree_all(name)
95
96
  end
@@ -358,27 +358,19 @@ module Spider; module Model
358
358
 
359
359
  # Iterates on objects, loading when needed.
360
360
  def each
361
- tmp = []
362
- prev_parents = []
363
- self.each_index do |i|
361
+ self.each_rolling_index do |i|
364
362
  obj = @objects[i]
365
363
  prev_parent = obj._parent
366
364
  prev_parent_element = obj._parent_element
367
365
  obj.set_parent(self, nil)
368
- tmp << obj
369
- prev_parents << [prev_parent, prev_parent_element]
370
- end
371
- tmp.each do |obj|
372
366
  yield obj
373
- end
374
- tmp.each_index do |i|
375
- prev_parent, prev_parent_element = prev_parents[i]
376
- tmp[i].set_parent(prev_parent, prev_parent_element)
367
+ obj.set_parent(prev_parent, prev_parent_element)
377
368
  end
378
369
  end
379
370
 
380
- # Iterates yielding objects index. Will load when needed.
381
- def each_index
371
+ # Iterates yielding the internal objects index. Will load when needed. If a window is
372
+ # used, the index will roll back to 0 on every window.
373
+ def each_rolling_index
382
374
  @window_current_start = nil if (@fetch_window)
383
375
  while (!@fetch_window || has_more?)
384
376
  load_next unless !autoload? || (!@fetch_window && @loaded)
@@ -389,6 +381,14 @@ module Spider; module Model
389
381
  end
390
382
  end
391
383
 
384
+ # Iterates yielding the queryset index. Will load when needed.
385
+ def each_index
386
+ self.each_rolling_index do |i|
387
+ i += @window_current_start-1 if @window_current_start
388
+ yield i
389
+ end
390
+ end
391
+
392
392
  # Iterates on indexes without loading.
393
393
  def each_current_index
394
394
  @objects.each_index do |i|
@@ -810,6 +810,7 @@ module Spider; module Model
810
810
  # Performs a deep copy
811
811
  def clone
812
812
  c = self.class.new(self.model, self.query.clone)
813
+ c.autoload = self.autoload?
813
814
  c_objects = c.instance_variable_get(:@objects)
814
815
  @objects.each do |o|
815
816
  c_objects << o.clone
@@ -49,7 +49,7 @@ module Spider; module Model; module Storage; module Db
49
49
  251 => 'LONG_BLOB',
50
50
  252 => 'BLOB',
51
51
  253 => 'VARCHAR',
52
- 254 => 'STRING',
52
+ 254 => 'CHAR',
53
53
  255 => 'GEOMETRY'
54
54
  }
55
55
  @field_flags = {
@@ -343,7 +343,7 @@ module Spider; module Model; module Storage; module Db
343
343
  fields.each do |f|
344
344
  type = self.class.field_types[f.type]
345
345
  length = f.length;
346
- length /= 3 if (type == 'VARCHAR')
346
+ length /= 3 if ['CHAR', 'VARCHAR'].include?(type)
347
347
  scale = nil
348
348
  precision = f.decimals
349
349
  # FIXME
@@ -446,6 +446,11 @@ module Spider; module Model; module Storage; module Db
446
446
  end
447
447
  end
448
448
 
449
+ def schema_field_int_equal?(current, field)
450
+ # FIXME
451
+ return true
452
+ end
453
+
449
454
  def schema_field_text_equal?(current, field)
450
455
  # FIXME
451
456
  return true
@@ -98,8 +98,9 @@ module Spider; module Model; module Storage; module Db
98
98
  # Sets the column name for an element.
99
99
  def set_column(element_name, field)
100
100
  field = Field.new(@table, field[:name], field[:type], field[:attributes] || {}) if field.is_a?(Hash)
101
+ had_column = @columns[element_name]
101
102
  @columns[element_name] = field
102
- @order << field
103
+ @order << field unless had_column
103
104
  end
104
105
 
105
106
  # Sets a foreign key to the primary key of an element.
@@ -115,8 +116,9 @@ module Spider; module Model; module Storage; module Db
115
116
  end
116
117
  end
117
118
  @foreign_keys[element_name] ||= {}
119
+ had_fk = @foreign_keys[element_name][element_key]
118
120
  @foreign_keys[element_name][element_key] = field
119
- @order << field
121
+ @order << field unless had_fk
120
122
  end
121
123
 
122
124
  def set_foreign_key_constraint(name, table, keys, options={})
@@ -341,11 +341,11 @@ module Spider; module Model; module Storage; module Db
341
341
  comp = comp == '=' ? "IS" : "IS NOT"
342
342
  sql = "#{key} #{comp} NULL"
343
343
  else
344
- if (comp.to_s.downcase == 'between')
345
- if (bound_vars)
346
- val0, val1 = value
344
+ if comp.to_s.downcase == 'between'
345
+ if bound_vars
346
+ val0 = val1 = '?'
347
347
  else
348
- val0 = val1 = '?'
348
+ val0, val1 = value
349
349
  end
350
350
  sql = "#{key} #{comp} #{val0} AND #{val1}"
351
351
  else
@@ -142,8 +142,10 @@ module Spider; module Model
142
142
  @new_objects << obj unless curr
143
143
  if action == :save
144
144
  children = obj.mapper.children_for_unit_of_work(obj, action)
145
+ prms = params.clone
146
+ prms.delete(:force)
145
147
  children.each do |child|
146
- add(child, action, params)
148
+ add(child, action, prms)
147
149
  end
148
150
  end
149
151
  end
@@ -3,7 +3,7 @@ require 'spiderfw/templates/template_blocks'
3
3
  module Spider; module TemplateBlocks
4
4
 
5
5
  class HTML < Block
6
- HTML_NO_CLOSE = ['br', 'img']
6
+ HTML_NO_CLOSE = ['br', 'img', 'input']
7
7
 
8
8
  def compile(options={})
9
9
  c = ""
@@ -41,7 +41,7 @@ module Spider; module TemplateBlocks
41
41
  cl += ' ' unless cl.empty?
42
42
  cl += '{ @widget[:css_classes] }'
43
43
  end
44
- @el.set_attribute('class', cl)
44
+ @el.set_attribute('class', cl) unless cl.blank?
45
45
  end
46
46
  start = "$out << '<"+@el.name
47
47
  @el.attributes.to_hash.each do |key, val|
@@ -0,0 +1,25 @@
1
+ require 'spiderfw/templates/template_blocks'
2
+
3
+ module Spider; module TemplateBlocks
4
+
5
+ class Lambda < Block
6
+
7
+ def compile(options={})
8
+ init = ""
9
+ lambda_name = @el.attributes['sp:lambda']
10
+ @el.remove_attribute('sp:lambda')
11
+ c = "#{lambda_name} = lambda do\n"
12
+ content = Spider::TemplateBlocks.parse_element(@el, @allowed_blocks, @template).compile(options)
13
+ content.run_code.each_line do |line|
14
+ c += ' '+line
15
+ end
16
+ c += "end\n"
17
+ c += "#{lambda_name}.call"
18
+ return CompiledBlock.new(init, c)
19
+ end
20
+
21
+
22
+ end
23
+
24
+
25
+ end; end
@@ -0,0 +1,41 @@
1
+ require 'spiderfw/templates/template_blocks'
2
+
3
+ module Spider; module TemplateBlocks
4
+
5
+ class Recurse < Block
6
+
7
+ def compile(options={})
8
+ init = ""
9
+ c = ""
10
+ lambda_name = @el.attributes['lambda']
11
+ vars_attr = @el.attributes['vars']
12
+ vars = nil
13
+ unless vars_attr.blank?
14
+ vars = {}
15
+ var_pairs = vars_attr.split(/\s*,\s*/)
16
+ var_pairs.each do |pair|
17
+ from, to = pair.split(/\s*=>\s*/)
18
+ vars[from] = to
19
+ end
20
+ c += "___prev_vars = {}\n"
21
+ vars.each do |from, to|
22
+ c += "___prev_vars[:#{from}] = #{from}\n"
23
+ end
24
+ vars.each do |from, to|
25
+ c += "#{from} = #{to}\n"
26
+ end
27
+ end
28
+ c += "#{lambda_name}.call\n"
29
+ if vars
30
+ vars.each do |from, to|
31
+ c += "#{from} = ___prev_vars[:#{from}]\n"
32
+ end
33
+ end
34
+ return CompiledBlock.new(init, c)
35
+ end
36
+
37
+
38
+ end
39
+
40
+
41
+ end; end
@@ -51,14 +51,13 @@ module Spider; module TemplateBlocks
51
51
 
52
52
  template = klass.load_template(template_attr || klass.default_template)
53
53
  template.asset_profiles = asset_profiles if asset_profiles
54
- if (overrides.length > 0)
55
- #template_name = klass.find_template(template_attr)
54
+ # @template is the containing template, template is the widget's template
55
+ if overrides.length > 0
56
56
  template.add_overrides overrides
57
57
  @template.add_subtemplate(id, template, klass)
58
58
  else
59
59
  @template.add_widget_template(template, klass)
60
60
  end
61
- # end
62
61
 
63
62
  init = ""
64
63
  t_param = 'nil'
@@ -249,6 +249,7 @@ module Spider
249
249
  app_relative_path = 'spider'
250
250
  app_path = Spider::SpiderController.pub_path
251
251
  end
252
+ app_pathname = Pathname.new(app_path)
252
253
 
253
254
  pub_app = "#{pub_dest}/#{app_relative_path}"
254
255
  FileUtils.mkdir_p(pub_app)
@@ -263,14 +264,20 @@ module Spider
263
264
  url = url.first
264
265
  next if url =~ %r{^/} || url =~ %r{^[a-z]+://}
265
266
  path = ""
266
- url_dest = File.expand_path(File.join(pub_app, url))
267
267
  url_src = File.expand_path(File.join(src_dir, url))
268
- unless url_src.index(app_path) == 0
268
+ src_pathname = Pathname.new(url_src)
269
+ src_rel = nil
270
+ begin
271
+ src_rel = src_pathname.relative_path_from(app_pathname)
272
+ rescue ArgumentError
269
273
  raise "Can't combine CSS if paths go outside app: #{url} in #{path}"
270
274
  end
275
+
276
+ url_dest = File.join(pub_app, src_rel.to_s)
277
+
271
278
  FileUtils.mkdir_p(File.dirname(url_dest))
272
279
  cachebuster = Spider.conf.get('css.cachebuster')
273
- new_url = "#{app_relative_path}/#{url}"
280
+ new_url = "#{app_relative_path}/#{src_rel}"
274
281
  if File.exist?(url_src)
275
282
  mtime = File.mtime(url_src).to_i
276
283
  if cachebuster && File.exist?(url_dest) && mtime > File.mtime(url_dest).to_i
@@ -341,6 +348,16 @@ module Spider
341
348
  ass = {:src => ass} if ass.is_a?(String)
342
349
  $out << "<script type=\"text/javascript\" src=\"#{ass[:src]}\"></script>\n"
343
350
  end
351
+ unless @not_first_js
352
+ $out << "<script type=\"text/javascript\">"
353
+ @not_first_js = true
354
+ $out << "window.SPIDER_BASE_URL = '#{self[:base_url]}'; "
355
+ $out << "if (window.Spider) Spider.baseUrl = window.SPIDER_BASE_URL;\n"
356
+ unless self[:js_translations].blank?
357
+ $out << self[:js_translations]+"\n"
358
+ end
359
+ $out << "</script>"
360
+ end
344
361
  end
345
362
  if types.include?(:css)
346
363
  self.assets[:css].each do |ass|