binda 0.0.7 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (301) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +850 -18
  3. data/Rakefile +1 -13
  4. data/app/assets/javascripts/binda/application.js +23 -0
  5. data/app/assets/javascripts/binda/components/bootstrap.js +9 -0
  6. data/app/assets/javascripts/binda/components/field_group_editor.js +18 -0
  7. data/app/assets/javascripts/binda/components/fileupload.js +182 -0
  8. data/app/assets/javascripts/binda/components/form_item.js +91 -23
  9. data/app/assets/javascripts/binda/components/form_item_choice.js +15 -8
  10. data/app/assets/javascripts/binda/components/form_item_editor.js +6 -6
  11. data/app/assets/javascripts/binda/components/form_item_image.js +23 -0
  12. data/app/assets/javascripts/binda/components/form_item_repeater.js +70 -23
  13. data/app/assets/javascripts/binda/components/login-shader.js +193 -0
  14. data/app/assets/javascripts/binda/components/login_form.js +116 -0
  15. data/app/assets/javascripts/binda/components/radio-toggle.js +18 -0
  16. data/app/assets/javascripts/binda/components/select2.js +22 -0
  17. data/app/assets/javascripts/binda/components/sortable.js +53 -8
  18. data/app/assets/javascripts/binda/dist/binda.bundle.js +914 -107
  19. data/app/assets/javascripts/binda/index.js +26 -3
  20. data/app/assets/stylesheets/binda/application.scss +6 -0
  21. data/app/assets/stylesheets/binda/components/assets_manager.scss +46 -36
  22. data/app/assets/stylesheets/binda/components/b-btn.scss +114 -0
  23. data/app/assets/stylesheets/binda/components/button.scss +4 -1
  24. data/app/assets/stylesheets/binda/components/fileupload.scss +134 -0
  25. data/app/assets/stylesheets/binda/components/form_item.scss +233 -168
  26. data/app/assets/stylesheets/binda/components/form_item_image.scss +0 -0
  27. data/app/assets/stylesheets/binda/components/form_item_video.scss +25 -0
  28. data/app/assets/stylesheets/binda/components/main_container.scss +3 -0
  29. data/app/assets/stylesheets/binda/components/main_content.scss +1 -2
  30. data/app/assets/stylesheets/binda/components/main_header.scss +21 -20
  31. data/app/assets/stylesheets/binda/components/main_sidebar.scss +121 -0
  32. data/app/assets/stylesheets/binda/components/main_table.scss +84 -28
  33. data/app/assets/stylesheets/binda/components/popup_warning.scss +71 -0
  34. data/app/assets/stylesheets/binda/components/select2.scss +126 -0
  35. data/app/assets/stylesheets/binda/components/sortable.scss +83 -56
  36. data/app/assets/stylesheets/binda/components/standard-form.scss +228 -0
  37. data/app/assets/stylesheets/binda/components/texts.scss +6 -0
  38. data/app/assets/stylesheets/binda/controllers/components_index.scss +3 -0
  39. data/app/assets/stylesheets/binda/controllers/users_sessions_new.scss +309 -0
  40. data/app/assets/stylesheets/binda/index.scss +16 -8
  41. data/app/assets/stylesheets/binda/settings/bootstrap_overrides.scss +0 -0
  42. data/app/assets/stylesheets/binda/settings/buttons.scss +36 -0
  43. data/app/assets/stylesheets/binda/settings/common.scss +36 -79
  44. data/app/assets/stylesheets/binda/settings/fonts.scss +88 -31
  45. data/app/assets/stylesheets/binda/settings/tiny_mce_overrides.scss +82 -0
  46. data/app/assets/stylesheets/binda/settings/variables.scss +36 -31
  47. data/app/controllers/binda/application_controller.rb +0 -2
  48. data/app/controllers/binda/assets_controller.rb +1 -1
  49. data/app/controllers/binda/boards_controller.rb +15 -4
  50. data/app/controllers/binda/components_controller.rb +30 -15
  51. data/app/controllers/binda/field_groups_controller.rb +19 -4
  52. data/app/controllers/binda/images_controller.rb +68 -0
  53. data/app/controllers/binda/repeaters_controller.rb +3 -12
  54. data/app/controllers/binda/structures_controller.rb +8 -1
  55. data/app/controllers/binda/videos_controller.rb +68 -0
  56. data/app/controllers/concerns/binda/fieldable_helpers.rb +113 -28
  57. data/app/controllers/concerns/binda/maintenance_helpers.rb +34 -0
  58. data/app/helpers/binda/components_helper.rb +26 -2
  59. data/app/helpers/binda/field_groups_helper.rb +16 -0
  60. data/app/helpers/binda/structures_helper.rb +6 -0
  61. data/app/models/binda/asset.rb +0 -4
  62. data/app/models/binda/b.rb +5 -0
  63. data/app/models/binda/board.rb +1 -18
  64. data/app/models/binda/choice.rb +48 -12
  65. data/app/models/binda/component.rb +20 -0
  66. data/app/models/binda/field_group.rb +2 -2
  67. data/app/models/binda/field_setting.rb +61 -28
  68. data/app/models/binda/gallery.rb +0 -2
  69. data/app/models/binda/image.rb +7 -0
  70. data/app/models/binda/relation.rb +79 -0
  71. data/app/models/binda/relation_link.rb +11 -0
  72. data/app/models/binda/repeater.rb +1 -1
  73. data/app/models/binda/selection.rb +0 -9
  74. data/app/models/binda/structure.rb +41 -39
  75. data/app/models/binda/video.rb +7 -0
  76. data/app/models/concerns/binda/default_helpers.rb +186 -0
  77. data/app/models/concerns/binda/fieldable_associations.rb +276 -30
  78. data/app/uploaders/binda/{asset → image}/image_uploader.rb +27 -9
  79. data/app/uploaders/binda/video/video_uploader.rb +51 -0
  80. data/app/views/binda/boards/edit.html.erb +6 -1
  81. data/app/views/binda/categories/_form.html.erb +41 -40
  82. data/app/views/binda/categories/edit.html.erb +1 -1
  83. data/app/views/binda/categories/index.html.erb +16 -13
  84. data/app/views/binda/components/edit.html.erb +6 -3
  85. data/app/views/binda/components/index.html.erb +69 -28
  86. data/app/views/binda/components/new.html.erb +1 -1
  87. data/app/views/binda/components/sort_index.html.erb +46 -0
  88. data/app/views/binda/field_groups/_form_body.html.erb +65 -44
  89. data/app/views/binda/field_groups/_form_item.html.erb +66 -23
  90. data/app/views/binda/field_groups/_form_item_choice.erb +34 -15
  91. data/app/views/binda/field_groups/_form_section.html.erb +6 -10
  92. data/app/views/binda/field_groups/_form_section_repeater.html.erb +3 -3
  93. data/app/views/binda/field_groups/edit.html.erb +1 -1
  94. data/app/views/binda/field_settings/_form_body.html.erb +5 -5
  95. data/app/views/binda/field_settings/edit.html.erb +1 -1
  96. data/app/views/binda/fieldable/_form_body.html.erb +93 -79
  97. data/app/views/binda/fieldable/_form_item_date.html.erb +14 -14
  98. data/app/views/binda/fieldable/_form_item_image.html.erb +35 -0
  99. data/app/views/binda/fieldable/_form_item_new_repeater.html.erb +12 -5
  100. data/app/views/binda/fieldable/_form_item_relation.html.erb +44 -0
  101. data/app/views/binda/fieldable/_form_item_repeater.html.erb +80 -58
  102. data/app/views/binda/fieldable/_form_item_selections.html.erb +109 -87
  103. data/app/views/binda/fieldable/_form_item_string.html.erb +19 -17
  104. data/app/views/binda/fieldable/_form_item_text.html.erb +19 -16
  105. data/app/views/binda/fieldable/_form_item_video.html.erb +32 -0
  106. data/app/views/binda/fieldable/_form_section.html.erb +27 -5
  107. data/app/views/binda/fieldable/_form_section_repeater.html.erb +30 -10
  108. data/app/views/binda/fieldable/_form_sidebar.html.erb +44 -20
  109. data/app/views/binda/manage/users/_form_body.html.erb +42 -37
  110. data/app/views/binda/manage/users/edit.html.erb +1 -1
  111. data/app/views/binda/manage/users/index.html.erb +21 -21
  112. data/app/views/binda/structures/_form_body.html.erb +54 -60
  113. data/app/views/binda/structures/_form_section.html.erb +32 -18
  114. data/app/views/binda/structures/_form_sidebar.html.erb +35 -0
  115. data/app/views/binda/structures/edit.html.erb +2 -2
  116. data/app/views/binda/structures/index.html.erb +21 -16
  117. data/app/views/binda/structures/sort_index.html.erb +36 -0
  118. data/app/views/{users → binda/users}/confirmations/new.html.erb +1 -1
  119. data/app/views/{users → binda/users}/mailer/confirmation_instructions.html.erb +0 -0
  120. data/app/views/{users → binda/users}/mailer/password_change.html.erb +0 -0
  121. data/app/views/{users → binda/users}/mailer/reset_password_instructions.html.erb +0 -0
  122. data/app/views/{users → binda/users}/mailer/unlock_instructions.html.erb +0 -0
  123. data/app/views/{users → binda/users}/passwords/edit.html.erb +1 -1
  124. data/app/views/{users → binda/users}/passwords/new.html.erb +1 -1
  125. data/app/views/{users → binda/users}/registrations/edit.html.erb +0 -0
  126. data/app/views/{users → binda/users}/registrations/new.html.erb +1 -1
  127. data/app/views/binda/users/sessions/_background.html.erb +139 -0
  128. data/app/views/binda/users/sessions/new.html.erb +62 -0
  129. data/app/views/{users → binda/users}/shared/_links.html.erb +3 -3
  130. data/app/views/{users → binda/users}/unlocks/new.html.erb +1 -1
  131. data/app/views/kaminari/_first_page.html.erb +11 -0
  132. data/app/views/kaminari/_gap.html.erb +8 -0
  133. data/app/views/kaminari/_last_page.html.erb +11 -0
  134. data/app/views/kaminari/_next_page.html.erb +11 -0
  135. data/app/views/kaminari/_page.html.erb +12 -0
  136. data/app/views/kaminari/_paginator.html.erb +19 -0
  137. data/app/views/kaminari/_prev_page.html.erb +11 -0
  138. data/app/views/layouts/binda/_flash.html.erb +1 -1
  139. data/app/views/layouts/binda/_header.html.erb +2 -6
  140. data/app/views/layouts/binda/_sidebar.html.erb +11 -4
  141. data/app/views/layouts/binda/application.html.erb +15 -7
  142. data/config/autoprefixer.yml +5 -0
  143. data/config/database.yml.travis +3 -0
  144. data/config/initializers/assets.rb +1 -0
  145. data/config/initializers/autoprefixer.yml +5 -0
  146. data/config/initializers/carrierwave.rb +32 -0
  147. data/config/initializers/devise.rb +14 -10
  148. data/config/initializers/devise_patch.rb +8 -8
  149. data/config/initializers/simple_form.rb +4 -0
  150. data/config/initializers/simple_form__fileupload.rb +121 -0
  151. data/config/initializers/{simple_form_bootstrap.rb → simple_form_custom.rb} +79 -50
  152. data/config/locales/en.yml +61 -3
  153. data/config/locales/it.yml +51 -0
  154. data/config/locales/simple_form.en.yml +3 -3
  155. data/config/routes.rb +41 -24
  156. data/db/migrate/1_create_binda_tables.rb +18 -7
  157. data/db/migrate/20171214140451_add_preview_mode.rb +5 -0
  158. data/lib/binda.rb +1 -1
  159. data/lib/binda/engine.rb +19 -23
  160. data/lib/binda/version.rb +2 -2
  161. data/lib/generators/binda/install/install_generator.rb +59 -54
  162. data/lib/generators/binda/install/templates/config/initializers/carrierwave.rb +11 -2
  163. data/lib/generators/binda/maintenance/USAGE +8 -0
  164. data/lib/generators/binda/maintenance/maintenance_generator.rb +50 -0
  165. data/lib/generators/binda/maintenance/templates/app/assets/javascripts/maintenance.js +0 -0
  166. data/lib/generators/binda/maintenance/templates/app/assets/stylesheets/maintenance.scss +0 -0
  167. data/lib/generators/binda/maintenance/templates/app/views/layouts/maintenance.html.erb +16 -0
  168. data/lib/generators/binda/maintenance/templates/config/initializers/maintenance.rb +1 -0
  169. data/lib/generators/binda/setup/setup_generator.rb +41 -30
  170. data/lib/tasks/add_default_helpers_class_task.rake +11 -0
  171. data/lib/tasks/add_video_feature_task.rake +15 -0
  172. data/lib/tasks/remove_orphan_fields_task.rake +16 -0
  173. data/lib/tasks/set_repeater_position_task.rake +13 -0
  174. data/lib/tasks/upgrade_to_v007_task.rake +72 -0
  175. data/lib/tasks/user_tasks.rake +14 -0
  176. data/vendor/assets/fonts/font-awesome/fa-brands-400.eot +0 -0
  177. data/vendor/assets/fonts/font-awesome/fa-brands-400.svg +978 -0
  178. data/vendor/assets/fonts/font-awesome/fa-brands-400.ttf +0 -0
  179. data/vendor/assets/fonts/font-awesome/fa-brands-400.woff +0 -0
  180. data/vendor/assets/fonts/font-awesome/fa-brands-400.woff2 +0 -0
  181. data/vendor/assets/fonts/font-awesome/fa-regular-400.eot +0 -0
  182. data/vendor/assets/fonts/font-awesome/fa-regular-400.svg +363 -0
  183. data/vendor/assets/fonts/font-awesome/fa-regular-400.ttf +0 -0
  184. data/vendor/assets/fonts/font-awesome/fa-regular-400.woff +0 -0
  185. data/vendor/assets/fonts/font-awesome/fa-regular-400.woff2 +0 -0
  186. data/vendor/assets/fonts/font-awesome/fa-solid-900.eot +0 -0
  187. data/vendor/assets/fonts/font-awesome/fa-solid-900.svg +1410 -0
  188. data/vendor/assets/fonts/font-awesome/fa-solid-900.ttf +0 -0
  189. data/vendor/assets/fonts/font-awesome/fa-solid-900.woff +0 -0
  190. data/vendor/assets/fonts/font-awesome/fa-solid-900.woff2 +0 -0
  191. data/vendor/assets/javascripts/GSAP/CSSPlugin.min.js +13 -0
  192. data/vendor/assets/javascripts/GSAP/EasePack.min.js +12 -0
  193. data/vendor/assets/javascripts/GSAP/ScrollToPlugin.min.js +12 -0
  194. data/vendor/assets/javascripts/GSAP/TweenLite.min.js +12 -0
  195. data/vendor/assets/javascripts/select2/i18n/af.js +3 -0
  196. data/vendor/assets/javascripts/select2/i18n/ar.js +3 -0
  197. data/vendor/assets/javascripts/select2/i18n/az.js +3 -0
  198. data/vendor/assets/javascripts/select2/i18n/bg.js +3 -0
  199. data/vendor/assets/javascripts/select2/i18n/bs.js +3 -0
  200. data/vendor/assets/javascripts/select2/i18n/ca.js +3 -0
  201. data/vendor/assets/javascripts/select2/i18n/cs.js +3 -0
  202. data/vendor/assets/javascripts/select2/i18n/da.js +3 -0
  203. data/vendor/assets/javascripts/select2/i18n/de.js +3 -0
  204. data/vendor/assets/javascripts/select2/i18n/dsb.js +3 -0
  205. data/vendor/assets/javascripts/select2/i18n/el.js +3 -0
  206. data/vendor/assets/javascripts/select2/i18n/en.js +3 -0
  207. data/vendor/assets/javascripts/select2/i18n/es.js +3 -0
  208. data/vendor/assets/javascripts/select2/i18n/et.js +3 -0
  209. data/vendor/assets/javascripts/select2/i18n/eu.js +3 -0
  210. data/vendor/assets/javascripts/select2/i18n/fa.js +3 -0
  211. data/vendor/assets/javascripts/select2/i18n/fi.js +3 -0
  212. data/vendor/assets/javascripts/select2/i18n/fr.js +3 -0
  213. data/vendor/assets/javascripts/select2/i18n/gl.js +3 -0
  214. data/vendor/assets/javascripts/select2/i18n/he.js +3 -0
  215. data/vendor/assets/javascripts/select2/i18n/hi.js +3 -0
  216. data/vendor/assets/javascripts/select2/i18n/hr.js +3 -0
  217. data/vendor/assets/javascripts/select2/i18n/hsb.js +3 -0
  218. data/vendor/assets/javascripts/select2/i18n/hu.js +3 -0
  219. data/vendor/assets/javascripts/select2/i18n/hy.js +3 -0
  220. data/vendor/assets/javascripts/select2/i18n/id.js +3 -0
  221. data/vendor/assets/javascripts/select2/i18n/is.js +3 -0
  222. data/vendor/assets/javascripts/select2/i18n/it.js +3 -0
  223. data/vendor/assets/javascripts/select2/i18n/ja.js +3 -0
  224. data/vendor/assets/javascripts/select2/i18n/km.js +3 -0
  225. data/vendor/assets/javascripts/select2/i18n/ko.js +3 -0
  226. data/vendor/assets/javascripts/select2/i18n/lt.js +3 -0
  227. data/vendor/assets/javascripts/select2/i18n/lv.js +3 -0
  228. data/vendor/assets/javascripts/select2/i18n/mk.js +3 -0
  229. data/vendor/assets/javascripts/select2/i18n/ms.js +3 -0
  230. data/vendor/assets/javascripts/select2/i18n/nb.js +3 -0
  231. data/vendor/assets/javascripts/select2/i18n/nl.js +3 -0
  232. data/vendor/assets/javascripts/select2/i18n/pl.js +3 -0
  233. data/vendor/assets/javascripts/select2/i18n/ps.js +3 -0
  234. data/vendor/assets/javascripts/select2/i18n/pt-BR.js +3 -0
  235. data/vendor/assets/javascripts/select2/i18n/pt.js +3 -0
  236. data/vendor/assets/javascripts/select2/i18n/ro.js +3 -0
  237. data/vendor/assets/javascripts/select2/i18n/ru.js +3 -0
  238. data/vendor/assets/javascripts/select2/i18n/sk.js +3 -0
  239. data/vendor/assets/javascripts/select2/i18n/sl.js +3 -0
  240. data/vendor/assets/javascripts/select2/i18n/sr-Cyrl.js +3 -0
  241. data/vendor/assets/javascripts/select2/i18n/sr.js +3 -0
  242. data/vendor/assets/javascripts/select2/i18n/sv.js +3 -0
  243. data/vendor/assets/javascripts/select2/i18n/th.js +3 -0
  244. data/vendor/assets/javascripts/select2/i18n/tr.js +3 -0
  245. data/vendor/assets/javascripts/select2/i18n/uk.js +3 -0
  246. data/vendor/assets/javascripts/select2/i18n/vi.js +3 -0
  247. data/vendor/assets/javascripts/select2/i18n/zh-CN.js +3 -0
  248. data/vendor/assets/javascripts/select2/i18n/zh-TW.js +3 -0
  249. data/vendor/assets/javascripts/select2/select2.full.min.js +1 -0
  250. data/vendor/assets/javascripts/select2/select2.min.js +1 -0
  251. data/vendor/assets/javascripts/tether.min.js +1 -0
  252. data/vendor/assets/stylesheets/{bootstrap-select.css → bootstrap/bootstrap-select.css} +0 -0
  253. data/vendor/assets/stylesheets/font-awesome/_animated.scss +6 -20
  254. data/vendor/assets/stylesheets/font-awesome/_bordered-pulled.scss +6 -11
  255. data/vendor/assets/stylesheets/font-awesome/_core.scss +11 -7
  256. data/vendor/assets/stylesheets/font-awesome/_fixed-width.scss +1 -1
  257. data/vendor/assets/stylesheets/font-awesome/_icons.scss +785 -787
  258. data/vendor/assets/stylesheets/font-awesome/_larger.scss +16 -6
  259. data/vendor/assets/stylesheets/font-awesome/_list.scss +7 -8
  260. data/vendor/assets/stylesheets/font-awesome/_mixins.scss +17 -20
  261. data/vendor/assets/stylesheets/font-awesome/_rotated-flipped.scss +9 -6
  262. data/vendor/assets/stylesheets/font-awesome/_screen-reader.scss +2 -2
  263. data/vendor/assets/stylesheets/font-awesome/_stacked.scss +19 -8
  264. data/vendor/assets/stylesheets/font-awesome/_variables.scss +795 -795
  265. data/vendor/assets/stylesheets/font-awesome/fa-brands.scss +21 -0
  266. data/vendor/assets/stylesheets/font-awesome/fa-regular.scss +22 -0
  267. data/vendor/assets/stylesheets/font-awesome/fa-solid.scss +23 -0
  268. data/vendor/assets/stylesheets/font-awesome/fontawesome.scss +20 -0
  269. data/vendor/assets/stylesheets/select2/select2.min.css +1 -0
  270. metadata +278 -125
  271. data/app/assets/javascripts/binda/components/form_item_asset.js +0 -25
  272. data/app/assets/stylesheets/binda/application.css +0 -6
  273. data/app/assets/stylesheets/binda/components/form_body.scss +0 -2
  274. data/app/assets/stylesheets/binda/components/form_item_asset.scss +0 -20
  275. data/app/assets/stylesheets/binda/components/form_section.scss +0 -40
  276. data/app/assets/stylesheets/binda/components/sidebar.scss +0 -131
  277. data/app/assets/stylesheets/binda/layout/components_index.scss +0 -9
  278. data/app/assets/stylesheets/binda/layout/dashboard.scss +0 -7
  279. data/app/assets/stylesheets/binda/layout/users_sign_in.scss +0 -29
  280. data/app/controllers/binda/bindings_controller.rb +0 -62
  281. data/app/controllers/concerns/binda/default_helpers.rb +0 -226
  282. data/app/helpers/binda/bindings_helper.rb +0 -4
  283. data/app/models/binda/binda.rb +0 -7
  284. data/app/models/binda/binding.rb +0 -24
  285. data/app/views/binda/bindings/_form.html.erb +0 -32
  286. data/app/views/binda/bindings/edit.html.erb +0 -6
  287. data/app/views/binda/bindings/index.html.erb +0 -31
  288. data/app/views/binda/bindings/new.html.erb +0 -5
  289. data/app/views/binda/bindings/show.html.erb +0 -19
  290. data/app/views/binda/field_groups/index.html.erb +0 -34
  291. data/app/views/binda/fieldable/_form_item_asset.html.erb +0 -20
  292. data/app/views/users/sessions/new.html.erb +0 -27
  293. data/lib/tasks/binda.rake +0 -79
  294. data/vendor/assets/fonts/font-awesome/FontAwesome.otf +0 -0
  295. data/vendor/assets/fonts/font-awesome/fontawesome-webfont.eot +0 -0
  296. data/vendor/assets/fonts/font-awesome/fontawesome-webfont.svg +0 -2671
  297. data/vendor/assets/fonts/font-awesome/fontawesome-webfont.ttf +0 -0
  298. data/vendor/assets/fonts/font-awesome/fontawesome-webfont.woff +0 -0
  299. data/vendor/assets/fonts/font-awesome/fontawesome-webfont.woff2 +0 -0
  300. data/vendor/assets/stylesheets/font-awesome/_path.scss +0 -15
  301. data/vendor/assets/stylesheets/font-awesome/font-awesome.scss +0 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6690ffecf6e02f102a52ba0adb48e57914e6daa3
4
- data.tar.gz: 3a29b2ed21beea482e4d4f069ee882595ab321b9
3
+ metadata.gz: b58323a2adb5832314cc30abbce3b2455b5771a2
4
+ data.tar.gz: 7662cff5f1a441bc8d8ad6872ffea56836d1c276
5
5
  SHA512:
6
- metadata.gz: 084e2b3bb8e2e52676cc381e8eb6daaceb15a2127da3fe78889bcf3d36054b2adfcb2948fd042afa12e6446f45a6709722b702eb97dbb5419e4ae06b937b599f
7
- data.tar.gz: 29cd68ff87c402662711569bfdef44c4951e39f36a112f900ced53a5c325bbc8a2819818a27292a40212c4dcfe665b980f1ebaf9015d29d2b6db343ba2b2b50e
6
+ metadata.gz: 4b46646f7c7b91be681708f2373695f04c3b2ffca7390212c1d285d4d8434442505c58610b581367639a2d057edf164fa608091ed70d7fcc9b82d446f3bcead7
7
+ data.tar.gz: e005c49678e2d93cf8ed140b0d3635359c3f7a11ae91d9dd7c8b82796081542eb942ea8fc1860d2935900487c6ee6851299851f1961d82d3fa21049a21d10fd6
data/README.md CHANGED
@@ -3,48 +3,880 @@ A modular CMS for Ruby on Rails 5.1.
3
3
 
4
4
  [![Code Climate](https://codeclimate.com/github/lacolonia/binda/badges/gpa.svg)](https://codeclimate.com/github/lacolonia/binda)
5
5
  [![Issue Count](https://codeclimate.com/github/lacolonia/binda/badges/issue_count.svg)](https://codeclimate.com/github/lacolonia/binda)
6
- [![Test Coverage](https://codeclimate.com/github/lacolonia/binda/badges/coverage.svg)](https://codeclimate.com/github/lacolonia/binda/coverage)
7
- [![Slack](https://binda.herokuapp.com/badge.svg)](https://binda.herokuapp.com)
6
+ [![Build Status](https://travis-ci.org/a-barbieri/binda.svg?branch=master)](https://travis-ci.org/lacolonia/binda)
7
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/5dc62774a6b8b63aa72b/test_coverage)](https://codeclimate.com/github/lacolonia/binda/test_coverage)
8
+ [![Dependency Status](https://gemnasium.com/badges/github.com/lacolonia/binda.svg)](https://gemnasium.com/github.com/lacolonia/binda)
9
+ [![Inline docs](http://inch-ci.org/github/lacolonia/binda.svg?branch=master)](http://inch-ci.org/github/lacolonia/binda)
8
10
 
9
- ## Installation
10
- Add this line to your application's Gemfile:
11
+ > This documentation has been written for the [Official Documentation](http://www.rubydoc.info/gems/binda), not the Github README.
12
+ > If you still prefer to read Github README be aware that links might not work properly.
13
+
14
+ ---
15
+
16
+
17
+
18
+ # Quick Start
19
+
20
+ **Binda** is a CMS with an intuitive out-of-the-box interface to manage and customize page components.
21
+
22
+ The core element is the _structure_ element which is the finger print of any _component_ instance. Every _structure_ can have one or more _field-groups_ which can be populated with several _field-settings_. _Field-groups_ and _field-settings_ represent _components_ features, such as galleries, textareas, dates, repeaters and so on.
23
+
24
+ Let's say your website needs a set of pages with a subtitle. That's super easy.
25
+
26
+ - create a "Page" _structure_
27
+ - go to General Details of "Page" _structure_ (see the small pencil icon)
28
+ - set a "Subtitle" _field-settings_ based both on a _String_ field type.
29
+
30
+ Done! Now you'll see the "Pages" tab in your menu which will contain all your pages.
31
+
32
+ It's easier learning by doing than by reading. ;-)
33
+
34
+ ![Binda preview](https://www.dropbox.com/s/m7vwrou1homqc6p/binda-01.gif?raw=1)
35
+
36
+ ---
37
+
38
+
39
+
40
+ # Installation
41
+
42
+ Install Binda via terminal
43
+
44
+ ```bash
45
+ gem install binda
46
+ ```
47
+
48
+ alternatively add the gem to your application's Gemfile:
11
49
 
12
50
  ```ruby
13
- gem 'binda', '~> 0.0.7'
51
+ gem 'binda'
14
52
  ```
15
53
 
16
54
  Then execute:
17
55
 
18
56
  ```bash
19
- $ bundle
57
+ bundle install
58
+ ```
59
+
60
+ Before completing the installation you need to setup the database. If you are going to use Postgres set it up now.
61
+
62
+ To complete binda installation run the installer from terminal. Binda will take you through a bit of configuration where you will setup the first user and some basic details.
63
+
64
+ ```bash
65
+ rails generate binda:install
66
+ ```
67
+
68
+ Now you are good to go. Good job!
69
+
70
+ ## Recommended workflow
71
+
72
+ Binda is totally bound to its database in order to let you structure your CMS directly from the admin panel. The recommended workflow is:
73
+
74
+ 1. Install and develop the application locally
75
+ 2. Migrate server and database to production once ready
76
+ 3. For any update sync your local database with the production one
77
+
78
+ This ensure the application structure remains the same.
79
+
80
+ If you want to avoid copying the entire database you can just refer to the following `binda_structures`
81
+
82
+ ## Reset credentials and initial settings
83
+
84
+ If you need to re-install Binda and reset initial database settings (such as username and password for example) execute the following command from the application root.
85
+
86
+ ```bash
87
+ rails generate binda:setup
88
+ ```
89
+
90
+ ## Specific needs
91
+ In order to use Carrierwave to process images you need to run MiniMagik. Please refer to [Carrierwave documentation](https://github.com/carrierwaveuploader/carrierwave#using-minimagick) to find more information.
92
+
93
+ If you are not going to use Rails default ORM please check [Carrierwave documentation](https://github.com/carrierwaveuploader/carrierwave#datamapper-mongoid-sequel) and [Devise documentation](https://github.com/plataformatec/devise#other-orms).
94
+
95
+ ---
96
+
97
+
98
+
99
+ # Settings
100
+
101
+ Binda comes with some default preferences.
102
+
103
+ During the installation process you will be asked to provide the _website name_, _website description_ and the credentials for the default super administrator.
104
+
105
+ This two preferences can be changed later on inside _Dashboard_ panel visible in the sidebar.
106
+
107
+ You can customize the _Dashboard_ panel adding, removing and modifing fields as you prefer. As a matter of fact in _Structures_ you can find the one related to _Dashboard_ which you can edit as you like. The only thing you shouldn't do is to turn it into a component!
108
+
109
+ You can also create new boards if you need it. See https://github.com/lacolonia/binda/wiki/Boards
110
+
111
+ By default after the installation a `Board` called `dashboard` will be populated with three fields: a `Radio` called `maintenance-mode`, a `String` called `website-name` and `Text` called `webiste-description`.
112
+
113
+ You can retrieve them this way:
114
+
115
+ ```ruby
116
+ B.get_boards('dashboard').first.get_radio_choice('maintenance-mode')
117
+ # => return string which can be 'true' or 'false'
118
+ B.get_boards('dashboard').first.get_string('website-name')
119
+ # => return string with website name
120
+ B.get_boards('dashboard').first.get_text('website-description')
121
+ # => return text with website description
122
+ ```
123
+
124
+ ---
125
+
126
+
127
+
128
+ # Structures
129
+
130
+ _Structures_ are the DNA of the application _components_ and _boards_. Each _component_ and _board_ is defined by a _structure_.
131
+
132
+ ## Create a structure
133
+
134
+ Creating a _structure_ is fairly easy. Just click on the sidebar tab called _Structures_ and then on the _New structure_ button. You will be asked to provide a name which will be used from then on to call the relative component or board. You can also select the type of structure: _component_ or _board_. The former will let you create multiple instances for that structure whereas the latter will let you create only one instance. Why? A _component_ is great for something like posts, pages and so on. _Board_ are useful for content that is set once throghout the application, for example the website description.
135
+
136
+ Once the _structure_ has been created it's possible to add field groups. By default there is one field group called *General Details* which is empty. You can customize that or add new ones.
137
+
138
+ In order to add _field settings_ that will let you add content to your _component_ (or _board_) you need to enter on of the _structure's field groups_.
139
+
140
+ ## Retrieve a structure
141
+
142
+ Once you create a _structure_ you can call it from your controller like so:
143
+
144
+ ```ruby
145
+ @my_structure = Binda::Structure.find_by(slug: 'my-structure')
146
+ ```
147
+
148
+ From that you can do all sorts of things.
149
+
150
+ ```ruby
151
+ # get all field groups
152
+ @field_groups = @my_structure.field_groups
153
+
154
+ # get all field settings
155
+ @field_settings = []
156
+ @field_groups.each do |group|
157
+ group.field_settings.each do |setting|
158
+ @field_settings << setting
159
+ end
160
+ end
161
+ ```
162
+
163
+ Depending on the structure type, to retrieve all related _components_ or the related _board_ you can use the Binda helper (which is suggested if you care about performance, see [component](#Components) or [board](#Boards)) or do it the usual Ruby on Rails way like so:
164
+
165
+ ```ruby
166
+ # if structure is a component type
167
+ @components = @my_structure.components
168
+
169
+ # if structure is a board type
170
+ @board = @my_structure.board
171
+ ```
172
+
173
+ ---
174
+
175
+
176
+
177
+ # Components
178
+
179
+ _Components_ are instances of a _structure_.
180
+
181
+ In order to retrieve a single _component_ you can use one of the following methods:
182
+
183
+ ## Using the helper
184
+
185
+ A useful helper is `B.get_components`. This helper will retrieve all _components_ from a specific _structure_. Find specific info in the [technical documentation](http://www.rubydoc.info/gems/binda/Binda/DefaultHelpers).
186
+
187
+ Then in any of your controllers you can retrive the components belonging to a specific structure just using the structure slug. Let's see an example that uses the `page` structure to retrieve all related components.
188
+
189
+ ```ruby
190
+ B.get_components('page')
191
+ # return all pages
192
+
193
+ B.get_components('page')
194
+ .find_by(slug: 'my-first-page')
195
+ # return `my-first-page`
196
+
197
+ # expand query
198
+ B.get_components('page')
199
+ .published
200
+ .order('position')
201
+
202
+ # reduce N+1 query issue by including dependencies
203
+ B.get_components('page')
204
+ .includes(:strings, :texts, repeaters: [:images, :selections])
205
+ ```
206
+
207
+ To be able to use this helper in the application console you need to run `Binda.include Bidna::DefaultHelpers`
208
+
209
+ ## Using the rails way
210
+
211
+ Retrieve a single component
212
+
213
+ ```ruby
214
+ @component = Binda::Component.find_by( slug: 'my-first-component')
215
+ ```
216
+
217
+ Retrieve a single component but eager load the field setting needed. This optimize the query and greatly reduce request time.
218
+
219
+ ```ruby
220
+ @component = Binda::Component.where(slug: 'my-first-component')
221
+ .includes( :strings, :texts, :assets, :selections )
222
+ .first
223
+ ```
224
+
225
+ Then, if you want to retrieve all components that belongs to a specific structure **don't** do the following:
226
+
227
+ ```ruby
228
+ # SLOW
229
+ @structure = Binda::Structure.find_by( slug: 'my-structure')
230
+ @components = @structure.components
231
+ ```
232
+
233
+ **Do this instead!**
234
+
235
+ ```ruby
236
+ # FASTER
237
+ @components = Binda::Component.where( structure_id: Binda::Structure.where( slug: 'my-structure' ) )
238
+
239
+ # which is the same thing of doing:
240
+ @components = B.get_components('my-structure')
241
+ ```
242
+
243
+ You can add any other option to the query then:
244
+
245
+ ```ruby
246
+ @components = Binda::Component.where( structure_id: Binda::Structure.where( slug: 'my-structure' ) )
247
+ .published
248
+ .order('name')
249
+ .includes( :strings, :texts, :assets, :selections )
250
+
251
+ # which is the same thing of doing:
252
+ @components = B.get_components('my-structure')
253
+ .published
254
+ .order('name')
255
+ .includes( :strings, :texts, :assets, :selections )
256
+ ```
257
+
258
+ ## Enable preview
259
+
260
+ When you created the component structure you might have enabled the **preview mode**. The easiest way to integrate the preview with yor application is to update the `config/routes.rb` file with a redirect that binds the component preview url to the controller that is in chardge of showing that component in your application.
261
+
262
+ For example let's say you have a *animal* structure with slug `animal`:
263
+
264
+ ```ruby
265
+ # your application single animal route
266
+ get 'animals/:slug', to: 'animals#show', as: animal
267
+
268
+ # the bound to a animal preview should be
269
+ get "admin_panel/animal/:slug", to: redirect('/animals/%{slug}')
270
+ ```
271
+
272
+ ---
273
+
274
+
275
+
276
+ # Boards
277
+
278
+ _Boards_ give you the possibility to have a panel where to list some specific settings.
279
+
280
+ A great example of a _board_ is the _Dashboard_. This board is useful to store the generic data which can be used throughout the application, like the website name and description.
281
+
282
+ You can create as many _boards_ you like and add any field you want. To set up a _board_ go to _Structures_ and create a new _structure_ with type "_board_". The name of the structure will determine also the name of the board. Once created a new tab will appear on the main sidebar. The newly created structure is already populated with the _General Details_ field group which is initially empty. To add new field settings you can decide to edit this field group or create a new field group.
283
+
284
+ Once ready you can head to the _board_ page by clicking the tab on the main sidebar and populate the fields with your content.
285
+
286
+ To retrieve _board_ content you can use one of those methods:
287
+
288
+ ```ruby
289
+ @board = Binda::Board.find_by(slug: 'my_board')
290
+
291
+ @board = B.get_boards('my-board').first
292
+ ```
293
+
294
+ ## Board Helpers
295
+
296
+ If you care about performance you can use the `Binda.get_board` helper to retrieve the _board_ object.
297
+
298
+ This method retrieves a **board**. Find specific info in the [technical documentation](http://www.rubydoc.info/gems/binda/Binda/DefaultHelpers).
299
+
300
+ ```ruby
301
+ B.get_boards('my-dashboard').first
302
+ # return the board
303
+
304
+ # reduce N+1 query issue by including dependencies
305
+ B.get_boards('default-dashboard')
306
+ .includes(:strings, :texts, repeaters: [:images, :selections])
307
+ .first
308
+ ```
309
+
310
+ _Boards_ can make use of all field helpers. See the [fields documentation](#Field_Helpers) for more information.
311
+
312
+ To be able to use this helper in the application console you need to run `Binda.include Bidna::DefaultHelpers`
313
+
314
+ ## Using console
315
+
316
+ If you are going to use Rails console you need to know that a _board_ is automatically generated once you create a _structure_ with an `instance_type` of `board`.
317
+
318
+ Example:
319
+
320
+ ```bash
321
+ board_structure = Binda::Structure.create!(name: 'new dashboard', instance_type: 'board')
322
+ board = board_structure.board
323
+ ```
324
+
325
+ ---
326
+
327
+
328
+
329
+ # Fields
330
+
331
+ Every _field setting_ is based on a field type. You can create several field settings based on a single field type.
332
+
333
+ Here below a list of field types available and their use:
334
+
335
+ | Field setting | Use details |
336
+ |---|---|
337
+ | String | Store a string. No formatting options available. |
338
+ | Text | Store a text. TinyMCE let's you format the text as you like. |
339
+ | Image | Store image. |
340
+ | Video | Store video. |
341
+ | Date | Store a date. |
342
+ | Radio | Select one choice amongst a custom set. |
343
+ | Selection | Select one or more choices amongst a custom set. |
344
+ | Check Box | Select one or more choices amongst a custom set. |
345
+ | Repeater | Store multiple instances of a field or a collection of fields. |
346
+ | Relation | Connect multiple instances of a _component_ or _board_ to each other. |
347
+
348
+ ## How to get field content
349
+
350
+ Every field setting has a unique `slug`. The default `slug` is made of the `structure name + field group name + field setting name`. If it's a child of a _repeater_ the slug will include the _repeater_ slug as well. You can customise the `slug` as you like keeping in mind that there every `slug` can be attach to only one field setting.
351
+
352
+ In order to retrieve a field content you can use one of the following helpers.
353
+
354
+ Let's say you want to get a specific field from a _component_ instance:
355
+
356
+ ```ruby
357
+ # controller file
358
+ @article = B.get_components('article').first
359
+
360
+ # view file
361
+ @article.get_text('description')
362
+ # => 'Hello world'
363
+ ```
364
+
365
+ This helpers will work for any instance of `Binda::Component`, `Binda::Board` and `Binda::Repeater`.
366
+
367
+ ## Field Helpers
368
+
369
+ Here below a list of helpers.
370
+
371
+ You can retrieve field content from a instance of `Binda::Component`, `Binda::Board` or `Binda::Repeater`. See [How to get field content](#How_to_get_field_content).
372
+
373
+ **NOTE: source links are based on the latest public version.** If you are using an older version or a specific branch please refer to the [source](https://github.com/lacolonia/binda/blob/master/app/models/concerns/binda/fieldable_associations.rb) switching to the branch/tag you are looking for.
374
+
375
+ | Helper |||
376
+ |---|---|---|
377
+ | `has_text`| Returns `true/false` | [source](http://www.rubydoc.info/gems/binda/Binda/FieldableAssociations:has_text) |
378
+ | `get_text`| Returns the text. Use [`simple_format`](https://apidock.com/rails/ActionView/Helpers/TextHelper/simple_format) to maintain HTML tags. | [source](http://www.rubydoc.info/gems/binda/Binda/FieldableAssociations:get_text) |
379
+ | `has_string`| Returns `true/false`. | [source](http://www.rubydoc.info/gems/binda/Binda/FieldableAssociations:has_string) |
380
+ | `get_string`| Returns the text. Use [`simple_format`](https://apidock.com/rails/ActionView/Helpers/TextHelper/simple_format) to maintain HTML tags. | [source](http://www.rubydoc.info/gems/binda/Binda/FieldableAssociations:get_string) |
381
+ |`has_image`| Returns `true/false`.| [source](http://www.rubydoc.info/gems/binda/Binda/FieldableAssociations:has_image) |
382
+ |`get_image_url(size)`| Returns the url of the image. A thumbnail version (200x200) by specifying `thumb` size. If no size is provided the method will return the original image size. | [source](http://www.rubydoc.info/gems/binda/Binda/FieldableAssociations:get_image_url) |
383
+ |`get_image_path(size)`| Returns the path of the image. A thumbnail version (200x200) by specifying `thumb` size. If no size is provided the method will return the original image size. | [source](http://www.rubydoc.info/gems/binda/Binda/FieldableAssociations:get_image_path) |
384
+ |`has_video`| Returns `true/false`.| [source](http://www.rubydoc.info/gems/binda/Binda/FieldableAssociations:has_video) |
385
+ |`get_video_url`| Returns the url of the video. | [source](http://www.rubydoc.info/gems/binda/Binda/FieldableAssociations:get_video_url) |
386
+ |`get_video_path`| Returns the path of the video. | [source](http://www.rubydoc.info/gems/binda/Binda/FieldableAssociations:get_image_path) |
387
+ |`has_date`| Returns `true/false` | [source](http://www.rubydoc.info/gems/binda/Binda/FieldableAssociations:has_date) |
388
+ |`get_date`| Returns the date in `datetime` format. Use [`strftime`](https://apidock.com/rails/ActiveSupport/TimeWithZone/strftime) to change date format. | [source](http://www.rubydoc.info/gems/binda/Binda/FieldableAssociations:get_date) |
389
+ |`has_repeater`| Returns `true/false`| [source](http://www.rubydoc.info/gems/binda/Binda/FieldableAssociations:has_repeater) |
390
+ |`get_repeater`| Returns an array of repeaters. See next session for more details. | [source](http://www.rubydoc.info/gems/binda/Binda/FieldableAssociations:get_repeater) |
391
+ |`get_selection_choice`| Returns an hash with label and value of the selected choice. | [source](http://www.rubydoc.info/gems/binda/Binda/FieldableAssociations:get_selection_choice) |
392
+ |`get_radio_choice`| Returns an hash with label and value of the selected choice. | [source](http://www.rubydoc.info/gems/binda/Binda/FieldableAssociations:get_radio_choice) |
393
+ |`get_checkbox_choices`| Returns an array of label/value pairs of all the selected choices. | [source](http://www.rubydoc.info/gems/binda/Binda/FieldableAssociations:get_checkbox_choices) |
394
+ |`has_related_components`| Check if has related components. | [source](http://www.rubydoc.info/gems/binda/Binda/FieldableAssociations:has_related_components) |
395
+ |`get_related_components`| Retrieve related components. | [source](http://www.rubydoc.info/gems/binda/Binda/FieldableAssociations:has_related_components) |
396
+ |`has_related_boards`| Check if has related boards. | [source](http://www.rubydoc.info/gems/binda/Binda/FieldableAssociations:has_related_boards) |
397
+ |`get_related_boards`| Retrieve related boards. | [source](http://www.rubydoc.info/gems/binda/Binda/FieldableAssociations:has_related_boards) |
398
+
399
+ If you need to get each dependent of all relations with a specified slug (or slugs) you can use `B.get_relation_dependents` helper. This is very useful to retrieve only the instances which have a owner (and therefore are 'dependents').
400
+
401
+ For example, you have several `event` components, each related to several `artist` components with a `partecipants` relation field where every event owns some artists. If you want to retrieve all artists which have been involved in at least one event you can try with
402
+
403
+ ```ruby
404
+ B.get_relation_dependents('partecipants')
405
+ # returns all artists which are related to at least one event
406
+ ```
407
+
408
+ If you want to retrieve each owner of all relations with the specified slug (or slugs) you can do the following:
409
+
410
+ ```ruby
411
+ B.get_relation_owners('partecipants')
412
+ # returns all events which are related to at least one artist
413
+ ```
414
+
415
+
416
+ ---
417
+
418
+
419
+
420
+ # Repeaters
421
+
422
+ Generally a _field setting_ is associated to a single content entry. Therefore if a _field setting_ has type `text` there will be only one `Binda::Text` related to it.
423
+
424
+ If you want to have multiple entries for a single _field setting_ you need to create a _repeater_.
425
+
426
+ For example: lets say you have a _Movie_ component and you need to list some credits. You can create a _repeater_ and add a field setting with type `string` and name it _credit_. In the _movie_ editor you will able to add as many credit field you like.
427
+
428
+ Another example: imagine you setup a repeater with two children, a string and a asset field.
429
+
430
+ ```
431
+ page (structure)
432
+ |__ default details (field_group)
433
+ |__ slide (repeater)
434
+ |__ title (string)
435
+ |__ image (asset)
436
+ ```
437
+
438
+ Then on the component editor you can
439
+
440
+ ```
441
+ My first page (component)
442
+ |__ slide_1
443
+ |__ 'My first slide'
444
+ |__ img_1.png
445
+ |__ slide_2
446
+ |__ 'My second slide'
447
+ |__ img_2.png
448
+ |__ slide_3
449
+ |__ 'My last slide'
450
+ |__ img_999.png
451
+
452
+ ```
453
+
454
+ The code can be something like this:
455
+
456
+ ```ruby
457
+ @page = B.get_components('page')
458
+ .where(slug: 'my-first-page')
459
+ .includes(repeaters: [:texts, :images])
460
+ .first
461
+
462
+ @page.get_repeater('slide').each do |slide|
463
+ slide.title
464
+ slide.get_image_path
465
+ end
466
+ ```
467
+
468
+ To be able to use this helper in the application console you need to run `Binda.include Bidna::DefaultHelpers`
469
+
470
+ The repeater model `Binda::Repeater` can make use of any of the [field helpers](#Field_Helpers).
471
+
472
+ ---
473
+
474
+
475
+
476
+ # Users
477
+
478
+ Binda offers two main roles. The **super admin** which is capable of administrating the entire website and the **standard admin** user which cannot manage the structures, field groups and field settings.
479
+
480
+ In case you cannot access with your account anymore you can create a new **super admin** via console running this task:
481
+
482
+ ```bash
483
+ rails binda:create_super_admin
484
+ ```
485
+
486
+ ---
487
+
488
+
489
+ # Maintenance Mode
490
+
491
+ Binda offers a maintenance mode out-of-the-box. In your routes you will find:
492
+
493
+ ```ruby
494
+ # config/routes.rb
495
+ get 'maintenance', to: 'maintenance#index', as: 'maintenance'
496
+ ```
497
+
498
+ You can change the url to be whatever you like, as long as you keep the route name. For example
499
+
500
+ ```ruby
501
+ # config/routes.rb
502
+ get 'under_construction', to: 'maintenance#index', as: 'maintenance'
503
+ ```
504
+
505
+ The maintenance behaviour is controlled by the `MaintenanceHelper` included in your `app/controllers/application_controller.rb`. If you don't have it make sure it's included this way:
506
+
507
+ ```ruby
508
+ # app/controllers/application_controller.rb
509
+ include ::Binda::MaintenanceHelpers
510
+ ```
511
+
512
+ ## Customize maintenance appeareance
513
+
514
+ The maintenance mode is controlled by the `app/controllers/maintenance_controller.rb` which renders a single view: `app/views/layouts/maintenance.html.erb`. You can do whatever you like with it.
515
+
516
+ To change appereance and behaviour of the page add your styles to `app/assets/stylesheets/maintenance.scss` and your scripts to `app/assets/javascript/maintenance.js`. These are manifest files so if you need jQuery for example, you just need to add `//= jquery` at the top of `maintenance.js` file.
517
+
518
+ ---
519
+
520
+
521
+ # Plugins
522
+
523
+ Here a list of useful plugins:
524
+
525
+ - [Binda Multilanguage](https://github.com/lacolonia/binda_multilanguage)
526
+
527
+ ---
528
+
529
+
530
+
531
+ # Upgrade
532
+
533
+ Here some upgrade instruction.
534
+
535
+
536
+ To upgrade from 0.0.6 to 0.0.7 please refer to the [release documentation](https://github.com/lacolonia/binda/releases/tag/0.0.7)
537
+
538
+ ---
539
+
540
+
541
+
542
+ # Create a Binda plugin
543
+
544
+ You can create a plugin to add new features to Binda. This is the most suitable and correct way to develop a new feature that will be possibly shared and use by everyone in the future.
545
+
546
+ The first step is to create a plugin.
547
+ ```
548
+ rails plugin new binda_new_feature --skip-test --dummy-path=spec/dummy --mountable
20
549
  ```
550
+ This will create a folder `binda_new_feature` which will contain your plugin `BindaNewFeature`.
551
+
552
+ We will `--skip-test` as we are going to use Rspec instead of standard Ruby on Rails test suite. For the same reason the `--dummy-path` will change to `spec/dummy`. Ultimately we want the plugin to be `--mountable`.
553
+
554
+ ## Add dependencies
555
+ Populate `binda_new_feature.gemspec` with dependencies and replace every `TODO` with a content that makes sense.
556
+
557
+ ```ruby
558
+ # binda_new_feature.gemspec
559
+
560
+ $:.push File.expand_path("../lib", __FILE__)
561
+
562
+ # Maintain your gem's version:
563
+ require "binda_new_feature/version"
564
+
565
+ # Describe your gem and declare its dependencies:
566
+ Gem::Specification.new do |s|
567
+ s.name = "binda_new_feature"
568
+ s.version = BindaNewFeature::VERSION
569
+ s.authors = ["Me"]
570
+ s.email = ["me@mydomain.com"]
571
+ s.homepage = "http://mydomain.com"
572
+ s.summary = "Binda New Feature is plugin for Binda CMS"
573
+ s.description = "Use this plugin to enable new feature in your application"
574
+ s.license = "MIT"
21
575
 
22
- To install Binda run the installer from terminal.
576
+ s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]
23
577
 
24
- ``` bash
25
- $ rails g binda:install
578
+ s.add_dependency "rails", ">= 5.0", "< 5.2"
579
+ s.add_dependency "binda", "~> 0.0"
580
+
581
+ # Test suite
582
+ s.add_development_dependency "rspec-rails", ">= 3.5", "< 3.7"
583
+ end
584
+ ```
585
+
586
+ Make sure all dependencies are versioned in order to avoid issues due to deprecation in future releases. (The above versions are dated 07/2017)
587
+
588
+ ## Prepare plugin for testing
589
+ Before coding anything make sure you complete the following steps:
590
+
591
+
592
+ 1) Install Rspec
593
+
594
+ ```
595
+ rails generate rspec:install
596
+ ```
597
+
598
+ 2) Install Binda on the dummy application
599
+
600
+ ```
601
+ cd spec/dummy
602
+ rails generate binda:install
26
603
  ```
27
604
 
28
- Now you are good to go. Run `rails s` and check the administration panel at `http://localhost:3000/admin_panel`.
605
+ 3) Tell `config.generators` to use Rspec:
29
606
 
30
- To get into details read [Binda Guidelines](https://github.com/lacolonia/binda/wiki).
607
+ ```ruby
608
+ # lib/binda_new_feature/engine.rb
609
+
610
+ module BindaNewFeature
611
+ class Engine < ::Rails::Engine
612
+ isolate_namespace BindaNewFeature
613
+
614
+ config.generators do |g|
615
+ g.test_framework :rspec
616
+ end
617
+
618
+ end
619
+ end
620
+ ```
621
+
622
+ This makes sure Rails uses Rspec to create test specs every time you generate something with `rails g` command (be it a model, controller or scaffold).
623
+
624
+ 4) change a line in `spec/rails_helper.rb`
625
+
626
+ ```ruby
627
+ # require File.expand_path('../../config/environment', __FILE__)
628
+ # should be changed to
629
+ require File.expand_path('../dummy/config/environment', __FILE__)
630
+ ```
631
+
632
+ ## Create a first test
633
+ Let's create a fake controller to see if the plugin works.
634
+
635
+ ```
636
+ rails generate controller binda/foo index --skip-namespace
637
+ ```
638
+
639
+ This command create a controller called `Binda::Foo` which will be integrated to `Binda` engine and, we have done everything correctly, we should have a spec ready to be populated with tests in `spec/controllers/binda/foo_controller_spec.rb`.
640
+
641
+ Lets add Binda routes to that spec. (See why you need to specify routes [here](https://content.pivotal.io/blog/writing-rails-engine-rspec-controller-tests))
642
+
643
+ ```ruby
644
+ # spec/controllers/binda/foo_controller_spec.rb
645
+
646
+ require 'rails_helper'
647
+
648
+ module BindaNewFeature
649
+ RSpec.describe FooController, type: :controller do
650
+
651
+ # This line is very important
652
+ routes { Binda::Engine.routes }
653
+
654
+ describe 'GET #index' do
655
+ it 'returns http success' do
656
+ get :index
657
+ expect(response).to have_http_status(:success)
658
+ end
659
+ end
660
+
661
+ end
662
+ end
663
+ ```
31
664
 
32
- **Warning: run the installer once.** Running the installer for each application environment will cause issues with users' passwords. Also remember that if you need to re-install Binda you need to drop all Binda database tables first. More details [here](https://github.com/lacolonia/binda/wiki/Installation)
665
+ The generator unfortunately creates a namespace inside `BindaNewFeature::Engine.routes` which we will not use. Instead add the folloing lines which uses `Binda::Engine.routes`
33
666
 
34
- ## Bug reporting
667
+ ```ruby
668
+ # config/routes.rb
669
+
670
+ BindaNewFeature::Engine.routes.draw do
671
+ end
672
+
673
+ Binda::Engine.routes.draw do
674
+ get 'foo', to: 'foo#index'
675
+ end
676
+ ```
677
+
678
+ Now running `rspec` the test should pass. (you might have 2 pending examples for foo helper and view, but that's not a problem for now).
679
+
680
+ ## Extend a Binda models and controllers
681
+ Sometimes you want to add new methods to Binda models with your plugin. In order to do it you need to make your plugin aware of Binda and its models. To achive it require Binda at the top of the `lib/binda_new_feature/engine.rb` like so:
682
+
683
+ ```ruby
684
+ require "binda"
685
+ ```
686
+
687
+ If you want to access Binda::ApplicationController to inherit its methods change the parent_controller configuration of your plugin in the same file:
688
+
689
+ ```ruby
690
+ # lib/binda_new_feature/engine.rb
691
+
692
+ # ... all `require` gems
693
+
694
+ module BindaNewFeature
695
+ class Engine < ::Rails::Engine
696
+
697
+ # ... some other code
698
+
699
+ config.parent_controller = 'Binda::ApplicationController'
700
+ end
701
+ end
702
+ ```
703
+
704
+ ---
705
+
706
+
707
+
708
+ # How to create a form of nested components
709
+
710
+ Let's say you have a component which depends on another components and you want your user to edit both of them in the same form. No problem.
711
+
712
+ ```ruby
713
+ # controller
714
+ # Let's say your structure has slug = `my_structure` and id = `123`
715
+ # and you want to edit `component_A` and its child `component_B`
716
+
717
+ @structure = Binda::Structure.find(123)
718
+ # or if you use Friendly_id
719
+ @structure = Binda::Structure.friendly.find('my_structure')
720
+
721
+ @component_A = @structure.components.detect{|c| c.slug == 'component_A'}
722
+ @component_B = @structure.components.detect{|c| c.slug == 'component_B'}
723
+ ```
724
+
725
+ ```ruby
726
+ # view
727
+ <%= simple_form_for @structure, html: { class: 'some-form-class' } do |f| %>
728
+ <%= f.simple_fields_for :components, @component_A do |A| %>
729
+ <=% A.input :name_of_a_column %>
730
+ <=% A.input :name_of_another_column %>
731
+ <% end %>
732
+ <%= f.simple_fields_for :components, @component_B do |B| %>
733
+ <=% B.input :name_of_a_column %>
734
+ <=% B.input :name_of_another_column %>
735
+ <% end %>
736
+ <% end %>
737
+ ```
738
+
739
+ ---
740
+
741
+
742
+
743
+ # How to contribute
744
+
745
+ Any contribution is more than welcome.
746
+
747
+ To contribute [fork this project](https://github.com/lacolonia/binda/wiki/_new#fork-destination-box) and clone the fork in your local machine. There you are free to experiment following this principles:
748
+ - before diving into the code [open a issue](https://github.com/lacolonia/binda/issues/new) to explain what you'd like to do
749
+ - don't add gem dependencies unless it's absolutely necessary
750
+ - keep it simple and be DRY
751
+ - add [tests](#How_to_test)
752
+ - comment your code following [Yard guidelines](http://www.rubydoc.info/gems/yard/file/docs/GettingStarted.md) principles (use `yard server -r` to see the HTML version at `http://localhost:8808`, if you make any change to the doc just refresh the page and the documentaion page gets updated automagically)
753
+ - update the README.rb file, use Github markdown
754
+ - if you are not adding a core feature consider writing a plugin instead
755
+ - improve and/or add new I18n translations
756
+ - when fixing a bug, provide a failing test case that your patch solves
757
+
758
+ ## How to work locally
759
+ Ensure you have installed Binda dependencies.
760
+
761
+ ```bash
762
+ cd path/to/binda
763
+ bundle install
764
+ npm install
765
+ ```
766
+
767
+ To see what you are actually doing you can make use of the **dummy application** which is shipped with Binda.
768
+
769
+ Ensure you have Postgres up and running, then create dummy databases.
770
+
771
+ ```bash
772
+ cd spec/dummy
773
+ rails db:create
774
+ ```
775
+
776
+ If you haven't already, install Binda.
777
+
778
+ ```bash
779
+ rails generate binda:install
780
+ ```
781
+
782
+ In order to edit javascript files you need to run Webpack and leave the terminal window open, so Webpack can compile everytime you save a file. To install Webpack run `npm install` from the root of your application. Then everytime you want to edit a javascript file run:
783
+
784
+ ```bash
785
+ webpack
786
+ ```
787
+
788
+ If you need to reset your database run the following commands
789
+
790
+ ```
791
+ cd spec/dummy
792
+ rails db:drop && rails db:create
793
+ rails generate binda:setup
794
+ ```
795
+
796
+ In order to make the dummy application flexible any update to that folder isn't saved in the repository.
797
+
798
+ This let you as you prefer with your dummy without the hassle of cleaning it before creating a commit.
799
+
800
+ ## How to test
801
+ In order to avoid the *it works on my machine* issue, test are run via Travis every time a commit is pushed. Make sure you register your forked version on Travis in order to test every commit. If you don't the forked version will be tested once you make a pull request to the original repository.
802
+
803
+ If you want (and you should) test locally Binda use RSpec, FactoryGirl and Capybara to run tests. You can find all specs in `spec` folder. Capybara needs Firefox and [Geckodriver](https://github.com/mozilla/geckodriver) to run so make sure you have it installed in your machine. If you have Node you can install Geckodriver via npm:
804
+
805
+ ```bash
806
+ npm install --global geckodriver
807
+ ```
808
+
809
+ Some specs are run against the database. If you haven't installed Binda on the dummy application yet run:
810
+
811
+ ```bash
812
+ rails db:migrate RAILS_ENV=test
813
+ ```
814
+
815
+ The above command might generate an error. This is probably because you have previously installed Binda and the generator finds migration both in `binda/db/migrate` and `binda/spec/dummy/db/migrate`. To solve the issue, remove the `spec/dummy/db/migrate` folder and run the previous command again. Here below the oneliner (be aware that this destroy both development and test databases of the dummy app):
816
+
817
+ ```bash
818
+ rm -rf spec/dummy/db/migrate && rails db:drop && rails db:create && rails generate binda:install && rails db:migrate RAILS_ENV=test
819
+ ```
820
+
821
+ In case you are creating new migrations or modifing the default one, consider running the above command to refresh the `schema.rb` file while updating both databases.
822
+
823
+ If in the future you need to clean your dummy app code, simply run:
824
+
825
+ ```bash
826
+ rm -rf spec/dummy && git checkout spec/dummy
827
+ ```
828
+
829
+ **The command above should be run before any commit!**
830
+
831
+ Once all setup is done run RSpec every time you update the specs:
832
+
833
+ ```bash
834
+ rpsec
835
+ ```
836
+
837
+ Some helpful hints to debug tests are:
838
+
839
+ 1. Add `save_and_open_page` command in the code of the test example. This will save the page and let you inspect it.
840
+ 2. Add `binding.pry` this will stop the test and let you inspect the code at that moment of the code.
841
+ 3. In the command line, from Binda root folder, execute `tail -f ./spec/dummy/log/test.log` this will give you the list of operations executed by the server while you are running the test.
842
+
843
+ ## Update test coverage
844
+
845
+ Once tests are done update Code-Climate test coverage locally (Mac OSX).
846
+
847
+ ```bash
848
+ $ cd path/to/binda
849
+ $ curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-0.1.4-darwin-amd64 > ./cc-test-reporter
850
+ $ chmod +x ./cc-test-reporter
851
+ $ ./cc-test-reporter before-build
852
+ $ rspec
853
+ $ ./cc-test-reporter after-build -r a8789f8ca71f52cc879c1fa313d94547c9a0ddbd207977fe997f686a71e0c400
854
+ ```
855
+
856
+ `cc-test-reporter` is ignored by the repo, so it want be pushed.
857
+
858
+ Same thing can be done on linux usign another binary code (see [documentation](https://docs.codeclimate.com/docs/configuring-test-coverage)). Besides the test coverage can be done automatically via Travis as well, but not on pull requests.
859
+
860
+ ---
861
+
862
+
863
+
864
+ ### Bug reporting
35
865
  Please refer to this [guide](http://yourbugreportneedsmore.info).
36
- If you need direct help you can join [Binda Slack Community](https://binda.herokuapp.com).
866
+ If you need direct help you can join [Binda Slack Community](https://bindacms.slack.com).
37
867
 
38
868
 
39
- ## License
869
+ ### License
40
870
  The gem is available as open source under the terms of the [GNU General Public License v3.0](https://github.com/a-barbieri/binda/blob/master/LICENSE).
41
871
 
42
- ## Credits
872
+ ### Credits
43
873
  Binda is inspired by [Spina CMS](https://github.com/denkGroot/Spina).
44
874
 
45
875
  We give also credit to authors and contributors of the gems that Binda uses. Huge thank you to all of them.
46
876
 
47
- ## Who is Binda?
877
+ ### Who is Binda?
48
878
  Is [this guy here](https://en.wikipedia.org/wiki/Alfredo_Binda).
49
879
 
50
- ![Alfredo Binda 1927](./Alfredo_Binda_1927.jpg)
880
+ ![Alfredo Binda 1927](https://www.dropbox.com/s/ktv8qo13zvoc9g4/Alfredo_Binda_1927.jpg?raw=1)
881
+
882
+