Skip to content

Commit

Permalink
Merge branch 'main' of github.com:PEMB2030/decidim-capitalofdemocracy…
Browse files Browse the repository at this point in the history
…-barcelona

# Conflicts:
#	package-lock.json
  • Loading branch information
microstudi committed Aug 14, 2023
2 parents db3efe8 + a7a714d commit de4ba74
Show file tree
Hide file tree
Showing 37 changed files with 894 additions and 32 deletions.
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ gem "puma", ">= 5.0.0"

gem "wicked_pdf", "~> 2.1"

gem "deface", ">= 1.9"

group :development, :test do
gem "faker", "~> 2.14"
gem "byebug", "~> 11.0", platform: :mri
Expand All @@ -36,6 +38,7 @@ group :development do
gem "listen"
gem "spring"
gem "spring-watcher-listen"
gem "rubocop-faker"
gem "web-console"
end

Expand Down
15 changes: 15 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,12 @@ GEM
declarative-builder (0.1.0)
declarative-option (< 0.2.0)
declarative-option (0.1.0)
deface (1.9.0)
actionview (>= 5.2)
nokogiri (>= 1.6)
polyglot
railties (>= 5.2)
rainbow (>= 2.1.0)
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
devise (4.9.2)
Expand Down Expand Up @@ -564,6 +570,8 @@ GEM
net-smtp (0.3.3)
net-protocol
nio4r (2.5.9)
nokogiri (1.14.5-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.14.5-x86_64-linux)
racc (~> 1.4)
oauth (1.1.0)
Expand Down Expand Up @@ -616,6 +624,7 @@ GEM
pg_search (2.3.6)
activerecord (>= 5.2)
activesupport (>= 5.2)
polyglot (0.3.5)
premailer (1.21.0)
addressable
css_parser (>= 1.12.0)
Expand Down Expand Up @@ -736,6 +745,9 @@ GEM
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.29.0)
parser (>= 3.2.1.0)
rubocop-faker (1.1.0)
faker (>= 2.12.0)
rubocop (>= 0.82.0)
rubocop-rails (2.15.2)
activesupport (>= 4.2.0)
rack (>= 1.1)
Expand Down Expand Up @@ -859,6 +871,7 @@ GEM
zeitwerk (2.6.11)

PLATFORMS
x86_64-darwin-22
x86_64-linux

DEPENDENCIES
Expand All @@ -873,10 +886,12 @@ DEPENDENCIES
decidim-newsletter_agenda!
decidim-templates!
decidim-term_customizer!
deface (>= 1.9)
faker (~> 2.14)
letter_opener_web
listen
puma (>= 5.0.0)
rubocop-faker
sidekiq
sidekiq-cron
spring
Expand Down
11 changes: 11 additions & 0 deletions app/cells/concerns/decidim/statistic_cell_override.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

module Decidim
module StatisticCellOverride
extend ActiveSupport::Concern

included do
include Decidim::IconHelper
end
end
end
25 changes: 25 additions & 0 deletions app/cells/decidim/content_blocks/active_processes/show.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<section id="active-processes" class="extended home-section">
<div class="wrapper-home">
<div class="row column">
<h3 class="section-heading"><%= t(".title") %></h3>
<div class="text-center">
<div class="row small-up-1 medium-up-3">
<% (1..3).each do |i| %>
<div class="column">
<div class="card">
<%= link_to link_url(i) do %>
<% if (image_url = image_url_for(i)) %>
<%= image_tag image_url %>
<% end %>
<h3 class="heading3 card-header text-left ml-s" style="color: <%= text_color(i) %>;"><%= link_text(i)
%></h3>
<% end %>
</div>
</div>
<% end %>
</div>
<%= button %>
</div>
</div>
</div>
</section>
58 changes: 58 additions & 0 deletions app/cells/decidim/content_blocks/active_processes_cell.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# frozen_string_literal: true

module Decidim
module ContentBlocks
class ActiveProcessesCell < Decidim::ViewModel
def show
render
end

def link_url(attribute)
model.settings["link_url_#{attribute}"]
end

def link_text(attribute)
translated_attribute(model.settings["link_text_#{attribute}"])
end

def image_url_for(attribute)
return unless has_image?(attribute)

blob = image_blob(attribute)
return if blob.nil?

variant = blob.variant(resize_to_fit: [400, 300]).processed
url_for(variant)
end

def text_color(attribute)
model.settings["text_color_#{attribute}"]
end

def button
return unless button_text && button_url

link_to button_text, button_url, class: "button hollow"
end

private

def image_blob(attribute)
model.images_container.send("image_#{attribute}").blob
end

def has_image?(attribute)
image = model.images_container.send("image_#{attribute}")
image.present? && image.attached?
end

def button_text
translated_attribute(model.settings.button_text)
end

def button_url
model.settings.button_url
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<ul class="tabs" data-tabs id="active-processes-tabs">
<% (1..3).each do |i| %>
<li class="tabs-title <%= 'is-active' if i == 1 %>">
<a href="#panel<%= i %>" <%= 'aria-selected="true"' if i == 1 %> data-tabs-target="panel<%= i %>">Item <%= i %></a>
</li>
<% end %>
</ul>

<div class="tabs-content" data-tabs-content="active-processes-tabs">
<% (1..3).each do |i| %>
<div class="tabs-panel <%= 'is-active' if i == 1 %>" id="panel<%= i %>">
<fieldset class="fieldset">
<% form.fields_for :settings, form.object.settings do |settings_fields| %>
<%= settings_fields.translated :text_field, "link_text_#{i}".to_sym, label: t("decidim.content_blocks.active_processes_settings_form.link_text") %>
<%= settings_fields.text_field "link_url_#{i}".to_sym, label: t("decidim.content_blocks.active_processes_settings_form.link_url") %>
<%= settings_fields.text_field "text_color_#{i}", label: t("decidim.content_blocks.active_processes_settings_form.text_color"), type: "color" %>
<% end %>

<div class="organization-images">
<% form.fields_for :images, form.object.images do |images_fields| %>
<%= images_fields.upload "image_#{i}".to_sym, label: t("decidim.content_blocks.active_processes_settings_form.image") %>
<% end %>
</div>
</fieldset>
</div>
<% end %>
<fieldset class="fieldset">
<% form.fields_for :settings, form.object.settings do |settings_fields| %>
<%= settings_fields.translated :text_field, :button_text, label: t("decidim.content_blocks.active_processes_settings_form.button_text") %>
<%= settings_fields.text_field :button_url, label: t("decidim.content_blocks.active_processes_settings_form.button_url") %>
<% end %>
</fieldset>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

module Decidim
module ContentBlocks
class ActiveProcessesSettingsFormCell < Decidim::ViewModel
alias form model
end
end
end
19 changes: 19 additions & 0 deletions app/cells/decidim/content_blocks/extended_hero/show.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<section id="hero" class="extended hero home-section" style="background-image:url('<%= background_image %>');">
<div class="hero__container">
<div class="row">
<div class="columns small-centered large-10">
<h1 class="text-highlight heading1 hero-heading">
<%= welcome_text.html_safe %>
</h1>
<h3 class="text-highlight subtitle-hero">
<%= subtitle_text.html_safe %>
</h3>
</div>
</div>
<div class="row">
<div class="columns small-centered small-6 medium-4 mediumlarge-3">
<%= cta_button %>
</div>
</div>
</div>
</section>
56 changes: 56 additions & 0 deletions app/cells/decidim/content_blocks/extended_hero_cell.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# frozen_string_literal: true

module Decidim
module ContentBlocks
class ExtendedHeroCell < Decidim::ContentBlocks::HeroCell
def show
render
end

def welcome_text
if translated_welcome_text.blank?
default_welcome_text
else
processed_welcome_text
end
end

def subtitle_text
decidim_sanitize(translated_subtitle) if translated_subtitle
end

private

def translated_welcome_text
translated_attribute(model.settings.welcome_title)
end

def translated_subtitle
translated_attribute(model.settings.subtitle)
end

def default_welcome_text
t("decidim.pages.home.hero.welcome", organization: current_organization.name)
end

def processed_welcome_text
text_parts = translated_welcome_text.split("<br>", 2)
content = content_tag(:span, sanitize(text_parts[0]), class: "no-wrap")
content + (text_parts[1] ? ("<br>".html_safe + sanitize(text_parts[1])) : "")
end

# A MD5 hash of model attributes because is needed because
# the model doesn't respond to cache_key_with_version nor updated_at method
def cache_hash
hash = []
hash << "decidim/content_blocks/hero"
hash << Digest::MD5.hexdigest(model.attributes.to_s)
hash << current_organization.cache_key_with_version
hash << I18n.locale.to_s
hash << background_image

hash.join(Decidim.cache_key_separator)
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<% form.fields_for :settings, form.object.settings do |settings_fields| %>
<%= settings_fields.translated :text_field, :welcome_title, label: t(".welcome_text") %>
<%= settings_fields.translated :text_field, :subtitle, label: t(".subtitle") %>
<% end %>
<% form.fields_for :images, form.object.images do |images_fields| %>
<%= images_fields.upload :background_image, label: t(".background_image") %>
<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

module Decidim
module ContentBlocks
class ExtendedHeroSettingsFormCell < Decidim::ViewModel
alias form model

def content_block
options[:content_block]
end
end
end
end
14 changes: 14 additions & 0 deletions app/cells/decidim/statistic/show.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<div class="statistic__data flex--fsc <%= stat_dom_class %>">
<div class="statistic__icon flex--cc">
<%= icon "actions", class: "card--list__icon", role: "img", "aria-hidden": true, remove_icon_class: true %>
</div>
<div>
<span class="statistic__number">
<%= stat_number %>
</span>

<h4 class="statistic__title">
<%= stat_title %>
</h4>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!-- replace 'erb[silent]:contains("if organization.logo.attached?")' closing_selector 'erb[silent]:contains("end")' -->

<%= render partial: "layouts/decidim/header_logo", locals: {organization: organization} %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!-- replace ".main-footer" -->

<div class="main-footer">
<% if current_organization && current_organization.official_img_footer.attached? %>
<%= link_to current_organization.official_url, class: "main-footer__badge" do %>
<%= image_tag current_organization.attached_uploader(:official_img_footer).path, alt: current_organization.name %>
<% end %>
<% end %>
<div class="row">
<div class="main-footer__content flex--sbc column">
<div class="logos flex--sbc">
<div class="footer-logo">
<%= image_pack_tag("media/images/logo_capitalitat.png") %>
</div>
<div class="footer-logo">
<%= image_pack_tag("media/images/logo_footer_2.png") %>
</div>
</div>
<%= render partial: "layouts/decidim/social_media_links" %>
</div>
</div>
</div>
Loading

0 comments on commit de4ba74

Please sign in to comment.