lipsiadmin 2.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (467) hide show
  1. data/CHANGELOG +90 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README +60 -0
  4. data/Rakefile +90 -0
  5. data/init.rb +1 -0
  6. data/lib/access_control/authentication.rb +105 -0
  7. data/lib/access_control/base.rb +227 -0
  8. data/lib/controller/ext.rb +168 -0
  9. data/lib/controller/lipsiadmin_controller.rb +18 -0
  10. data/lib/controller/pdf_builder.rb +67 -0
  11. data/lib/controller/rescue.rb +72 -0
  12. data/lib/controller/responds_to_parent.rb +56 -0
  13. data/lib/data_base/attachment.rb +351 -0
  14. data/lib/data_base/attachment/attach.rb +515 -0
  15. data/lib/data_base/attachment/geometry.rb +117 -0
  16. data/lib/data_base/attachment/iostream.rb +62 -0
  17. data/lib/data_base/attachment/processor.rb +49 -0
  18. data/lib/data_base/attachment/storage.rb +223 -0
  19. data/lib/data_base/attachment/thumbnail.rb +72 -0
  20. data/lib/data_base/attachment/upfile.rb +45 -0
  21. data/lib/data_base/attachment_table.rb +142 -0
  22. data/lib/data_base/translate_attributes.rb +30 -0
  23. data/lib/data_base/utility_scopes.rb +40 -0
  24. data/lib/data_base/without_table.rb +62 -0
  25. data/lib/generator.rb +114 -0
  26. data/lib/lipsiadmin.rb +77 -0
  27. data/lib/lipsiadmin_tasks.rb +3 -0
  28. data/lib/locale/en.yml +16 -0
  29. data/lib/locale/it.yml +16 -0
  30. data/lib/mailer/exception/exception.html.erb +11 -0
  31. data/lib/mailer/exception_notifier.rb +46 -0
  32. data/lib/mailer/pdf_builder.rb +66 -0
  33. data/lib/utils/html_entities.rb +63 -0
  34. data/lib/utils/literal.rb +20 -0
  35. data/lib/version.rb +9 -0
  36. data/lib/view/helpers/active_record_helper.rb +11 -0
  37. data/lib/view/helpers/backend_helper.rb +132 -0
  38. data/lib/view/helpers/ext/column_model.rb +73 -0
  39. data/lib/view/helpers/ext/component.rb +163 -0
  40. data/lib/view/helpers/ext/configuration.rb +36 -0
  41. data/lib/view/helpers/ext/grid.rb +281 -0
  42. data/lib/view/helpers/ext/store.rb +103 -0
  43. data/lib/view/helpers/ext/templates/grid_functions.js.erb +51 -0
  44. data/lib/view/helpers/ext/tool_bar.rb +40 -0
  45. data/lib/view/helpers/ext_helper.rb +150 -0
  46. data/lib/view/helpers/view_helper.rb +222 -0
  47. data/lipsiadmin_generators/attachment/REMEMBER +21 -0
  48. data/lipsiadmin_generators/attachment/attachment_generator.rb +27 -0
  49. data/lipsiadmin_generators/attachment/templates/migration.rb +14 -0
  50. data/lipsiadmin_generators/attachment/templates/model.rb +4 -0
  51. data/lipsiadmin_generators/backend/REMEMBER +18 -0
  52. data/lipsiadmin_generators/backend/backend_generator.rb +58 -0
  53. data/lipsiadmin_generators/backend/templates/config/config.yml +14 -0
  54. data/lipsiadmin_generators/backend/templates/config/initializers/config.rb +7 -0
  55. data/lipsiadmin_generators/backend/templates/config/initializers/emails.rb +2 -0
  56. data/lipsiadmin_generators/backend/templates/config/initializers/exception_notifier.rb +7 -0
  57. data/lipsiadmin_generators/backend/templates/config/locales/backend/en.yml +204 -0
  58. data/lipsiadmin_generators/backend/templates/config/locales/backend/it.yml +203 -0
  59. data/lipsiadmin_generators/backend/templates/config/locales/frontend/en.yml +5 -0
  60. data/lipsiadmin_generators/backend/templates/config/locales/frontend/it.yml +5 -0
  61. data/lipsiadmin_generators/backend/templates/config/locales/models/en.yml +31 -0
  62. data/lipsiadmin_generators/backend/templates/config/locales/models/it.yml +23 -0
  63. data/lipsiadmin_generators/backend/templates/config/locales/rails/en.yml +148 -0
  64. data/lipsiadmin_generators/backend/templates/config/locales/rails/it.yml +109 -0
  65. data/lipsiadmin_generators/backend/templates/controllers/backend/accounts_controller.rb +53 -0
  66. data/lipsiadmin_generators/backend/templates/controllers/backend/base_controller.rb +8 -0
  67. data/lipsiadmin_generators/backend/templates/controllers/backend/sessions_controller.rb +21 -0
  68. data/lipsiadmin_generators/backend/templates/controllers/backend_controller.rb +2 -0
  69. data/lipsiadmin_generators/backend/templates/controllers/frontend_controller.rb +4 -0
  70. data/lipsiadmin_generators/backend/templates/controllers/javascripts_controller.rb +17 -0
  71. data/lipsiadmin_generators/backend/templates/exceptions/template.html.haml +5 -0
  72. data/lipsiadmin_generators/backend/templates/helpers/backend_helper.rb +2 -0
  73. data/lipsiadmin_generators/backend/templates/helpers/frontend_helper.rb +2 -0
  74. data/lipsiadmin_generators/backend/templates/images/backend/back.gif +0 -0
  75. data/lipsiadmin_generators/backend/templates/images/backend/background.png +0 -0
  76. data/lipsiadmin_generators/backend/templates/images/backend/bg-content.png +0 -0
  77. data/lipsiadmin_generators/backend/templates/images/backend/bg-hd-slate.png +0 -0
  78. data/lipsiadmin_generators/backend/templates/images/backend/bg-hd.png +0 -0
  79. data/lipsiadmin_generators/backend/templates/images/backend/bg-intro.png +0 -0
  80. data/lipsiadmin_generators/backend/templates/images/backend/bg-login.png +0 -0
  81. data/lipsiadmin_generators/backend/templates/images/backend/bg-menu-slate.png +0 -0
  82. data/lipsiadmin_generators/backend/templates/images/backend/bg-menu.png +0 -0
  83. data/lipsiadmin_generators/backend/templates/images/backend/bg.png +0 -0
  84. data/lipsiadmin_generators/backend/templates/images/backend/btn-login.png +0 -0
  85. data/lipsiadmin_generators/backend/templates/images/backend/delete.gif +0 -0
  86. data/lipsiadmin_generators/backend/templates/images/backend/download.gif +0 -0
  87. data/lipsiadmin_generators/backend/templates/images/backend/duplicate.gif +0 -0
  88. data/lipsiadmin_generators/backend/templates/images/backend/edit.gif +0 -0
  89. data/lipsiadmin_generators/backend/templates/images/backend/hd-bg-slate.gif +0 -0
  90. data/lipsiadmin_generators/backend/templates/images/backend/hd-bg.gif +0 -0
  91. data/lipsiadmin_generators/backend/templates/images/backend/it.gif +0 -0
  92. data/lipsiadmin_generators/backend/templates/images/backend/loader.gif +0 -0
  93. data/lipsiadmin_generators/backend/templates/images/backend/logo-loader.png +0 -0
  94. data/lipsiadmin_generators/backend/templates/images/backend/logo-small.png +0 -0
  95. data/lipsiadmin_generators/backend/templates/images/backend/new.gif +0 -0
  96. data/lipsiadmin_generators/backend/templates/images/backend/no-image.png +0 -0
  97. data/lipsiadmin_generators/backend/templates/images/backend/preview.gif +0 -0
  98. data/lipsiadmin_generators/backend/templates/images/backend/print.gif +0 -0
  99. data/lipsiadmin_generators/backend/templates/images/backend/save.gif +0 -0
  100. data/lipsiadmin_generators/backend/templates/images/backend/support.gif +0 -0
  101. data/lipsiadmin_generators/backend/templates/images/backend/us.gif +0 -0
  102. data/lipsiadmin_generators/backend/templates/images/ext/default/box/corners-blue.gif +0 -0
  103. data/lipsiadmin_generators/backend/templates/images/ext/default/box/corners.gif +0 -0
  104. data/lipsiadmin_generators/backend/templates/images/ext/default/box/l-blue.gif +0 -0
  105. data/lipsiadmin_generators/backend/templates/images/ext/default/box/l.gif +0 -0
  106. data/lipsiadmin_generators/backend/templates/images/ext/default/box/r-blue.gif +0 -0
  107. data/lipsiadmin_generators/backend/templates/images/ext/default/box/r.gif +0 -0
  108. data/lipsiadmin_generators/backend/templates/images/ext/default/box/tb-blue.gif +0 -0
  109. data/lipsiadmin_generators/backend/templates/images/ext/default/box/tb-slate.gif +0 -0
  110. data/lipsiadmin_generators/backend/templates/images/ext/default/box/tb.gif +0 -0
  111. data/lipsiadmin_generators/backend/templates/images/ext/default/button/btn-arrow.gif +0 -0
  112. data/lipsiadmin_generators/backend/templates/images/ext/default/button/btn-sprite.gif +0 -0
  113. data/lipsiadmin_generators/backend/templates/images/ext/default/dd/drop-add.gif +0 -0
  114. data/lipsiadmin_generators/backend/templates/images/ext/default/dd/drop-no.gif +0 -0
  115. data/lipsiadmin_generators/backend/templates/images/ext/default/dd/drop-yes.gif +0 -0
  116. data/lipsiadmin_generators/backend/templates/images/ext/default/editor/tb-sprite.gif +0 -0
  117. data/lipsiadmin_generators/backend/templates/images/ext/default/form/clear-trigger.gif +0 -0
  118. data/lipsiadmin_generators/backend/templates/images/ext/default/form/clear-trigger.psd +0 -0
  119. data/lipsiadmin_generators/backend/templates/images/ext/default/form/date-trigger.gif +0 -0
  120. data/lipsiadmin_generators/backend/templates/images/ext/default/form/date-trigger.psd +0 -0
  121. data/lipsiadmin_generators/backend/templates/images/ext/default/form/error-tip-corners.gif +0 -0
  122. data/lipsiadmin_generators/backend/templates/images/ext/default/form/exclamation.gif +0 -0
  123. data/lipsiadmin_generators/backend/templates/images/ext/default/form/search-trigger.gif +0 -0
  124. data/lipsiadmin_generators/backend/templates/images/ext/default/form/search-trigger.psd +0 -0
  125. data/lipsiadmin_generators/backend/templates/images/ext/default/form/text-bg.gif +0 -0
  126. data/lipsiadmin_generators/backend/templates/images/ext/default/form/trigger-tpl.gif +0 -0
  127. data/lipsiadmin_generators/backend/templates/images/ext/default/form/trigger.gif +0 -0
  128. data/lipsiadmin_generators/backend/templates/images/ext/default/form/trigger.psd +0 -0
  129. data/lipsiadmin_generators/backend/templates/images/ext/default/gradient-bg.gif +0 -0
  130. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/Thumbs.db +0 -0
  131. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/arrow-left-white.gif +0 -0
  132. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/arrow-right-white.gif +0 -0
  133. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/col-move-bottom.gif +0 -0
  134. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/col-move-top.gif +0 -0
  135. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/columns.gif +0 -0
  136. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/dirty.gif +0 -0
  137. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/done.gif +0 -0
  138. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/drop-no.gif +0 -0
  139. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/drop-yes.gif +0 -0
  140. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/footer-bg.gif +0 -0
  141. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/grid-blue-hd.gif +0 -0
  142. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/grid-blue-split.gif +0 -0
  143. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/grid-hrow.gif +0 -0
  144. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/grid-loading.gif +0 -0
  145. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/grid-split.gif +0 -0
  146. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/grid-vista-hd.gif +0 -0
  147. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/grid3-hd-btn.gif +0 -0
  148. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/grid3-hrow-over.gif +0 -0
  149. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/grid3-hrow.gif +0 -0
  150. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/grid3-special-col-bg.gif +0 -0
  151. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/grid3-special-col-sel-bg.gif +0 -0
  152. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/group-by.gif +0 -0
  153. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/group-expand-sprite.gif +0 -0
  154. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/hd-pop.gif +0 -0
  155. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/hmenu-asc.gif +0 -0
  156. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/hmenu-desc.gif +0 -0
  157. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/hmenu-lock.gif +0 -0
  158. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/hmenu-lock.png +0 -0
  159. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/hmenu-unlock.gif +0 -0
  160. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/hmenu-unlock.png +0 -0
  161. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/invalid_line.gif +0 -0
  162. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/loading.gif +0 -0
  163. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/mso-hd.gif +0 -0
  164. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/nowait.gif +0 -0
  165. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/page-first-disabled.gif +0 -0
  166. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/page-first.gif +0 -0
  167. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/page-last-disabled.gif +0 -0
  168. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/page-last.gif +0 -0
  169. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/page-next-disabled.gif +0 -0
  170. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/page-next.gif +0 -0
  171. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/page-prev-disabled.gif +0 -0
  172. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/page-prev.gif +0 -0
  173. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/pick-button.gif +0 -0
  174. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/refresh.gif +0 -0
  175. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/row-check-sprite.gif +0 -0
  176. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/row-expand-sprite.gif +0 -0
  177. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/row-over.gif +0 -0
  178. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/row-sel.gif +0 -0
  179. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/sort_asc.gif +0 -0
  180. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/sort_desc.gif +0 -0
  181. data/lipsiadmin_generators/backend/templates/images/ext/default/grid/wait.gif +0 -0
  182. data/lipsiadmin_generators/backend/templates/images/ext/default/layout/collapse.gif +0 -0
  183. data/lipsiadmin_generators/backend/templates/images/ext/default/layout/expand.gif +0 -0
  184. data/lipsiadmin_generators/backend/templates/images/ext/default/layout/gradient-bg.gif +0 -0
  185. data/lipsiadmin_generators/backend/templates/images/ext/default/layout/mini-bottom.gif +0 -0
  186. data/lipsiadmin_generators/backend/templates/images/ext/default/layout/mini-left.gif +0 -0
  187. data/lipsiadmin_generators/backend/templates/images/ext/default/layout/mini-right.gif +0 -0
  188. data/lipsiadmin_generators/backend/templates/images/ext/default/layout/mini-top.gif +0 -0
  189. data/lipsiadmin_generators/backend/templates/images/ext/default/layout/ns-collapse.gif +0 -0
  190. data/lipsiadmin_generators/backend/templates/images/ext/default/layout/ns-expand.gif +0 -0
  191. data/lipsiadmin_generators/backend/templates/images/ext/default/layout/panel-close.gif +0 -0
  192. data/lipsiadmin_generators/backend/templates/images/ext/default/layout/panel-title-bg.gif +0 -0
  193. data/lipsiadmin_generators/backend/templates/images/ext/default/layout/panel-title-light-bg.gif +0 -0
  194. data/lipsiadmin_generators/backend/templates/images/ext/default/layout/stick.gif +0 -0
  195. data/lipsiadmin_generators/backend/templates/images/ext/default/layout/stuck.gif +0 -0
  196. data/lipsiadmin_generators/backend/templates/images/ext/default/layout/tab-close-on.gif +0 -0
  197. data/lipsiadmin_generators/backend/templates/images/ext/default/layout/tab-close.gif +0 -0
  198. data/lipsiadmin_generators/backend/templates/images/ext/default/menu/checked.gif +0 -0
  199. data/lipsiadmin_generators/backend/templates/images/ext/default/menu/group-checked.gif +0 -0
  200. data/lipsiadmin_generators/backend/templates/images/ext/default/menu/item-over.gif +0 -0
  201. data/lipsiadmin_generators/backend/templates/images/ext/default/menu/menu-parent.gif +0 -0
  202. data/lipsiadmin_generators/backend/templates/images/ext/default/menu/menu.gif +0 -0
  203. data/lipsiadmin_generators/backend/templates/images/ext/default/menu/unchecked.gif +0 -0
  204. data/lipsiadmin_generators/backend/templates/images/ext/default/panel/corners-sprite.gif +0 -0
  205. data/lipsiadmin_generators/backend/templates/images/ext/default/panel/left-right.gif +0 -0
  206. data/lipsiadmin_generators/backend/templates/images/ext/default/panel/light-hd.gif +0 -0
  207. data/lipsiadmin_generators/backend/templates/images/ext/default/panel/tool-sprite-tpl.gif +0 -0
  208. data/lipsiadmin_generators/backend/templates/images/ext/default/panel/tool-sprites.gif +0 -0
  209. data/lipsiadmin_generators/backend/templates/images/ext/default/panel/tools-sprites-trans.gif +0 -0
  210. data/lipsiadmin_generators/backend/templates/images/ext/default/panel/top-bottom.gif +0 -0
  211. data/lipsiadmin_generators/backend/templates/images/ext/default/panel/top-bottom.png +0 -0
  212. data/lipsiadmin_generators/backend/templates/images/ext/default/panel/white-corners-sprite.gif +0 -0
  213. data/lipsiadmin_generators/backend/templates/images/ext/default/panel/white-left-right.gif +0 -0
  214. data/lipsiadmin_generators/backend/templates/images/ext/default/panel/white-top-bottom.gif +0 -0
  215. data/lipsiadmin_generators/backend/templates/images/ext/default/progress/progress-bg.gif +0 -0
  216. data/lipsiadmin_generators/backend/templates/images/ext/default/qtip/bg.gif +0 -0
  217. data/lipsiadmin_generators/backend/templates/images/ext/default/qtip/close.gif +0 -0
  218. data/lipsiadmin_generators/backend/templates/images/ext/default/qtip/tip-sprite.gif +0 -0
  219. data/lipsiadmin_generators/backend/templates/images/ext/default/s.gif +0 -0
  220. data/lipsiadmin_generators/backend/templates/images/ext/default/shadow-c.png +0 -0
  221. data/lipsiadmin_generators/backend/templates/images/ext/default/shadow-lr.png +0 -0
  222. data/lipsiadmin_generators/backend/templates/images/ext/default/shadow.png +0 -0
  223. data/lipsiadmin_generators/backend/templates/images/ext/default/shared/blue-loading.gif +0 -0
  224. data/lipsiadmin_generators/backend/templates/images/ext/default/shared/calendar.gif +0 -0
  225. data/lipsiadmin_generators/backend/templates/images/ext/default/shared/glass-bg.gif +0 -0
  226. data/lipsiadmin_generators/backend/templates/images/ext/default/shared/hd-sprite.gif +0 -0
  227. data/lipsiadmin_generators/backend/templates/images/ext/default/shared/large-loading.gif +0 -0
  228. data/lipsiadmin_generators/backend/templates/images/ext/default/shared/left-btn.gif +0 -0
  229. data/lipsiadmin_generators/backend/templates/images/ext/default/shared/loading-balls.gif +0 -0
  230. data/lipsiadmin_generators/backend/templates/images/ext/default/shared/right-btn.gif +0 -0
  231. data/lipsiadmin_generators/backend/templates/images/ext/default/shared/warning.gif +0 -0
  232. data/lipsiadmin_generators/backend/templates/images/ext/default/sizer/e-handle-dark.gif +0 -0
  233. data/lipsiadmin_generators/backend/templates/images/ext/default/sizer/e-handle.gif +0 -0
  234. data/lipsiadmin_generators/backend/templates/images/ext/default/sizer/ne-handle-dark.gif +0 -0
  235. data/lipsiadmin_generators/backend/templates/images/ext/default/sizer/ne-handle.gif +0 -0
  236. data/lipsiadmin_generators/backend/templates/images/ext/default/sizer/nw-handle-dark.gif +0 -0
  237. data/lipsiadmin_generators/backend/templates/images/ext/default/sizer/nw-handle.gif +0 -0
  238. data/lipsiadmin_generators/backend/templates/images/ext/default/sizer/s-handle-dark.gif +0 -0
  239. data/lipsiadmin_generators/backend/templates/images/ext/default/sizer/s-handle.gif +0 -0
  240. data/lipsiadmin_generators/backend/templates/images/ext/default/sizer/se-handle-dark.gif +0 -0
  241. data/lipsiadmin_generators/backend/templates/images/ext/default/sizer/se-handle.gif +0 -0
  242. data/lipsiadmin_generators/backend/templates/images/ext/default/sizer/square.gif +0 -0
  243. data/lipsiadmin_generators/backend/templates/images/ext/default/sizer/sw-handle-dark.gif +0 -0
  244. data/lipsiadmin_generators/backend/templates/images/ext/default/sizer/sw-handle.gif +0 -0
  245. data/lipsiadmin_generators/backend/templates/images/ext/default/slider/slider-bg.png +0 -0
  246. data/lipsiadmin_generators/backend/templates/images/ext/default/slider/slider-thumb.png +0 -0
  247. data/lipsiadmin_generators/backend/templates/images/ext/default/slider/slider-v-bg.png +0 -0
  248. data/lipsiadmin_generators/backend/templates/images/ext/default/slider/slider-v-thumb.png +0 -0
  249. data/lipsiadmin_generators/backend/templates/images/ext/default/tabs/scroll-left.gif +0 -0
  250. data/lipsiadmin_generators/backend/templates/images/ext/default/tabs/scroll-right.gif +0 -0
  251. data/lipsiadmin_generators/backend/templates/images/ext/default/tabs/scroller-bg.gif +0 -0
  252. data/lipsiadmin_generators/backend/templates/images/ext/default/tabs/tab-btm-inactive-left-bg.gif +0 -0
  253. data/lipsiadmin_generators/backend/templates/images/ext/default/tabs/tab-btm-inactive-right-bg.gif +0 -0
  254. data/lipsiadmin_generators/backend/templates/images/ext/default/tabs/tab-btm-left-bg.gif +0 -0
  255. data/lipsiadmin_generators/backend/templates/images/ext/default/tabs/tab-btm-right-bg.gif +0 -0
  256. data/lipsiadmin_generators/backend/templates/images/ext/default/tabs/tab-close.gif +0 -0
  257. data/lipsiadmin_generators/backend/templates/images/ext/default/tabs/tab-strip-bg.gif +0 -0
  258. data/lipsiadmin_generators/backend/templates/images/ext/default/tabs/tab-strip-bg.png +0 -0
  259. data/lipsiadmin_generators/backend/templates/images/ext/default/tabs/tab-strip-btm-bg.gif +0 -0
  260. data/lipsiadmin_generators/backend/templates/images/ext/default/tabs/tabs-sprite.gif +0 -0
  261. data/lipsiadmin_generators/backend/templates/images/ext/default/toolbar/bg.gif +0 -0
  262. data/lipsiadmin_generators/backend/templates/images/ext/default/toolbar/btn-arrow-light.gif +0 -0
  263. data/lipsiadmin_generators/backend/templates/images/ext/default/toolbar/btn-arrow.gif +0 -0
  264. data/lipsiadmin_generators/backend/templates/images/ext/default/toolbar/btn-over-bg.gif +0 -0
  265. data/lipsiadmin_generators/backend/templates/images/ext/default/toolbar/gray-bg.gif +0 -0
  266. data/lipsiadmin_generators/backend/templates/images/ext/default/toolbar/tb-bg.gif +0 -0
  267. data/lipsiadmin_generators/backend/templates/images/ext/default/toolbar/tb-btn-sprite.gif +0 -0
  268. data/lipsiadmin_generators/backend/templates/images/ext/default/tree/arrows.gif +0 -0
  269. data/lipsiadmin_generators/backend/templates/images/ext/default/tree/drop-add.gif +0 -0
  270. data/lipsiadmin_generators/backend/templates/images/ext/default/tree/drop-between.gif +0 -0
  271. data/lipsiadmin_generators/backend/templates/images/ext/default/tree/drop-no.gif +0 -0
  272. data/lipsiadmin_generators/backend/templates/images/ext/default/tree/drop-over.gif +0 -0
  273. data/lipsiadmin_generators/backend/templates/images/ext/default/tree/drop-under.gif +0 -0
  274. data/lipsiadmin_generators/backend/templates/images/ext/default/tree/drop-yes.gif +0 -0
  275. data/lipsiadmin_generators/backend/templates/images/ext/default/tree/elbow-end-minus-nl.gif +0 -0
  276. data/lipsiadmin_generators/backend/templates/images/ext/default/tree/elbow-end-minus.gif +0 -0
  277. data/lipsiadmin_generators/backend/templates/images/ext/default/tree/elbow-end-plus-nl.gif +0 -0
  278. data/lipsiadmin_generators/backend/templates/images/ext/default/tree/elbow-end-plus.gif +0 -0
  279. data/lipsiadmin_generators/backend/templates/images/ext/default/tree/elbow-end.gif +0 -0
  280. data/lipsiadmin_generators/backend/templates/images/ext/default/tree/elbow-line.gif +0 -0
  281. data/lipsiadmin_generators/backend/templates/images/ext/default/tree/elbow-minus-nl.gif +0 -0
  282. data/lipsiadmin_generators/backend/templates/images/ext/default/tree/elbow-minus.gif +0 -0
  283. data/lipsiadmin_generators/backend/templates/images/ext/default/tree/elbow-plus-nl.gif +0 -0
  284. data/lipsiadmin_generators/backend/templates/images/ext/default/tree/elbow-plus.gif +0 -0
  285. data/lipsiadmin_generators/backend/templates/images/ext/default/tree/elbow.gif +0 -0
  286. data/lipsiadmin_generators/backend/templates/images/ext/default/tree/folder-open.gif +0 -0
  287. data/lipsiadmin_generators/backend/templates/images/ext/default/tree/folder.gif +0 -0
  288. data/lipsiadmin_generators/backend/templates/images/ext/default/tree/leaf.gif +0 -0
  289. data/lipsiadmin_generators/backend/templates/images/ext/default/tree/loading.gif +0 -0
  290. data/lipsiadmin_generators/backend/templates/images/ext/default/tree/s.gif +0 -0
  291. data/lipsiadmin_generators/backend/templates/images/ext/default/window/icon-error.gif +0 -0
  292. data/lipsiadmin_generators/backend/templates/images/ext/default/window/icon-info.gif +0 -0
  293. data/lipsiadmin_generators/backend/templates/images/ext/default/window/icon-question.gif +0 -0
  294. data/lipsiadmin_generators/backend/templates/images/ext/default/window/icon-warning.gif +0 -0
  295. data/lipsiadmin_generators/backend/templates/images/ext/default/window/left-corners.png +0 -0
  296. data/lipsiadmin_generators/backend/templates/images/ext/default/window/left-corners.psd +0 -0
  297. data/lipsiadmin_generators/backend/templates/images/ext/default/window/left-right.png +0 -0
  298. data/lipsiadmin_generators/backend/templates/images/ext/default/window/left-right.psd +0 -0
  299. data/lipsiadmin_generators/backend/templates/images/ext/default/window/right-corners.png +0 -0
  300. data/lipsiadmin_generators/backend/templates/images/ext/default/window/right-corners.psd +0 -0
  301. data/lipsiadmin_generators/backend/templates/images/ext/default/window/top-bottom.png +0 -0
  302. data/lipsiadmin_generators/backend/templates/images/ext/default/window/top-bottom.psd +0 -0
  303. data/lipsiadmin_generators/backend/templates/images/ext/slate/button/btn-arrow.gif +0 -0
  304. data/lipsiadmin_generators/backend/templates/images/ext/slate/button/btn-sprite.gif +0 -0
  305. data/lipsiadmin_generators/backend/templates/images/ext/slate/editor/tb-sprite.gif +0 -0
  306. data/lipsiadmin_generators/backend/templates/images/ext/slate/form/checkbox.gif +0 -0
  307. data/lipsiadmin_generators/backend/templates/images/ext/slate/form/clear-trigger.gif +0 -0
  308. data/lipsiadmin_generators/backend/templates/images/ext/slate/form/date-trigger.gif +0 -0
  309. data/lipsiadmin_generators/backend/templates/images/ext/slate/form/radio.gif +0 -0
  310. data/lipsiadmin_generators/backend/templates/images/ext/slate/form/search-trigger.gif +0 -0
  311. data/lipsiadmin_generators/backend/templates/images/ext/slate/form/trigger-tpl.gif +0 -0
  312. data/lipsiadmin_generators/backend/templates/images/ext/slate/form/trigger.gif +0 -0
  313. data/lipsiadmin_generators/backend/templates/images/ext/slate/gradient-bg.gif +0 -0
  314. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/arrow-left-white.gif +0 -0
  315. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/arrow-right-white.gif +0 -0
  316. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/col-move-bottom.gif +0 -0
  317. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/col-move-top.gif +0 -0
  318. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/footer-bg.gif +0 -0
  319. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/grid-blue-hd.gif +0 -0
  320. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/grid-blue-split.gif +0 -0
  321. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/grid-hrow.gif +0 -0
  322. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/grid-split.gif +0 -0
  323. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/grid-vista-hd.gif +0 -0
  324. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/grid3-hd-btn.gif +0 -0
  325. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/grid3-hrow-over.gif +0 -0
  326. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/grid3-hrow.gif +0 -0
  327. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/grid3-special-col-bg.gif +0 -0
  328. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/grid3-special-col-sel-bg.gif +0 -0
  329. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/group-expand-sprite.gif +0 -0
  330. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/mso-hd.gif +0 -0
  331. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/page-first-disabled.gif +0 -0
  332. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/page-first.gif +0 -0
  333. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/page-last-disabled.gif +0 -0
  334. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/page-last.gif +0 -0
  335. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/page-next-disabled.gif +0 -0
  336. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/page-next.gif +0 -0
  337. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/page-prev-disabled.gif +0 -0
  338. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/page-prev.gif +0 -0
  339. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/refresh.gif +0 -0
  340. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/row-over.gif +0 -0
  341. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/row-sel.gif +0 -0
  342. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/sort_asc.gif +0 -0
  343. data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/sort_desc.gif +0 -0
  344. data/lipsiadmin_generators/backend/templates/images/ext/slate/menu/checked.gif +0 -0
  345. data/lipsiadmin_generators/backend/templates/images/ext/slate/menu/group-checked.gif +0 -0
  346. data/lipsiadmin_generators/backend/templates/images/ext/slate/menu/item-over - Copy.gif +0 -0
  347. data/lipsiadmin_generators/backend/templates/images/ext/slate/menu/item-over.gif +0 -0
  348. data/lipsiadmin_generators/backend/templates/images/ext/slate/menu/menu-parent.gif +0 -0
  349. data/lipsiadmin_generators/backend/templates/images/ext/slate/menu/menu.gif +0 -0
  350. data/lipsiadmin_generators/backend/templates/images/ext/slate/menu/unchecked.gif +0 -0
  351. data/lipsiadmin_generators/backend/templates/images/ext/slate/panel/corners-sprite.gif +0 -0
  352. data/lipsiadmin_generators/backend/templates/images/ext/slate/panel/left-right.gif +0 -0
  353. data/lipsiadmin_generators/backend/templates/images/ext/slate/panel/light-hd.gif +0 -0
  354. data/lipsiadmin_generators/backend/templates/images/ext/slate/panel/tool-sprite-tpl.gif +0 -0
  355. data/lipsiadmin_generators/backend/templates/images/ext/slate/panel/tool-sprites.gif +0 -0
  356. data/lipsiadmin_generators/backend/templates/images/ext/slate/panel/tools-sprites-trans.gif +0 -0
  357. data/lipsiadmin_generators/backend/templates/images/ext/slate/panel/top-bottom.gif +0 -0
  358. data/lipsiadmin_generators/backend/templates/images/ext/slate/panel/top-bottom.png +0 -0
  359. data/lipsiadmin_generators/backend/templates/images/ext/slate/panel/white-corners-sprite.gif +0 -0
  360. data/lipsiadmin_generators/backend/templates/images/ext/slate/panel/white-left-right.gif +0 -0
  361. data/lipsiadmin_generators/backend/templates/images/ext/slate/panel/white-top-bottom.gif +0 -0
  362. data/lipsiadmin_generators/backend/templates/images/ext/slate/progress/progress-bg.gif +0 -0
  363. data/lipsiadmin_generators/backend/templates/images/ext/slate/qtip/bg.gif +0 -0
  364. data/lipsiadmin_generators/backend/templates/images/ext/slate/qtip/close.gif +0 -0
  365. data/lipsiadmin_generators/backend/templates/images/ext/slate/qtip/tip-sprite.gif +0 -0
  366. data/lipsiadmin_generators/backend/templates/images/ext/slate/s.gif +0 -0
  367. data/lipsiadmin_generators/backend/templates/images/ext/slate/shared/glass-bg.gif +0 -0
  368. data/lipsiadmin_generators/backend/templates/images/ext/slate/shared/hd-sprite.gif +0 -0
  369. data/lipsiadmin_generators/backend/templates/images/ext/slate/shared/left-btn.gif +0 -0
  370. data/lipsiadmin_generators/backend/templates/images/ext/slate/shared/right-btn.gif +0 -0
  371. data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/e-handle-dark.gif +0 -0
  372. data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/e-handle.gif +0 -0
  373. data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/ne-handle-dark.gif +0 -0
  374. data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/ne-handle.gif +0 -0
  375. data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/nw-handle-dark.gif +0 -0
  376. data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/nw-handle.gif +0 -0
  377. data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/s-handle-dark.gif +0 -0
  378. data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/s-handle.gif +0 -0
  379. data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/se-handle-dark.gif +0 -0
  380. data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/se-handle.gif +0 -0
  381. data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/square.gif +0 -0
  382. data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/sw-handle-dark.gif +0 -0
  383. data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/sw-handle.gif +0 -0
  384. data/lipsiadmin_generators/backend/templates/images/ext/slate/slider/slider-bg.png +0 -0
  385. data/lipsiadmin_generators/backend/templates/images/ext/slate/slider/slider-thumb.png +0 -0
  386. data/lipsiadmin_generators/backend/templates/images/ext/slate/slider/slider-v-bg.png +0 -0
  387. data/lipsiadmin_generators/backend/templates/images/ext/slate/slider/slider-v-thumb.png +0 -0
  388. data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/scroll-left.gif +0 -0
  389. data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/scroll-right.gif +0 -0
  390. data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/scroller-bg.gif +0 -0
  391. data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/tab-btm-inactive-left-bg.gif +0 -0
  392. data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/tab-btm-inactive-right-bg.gif +0 -0
  393. data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/tab-btm-left-bg.gif +0 -0
  394. data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/tab-btm-right-bg.gif +0 -0
  395. data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/tab-close.gif +0 -0
  396. data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/tab-strip-bg.gif +0 -0
  397. data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/tab-strip-bg.png +0 -0
  398. data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/tab-strip-btm-bg.gif +0 -0
  399. data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/tabs-sprite.gif +0 -0
  400. data/lipsiadmin_generators/backend/templates/images/ext/slate/toolbar/bg-menu.png +0 -0
  401. data/lipsiadmin_generators/backend/templates/images/ext/slate/toolbar/bg.gif +0 -0
  402. data/lipsiadmin_generators/backend/templates/images/ext/slate/toolbar/btn-arrow-light.gif +0 -0
  403. data/lipsiadmin_generators/backend/templates/images/ext/slate/toolbar/btn-arrow.gif +0 -0
  404. data/lipsiadmin_generators/backend/templates/images/ext/slate/toolbar/btn-over-bg.gif +0 -0
  405. data/lipsiadmin_generators/backend/templates/images/ext/slate/toolbar/gray-bg.gif +0 -0
  406. data/lipsiadmin_generators/backend/templates/images/ext/slate/toolbar/tb-bg.gif +0 -0
  407. data/lipsiadmin_generators/backend/templates/images/ext/slate/toolbar/tb-btn-sprite.gif +0 -0
  408. data/lipsiadmin_generators/backend/templates/images/ext/slate/tree/arrows.gif +0 -0
  409. data/lipsiadmin_generators/backend/templates/images/ext/slate/window/icon-error.gif +0 -0
  410. data/lipsiadmin_generators/backend/templates/images/ext/slate/window/icon-info.gif +0 -0
  411. data/lipsiadmin_generators/backend/templates/images/ext/slate/window/icon-question.gif +0 -0
  412. data/lipsiadmin_generators/backend/templates/images/ext/slate/window/icon-warning.gif +0 -0
  413. data/lipsiadmin_generators/backend/templates/images/ext/slate/window/left-corners.png +0 -0
  414. data/lipsiadmin_generators/backend/templates/images/ext/slate/window/left-right.png +0 -0
  415. data/lipsiadmin_generators/backend/templates/images/ext/slate/window/right-corners.png +0 -0
  416. data/lipsiadmin_generators/backend/templates/images/ext/slate/window/top-bottom.png +0 -0
  417. data/lipsiadmin_generators/backend/templates/javascripts/controls.js +3 -0
  418. data/lipsiadmin_generators/backend/templates/javascripts/dragdrop.js +3 -0
  419. data/lipsiadmin_generators/backend/templates/javascripts/effects.js +4 -0
  420. data/lipsiadmin_generators/backend/templates/javascripts/ext.js +76 -0
  421. data/lipsiadmin_generators/backend/templates/javascripts/prototype.js +12 -0
  422. data/lipsiadmin_generators/backend/templates/layouts/backend.html.haml +12 -0
  423. data/lipsiadmin_generators/backend/templates/layouts/frontend.html.haml +7 -0
  424. data/lipsiadmin_generators/backend/templates/migrations/create_accounts.rb +20 -0
  425. data/lipsiadmin_generators/backend/templates/models/account.rb +116 -0
  426. data/lipsiadmin_generators/backend/templates/models/account_access.rb +17 -0
  427. data/lipsiadmin_generators/backend/templates/models/notifier.rb +15 -0
  428. data/lipsiadmin_generators/backend/templates/stylesheets/backend-slate.css +105 -0
  429. data/lipsiadmin_generators/backend/templates/stylesheets/backend.css +74 -0
  430. data/lipsiadmin_generators/backend/templates/stylesheets/ext-slate.css +241 -0
  431. data/lipsiadmin_generators/backend/templates/stylesheets/ext.css +904 -0
  432. data/lipsiadmin_generators/backend/templates/stylesheets/login.css +22 -0
  433. data/lipsiadmin_generators/backend/templates/stylesheets/print.css +11 -0
  434. data/lipsiadmin_generators/backend/templates/stylesheets/standard.css +62 -0
  435. data/lipsiadmin_generators/backend/templates/views/backend/accounts/_form.html.haml +21 -0
  436. data/lipsiadmin_generators/backend/templates/views/backend/accounts/edit.html.haml +3 -0
  437. data/lipsiadmin_generators/backend/templates/views/backend/accounts/index.rjs +16 -0
  438. data/lipsiadmin_generators/backend/templates/views/backend/accounts/new.html.haml +3 -0
  439. data/lipsiadmin_generators/backend/templates/views/backend/base/index.html.haml +17 -0
  440. data/lipsiadmin_generators/backend/templates/views/backend/base/welcome.html.haml +2 -0
  441. data/lipsiadmin_generators/backend/templates/views/backend/sessions/new.html.haml +12 -0
  442. data/lipsiadmin_generators/backend/templates/views/javascripts/backend.js.erb +346 -0
  443. data/lipsiadmin_generators/backend/templates/views/javascripts/locale.js.erb +135 -0
  444. data/lipsiadmin_generators/backend/templates/views/notifier/registration.html.erb +2 -0
  445. data/lipsiadmin_generators/backend/templates/views/notifier/support_request.html.erb +1 -0
  446. data/lipsiadmin_generators/backend_page/REMEMBER +7 -0
  447. data/lipsiadmin_generators/backend_page/backend_page_generator.rb +212 -0
  448. data/lipsiadmin_generators/backend_page/templates/controller.rb +61 -0
  449. data/lipsiadmin_generators/backend_page/templates/form.html.haml +5 -0
  450. data/lipsiadmin_generators/backend_page/templates/form_scaffolding.html.haml +1 -0
  451. data/lipsiadmin_generators/backend_page/templates/functional_test.rb +45 -0
  452. data/lipsiadmin_generators/backend_page/templates/helper.rb +2 -0
  453. data/lipsiadmin_generators/backend_page/templates/view_edit.html.haml +3 -0
  454. data/lipsiadmin_generators/backend_page/templates/view_index.rjs.erb +16 -0
  455. data/lipsiadmin_generators/backend_page/templates/view_new.html.haml +3 -0
  456. data/lipsiadmin_generators/pdf/pdf_generator.rb +50 -0
  457. data/lipsiadmin_generators/pdf/templates/layout.html.erb +18 -0
  458. data/lipsiadmin_generators/pdf/templates/stylesheets/print.css +11 -0
  459. data/lipsiadmin_generators/pdf/templates/view.html.haml +7 -0
  460. data/resources/Pd4Ruby.class +0 -0
  461. data/resources/Pd4Ruby.java +52 -0
  462. data/resources/javascripts/ux.js +1102 -0
  463. data/resources/pd4ml.jar +0 -0
  464. data/resources/rdoc/horo.rb +613 -0
  465. data/resources/ss_css2.jar +0 -0
  466. data/tasks/lipsiadmin_tasks.rake +14 -0
  467. metadata +604 -0
@@ -0,0 +1,168 @@
1
+ module Lipsiadmin
2
+ module Controller
3
+ module Ext
4
+ # Return column config, and store config/data for ExtJS ColumnModel and Store
5
+ #
6
+ # Examples:
7
+ #
8
+ # # app/controllers/backend/debtors_controller.rb
9
+ # def index
10
+ # @column_store = column_store_for Debtor do |cm|
11
+ # cm.add :id
12
+ # cm.add "full_name_or_company.upcase", "Full Name", :sortable => true, :dataIndex => :company
13
+ # cm.add :email, "Email", :sortable => true
14
+ # cm.add :piva, "Piva", :sortable => true
15
+ # cm.add :created_at, "Creato il", :sortable => true, :renderer => :date, :align => :right
16
+ # cm.add :updated_at, "Aggiornato il", :sortable => true, :renderer => :datetime, :align => :right
17
+ # end
18
+ #
19
+ # respond_to do |format|
20
+ # format.js
21
+ # format.json do
22
+ # render :json => @column_store.store_data(params)
23
+ #
24
+ # # or you can manually do:
25
+ # # debtors = Debtor.search(params)
26
+ # # debtors_count = debtors.size
27
+ # # debtors_paginated = debtors.paginate(params)
28
+ # # render :json => { :results => @column_store.store_data_from(debtors_paginated), :count => debtors_count }
29
+ # end
30
+ # end
31
+ # end
32
+ #
33
+ # # app/views/backend/index.rjs
34
+ # page.grid do |grid|
35
+ # grid.id "debtors-grid" # If you don't set this columns are not saved in cookies
36
+ # grid.title "List al debtors"
37
+ # grid.base_path "/backend/debtors"
38
+ # grid.forgery_protection_token request_forgery_protection_token
39
+ # grid.authenticity_token form_authenticity_token
40
+ # grid.tbar :default
41
+ # grid.store do |store|
42
+ # store.url "/backend/debtors.json"
43
+ # store.fields @column_store.store_fields
44
+ # end
45
+ # grid.columns do |columns|
46
+ # columns.fields @column_store.column_fields
47
+ # end
48
+ # grid.bbar :store => grid.get_store, :pageSize => params[:limit] # Remember to add after defining store!
49
+ # end
50
+ #
51
+ def column_store_for(model, &block)
52
+ ColumnStore.new(model, &block)
53
+ end
54
+
55
+ class ColumnStore#:nodoc:
56
+ attr_reader :data
57
+
58
+ def initialize(model, &block)#:nodoc
59
+ @model = model
60
+ @data = []
61
+ yield self
62
+ end
63
+
64
+ # Method for add columns to the Column Model
65
+ def add(method, header=nil, options={})
66
+ options[:method] = method
67
+ # Setting hidden and removing query for
68
+ # items that don't have headers
69
+ if header.blank?
70
+ options[:hidden] = true
71
+ options[:query] = false
72
+ end
73
+
74
+ # Reforma DataIndex
75
+ if options[:dataIndex].is_a?(Array)
76
+ options[:dataIndex] = options[:dataIndex].collect do |f|
77
+ f.is_a?(Symbol) ? "#{@model.table_name}.#{f}" : f
78
+ end.join(",")
79
+ end
80
+
81
+ # Reformat query
82
+ if options[:method].is_a?(Symbol)
83
+ options[:dataIndex] ||= "#{@model.table_name}.#{options[:method]}"
84
+ else
85
+ # if we have eg. prodcedure.category.name we need to build
86
+ # a sql finder action so we need to generate
87
+ # procedures.categories.name
88
+ columns = options[:method].split(".")
89
+ if columns.empty?
90
+ options[:dataIndex] ||= "#{@model.table_name}.#{options[:method]}"
91
+ else
92
+ options[:dataIndex] ||= columns[0..columns.length-2].collect(&:pluralize).join(".") + "." + columns.at(columns.size-1)
93
+ end
94
+ end
95
+
96
+ # Reformat dataIndex
97
+ options[:mapping] ||= options[:dataIndex].to_s.downcase.gsub(/[^a-z0-9]+/, '_').
98
+ gsub(/-+$/, '_').
99
+ gsub(/^-+$/, '_')
100
+
101
+ # Reformat header
102
+ options[:header] = header || options[:dataIndex].to_s.humanize
103
+
104
+ @data << options
105
+ end
106
+
107
+ # Return an array config for build an Ext.grid.ColumnModel() config
108
+ def column_fields
109
+ @data.clone.inject([]) do |fields, data|
110
+ # Prevent to removing in the original Hash
111
+ field = data.clone
112
+ field.delete(:method)
113
+ field.delete(:mapping)
114
+ fields << field
115
+ fields
116
+ end
117
+ end
118
+
119
+ # Return an array config for build an Ext.data.GroupingStore()
120
+ def store_fields
121
+ @data.inject([]) do |fields, data|
122
+ hash = { :name => data[:dataIndex], :mapping => data[:mapping] }
123
+ hash.merge!(:type => data[:renderer]) if data[:renderer] &&
124
+ (data[:renderer] == :date || data[:renderer] == :datetime)
125
+ fields << hash
126
+ fields
127
+ end
128
+ end
129
+
130
+ # Return data for a custom collection for the ExtJS Ext.data.GroupingStore() json
131
+ def store_data_from(collection)
132
+ collection.inject([]) do |store, c|
133
+ store << @data.inject({ :id => c.id }) do |options, data|
134
+ options[data[:mapping]] = (c.instance_eval(data[:method].to_s) rescue I18n.t("lipsiadmin.labels.not_found"))
135
+ options
136
+ end
137
+ store
138
+ end
139
+ end
140
+
141
+ # Return a searched and paginated data collection for the ExtJS Ext.data.GroupingStore() json
142
+ # You can pass options like:
143
+ #
144
+ # Examples
145
+ #
146
+ # store_data(params, :conditions => "found = 1")
147
+ # store_data(params, :include => :posts)
148
+ #
149
+ def store_data(params, options={})
150
+ @model.send(:with_scope, :find => options) do
151
+ collection = @model.search(params)
152
+ collection_count = collection.size
153
+ collection_paginated = collection.paginate(params)
154
+ { :results => store_data_from(collection_paginated), :count => collection_count }
155
+ end
156
+ end
157
+
158
+ # Returns an object whose <tt>to_json</tt> evaluates to +code+. Use this to pass a literal JavaScript
159
+ # expression as an argument to another JavaScriptGenerator method.
160
+ #
161
+ def literal(code)
162
+ ActiveSupport::JSON::Variable.new(code.to_s)
163
+ end
164
+ alias_method :l, :literal
165
+ end
166
+ end
167
+ end
168
+ end
@@ -0,0 +1,18 @@
1
+ module Lipsiadmin#:nodoc:
2
+ module Controller#:nodoc:
3
+ # Base Backend Controller that define:
4
+ #
5
+ # layout false
6
+ # before_filter :backend_login_required
7
+ # helper Lipsiadmin::View::Helpers::BackendHelper
8
+ #
9
+ class Base < ActionController::Base
10
+ def self.inherited(subclass)#:nodoc:
11
+ super
12
+ subclass.layout false
13
+ subclass.before_filter :backend_login_required
14
+ subclass.helper Lipsiadmin::View::Helpers::BackendHelper
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,67 @@
1
+ module Lipsiadmin
2
+ module Controller
3
+ # This module convert a string/controller to a pdf through Pd4ml java library (included in this plugin)
4
+ #
5
+ # For generate a pdf you can simply do
6
+ #
7
+ # script/generate pdf invoice
8
+ #
9
+ # then edit your template /app/views/pdf/invoice.html.haml
10
+ #
11
+ # Then in any of your controllers add some like this:
12
+ #
13
+ # def generate_pdf_invoice
14
+ # render_pdf :invoice, 'invoice_file.pdf'
15
+ # end
16
+ #
17
+ # Possible options are:
18
+ #
19
+ # * landescape, default it's false
20
+ # * send_data, default it's true
21
+ #
22
+ module PdfBuilder
23
+ include Lipsiadmin::Utils::HtmlEntities
24
+
25
+ # Path to the pd4ml jarfile
26
+ JARPATH = "../../resources"
27
+
28
+ # Convert a stream to pdf, the template must be located in app/view/pdf/yourtemplate.pdf.erb
29
+ def render_pdf(template, filename=nil, options={})
30
+
31
+ options[:landescape] ||= true
32
+ options[:send_data] ||= !filename.blank?
33
+ # encode the template
34
+ input = encode_entities(render(:template => "/pdf/#{template}.html.haml", :layout => "print"))
35
+
36
+ # search for stylesheet links and make their paths absolute.
37
+ input.gsub!('<link href="/javascripts', '<link href="' + RAILS_ROOT + '/public/javascripts')
38
+ input.gsub!('<link href="/stylesheets', '<link href="' + RAILS_ROOT + '/public/stylesheets')
39
+
40
+ # search for images src, append full-path.
41
+ input.gsub!('src="/', 'src="' + RAILS_ROOT + '/public/')
42
+ input.gsub!('url(','url('+RAILS_ROOT+'/public')
43
+
44
+ cmd = "java -Xmx512m -Djava.awt.headless=true -cp pd4ml.jar:.:#{File.dirname(__FILE__)}/#{JARPATH} Pd4Ruby '#{input}' 950 A4 #{options[:landescape]}"
45
+
46
+ output = %x[cd #{File.dirname(__FILE__)}/#{JARPATH} \n #{cmd}]
47
+
48
+ # raise error if process returned false (ie: a java error)
49
+ raise PdfError, "An unknonwn error occurred while generating pdf: cd #{File.dirname(__FILE__)}/#{JARPATH} #{cmd}" if $?.success? === false
50
+
51
+ # return raw pdf binary-stream
52
+ if options[:send_data]
53
+ pdf_options = { :filename => filename, :type => 'application/pdf' }
54
+ pdf_options[:disposition] = "inline" if Rails.env == "development"
55
+ send_data(output, pdf_options)
56
+ else
57
+ erase_results
58
+ output
59
+ end
60
+ end
61
+
62
+ # Errors For PDF
63
+ class PdfError < StandardError#:nodoc:
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,72 @@
1
+ module Lipsiadmin
2
+ module Controller
3
+ # This module are raised when an exception fire up in controllers.
4
+ #
5
+ # Now you can personalize exception and simplify the layout using templates in:
6
+ #
7
+ # app/views/exception
8
+ #
9
+ # when an exception is raised it try to send an email, and for send an email
10
+ # you need to configure in enviroment or in an initializer some like this:
11
+ #
12
+ # Examples:
13
+ #
14
+ # Lipsiadmin::Mailer::ExceptionNotifier.sender_address = %("Exception Notifier" <server1@lipsiasoft.com>)
15
+ # Lipsiadmin::Mailer::ExceptionNotifier.recipients_addresses = %(info@lipsiasoft.com)
16
+ # Lipsiadmin::Mailer::ExceptionNotifier.email_prefix = "[Your Project]"
17
+ #
18
+ module Rescue
19
+
20
+ def self.included(base)#:nodoc:
21
+ base.class_eval do
22
+ alias_method_chain :rescue_action_in_public, :notifier
23
+ end
24
+ end
25
+
26
+ # Overwrite to implement public exception handling (for requests answering false to <tt>local_request?</tt>). By
27
+ # default will call render_optional_error_file. Override this method to provide more user friendly error messages.
28
+ def rescue_action_in_public_with_notifier(exception) #:doc:
29
+ response_code = response_code_for_rescue(exception)
30
+ status = interpret_status(response_code)[0,3]
31
+ respond_to do |format|
32
+ # Personalize rescue rules for backend
33
+ if controller_path =~ /^backend\//
34
+ # Usually when we made a post we submit the form
35
+ # to a target iframe, so we need to respond to the parent.
36
+ if request.post?
37
+ responds_to_parent do
38
+ render :update do |page|
39
+ page.unmask
40
+ page.ext_alert I18n.t("lipsiadmin.exceptions.#{status}.title"), I18n.t("lipsiadmin.exceptions.#{status}.description")
41
+ end
42
+ end
43
+ else
44
+ # We can't use status, because Backend.app.load don't permit load 500, 404 pages
45
+ format.html { render :template => "/exceptions/#{status}" }
46
+ format.js do
47
+ render :update do |page|
48
+ page.unmask
49
+ page.ext_alert I18n.t("lipsiadmin.exceptions.#{status}.title"), I18n.t("lipsiadmin.exceptions.#{status}.description")
50
+ end
51
+ end
52
+ format.all { render :nothing => true, :status => status }
53
+ end
54
+ else
55
+ format.html { render :template => "/exceptions/#{status}", :status => status }
56
+ format.all { render :nothing => true, :status => status }
57
+ end
58
+ end
59
+ rescue Exception => e
60
+ logger.error e.message
61
+ erase_results
62
+ rescue_action_in_public_without_notifier(exception)
63
+ ensure
64
+ if response_code != :not_found && Lipsiadmin::Mailer::ExceptionNotifier.send_mail
65
+ Lipsiadmin::Mailer::ExceptionNotifier.deliver_exception(exception, self, request)
66
+ end
67
+ end
68
+
69
+ end
70
+
71
+ end
72
+ end
@@ -0,0 +1,56 @@
1
+ module Lipsiadmin
2
+ module Controller
3
+ # Executes the response body as JavaScript in the context of the parent window.
4
+ #
5
+ # Use this method of you are posting a form to a hidden IFRAME or if you would like
6
+ # to use IFRAME base RPC.
7
+ module RespondsToParent
8
+ # Render an action to parent
9
+ def render_to_parent(*options_for_render)
10
+ responds_to_parent do
11
+ # I don't use page.update for prevent dobule rendering
12
+ # and so we can save rendering time!
13
+ source = render_to_string(*options_for_render)
14
+ render :update do |page|
15
+ page.call "Backend.app.update", source
16
+ end
17
+ end
18
+ end
19
+ # Redirect parent to a new url
20
+ def redirect_parent_to(location)
21
+ responds_to_parent do
22
+ render :update do |page|
23
+ page.load location, true
24
+ end
25
+ end
26
+ end
27
+
28
+ private
29
+ def responds_to_parent(&block)
30
+ yield
31
+ # We're returning HTML instead of JS or XML now
32
+ response.headers['Content-Type'] = 'text/html; charset=UTF-8'
33
+ # Either pull out a redirect or the request body
34
+ script = location = erase_redirect_results ? "document.location.href = #{location.to_s.inspect}" : response.body
35
+ # Escape quotes, linebreaks and slashes, maintaining previously escaped slashes
36
+ # Suggestions for improvement?
37
+ script = (script || '').
38
+ gsub('\\', '\\\\\\').
39
+ gsub(/\r\n|\r|\n/, '\\n').
40
+ gsub(/['"]/, '\\\\\&').
41
+ gsub('</script>','</scr"+"ipt>')
42
+ # Clear out the previous render to prevent double render
43
+ erase_results
44
+ # Eval in parent scope and replace document location of this frame
45
+ # so back button doesn't replay action on targeted forms
46
+ # loc = document.location to be set after parent is updated for IE
47
+ # setTimeout - scope the execution in the windows parent for safari
48
+ # window.eval - legal eval for Opera
49
+ render :text => "<html><body><script type='text/javascript' charset='utf-8'>
50
+ window.parent.eval('#{script}');
51
+ document.location.replace('about:blank');
52
+ </script></body></html>"
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,351 @@
1
+ require 'tempfile'
2
+ require 'data_base/attachment/upfile'
3
+ require 'data_base/attachment/iostream'
4
+ require 'data_base/attachment/geometry'
5
+ require 'data_base/attachment/processor'
6
+ require 'data_base/attachment/thumbnail'
7
+ require 'data_base/attachment/storage'
8
+ require 'data_base/attachment/attach'
9
+
10
+ if defined? RAILS_ROOT
11
+ Dir.glob(File.join(File.expand_path(RAILS_ROOT), "lib", "attachment_processors", "*.rb")).each do |processor|
12
+ require processor
13
+ end
14
+ end
15
+
16
+ module Lipsiadmin
17
+ module DataBase
18
+ module Attachment
19
+
20
+ class << self#:nodoc:
21
+ def included(base) #:nodoc:
22
+ base.extend(ClassMethods)
23
+ end
24
+ end
25
+
26
+ module ClassMethods
27
+
28
+ # Attach a single file/image to your model.
29
+ #
30
+ # Examples:
31
+ #
32
+ # has_one_attachment :image
33
+ # attachment_styles_for :image, :normal, "128x128!"
34
+ # validates_attachment_presence_for :image
35
+ # validates_attachment_size_for :image, :greater_than => 10.megabytes
36
+ # validates_attachment_content_type_for :image, "image/png"
37
+ #
38
+ # Then in your form (with multipart) you can simply add:
39
+ #
40
+ # =file_field :mymodel, :image_attributes
41
+ #
42
+ def has_one_attachment(name, options={})
43
+ options[:as] ||= :attacher
44
+ options[:class_name] ||= "Attachment"
45
+ has_one name, options
46
+ before_save "before_save_for_#{name}"
47
+ attr_accessor "#{name}_attributes"
48
+
49
+ write_inheritable_attribute(:attachment_definitions, {}) if attachment_definitions.nil?
50
+ attachment_definitions[name] = {:validations => {}}.merge(reflections[name].class_name.constantize.attachment_definitions)
51
+
52
+ validates_each(name) do |record, attr, value|
53
+ attributes = record.send("#{name}_attributes")
54
+ attributes ||= {}
55
+
56
+ attributes.merge!(:attachment_definitions => record.class.attachment_definitions[name])
57
+ file_column = reflections[name].class_name.constantize.new(attributes)
58
+ unless file_column.valid?
59
+ file_column.errors.each do |error, message|
60
+ record.errors.add(name, message) if message
61
+ end
62
+ end
63
+ end
64
+
65
+ define_method "before_save_for_#{name}" do
66
+ attributes = send("#{name}_attributes")
67
+ attributes ||= {}
68
+
69
+ return if attributes[:file].blank?
70
+
71
+ attributes.merge!(:attachment_definitions => self.class.attachment_definitions[name])
72
+
73
+ if file_column = self.send(name)
74
+ file_column.update_attributes(attributes)
75
+ else
76
+ self.send(name).build(attributes)
77
+ end
78
+
79
+ end
80
+ end
81
+
82
+ # Attach a many files/images to your model.
83
+ #
84
+ # Examples:
85
+ #
86
+ # has_one_attachment :images
87
+ # attachment_styles_for :images, :normal, "128x128!"
88
+ # validates_attachment_presence_for :images
89
+ # validates_attachment_size_for :images, :greater_than => 10.megabytes
90
+ # validates_attachment_content_type_for :images, "image/png"
91
+ #
92
+ # Then in your form (with multipart) you can simply add:
93
+ #
94
+ # =fields_for "yourmodel[attachments_attributes][]", @yourmodel.images.build do |image|
95
+ # =image.file_field :file
96
+ #
97
+ def has_many_attachments(name, options = {})
98
+ options[:as] ||= :attacher
99
+ options[:class_name] ||= "Attachment"
100
+
101
+ has_many name, options
102
+ before_save "before_save_for_#{name}"
103
+ attr_accessor "#{name}_attributes"
104
+
105
+ write_inheritable_attribute(:attachment_definitions, {}) if attachment_definitions.nil?
106
+ attachment_definitions[name] = {:validations => {}}.merge(reflections[name].class_name.constantize.attachment_definitions)
107
+
108
+ validates_each(name) do |record, attr, value|
109
+ attributes = record.send("#{name}_attributes")
110
+ attributes ||= {}
111
+
112
+ file_column = nil
113
+ for attribute in attributes
114
+ attribute.merge!(:attachment_definitions => record.class.attachment_definitions[name])
115
+ file_column = reflections[name].class_name.constantize.new(attribute)
116
+ unless file_column.valid?
117
+ file_column.errors.each do |error, message|
118
+ record.errors.add(name, message) if message
119
+ end
120
+ end
121
+ end
122
+ end
123
+
124
+ define_method "before_save_for_#{name}" do
125
+ attributes = send("#{name}_attributes")
126
+ attributes ||= {}
127
+
128
+ file_column = nil
129
+
130
+ for attribute in attributes
131
+ next if attribute["file"].blank?
132
+ attribute.merge!(:attachment_definitions => self.class.attachment_definitions[name])
133
+ self.send(name).build(attribute)
134
+ end
135
+
136
+ end
137
+ end
138
+
139
+ # The full URL of where the attachment is publically accessible. This can just
140
+ # as easily point to a directory served directly through Apache as it can to an action
141
+ # that can control permissions. You can specify the full domain and path, but usually
142
+ # just an absolute path is sufficient. The leading slash *must* be included manually for
143
+ # absolute paths. The default value is
144
+ # "/uploads/:id_:attachment_:style_:basename.:extension". See
145
+ # Lipsiadmin::Attachment::Attach#interpolate for more information on variable interpolaton.
146
+ # :url => "/:class/:attachment/:id/:style_:basename.:extension"
147
+ # :url => "http://some.other.host/stuff/:class/:id_:extension"
148
+ def attachment_url_for(name, url)
149
+ attachment_definitions[name][:url] = url
150
+ end
151
+
152
+ # The URL that will be returned if there is no attachment assigned.
153
+ # This field is interpolated just as the url is. The default value is
154
+ # "/images/backend/no-image.png"
155
+ # has_one_attached_file :avatar
156
+ # attachment_default_url :avatar, "/images/backend/no-image.png"
157
+ # User.new.avatar.url(:small) # => "/images/backend/no-image.png"
158
+ def attachment_default_url_for(name, url)
159
+ attachment_definitions[name][:default_url]
160
+ end
161
+
162
+ # The path were the attachment are stored.
163
+ # The default value is
164
+ # :rails_root/public/uploads/:id_:attachment_:style_:basename.:extension
165
+ # This value must be in consistency with <tt>url</tt>
166
+ def attachment_path_for(name, path)
167
+ attachment_definitions[name][:path] = path
168
+ end
169
+
170
+ # A hash of thumbnail styles and their geometries. You can find more about
171
+ # geometry strings at the ImageMagick website
172
+ # (http://www.imagemagick.org/script/command-line-options.php#resize). Attachment
173
+ # also adds the "#" option (e.g. "50x50#"), which will resize the image to fit maximally
174
+ # inside the dimensions and then crop the rest off (weighted at the center). The
175
+ # default value is to generate no thumbnails.
176
+ def attachment_styles_for(name, style_name, styles)
177
+ attachment_definitions[name][:styles] = { style_name => styles }
178
+ end
179
+
180
+ # The thumbnail style that will be used by default URLs.
181
+ # Defaults to +original+.
182
+ # attachment_styles :avatar, :normal, "100x100#"
183
+ # attachment_default_style :normal
184
+ # user.avatar.url # => "/avatars/23/normal_me.png"
185
+ def attachment_default_style_for(name, default_style)
186
+ attachment_definitions[name][:default_style] = default_style
187
+ end
188
+
189
+ # Will raise an error if Attachment cannot post_process an uploaded file due
190
+ # to a command line error. This will override the global setting for this attachment.
191
+ # Defaults to false.
192
+ def attachment_whiny_for(name, whiny_thumbnails)
193
+ attachment_definitions[name][:whiny_thumbnails] = whiny_thumbnails
194
+ end
195
+
196
+ # Chooses the storage backend where the files will be stored. The current
197
+ # choices are :filesystem and :s3. The default is :filesystem. Make sure you read the
198
+ # documentation for Lipsiadmin::Attachment::Storage::Filesystem and Lipsiadmin::Attachment::Storage::S3
199
+ # for backend-specific options.
200
+ def attachment_storage_for(name, storage)
201
+ attachment_definitions[name][:storage] = storage
202
+ end
203
+
204
+ # When creating thumbnails, use this free-form options
205
+ # field to pass in various convert command options. Typical options are "-strip" to
206
+ # remove all Exif data from the image (save space for thumbnails and avatars) or
207
+ # "-depth 8" to specify the bit depth of the resulting conversion. See ImageMagick
208
+ # convert documentation for more options: (http://www.imagemagick.org/script/convert.php)
209
+ # Note that this option takes a hash of options, each of which correspond to the style
210
+ # of thumbnail being generated. You can also specify :all as a key, which will apply
211
+ # to all of the thumbnails being generated. If you specify options for the :original,
212
+ # it would be best if you did not specify destructive options, as the intent of keeping
213
+ # the original around is to regenerate all the thumbnails when requirements change.
214
+ # attachment_styles :avatar, :large, "300x300"
215
+ # attachment_styles :avatar, :negative, "100x100"
216
+ # attachment_convert_options :avatar, :all, "-strip"
217
+ # attachment_convert_options :avatar, :negative, "-negate"
218
+ def attachment_convert_options_for(name, convert_name, convert_options)
219
+ attachment_definitions[name][:convert_options] = { convert_name => convert_options}
220
+ end
221
+
222
+ # When processing, if the spawn plugin is installed, processing can be done in
223
+ # a background fork or thread if desired.
224
+ def attachment_background_for(name, background)
225
+ attachment_definitions[name][:background] = background
226
+ end
227
+
228
+ # Attachment supports an extendible selection of post-processors. When you define
229
+ # a set of styles for an attachment, by default it is expected that those
230
+ # "styles" are actually "thumbnails". However, you can do more than just
231
+ # thumbnail images. By defining a subclass of Lipsiadmin::Attachment::Processor, you can
232
+ # perform any processing you want on the files that are attached. Any file in
233
+ # your Rails app's lib/attachment_processors directory is automatically loaded by
234
+ # Attachment, allowing you to easily define custom processors. You can specify a
235
+ # processor with the :processors option to has_attached_file:
236
+ #
237
+ # attachment_styles :avatar, :text, { :quality => :better }
238
+ # attachment_processors :avatar, :ocr
239
+ #
240
+ # This would load the hypothetical class Lipsiadmin::Ocr, which would have the
241
+ # hash "{ :quality => :better }" passed to it along with the uploaded file. For
242
+ # more information about defining processors, see Lipsiadmin::Attachment::Processor.
243
+ #
244
+ # The default processor is Lipsiadmin::Attachment::Thumbnail. For backwards compatability
245
+ # reasons, you can pass a single geometry string or an array containing a
246
+ # geometry and a format, which the file will be converted to, like so:
247
+ #
248
+ # attachment_styles :avatar, :thumb, ["32x32#", :png]
249
+ #
250
+ # This will convert the "thumb" style to a 32x32 square in png format, regardless
251
+ # of what was uploaded. If the format is not specified, it is kept the same (i.e.
252
+ # jpgs will remain jpgs).
253
+ #
254
+ # Multiple processors can be specified, and they will be invoked in the order
255
+ # they are defined in the :processors array. Each successive processor will
256
+ # be given the result of the previous processor's execution. All processors will
257
+ # receive the same parameters, which are what you define in the :styles hash.
258
+ # For example, assuming we had this definition:
259
+ #
260
+ # attachment_styles :avatar, :text, { :quality => :better }
261
+ # attachment_processors :avatar, :rotator
262
+ # attachment_processors :avatar, :ocr
263
+ #
264
+ # then both the :rotator processor and the :ocr processor would receive the
265
+ # options "{ :quality => :better }". This parameter may not mean anything to one
266
+ # or more or the processors, and they are free to ignore it.
267
+ def attachment_processors_for(name, processor_name, processors)
268
+ attachment_definitions[name][:processors] = { processor_name => processor_processors }
269
+ end
270
+
271
+ # Places ActiveRecord-style validations on the size of the file assigned. The
272
+ # possible options are:
273
+ # * +in+: a Range of bytes (i.e. +1..1.megabyte+),
274
+ # * +less_than+: equivalent to :in => 0..options[:less_than]
275
+ # * +greater_than+: equivalent to :in => options[:greater_than]..Infinity
276
+ # * +message+: error message to display, use :min and :max as replacements
277
+ def validates_attachment_size_for(name, options = {})
278
+ min = options[:greater_than] || (options[:in] && options[:in].first) || 0
279
+ max = options[:less_than] || (options[:in] && options[:in].last) || (1.0/0)
280
+ range = (min..max)
281
+ helper = ActionController::Base.helpers
282
+
283
+ if options[:message].blank?
284
+ message = ""
285
+ message << I18n.t("activerecord.errors.messages.greater_than", :count => helper.number_to_human_size(min)) if min > 0
286
+ message << " " + I18n.t("activerecord.errors.messages.less_than", :count => helper.number_to_human_size(max)) if max.to_f.infinite? != 1
287
+ else
288
+ message = options[:message]
289
+ end
290
+
291
+ attachment_definitions[name][:validations][:size] = lambda do |attachment, instance|
292
+ if attachment.exist? && !range.include?(attachment.size.to_i)
293
+ message
294
+ end
295
+ end
296
+ end
297
+
298
+ # Adds errors if thumbnail creation fails. The same as specifying :whiny_thumbnails => true.
299
+ def validates_attachment_thumbnails_for(name, options = {})
300
+ attachment_definitions[name][:whiny_thumbnails] = true
301
+ end
302
+
303
+ # Places ActiveRecord-style validations on the presence of a file.
304
+ def validates_attachment_presence_for(name, options = {})
305
+ message = options[:message] || I18n.t("activerecord.errors.messages.blank")
306
+ attachment_definitions[name][:validations][:presence] = lambda do |attachment, instance|
307
+ message unless attachment.exist?
308
+ end
309
+ end
310
+
311
+ # Places ActiveRecord-style validations on the content type of the file
312
+ # assigned. The possible options are:
313
+ # * +content_type+: Allowed content types. Can be a single content type
314
+ # or an array. Each type can be a String or a Regexp. It should be
315
+ # noted that Internet Explorer upload files with content_types that you
316
+ # may not expect. For example, JPEG images are given image/pjpeg and
317
+ # PNGs are image/x-png, so keep that in mind when determining how you
318
+ # match. Allows all by default.
319
+ # * +message+: The message to display when the uploaded file has an invalid
320
+ # content type.
321
+ def validates_attachment_content_type_for(name, *args)
322
+ options = {}
323
+ valid_types = []
324
+ args.each do |variable|
325
+ case variable
326
+ when String then valid_types << variable
327
+ when Hash then options.merge!(variable)
328
+ end
329
+ end
330
+ attachment_definitions[name][:validations][:content_type] = lambda do |attachment, instance|
331
+ unless attachment.original_filename.blank?
332
+ content_type = attachment.instance_read(:content_type)
333
+ unless valid_types.any?{ |t| t === content_type }
334
+ options[:message] || I18n.t("activerecord.errors.messages.content_type")
335
+ end
336
+ end
337
+ end
338
+ end
339
+
340
+ # Returns the attachment definitions defined by each call to
341
+ # has_attached_file.
342
+ def attachment_definitions
343
+ read_inheritable_attribute(:attachment_definitions)
344
+ end
345
+
346
+ end
347
+
348
+ end
349
+
350
+ end
351
+ end