releaf 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (323) hide show
  1. data/LICENSE +24 -0
  2. data/README.md +74 -0
  3. data/Rakefile +62 -0
  4. data/app/assets/images/releaf/3rd_party/jquery-ui-1.9.2.custom/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  5. data/app/assets/images/releaf/3rd_party/jquery-ui-1.9.2.custom/ui-bg_flat_75_ffffff_40x100.png +0 -0
  6. data/app/assets/images/releaf/3rd_party/jquery-ui-1.9.2.custom/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  7. data/app/assets/images/releaf/3rd_party/jquery-ui-1.9.2.custom/ui-bg_glass_65_ffffff_1x400.png +0 -0
  8. data/app/assets/images/releaf/3rd_party/jquery-ui-1.9.2.custom/ui-bg_glass_75_dadada_1x400.png +0 -0
  9. data/app/assets/images/releaf/3rd_party/jquery-ui-1.9.2.custom/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  10. data/app/assets/images/releaf/3rd_party/jquery-ui-1.9.2.custom/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  11. data/app/assets/images/releaf/3rd_party/jquery-ui-1.9.2.custom/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  12. data/app/assets/images/releaf/3rd_party/jquery-ui-1.9.2.custom/ui-icons_222222_256x240.png +0 -0
  13. data/app/assets/images/releaf/3rd_party/jquery-ui-1.9.2.custom/ui-icons_2e83ff_256x240.png +0 -0
  14. data/app/assets/images/releaf/3rd_party/jquery-ui-1.9.2.custom/ui-icons_454545_256x240.png +0 -0
  15. data/app/assets/images/releaf/3rd_party/jquery-ui-1.9.2.custom/ui-icons_888888_256x240.png +0 -0
  16. data/app/assets/images/releaf/3rd_party/jquery-ui-1.9.2.custom/ui-icons_cd0a0a_256x240.png +0 -0
  17. data/app/assets/images/releaf/3rd_party/lightbox/close.png +0 -0
  18. data/app/assets/images/releaf/3rd_party/lightbox/loading.gif +0 -0
  19. data/app/assets/images/releaf/3rd_party/lightbox/next.png +0 -0
  20. data/app/assets/images/releaf/3rd_party/lightbox/prev.png +0 -0
  21. data/app/assets/images/releaf/add.png +0 -0
  22. data/app/assets/images/releaf/background.jpg +0 -0
  23. data/app/assets/images/releaf/button/button_bgr.gif +0 -0
  24. data/app/assets/images/releaf/button/button_hover_bgr.png +0 -0
  25. data/app/assets/images/releaf/controllers/content/close.gif +0 -0
  26. data/app/assets/images/releaf/controllers/content/close_active.gif +0 -0
  27. data/app/assets/images/releaf/controllers/content/close_hover.gif +0 -0
  28. data/app/assets/images/releaf/controllers/content/global_fields_bgr.png +0 -0
  29. data/app/assets/images/releaf/controllers/content/open.gif +0 -0
  30. data/app/assets/images/releaf/controllers/content/open_2.gif +0 -0
  31. data/app/assets/images/releaf/controllers/content/open_active.gif +0 -0
  32. data/app/assets/images/releaf/controllers/content/open_hover.gif +0 -0
  33. data/app/assets/images/releaf/controllers/sessions/background.jpg +0 -0
  34. data/app/assets/images/releaf/controllers/sessions/logo.jpg +0 -0
  35. data/app/assets/images/releaf/expand_tool/close.png +0 -0
  36. data/app/assets/images/releaf/expand_tool/close_hover.png +0 -0
  37. data/app/assets/images/releaf/expand_tool/close_hover_shim.png +0 -0
  38. data/app/assets/images/releaf/expand_tool/close_shim.png +0 -0
  39. data/app/assets/images/releaf/expand_tool/loader.gif +0 -0
  40. data/app/assets/images/releaf/expand_tool/open.png +0 -0
  41. data/app/assets/images/releaf/expand_tool/open_hover.png +0 -0
  42. data/app/assets/images/releaf/expand_tool/open_hover_shim.png +0 -0
  43. data/app/assets/images/releaf/expand_tool/open_shim.png +0 -0
  44. data/app/assets/images/releaf/favicon.ico +0 -0
  45. data/app/assets/images/releaf/globalFieldContainerBgr.png +0 -0
  46. data/app/assets/images/releaf/icons/129.png +0 -0
  47. data/app/assets/images/releaf/icons/130.png +0 -0
  48. data/app/assets/images/releaf/icons/accept.png +0 -0
  49. data/app/assets/images/releaf/icons/add.png +0 -0
  50. data/app/assets/images/releaf/icons/arrow_down.png +0 -0
  51. data/app/assets/images/releaf/icons/arrow_left.png +0 -0
  52. data/app/assets/images/releaf/icons/arrow_refresh.png +0 -0
  53. data/app/assets/images/releaf/icons/arrow_up.png +0 -0
  54. data/app/assets/images/releaf/icons/bin_empty.png +0 -0
  55. data/app/assets/images/releaf/icons/bullet_black.png +0 -0
  56. data/app/assets/images/releaf/icons/bullet_connect.png +0 -0
  57. data/app/assets/images/releaf/icons/bullet_start.png +0 -0
  58. data/app/assets/images/releaf/icons/bullet_tick.png +0 -0
  59. data/app/assets/images/releaf/icons/chrome.png +0 -0
  60. data/app/assets/images/releaf/icons/control_play.png +0 -0
  61. data/app/assets/images/releaf/icons/date.png +0 -0
  62. data/app/assets/images/releaf/icons/delete.png +0 -0
  63. data/app/assets/images/releaf/icons/disk.png +0 -0
  64. data/app/assets/images/releaf/icons/drag-handle.png +0 -0
  65. data/app/assets/images/releaf/icons/error.png +0 -0
  66. data/app/assets/images/releaf/icons/eye.png +0 -0
  67. data/app/assets/images/releaf/icons/firefox.png +0 -0
  68. data/app/assets/images/releaf/icons/google-not-available.gif +0 -0
  69. data/app/assets/images/releaf/icons/google.gif +0 -0
  70. data/app/assets/images/releaf/icons/keyboard.png +0 -0
  71. data/app/assets/images/releaf/icons/left_16.png +0 -0
  72. data/app/assets/images/releaf/icons/link.png +0 -0
  73. data/app/assets/images/releaf/icons/magnifier.png +0 -0
  74. data/app/assets/images/releaf/icons/notAllowed.png +0 -0
  75. data/app/assets/images/releaf/icons/page_white_add.png +0 -0
  76. data/app/assets/images/releaf/icons/page_white_edit.png +0 -0
  77. data/app/assets/images/releaf/icons/page_white_put.png +0 -0
  78. data/app/assets/images/releaf/icons/page_white_text.png +0 -0
  79. data/app/assets/images/releaf/icons/pencil.png +0 -0
  80. data/app/assets/images/releaf/icons/picture.png +0 -0
  81. data/app/assets/images/releaf/icons/right_16.png +0 -0
  82. data/app/assets/images/releaf/icons/tick.png +0 -0
  83. data/app/assets/images/releaf/icons/warning.png +0 -0
  84. data/app/assets/images/releaf/icons/world_go.png +0 -0
  85. data/app/assets/images/releaf/icons/world_link.png +0 -0
  86. data/app/assets/images/releaf/input/autocompleteExpandIcon.png +0 -0
  87. data/app/assets/images/releaf/input/input_bgr.gif +0 -0
  88. data/app/assets/images/releaf/language_root.png +0 -0
  89. data/app/assets/images/releaf/loader.gif +0 -0
  90. data/app/assets/images/releaf/logout.png +0 -0
  91. data/app/assets/images/releaf/main_menu/active_bgr.png +0 -0
  92. data/app/assets/images/releaf/main_menu/bgr.png +0 -0
  93. data/app/assets/images/releaf/main_menu/hover_bgr.png +0 -0
  94. data/app/assets/images/releaf/module.png +0 -0
  95. data/app/assets/images/releaf/panel_layout/active_bgr.png +0 -0
  96. data/app/assets/images/releaf/panel_layout/secondary_panel_horizontal_bgr.png +0 -0
  97. data/app/assets/images/releaf/panel_layout/secondary_panel_vertical_bgr.png +0 -0
  98. data/app/assets/images/releaf/releaf_table/selected_bgr.png +0 -0
  99. data/app/assets/images/releaf/releaf_table/th_bgr.gif +0 -0
  100. data/app/assets/javascripts/releaf/3rd_party/jquery-cookie/README.md +73 -0
  101. data/app/assets/javascripts/releaf/3rd_party/jquery-cookie/jquery.cookie.js +47 -0
  102. data/app/assets/javascripts/releaf/3rd_party/jquery-cookie/server.js +24 -0
  103. data/app/assets/javascripts/releaf/3rd_party/jquery-cookie/test.html +19 -0
  104. data/app/assets/javascripts/releaf/3rd_party/jquery-cookie/test.js +80 -0
  105. data/app/assets/javascripts/releaf/3rd_party/jquery-ui-timepicker-addon.js +1882 -0
  106. data/app/assets/javascripts/releaf/3rd_party/lightbox.js.erb +379 -0
  107. data/app/assets/javascripts/releaf/application.js +14 -0
  108. data/app/assets/javascripts/releaf/controllers/base.js +170 -0
  109. data/app/assets/javascripts/releaf/controllers/releaf/content.js +90 -0
  110. data/app/assets/javascripts/releaf/controllers/releaf/translations.js +31 -0
  111. data/app/assets/javascripts/releaf/include/continuous_scroll.js +321 -0
  112. data/app/assets/javascripts/releaf/include/field.type_autocomplete.js +58 -0
  113. data/app/assets/javascripts/releaf/include/field.type_richtext.js +90 -0
  114. data/app/assets/javascripts/releaf/include/localization.js +12 -0
  115. data/app/assets/javascripts/releaf/include/nested_fields.js +71 -0
  116. data/app/assets/javascripts/releaf/include/sortable.js +27 -0
  117. data/app/assets/javascripts/releaf/lib/request_url.js +183 -0
  118. data/app/assets/stylesheets/releaf/3rd_party/jquery-ui-1.9.2.custom.css.erb +464 -0
  119. data/app/assets/stylesheets/releaf/3rd_party/jquery-ui-timepicker-addon.css +10 -0
  120. data/app/assets/stylesheets/releaf/3rd_party/lightbox.css.erb +157 -0
  121. data/app/assets/stylesheets/releaf/application.css.erb +122 -0
  122. data/app/assets/stylesheets/releaf/controllers/base.css.erb +205 -0
  123. data/app/assets/stylesheets/releaf/controllers/releaf/content.css.erb +416 -0
  124. data/app/assets/stylesheets/releaf/controllers/releaf/sessions.css.scss.erb +116 -0
  125. data/app/assets/stylesheets/releaf/controllers/releaf/translations.css.erb +205 -0
  126. data/app/assets/stylesheets/releaf/include/button.css.erb +176 -0
  127. data/app/assets/stylesheets/releaf/include/field.css.erb +257 -0
  128. data/app/assets/stylesheets/releaf/include/input.css.erb +40 -0
  129. data/app/assets/stylesheets/releaf/include/main_menu.css.erb +66 -0
  130. data/app/assets/stylesheets/releaf/include/pagination.css.erb +29 -0
  131. data/app/assets/stylesheets/releaf/include/panel_layout.css.erb +251 -0
  132. data/app/assets/stylesheets/releaf/include/releaf_table.css.erb +112 -0
  133. data/app/assets/stylesheets/releaf/include/sortable.css.erb +12 -0
  134. data/app/controllers/releaf/admins_controller.rb +48 -0
  135. data/app/controllers/releaf/application_controller.rb +11 -0
  136. data/app/controllers/releaf/base_application_controller.rb +15 -0
  137. data/app/controllers/releaf/base_controller.rb +310 -0
  138. data/app/controllers/releaf/content_controller.rb +166 -0
  139. data/app/controllers/releaf/roles_controller.rb +36 -0
  140. data/app/controllers/releaf/sessions_controller.rb +5 -0
  141. data/app/controllers/releaf/tinymce_assets_controller.rb +26 -0
  142. data/app/controllers/releaf/translations_controller.rb +121 -0
  143. data/app/helpers/releaf/admin_helper.rb +79 -0
  144. data/app/helpers/releaf/application_helper.rb +4 -0
  145. data/app/helpers/releaf/pagination_renderer.rb +44 -0
  146. data/app/helpers/releaf/releaf_devise_helper.rb +8 -0
  147. data/app/models/releaf/admin.rb +51 -0
  148. data/app/models/releaf/node.rb +221 -0
  149. data/app/models/releaf/node_base.rb +25 -0
  150. data/app/models/releaf/role.rb +119 -0
  151. data/app/models/releaf/tinymce_asset.rb +6 -0
  152. data/app/views/layouts/releaf/admin.html.haml +51 -0
  153. data/app/views/releaf/aliases/_edit.body.haml +50 -0
  154. data/app/views/releaf/aliases/_edit.header.haml +19 -0
  155. data/app/views/releaf/aliases/_index.row.haml +5 -0
  156. data/app/views/releaf/aliases/_secondary_panel.haml +13 -0
  157. data/app/views/releaf/base/_edit.body.haml +19 -0
  158. data/app/views/releaf/base/_edit.field.haml +96 -0
  159. data/app/views/releaf/base/_edit.field.type_autocomplete.haml +15 -0
  160. data/app/views/releaf/base/_edit.field.type_checkbox.haml +5 -0
  161. data/app/views/releaf/base/_edit.field.type_date.haml +8 -0
  162. data/app/views/releaf/base/_edit.field.type_datetime.haml +8 -0
  163. data/app/views/releaf/base/_edit.field.type_delete_nested.haml +3 -0
  164. data/app/views/releaf/base/_edit.field.type_file.haml +10 -0
  165. data/app/views/releaf/base/_edit.field.type_image.haml +14 -0
  166. data/app/views/releaf/base/_edit.field.type_link.haml +4 -0
  167. data/app/views/releaf/base/_edit.field.type_password.haml +4 -0
  168. data/app/views/releaf/base/_edit.field.type_richtext.haml +4 -0
  169. data/app/views/releaf/base/_edit.field.type_richtext_i18n.haml +27 -0
  170. data/app/views/releaf/base/_edit.field.type_select.haml +11 -0
  171. data/app/views/releaf/base/_edit.field.type_text.haml +4 -0
  172. data/app/views/releaf/base/_edit.field.type_text_i18n.haml +27 -0
  173. data/app/views/releaf/base/_edit.field.type_textarea.haml +4 -0
  174. data/app/views/releaf/base/_edit.field.type_textarea_i18n.haml +27 -0
  175. data/app/views/releaf/base/_edit.field.type_time.haml +8 -0
  176. data/app/views/releaf/base/_edit.footer.haml +14 -0
  177. data/app/views/releaf/base/_edit.form.haml +4 -0
  178. data/app/views/releaf/base/_edit.has_many_associations.haml +45 -0
  179. data/app/views/releaf/base/_edit.header.haml +3 -0
  180. data/app/views/releaf/base/_index.body.haml +6 -0
  181. data/app/views/releaf/base/_index.cell.haml +19 -0
  182. data/app/views/releaf/base/_index.footer.haml +22 -0
  183. data/app/views/releaf/base/_index.header.haml +4 -0
  184. data/app/views/releaf/base/_index.row.haml +6 -0
  185. data/app/views/releaf/base/_index.search.haml +5 -0
  186. data/app/views/releaf/base/_index.table.haml +8 -0
  187. data/app/views/releaf/base/_secondary_panel.haml +9 -0
  188. data/app/views/releaf/base/_show.body.haml +7 -0
  189. data/app/views/releaf/base/_show.field.haml +78 -0
  190. data/app/views/releaf/base/_show.field.type_html.haml +1 -0
  191. data/app/views/releaf/base/_show.footer.haml +16 -0
  192. data/app/views/releaf/base/_show.header.haml +3 -0
  193. data/app/views/releaf/base/confirm_destroy.haml +10 -0
  194. data/app/views/releaf/base/edit.haml +1 -0
  195. data/app/views/releaf/base/index.haml +3 -0
  196. data/app/views/releaf/base/new.haml +1 -0
  197. data/app/views/releaf/base/show.haml +3 -0
  198. data/app/views/releaf/content/_edit.body.haml +45 -0
  199. data/app/views/releaf/content/_edit.content_fields.haml +19 -0
  200. data/app/views/releaf/content/_edit.slug.haml +12 -0
  201. data/app/views/releaf/content/_get_content_form.haml +7 -0
  202. data/app/views/releaf/content/_secondary_panel.haml +3 -0
  203. data/app/views/releaf/content/_show.field.content.haml +11 -0
  204. data/app/views/releaf/content/_tree_level.haml +16 -0
  205. data/app/views/releaf/content/ajax.new.haml +3 -0
  206. data/app/views/releaf/content/index.haml +0 -0
  207. data/app/views/releaf/roles/_edit.field.admins.haml +0 -0
  208. data/app/views/releaf/roles/_edit.field.permissions.haml +5 -0
  209. data/app/views/releaf/roles/_show.field.default.haml +6 -0
  210. data/app/views/releaf/roles/_show.field.permissions.haml +11 -0
  211. data/app/views/releaf/sessions/new.html.haml +17 -0
  212. data/app/views/releaf/translations/_edit.body.haml +50 -0
  213. data/app/views/releaf/translations/_edit.header.haml +19 -0
  214. data/app/views/releaf/translations/_index.row.haml +5 -0
  215. data/app/views/releaf/translations/_secondary_panel.haml +13 -0
  216. data/bin/releaf +25 -0
  217. data/lib/generators/releaf/install_generator.rb +87 -0
  218. data/lib/generators/releaf/templates/config/common_fields.yml.example +17 -0
  219. data/lib/generators/releaf/templates/controllers/home_controller.rb +4 -0
  220. data/lib/generators/releaf/templates/images/3rd_party/jquery_ui/smoothness/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  221. data/lib/generators/releaf/templates/images/3rd_party/jquery_ui/smoothness/ui-bg_flat_75_ffffff_40x100.png +0 -0
  222. data/lib/generators/releaf/templates/images/3rd_party/jquery_ui/smoothness/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  223. data/lib/generators/releaf/templates/images/3rd_party/jquery_ui/smoothness/ui-bg_glass_65_ffffff_1x400.png +0 -0
  224. data/lib/generators/releaf/templates/images/3rd_party/jquery_ui/smoothness/ui-bg_glass_75_dadada_1x400.png +0 -0
  225. data/lib/generators/releaf/templates/images/3rd_party/jquery_ui/smoothness/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  226. data/lib/generators/releaf/templates/images/3rd_party/jquery_ui/smoothness/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  227. data/lib/generators/releaf/templates/images/3rd_party/jquery_ui/smoothness/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  228. data/lib/generators/releaf/templates/images/3rd_party/jquery_ui/smoothness/ui-icons_222222_256x240.png +0 -0
  229. data/lib/generators/releaf/templates/images/3rd_party/jquery_ui/smoothness/ui-icons_2e83ff_256x240.png +0 -0
  230. data/lib/generators/releaf/templates/images/3rd_party/jquery_ui/smoothness/ui-icons_454545_256x240.png +0 -0
  231. data/lib/generators/releaf/templates/images/3rd_party/jquery_ui/smoothness/ui-icons_888888_256x240.png +0 -0
  232. data/lib/generators/releaf/templates/images/3rd_party/jquery_ui/smoothness/ui-icons_cd0a0a_256x240.png +0 -0
  233. data/lib/generators/releaf/templates/images/3rd_party/lightbox/close.png +0 -0
  234. data/lib/generators/releaf/templates/images/3rd_party/lightbox/loading.gif +0 -0
  235. data/lib/generators/releaf/templates/images/3rd_party/lightbox/next.png +0 -0
  236. data/lib/generators/releaf/templates/images/3rd_party/lightbox/prev.png +0 -0
  237. data/lib/generators/releaf/templates/initializers/releaf.rb +59 -0
  238. data/lib/generators/releaf/templates/initializers/releaf_i18n.rb +8 -0
  239. data/lib/generators/releaf/templates/initializers/releaf_store_current_template.rb +25 -0
  240. data/lib/generators/releaf/templates/javascripts/3rd_party/jquery_ui.js +14850 -0
  241. data/lib/generators/releaf/templates/javascripts/3rd_party/lightbox.js.erb +379 -0
  242. data/lib/generators/releaf/templates/javascripts/application.js +15 -0
  243. data/lib/generators/releaf/templates/javascripts/lib/js_check.js +8 -0
  244. data/lib/generators/releaf/templates/javascripts/lib/request_url.js +169 -0
  245. data/lib/generators/releaf/templates/javascripts/lib/sortable.js +29 -0
  246. data/lib/generators/releaf/templates/migrations/create_releaf_admins.rb +53 -0
  247. data/lib/generators/releaf/templates/migrations/create_releaf_nodes.rb +25 -0
  248. data/lib/generators/releaf/templates/migrations/create_releaf_roles.rb +11 -0
  249. data/lib/generators/releaf/templates/migrations/create_releaf_tinymce_assets.rb +10 -0
  250. data/lib/generators/releaf/templates/migrations/create_releaf_translations.rb +31 -0
  251. data/lib/generators/releaf/templates/models/admin_ability.rb +51 -0
  252. data/lib/generators/releaf/templates/seeds.rb +64 -0
  253. data/lib/generators/releaf/templates/stylesheets/3rd_party/jquery_ui/smoothness.css.erb +1174 -0
  254. data/lib/generators/releaf/templates/stylesheets/3rd_party/lightbox.css.erb +157 -0
  255. data/lib/generators/releaf/templates/stylesheets/3rd_party/reset.css +48 -0
  256. data/lib/generators/releaf/templates/stylesheets/application.scss +15 -0
  257. data/lib/generators/releaf/templates/stylesheets/style.scss +45 -0
  258. data/lib/generators/releaf/templates/views/home/index.html.haml +1 -0
  259. data/lib/generators/releaf/templates/views/layouts/application.html.haml +26 -0
  260. data/lib/i18n/backend/releaf.rb +96 -0
  261. data/lib/i18n/backend/releaf/translation.rb +56 -0
  262. data/lib/i18n/backend/releaf/translation_data.rb +32 -0
  263. data/lib/i18n/backend/releaf/translation_group.rb +30 -0
  264. data/lib/i18n/releaf.rb +1 -0
  265. data/lib/releaf.rb +30 -0
  266. data/lib/releaf/engine.rb +4 -0
  267. data/lib/releaf/slug.rb +79 -0
  268. data/lib/releaf/version.rb +3 -0
  269. data/lib/tasks/releaf_tasks.rake +4 -0
  270. data/spec/dummy/README.rdoc +261 -0
  271. data/spec/dummy/Rakefile +7 -0
  272. data/spec/dummy/app/assets/images/rails.png +0 -0
  273. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  274. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  275. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  276. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  277. data/spec/dummy/app/models/admin_ability.rb +51 -0
  278. data/spec/dummy/app/models/settings.rb +2 -0
  279. data/spec/dummy/app/views/layouts/application.html.haml +10 -0
  280. data/spec/dummy/config.ru +4 -0
  281. data/spec/dummy/config/application.rb +68 -0
  282. data/spec/dummy/config/boot.rb +6 -0
  283. data/spec/dummy/config/common_fields.yml.example +17 -0
  284. data/spec/dummy/config/database.yml +42 -0
  285. data/spec/dummy/config/environment.rb +5 -0
  286. data/spec/dummy/config/environments/development.rb +37 -0
  287. data/spec/dummy/config/environments/production.rb +67 -0
  288. data/spec/dummy/config/environments/test.rb +37 -0
  289. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  290. data/spec/dummy/config/initializers/devise.rb +232 -0
  291. data/spec/dummy/config/initializers/dragonfly.rb +1 -0
  292. data/spec/dummy/config/initializers/inflections.rb +15 -0
  293. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  294. data/spec/dummy/config/initializers/releaf.rb +59 -0
  295. data/spec/dummy/config/initializers/releaf_i18n.rb +8 -0
  296. data/spec/dummy/config/initializers/releaf_store_current_template.rb +25 -0
  297. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  298. data/spec/dummy/config/initializers/session_store.rb +8 -0
  299. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  300. data/spec/dummy/config/locales/devise.en.yml +58 -0
  301. data/spec/dummy/config/locales/en.yml +5 -0
  302. data/spec/dummy/config/routes.rb +11 -0
  303. data/spec/dummy/db/migrate/20130204164516_create_settings.rb +17 -0
  304. data/spec/dummy/db/migrate/20130204164523_create_releaf_nodes.rb +25 -0
  305. data/spec/dummy/db/migrate/20130204164524_create_releaf_roles.rb +11 -0
  306. data/spec/dummy/db/migrate/20130204164525_create_releaf_translations.rb +31 -0
  307. data/spec/dummy/db/migrate/20130204164526_create_releaf_admins.rb +53 -0
  308. data/spec/dummy/db/schema.rb +112 -0
  309. data/spec/dummy/db/seeds.rb +64 -0
  310. data/spec/dummy/doc/README_FOR_APP +2 -0
  311. data/spec/dummy/log/development.log +74 -0
  312. data/spec/dummy/log/test.log +129 -0
  313. data/spec/dummy/public/404.html +26 -0
  314. data/spec/dummy/public/422.html +26 -0
  315. data/spec/dummy/public/500.html +25 -0
  316. data/spec/dummy/public/favicon.ico +0 -0
  317. data/spec/dummy/script/rails +6 -0
  318. data/spec/dummy/tmp/cache/9C5/660/settings%3Ai18n_updated_at +1 -0
  319. data/spec/factories/factories.rb +24 -0
  320. data/spec/features/admin_spec.rb +41 -0
  321. data/spec/spec_helper.rb +23 -0
  322. data/templates/releaf/installer.rb +196 -0
  323. metadata +777 -0
@@ -0,0 +1,12 @@
1
+ .list[data-sortable] > .item {
2
+ position: relative;
3
+ }
4
+
5
+ .list[data-sortable] > .item > .handle {
6
+ top: 5px;
7
+ right: 50px;
8
+ width: 24px;
9
+ height: 24px;
10
+ position: absolute;
11
+ background: url(<%= asset_path('releaf/icons/drag-handle.png') %>) center center no-repeat;
12
+ }
@@ -0,0 +1,48 @@
1
+ module Releaf
2
+ class AdminsController < BaseController
3
+
4
+ def current_object_class
5
+ Releaf::Admin
6
+ end
7
+
8
+ def columns( view = nil )
9
+ fields = super - %w[
10
+ authentication_token
11
+ confirmation_sent_at
12
+ confirmation_token
13
+ confirmed_at
14
+ current_sign_in_at
15
+ current_sign_in_ip
16
+ encrypted_password
17
+ failed_attempts
18
+ last_sign_in_at
19
+ last_sign_in_ip
20
+ locked_at
21
+ remember_created_at
22
+ reset_password_sent_at
23
+ reset_password_token
24
+ sign_in_count
25
+ unconfirmed_email
26
+ unlock_token
27
+ ]
28
+
29
+ if view == 'index'
30
+ fields -= ['avatar_uid']
31
+ end
32
+
33
+ if %w[new create edit update].include? view
34
+ fields += ['password', 'password_confirmation']
35
+ end
36
+
37
+ return fields
38
+ end
39
+
40
+ protected
41
+
42
+ def admin_params( action )
43
+ return [] unless [:create, :update].include? action
44
+ %w[name surname role_id email password password_confirmation phone avatar retained_avatar]
45
+ end
46
+
47
+ end
48
+ end
@@ -0,0 +1,11 @@
1
+ module Releaf
2
+ class ApplicationController < BaseController
3
+ # I've no idea where this route to releaf/application.index comes from
4
+
5
+ def index
6
+ respond_to do |format|
7
+ format.html { redirect_to url_for(:action => 'index', :controller => 'releaf/content') }
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ module Releaf
2
+ class BaseApplicationController < ActionController::Base
3
+ # include ReleafDeviseHelper
4
+
5
+ before_filter "authenticate_#{ReleafDeviseHelper.devise_admin_model_name}!"
6
+ # check_authorization :unless => :devise_controller?
7
+ layout Releaf.layout
8
+ protect_from_forgery
9
+
10
+ def current_ability
11
+ @current_ability ||= AdminAbility.new(self.send("current_#{ReleafDeviseHelper.devise_admin_model_name}"))
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,310 @@
1
+ module Releaf
2
+ class BaseController < BaseApplicationController
3
+ before_filter do
4
+ filter_templates
5
+ set_locale
6
+ setup
7
+ end
8
+
9
+ def setup
10
+ @controller = self # this is used later in views
11
+ @features = { :create => true, :show => true, :edit => true, :destroy => true}
12
+ @panel_layout = true
13
+ @continuous_scroll = false
14
+ @items_per_page = 40
15
+ end
16
+
17
+ def secondary_panel
18
+ return '' unless @panel_layout
19
+ @_secondary_panel ||= render_to_string( :partial => "secondary_panel", :layout => false, :locals => build_secondary_panel_variables)
20
+ end
21
+
22
+ def build_secondary_panel_variables
23
+ menu_item_name = self.class.name.underscore.sub(/_controller$/, '')
24
+
25
+ # if this item is defined in main menu, then there will be no altmenu
26
+ # defined for it in alt menu, instead this method should be overriden in
27
+ # particular controller to return structure needed to render alt menu
28
+ return {} if Releaf.main_menu.include? menu_item_name
29
+
30
+ # if this item was not found in main menu, then we need to find it in one
31
+ # of alt menus. This way we'll know which alt menu to render.
32
+ base_menus = Releaf.main_menu.reject { |item| item[0] != '*' }
33
+ base_menus.each do |base_menu_name|
34
+ if view_context.base_menu_items(base_menu_name).include?(menu_item_name)
35
+ build_menu = { :menu => {} }
36
+
37
+ base_menu = Releaf.base_menu[base_menu_name]
38
+
39
+ base_menu.each do |section|
40
+ section_name = section[0].to_sym
41
+ build_menu[:menu][section_name] = []
42
+ section[1].each do |item|
43
+ build_menu[:menu][section_name].push({:controller => item.split(/#/, 2).first})
44
+ end
45
+ end
46
+
47
+ return build_menu
48
+ end
49
+ end
50
+
51
+ # coundn't find current controller in base_menu
52
+ return {}
53
+ end
54
+
55
+ def current_object_class
56
+ @_current_object_class ||= self.class.name.split('::').last.sub(/\s?Controller$/, '').classify.constantize
57
+ end
58
+
59
+ def current_object_class_name
60
+ current_object_class.name.underscore.tr('/', '_')
61
+ end
62
+
63
+ def columns view=params[:action]
64
+ cols = current_object_class.column_names - %w[id created_at updated_at encrypted_password position]
65
+ unless %w[new edit update create].include? view
66
+ cols -= %w[password password_confirmation]
67
+ end
68
+ return cols
69
+ end
70
+
71
+ def list_action
72
+ if !cookies['base_module:list_action'].blank?
73
+ feature = cookies['base_module:list_action']
74
+ if feature == 'confirm_destroy'
75
+ feature = 'destroy'
76
+ end
77
+ feature = feature.to_sym
78
+ if !@features[ feature ].blank?
79
+ return cookies['base_module:list_action']
80
+ end
81
+ end
82
+ if !@features[ :show ].blank?
83
+ return 'show'
84
+ end
85
+ return 'edit';
86
+ end
87
+
88
+ def has_template( name )
89
+ lookup_context.template_exists?( name, lookup_context.prefixes, false )
90
+ end
91
+
92
+ def find_parent_template( name )
93
+ lookup_context.find_template( name, lookup_context.prefixes.slice( 1, lookup_context.prefixes.length ), false )
94
+ end
95
+
96
+ def render_parent_template( name, locals = {} )
97
+ template = find_parent_template( name )
98
+ if template.blank?
99
+ return 'blank'
100
+ end
101
+ arguments = { :layout => false, :locals => locals, :template => template.virtual_path }
102
+ return render_to_string( arguments ).html_safe
103
+ end
104
+
105
+ def input_type_for( column_type, name )
106
+ input_type = 'text'
107
+ case column_type
108
+ when :boolean
109
+ input_type = 'checkbox'
110
+ when :text
111
+ input_type = 'textarea'
112
+ if name.end_with?( '_html' )
113
+ input_type = 'richtext'
114
+ end
115
+ end
116
+ return input_type
117
+ end
118
+
119
+ # actions
120
+
121
+ def autocomplete
122
+ authorize! :edit, current_object_class
123
+
124
+ c_obj = current_object_class
125
+
126
+ if params[:query_field] and params[:q] and params[:field] #and params[:field] =~ /_id\z/ and c_obj.column_names.include?(params[:field]) and c_obj.respond_to?(:reflect_on_association) and c_obj.reflect_on_association(params[:field].sub(/_id\z/, '').to_sym)
127
+
128
+ obj = c_obj.reflect_on_association(params[:field].sub(/_id\z/, '').to_sym).klass
129
+ obj_fields = obj.column_names
130
+
131
+ sql = []
132
+ sql_params = {}
133
+
134
+ params[:q].split(' ').each_with_index do |part, i|
135
+ sql.push "#{params[:query_field]} LIKE :part#{i}"
136
+ sql_params[:"part#{i}"] = "%#{part}%"
137
+ end
138
+
139
+ order_by = nil
140
+
141
+ if params[:order]
142
+ order_by = []
143
+
144
+ params[:order].split(',').each do |order_part|
145
+ if obj_fields.include? order_part.sub(/ (asc|desc)\z/i, '')
146
+ order_by.push order_part
147
+ end
148
+ end
149
+ end
150
+
151
+ order_by = [params[:query_field],'id'] if order_by.blank?
152
+
153
+ query = obj.where(sql.join(' AND '), sql_params).order(order_by.join(', '))
154
+
155
+ matching_items_count = query.count
156
+ list = query.limit(20)
157
+
158
+ @items = []
159
+ list.each do |item|
160
+ @items.push({ :id => item.id, :text => item.to_text })
161
+ end
162
+
163
+ respond_to do |format|
164
+ format.json { render :json => {:matching_items_count => matching_items_count, :query => params[:q], :results => @items } }
165
+ end
166
+
167
+ else
168
+ respond_to do |format|
169
+ format.json { raise }
170
+ end
171
+ end
172
+ end
173
+
174
+ def index
175
+ authorize! :list, current_object_class
176
+ if current_object_class.respond_to?( :filter )
177
+ @list = current_object_class.filter(:search => params[:search])
178
+ else
179
+ @list = current_object_class
180
+ end
181
+ @list = @list.page( params[:page] ).per_page( @items_per_page )
182
+ if !params[:ajax].blank?
183
+ render :layout => false
184
+ end
185
+ end
186
+
187
+ def urls
188
+ respond_to do |format|
189
+ format.json do
190
+ json = {}
191
+ params[:ids].each do |id|
192
+ json[id] = url_for( :action => params[:to_action], :id => id, :only_path => true )
193
+ end
194
+ render :json => json, :layout => false
195
+ end
196
+ end
197
+ end
198
+
199
+ def new
200
+ authorize! :create, current_object_class
201
+ @item = current_object_class.new
202
+ end
203
+
204
+ def show
205
+ @item = current_object_class.find(params[:id])
206
+ authorize! :show, @item
207
+ end
208
+
209
+ def edit
210
+ @item = current_object_class.find(params[:id])
211
+ authorize! :edit, @item
212
+ end
213
+
214
+ def create
215
+ authorize! :create, current_object_class
216
+ @item = current_object_class.new
217
+
218
+ if self.respond_to?(:"#{current_object_class_name}_params")
219
+ variables = params.require( current_object_class_name ).permit( *self.send(:"#{current_object_class_name}_params", :update) )
220
+ elsif @item.respond_to? :allowed_params
221
+ variables = params.require( current_object_class_name ).permit( *@item.allowed_params(:create) )
222
+ else
223
+ variables = params.require( current_object_class_name ).permit( *current_object_class.column_names )
224
+ end
225
+
226
+ @item.assign_attributes( variables )
227
+
228
+ respond_to do |format|
229
+ if @item.save
230
+ format.html { redirect_to url_for( :action => 'show', :id => @item.id ) }
231
+ else
232
+ format.html { render :action => "new" }
233
+ end
234
+ end
235
+ end
236
+
237
+ def update
238
+ @item = current_object_class.find(params[:id])
239
+ authorize! :edit, @item
240
+
241
+ if self.respond_to?(:"#{current_object_class_name}_params")
242
+ variables = params.require( current_object_class_name ).permit( *self.send(:"#{current_object_class_name}_params", :update) )
243
+ elsif @item.respond_to? :allowed_params
244
+ variables = params.require( current_object_class_name ).permit( *@item.allowed_params(:update) )
245
+ else
246
+ variables = params.require( current_object_class_name ).permit( *current_object_class.column_names )
247
+ end
248
+
249
+ respond_to do |format|
250
+ if @item.update_attributes( variables )
251
+ format.html { redirect_to url_for( :action => 'show', :id => @item.id ) }
252
+ else
253
+ format.html { render :action => "edit" }
254
+ end
255
+ end
256
+ end
257
+
258
+ def confirm_destroy
259
+ @item = current_object_class.find(params[:id])
260
+ authorize! :destroy, @item
261
+ end
262
+
263
+ def destroy
264
+ @item = current_object_class.find(params[:id])
265
+ authorize! :destroy, @item
266
+ @item.destroy
267
+
268
+ respond_to do |format|
269
+ format.html { redirect_to url_for( :action => 'index' ) }
270
+ end
271
+ end
272
+
273
+
274
+ private
275
+
276
+ def set_locale
277
+ I18n.locale = if params[:locale] && Settings.i18n_locales.include?(params[:locale])
278
+ params[:locale]
279
+ elsif cookies[:locale] && Settings.i18n_locales.include?(cookies[:locale])
280
+ cookies[:locale]
281
+ else
282
+ I18n.default_locale
283
+ end
284
+ end
285
+
286
+ def filter_templates
287
+ filter_templates_from_hash params
288
+ end
289
+
290
+ def filter_templates_from_array arr
291
+ return unless arr.is_a? Array
292
+ arr.each do |item|
293
+ if item.is_a? Hash
294
+ filter_templates_from_hash item
295
+ elsif item.is_a? Array
296
+ filter_templates_from_array item
297
+ end
298
+ end
299
+ end
300
+
301
+ def filter_templates_from_hash hsk
302
+ return unless hsk.is_a? Hash
303
+ hsk.delete :_template_
304
+ hsk.delete '_template_'
305
+
306
+ filter_templates_from_array hsk.values
307
+ end
308
+
309
+ end
310
+ end
@@ -0,0 +1,166 @@
1
+ module Releaf
2
+ class ContentController < BaseController
3
+
4
+ def columns( view = nil )
5
+ if view == 'show'
6
+ return %w[name parent_id visible protected content]
7
+ else
8
+ return super
9
+ end
10
+ end
11
+
12
+ def build_secondary_panel_variables
13
+ @nodes = Node.roots
14
+ super
15
+ end
16
+
17
+ def index
18
+ authorize! :index, Node
19
+ respond_to do |format|
20
+ format.html
21
+ end
22
+ end
23
+
24
+ def create
25
+ content_type = _node_params[:content_type].constantize
26
+ authorize! :create, content_type
27
+ @item = current_object_class.new(_node_params)
28
+ @item.assign_attributes(_node_common_fields_params)
29
+
30
+ respond_to do |format|
31
+ if @item.save
32
+ format.html { redirect_to url_for(:action => "index", :controller => 'content')}
33
+ else
34
+ form_extras
35
+ @order_nodes = Node.where(:parent_id => (params[:parent_id] ? params[:parent_id] : nil))
36
+ format.html { render action: "new" }
37
+ end
38
+ end
39
+ end
40
+
41
+ def generate_url
42
+ tmp_item = nil
43
+
44
+ if params[:id]
45
+ tmp_item = Node.find(params[:id])
46
+ elsif params[:parent_id].blank? == false
47
+ parent = Node.find(params[:parent_id])
48
+ tmp_item = parent.children.new
49
+ else
50
+ tmp_item = Node.new
51
+ end
52
+
53
+ tmp_item.name = params[:name]
54
+ tmp_item.slug = nil
55
+ # FIXME calling private method
56
+ tmp_item.send(:ensure_unique_url)
57
+
58
+ respond_to do |format|
59
+ format.js { render :text => tmp_item.slug }
60
+ end
61
+ end
62
+
63
+ def update
64
+ @item = current_object_class.find(params[:id])
65
+ authorize! :edit, @item
66
+
67
+ form_extras
68
+ @order_nodes = Node.where(:parent_id => (@item.parent_id ? @item.parent_id : nil)).where('id != :id', :id => params[:id])
69
+
70
+ @item.assign_attributes(_node_params)
71
+ @item.assign_attributes(_node_common_fields_params)
72
+
73
+
74
+ respond_to do |format|
75
+ if @item.save
76
+ format.html { redirect_to url_for(:action => "edit") }
77
+ else
78
+ format.html { render action: "edit" }
79
+ end
80
+ end
81
+ end
82
+
83
+ def new
84
+ authorize! :create, current_object_class
85
+ unless params[:ajax] == '1'
86
+ super
87
+ @order_nodes = Node.where(:parent_id => (params[:parent_id] ? params[:parent_id] : nil))
88
+ @position = 1
89
+ @item.parent_id = params[:parent_id]
90
+ form_extras
91
+ else
92
+ Rails.application.eager_load!
93
+ get_base_models
94
+ render 'ajax.new', :layout => nil
95
+ end
96
+ end
97
+
98
+ def edit
99
+ super
100
+ @order_nodes = Node.where(:parent_id => (@item.parent_id ? @item.parent_id : nil)).where('id != :id', :id => params[:id])
101
+
102
+ if @item.higher_item
103
+ @position = @item.higher_item.position
104
+ else
105
+ @position = 1
106
+ end
107
+
108
+ form_extras
109
+ end
110
+
111
+ def get_content_form
112
+ Rails.application.eager_load!
113
+ raise ArgumentError unless NodeBase.node_classes.map { |nc| nc.name }.include? params[:content_type]
114
+ @node = current_object_class.find(params[:id])
115
+ authorize! :edit, @item
116
+
117
+ @item = params[:content_type].constantize.new
118
+
119
+ respond_to do |format|
120
+ format.html { render :partial => 'get_content_form', :layout => false }
121
+ end
122
+
123
+ end
124
+
125
+
126
+ def current_object_class
127
+ Node
128
+ end
129
+
130
+ protected
131
+
132
+ def _node_common_fields_params
133
+ allowed_params = (@item.common_field_names).map { |f| f.sub(/_uid$/, '') }
134
+ params.require(current_object_class_name).permit(*allowed_params)
135
+ end
136
+
137
+ def _node_params
138
+ allowed_params = (%w[parent_id name content_type slug position data visible protected content_object_attributes]).map { |f| f.sub(/_uid$/, '') }
139
+ params.require(current_object_class_name).permit(*allowed_params)
140
+ end
141
+
142
+ private
143
+
144
+ def form_extras
145
+ Rails.application.eager_load!
146
+ get_base_models
147
+
148
+ new_content_if_needed
149
+ end
150
+
151
+ def node_params(action)
152
+ # make sure none of actions, that are defined by BaseController can update item
153
+ []
154
+ end
155
+
156
+ def new_content_if_needed
157
+ return if @item.content
158
+ @item.content = @item.content_type.constantize.new if get_base_models.map { |bm| bm.name }.include? @item.content_type
159
+ end
160
+
161
+ def get_base_models
162
+ @base_models ||= NodeBase.node_classes
163
+ end
164
+
165
+ end
166
+ end