Class: Decidim::Core::ContentBlocks::RegistryManager

Inherits:
Object
  • Object
show all
Defined in:
decidim-core/lib/decidim/core/content_blocks/registry_manager.rb

Class Method Summary collapse

Class Method Details

.register_homepage_content_blocks!Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'decidim-core/lib/decidim/core/content_blocks/registry_manager.rb', line 7

def self.register_homepage_content_blocks!
  Decidim.content_blocks.register(:homepage, :hero) do |content_block|
    content_block.cell = "decidim/content_blocks/hero"
    content_block.settings_form_cell = "decidim/content_blocks/hero_settings_form"
    content_block.public_name_key = "decidim.content_blocks.hero.name"

    content_block.images = [
      {
        name: :background_image,
        uploader: "Decidim::HomepageImageUploader"
      }
    ]

    content_block.settings do |settings|
      settings.attribute :welcome_text, type: :text, translated: true
      settings.attribute :cta_button_path, type: :string, translated: true
      settings.attribute :cta_button_text, type: :string, translated: true
    end

    content_block.default!
  end

  Decidim.content_blocks.register(:homepage, :global_menu) do |content_block|
    content_block.cell = "decidim/content_blocks/global_menu"
    content_block.public_name_key = "decidim.content_blocks.global_menu.name"
    content_block.default!
  end

  Decidim.content_blocks.register(:homepage, :sub_hero) do |content_block|
    content_block.cell = "decidim/content_blocks/sub_hero"
    content_block.public_name_key = "decidim.content_blocks.sub_hero.name"
    content_block.default!
  end

  Decidim.content_blocks.register(:homepage, :highlighted_content_banner) do |content_block|
    content_block.cell = "decidim/content_blocks/highlighted_content_banner"
    content_block.settings_form_cell = "decidim/content_blocks/highlighted_content_banner_settings_form"
    content_block.public_name_key = "decidim.content_blocks.highlighted_content_banner.name"

    content_block.images = [
      {
        name: :background_image,
        uploader: "Decidim::HomepageImageUploader"
      }
    ]

    content_block.settings do |settings|
      settings.attribute :title, type: :text, translated: true
      settings.attribute :short_description, type: :text, translated: true
      settings.attribute :action_button_title, type: :text, translated: true
      settings.attribute :action_button_subtitle, type: :text, translated: true
      settings.attribute :action_button_url, type: :text
    end

    content_block.default!
  end

  Decidim.content_blocks.register(:homepage, :how_to_participate) do |content_block|
    content_block.cell = "decidim/content_blocks/how_to_participate"
    content_block.public_name_key = "decidim.content_blocks.how_to_participate.name"
    content_block.default!
  end

  Decidim.content_blocks.register(:homepage, :last_activity) do |content_block|
    content_block.cell = "decidim/content_blocks/last_activity"
    content_block.public_name_key = "decidim.content_blocks.last_activity.name"
    content_block.default!
  end

  Decidim.content_blocks.register(:homepage, :stats) do |content_block|
    content_block.cell = "decidim/content_blocks/stats"
    content_block.public_name_key = "decidim.content_blocks.stats.name"
    content_block.default!
  end

  Decidim.content_blocks.register(:homepage, :footer_sub_hero) do |content_block|
    content_block.cell = "decidim/content_blocks/footer_sub_hero"
    content_block.public_name_key = "decidim.content_blocks.footer_sub_hero.name"
    content_block.default!
  end

  Decidim.content_blocks.register(:homepage, :html) do |content_block|
    content_block.cell = "decidim/content_blocks/html"
    content_block.public_name_key = "decidim.content_blocks.html.name"
    content_block.settings_form_cell = "decidim/content_blocks/html_settings_form"

    content_block.settings do |settings|
      settings.attribute :html_content, type: :text, translated: true
    end
  end
end

.register_newsletter_templates!Object



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'decidim-core/lib/decidim/core/content_blocks/registry_manager.rb', line 138

def self.register_newsletter_templates!
  Decidim.content_blocks.register(:newsletter_template, :basic_only_text) do |content_block|
    content_block.cell = "decidim/newsletter_templates/basic_only_text"
    content_block.settings_form_cell = "decidim/newsletter_templates/basic_only_text_settings_form"
    content_block.public_name_key = "decidim.newsletter_templates.basic_only_text.name"

    content_block.settings do |settings|
      settings.attribute(
        :body,
        type: :text,
        translated: true,
        preview: -> { I18n.t("decidim.newsletter_templates.basic_only_text.body_preview") }
      )
    end

    content_block.default!
  end

  Decidim.content_blocks.register(:newsletter_template, :image_text_cta) do |content_block|
    content_block.cell = "decidim/newsletter_templates/image_text_cta"
    content_block.settings_form_cell = "decidim/newsletter_templates/image_text_cta_settings_form"
    content_block.public_name_key = "decidim.newsletter_templates.image_text_cta.name"

    content_block.images = [
      {
        name: :main_image,
        uploader: "Decidim::NewsletterTemplateImageUploader",
        preview: -> { ActionController::Base.helpers.asset_pack_path("media/images/placeholder.jpg") }
      }
    ]

    content_block.settings do |settings|
      settings.attribute(
        :introduction,
        type: :text,
        translated: true,
        preview: -> { I18n.t("decidim.newsletter_templates.image_text_cta.introduction_preview") }
      )
      settings.attribute(
        :body,
        type: :text,
        translated: true,
        preview: -> { I18n.t("decidim.newsletter_templates.image_text_cta.body_preview") }
      )
      settings.attribute(
        :cta_text,
        type: :text,
        translated: true,
        preview: -> { I18n.t("decidim.newsletter_templates.image_text_cta.cta_text_preview") }
      )
      settings.attribute(
        :cta_url,
        type: :text,
        translated: true,
        preview: -> { "http://decidim.org" }
      )
    end

    content_block.default!
  end
end

.register_static_page_blocks!Object



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'decidim-core/lib/decidim/core/content_blocks/registry_manager.rb', line 99

def self.register_static_page_blocks!
  Decidim.content_blocks.register(:static_page, :summary) do |content_block|
    content_block.cell = "decidim/content_blocks/static_page/summary"
    content_block.settings_form_cell = "decidim/content_blocks/static_page/summary_settings_form"
    content_block.public_name_key = "decidim.content_blocks.static_page.summary.name"

    content_block.settings do |settings|
      settings.attribute :summary, type: :text, translated: true
    end

    content_block.default!
  end

  Decidim.content_blocks.register(:static_page, :section) do |content_block|
    content_block.cell = "decidim/content_blocks/static_page/section"
    content_block.settings_form_cell = "decidim/content_blocks/static_page/section_settings_form"
    content_block.public_name_key = "decidim.content_blocks.static_page.section.name"

    content_block.settings do |settings|
      settings.attribute :content, type: :text, translated: true
    end

    content_block.default!
  end

  Decidim.content_blocks.register(:static_page, :two_pane_section) do |content_block|
    content_block.cell = "decidim/content_blocks/static_page/two_pane_section"
    content_block.settings_form_cell = "decidim/content_blocks/static_page/two_pane_section_settings_form"
    content_block.public_name_key = "decidim.content_blocks.static_page.two_pane_section.name"

    content_block.settings do |settings|
      settings.attribute :left_column, type: :text, translated: true
      settings.attribute :right_column, type: :text, translated: true
    end

    content_block.default!
  end
end