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 @@ +
<%= l(Date.parse(media_link[:date]), format: :decidim_short_with_month_name_short) %>
+ <% if media_link[:scope].present? %> + + <% end %> + <%= link_to t("conferences.multimedia_gallery.go_to_conference"), Decidim::Conferences::Engine.routes.url_helpers.conference_path(slug: media_link[:conference_slug]), target: "_blank" %> +