decidim-decidim_awesome 0.7.2 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (235) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +62 -35
  3. data/Rakefile +11 -12
  4. data/app/cells/decidim/decidim_awesome/content_blocks/map/error.erb +11 -0
  5. data/app/cells/decidim/decidim_awesome/content_blocks/map/show.erb +1 -61
  6. data/app/cells/decidim/decidim_awesome/content_blocks/map_cell.rb +11 -0
  7. data/app/cells/decidim/decidim_awesome/content_blocks/map_form/show.erb +8 -4
  8. data/app/commands/decidim/decidim_awesome/admin/create_custom_redirect.rb +51 -0
  9. data/app/commands/decidim/decidim_awesome/admin/destroy_custom_redirect.rb +47 -0
  10. data/app/commands/decidim/decidim_awesome/admin/update_custom_redirect.rb +49 -0
  11. data/app/commands/decidim/decidim_awesome/create_editor_image.rb +12 -5
  12. data/app/controllers/concerns/decidim/decidim_awesome/not_found_redirect.rb +58 -0
  13. data/app/controllers/decidim/decidim_awesome/admin/checks_controller.rb +15 -22
  14. data/app/controllers/decidim/decidim_awesome/admin/config_controller.rb +9 -1
  15. data/app/controllers/decidim/decidim_awesome/admin/custom_redirects_controller.rb +91 -0
  16. data/app/controllers/decidim/decidim_awesome/admin/menu_hacks_controller.rb +5 -8
  17. data/app/controllers/decidim/decidim_awesome/blank_component_controller.rb +19 -0
  18. data/app/controllers/decidim/decidim_awesome/editor_images_controller.rb +2 -3
  19. data/app/controllers/decidim/decidim_awesome/iframe_component/iframe_controller.rb +1 -1
  20. data/app/controllers/decidim/decidim_awesome/map_component/map_controller.rb +2 -6
  21. data/app/forms/decidim/decidim_awesome/admin/config_form.rb +2 -0
  22. data/app/forms/decidim/decidim_awesome/admin/custom_redirect_form.rb +45 -0
  23. data/app/forms/decidim/decidim_awesome/editor_image_form.rb +3 -2
  24. data/app/forms/decidim/decidim_awesome/proposals/proposal_wizard_create_step_form_override.rb +38 -0
  25. data/app/helpers/decidim/decidim_awesome/admin/config_constraints_helpers.rb +22 -9
  26. data/app/helpers/decidim/decidim_awesome/admin/system_checker_helpers.rb +36 -0
  27. data/app/helpers/decidim/decidim_awesome/map_helper.rb +18 -12
  28. data/app/helpers/decidim/decidim_awesome/proposals/application_helper_override.rb +2 -2
  29. data/app/jobs/decidim/decidim_awesome/migrate_legacy_images_job.rb +106 -0
  30. data/app/models/decidim/decidim_awesome/editor_image.rb +4 -9
  31. data/app/packs/entrypoints/decidim_admin_decidim_awesome.js +5 -0
  32. data/app/packs/entrypoints/decidim_admin_decidim_awesome.scss +1 -0
  33. data/app/packs/entrypoints/decidim_admin_decidim_awesome_custom_fields.js +2 -0
  34. data/app/packs/entrypoints/decidim_decidim_awesome.js +9 -0
  35. data/app/packs/entrypoints/decidim_decidim_awesome.scss +1 -0
  36. data/app/packs/entrypoints/decidim_decidim_awesome_admin_form_exit_warn.js +1 -0
  37. data/app/packs/entrypoints/decidim_decidim_awesome_custom_fields.js +1 -0
  38. data/app/packs/entrypoints/decidim_decidim_awesome_iframe.scss +1 -0
  39. data/app/packs/entrypoints/decidim_decidim_awesome_map.js +5 -0
  40. data/app/packs/entrypoints/decidim_decidim_awesome_map.scss +1 -0
  41. data/app/{assets → packs}/images/decidim/decidim_awesome/platoniq-logo.png +0 -0
  42. data/app/{assets/javascripts/decidim/decidim_awesome/admin/auto_edit.js.es6 → packs/src/decidim/decidim_awesome/admin/auto_edit.js} +39 -34
  43. data/app/packs/src/decidim/decidim_awesome/admin/check_redirections.js +48 -0
  44. data/app/{assets/javascripts/decidim/decidim_awesome/admin/codemirror.js.es6 → packs/src/decidim/decidim_awesome/admin/codemirror.js} +4 -4
  45. data/app/packs/src/decidim/decidim_awesome/admin/constraints.js +55 -0
  46. data/app/{assets/javascripts/decidim/decidim_awesome/admin/form_builder.js.es6 → packs/src/decidim/decidim_awesome/admin/custom_fields_builder.js} +23 -26
  47. data/app/{assets/javascripts/decidim/decidim_awesome/admin/form_exit_warn.js.es6 → packs/src/decidim/decidim_awesome/admin/form_exit_warn.js} +0 -2
  48. data/app/{assets/javascripts/decidim/decidim_awesome/admin/user_picker.js.es6 → packs/src/decidim/decidim_awesome/admin/user_picker.js} +3 -3
  49. data/app/packs/src/decidim/decidim_awesome/awesome_admin.js +23 -0
  50. data/app/packs/src/decidim/decidim_awesome/awesome_application.js +17 -0
  51. data/app/{assets/javascripts/decidim/decidim_awesome/awesome_map/api_fetcher.js.es6 → packs/src/decidim/decidim_awesome/awesome_map/api/api_fetcher.js} +1 -15
  52. data/app/packs/src/decidim/decidim_awesome/awesome_map/api/fetcher.js +131 -0
  53. data/app/packs/src/decidim/decidim_awesome/awesome_map/api/meetings_fetcher.js +59 -0
  54. data/app/packs/src/decidim/decidim_awesome/awesome_map/api/proposals_fetcher.js +52 -0
  55. data/app/packs/src/decidim/decidim_awesome/awesome_map/awesome_map.js +130 -0
  56. data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/controller.js +112 -0
  57. data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/meetings_controller.js +31 -0
  58. data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/proposals_controller.js +88 -0
  59. data/app/packs/src/decidim/decidim_awesome/awesome_map/controls_ui.js +221 -0
  60. data/app/packs/src/decidim/decidim_awesome/awesome_map/load_map.js +51 -0
  61. data/app/packs/src/decidim/decidim_awesome/editors/editor.js +190 -0
  62. data/app/{assets/javascripts/decidim/decidim_awesome/editors/tabs_focus.js.es6 → packs/src/decidim/decidim_awesome/editors/tabs_focus.js} +4 -6
  63. data/app/{assets/javascripts/decidim/decidim_awesome/forms/autosave.js.es6 → packs/src/decidim/decidim_awesome/forms/autosave.js} +20 -17
  64. data/app/packs/src/decidim/decidim_awesome/forms/custom_fields_renderer.js +207 -0
  65. data/app/{assets/javascripts/decidim/decidim_awesome/forms/rich_text_plugin.js.es6 → packs/src/decidim/decidim_awesome/forms/rich_text_plugin.js} +21 -20
  66. data/app/packs/src/decidim/decidim_awesome/proposals/custom_fields.js +22 -0
  67. data/app/packs/src/decidim/decidim_awesome/proposals/images.js +25 -0
  68. data/{vendor/assets/javascripts → app/packs/src/vendor}/image-resize.min.js +0 -0
  69. data/{vendor/assets/javascripts → app/packs/src/vendor}/image-upload.min.js +0 -0
  70. data/{vendor/assets/javascripts → app/packs/src/vendor}/jquery.truncate.js +0 -0
  71. data/app/packs/src/vendor/leaflet.featuregroup.subgroup.js +184 -0
  72. data/app/{assets → packs}/stylesheets/decidim/decidim_awesome/admin/auto_edits.scss +2 -1
  73. data/app/packs/stylesheets/decidim/decidim_awesome/admin/check_redirections.scss +28 -0
  74. data/app/{assets → packs}/stylesheets/decidim/decidim_awesome/admin/codemirror.scss +8 -6
  75. data/app/{assets → packs}/stylesheets/decidim/decidim_awesome/admin/constraints.scss +13 -13
  76. data/app/{assets → packs}/stylesheets/decidim/decidim_awesome/admin/custom_fields.scss +37 -10
  77. data/app/packs/stylesheets/decidim/decidim_awesome/admin/user_picker.scss +41 -0
  78. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_admin.scss +71 -0
  79. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_application.scss +19 -0
  80. data/app/{assets → packs}/stylesheets/decidim/decidim_awesome/awesome_iframe/iframe.scss +3 -3
  81. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_map/map.scss +176 -0
  82. data/app/{assets → packs}/stylesheets/decidim/decidim_awesome/editors/markdown_editor.scss +6 -4
  83. data/app/packs/stylesheets/decidim/decidim_awesome/editors/quill_editor.scss +58 -0
  84. data/app/{assets → packs}/stylesheets/decidim/decidim_awesome/forms/autosave.scss +2 -2
  85. data/app/packs/stylesheets/vendor/select2-foundation-theme.scss +348 -0
  86. data/app/presenters/decidim/decidim_awesome/menu_item_presenter_override.rb +25 -0
  87. data/app/presenters/decidim/decidim_awesome/menu_presenter_override.rb +23 -0
  88. data/app/uploaders/decidim/cw/decidim_awesome/image_uploader.rb +26 -0
  89. data/app/uploaders/decidim/decidim_awesome/image_uploader.rb +4 -16
  90. data/app/views/decidim/decidim_awesome/admin/checks/index.html.erb +28 -22
  91. data/app/views/decidim/decidim_awesome/admin/config/_constraints.html.erb +1 -1
  92. data/app/views/decidim/decidim_awesome/admin/config/_form_admins.html.erb +1 -1
  93. data/app/views/decidim/decidim_awesome/admin/config/_form_editors.html.erb +1 -0
  94. data/app/views/decidim/decidim_awesome/admin/config/_form_proposal_custom_fields.html.erb +1 -1
  95. data/app/views/decidim/decidim_awesome/admin/config/_form_styles.html.erb +7 -6
  96. data/app/views/decidim/decidim_awesome/admin/config/_modal.html.erb +1 -1
  97. data/app/views/decidim/decidim_awesome/admin/config/show.html.erb +3 -3
  98. data/app/views/decidim/decidim_awesome/admin/constraints/new.html.erb +1 -1
  99. data/app/views/decidim/decidim_awesome/admin/custom_redirects/_form.html.erb +6 -0
  100. data/app/views/decidim/decidim_awesome/admin/custom_redirects/edit.html.erb +13 -0
  101. data/app/views/decidim/decidim_awesome/admin/custom_redirects/index.html.erb +37 -0
  102. data/app/views/decidim/decidim_awesome/admin/custom_redirects/new.html.erb +13 -0
  103. data/app/views/decidim/decidim_awesome/admin/menu_hacks/edit.html.erb +1 -1
  104. data/app/views/decidim/decidim_awesome/admin/menu_hacks/new.html.erb +1 -1
  105. data/app/views/decidim/decidim_awesome/admin/proposals/_editor.html.erb +5 -3
  106. data/app/views/decidim/decidim_awesome/iframe_component/iframe/show.html.erb +1 -1
  107. data/app/views/decidim/decidim_awesome/map_component/map/_api_ready.html.erb +3 -0
  108. data/app/views/decidim/decidim_awesome/map_component/map/_map_template.html.erb +68 -0
  109. data/app/views/decidim/decidim_awesome/map_component/map/{error.erb → error.html.erb} +2 -0
  110. data/app/views/decidim/decidim_awesome/map_component/map/show.html.erb +3 -67
  111. data/app/views/decidim/proposals/admin/proposals/_form.html.erb +1 -1
  112. data/app/views/layouts/decidim/admin/decidim_awesome.html.erb +13 -9
  113. data/app/views/layouts/decidim/decidim_awesome/_awesome_config.html.erb +0 -2
  114. data/app/views/{v0.24 → v0.25}/decidim/proposals/collaborative_drafts/_show.html.erb +0 -0
  115. data/app/views/{v0.23 → v0.25}/layouts/decidim/_head.html.erb +12 -10
  116. data/app/views/v0.25/layouts/decidim/admin/_header.html.erb +11 -0
  117. data/app/views/{v0.23 → v0.26}/decidim/proposals/collaborative_drafts/_show.html.erb +1 -7
  118. data/app/views/{v0.24 → v0.26}/layouts/decidim/_head.html.erb +16 -10
  119. data/app/views/v0.26/layouts/decidim/admin/_header.html.erb +11 -0
  120. data/config/assets.rb +46 -0
  121. data/config/i18n-tasks.yml +6 -0
  122. data/config/locales/ca.yml +75 -13
  123. data/config/locales/cs.yml +63 -1
  124. data/config/locales/en.yml +67 -1
  125. data/config/locales/es.yml +63 -1
  126. data/config/locales/eu.yml +0 -232
  127. data/config/locales/fr.yml +115 -53
  128. data/config/locales/it.yml +63 -1
  129. data/config/locales/ja.yml +64 -3
  130. data/config/locales/nl.yml +5 -46
  131. data/config/locales/pt-BR.yml +346 -0
  132. data/config/locales/pt-PT.yml +7 -0
  133. data/config/locales/pt.yml +7 -0
  134. data/config/locales/sv.yml +67 -182
  135. data/lib/decidim/decidim_awesome/admin_engine.rb +10 -15
  136. data/lib/decidim/decidim_awesome/awesome.rb +214 -0
  137. data/lib/decidim/decidim_awesome/awesome_helpers.rb +0 -7
  138. data/lib/decidim/decidim_awesome/checksums.yml +13 -16
  139. data/lib/decidim/decidim_awesome/config.rb +1 -0
  140. data/lib/decidim/decidim_awesome/content_parsers/editor_images_parser.rb +39 -0
  141. data/lib/decidim/decidim_awesome/engine.rb +27 -55
  142. data/lib/decidim/decidim_awesome/iframe_component/admin_engine.rb +23 -0
  143. data/lib/decidim/decidim_awesome/iframe_component/component.rb +5 -5
  144. data/lib/decidim/decidim_awesome/map_component/admin_engine.rb +23 -0
  145. data/lib/decidim/decidim_awesome/map_component/component.rb +5 -4
  146. data/lib/decidim/decidim_awesome/map_component/engine.rb +34 -0
  147. data/lib/decidim/decidim_awesome/menu_hacker.rb +1 -0
  148. data/lib/decidim/decidim_awesome/test/factories.rb +2 -2
  149. data/lib/decidim/decidim_awesome/test/initializer.rb +25 -0
  150. data/lib/decidim/decidim_awesome/test/layouts/decidim/_head.html.erb +30 -2
  151. data/lib/decidim/decidim_awesome/test/layouts/decidim/admin/_header.html.erb +7 -2
  152. data/lib/decidim/decidim_awesome/test/shared_examples/config_examples.rb +18 -0
  153. data/lib/decidim/decidim_awesome/test/shared_examples/controller_examples.rb +13 -0
  154. data/lib/decidim/decidim_awesome/test/shared_examples/custom_redirects_contexts.rb +47 -0
  155. data/lib/decidim/decidim_awesome/test/shared_examples/menu_hack_contexts.rb +0 -17
  156. data/lib/decidim/decidim_awesome/test/shared_examples/scoped_admins_examples.rb +9 -17
  157. data/lib/decidim/decidim_awesome/test/shared_examples/summary_examples.rb +202 -0
  158. data/lib/decidim/decidim_awesome/version.rb +2 -2
  159. data/lib/decidim/decidim_awesome.rb +4 -152
  160. data/lib/tasks/decidim_awesome_active_storage_migrations_tasks.rake +37 -0
  161. data/lib/tasks/decidim_awesome_webpacker_tasks.rake +62 -0
  162. metadata +111 -113
  163. data/app/assets/config/decidim_admin_decidim_awesome_manifest.css +0 -3
  164. data/app/assets/config/decidim_admin_decidim_awesome_manifest.js +0 -2
  165. data/app/assets/config/decidim_decidim_awesome_manifest.css +0 -5
  166. data/app/assets/config/decidim_decidim_awesome_manifest.js +0 -4
  167. data/app/assets/config/legacy_decidim_admin_decidim_awesome_manifest.js +0 -2
  168. data/app/assets/config/legacy_decidim_decidim_awesome_manifest.js +0 -4
  169. data/app/assets/javascripts/decidim/decidim_awesome/admin/constraints.js.es6 +0 -54
  170. data/app/assets/javascripts/decidim/decidim_awesome/admin/legacy_form_builder.js.es6 +0 -80
  171. data/app/assets/javascripts/decidim/decidim_awesome/awesome_admin.js +0 -7
  172. data/app/assets/javascripts/decidim/decidim_awesome/awesome_application.js +0 -3
  173. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/categories.js.es6 +0 -25
  174. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/hashtags.js.es6 +0 -48
  175. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/layers.js.es6 +0 -107
  176. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/load_map.js.es6 +0 -15
  177. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/map.js.es6 +0 -207
  178. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/markers.js.es6 +0 -56
  179. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/meetings.js.es6 +0 -132
  180. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/proposals.js.es6 +0 -107
  181. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/utilities.js.es6 +0 -57
  182. data/app/assets/javascripts/decidim/decidim_awesome/editors/legacy_quill_editor.js.es6 +0 -172
  183. data/app/assets/javascripts/decidim/decidim_awesome/editors/quill_editor.js.es6 +0 -185
  184. data/app/assets/javascripts/decidim/decidim_awesome/forms/custom_fields_builder.js.es6 +0 -211
  185. data/app/assets/javascripts/decidim/decidim_awesome/legacy_admin.js +0 -7
  186. data/app/assets/javascripts/decidim/decidim_awesome/legacy_application.js +0 -3
  187. data/app/assets/javascripts/decidim/decidim_awesome/proposals/custom_fields.js.es6 +0 -21
  188. data/app/assets/javascripts/decidim/decidim_awesome/proposals/images.js.es6 +0 -25
  189. data/app/assets/stylesheets/decidim/decidim_awesome/admin/user_picker.scss +0 -35
  190. data/app/assets/stylesheets/decidim/decidim_awesome/awesome_admin.scss +0 -64
  191. data/app/assets/stylesheets/decidim/decidim_awesome/awesome_application.scss +0 -22
  192. data/app/assets/stylesheets/decidim/decidim_awesome/awesome_map/leaflet.scss.erb +0 -18
  193. data/app/assets/stylesheets/decidim/decidim_awesome/awesome_map/map.scss +0 -160
  194. data/app/assets/stylesheets/decidim/decidim_awesome/editors/quill_editor.scss +0 -22
  195. data/app/awesome_overrides/forms/decidim/proposals/proposal_wizard_create_step_form_override.rb +0 -28
  196. data/app/awesome_overrides/presenters/decidim/menu_presenter_override.rb +0 -39
  197. data/app/controllers/concerns/decidim/decidim_awesome/admin_not_found_redirect.rb +0 -39
  198. data/app/controllers/decidim/decidim_awesome/iframe_component/application_controller.rb +0 -15
  199. data/app/controllers/decidim/decidim_awesome/map_component/application_controller.rb +0 -15
  200. data/app/views/v0.23/layouts/decidim/admin/_header.html.erb +0 -12
  201. data/app/views/v0.24/layouts/decidim/admin/_header.html.erb +0 -12
  202. data/lib/decidim/decidim_awesome/test/themes/css.lvh.me.css +0 -3
  203. data/lib/decidim/decidim_awesome/test/themes/erb.lvh.me.scss.erb +0 -2
  204. data/lib/decidim/decidim_awesome/test/themes/scss.lvh.me.scss +0 -1
  205. data/lib/decidim/decidim_awesome/test/themes/test-theme/body.scss +0 -4
  206. data/vendor/assets/images/layers-2x.png +0 -0
  207. data/vendor/assets/images/layers.png +0 -0
  208. data/vendor/assets/images/marker-icon.png +0 -0
  209. data/vendor/assets/javascripts/codemirror-4.inline-attachment.js +0 -89
  210. data/vendor/assets/javascripts/codemirror.js +0 -9801
  211. data/vendor/assets/javascripts/delta.min.js +0 -405
  212. data/vendor/assets/javascripts/delta.min.js.map +0 -1
  213. data/vendor/assets/javascripts/europa.min.js +0 -4
  214. data/vendor/assets/javascripts/form-builder.min.js +0 -19
  215. data/vendor/assets/javascripts/form-render.min.js +0 -19
  216. data/vendor/assets/javascripts/form-storage.js +0 -824
  217. data/vendor/assets/javascripts/highlight.min.js +0 -44
  218. data/vendor/assets/javascripts/inline-attachment.js +0 -399
  219. data/vendor/assets/javascripts/inscrybmde.min.js +0 -7
  220. data/vendor/assets/javascripts/jquery-ui.min.js +0 -13
  221. data/vendor/assets/javascripts/jquery.inline-attachment.js +0 -66
  222. data/vendor/assets/javascripts/jsrender.min.js +0 -4
  223. data/vendor/assets/javascripts/keymap/sublime.js +0 -720
  224. data/vendor/assets/javascripts/leaflet.featuregroup.subgroup.js +0 -6
  225. data/vendor/assets/javascripts/mode/css/css.js +0 -864
  226. data/vendor/assets/javascripts/select2.js +0 -6147
  227. data/vendor/assets/langs/en-US.lang +0 -110
  228. data/vendor/assets/stylesheets/codemirror.css +0 -350
  229. data/vendor/assets/stylesheets/default.min.css +0 -1
  230. data/vendor/assets/stylesheets/foundation.min.css +0 -1
  231. data/vendor/assets/stylesheets/github.min.css +0 -2
  232. data/vendor/assets/stylesheets/inscrybmde.min.scss +0 -194
  233. data/vendor/assets/stylesheets/jquery-ui.min.css +0 -7
  234. data/vendor/assets/stylesheets/select2-foundation-theme.css +0 -249
  235. data/vendor/assets/stylesheets/select2.css +0 -515
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8913b46e29378088cc9b9eed9b69b0321e404f52900b725cea8e213bea47502e
4
- data.tar.gz: 5a79234c4b57bd7ea62589f833fef5ffff0468d4fec7ef907cbaabeb96df4dc0
3
+ metadata.gz: 82220fe500241ed7230f9b9c75496674ba199a90692d9b1e1ef0988dcfe73d8e
4
+ data.tar.gz: c0067b640dcc77a30556266f04af28337711cc084d3bddfd8b45d9c9e3566657
5
5
  SHA512:
6
- metadata.gz: cde9b7f7cfa19d19a9a9157c152e34a7ac849fd75b8cb2a23ae487836e561ff43bb961fa83d38e495069a427ec67e35afe05f1131ba1cbdf3509d25161f2b16f
7
- data.tar.gz: 20fa96490ce61a2679c13864e8b580f607b482a00176c684e1fd9f8014666f004a76299134c7096f57f9ff1e6aaaa2b4dca72df460fd1ad2180f5f129cea6291
6
+ metadata.gz: 13e277af1691dfe07af969b3422914e88738fddc84bbbe70bfdd029bf1abb04b618eac788fda19b8a802be612ccd27b145f9603f3f7032bdc10aef2c32f3ea28
7
+ data.tar.gz: d6710fa6ca902f9c03c2a8ccf8024b7770b12246fca1aa639a6e0d7eb657e88d68cf14c22169492236d6f496490a15f9aedb398bcdeefe14e41106b3a9f5d5cc
data/README.md CHANGED
@@ -1,9 +1,8 @@
1
1
  # Decidim::DecidimAwesome
2
2
 
3
- [![[CI] Test 0.24](https://github.com/Platoniq/decidim-module-decidim_awesome/actions/workflows/test-24.yml/badge.svg)](https://github.com/Platoniq/decidim-module-decidim_awesome/actions/workflows/test-24.yml)
4
- [![[CI] Test 0.23](https://github.com/Platoniq/decidim-module-decidim_awesome/actions/workflows/test-23.yml/badge.svg)](https://github.com/Platoniq/decidim-module-decidim_awesome/actions/workflows/test-23.yml)
3
+ [![[CI] Test](https://github.com/Platoniq/decidim-module-decidim_awesome/actions/workflows/test.yml/badge.svg)](https://github.com/Platoniq/decidim-module-decidim_awesome/actions/workflows/test.yml)
5
4
  [![Maintainability](https://api.codeclimate.com/v1/badges/2dada53525dd5a944089/maintainability)](https://codeclimate.com/github/Platoniq/decidim-module-decidim_awesome/maintainability)
6
- [![Test Coverage](https://codecov.io/gh/Platoniq/decidim-module-decidim_awesome/branch/master/graph/badge.svg?token=TFBMCLLZJG)](undefined)
5
+ [![Test Coverage](https://codecov.io/gh/Platoniq/decidim-module-decidim_awesome/branch/master/graph/badge.svg?token=TFBMCLLZJG)](https://codecov.io/gh/Platoniq/decidim-module-decidim_awesome)
7
6
 
8
7
  Usability and UX tweaks for Decidim.
9
8
 
@@ -78,44 +77,25 @@ It also provides a simple search by category, each category is assigned to a dif
78
77
 
79
78
  ![Awesome map](examples/awesome-map.png)
80
79
 
81
- #### 7. Allow Decidim to use custom CSS themes for every tenant
82
-
83
- When customizing CSS for a Decidim installation, each change affects all the organizations (tenant).
84
-
85
- This feature allows to customize each organization css without affecting the others in the same Decidim installation.
86
-
87
- ##### To create a theme
88
-
89
- 1. Get your hostname for the organization, theme search will be based on this (e.g: `myorganization.com`)
90
- 2. Create in you Decidim application this folder: `app/assets/themes/`
91
- 3. Create a file in that folder with the same name as the host and suffixed `.css` or `.scss` (e.g: `app/assets/themes/myorganization.com.scss`)
92
- 4. Modify that file as you like, you can use any SASS function available (such as `@import`)
93
- 5. Restart your server, enjoy!
94
-
95
- See an example here:
96
- https://github.com/Platoniq/decidim-demo/tree/master/app/assets/themes
97
-
98
- NOTE: Files presents in the `app/assets/themes` folder are added automatically into the precompile list of Rails by this plugin.
99
-
100
- #### 8. Fullscreen Iframe component
80
+ #### 7. Fullscreen Iframe component
101
81
 
102
82
  Another simple component that can be used to embed and Iframe with any external content in it that fills all the viewport.
103
83
 
104
84
  ![Fullscreen iframe](examples/fullscreen-iframe.png)
105
85
 
106
- #### 9. Live support chat
86
+ #### 8. Live support chat
107
87
 
108
88
  With this feature you can have a support chat in Decidim. It is linked to a [Telegram](https://telegram.org/) group or a single user chat using the [[IntergramBot](https://web.telegram.org/#/im?p=@IntergramBot). Just invite the bot to a group or chat with it directly, grab your ID, put it on the Awesome settings and have fun!. For more info or for hosting your own version of the bot check the [Intergram project](https://github.com/idoco/intergram).
109
89
 
110
90
  ![Intergram screenshot](examples/intergram.png)
111
91
 
112
- #### 10. Custom CSS applied only according scoped restrictions
92
+ #### 9. Custom CSS applied only according scoped restrictions
113
93
 
114
94
  With this feature you can create directly in the admin a CSS snipped that is only applied globally, in a particular assembly or even a single proposal!
115
95
 
116
96
  ![CSS screenshot](examples/custom_styles.png)
117
97
 
118
- #### 11. Change the main menu of Decidim entirely!
98
+ #### 10. Change the main menu of Decidim entirely!
119
99
 
120
100
  Feel free to hide, modify or add items in the Decidim's main menu. You can also change the order, establish some conditions (like showing only for logged users) or open in a new window.
121
101
 
@@ -124,7 +104,7 @@ Feel free to hide, modify or add items in the Decidim's main menu. You can also
124
104
  ![Menu hacks screenshot](examples/menu-3.png)
125
105
  ![Menu hacks screenshot](examples/menu-4.png)
126
106
 
127
- #### 12. Assign admins to specific scopes and prevent them modify anything else
107
+ #### 11. Assign admins to specific scopes and prevent them modify anything else
128
108
 
129
109
  Convert any user on the platform (that is not currently an admin) to a limited subset of participatory spaces or event compoponents. Just add users to a box and scope them to some constraints. These users will se the "Edit" button in everywhere they have permissions. Any access to unallowed zones will redirect the user to the admin index page.
130
110
 
@@ -132,7 +112,7 @@ Convert any user on the platform (that is not currently an admin) to a limited s
132
112
  ![Scoped admins unauthorized](examples/scoped_admins_unauthorized.png)
133
113
  ![Scoped admins configuration](examples/scoped_admins_config.png)
134
114
 
135
- #### 13. Custom fields for proposals
115
+ #### 12. Custom fields for proposals
136
116
 
137
117
  Now admins can substitute the body of a proposal with a set of form fields.
138
118
  Edition is make with a Drag & Drop interface in the admin and can (and should) be scoped to apply only to certain proposal components.
@@ -143,6 +123,26 @@ Technically, the content is stored in the database as an XML document compatible
143
123
  ![Custom fields screenshot](examples/custom-fields-2.png)
144
124
  ![Custom fields screenshot](examples/custom-fields-1.gif)
145
125
 
126
+ #### 13. Custom Redirections (or URL shortener feature)
127
+
128
+ Admins can create custom paths that redirect to other places. Destinations can be internal absolute paths or external sites.
129
+ There's also possible to choose to sanitize (ie: remove) any query string or to maintain it (so you can decide to use).
130
+
131
+ For instance you can create a redirection like
132
+
133
+ * `/take-me-somewhere` => `/processes/canary-islands`
134
+
135
+ Using a link with a query string (ie: `/take-me-somewhere?locale=es`) that will redirect the user to:
136
+
137
+ * `/processes/canary-islands` if query string is sanitized
138
+ * `/processes/canary-islands?locale=es` if query string is not sanitized
139
+
140
+ > Redirections work only after all other routes have been processed, you cannot override an existing route.
141
+ > The admin panel comes with a button to check if the redirection works (meaning that no other route is used by te application).
142
+ > Non-working routes will simply be ignored.
143
+
144
+ ![Custom redirections screenshot](examples/custom-redirections.png)
145
+
146
146
  #### To be continued...
147
147
 
148
148
  We're not done! Please check the [issues](/Platoniq/decidim-module-decidim_awesome/issues) (and participate) to see what's on our mind
@@ -154,7 +154,7 @@ Also feel free to propose something! or even better send a PR!
154
154
  Add this line to your application's Gemfile:
155
155
 
156
156
  ```ruby
157
- gem "decidim-decidim_awesome", "~> 0.7.2"
157
+ gem "decidim-decidim_awesome"
158
158
  ```
159
159
 
160
160
  And then execute:
@@ -162,18 +162,45 @@ And then execute:
162
162
  ```bash
163
163
  bundle
164
164
  bundle exec rails decidim_decidim_awesome:install:migrations
165
+ bundle exec rails decidim_decidim_awesome:webpacker:install
165
166
  bundle exec rails db:migrate
166
167
  ```
167
168
 
169
+ > NOTE: the `decidim_decidim_awesome:webpacker:install` is only necessary for Decidim versions starting at 0.25.
170
+
171
+ If you are upgrading from a version prior to 0.8, make sure to visit the URL `/admin/decidim_awesome/checks` and run image migrations for the old images:
172
+
173
+ ![Check image migrations](examples/check_image_migrations.png)
174
+
175
+ If you are a system admin, you can also perform this task by executing this rake task in the console:
176
+
177
+ ```
178
+ RAILS_ENV=production bin/rails decidim_awesome:active_storage_migrations:migrate_from_carrierwave
179
+ ```
180
+
181
+ Or check your migration status with:
182
+ ```
183
+ RAILS_ENV=production bin/rails decidim_awesome:active_storage_migrations:check_migration_from_carrierwave
184
+ ```
185
+
186
+
187
+ The correct version of Decidim Awesome should resolved automatically by the Bundler.
188
+ However you can force some specific version using `gem "decidim-decidim_awesome", "~> 0.8.0"` in the Gemfile.
189
+
168
190
  Depending on your Decidim version, choose the corresponding Awesome version to ensure compatibility:
169
191
 
170
192
  | Awesome version | Compatible Decidim versions |
171
193
  |---|---|
172
- | 0.5.x | 0.21.x, 0.22.x |
173
- | 0.6.x | 0.22.x, 0.23.x |
194
+ | 0.8.x | 0.25.x, 0.26.x |
174
195
  | 0.7.x | 0.23.x, 0.24.x |
196
+ | 0.6.x | 0.22.x, 0.23.x |
197
+ | 0.5.x | 0.21.x, 0.22.x |
175
198
 
176
- > *Heads up!* version 0.7.1 requires database migrations! Don't forget the migrations step when updating.
199
+ > *Heads up!*
200
+ > * version 0.8.0 removes CSS Themes for tenants. If you have been using them you will have to manually migrate them to custom styles.
201
+ > * version 0.8.0 uses ActiveStorage, same as Decidim 0.25. 2 new rake task have been introduced to facilitate the migration: `bin/rails decidim_awesome:active_storage_migrations:check_migration_from_carrierwave` and
202
+ `bin/rails decidim_awesome:active_storage_migrations:migrate_from_carrierwave`
203
+ > * version 0.7.1 requires database migrations! Don't forget the migrations step when updating.
177
204
 
178
205
  ## Configuration
179
206
 
@@ -301,8 +328,8 @@ DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec appraisal
301
328
  To test a specific apprasail configured version do the following:
302
329
 
303
330
  ```
304
- DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec appraisal decidim-0.23 rake test_app
305
- DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec appraisal decidim-0.23 rspec
331
+ DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec appraisal decidim-0.25 rake test_app
332
+ DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec appraisal decidim-0.25 rspec
306
333
  ```
307
334
 
308
335
  Note that the database user has to have rights to create and drop a database in
@@ -358,4 +385,4 @@ This engine is distributed under the GNU AFFERO GENERAL PUBLIC LICENSE.
358
385
 
359
386
  ## Credits
360
387
 
361
- This plugin has been developed by ![Platoniq](app/assets/images/decidim/decidim_awesome/platoniq-logo.png)
388
+ This plugin has been developed by ![Platoniq](app/packs/images/decidim/decidim_awesome/platoniq-logo.png)
data/Rakefile CHANGED
@@ -10,32 +10,30 @@ def install_module(path)
10
10
  end
11
11
  end
12
12
 
13
- def seed_db(path)
13
+ def override_webpacker_config_files(path)
14
14
  Dir.chdir(path) do
15
- system("bundle exec rake db:seed")
15
+ system("bundle exec rake decidim_decidim_awesome:webpacker:install")
16
16
  end
17
17
  end
18
18
 
19
- def copy_themes
20
- FileUtils.cp_r "lib/decidim/decidim_awesome/test/themes", "spec/decidim_dummy_app/app/assets/themes", verbose: true
19
+ def seed_db(path)
20
+ Dir.chdir(path) do
21
+ system("bundle exec rake db:seed")
22
+ end
21
23
  end
22
24
 
23
- def copy_headers
25
+ def copy_helpers
24
26
  FileUtils.mkdir_p "spec/decidim_dummy_app/app/views/v0.11", verbose: true
25
27
  FileUtils.cp_r "lib/decidim/decidim_awesome/test/layouts", "spec/decidim_dummy_app/app/views/v0.11/layouts", verbose: true
26
- end
27
-
28
- desc "copy test theme files"
29
- task :copy_themes do
30
- copy_themes
28
+ FileUtils.cp "lib/decidim/decidim_awesome/test/initializer.rb", "spec/decidim_dummy_app/config/initializers/decidim_awesome.rb", verbose: true
31
29
  end
32
30
 
33
31
  desc "Generates a dummy app for testing"
34
32
  task test_app: "decidim:generate_external_test_app" do
35
33
  ENV["RAILS_ENV"] = "test"
36
34
  install_module("spec/decidim_dummy_app")
37
- copy_themes
38
- copy_headers
35
+ override_webpacker_config_files("spec/decidim_dummy_app")
36
+ copy_helpers
39
37
  end
40
38
 
41
39
  desc "Generates a development app."
@@ -54,4 +52,5 @@ task :development_app do
54
52
 
55
53
  install_module("development_app")
56
54
  seed_db("development_app")
55
+ override_webpacker_config_files("development_app")
57
56
  end
@@ -0,0 +1,11 @@
1
+ <section class="wrapper-home map-block home-section">
2
+ <div class="row">
3
+ <div class="columns">
4
+ <div class="callout alert">
5
+ <p><%= t("unavailable", scope: "decidim.decidim_awesome.map_component.map.error") %></p>
6
+ </div>
7
+
8
+ <%= render partial: "decidim/decidim_awesome/map_component/map/api_ready.html" %>
9
+ </div>
10
+ </div>
11
+ </div>
@@ -6,67 +6,7 @@
6
6
  <div class="row">
7
7
  <div class="columns medium-12">
8
8
  <%= awesome_map_for global_map_components do %>
9
- <script id="marker-proposal-popup" type="text/x-jsrender">
10
- <div class="map-info__content">
11
- <h3>{{>title.translation}}</h3>
12
- <div id="bodyContent">
13
- <div class="description">{{:body.translation}}</div>
14
- <div class="map__date-adress">
15
- <div class="address card__extra">
16
- <div class="address__icon">{{:icon}}</div>
17
- <div class="address__details">
18
- <span>{{>address}}</span><br>
19
- </div>
20
- </div>
21
- </div>
22
- <div class="map-info__button">
23
- <a href="{{>link}}" class="button button--sc">
24
- <%= t("view_proposal", scope: "decidim.decidim_awesome.map_component.map.show") %>
25
- </a>
26
- </div>
27
- </div>
28
- </div>
29
- </script>
30
-
31
- <script id="marker-meeting-popup" type="text/x-jsrender">
32
- <div class="map-info__content">
33
- <h3>{{>title.translation}}</h3>
34
- <div id="bodyContent">
35
- <div class="description">{{:description.translation}}</div>
36
- <div class="map__date-adress">
37
- <div class="card__datetime">
38
- <div class="card__datetime__date">
39
- {{>startTimeDay}} <span class="card__datetime__month">{{>startTimeMonth}} {{>startTimeYear}}</span>
40
- </div>
41
- <div class="card__datetime__time">{{>starTime}}</div>
42
- </div>
43
- <div class="address card__extra">
44
- <div class="address__icon">{{:icon}}</div>
45
- <div class="address__details">
46
- <strong>{{:location.translation}}</strong><br>
47
- <span>{{>address}}</span><br>
48
- <span>{{:locationHints.translation}}</span>
49
- </div>
50
- </div>
51
- </div>
52
- <div class="map-info__button">
53
- <a href="{{>link}}" class="button button--sc">
54
- <%= t("decidim.meetings.meetings_map.view_meeting") %>
55
- </a>
56
- </div>
57
- </div>
58
- </div>
59
- </script>
60
-
61
- <style type="text/css">
62
- #awesome-map .leaflet-container {
63
- height: <%= model.settings.map_height %>px;
64
- }
65
- </style>
66
- <script>
67
- window.AwesomeMap = window.AwesomeMap || {};
68
- window.AwesomeMap.categories = <%= all_categories.to_json.html_safe %>;
69
- </script>
9
+ <%= render partial: "decidim/decidim_awesome/map_component/map/map_template.html", locals: { categories: all_categories, map_height: model.settings.map_height } %>
70
10
  <% end %>
71
11
  </div>
72
12
  </div>
@@ -4,6 +4,7 @@ module Decidim
4
4
  module DecidimAwesome
5
5
  module ContentBlocks
6
6
  class MapCell < Decidim::ViewModel
7
+ include Cell::ViewModel::Partial
7
8
  include Decidim::DecidimAwesome::MapHelper
8
9
  include Decidim::CardHelper
9
10
 
@@ -11,6 +12,16 @@ module Decidim
11
12
  delegate :settings, to: :model
12
13
  alias current_settings settings
13
14
 
15
+ def show
16
+ return error unless Decidim::Map.configured?
17
+
18
+ render
19
+ end
20
+
21
+ def error
22
+ render
23
+ end
24
+
14
25
  def hide_controls
15
26
  true
16
27
  end
@@ -19,10 +19,10 @@
19
19
  <div class="row two-buttons">
20
20
  <div>
21
21
  <%= settings_fields.text_field :map_center, label: t("map_center", scope: i18n_scope) %>
22
- <%= t("map_center_help", scope: i18n_scope) %>
22
+ <p class="help-text"><%= t("map_center_help", scope: i18n_scope) %></p>
23
23
  </div>
24
24
  <div><%= settings_fields.number_field :map_zoom, label: t("map_zoom", scope: i18n_scope) %>
25
- <%= t("map_zoom_help", scope: i18n_scope) %>
25
+ <p class="help-text"><%= t("map_zoom_help", scope: i18n_scope) %></p>
26
26
  </div>
27
27
  </div>
28
28
  <div class="row two-buttons">
@@ -42,8 +42,9 @@
42
42
  <div><%= settings_fields.check_box :show_evaluating, label: t("show_evaluating", scope: i18n_scope) %>
43
43
  </div>
44
44
  </div>
45
- <div class="row">
46
- <%= settings_fields.check_box :show_rejected, label: t("show_rejected", scope: i18n_scope) %>
45
+ <div class="row two-buttons">
46
+ <div><%= settings_fields.check_box :show_rejected, label: t("show_rejected", scope: i18n_scope) %></div>
47
+ <div><%= settings_fields.check_box :menu_merge_components, label: t("menu_merge_components", scope: i18n_scope) %></div>
47
48
  </div>
48
49
  <% end %>
49
50
 
@@ -58,4 +59,7 @@
58
59
  .two-buttons > div {
59
60
  width: 50%;
60
61
  }
62
+ .help-text {
63
+ margin-top: -1.5em;
64
+ }
61
65
  </style>
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module DecidimAwesome
5
+ module Admin
6
+ class CreateCustomRedirect < Rectify::Command
7
+ # Public: Initializes the command.
8
+ #
9
+ def initialize(form)
10
+ @form = form
11
+ @redirections = AwesomeConfig.find_or_initialize_by(var: :custom_redirects, organization: form.current_organization)
12
+ end
13
+
14
+ # Executes the command. Broadcasts these events:
15
+ #
16
+ # - :ok when everything is valid.
17
+ # - :invalid if we couldn't proceed.
18
+ #
19
+ # Returns nothing.
20
+ def call
21
+ return broadcast(:invalid) if form.invalid?
22
+ return broadcast(:invalid, I18n.t("custom_redirects.origin_exists", scope: "decidim.decidim_awesome.admin")) if url_exists?
23
+
24
+ create_redirection!
25
+ broadcast(:ok)
26
+ rescue StandardError => e
27
+ broadcast(:invalid, e.message)
28
+ end
29
+
30
+ private
31
+
32
+ attr_reader :form, :redirections
33
+
34
+ delegate :to_params, to: :form
35
+
36
+ def create_redirection!
37
+ redirections.value = {} unless redirections.value.is_a? Hash
38
+ redirections.value[to_params[0]] = to_params[1]
39
+ redirections.save!
40
+ end
41
+
42
+ def url_exists?
43
+ return false unless redirections
44
+ return false unless redirections.value.is_a? Hash
45
+
46
+ redirections.value[form.origin].present?
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module DecidimAwesome
5
+ module Admin
6
+ class DestroyCustomRedirect < Rectify::Command
7
+ # Public: Initializes the command.
8
+ #
9
+ # item - the redirections item to destroy
10
+ # organization
11
+ def initialize(item, organization)
12
+ @item = item
13
+ @organization = organization
14
+ @redirections = AwesomeConfig.find_by(var: :custom_redirects, organization: organization)
15
+ end
16
+
17
+ # Executes the command. Broadcasts these events:
18
+ #
19
+ # - :ok when everything is valid.
20
+ # - :invalid if we couldn't proceed.
21
+ #
22
+ # Returns nothing.
23
+ def call
24
+ return broadcast(:invalid) unless url_exists?
25
+
26
+ redirections.value&.except!(item.origin)
27
+ redirections.save!
28
+
29
+ broadcast(:ok, @item)
30
+ rescue StandardError => e
31
+ broadcast(:invalid, e.message)
32
+ end
33
+
34
+ private
35
+
36
+ attr_reader :organization, :item, :redirections
37
+
38
+ def url_exists?
39
+ return false unless redirections
40
+ return false unless redirections.value.is_a? Hash
41
+
42
+ redirections.value[item.origin].present?
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module DecidimAwesome
5
+ module Admin
6
+ class UpdateCustomRedirect < Rectify::Command
7
+ # Public: Initializes the command.
8
+ #
9
+ def initialize(form, item)
10
+ @form = form
11
+ @item = item
12
+ @redirects = AwesomeConfig.find_by(var: :custom_redirects, organization: form.current_organization)
13
+ end
14
+
15
+ # Executes the command. Broadcasts these events:
16
+ #
17
+ # - :ok when everything is valid.
18
+ # - :invalid if we couldn't proceed.
19
+ #
20
+ # Returns nothing.
21
+ def call
22
+ return broadcast(:invalid) if form.invalid?
23
+ return broadcast(:invalid, I18n.t("custom_redirects.origin_missing", scope: "decidim.decidim_awesome.admin")) unless url_exists?
24
+
25
+ redirects.value&.except!(item.origin)
26
+ redirects.value[to_params[0]] = to_params[1]
27
+ redirects.save!
28
+
29
+ broadcast(:ok, redirects)
30
+ rescue StandardError => e
31
+ broadcast(:invalid, e.message)
32
+ end
33
+
34
+ private
35
+
36
+ attr_reader :form, :redirects, :item
37
+
38
+ delegate :to_params, to: :form
39
+
40
+ def url_exists?
41
+ return unless redirects
42
+ return unless redirects.value.is_a? Hash
43
+
44
+ redirects.value[item.origin].present?
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -19,15 +19,22 @@ module Decidim
19
19
  def call
20
20
  return broadcast(:invalid) if form.invalid?
21
21
 
22
- image = EditorImage.new(
22
+ transaction do
23
+ create_editor_image!
24
+ end
25
+
26
+ broadcast(:ok, @editor_image)
27
+ end
28
+
29
+ private
30
+
31
+ def create_editor_image!
32
+ @editor_image = EditorImage.create!(
23
33
  path: form.path,
24
34
  decidim_author_id: form.current_user.id,
25
35
  organization: form.organization,
26
- image: form.image
36
+ file: form.file
27
37
  )
28
-
29
- image.save!
30
- broadcast(:ok, image)
31
38
  end
32
39
 
33
40
  attr_reader :form
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module DecidimAwesome
5
+ module NotFoundRedirect
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+ before_action :redirect_unallowed_scoped_admins, only: :not_found, if: -> { request.original_fullpath =~ %r{^(/+)admin} }
10
+ before_action :redirect_to_custom_paths, only: :not_found, if: -> { DecidimAwesome.enabled? :custom_redirects }
11
+ private
12
+
13
+ def redirect_unallowed_scoped_admins
14
+ return unless Decidim::User.respond_to? :awesome_admins_for_current_scope
15
+ return unless Decidim::User.respond_to? :awesome_potential_admins
16
+ return unless defined? current_user
17
+ return unless Decidim::User.awesome_potential_admins.include? current_user.id
18
+
19
+ # assiging a flash message here does not work after redirection due the order of middleware in Rails
20
+ # as a workaround, send a message through a get parameter
21
+ path = "/admin/?unauthorized"
22
+ referer = request.headers["Referer"]
23
+ if referer
24
+ uri = URI(referer)
25
+ params = Rack::Utils.parse_query uri.query
26
+ unless request.params.has_key? "unauthorized"
27
+ params["unauthorized"] = nil
28
+ path = "#{uri.path}?#{Rack::Utils.build_query(params)}"
29
+ end
30
+ end
31
+
32
+ redirect_to path
33
+ end
34
+
35
+ def redirect_to_custom_paths
36
+ destination = custom_redirects_destination(request.original_fullpath)
37
+ redirect_to destination if destination.present?
38
+ end
39
+
40
+ def custom_redirects_destination(fullpath)
41
+ redirects = (AwesomeConfig.find_by(var: :custom_redirects, organization: current_organization)&.value || {}).filter { |_, v| v["active"] }
42
+ return if redirects.blank?
43
+ return unless redirects.is_a? Hash
44
+
45
+ path, query = fullpath.split("?")
46
+ destination = redirects.dig(path.downcase, "destination")
47
+ pass_query = redirects.dig(path.downcase, "pass_query")
48
+ if pass_query.present?
49
+ union = destination.include?("?") ? "&" : "?"
50
+ destination = "#{destination}#{union}#{query}"
51
+ end
52
+
53
+ return destination.strip if destination.present?
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end