decidim-gallery 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE-AGPLv3.txt +661 -0
  3. data/README.md +30 -0
  4. data/Rakefile +9 -0
  5. data/app/cells/decidim/gallery/main/image.erb +51 -0
  6. data/app/cells/decidim/gallery/main/image_collection.erb +13 -0
  7. data/app/cells/decidim/gallery/main/image_list.erb +9 -0
  8. data/app/cells/decidim/gallery/main/video.erb +20 -0
  9. data/app/cells/decidim/gallery/main/video_collection.erb +3 -0
  10. data/app/cells/decidim/gallery/main_cell.rb +88 -0
  11. data/app/cells/decidim/gallery/video/show.erb +6 -0
  12. data/app/cells/decidim/gallery/video_cell.rb +96 -0
  13. data/app/commands/decidim/gallery/admin/create_gallery_item.rb +50 -0
  14. data/app/commands/decidim/gallery/admin/publish_gallery_item.rb +38 -0
  15. data/app/commands/decidim/gallery/admin/unpublish_gallery_item.rb +38 -0
  16. data/app/commands/decidim/gallery/admin/update_gallery_item.rb +44 -0
  17. data/app/controllers/decidim/gallery/admin/application_controller.rb +24 -0
  18. data/app/controllers/decidim/gallery/admin/gallery_item_controller.rb +104 -0
  19. data/app/controllers/decidim/gallery/application_controller.rb +8 -0
  20. data/app/controllers/decidim/gallery/gallery_controller.rb +9 -0
  21. data/app/forms/decidim/gallery/admin/gallery_item_form.rb +17 -0
  22. data/app/forms/decidim/gallery/admin/gallery_item_image_form.rb +14 -0
  23. data/app/forms/decidim/gallery/admin/gallery_item_video_form.rb +12 -0
  24. data/app/helpers/decidim/gallery/admin/application_helper.rb +18 -0
  25. data/app/model/decidim/gallery/application_record.rb +10 -0
  26. data/app/model/decidim/gallery/gallery_item.rb +38 -0
  27. data/app/overrides/decidim/admin/static_pages/edit/add_gallery.html.erb.deface +11 -0
  28. data/app/overrides/decidim/pages/_standalone/add_content_blocks.html.erb.deface +7 -0
  29. data/app/overrides/decidim/pages/_tabbed/add_content_blocks.html.erb.deface +5 -0
  30. data/app/packs/entrypoints/decidim_gallery.js +3 -0
  31. data/app/packs/images/decidim/gallery/icon.svg +1 -0
  32. data/app/packs/src/decidim/gallery/gallery.js +42 -0
  33. data/app/packs/src/decidim/gallery/masonry/EvEmitter.js +85 -0
  34. data/app/packs/src/decidim/gallery/masonry/getSize.js +181 -0
  35. data/app/packs/src/decidim/gallery/masonry/jQueryBridget.js +109 -0
  36. data/app/packs/src/decidim/gallery/masonry/masonry.js +202 -0
  37. data/app/packs/src/decidim/gallery/masonry/matchesSelector.js +25 -0
  38. data/app/packs/src/decidim/gallery/masonry/outlayer.js +885 -0
  39. data/app/packs/src/decidim/gallery/masonry/outlayerItem.js +522 -0
  40. data/app/packs/src/decidim/gallery/masonry/utils.js +203 -0
  41. data/app/packs/stylesheets/decidim/gallery/_gallery.scss +3 -0
  42. data/app/permissions/decidim/gallery/admin/permissions.rb +18 -0
  43. data/app/permissions/decidim/gallery/permissions.rb +17 -0
  44. data/app/views/decidim/gallery/admin/gallery_item/_form_image.html.erb +16 -0
  45. data/app/views/decidim/gallery/admin/gallery_item/_form_video.html.erb +16 -0
  46. data/app/views/decidim/gallery/admin/gallery_item/edit.html.erb +9 -0
  47. data/app/views/decidim/gallery/admin/gallery_item/index.html.erb +52 -0
  48. data/app/views/decidim/gallery/admin/gallery_item/new.html.erb +9 -0
  49. data/app/views/decidim/gallery/gallery/index.html.erb +11 -0
  50. data/config/assets.rb +9 -0
  51. data/config/i18n-tasks.yml +22 -0
  52. data/config/locales/en.yml +79 -0
  53. data/config/locales/fr.yml +79 -0
  54. data/config/locales/ro.yml +79 -0
  55. data/lib/decidim/gallery/admin/static_pages/command.rb +15 -0
  56. data/lib/decidim/gallery/admin/static_pages/form.rb +21 -0
  57. data/lib/decidim/gallery/admin.rb +14 -0
  58. data/lib/decidim/gallery/admin_engine.rb +27 -0
  59. data/lib/decidim/gallery/component.rb +47 -0
  60. data/lib/decidim/gallery/engine.rb +60 -0
  61. data/lib/decidim/gallery/test/factories.rb +58 -0
  62. data/lib/decidim/gallery/version.rb +14 -0
  63. data/lib/decidim/gallery.rb +14 -0
  64. data/lib/tasks/decidim_gallery.rake +16 -0
  65. metadata +163 -0
@@ -0,0 +1,3 @@
1
+ .gallery-item {
2
+ margin-bottom: 10px;
3
+ }
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Gallery
5
+ module Admin
6
+ class Permissions < Decidim::DefaultPermissions
7
+ def permissions
8
+ return permission_action if permission_action.scope != :admin
9
+
10
+ allow! if permission_action.subject == :gallery
11
+ allow! if permission_action.subject == :gallery_item
12
+
13
+ permission_action
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Gallery
5
+ class Permissions < Decidim::DefaultPermissions
6
+ def permissions
7
+ return permission_action unless user
8
+
9
+ # Delegate the admin permission checks to the admin permissions class
10
+ return Decidim::Gallery::Admin::Permissions.new(user, permission_action, context).permissions if permission_action.scope == :admin
11
+
12
+ allow!
13
+ permission_action
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,16 @@
1
+ <div class="card">
2
+ <div class="card-divider">
3
+ <h2 class="card-title"><%= title %></h2>
4
+ </div>
5
+ <div class="card-section">
6
+ <div class="row column">
7
+ <%= form.translated :text_field, :title, autofocus: true %>
8
+ </div>
9
+ <div class="row column">
10
+ <%= form.number_field :weight %>
11
+ </div>
12
+ <div class="row column">
13
+ <%= form.upload :photo %>
14
+ </div>
15
+ </div>
16
+ </div>
@@ -0,0 +1,16 @@
1
+ <div class="card">
2
+ <div class="card-divider">
3
+ <h2 class="card-title"><%= title %></h2>
4
+ </div>
5
+ <div class="card-section">
6
+ <div class="row column">
7
+ <%= form.translated :text_field, :title, autofocus: true %>
8
+ </div>
9
+ <div class="row column">
10
+ <%= form.number_field :weight %>
11
+ </div>
12
+ <div class="row column">
13
+ <%= form.translated :text_field, :video_url %>
14
+ </div>
15
+ </div>
16
+ </div>
@@ -0,0 +1,9 @@
1
+ <%= decidim_form_for(@form, url: { action: "update" }, html: { class: "form edit_post" }) do |f| %>
2
+ <%= render partial: "form_#{current_component.settings["gallery_type"]}", object: f, locals: {
3
+ form: f,
4
+ title: t("title", scope: "decidim.gallery.admin.gallery_item.new.#{current_component.settings["gallery_type"]}")
5
+ } %>
6
+ <div class="button--double form-general-submit">
7
+ <%= f.submit t(".save") %>
8
+ </div>
9
+ <% end %>
@@ -0,0 +1,52 @@
1
+ <div class="card">
2
+ <div class="card-divider">
3
+ <h2 class="card-title">
4
+ <%= t(".title") %>
5
+ <%= link_to t("actions.new", scope: "decidim.gallery", name: t("gallery_item.index.title", scope: "decidim.gallery.admin")), new_gallery_item_path, class: "button tiny button--title" if allowed_to? :create, :gallery %>
6
+ </h2>
7
+ </div>
8
+
9
+ <div class="card-section">
10
+ <div class="table-scroll">
11
+ <table class="table-list">
12
+ <thead>
13
+ <tr>
14
+ <th><%= t("models.gallery_item.fields.title", scope: "decidim.gallery") %></th>
15
+ <th><%= t("models.gallery_item.fields.weight", scope: "decidim.gallery") %></th>
16
+ <th><%= t("models.gallery_item.fields.created_at", scope: "decidim.gallery") %></th>
17
+ <th class="actions"><%= t("actions.title", scope: "decidim.gallery") %></th>
18
+ </tr>
19
+ </thead>
20
+ <tbody>
21
+ <% gallery_items.created_at_desc.each do |post| %>
22
+ <tr data-id="<%= post.id %>">
23
+ <td><%= translated_attribute(post.title) %><br></td>
24
+ <td><%= post.weight %><br></td>
25
+ <td><%= l post.created_at, format: "%d/%m/%Y - %H:%M" %></td>
26
+ <td class="table-list__actions">
27
+ <% if allowed_to? :update, :gallery, gallery_item: post %>
28
+ <% if post.published? %>
29
+ <%= icon_link_to "x", unpublish_gallery_item_path(post), t("actions.unpublish", scope: "decidim.gallery"), method: :put, class: "action-icon--unpublish", data: { confirm: t("actions.confirm_unpublish", scope: "decidim.gallery") } %>
30
+ <% else %>
31
+ <%= icon_link_to "check", publish_gallery_item_path(post), t("actions.publish", scope: "decidim.gallery"), method: :put, class: "action-icon--publish" %>
32
+ <% end %>
33
+ <% else %>
34
+ <span class="action-space icon"></span>
35
+ <% end %>
36
+
37
+ <% if allowed_to? :update, :gallery, gallery_item: post %>
38
+ <%= icon_link_to "pencil", edit_gallery_item_path(post), t("actions.edit", scope: "decidim.gallery"), class: "action-icon--edit" %>
39
+ <% end %>
40
+
41
+ <% if allowed_to? :destroy, :gallery, gallery_item: post %>
42
+ <%= icon_link_to "circle-x", gallery_item_path(post), t("actions.destroy", scope: "decidim.gallery"), method: :delete, class: "action-icon--remove", data: { confirm: t("actions.confirm_destroy", scope: "decidim.gallery") } %>
43
+ <% end %>
44
+ </td>
45
+ </tr>
46
+ <% end %>
47
+ </tbody>
48
+ </table>
49
+ <%= paginate gallery_items, theme: "decidim" %>
50
+ </div>
51
+ </div>
52
+ </div>
@@ -0,0 +1,9 @@
1
+ <%= decidim_form_for(@form, url: { action: "create" }, html: { class: "form new_post" }) do |f| %>
2
+ <%= render partial: "form_#{current_component.settings["gallery_type"]}", object: f, locals: {
3
+ form: f,
4
+ title: t("title", scope: "decidim.gallery.admin.gallery_item.new.#{current_component.settings["gallery_type"]}")
5
+ } %>
6
+ <div class="button--double form-general-submit">
7
+ <%= f.submit t(".create") %>
8
+ </div>
9
+ <% end %>
@@ -0,0 +1,11 @@
1
+ <div class="row columns">
2
+ <div class="title-action">
3
+ <h2 class="title-action__title section-heading"><%= translated_attribute(current_component.name) %></h2>
4
+ </div>
5
+ </div>
6
+
7
+ <div class="row">
8
+ <div class="columns">
9
+ <%= cell("decidim/gallery/main", OpenStruct.new(gallery_id: current_component.id), context: { view_context: self }) %>
10
+ </div>
11
+ </div>
data/config/assets.rb ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ base_path = File.expand_path("..", __dir__)
4
+
5
+ Decidim::Webpacker.register_path("#{base_path}/app/packs")
6
+ Decidim::Webpacker.register_entrypoints(
7
+ decidim_gallery: "#{base_path}/app/packs/entrypoints/decidim_gallery.js"
8
+ )
9
+ Decidim::Webpacker.register_stylesheet_import("stylesheets/decidim/gallery/gallery")
@@ -0,0 +1,22 @@
1
+ ---
2
+
3
+ base_locale: en
4
+ locales: [en, fr]
5
+
6
+ search:
7
+ strict: false
8
+ relative_roots:
9
+ - app/controllers
10
+ - app/helpers
11
+ - app/views
12
+ - app/cells
13
+ - lib/decidim/gallery
14
+
15
+ ignore_unused:
16
+ - "decidim.components.gallery.name"
17
+ - "decidim.gallery.admin.gallery_item.new.image.title"
18
+ - "decidim.gallery.admin.gallery_item.new.video.title"
19
+ - "decidim.components.gallery.settings.global.*"
20
+
21
+ ignore_missing:
22
+ - locale.name
@@ -0,0 +1,79 @@
1
+ ---
2
+ en:
3
+ decidim:
4
+ components:
5
+ gallery:
6
+ name: Gallery
7
+ settings:
8
+ global:
9
+ additional_css: Additional CSS
10
+ announcement: Announcement
11
+ gallery_type: Type of Gallery
12
+ gallery_type_choices:
13
+ image: Image
14
+ video: Video
15
+ items_per_page: Items per page
16
+ items_per_page_choices:
17
+ '12': '12'
18
+ '15': '15'
19
+ '18': '18'
20
+ show_announcement: Display announcement
21
+ show_title: Show title
22
+ gallery:
23
+ actions:
24
+ confirm_destroy: Are you sure you want to delete?
25
+ confirm_unpublish: Are you sure you want to unpublish?
26
+ destroy: Delete
27
+ edit: Edit
28
+ new: New Gallery Item
29
+ publish: Publish
30
+ title: Actions
31
+ unpublish: Unpublish
32
+ admin:
33
+ formatted_text: Gallery %{component_name} in %{space_name}
34
+ gallery_item:
35
+ create:
36
+ invalid: Invalid
37
+ success: Valid
38
+ destroy:
39
+ success: Successfully deleted
40
+ edit:
41
+ save: Save
42
+ index:
43
+ title: Gallery
44
+ new:
45
+ create: Create
46
+ image:
47
+ title: New Gallery Image Item
48
+ video:
49
+ title: New Gallery Video Item
50
+ publish:
51
+ invalid: There was an error publishing resource
52
+ success: Successfully published
53
+ unpublish:
54
+ invalid: There was an error unpublishing resource
55
+ success: Successfully unpublished
56
+ update:
57
+ invalid: There was an error updating the resource
58
+ success: Successfully updated
59
+ main:
60
+ close_modal: Close
61
+ image:
62
+ few: "%{count} Photos"
63
+ one: 1 Photo
64
+ other: "%{count} Photos"
65
+ load_more: View more
66
+ next_slide: Next
67
+ previous_slide: Previous
68
+ video:
69
+ few: "%{count} Videos"
70
+ one: 1 Video
71
+ other: "%{count} Videos"
72
+ models:
73
+ gallery_item:
74
+ fields:
75
+ created_at: Creation date
76
+ title: Title
77
+ weight: Weight
78
+ none: None
79
+ settings: Gallery Settings
@@ -0,0 +1,79 @@
1
+ ---
2
+ fr:
3
+ decidim:
4
+ components:
5
+ gallery:
6
+ name: Galerie
7
+ settings:
8
+ global:
9
+ additional_css: CSS additionnel
10
+ announcement: Annonce
11
+ gallery_type: Type de Galerie
12
+ gallery_type_choices:
13
+ image: Image
14
+ video: Vidéo
15
+ items_per_page: Éléments par page
16
+ items_per_page_choices:
17
+ '12': '12'
18
+ '15': '15'
19
+ '18': '18'
20
+ show_announcement: Montrer l'annonce
21
+ show_title: Afficher le titre
22
+ gallery:
23
+ actions:
24
+ confirm_destroy: Etes-vous sûr de vouloir supprimer ?
25
+ confirm_unpublish: Êtes-vous sûr de vouloir dépublier ?
26
+ destroy: Supprimer
27
+ edit: Modifier
28
+ new: Nouvel élément de la galerie
29
+ publish: Publier
30
+ title: Actions
31
+ unpublish: Dé-publier
32
+ admin:
33
+ formatted_text: Galerie %{component_name} dans %{space_name}
34
+ gallery_item:
35
+ create:
36
+ invalid: Non valide
37
+ success: Valide
38
+ destroy:
39
+ success: Suppression effectuée avec succès
40
+ edit:
41
+ save: Sauvegarder
42
+ index:
43
+ title: Galerie
44
+ new:
45
+ create: Créer
46
+ image:
47
+ title: Nouvelle image de galerie
48
+ video:
49
+ title: Nouvel vidéo de la galerie
50
+ publish:
51
+ invalid: Une erreur s'est produite lors de la publication de votre fichier
52
+ success: Publié avec succès
53
+ unpublish:
54
+ invalid: Une erreur s'est produite lors de la dé-publication de votre fichier
55
+ success: Dé-publié avec succès
56
+ update:
57
+ invalid: Une erreur est survenue lors de la mise à jour du fichier
58
+ success: Mis à jour avec succès
59
+ main:
60
+ close_modal: Fermer
61
+ image:
62
+ few: "%{count} photos"
63
+ one: 1 Photo
64
+ other: "%{count} photos"
65
+ load_more: Afficher plus
66
+ next_slide: Suivant
67
+ previous_slide: Précédent
68
+ video:
69
+ few: "%{count} vidéos"
70
+ one: 1 vidéo
71
+ other: "%{count} vidéos"
72
+ models:
73
+ gallery_item:
74
+ fields:
75
+ created_at: Date de création
76
+ title: Titre
77
+ weight: Poids
78
+ none: Aucun
79
+ settings: Configuration de la galerie
@@ -0,0 +1,79 @@
1
+ ---
2
+ ro:
3
+ decidim:
4
+ components:
5
+ gallery:
6
+ name: Galerie
7
+ settings:
8
+ global:
9
+ additional_css: CSS suplimentar
10
+ announcement: Announcement
11
+ gallery_type: Tipul galeriei
12
+ gallery_type_choices:
13
+ image: Imagine
14
+ video: Video
15
+ items_per_page: Articole pe pagină
16
+ items_per_page_choices:
17
+ '12': '12'
18
+ '15': '15'
19
+ '18': '18'
20
+ show_announcement: Display announcement
21
+ show_title: Arată titlul
22
+ gallery:
23
+ actions:
24
+ confirm_destroy: Eşti sigur că dorești să ștergi?
25
+ confirm_unpublish: Sigur doriți să anulați publicarea?
26
+ destroy: Şterge
27
+ edit: Editare
28
+ new: Element nou de galerie
29
+ publish: Publicare
30
+ title: Acțiuni
31
+ unpublish: Anulează publicarea
32
+ admin:
33
+ formatted_text: Galerie %{component_name} în %{space_name}
34
+ gallery_item:
35
+ create:
36
+ invalid: Invalid
37
+ success: Valid
38
+ destroy:
39
+ success: Șters cu succes
40
+ edit:
41
+ save: Salvează
42
+ index:
43
+ title: Galerie
44
+ new:
45
+ create: Creează
46
+ image:
47
+ title: Element nou de galerie
48
+ video:
49
+ title: Element video nou
50
+ publish:
51
+ invalid: A apărut o eroare la publicarea resursei
52
+ success: Publicare reușită
53
+ unpublish:
54
+ invalid: A apărut o eroare la actualizarea resursei
55
+ success: Actualizare reușită
56
+ update:
57
+ invalid: A apărut o eroare la actualizarea resursei
58
+ success: Actualizare reușită
59
+ main:
60
+ close_modal: Închide
61
+ image:
62
+ few: "%{count} Imagini"
63
+ one: 1 imagine
64
+ other: "%{count} Imagini"
65
+ load_more: Vezi mai multe
66
+ next_slide: Următorul
67
+ previous_slide: Anteriorul
68
+ video:
69
+ few: "%{count} videoclipuri"
70
+ one: 1 videoclip
71
+ other: "%{count} videoclipuri"
72
+ models:
73
+ gallery_item:
74
+ fields:
75
+ created_at: Data creării
76
+ title: Titlu
77
+ weight: Greutate
78
+ none: Niciuna
79
+ settings: Setări galerie
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Gallery
5
+ module Admin
6
+ module StaticPages
7
+ module Command
8
+ def attributes
9
+ super.merge(gallery_id: form.gallery_id)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Gallery
5
+ module Admin
6
+ module StaticPages
7
+ module Form
8
+ def self.prepended(base)
9
+ base.class_eval do
10
+ attribute :gallery_id, Integer
11
+ end
12
+ end
13
+
14
+ def galleries
15
+ @galleries ||= Decidim::Component.where(participatory_space: current_organization.public_participatory_spaces, manifest_name: "gallery")
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Gallery
5
+ # This module contains all the domain logic associated to Decidim's Gallery
6
+ # component admin panel.
7
+ module Admin
8
+ module StaticPages
9
+ autoload :Command, "decidim/gallery/admin/static_pages/command"
10
+ autoload :Form, "decidim/gallery/admin/static_pages/form"
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Gallery
5
+ # This is the engine that runs on the public interface of `Gallery`.
6
+ class AdminEngine < ::Rails::Engine
7
+ isolate_namespace Decidim::Gallery::Admin
8
+
9
+ paths["db/migrate"] = nil
10
+ paths["lib/tasks"] = nil
11
+
12
+ routes do
13
+ resources :gallery_item do
14
+ member do
15
+ put :publish
16
+ put :unpublish
17
+ end
18
+ end
19
+ root to: "gallery_item#index"
20
+ end
21
+
22
+ def load_seed
23
+ nil
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "decidim/components/namer"
4
+
5
+ Decidim.register_component(:gallery) do |component|
6
+ component.engine = Decidim::Gallery::Engine
7
+ component.admin_engine = Decidim::Gallery::AdminEngine
8
+ component.icon = "decidim/gallery/icon.svg"
9
+ component.permissions_class_name = "Decidim::Gallery::Permissions"
10
+
11
+ component.on(:before_destroy) do |instance|
12
+ raise StandardError, "Can't remove this component" if Decidim::Gallery::GalleryItem.where(component: instance).any?
13
+ end
14
+
15
+ # component.on(:update) do |instance|
16
+ # end
17
+
18
+ # These actions permissions can be configured in the admin panel
19
+ # component.actions = %w(create)
20
+ # component.actions = %w(endorse vote create withdraw amend comment)
21
+
22
+ component.settings(:global) do |settings|
23
+ settings.attribute :announcement, type: :text, translated: true, editor: true
24
+ settings.attribute :show_announcement, type: :boolean, default: true
25
+ settings.attribute :gallery_type, type: :enum, default: "image", choices: %w(image video)
26
+ settings.attribute :items_per_page, type: :enum, default: "12", choices: %w(12 15 18)
27
+ settings.attribute :additional_css, type: :string, default: "medium-up-2 large-up-2"
28
+ settings.attribute :show_title, type: :boolean, default: true
29
+ end
30
+
31
+ # component.settings(:step) do |settings|
32
+ # end
33
+
34
+ # component.register_resource(:some_resource) do |resource|
35
+ # # Register a optional resource that can be references from other resources.
36
+ # resource.model_class_name = "Decidim::Gallery::SomeResource"
37
+ # resource.template = "decidim/gallery/some_resources/linked_some_resources"
38
+ # end
39
+
40
+ # component.register_stat :some_stat do |context, start_at, end_at|
41
+ # # Register some stat number to the application
42
+ # end
43
+
44
+ # component.seeds do |participatory_space|
45
+ # # Add some seeds for this component
46
+ # end
47
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails"
4
+ require "decidim/core"
5
+
6
+ module Decidim
7
+ module Gallery
8
+ # This is the engine that runs on the public interface of gallery.
9
+ class Engine < ::Rails::Engine
10
+ isolate_namespace Decidim::Gallery
11
+
12
+ routes do
13
+ # Add engine routes here
14
+ # resources :gallery
15
+ root to: "gallery#index"
16
+ end
17
+
18
+ initializer "decidim_gallery.deface" do
19
+ Rails.application.configure do
20
+ config.deface.enabled = true
21
+ end
22
+ end
23
+
24
+ initializer "decidim_gallery.webpacker.assets_path" do
25
+ Decidim.register_assets_path File.expand_path("app/packs", root)
26
+ end
27
+
28
+ initializer "decidim_gallery.add_cells_view_paths" do
29
+ Cell::ViewModel.view_paths << File.expand_path("#{Decidim::Gallery::Engine.root}/app/cells")
30
+ Cell::ViewModel.view_paths << File.expand_path("#{Decidim::Gallery::Engine.root}/app/views") # for partials
31
+ end
32
+
33
+ initializer "decidim_gallery.action_controller" do
34
+ Rails.application.reloader.to_prepare do
35
+ ActiveSupport.on_load :action_controller do
36
+ ::Decidim::Admin::StaticPagesController.helper Decidim::Gallery::Admin::ApplicationHelper
37
+ ::Decidim::Admin::StaticPageForm.prepend Decidim::Gallery::Admin::StaticPages::Form
38
+ ::Decidim::Admin::CreateStaticPage.prepend Decidim::Gallery::Admin::StaticPages::Command
39
+ ::Decidim::Admin::UpdateStaticPage.prepend Decidim::Gallery::Admin::StaticPages::Command
40
+ end
41
+ end
42
+ end
43
+
44
+ initializer "decidim_gallery.register_blocks" do
45
+ Decidim.content_blocks.register(:gallery_page, :gallery_container) do |content_block|
46
+ content_block.cell = "decidim/gallery/main_container"
47
+ content_block.settings_form_cell = "decidim/gallery/page_main_container_settings_form"
48
+ content_block.public_name_key = "decidim.gallery.content_blocks.header.name"
49
+
50
+ content_block.settings do |settings|
51
+ settings.attribute :title, type: :string, translated: true
52
+ settings.attribute :gallery_id, type: :integer
53
+ settings.attribute :gallery_per_page, type: :integer, default: 12
54
+ settings.attribute :css, type: :string, default: "medium-up-2 large-up-2"
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end