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,36 @@
1
+ module Releaf
2
+ class RolesController < BaseController
3
+
4
+ def current_object_class
5
+ Releaf::Role
6
+ end
7
+
8
+ def columns( view = nil )
9
+ fields = (super(view) - ['default']).insert(1, 'default')
10
+ if view == 'index'
11
+ fields - ['permissions'] + ['admin_permission']
12
+ else
13
+ fields
14
+ end
15
+ end
16
+
17
+ protected
18
+
19
+ def role_params( action )
20
+ return [] unless [:update, :create].include? action
21
+
22
+ fields = ['name', 'default']
23
+ AdminAbility::PERMISSIONS.each do |permission|
24
+ if permission.is_a? String
25
+ fields.push "#{permission}_permission"
26
+ elsif permission.is_a? Array
27
+ fields.push "#{permission[0]}_permissions"
28
+ else
29
+ raise RuntimeError, 'invalid permissions'
30
+ end
31
+ end
32
+ return fields
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,5 @@
1
+ module Releaf
2
+ class SessionsController < Devise::SessionsController
3
+ layout "releaf/admin"
4
+ end
5
+ end
@@ -0,0 +1,26 @@
1
+ module Releaf
2
+ class TinymceAssetsController < BaseController
3
+ skip_authorization_check :only => [:create]
4
+
5
+ def create
6
+ asset = TinymceAsset.new
7
+ asset.file_type = params[:file].content_type
8
+ asset.file = params[:file]
9
+ asset.save!
10
+
11
+
12
+ render json: {
13
+ image: {
14
+ # url: serve_tinymce_asset_path(asset)
15
+ url: asset.file.url
16
+ }
17
+ }, content_type: "text/html"
18
+ end
19
+
20
+ # def serve
21
+ # asset = TinymceAsset.find(params[:id])
22
+ # send_file asset.file.path, :type => asset.file_type
23
+ # end
24
+
25
+ end
26
+ end
@@ -0,0 +1,121 @@
1
+ module Releaf
2
+ class TranslationsController < BaseController
3
+
4
+ def setup
5
+ super
6
+ @object_class = I18n::Backend::Releaf::TranslationGroup
7
+ @features[:show] = false
8
+ @continuous_scroll = true
9
+ end
10
+
11
+ def current_object_class
12
+ @object_class
13
+ end
14
+
15
+ def build_secondary_panel_variables
16
+ @groups = I18n::Backend::Releaf::TranslationGroup.order(:scope).all
17
+ super
18
+ end
19
+
20
+ def columns( view = nil )
21
+ return super + (Settings.i18n_locales || [])
22
+ end
23
+
24
+ def index
25
+ authorize! :manage, I18n::Backend::Releaf::Translation
26
+ @list = @object_class = I18n::Backend::Releaf::Translation.includes(:translation_data).filter(:search => params[:search])
27
+ if !params[:ajax].blank?
28
+ render :layout => false
29
+ end
30
+ end
31
+
32
+ def edit
33
+ authorize! :manage, I18n::Backend::Releaf::Translation
34
+ @item = current_object_class.find(params[:id])
35
+ end
36
+
37
+ def show
38
+ authorize! :manage, I18n::Backend::Releaf::Translation
39
+ redirect_to url_for( :action => "edit", :id => params[:id] )
40
+ end
41
+
42
+ def create
43
+ authorize! :manage, I18n::Backend::Releaf::Translation
44
+ @item = current_object_class.new(item_params)
45
+
46
+ respond_to do |format|
47
+ if @item.save
48
+ update_translations
49
+ Settings.i18n_updated_at = Time.now
50
+ format.html { redirect_to url_for(:action => "edit", :id => @item.id) }
51
+ else
52
+ format.html { render :action => "new" }
53
+ end
54
+ end
55
+ end
56
+
57
+ def update
58
+ authorize! :manage, I18n::Backend::Releaf::Translation
59
+ @item = current_object_class.find(params[:id])
60
+
61
+ unless params[:translations].blank?
62
+ ids_to_keep = update_translations
63
+ @item.translations.where('id NOT IN (?)', ids_to_keep).destroy_all
64
+ else
65
+ @item.translations.destroy_all
66
+ end
67
+ Settings.i18n_updated_at = Time.now
68
+
69
+
70
+ respond_to do |format|
71
+ format.html { redirect_to url_for(:action => "edit", :id => @item.id) }
72
+ end
73
+ end
74
+
75
+
76
+ private
77
+
78
+ def update_translations
79
+ return [] if params[:translations].blank?
80
+
81
+ ids_to_keep = [];
82
+ params[:translations].each_pair do |id,t|
83
+ next if t['key'].blank?
84
+
85
+ translation = nil
86
+ if id =~ /\A\d+\z/
87
+ translation = I18n::Backend::Releaf::Translation.find(id)
88
+ else
89
+ translation = @item.translations.new
90
+ end
91
+
92
+ translation.key = params[:translation_group][:scope] + '.' + t['key']
93
+ translation.save
94
+
95
+
96
+ unless id =~ /\A\d+\z/
97
+ id = translation.id
98
+ end
99
+
100
+ ids_to_keep.push id
101
+
102
+
103
+ (Settings.i18n_locales || []).each do |locale|
104
+ translation_data = I18n::Backend::Releaf::TranslationData.find_or_initialize_by_translation_id_and_lang(id, locale)
105
+ unless t['localization'][locale].blank?
106
+ translation_data.localization = t['localization'][locale]
107
+ translation_data.save
108
+ else
109
+ translation_data.destroy
110
+ end
111
+ end
112
+ end
113
+ return ids_to_keep
114
+ end
115
+
116
+ def item_params
117
+ params.require(current_object_class_name).permit(:scope)
118
+ end
119
+
120
+ end
121
+ end
@@ -0,0 +1,79 @@
1
+ module Releaf
2
+ module AdminHelper
3
+
4
+ def polymorphic_association_names obj
5
+ poly_asoc = obj.class.reflect_on_all_associations.map { |r| r.options[:polymorphic] ? r.name : nil }
6
+ poly_asoc.delete(nil)
7
+ poly_asoc.map { |pa| pa.to_s }
8
+ end
9
+
10
+ def has_many_association_names obj
11
+ reflect_all_asoc = obj.reflect_on_all_associations(:has_many)
12
+ has_many_asoc_names = reflect_all_asoc.map { |asoc| asoc.name }
13
+
14
+ reflect_all_asoc.each do |asoc|
15
+ next unless asoc.options.has_key?(:through)
16
+ has_many_asoc_names.delete(asoc.name)
17
+ end
18
+
19
+ # don't show translations associaton which is created by globalize3
20
+ has_many_asoc_names - [:translations]
21
+ end
22
+
23
+
24
+ def is_this_main_menu_item_active? releaf_main_menu_item
25
+ _check_if_this_is_valid_releaf_main_menu_item releaf_main_menu_item
26
+
27
+ unless releaf_main_menu_item.start_with?('*')
28
+ return params[:controller] == _menu_item_controller_name(releaf_main_menu_item)
29
+ else
30
+ return base_menu_items(releaf_main_menu_item).include? params[:controller]
31
+ end
32
+ end
33
+
34
+ def main_menu_item_url releaf_main_menu_item, options={}
35
+ # TODO implement options
36
+ _check_if_this_is_valid_releaf_main_menu_item releaf_main_menu_item
37
+
38
+ unless releaf_main_menu_item.start_with?('*')
39
+ return url_for(:controller => _menu_item_controller_name(releaf_main_menu_item), :action => _menu_item_action_name(releaf_main_menu_item))
40
+ else
41
+ submenu_items = Releaf.base_menu[releaf_main_menu_item]
42
+
43
+ # TODO find first item in submenu_items list, that current admin can access
44
+ first_accessible_item = submenu_items[0][1][0] # currently will find first
45
+
46
+ return url_for(:controller => _menu_item_controller_name(first_accessible_item), :action => _menu_item_action_name(first_accessible_item))
47
+ end
48
+ end
49
+
50
+ def base_menu_items base_menu_name
51
+ submenu_items = Releaf.base_menu[base_menu_name]
52
+ return [] if submenu_items.blank?
53
+
54
+ all_submenu_items = []
55
+ submenu_items.each do |group|
56
+ group[1].each { |item| all_submenu_items.push _menu_item_controller_name(item) }
57
+ end
58
+
59
+ return all_submenu_items
60
+ end
61
+
62
+ private
63
+
64
+ def _menu_item_controller_name releaf_menu_item
65
+ releaf_menu_item.split(/#/, 2).first
66
+ end
67
+
68
+ def _menu_item_action_name releaf_menu_item
69
+ releaf_menu_item.split(/#/, 2)[2] || 'index'
70
+ end
71
+
72
+ def _check_if_this_is_valid_releaf_main_menu_item item
73
+ raise ArgumentError, "not a string" unless item.is_a? String
74
+ raise ArgumentError, "no such Releaf main menu item" unless Releaf.main_menu.include? item
75
+ end
76
+
77
+
78
+ end
79
+ end
@@ -0,0 +1,4 @@
1
+ module Releaf
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,44 @@
1
+ module Releaf
2
+ module PaginationRenderer
3
+ # This class does the heavy lifting of actually building the pagination
4
+ # links. It is used by +will_paginate+ helper internally.
5
+
6
+ # This is used in admin/base/_index.footer view
7
+
8
+ class LinkRenderer < WillPaginate::ActionView::LinkRenderer
9
+
10
+ protected
11
+
12
+ def page_number(page)
13
+ unless page == current_page
14
+ link(page, page, :rel => rel_value(page), :class => 'button')
15
+ else
16
+ tag(:em, "<span>#{page}</span>", :class => 'current active button')
17
+ end
18
+ end
19
+
20
+ def gap
21
+ text = '&hellip;'
22
+ %(<span class="gap button disabled">#{text}</span>)
23
+ end
24
+
25
+ def previous_or_next_page(page, text, classname)
26
+ if page
27
+ link(text, page, :class => classname + ' button')
28
+ else
29
+ tag(:span, "<span>#{text}</span>", :class => classname + ' button disabled')
30
+ end
31
+ end
32
+
33
+ def link(text, target, attributes = {})
34
+ if target.is_a? Fixnum
35
+ attributes[:rel] = rel_value(target)
36
+ target = url(target)
37
+ end
38
+ attributes[:href] = target
39
+ tag(:a, "<span>#{text}</span>", attributes)
40
+ end
41
+
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,8 @@
1
+ module Releaf
2
+ module ReleafDeviseHelper
3
+ # FIXME need better name
4
+ def self.devise_admin_model_name
5
+ Releaf.devise_for.underscore.tr('/', '_')
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,51 @@
1
+ module Releaf
2
+ class Admin < ActiveRecord::Base
3
+ self.table_name = 'releaf_admins'
4
+
5
+ # Include default devise modules. Others available are:
6
+ # :token_authenticatable, :confirmable,
7
+ # :lockable, :timeoutable and :omniauthable
8
+ # :registerable
9
+ devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable
10
+
11
+ validates_presence_of :name, :surname, :role_id, :email
12
+ validates_uniqueness_of :email, :case_sensitive => false
13
+ belongs_to :role
14
+
15
+ image_accessor :avatar
16
+
17
+ scope :filter, lambda {|params|
18
+ fields = []
19
+ values = {}
20
+
21
+ if !params.empty?
22
+ if !params[:search].blank?
23
+ params[:search].strip.split(" ").each_with_index do|word, i|
24
+ fields << "email LIKE :email#{i}"
25
+ values["email#{i}".to_sym] = '%' + word + '%'
26
+ end
27
+ end
28
+ end
29
+
30
+ if !fields.empty?
31
+ where(fields.join(' AND '), values)
32
+ end
33
+ }
34
+
35
+ def display_name
36
+ [self.name, self.surname].join(' ')
37
+ end
38
+ alias :to_text :display_name
39
+
40
+ def role
41
+ super || Role.default
42
+ end
43
+
44
+ protected
45
+
46
+ def password_required?
47
+ self.new_record? || self.encrypted_password.blank?
48
+ end
49
+
50
+ end
51
+ end
@@ -0,0 +1,221 @@
1
+ module Releaf
2
+ class Node < ActiveRecord::Base
3
+ COMMON_FIELD_NAME_PREFIX = 'data_'
4
+
5
+ acts_as_nested_set
6
+ acts_as_list :scope => :parent_id
7
+ include Slug
8
+ self.table_name = 'releaf_nodes'
9
+
10
+ serialize :data, Hash
11
+ default_scope :order => 'position'
12
+
13
+ validates_presence_of :name, :slug, :content_type
14
+ validates_uniqueness_of :slug, :scope => :parent_id
15
+
16
+ alias_attribute :to_text, :name
17
+
18
+ belongs_to :content, :polymorphic => true, :dependent => :destroy
19
+ accepts_nested_attributes_for :content
20
+
21
+ # FIXME get rid of attr_protected
22
+ attr_protected :none
23
+
24
+ acts_as_url :name, :url_attribute => :slug, :scope => :parent_id #, :only_when_blank => true, :limit => 255
25
+
26
+ def content_object
27
+ self.content
28
+ end
29
+
30
+ def content_object_attributes=(new_attr)
31
+ if self.content
32
+ self.content.update_attributes(new_attr)
33
+ else
34
+ nc = new_content(new_attr)
35
+ nc.save
36
+
37
+ self.content = nc
38
+ self.update_attribute(:content_id, nc.id)
39
+ end
40
+ end
41
+
42
+ ##
43
+ # Return node public url
44
+
45
+ def url
46
+ if parent_id
47
+ url = parent.url + "/" + slug.to_s
48
+ else
49
+ url = slug.to_s
50
+ end
51
+
52
+ url
53
+ end
54
+
55
+ ##
56
+ # Return node content object public controller
57
+
58
+ def controller
59
+ raise "Missing content object" if content_object.blank?
60
+ return "#{content_type}_controller".classify.constantize
61
+ end
62
+
63
+ def self.get_object_from_path path, params = {}
64
+ node = nil
65
+ parent_node = nil
66
+
67
+ if path.class == String
68
+ path = path.split("/").reject(&:empty?)
69
+ end
70
+
71
+ unless params[:locale].nil?
72
+ parent_node = Node.roots.find_by_slug(params[:locale])
73
+ end
74
+
75
+ path.each do |part|
76
+ node = Node.where(:parent_id => (parent_node ? parent_node.id : nil), :slug => part).first
77
+ if node
78
+ parent_node = node
79
+ else
80
+ unless params[:strict].blank?
81
+ node = nil
82
+ else
83
+ node = parent_node
84
+ end
85
+ break
86
+ end
87
+ end
88
+
89
+ unless params[:controller].nil?
90
+ if params[:controller] != node.controller.to_s
91
+ node = nil
92
+ end
93
+ end
94
+
95
+ node
96
+ end
97
+
98
+ def to_s
99
+ name
100
+ end
101
+
102
+ def method_missing(method, *args, &block)
103
+ if self.class.column_names.include?('data')
104
+ case method.to_s
105
+ when /^(#{COMMON_FIELD_NAME_PREFIX}(.+))=$/ then
106
+ if common_field_names.include? $1
107
+ return common_field_setter($2, args[0])
108
+ end
109
+ when /^(#{COMMON_FIELD_NAME_PREFIX}(.+))$/ then
110
+ if common_field_names.include? $1
111
+ return common_field_getter($2)
112
+ end
113
+ end
114
+ end
115
+
116
+ return super(method, *args, &block)
117
+ end
118
+
119
+ def respond_to? method_id, include_private = false
120
+ # this is needed for mass asignment (update_attributes) to work with common_fields
121
+ rt = super(method_id, include_private)
122
+ return true if rt
123
+ return common_field_names.include?(method_id.to_s.sub(/=$/, ''))
124
+ end
125
+
126
+ def common_fields_schema
127
+ @_common_fields_schema ||= common_fields_schema_for_instance
128
+ end
129
+
130
+ def common_field_names
131
+ @_common_field_names ||= common_fields_schema.map { |f| "#{COMMON_FIELD_NAME_PREFIX}#{f['field_name']}" }
132
+ end
133
+
134
+ def common_field_field_type(field_name)
135
+ common_field_options(field_name.sub(/^#{COMMON_FIELD_NAME_PREFIX}/, ''))['field_type']
136
+ end
137
+
138
+ def self.load_common_fields_schema
139
+
140
+ common_fields_schema_file = Rails.root.to_s+ '/config/common_fields.yml'
141
+ cfschema = if File.exists?(common_fields_schema_file)
142
+ YAML::load_file(common_fields_schema_file)
143
+ else
144
+ []
145
+ end
146
+
147
+ raise "common_fields common_fields_schema is not an array" unless cfschema.is_a? Array
148
+ cfschema.each_with_index do |field,i|
149
+ raise "common_fields common_fields_schema contains non-hash element in root node" unless field.is_a? Hash
150
+ raise "field_name not defined for field ##{i}" unless field.has_key?('field_name')
151
+ raise "field_name must be string" unless field['field_name'].is_a? String
152
+ raise "field_type not defined for #{field['field_type']} field" unless field.has_key?('field_type')
153
+ raise "apply_to not defined for #{field['apply_to']} field" unless field.has_key?('apply_to')
154
+ end
155
+ return cfschema
156
+ end
157
+
158
+ private
159
+
160
+ def common_fields_schema_for_instance
161
+
162
+ full_schema =if defined?(COMMON_FIELDS_SCHEMA)
163
+ COMMON_FIELDS_SCHEMA.dup
164
+ else
165
+ self.class.load_common_fields_schema.dup
166
+ end
167
+
168
+ full_schema.delete_if do |field|
169
+ keep = false
170
+
171
+ if field['apply_to'].is_a?(String) && (field['apply_to'] == '*' || field['apply_to'] == self.content_type)
172
+ keep = true
173
+ elsif field['apply_to'].is_a?(Array) && field['apply_to'].include?(self.content_type)
174
+ keep = true
175
+ else
176
+ keep = false
177
+ end
178
+
179
+ if keep == true && field.has_key?('deny_for')
180
+ if field['deny_for'].is_a?(String) && (field['deny_for'] == '*' || field['deny_for'] == self.content_type)
181
+ keep = false
182
+ elsif field['deny_for'].is_a?(Array) && field['deny_for'].include?(self.content_type)
183
+ keep = false
184
+ end
185
+ end
186
+
187
+ if keep == true && field.has_key?('levels')
188
+ keep = false unless field['levels'].include? level
189
+ end
190
+
191
+ !keep
192
+ end
193
+
194
+ return full_schema
195
+ end
196
+
197
+ def common_field_setter(key, value)
198
+ self.data[key] = value
199
+ end
200
+
201
+ def common_field_getter(key)
202
+ self.data.has_key?(key) ? self.data[key] : common_field_default_value(key)
203
+ end
204
+
205
+ def common_field_options(key)
206
+ common_fields_schema.each do |field|
207
+ return field if field['field_name'] == key
208
+ end
209
+ end
210
+
211
+ def common_field_default_value(key)
212
+ common_field_options(key)['default']
213
+ end
214
+
215
+ def new_content(attr)
216
+ raise RuntimeError, 'content_type must be set' unless content_type
217
+ self.content_type.constantize.new(attr)
218
+ end
219
+
220
+ end
221
+ end