diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7fcbb16..cdac3d4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,6 +35,22 @@ jobs: ruby-version: ${{ env.RUBY_VERSION }} bundler-cache: true + - uses: nanasess/setup-chromedriver@v2 + with: + chromedriver-version: 119.0.6045.105 + + - name: List Chrome + shell: "bash" + run: apt list --installed | grep chrome + + - name: Remove Chrome + shell: "bash" + run: sudo apt remove google-chrome-stable + + - uses: browser-actions/setup-chrome@v1 + with: + chrome-version: 119.0.6045.105 + - name: Bundle Install run: bundle install diff --git a/.gitignore b/.gitignore index 173f5f3..e201893 100644 --- a/.gitignore +++ b/.gitignore @@ -61,5 +61,5 @@ node_modules yarn-debug.log* .yarn-integrity -public/sw.js -public/sw.js.map +public/sw.js* +public/sw.js.map* diff --git a/app/controllers/multimedia_gallery_controller.rb b/app/controllers/multimedia_gallery_controller.rb new file mode 100644 index 0000000..2f14f7f --- /dev/null +++ b/app/controllers/multimedia_gallery_controller.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class MultimediaGalleryController < Decidim::ApplicationController + helper_method :media_links + + private + + def media_links + @media_links ||= begin + JSON.parse(File.read(Rails.root.join("tmp/multimedia/#{current_organization.id}.json"))).map(&:deep_symbolize_keys) + rescue Errno::ENOENT + [] + end + end +end diff --git a/app/jobs/plataformess/multimedia/sync_all_job.rb b/app/jobs/plataformess/multimedia/sync_all_job.rb new file mode 100644 index 0000000..f43eb9a --- /dev/null +++ b/app/jobs/plataformess/multimedia/sync_all_job.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +module Plataformess + module Multimedia + class SyncAllJob < ApplicationJob + queue_as :default + + def perform(organization_id) + media_links = media_links(organization_id) + Rails.logger.info "SyncAllJob: #{media_links.count} media links to process" + return if media_links.empty? + + store_result(organization_id, media_links.map { |media_link| process_media_link(media_link) }) + end + + private + + def store_result(organization_id, result) + File.write(Rails.root.join("tmp/multimedia/#{organization_id}.json"), result.to_json) + end + + def media_links(organization_id) + @media_links ||= Decidim::Conferences::MediaLink.left_outer_joins(conference: :scope) + .where(conference: { decidim_organization_id: organization_id }) + .order(updated_at: :desc) + end + + def process_media_link(media_link) + { + title: media_link.title, + date: media_link.date, + link: process_link(media_link.link), + conference_slug: media_link.conference.slug, + scope: media_link.conference.scope.present? ? media_link.conference.scope.name : nil + } + end + + def process_link(link) + return peertube_embed_url(link) if link.match?("peertube") + + link + end + + def peertube_embed_url(url) + url.match?("watch") ? url.gsub("watch", "embed") : url.gsub("/w/", "/videos/embed/") + end + end + end +end diff --git a/app/packs/stylesheets/plataformess.scss b/app/packs/stylesheets/plataformess.scss index f66f5b2..c9c8680 100644 --- a/app/packs/stylesheets/plataformess.scss +++ b/app/packs/stylesheets/plataformess.scss @@ -112,3 +112,4 @@ @import "plataformess/process"; @import "plataformess/social_crowdfunding"; @import "plataformess/tables"; +@import "plataformess/multimedia_gallery"; diff --git a/app/packs/stylesheets/plataformess/_multimedia_gallery.scss b/app/packs/stylesheets/plataformess/_multimedia_gallery.scss new file mode 100644 index 0000000..33cb32e --- /dev/null +++ b/app/packs/stylesheets/plataformess/_multimedia_gallery.scss @@ -0,0 +1,39 @@ +.multimedia_gallery { + .row { + display: flex; + } + + @media screen and (max-width: 596px) { + .row { + flex-direction: column-reverse; + padding-bottom: 10%; + } + } + + .column { + flex: 1; + } + + .info{ + flex: 1; + display: flex; + flex-direction: column; + justify-content: left; + align-items: flex-start; + padding: 5%; + overflow: hidden; + } + + .tags { + li { + a { + cursor: default; + text-decoration: none; + color: inherit; + &:hover { + border-color: $link-color; + } + } + } + } +} diff --git a/app/views/multimedia_gallery/index.html.erb b/app/views/multimedia_gallery/index.html.erb new file mode 100644 index 0000000..0e2e258 --- /dev/null +++ b/app/views/multimedia_gallery/index.html.erb @@ -0,0 +1,19 @@ + diff --git a/app/workers/multimedia_gallery_worker.rb b/app/workers/multimedia_gallery_worker.rb new file mode 100644 index 0000000..1d65055 --- /dev/null +++ b/app/workers/multimedia_gallery_worker.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require "rake" + +Rails.application.load_tasks + +class MultimediaGalleryWorker + include Sidekiq::Worker + + def perform(*_args) + Rake::Task["plataformess:multimedia:sync:all"].invoke + end +end diff --git a/config/database.yml b/config/database.yml index 27440db..b9bee79 100644 --- a/config/database.yml +++ b/config/database.yml @@ -29,7 +29,7 @@ default: &default development: <<: *default - database: decidim-plataformess_development + database: <%= ENV.fetch("DATABASE_NAME") { "decidim-plataformess_development" } %> # The specified database role being used to connect to postgres. # To create additional roles in postgres see `$ createuser --help`. diff --git a/config/locales/ca.yml b/config/locales/ca.yml new file mode 100644 index 0000000..96c75e2 --- /dev/null +++ b/config/locales/ca.yml @@ -0,0 +1,5 @@ +--- +ca: + conferences: + multimedia_gallery: + go_to_conference: Anar a la jornada diff --git a/config/locales/en.yml b/config/locales/en.yml index 5463f43..2a6bc78 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,3 +1,5 @@ --- en: - hello: Hello world + conferences: + multimedia_gallery: + go_to_conference: Go to conference diff --git a/config/routes.rb b/config/routes.rb index ed07b7b..5aafe9a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -12,4 +12,6 @@ mount Decidim::Core::Engine => "/" # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html + + resources :multimedia_gallery, only: :index end diff --git a/config/schedule.yml b/config/schedule.yml index ecfba24..f62b074 100644 --- a/config/schedule.yml +++ b/config/schedule.yml @@ -9,3 +9,8 @@ data_job: cron: "3 3 * * *" class: "DataPortabilityWorker" queue: default + +multimedia_gallery_job: + cron: "0 1 * * *" + class: "MultimediaGalleryWorker" + queue: default diff --git a/config/secrets.yml b/config/secrets.yml index d9a2f07..56e3f30 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -158,7 +158,7 @@ default: &default development: <<: *default - secret_key_base: d68bdd64e847c12983623875b9c7e1fd16e36b4ea46e5d44c83bfb49b29af647af3b4b2741a6b7032e74e88018db0de5a206caa9b8b198c295aaad820d8b904a + secret_key_base: <%= Decidim::Env.new("SECRET_KEY_BASE", "d68bdd64e847c12983623875b9c7e1fd16e36b4ea46e5d44c83bfb49b29af647af3b4b2741a6b7032e74e88018db0de5a206caa9b8b198c295aaad820d8b904a") %> omniauth: developer: enabled: true diff --git a/lib/tasks/plataformess/multimedia.rake b/lib/tasks/plataformess/multimedia.rake new file mode 100644 index 0000000..a26dc66 --- /dev/null +++ b/lib/tasks/plataformess/multimedia.rake @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +namespace :plataformess do + namespace :multimedia do + namespace :sync do + desc "Sync all media links" + task all: :environment do + Decidim::Organization.find_each do |organization| + Plataformess::Multimedia::SyncAllJob.perform_now(organization.id) + end + end + end + end +end