sunrise-cms 0.7.0.rc2 → 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (239) hide show
  1. data/README.md +18 -17
  2. data/app/assets/stylesheets/sunrise/main.css +1 -1
  3. data/app/controllers/sunrise/manager_controller.rb +4 -7
  4. data/app/controllers/sunrise/settings_controller.rb +1 -1
  5. data/app/views/layouts/sunrise/application.html.erb +1 -1
  6. data/app/views/sunrise/manager/_form.html.erb +1 -1
  7. data/app/views/sunrise/shared/_filter.html.erb +3 -3
  8. data/app/views/sunrise/shared/_panel.html.erb +2 -2
  9. data/app/views/sunrise/shared/_toolbar.html.erb +1 -1
  10. data/config/routes.rb +14 -15
  11. data/lib/generators/sunrise/templates/config/active_record/sunrise.rb +11 -8
  12. data/lib/generators/sunrise/templates/config/mongoid/sunrise.rb +9 -6
  13. data/lib/generators/sunrise/templates/models/sunrise/sunrise_navigation.rb +8 -9
  14. data/lib/generators/sunrise/templates/models/sunrise/sunrise_page.rb +4 -4
  15. data/lib/generators/sunrise/templates/models/sunrise/sunrise_structure.rb +8 -8
  16. data/lib/generators/sunrise/templates/models/sunrise/sunrise_user.rb +14 -14
  17. data/lib/generators/sunrise/templates/uploaders/avatar_uploader.rb +1 -1
  18. data/lib/sunrise/abstract_model.rb +29 -27
  19. data/lib/sunrise/config/export.rb +26 -0
  20. data/lib/sunrise/config/{edit.rb → form.rb} +1 -1
  21. data/lib/sunrise/config/{list.rb → index.rb} +1 -1
  22. data/lib/sunrise/config/model.rb +23 -12
  23. data/lib/sunrise/config/navigation.rb +33 -11
  24. data/lib/sunrise/config/page_presenter.rb +31 -0
  25. data/lib/sunrise/config.rb +15 -10
  26. data/lib/sunrise/engine.rb +0 -1
  27. data/lib/sunrise/models/structure.rb +7 -7
  28. data/lib/sunrise/utils.rb +0 -1
  29. data/lib/sunrise/version.rb +1 -1
  30. data/spec/controllers/sunrise/settings_controller_spec.rb +2 -2
  31. data/spec/dummy/app/{models/sunrise → sunrise}/sunrise_post.rb +3 -3
  32. data/spec/dummy/config/application.rb +2 -10
  33. data/spec/dummy/config/environments/development.rb +3 -0
  34. data/spec/dummy/config/environments/production.rb +6 -0
  35. data/spec/dummy/config/environments/test.rb +5 -3
  36. data/spec/dummy/db/schema.rb +90 -0
  37. data/spec/models/avatar_spec.rb +1 -1
  38. data/spec/models/sunrise/abstract_model_spec.rb +5 -8
  39. data/spec/requests/manager/default/edit_spec.rb +1 -1
  40. data/spec/requests/manager/default/new_spec.rb +1 -1
  41. data/spec/requests/manager/default/update_spec.rb +3 -3
  42. data/spec/requests/manager/many/index_spec.rb +2 -1
  43. data/spec/requests/manager/many/new_spec.rb +1 -1
  44. data/spec/spec_helper.rb +18 -0
  45. data/spec/sunrise_spec.rb +2 -2
  46. metadata +10 -405
  47. data/app/controllers/sunrise/shared_controller.rb +0 -13
  48. data/app/views/sunrise/shared/services.json.jbuilder +0 -6
  49. data/lib/sunrise/utils/mysql.rb +0 -35
  50. data/spec/controllers/sunrise/shared_controller_spec.rb +0 -32
  51. data/spec/dummy/log/test.log +0 -22584
  52. data/spec/dummy/public/uploads/avatar/content_rails.png +0 -0
  53. data/spec/dummy/public/uploads/avatar/rails.png +0 -0
  54. data/spec/dummy/public/uploads/avatar/thumb_rails.png +0 -0
  55. data/spec/dummy/public/uploads/tmp/1397814500-44499-6278/rails.png +0 -0
  56. data/spec/dummy/public/uploads/tmp/1397814500-44499-6278/small_rails.png +0 -0
  57. data/spec/dummy/public/uploads/tmp/1397814500-44499-6278/thumb_rails.png +0 -0
  58. data/spec/dummy/public/uploads/tmp/1397814501-44499-0716/rails.png +0 -0
  59. data/spec/dummy/public/uploads/tmp/1397814501-44499-0716/small_rails.png +0 -0
  60. data/spec/dummy/public/uploads/tmp/1397814501-44499-0716/thumb_rails.png +0 -0
  61. data/spec/dummy/public/uploads/tmp/1397814501-44499-6498/rails.png +0 -0
  62. data/spec/dummy/public/uploads/tmp/1397814501-44499-6498/small_rails.png +0 -0
  63. data/spec/dummy/public/uploads/tmp/1397814501-44499-6498/thumb_rails.png +0 -0
  64. data/spec/dummy/public/uploads/tmp/1397814502-44499-9048/silicon_valley.jpg +0 -0
  65. data/spec/dummy/public/uploads/tmp/1397814502-44499-9048/small_silicon_valley.jpg +0 -0
  66. data/spec/dummy/public/uploads/tmp/1397814502-44499-9048/thumb_silicon_valley.jpg +0 -0
  67. data/spec/dummy/public/uploads/tmp/1397814509-44499-4712/rails.png +0 -0
  68. data/spec/dummy/public/uploads/tmp/1397814511-44499-6511/rails.png +0 -0
  69. data/spec/dummy/public/uploads/tmp/1397814514-44499-0946/rails.png +0 -0
  70. data/spec/dummy/public/uploads/tmp/1397814515-44499-4275/rails.png +0 -0
  71. data/spec/dummy/public/uploads/tmp/1397814516-44499-7258/rails.png +0 -0
  72. data/spec/dummy/public/uploads/tmp/1397814743-45062-5613/rails.png +0 -0
  73. data/spec/dummy/public/uploads/tmp/1397814743-45062-5613/small_rails.png +0 -0
  74. data/spec/dummy/public/uploads/tmp/1397814743-45062-5613/thumb_rails.png +0 -0
  75. data/spec/dummy/public/uploads/tmp/1397814744-45062-2352/rails.png +0 -0
  76. data/spec/dummy/public/uploads/tmp/1397814744-45062-2352/small_rails.png +0 -0
  77. data/spec/dummy/public/uploads/tmp/1397814744-45062-2352/thumb_rails.png +0 -0
  78. data/spec/dummy/public/uploads/tmp/1397814744-45062-7990/rails.png +0 -0
  79. data/spec/dummy/public/uploads/tmp/1397814744-45062-7990/small_rails.png +0 -0
  80. data/spec/dummy/public/uploads/tmp/1397814744-45062-7990/thumb_rails.png +0 -0
  81. data/spec/dummy/public/uploads/tmp/1397814745-45062-4632/silicon_valley.jpg +0 -0
  82. data/spec/dummy/public/uploads/tmp/1397814745-45062-4632/small_silicon_valley.jpg +0 -0
  83. data/spec/dummy/public/uploads/tmp/1397814745-45062-4632/thumb_silicon_valley.jpg +0 -0
  84. data/spec/dummy/public/uploads/tmp/1397814752-45062-3620/rails.png +0 -0
  85. data/spec/dummy/public/uploads/tmp/1397814754-45062-7554/rails.png +0 -0
  86. data/spec/dummy/public/uploads/tmp/1397814757-45062-6575/rails.png +0 -0
  87. data/spec/dummy/public/uploads/tmp/1397814758-45062-2473/rails.png +0 -0
  88. data/spec/dummy/public/uploads/tmp/1397814758-45062-7698/rails.png +0 -0
  89. data/spec/dummy/public/uploads/tmp/1397815061-45673-4098/rails.png +0 -0
  90. data/spec/dummy/public/uploads/tmp/1397815061-45673-4098/small_rails.png +0 -0
  91. data/spec/dummy/public/uploads/tmp/1397815061-45673-4098/thumb_rails.png +0 -0
  92. data/spec/dummy/public/uploads/tmp/1397815062-45673-5873/rails.png +0 -0
  93. data/spec/dummy/public/uploads/tmp/1397815062-45673-5873/small_rails.png +0 -0
  94. data/spec/dummy/public/uploads/tmp/1397815062-45673-5873/thumb_rails.png +0 -0
  95. data/spec/dummy/public/uploads/tmp/1397815062-45673-9908/rails.png +0 -0
  96. data/spec/dummy/public/uploads/tmp/1397815062-45673-9908/small_rails.png +0 -0
  97. data/spec/dummy/public/uploads/tmp/1397815062-45673-9908/thumb_rails.png +0 -0
  98. data/spec/dummy/public/uploads/tmp/1397815063-45673-6362/silicon_valley.jpg +0 -0
  99. data/spec/dummy/public/uploads/tmp/1397815063-45673-6362/small_silicon_valley.jpg +0 -0
  100. data/spec/dummy/public/uploads/tmp/1397815063-45673-6362/thumb_silicon_valley.jpg +0 -0
  101. data/spec/dummy/public/uploads/tmp/1397815070-45673-9261/rails.png +0 -0
  102. data/spec/dummy/public/uploads/tmp/1397815072-45673-2350/rails.png +0 -0
  103. data/spec/dummy/public/uploads/tmp/1397815075-45673-3163/rails.png +0 -0
  104. data/spec/dummy/public/uploads/tmp/1397815076-45673-3745/rails.png +0 -0
  105. data/spec/dummy/public/uploads/tmp/1397815077-45673-2689/rails.png +0 -0
  106. data/spec/dummy/tmp/cache/assets/test/sprockets/025a845bfc99eb99aa9690545d024974 +0 -0
  107. data/spec/dummy/tmp/cache/assets/test/sprockets/02ca6949ca99936393e2992467409faf +0 -0
  108. data/spec/dummy/tmp/cache/assets/test/sprockets/03bae0b322a9c8706915fdb4f8d50961 +0 -0
  109. data/spec/dummy/tmp/cache/assets/test/sprockets/06632caa2dd14ba28b138446bd3d807a +0 -0
  110. data/spec/dummy/tmp/cache/assets/test/sprockets/06a86d61c2e57fad1cee30584df6f969 +0 -0
  111. data/spec/dummy/tmp/cache/assets/test/sprockets/07d036bf808a7ace22ce3b32701a2867 +0 -0
  112. data/spec/dummy/tmp/cache/assets/test/sprockets/0cc8e44f8b692c44ef509fd2d7f38941 +0 -0
  113. data/spec/dummy/tmp/cache/assets/test/sprockets/0d7fd69f7cbd03f1617b280bfb33677e +0 -0
  114. data/spec/dummy/tmp/cache/assets/test/sprockets/0e7270936d642e566d747ab335c44ec2 +0 -0
  115. data/spec/dummy/tmp/cache/assets/test/sprockets/0f382880a507fbcedb3a83727f118f84 +0 -0
  116. data/spec/dummy/tmp/cache/assets/test/sprockets/0fab3bb8b5212da52c8b7e0ae428b22a +0 -0
  117. data/spec/dummy/tmp/cache/assets/test/sprockets/12bbe81ebeeacdf11820f57a821789ff +0 -0
  118. data/spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  119. data/spec/dummy/tmp/cache/assets/test/sprockets/146ce2f3522fd98d4a8a1501f16c7092 +0 -0
  120. data/spec/dummy/tmp/cache/assets/test/sprockets/172c139e25cc08516d5a8c72c777dd4d +0 -0
  121. data/spec/dummy/tmp/cache/assets/test/sprockets/18b64b11b8b00cc21a396da25a5ff156 +0 -0
  122. data/spec/dummy/tmp/cache/assets/test/sprockets/197d8d604ec08a638b656e053944b734 +0 -0
  123. data/spec/dummy/tmp/cache/assets/test/sprockets/1bdb903463fe67323dbadb0f78337c70 +0 -0
  124. data/spec/dummy/tmp/cache/assets/test/sprockets/1beea1617441e02d76649f4b799aedac +0 -0
  125. data/spec/dummy/tmp/cache/assets/test/sprockets/20f8ac265bd1f0c57067c7a4b5c8f119 +0 -0
  126. data/spec/dummy/tmp/cache/assets/test/sprockets/212fc15df4fd708ebdef5bd3be2191c1 +0 -0
  127. data/spec/dummy/tmp/cache/assets/test/sprockets/256dcb01e7f35659d770584fd71a85d2 +0 -0
  128. data/spec/dummy/tmp/cache/assets/test/sprockets/25a167c7563d6fe8ec6b13ec1ac09274 +0 -0
  129. data/spec/dummy/tmp/cache/assets/test/sprockets/2a6ef2448bbff5c2c3c70c141f744cf5 +0 -0
  130. data/spec/dummy/tmp/cache/assets/test/sprockets/2dedb8177c20286c4259c1d58c5646cc +0 -0
  131. data/spec/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  132. data/spec/dummy/tmp/cache/assets/test/sprockets/33b9cc34fd627b9c81e63eb0faf06efb +0 -0
  133. data/spec/dummy/tmp/cache/assets/test/sprockets/33bd898bccf5b0821d1d3ffa02e9d1b6 +0 -0
  134. data/spec/dummy/tmp/cache/assets/test/sprockets/350390c7e44df7d038254cff29468e2d +0 -0
  135. data/spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  136. data/spec/dummy/tmp/cache/assets/test/sprockets/3633276e08728ac0cfea5659b4f8b516 +0 -0
  137. data/spec/dummy/tmp/cache/assets/test/sprockets/37b103f4623089af1456b90830fe941c +0 -0
  138. data/spec/dummy/tmp/cache/assets/test/sprockets/392239d689265304b5fe68912a8f2383 +0 -0
  139. data/spec/dummy/tmp/cache/assets/test/sprockets/3c396fbac68d9fb827a0f4c9d8cae3b6 +0 -0
  140. data/spec/dummy/tmp/cache/assets/test/sprockets/43ad0cf2497efae7114ac03a314706c5 +0 -0
  141. data/spec/dummy/tmp/cache/assets/test/sprockets/46e447bca92498433b2a3114106389a9 +0 -0
  142. data/spec/dummy/tmp/cache/assets/test/sprockets/47395ef44102932b2b9fe17a46c16601 +0 -0
  143. data/spec/dummy/tmp/cache/assets/test/sprockets/4c1c0c6c54ed879c4a5489eadd3a772c +0 -0
  144. data/spec/dummy/tmp/cache/assets/test/sprockets/4ca01587005a9b895bca383881bec87d +0 -0
  145. data/spec/dummy/tmp/cache/assets/test/sprockets/4cffdba2a7aac80c1765e060b152b382 +0 -0
  146. data/spec/dummy/tmp/cache/assets/test/sprockets/54d68ac9b230a01a37ef415779a748da +0 -0
  147. data/spec/dummy/tmp/cache/assets/test/sprockets/55b923cfea92fd264597042a44303f0c +0 -0
  148. data/spec/dummy/tmp/cache/assets/test/sprockets/56d4d696f46e9a63d0a42e11556bce11 +0 -0
  149. data/spec/dummy/tmp/cache/assets/test/sprockets/56e5bd2f3c94d7a9d0da7c4e05c7ad78 +0 -0
  150. data/spec/dummy/tmp/cache/assets/test/sprockets/5807e61754ed8b16702f6ad7ba34d439 +0 -0
  151. data/spec/dummy/tmp/cache/assets/test/sprockets/5a44970074ecbfeae2cc9798ed7da7aa +0 -0
  152. data/spec/dummy/tmp/cache/assets/test/sprockets/5ab8f53cba6a8bdf2c6d671491c397ce +0 -0
  153. data/spec/dummy/tmp/cache/assets/test/sprockets/5e27babe25470126fbc4635dc9fe9a6a +0 -0
  154. data/spec/dummy/tmp/cache/assets/test/sprockets/6056bd921f3a4b6e437dab030d7fef90 +0 -0
  155. data/spec/dummy/tmp/cache/assets/test/sprockets/61533733f5f9ec09571d2d5c45d5ab47 +0 -0
  156. data/spec/dummy/tmp/cache/assets/test/sprockets/68c52f388e9c2401252c0bedf6247c8c +0 -0
  157. data/spec/dummy/tmp/cache/assets/test/sprockets/6a1e72555b75237fffccb5de8937b4d4 +0 -0
  158. data/spec/dummy/tmp/cache/assets/test/sprockets/6a8187f5c6f2e115d1a1c21ca2ec81a0 +0 -0
  159. data/spec/dummy/tmp/cache/assets/test/sprockets/7041d544b28bff5f26dde49d77a2e87d +0 -0
  160. data/spec/dummy/tmp/cache/assets/test/sprockets/747d1d7298f227da4193f23f3932ac8e +0 -0
  161. data/spec/dummy/tmp/cache/assets/test/sprockets/749bd767d6654c80265f5ca0959dc8e1 +0 -0
  162. data/spec/dummy/tmp/cache/assets/test/sprockets/75870e6b6fe8335a7912ca4ea859a76a +0 -0
  163. data/spec/dummy/tmp/cache/assets/test/sprockets/759bbbe7d51d98664d8072e51b24744b +0 -0
  164. data/spec/dummy/tmp/cache/assets/test/sprockets/7a1f4a9bcb1d7d1e515330c4f5c391ad +0 -0
  165. data/spec/dummy/tmp/cache/assets/test/sprockets/7ad564910e515e335bb008989a97efb7 +0 -0
  166. data/spec/dummy/tmp/cache/assets/test/sprockets/7b55037b89f2debe558b43fe7542e409 +0 -0
  167. data/spec/dummy/tmp/cache/assets/test/sprockets/7ff7dd624cb7a6db5ec99af129138020 +0 -0
  168. data/spec/dummy/tmp/cache/assets/test/sprockets/80870efa2a2ddb1de325c224daff5712 +0 -0
  169. data/spec/dummy/tmp/cache/assets/test/sprockets/856b05d9307e97e681bc5c7f3649f714 +0 -0
  170. data/spec/dummy/tmp/cache/assets/test/sprockets/8766064af197b444eb1f06a6650ca9c3 +0 -0
  171. data/spec/dummy/tmp/cache/assets/test/sprockets/894aeaae9cc8483fa9f7a5146ff6ff6f +0 -0
  172. data/spec/dummy/tmp/cache/assets/test/sprockets/8a559f967fac90d4ae5a84af92c111e1 +0 -0
  173. data/spec/dummy/tmp/cache/assets/test/sprockets/8c5ee15b5860dcf2941abd00daf001eb +0 -0
  174. data/spec/dummy/tmp/cache/assets/test/sprockets/8c9393d7c6a1a2b6bb1fc9a9ccaba111 +0 -0
  175. data/spec/dummy/tmp/cache/assets/test/sprockets/8d476275ed52a5aa897cb7eef648dbc4 +0 -0
  176. data/spec/dummy/tmp/cache/assets/test/sprockets/906da6ff8c06db3e472a0a10985b668c +0 -0
  177. data/spec/dummy/tmp/cache/assets/test/sprockets/94826bb92d888d50a265392a81ce1286 +0 -0
  178. data/spec/dummy/tmp/cache/assets/test/sprockets/956d7ea9ee52ec12759995ab47f1e780 +0 -0
  179. data/spec/dummy/tmp/cache/assets/test/sprockets/974812817397ff6032b286a281d9a163 +0 -0
  180. data/spec/dummy/tmp/cache/assets/test/sprockets/9ba0cab624f25b68f79447e62fbc6112 +0 -0
  181. data/spec/dummy/tmp/cache/assets/test/sprockets/a1c0fa5689dff4e7edcc4f175f9d54bf +0 -0
  182. data/spec/dummy/tmp/cache/assets/test/sprockets/a43280845b1d41babd3f6714cd2d1337 +0 -0
  183. data/spec/dummy/tmp/cache/assets/test/sprockets/a50e247ceb9e9af32260a73eadbb65cb +0 -0
  184. data/spec/dummy/tmp/cache/assets/test/sprockets/a668bf13b4df6854c8c1085b26daa63a +0 -0
  185. data/spec/dummy/tmp/cache/assets/test/sprockets/a78a33e8cea959257da93b3e67786300 +0 -0
  186. data/spec/dummy/tmp/cache/assets/test/sprockets/aa4822def20c419f0e50e2a38e73a1df +0 -0
  187. data/spec/dummy/tmp/cache/assets/test/sprockets/aa94554c7d6f15d3f88e9710b043c2cc +0 -0
  188. data/spec/dummy/tmp/cache/assets/test/sprockets/abde9800d767ab39abc91703e5a83d70 +0 -0
  189. data/spec/dummy/tmp/cache/assets/test/sprockets/b25e1f0b850e73d0e1ef154249ce8135 +0 -0
  190. data/spec/dummy/tmp/cache/assets/test/sprockets/b4e0977feb24777fe3df7dd188b2b123 +0 -0
  191. data/spec/dummy/tmp/cache/assets/test/sprockets/b4e12b8782fac2f3caaa4aea2f89087c +0 -0
  192. data/spec/dummy/tmp/cache/assets/test/sprockets/b8c47badf85ceedb2268ef3b0f074257 +0 -0
  193. data/spec/dummy/tmp/cache/assets/test/sprockets/bafd6678f36ffd5fb29e4d9055df1f97 +0 -0
  194. data/spec/dummy/tmp/cache/assets/test/sprockets/bc4b7beed5a786619d6c3855909cb077 +0 -0
  195. data/spec/dummy/tmp/cache/assets/test/sprockets/bfc0fef30976427a03ddccb1ce78d6e7 +0 -0
  196. data/spec/dummy/tmp/cache/assets/test/sprockets/c104157fd9dbe5edc61a1889af968e19 +0 -0
  197. data/spec/dummy/tmp/cache/assets/test/sprockets/c37e2e0969ee5b3590335141a08ed884 +0 -0
  198. data/spec/dummy/tmp/cache/assets/test/sprockets/c3dc3ada4560805584739bfe7c2b24d9 +0 -0
  199. data/spec/dummy/tmp/cache/assets/test/sprockets/c4d36397803a4adf8ea86a8936b2d5f5 +0 -0
  200. data/spec/dummy/tmp/cache/assets/test/sprockets/c8f8b0ae15c86cf8aae9e3601758435e +0 -0
  201. data/spec/dummy/tmp/cache/assets/test/sprockets/cbbe8f22213647e8549911f486aee9b3 +0 -0
  202. data/spec/dummy/tmp/cache/assets/test/sprockets/cc04ce51d1e3d02a64f2781ea0876af3 +0 -0
  203. data/spec/dummy/tmp/cache/assets/test/sprockets/cebb517859b2ed48276bf54e0ba6dcec +0 -0
  204. data/spec/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  205. data/spec/dummy/tmp/cache/assets/test/sprockets/d311318a280b46ab076da5c419b210ab +0 -0
  206. data/spec/dummy/tmp/cache/assets/test/sprockets/d48c8e1ff1b6fcdbacf6ab08f8bde111 +0 -0
  207. data/spec/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  208. data/spec/dummy/tmp/cache/assets/test/sprockets/d7c40ebee2fb9471bab352337570ba40 +0 -0
  209. data/spec/dummy/tmp/cache/assets/test/sprockets/d9390b9983c2dcadf2533a63d0f7a84c +0 -0
  210. data/spec/dummy/tmp/cache/assets/test/sprockets/da055188ac218679c8fe62932c379340 +0 -0
  211. data/spec/dummy/tmp/cache/assets/test/sprockets/da4488b32bd6fb75c655a077956c9034 +0 -0
  212. data/spec/dummy/tmp/cache/assets/test/sprockets/e0f1660d21c6375d8a36eac87ae8ccbc +0 -0
  213. data/spec/dummy/tmp/cache/assets/test/sprockets/e1639f86099d91eb2fede327d443906f +0 -0
  214. data/spec/dummy/tmp/cache/assets/test/sprockets/e25f607f69c16bc5ffb481f9606b457e +0 -0
  215. data/spec/dummy/tmp/cache/assets/test/sprockets/e2c4f946939f2d7d0b42d86383755cae +0 -0
  216. data/spec/dummy/tmp/cache/assets/test/sprockets/e4a2ab1f3bf2d0726dff720ae88e8abc +0 -0
  217. data/spec/dummy/tmp/cache/assets/test/sprockets/e4f46080338c0c52e3933999a7f8106d +0 -0
  218. data/spec/dummy/tmp/cache/assets/test/sprockets/e59a3c2ff941e0fdc7987168580bf4cc +0 -0
  219. data/spec/dummy/tmp/cache/assets/test/sprockets/e5ab921ab9e413144898d780049a5c88 +0 -0
  220. data/spec/dummy/tmp/cache/assets/test/sprockets/e6cfe2e09e34ec2b24494a74eed5243a +0 -0
  221. data/spec/dummy/tmp/cache/assets/test/sprockets/e994cc6f07f643c4c230a9b740fd03f5 +0 -0
  222. data/spec/dummy/tmp/cache/assets/test/sprockets/ec87c33887ff6c0258bd8469a77bdcb4 +0 -0
  223. data/spec/dummy/tmp/cache/assets/test/sprockets/eccb73ad1563f9b070c4ffdf07ffff38 +0 -0
  224. data/spec/dummy/tmp/cache/assets/test/sprockets/ee5a41236d43159aac87f9224a0bcfb8 +0 -0
  225. data/spec/dummy/tmp/cache/assets/test/sprockets/f00fb03eca205b5e302d9ae7ed652817 +0 -0
  226. data/spec/dummy/tmp/cache/assets/test/sprockets/f24a0e7771eab5bd17ee05c73c56649e +0 -0
  227. data/spec/dummy/tmp/cache/assets/test/sprockets/f2de4855fd4840abb2f6e80afee5f4ed +0 -0
  228. data/spec/dummy/tmp/cache/assets/test/sprockets/f475ab32c44efa173bf8ba75435d2570 +0 -0
  229. data/spec/dummy/tmp/cache/assets/test/sprockets/f5165c4d7cee0e7cb99bc069fd4c09b9 +0 -0
  230. data/spec/dummy/tmp/cache/assets/test/sprockets/f53b02f1d2cbab753c7931e700469bed +0 -0
  231. data/spec/dummy/tmp/cache/assets/test/sprockets/f5cf5c65e6bf2039363f3b1e09bcdc9c +0 -0
  232. data/spec/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  233. data/spec/dummy/tmp/cache/assets/test/sprockets/f975cba8c490022ddfc45bab0b512879 +0 -0
  234. data/spec/dummy/tmp/cache/assets/test/sprockets/fba4eeb0b33c40737a907a18ee0770a4 +0 -0
  235. data/spec/dummy/tmp/cache/assets/test/sprockets/fbe8d6803f3e5a9ccb6eb7a285b95ee0 +0 -0
  236. data/spec/dummy/tmp/cache/assets/test/sprockets/fd7e46e0b42a510b40f17d1f1bacf80e +0 -0
  237. data/spec/dummy/tmp/cache/assets/test/sprockets/fd9e24b6acf76f9d44cc8e26d3148e39 +0 -0
  238. data/spec/dummy/tmp/cache/assets/test/sprockets/fe03e8232ec516da863efecd7bb2678b +0 -0
  239. data/spec/requests/shared_spec.rb +0 -36
data/README.md CHANGED
@@ -2,11 +2,23 @@
2
2
 
3
3
  Open source mini content management system for programmers.
4
4
 
5
+ ## Setup
6
+
7
+ For rails 4.x.x:
8
+
9
+ ```ruby
10
+ gem "sunrise-cms", :require => "sunrise"
11
+ ```
12
+
13
+ For rails 3.x.x:
14
+
15
+ ```ruby
16
+ gem "sunrise-cms", "~> 0.7.x" :require => "sunrise"
17
+ ```
18
+
5
19
  ## Instructions
6
20
 
7
21
  ### ActiveRecord
8
-
9
- List of gems for [active_record](https://gist.github.com/4529926#file-gemfile-active_record).
10
22
 
11
23
  ```bash
12
24
  $> rails g devise:install
@@ -24,8 +36,6 @@ $> rails g public_activity:migration
24
36
 
25
37
  ### Mongoid
26
38
 
27
- List of gems for [mongoid](https://gist.github.com/4529926#file-gemfile-mongoid).
28
-
29
39
  ```bash
30
40
  $> rails g sunrise:install --orm=mongoid
31
41
  ```
@@ -42,7 +52,7 @@ class SunriseProduct < Sunrise::AbstractModel
42
52
 
43
53
  after_sort :clear_cache
44
54
 
45
- list :thumbs do
55
+ index :thumbs do
46
56
  scope { Product.includes(:picture) }
47
57
  preview lambda { |product| product.picture.try(:url, :thumb) }
48
58
 
@@ -51,7 +61,7 @@ class SunriseProduct < Sunrise::AbstractModel
51
61
  field :total_stock
52
62
  end
53
63
 
54
- list :export do
64
+ export do
55
65
  scope { Product.includes(:picture).recently.with_state(:finished) }
56
66
 
57
67
  field :id
@@ -71,7 +81,7 @@ class SunriseProduct < Sunrise::AbstractModel
71
81
  field :is_visible
72
82
  end
73
83
 
74
- edit do
84
+ form do
75
85
  field :title
76
86
  field :price
77
87
  field :total_stock
@@ -139,15 +149,6 @@ For more info look at jbuilder https://rubygems.org/gems/jbuilder.
139
149
 
140
150
  ### Strong parameters
141
151
 
142
- Sunrise include gem [strong_parameters](https://github.com/rails/strong_parameters)
143
- In all models your need include module ActiveModel::ForbiddenAttributesProtection:
144
-
145
- ``` ruby
146
- class Post < ActiveRecord::Base
147
- include ActiveModel::ForbiddenAttributesProtection
148
- end
149
- ```
150
-
151
152
  Now in sunrise file you can perform attributes check.
152
153
  By default permited_attributes allow edit all attributes.
153
154
 
@@ -192,4 +193,4 @@ config.to_prepare do
192
193
  end
193
194
  ```
194
195
 
195
- Copyright (c) 2013 Fodojo, released under the MIT license
196
+ Copyright (c) 2014 Fodojo, released under the MIT license
@@ -1177,7 +1177,7 @@ a.close-but:hover {
1177
1177
  border: solid 1px #ccc;
1178
1178
  padding: 10px;
1179
1179
  width: 255px;
1180
- height: 50px;
1180
+ height: 40px;
1181
1181
  font-size: 12px;
1182
1182
  }
1183
1183
  .sort-wrapper .sort-items-holder .sort-item:hover {
@@ -55,18 +55,15 @@ module Sunrise
55
55
  end
56
56
 
57
57
  def export
58
- abstract_model.current_list = "export"
59
- @records = abstract_model.apply_scopes(params)
60
- options = { :filename => abstract_model.export_filename,
61
- :columns => abstract_model.export_columns }
58
+ @records = abstract_model.apply_scopes(params, false)
62
59
 
63
60
  respond_to do |format|
64
61
  format.xml { render :xml => @records }
65
62
  format.json { render :json => @records }
66
- format.csv { render options.merge(:csv => @records) }
63
+ format.csv { render abstract_model.export_options.merge(:csv => @records) }
67
64
 
68
65
  if defined?(Mime::XLSX)
69
- format.xlsx { render options.merge(:xlsx => @records) }
66
+ format.xlsx { render abstract_model.export_options.merge(:xlsx => @records) }
70
67
  end
71
68
  end
72
69
  end
@@ -155,7 +152,7 @@ module Sunrise
155
152
  end
156
153
 
157
154
  def redirect_after_update(record = nil)
158
- if abstract_model.without_list?
155
+ if abstract_model.without_index?
159
156
  index_path(:model_name => abstract_model.plural)
160
157
  else
161
158
  scoped_index_path
@@ -3,7 +3,7 @@ module Sunrise
3
3
  authorize_resource :class => false
4
4
 
5
5
  def edit
6
- @settings = Settings.all
6
+ @settings = Settings.get_all
7
7
  respond_with(@settings)
8
8
  end
9
9
 
@@ -22,7 +22,7 @@
22
22
 
23
23
  <div class="footer">
24
24
  <div class="fwrapper">
25
- <%= image_tag("sunrise/created.png", :alt => "Example.com") %>
25
+ <%= image_tag("sunrise/created.png", :title => "fodojo.com") %>
26
26
  </div>
27
27
  </div>
28
28
 
@@ -7,7 +7,7 @@
7
7
  <div class="wysiwyg-holder">
8
8
  <%= render :partial => "sunrise/shared/available_locales", :locals => {:form => f} if abstract_model.translate? %>
9
9
 
10
- <%= render :partial => 'field', :collection => abstract_model.edit_fields, :locals => {:form => f} %>
10
+ <%= render :partial => 'field', :collection => abstract_model.form_fields, :locals => {:form => f} %>
11
11
  </div>
12
12
 
13
13
  <% if abstract_model.sidebar_groups? -%>
@@ -15,7 +15,7 @@
15
15
  <%= link_to t('manage.filter'), scoped_index_path, :class => "filter-but ddmenu", :rel => "filter" %>
16
16
  <% end %>
17
17
 
18
- <% unless abstract_model.without_list? %>
18
+ <% unless abstract_model.without_index? %>
19
19
  <div class="tabs-holder">
20
20
  <%= content_tag :div, :class => 'tabs-item' do %>
21
21
  <% if abstract_model.current_list == :table %>
@@ -23,7 +23,7 @@
23
23
  <% else %>
24
24
  <%= link_to image_tag('sunrise/empty.gif'), {:view=>"table"}, :class => "table", :title => t('manage.buttons.table') %>
25
25
  <% end %>
26
- <% end if abstract_model.config.available_list_view.include?(:table) -%>
26
+ <% end if abstract_model.config.available_index_views.include?(:table) -%>
27
27
 
28
28
  <%= content_tag :div, :class => 'tabs-item' do %>
29
29
  <% if abstract_model.current_list == :thumbs %>
@@ -31,7 +31,7 @@
31
31
  <% else %>
32
32
  <%= link_to image_tag('sunrise/empty.gif'), {:view=>"thumbs"}, :class => "list", :title => t('manage.buttons.thumbs') %>
33
33
  <% end %>
34
- <% end if abstract_model.config.available_list_view.include?(:thumbs) -%>
34
+ <% end if abstract_model.config.available_index_views.include?(:thumbs) -%>
35
35
  </div>
36
36
 
37
37
  <% if abstract_model.sort_available? %>
@@ -2,7 +2,7 @@
2
2
  <div class="rel-holder">
3
3
  <div class="menu-holder">
4
4
  <ul class="main-menu">
5
- <% Sunrise::Config.nav.each do |key, value| %>
5
+ <% Sunrise::Config.navigation.each do |key, value| %>
6
6
  <li>
7
7
  <%= link_to "##{key}", :class => "ddmenu", :rel => key do -%>
8
8
  <%= content_tag(:span, :class => key) do -%>
@@ -25,7 +25,7 @@
25
25
  </ul>
26
26
  </div>
27
27
 
28
- <% Sunrise::Config.nav.each do |key, value| -%>
28
+ <% Sunrise::Config.navigation.each do |key, value| -%>
29
29
  <%= content_tag(:div, :id => "#{key}-container", :class => ["sub-wrapper", key], :style => "display: none;") do -%>
30
30
  <div class="sub-inner">
31
31
  <%= content_tag(:ul, :class => ["#{key}-list", "default-list"]) do -%>
@@ -2,7 +2,7 @@
2
2
  <div class="act-buttons-wrapper">
3
3
  <div class="but-holder"><div class="check"><input type="checkbox" /></div></div>
4
4
 
5
- <% unless abstract_model.without_list? %>
5
+ <% unless abstract_model.without_index? %>
6
6
  <% abstract_model.list.buttons.each do |name| %>
7
7
  <% if can? name, abstract_model.model, :context => :sunrise %>
8
8
  <%= render :partial => "sunrise/manager/buttons/#{name}", :locals => {:model => abstract_model} %>
data/config/routes.rb CHANGED
@@ -1,26 +1,25 @@
1
1
  Sunrise::Engine.routes.draw do
2
- root :to => "dashboard#index"
2
+ root to: Sunrise::Config.root_controller
3
3
 
4
- get "/services", :to => "shared#services", :as => "services"
5
- get "/dashboard/p/:page", :to => "dashboard#index", :page => /\d+/
4
+ get "/dashboard/p/:page", to: "dashboard#index", page: /\d+/
6
5
 
7
- resource :settings, :only => [:edit, :update]
6
+ resource :settings, only: [:edit, :update]
8
7
 
9
8
  controller "manager" do
10
9
  scope ":model_name" do
11
- get "/", :to => :index, :as => "index", :via => [:get, :post]
12
- get "/export.:format", :to => :export, :as => "export"
13
- post "/sort", :to => :sort, :as => "sort"
14
- get "/new", :to => :new, :as => "new"
15
- post "/new", :to => :create, :as => "create"
16
- delete "/mass_destroy", :to => :mass_destroy, :as => "mass_destroy"
10
+ get "/", to: :index, as: :index
11
+ get "/export.:format", to: :export, as: :export
12
+ post "/sort", to: :sort, as: :sort
13
+ get "/new", to: :new, as: :new
14
+ post "/new", to: :create, as: :create
15
+ delete "/mass_destroy", to: :mass_destroy, as: :mass_destroy
17
16
 
18
17
  scope ":id" do
19
- get "/", :to => :show, :as => "show"
20
- get "/edit", :to => :edit, :as => "edit"
21
- patch "/edit", :to => :update, :as => "update"
22
- get "/delete", :to => :delete, :as => "delete"
23
- delete "/delete", :to => :destroy, :as => "destroy"
18
+ get "/", to: :show, as: :show
19
+ get "/edit", to: :edit, as: :edit
20
+ patch "/edit", to: :update, as: :update
21
+ get "/delete", to: :delete, as: :delete
22
+ delete "/delete", to: :destroy, as: :destroy
24
23
  end
25
24
  end
26
25
  end
@@ -15,13 +15,13 @@ Sunrise.setup do |config|
15
15
  # The display for a model instance (i.e. a single database record).
16
16
  # config.label_methods = [:title, :name]
17
17
 
18
- # Defailt list template view (default: "thumbs")
19
- # config.default_list_view = "thumbs"
18
+ # Default list template view (default: "thumbs")
19
+ # config.default_index_view = "thumbs"
20
20
 
21
21
  # Avariable lists views (default: [:list, :thumbs, :table])
22
- # config.available_list_view = [:list, :thumbs, :table]
22
+ # config.available_index_views = [:list, :thumbs, :table]
23
23
 
24
- # Defailt list template view (default: "sort_order")
24
+ # Default sort order column (default: "sort_order")
25
25
  # config.sort_column = "sort_order"
26
26
 
27
27
  # Find template before rendering (default: true)
@@ -39,13 +39,16 @@ Sunrise.setup do |config|
39
39
 
40
40
  # Lists the formats that should be treated as navigational (default: [:html, :json])
41
41
  # config.navigational_formats = [:html, :json]
42
+
43
+ # Welcome (root) controller path
44
+ # config.root_controller = "dashboard#index"
42
45
  end
43
46
 
44
47
  PublicActivity::Config.set do
45
48
  orm :active_record
46
49
  end
47
50
 
48
- #if Settings.table_exists?
49
- # Settings.defaults[:some_setting] = "value"
50
- # Settings.defaults[:some_setting2] = "value2"
51
- #end
51
+ # if Settings.table_exists?
52
+ # Settings.some_setting = "value"
53
+ # Settings.some_setting2 = "value2"
54
+ # end
@@ -15,13 +15,13 @@ Sunrise.setup do |config|
15
15
  # The display for a model instance (i.e. a single database record).
16
16
  # config.label_methods = [:title, :name]
17
17
 
18
- # Defailt list template view (default: "thumbs")
19
- # config.default_list_view = "thumbs"
18
+ # Default list template view (default: "thumbs")
19
+ # config.default_index_view = "thumbs"
20
20
 
21
21
  # Avariable lists views (default: [:list, :thumbs, :table])
22
- # config.available_list_view = [:list, :thumbs, :table]
22
+ # config.available_index_views = [:list, :thumbs, :table]
23
23
 
24
- # Defailt list template view (default: "sort_order")
24
+ # Default sort order column (default: "sort_order")
25
25
  # config.sort_column = "sort_order"
26
26
 
27
27
  # Find template before rendering (default: true)
@@ -39,6 +39,9 @@ Sunrise.setup do |config|
39
39
 
40
40
  # Lists the formats that should be treated as navigational (default: [:html, :json])
41
41
  # config.navigational_formats = [:html, :json]
42
+
43
+ # Welcome (root) controller path
44
+ # config.root_controller = "dashboard#index"
42
45
  end
43
46
 
44
47
  PublicActivity::Config.set do
@@ -46,6 +49,6 @@ PublicActivity::Config.set do
46
49
  end
47
50
 
48
51
  #if Settings.table_exists?
49
- # Settings.defaults[:some_setting] = "value"
50
- # Settings.defaults[:some_setting2] = "value2"
52
+ # Settings.some_setting = "value"
53
+ # Settings.some_setting2 = "value2"
51
54
  #end
@@ -1,14 +1,13 @@
1
1
  class SunriseNavigation < Sunrise::Config::Navigation
2
- navigation :main do |m|
3
- m.item :dashboard, root_path, :class => "icon1"
4
- m.item :structures, index_path(:model_name => "structures"), :class => "icon2"
5
- m.item :users, index_path(:model_name => "users"), :class => "icon3"
6
- m.item :services, "#", :class => "icon4"
7
- m.item :settings, edit_settings_path, :class => "icon4"
2
+ navigation :main do
3
+ item :dashboard, root_path, class: "icon1"
4
+ item :structures, index_path(model_name: "structures"), class: "icon2"
5
+ item :users, index_path(model_name: "users"), class: "icon3"
6
+ item :settings, edit_settings_path, class: "icon4"
8
7
  end
9
8
 
10
- navigation :creates do |c|
11
- c.item :structures, new_path(:model_name => "structures")
12
- c.item :users, new_path(:model_name => "users")
9
+ navigation :creates do
10
+ item :structures, new_path(model_name: "structures")
11
+ item :users, new_path(model_name: "users")
13
12
  end
14
13
  end
@@ -1,10 +1,10 @@
1
1
  class SunrisePage < Sunrise::AbstractModel
2
2
  self.resource_name = "Structure"
3
3
 
4
- list false
4
+ index false
5
5
 
6
- edit do
7
- field :main, :as => :text
8
- field :sidebar, :as => :text
6
+ form do
7
+ field :content, as: :text
8
+ field :sidebar, as: :text
9
9
  end
10
10
  end
@@ -2,10 +2,10 @@
2
2
  class SunriseStructure < Sunrise::AbstractModel
3
3
  self.resource_name = "Structure"
4
4
 
5
- default_list_view :tree
6
- available_list_view [:tree, :thumbs]
5
+ default_index_view :tree
6
+ available_index_views [:tree, :thumbs]
7
7
 
8
- list :tree do
8
+ index :tree do
9
9
  field :title
10
10
  field :updated_at
11
11
  field :id
@@ -17,16 +17,16 @@ class SunriseStructure < Sunrise::AbstractModel
17
17
  field :is_visible
18
18
  end
19
19
 
20
- edit do
20
+ form do
21
21
  field :title
22
22
  field :redirect_url
23
23
  field :slug
24
- field :parent_id, :collection => lambda { Structure.nested_set_options() {|i| "#{'–' * i.depth} #{i.title}"} }, :if => lambda { |s| s.moveable? }
25
- field :structure_type_id, :collection => lambda { StructureType.all }, :include_blank => false
26
- field :position_type_id, :collection => lambda { PositionType.all }, :include_blank => false
24
+ field :parent_id, collection: lambda { Structure.nested_set_options() {|i| "#{'–' * i.depth} #{i.title}"} }, if: lambda { |s| s.moveable? }
25
+ field :structure_type_id, collection: lambda { StructureType.all }, include_blank: false
26
+ field :position_type_id, collection: lambda { PositionType.all }, include_blank: false
27
27
  field :is_visible
28
28
 
29
- group :meta_tags, :holder => :sidebar do
29
+ group :meta_tags, holder: :sidebar do
30
30
  field :tag_title
31
31
  field :tag_keywords
32
32
  field :tag_description
@@ -1,7 +1,7 @@
1
1
  class SunriseUser < Sunrise::AbstractModel
2
2
  self.resource_name = "User"
3
3
 
4
- list :table do
4
+ index :table do
5
5
  field :email
6
6
  field :updated_at
7
7
  field :id
@@ -12,12 +12,12 @@ class SunriseUser < Sunrise::AbstractModel
12
12
  end
13
13
  end
14
14
 
15
- list :thumbs do
15
+ index :thumbs do
16
16
  scope { User.includes(:avatar) }
17
17
  preview lambda { |user| user.avatar.try(:url, :thumb) }
18
18
 
19
- field :email, :label => false
20
- field :updated_at, :label => false
19
+ field :email, label: false
20
+ field :updated_at, label: false
21
21
  field :id
22
22
 
23
23
  group :search do
@@ -25,8 +25,14 @@ class SunriseUser < Sunrise::AbstractModel
25
25
  field :name
26
26
  end
27
27
  end
28
+
29
+ export do
30
+ field :id
31
+ field :name
32
+ field :email
33
+ end
28
34
 
29
- edit do
35
+ form do
30
36
  permited_attributes lambda { |user|
31
37
  user.admin? ? :all : [:name, :password, :password_confirmation, :avatar_attributes]
32
38
  }
@@ -35,16 +41,10 @@ class SunriseUser < Sunrise::AbstractModel
35
41
  field :email
36
42
  field :password
37
43
  field :password_confirmation
38
- field :role_type_id, :collection => lambda { RoleType.all }
44
+ field :role_type_id, collection: lambda { RoleType.all }
39
45
 
40
- group :bottom, :holder => :bottom do
41
- field :avatar, :as => :uploader
46
+ group :bottom, holder: :bottom do
47
+ field :avatar, as: :uploader
42
48
  end
43
49
  end
44
-
45
- list :export do
46
- field :id
47
- field :name
48
- field :email
49
- end
50
50
  end
@@ -2,7 +2,7 @@ class AvatarUploader < Sunrise::CarrierWave::BaseUploader
2
2
  process :quality => 90
3
3
 
4
4
  version :thumb do
5
- process :resize_to_fill => [50, 50]
5
+ process :resize_to_fill => [100, 100]
6
6
  end
7
7
 
8
8
  version :small do
@@ -55,8 +55,8 @@ module Sunrise
55
55
 
56
56
  def initialize(params = {})
57
57
  @model_name = model.model_name
58
- @current_list = config.default_list_view
59
- @available_list_view = config.available_list_view
58
+ @current_list = config.default_index_view
59
+ @available_index_views = config.available_index_views
60
60
  @sort_column = config.sort_column
61
61
  @request_params = params.symbolize_keys
62
62
  self.current_list = params[:view]
@@ -68,16 +68,11 @@ module Sunrise
68
68
 
69
69
  # Save current list view
70
70
  def current_list=(value)
71
- unless value.blank?
72
- @current_list = value.to_s.downcase.to_sym
71
+ if value && @available_index_views.include?(value.to_sym)
72
+ @current_list = value.to_sym
73
73
  end
74
74
  end
75
75
 
76
- # Key which stored list settings
77
- def list_key
78
- ["list", current_list].compact.join('_').to_sym
79
- end
80
-
81
76
  # Load association record
82
77
  def parent_record
83
78
  @parent_record ||= find_parent_record
@@ -91,13 +86,13 @@ module Sunrise
91
86
 
92
87
  # Get current list settings
93
88
  def list
94
- return false if without_list?
95
- config.sections[list_key] ||= Config::List.new(self.class)
89
+ return false if without_index?
90
+ config.index(current_list)
96
91
  end
97
92
 
98
- # Is list config disabled
99
- def without_list?
100
- config.sections[:list] === false
93
+ # Is index config disabled
94
+ def without_index?
95
+ config.index === false
101
96
  end
102
97
 
103
98
  def search_available?
@@ -167,15 +162,15 @@ module Sunrise
167
162
  end
168
163
 
169
164
  # Convert request params to model scopes
170
- def apply_scopes(params = nil)
171
- raise ::AbstractController::ActionNotFound.new("List config is turn off") if without_list?
165
+ def apply_scopes(params = nil, pagination = true)
166
+ raise ::AbstractController::ActionNotFound.new("List config is turn off") if without_index?
172
167
  params ||= @request_params
173
168
 
174
169
  scope = default_scope(params)
175
170
 
176
171
  if current_list == :tree
177
172
  scope = scope.roots
178
- else
173
+ elsif pagination
179
174
  scope = page_scope(scope, params[:page], params[:per])
180
175
  end
181
176
 
@@ -187,7 +182,7 @@ module Sunrise
187
182
  params ||= @request_params
188
183
 
189
184
  scope = model.sunrise_search(params[:search]) if model.respond_to?(:sunrise_search) && !params[:search].blank?
190
- scope ||= model.scoped
185
+ scope ||= model.where(nil)
191
186
 
192
187
  scope = scope.merge(association_scope) unless parent_record.nil?
193
188
  scope = scope.merge(sort_scope(params[:sort])) unless params[:sort].blank?
@@ -221,20 +216,27 @@ module Sunrise
221
216
 
222
217
  # List of columns names to be exported
223
218
  def export_columns
224
- list.fields ? list.fields.map(&:name) : model.column_names
219
+ @export_columns ||= (config.export ? config.export.fields.map(&:name) : model.column_names)
225
220
  end
226
221
 
227
222
  # Filename for export data
228
223
  def export_filename
229
224
  @export_filename ||= [plural, Time.now.strftime("%Y-%m-%d_%Hh%Mm%S")].join('_')
230
225
  end
226
+
227
+ def export_options
228
+ {
229
+ :filename => export_filename,
230
+ :columns => export_columns
231
+ }
232
+ end
231
233
 
232
- def edit_fields
233
- config.edit.fields || []
234
+ def form_fields
235
+ config.form.fields || []
234
236
  end
235
237
 
236
238
  def permit_attributes(params, user = nil)
237
- value = config.edit.permited_attributes
239
+ value = config.form.permited_attributes
238
240
 
239
241
  attrs = case value
240
242
  when Proc then value.call(user)
@@ -252,17 +254,17 @@ module Sunrise
252
254
 
253
255
  # Has translated columns
254
256
  def translate?
255
- !config.edit.groups[:translate].blank?
257
+ !config.form.groups[:translate].blank?
256
258
  end
257
259
 
258
260
  # Files to translate
259
261
  def translate_fields
260
- config.edit.groups[:translate].try(:fields) || []
262
+ config.form.groups[:translate].try(:fields) || []
261
263
  end
262
264
 
263
265
  # Find sidebar groups
264
266
  def sidebar_groups
265
- @sidebar_groups ||= config.edit.groups.values.select { |v| v.sidebar? }
267
+ @sidebar_groups ||= config.form.groups.values.select { |v| v.sidebar? }
266
268
  end
267
269
 
268
270
  # Check if sidebar groups exists
@@ -272,7 +274,7 @@ module Sunrise
272
274
 
273
275
  # Find bottom groups
274
276
  def bottom_groups
275
- @bottom_groups ||= config.edit.groups.values.select { |v| v.bottom? }
277
+ @bottom_groups ||= config.form.groups.values.select { |v| v.bottom? }
276
278
  end
277
279
 
278
280
  protected
@@ -299,4 +301,4 @@ module Sunrise
299
301
  !(@request_params[:parent_id].blank? || @request_params[:parent_type].blank?)
300
302
  end
301
303
  end
302
- end
304
+ end
@@ -0,0 +1,26 @@
1
+ require 'sunrise/config/base'
2
+ require 'sunrise/config/has_groups'
3
+ require 'sunrise/config/has_fields'
4
+
5
+ module Sunrise
6
+ module Config
7
+ class Export < Base
8
+ include Sunrise::Config::HasFields
9
+
10
+ # Column to sort
11
+ register_instance_option :sort_column do
12
+ abstract_model.model.primary_key
13
+ end
14
+
15
+ # Sort direction
16
+ register_instance_option :sort_mode do
17
+ Sunrise::Config.default_sort_mode
18
+ end
19
+
20
+ # Default scope
21
+ register_instance_option(:scope) do
22
+ nil
23
+ end
24
+ end
25
+ end
26
+ end
@@ -3,7 +3,7 @@ require 'sunrise/config/has_fields'
3
3
 
4
4
  module Sunrise
5
5
  module Config
6
- class Edit < Base
6
+ class Form < Base
7
7
  include Sunrise::Config::HasFields
8
8
  include Sunrise::Config::HasGroups
9
9
 
@@ -4,7 +4,7 @@ require 'sunrise/config/has_fields'
4
4
 
5
5
  module Sunrise
6
6
  module Config
7
- class List < Base
7
+ class Index < Base
8
8
  include Sunrise::Config::HasFields
9
9
  include Sunrise::Config::HasGroups
10
10