-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Multimedia gallery from conference media links (#25)
* Multimedia gallery from conference media links * Change multimedia path * Lock ChromeDriver to 119.0.6045.105 * Apply styles on multimedia page * Fix .gitignore and configurable local database and secret key base configurable * Lint files * Schedule multimedia gallery rake task * Lint file * Pinning chrome version to v119
- Loading branch information
Showing
15 changed files
with
185 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
app/packs/stylesheets/plataformess/_multimedia_gallery.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<div class="multimedia_gallery"> | ||
<% media_links.each do |media_link| %> | ||
<div class="row"> | ||
<div class="column"> | ||
<div class="responsive-embed widescreen"> | ||
<iframe sandbox="allow-same-origin allow-scripts allow-popups" src="<%= media_link[:link] %>" frameborder="0" allowfullscreen></iframe> | ||
</div> | ||
</div> | ||
<div class="info"> | ||
<h2 class="heading2"><%= translated_attribute media_link[:title] %></h2> | ||
<p><%= l(Date.parse(media_link[:date]), format: :decidim_short_with_month_name_short) %></p> | ||
<% if media_link[:scope].present? %> | ||
<ul class="tags"><li><a><%= translated_attribute media_link[:scope] %></a></li></ul> | ||
<% 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" %> | ||
</div> | ||
</div> | ||
<% end %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
ca: | ||
conferences: | ||
multimedia_gallery: | ||
go_to_conference: Anar a la jornada |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
--- | ||
en: | ||
hello: Hello world | ||
conferences: | ||
multimedia_gallery: | ||
go_to_conference: Go to conference |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |