Compare commits

...

2 Commits

Author SHA1 Message Date
edb558c2d5 ADD portada, backend & styles 2025-07-25 11:51:47 +00:00
81f7145333 ADD header & menus 2025-07-25 11:51:11 +00:00
9 changed files with 363 additions and 111 deletions

View File

@ -1,5 +1,61 @@
jQuery( document ).ready( function( $ ) {
// jQuery( document ).ready( function( $ ) {
// console.log('modal')
// Your JavaScript goes here
// $(document).ready(function () {
// const $videoModal = $('#videoModal');
// const $modalIframe = $('#modalVideoIframe');
// const $modalTitle = $('#videoModalLabel');
// // Cuando se abre el modal
// $videoModal.on('show.bs.modal', function (event) {
// const $button = $(event.relatedTarget);
// const videoUrl = $button.data('video-url');
// const videoTitle = $button.data('video-title');
// const videoAllow = $button.data('video-allow');
// const separator = videoUrl.includes('?') ? '&' : '?';
// const autoplayUrl = videoUrl + separator + 'autoplay=1';
// $modalIframe.attr('src', autoplayUrl);
// $modalIframe.attr('title', videoTitle);
// $modalIframe.attr('allow', videoAllow);
// $modalTitle.text(videoTitle);
// });
// // Cuando se cierra el modal, parar el vídeo
// $videoModal.on('hide.bs.modal', function () {
// $modalIframe.attr('src', '');
// });
// });
// });
console.log('hello')
document.addEventListener('DOMContentLoaded', function() {
const videoModal = document.getElementById('videoModal');
const modalIframe = document.getElementById('modalVideoIframe');
const modalTitle = document.getElementById('videoModalLabel');
// Cuando se abre el modal
videoModal.addEventListener('show.bs.modal', function (event) {
const button = event.relatedTarget;
const videoUrl = button.getAttribute('data-video-url');
const videoTitle = button.getAttribute('data-video-title');
const videoAllow = button.getAttribute('data-video-allow');
// Añadir autoplay al URL si no lo tiene
const separator = videoUrl.includes('?') ? '&' : '?';
const autoplayUrl = videoUrl + separator + 'autoplay=1';
modalIframe.src = autoplayUrl;
modalIframe.title = videoTitle;
modalIframe.allow = videoAllow;
modalTitle.textContent = videoTitle;
});
// Cuando se cierra el modal, parar el vídeo
videoModal.addEventListener('hide.bs.modal', function () {
modalIframe.src = '';
});
});

View File

@ -31,9 +31,7 @@ class StarterSite extends Site {
add_filter('upload_mimes', [$this, 'add_svg_support']); //add svg files
add_filter('timber/context', [$this, 'add_global_context']); // variables globales
//add_filter('timber/twig', [$this, 'add_youtube_function_to_twig']);
add_filter('timber/twig', [$this, 'add_videos_embed_to_twig']);
add_filter('timber/twig', [$this, 'add_videos_embed_to_twig']); //videos embed
parent::__construct();
}
@ -48,9 +46,9 @@ class StarterSite extends Site {
wp_enqueue_style( 'twbsi', get_template_directory_uri() . '/vendor/twbs/bootstrap-icons/font/bootstrap-icons.min.css', [], $version, 'all');
wp_enqueue_style( 'lust', get_template_directory_uri() . '/style.css', [], $version, 'all');
//~ wp_enqueue_script( 'pop', get_template_directory_uri() . '/static/popper.min.js', [], $version, false);
// wp_enqueue_script( 'pop', get_template_directory_uri() . '/static/popper.min.js', [], $version, false);
wp_enqueue_script( 'twbs', get_template_directory_uri() . '/vendor/twbs/bootstrap/dist/js/bootstrap.min.js', [], $version, false);
//wp_enqueue_script( 'lust', get_template_directory_uri() . '/static/site.js', [], $version, false);
wp_enqueue_script( 'lust', get_template_directory_uri() . '/assets/scripts/site.js', [], $version, false);
}
@ -192,6 +190,11 @@ class StarterSite extends Site {
return $options;
}
/**
* New functions to add Sindikatua theme
* @author Gustavo
*/
//add svg files
public function add_svg_support($file_types) {
$new_filetypes = array();
@ -229,6 +232,7 @@ class StarterSite extends Site {
private function getIconsRRSS() {
$icons_rrss = [];
for ($i = 1; $i <= 4; $i++) {
$img = get_field('rrss_img_' . $i, 'option');
$url = get_field('rrss_url_' . $i, 'option');
@ -246,7 +250,7 @@ class StarterSite extends Site {
private function getLogosHeader ($max_logos = 2) {
$logos = [];
for ($i = 1; $i <= $max_logos; $i++) {
$logoHeader = get_field('logo_header_' . $i, 'option');
$textoHeader = get_field('texto_header_' . $i, 'option');
@ -260,13 +264,12 @@ class StarterSite extends Site {
}
return $logos;
}
private function getVideosCarousel($cantidad = 2) {
private function getVideosCarousel() {
return Timber::get_posts([
'post_type' => 'videos',
'posts_per_page' => $cantidad,
'posts_per_page' => -1, // -1 = sin límite
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC'
@ -283,17 +286,15 @@ class StarterSite extends Site {
]);
}
// Añadir en functions.php si no la tienes ya
// private function obtener_youtube_id($url) {
// $pattern = '/(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/\s]{11})/';
// preg_match($pattern, $url, $matches);
// return isset($matches[1]) ? $matches[1] : false;
// }
// public function add_youtube_function_to_twig($twig) {
// $twig->addFunction(new \Twig\TwigFunction('youtube_id', [$this, 'obtener_youtube_id']));
// return $twig;
// }
private function getCampanaArticles() {
return Timber::get_posts([
'post_type' => 'campana',
'posts_per_page' => 1,
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC'
]);
}
public function generar_embed_universal($url) {
if (empty($url)) {
@ -304,12 +305,13 @@ class StarterSite extends Site {
if (strpos($url, 'youtube.com') !== false || strpos($url, 'youtu.be') !== false) {
//error_log('es un vídeo de youtube'); // Debug
preg_match('/(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/\s]{11})/', $url, $matches);
if (!empty($matches[1])) {
$embed_data = [
'platform' => 'youtube',
'embed_url' => 'https://www.youtube.com/embed/' . $matches[1] . '?rel=0&modestbranding=1',
'allow' => 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture'
'thumbnail_url' => 'https://img.youtube.com/vi/' . $matches[1]. '/hqdefault.jpg',
'allow' => 'autoplay; encrypted-media; picture-in-picture'
];
//error_log('Embed URL generada: ' . $embed_data['embed_url']);
@ -357,6 +359,7 @@ class StarterSite extends Site {
$context['logos_header'] = $this->getLogosHeader();
$context['videos_carousel'] = $this->getVideosCarousel();
$context['ultimo_articulo_opinion'] = $this->getUltimoArticuloOpinion();
$context['posts_campana'] = $this->getCampanaArticles();
return $context;
}

View File

@ -11,7 +11,12 @@
font-display: swap;
}
/* HEADER sindikatua */
.text-sindikatua {
font-family: 'Yaro', Arial, sans-serif;
}
/* HEADER ->MENU */
@media (min-width: 992px) {
.menu-bar .dropdown:hover .dropdown-menu {
display: block;
@ -40,9 +45,8 @@
}
/* CSS cards 'noticias' */
.recent-posts .card-img-overlay,
.opinion-article .card-img-overlay {
/* PORTADA -> CARDS RECENt POSTS NOTICIAS */
.recent-posts .card-img-overlay {
top: auto !important; /* Anula el top: 0 por defecto de Bootstrap */
bottom: 0;
height: 25%;
@ -51,6 +55,28 @@
align-items: center;
}
/* PORTADA -> CARDS OPINION */
.opinion-article .card-img-overlay {
top: auto !important; /* Anula el top: 0 por defecto de Bootstrap */
bottom: 0;
height: 30%;
background: rgba(128, 128, 128, 0.8);
display: flex;
align-items: center;
}
@media (991px <= width < 1400px) {
.opinion-article .card-img-overlay {
height: 40%;
}
}
@media (width < 990px) {
.opinion-article .card-img-overlay {
height: 20%;
}
}
.recent-posts .card-title,
.opinion-article .card-title {
color: white;
@ -76,26 +102,59 @@
color: #E30B16;
}
.card.secondary-article {
height: auto;
}
.recent-posts .card.secondary-article .card-title {
font-size: medium;
}
/* Responsive */
@media (max-width: 768px) {
.card-img-overlay {
.recent-posts .card-img-overlay {
height: 18%;
}
.card-title {
.recent-posts .card-title {
font-size: 0.9rem;
}
.recent-posts .media-mb {
margin-bottom: 1rem; /* o el valor que necesites */
}
}
/* PORTADA -> Titles */
.page-portada .sp-module-title::after {
background: #cc1d1a;
content: "";
height: 1px;
left: 0;
position: absolute;
bottom: -12px;
width: 150px;
}
.page-portada .sp-module-title::before {
background: #cc1d1a;
content: "";
height: 1px;
left: 0;
position: absolute;
bottom: -15px;
width: 150px;
}
/* PORTADA -> SECTION VIDEO */
.video-iframe {
border-radius: 0.5rem; /* o usa la clase .rounded directamente */
overflow: hidden;
}
/* PORTADA -> SECTION CAMPAÑA */
.card-img-fixed {
max-height: 300px; /* o el valor que necesites */
object-fit: cover;
width: 100%;
}
/* FOOTER */
/* Convert SVG RRSS white */
.svg-white {
filter: brightness(0) invert(1);
@ -118,10 +177,4 @@
.svg-hover-white:hover {
filter: brightness(0) invert(1);
}
/* texto header sindikatua */
.text-sindikatua {
font-family: 'Yaro', Arial, sans-serif;
}
}

View File

@ -19,8 +19,8 @@
</div>
<!-- nav -->
<div class="row align-items-center justify-content-around container-fluid bg-body-tertiary">
<div class="col-7 col-md-10">
<div class="d-flex align-items-center justify-content-around bg-body-tertiary">
<div>
<nav class="navbar navbar-expand-lg">
<div class="container-fluid">
<div class="collapse navbar-collapse" id="navbarNavDropdown">
@ -29,10 +29,10 @@
</div>
</nav>
</div>
<div class="col-3 col-md-1 mt-2 mt-sm-0">
{#<div>
{% include "partials/btn-search.twig" with {'items': menu.get_items} %}
</div>
<div class="col-2 col-md-1">
</div> #}
<div>
{% include "partials/menu-burger.twig" with {'items': menu.get_items} %}
</div>
</div>

View File

@ -15,17 +15,30 @@
{% if (item.children) %}
<li class="nav-item dropdown effect-nav">
{#<a class="nav-link dropdown-toggle" href="{{ item.link }}" role="button" data-bs-toggle="dropdown" aria-expanded="false">#}
<a class="nav-link dropdown-toggle text-light" href="{{ item.link }}" role="button" aria-expanded="false">
{{item.title}}</a>
<a class="nav-link dropdown-toggle text-light"
{% if item.target %}target="{{ item.target }}"{% endif %}
{% if item.xfn %}rel="{{ item.xfn }}"{% endif %}
href="{{ item.link }}"
role="button"
aria-expanded="false">
{{item.title}}
</a>
<ul class="dropdown-menu">
{% for subitem in item.children %}
<li><a class="dropdown-item text-dark" href="{{ subitem.link }}">{{subitem.title}}</a></li>
<li><a class="dropdown-item text-dark"
{% if subitem.target %}target="{{ subitem.target }}"{% endif %}
{% if subitem.xfn %}rel="{{ subitem.xfn }}"{% endif %}
href="{{ subitem.link }}">
{{subitem.title}}</a></li>
{% endfor %}
</ul>
</li>
{% else %}
<li class="{{item.classes | join(' ')}} nav-item effect-nav">
<a class="nav-link text-light" href="{{ item.link }}">
<a class="nav-link text-light"
href="{{ item.link }}"
{% if item.xfn %}rel="{{ item.xfn }}"{% endif %}
{% if item.target %}target="{{ item.target }}"{% endif %}>
{{ item.title }}
</a>
{% include 'partials/menu.twig' with {items: item.children} %}

View File

@ -4,17 +4,32 @@
{% if (item.children) %}
<li class="nav-item dropdown effect-nav">
{#<a class="nav-link dropdown-toggle" href="{{ item.link }}" role="button" data-bs-toggle="dropdown" aria-expanded="false">#}
<a class="nav-link dropdown-toggle" href="{{ item.link }}" role="button" aria-expanded="false">
{{item.title}}</a>
<a class="nav-link dropdown-toggle"
href="{{ item.link }}"
role="button"
aria-expanded="false"
{% if item.xfn %}rel="{{ item.xfn }}"{% endif %}
{% if item.target %}target="{{ item.target }}"{% endif %}>
{{item.title}}
</a>
<ul class="dropdown-menu">
{% for subitem in item.children %}
<li><a class="dropdown-item" href="{{ subitem.link }}">{{subitem.title}}</a></li>
<li><a class="dropdown-item"
href="{{ subitem.link }}"
{% if subitem.xfn %}rel="{{ subitem.xfn }}"{% endif %}
{% if subitem.target %}target="{{ subitem.target }}"{% endif %}>
{{subitem.title}}
</a>
</li>
{% endfor %}
</ul>
</li>
{% else %}
<li class="{{item.classes | join(' ')}} nav-item effect-nav">
<a class="nav-link" href="{{ item.link }}">
<a class="nav-link"
href="{{ item.link }}"
{% if item.xfn %}rel="{{ item.xfn }}"{% endif %}
{% if item.target %}target="{{ item.target }}"{% endif %}>
{{ item.title }}
</a>
{% include 'partials/menu.twig' with {items: item.children} %}

View File

@ -1,48 +1,73 @@
<section class="py-5">
<section class="py-4">
<div class="container">
<div class="row align-items-center">
<div class="row align-items-stretch">
{# Primera columna - Carousel con vídeos embebidos #}
<div class="col-lg-8 col-12 mb-4 mb-lg-0">
<h2 class="mb-4">Últimos Vídeos</h2>
<p class="mb-4 position-relative fs-4 fw-bold sp-module-title">VÍDEOS</p>
{% if videos_carousel %}
<div id="videosCarousel" class="carousel slide" data-bs-ride="carousel">
<div class="carousel-inner">
{% for pair in videos_carousel|batch(2, null) %}
<div class="carousel-item {% if loop.first %}active{% endif %}">
<div class="row">
{% for video in pair %}
{% if video %}
<div class="col-6">
<div class="video-item">
{% set url_video = video.meta('url_video') %}
{% set video_data = generar_embed(url_video) %}
{% for pair in videos_carousel|batch(2, null) %}
<div class="carousel-item {% if loop.first %}active{% endif %}">
<div class="row">
{% for video in pair %}
{% if video %}
<div class="col-6">
<div class="video-item">
{% set url_video = video.meta('url_video') %}
{% set video_data = generar_embed(url_video) %}
{% if video_data %}
{# Thumbnail clickeable en lugar del iframe #}
<div class="ratio ratio-16x9 video-thumbnail-container position-relative rounded"
data-bs-toggle="modal"
data-bs-target="#videoModal"
data-video-url="{{ video_data.embed_url }}"
data-video-title="{{ video.titulo }}"
data-video-allow="{{ video_data.allow }}"
style="cursor: pointer;
background-image: url('{{ video_data.thumbnail_url }}');
background-size: cover;
background-position: center;">
{% if video_data %}
<div class="ratio ratio-1x1">
<iframe src="{{ video_data.embed_url }}"
title="{{ video.titulo }}"
frameborder="0"
allow="{{ video_data.allow }}"
allowfullscreen>
</iframe>
</div>
{% else %}
<div class="alert alert-warning">
<h5>{{ video.titulo }}</h5>
<p class="mb-0">No se ha configurado URL para este vídeo.</p>
</div>
{% endif %}
{# Overlay con botón play #}
<div class="position-absolute top-0 start-0 w-100 h-100 d-flex align-items-center justify-content-center">
<div class="btn btn-danger btn-lg rounded-circle d-flex align-items-center justify-content-center"
style="width: 60px; height: 60px;">
<i class="bi bi-play-btn" style="font-size: 2rem;"></i>
</div>
</div>
{# Overlay oscuro al hover #}
<div class="position-absolute top-0 start-0 w-100 h-100 bg-dark opacity-0 hover-overlay"
style="transition: opacity 0.3s ease;">
</div>
{# Título del vídeo #}
<div class="position-absolute bottom-0 start-0 end-0 bg-dark bg-opacity-75 text-white p-3 rounded">
<h6 class="mb-0 text-white">{{ video.titulo }}</h6>
</div>
</div>
{% else %}
<div class="alert alert-warning">
<h5>{{ video.titulo }}</h5>
<p class="mb-0">No se ha configurado URL para este vídeo.</p>
</div>
{% endif %}
{% endfor %}
</div>
</div>
{% endif %}
{% endfor %}
</div>
{% endfor %}
</div>
{% endfor %}
</div>
{# carousel controls buttons#}
{% if videos_carousel|length > 1 %}
<button class="carousel-control-prev" type="button" data-bs-target="#videosCarousel" data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
@ -53,45 +78,80 @@
<span class="visually-hidden">Siguiente</span>
</button>
<div class="carousel-indicators">
{# <div class="carousel-indicators">
{% for pair in videos_carousel|batch(2, null) %}
<button type="button" data-bs-target="#videosCarousel" data-bs-slide-to="{{ loop.index0 }}"
{% if loop.first %}class="active"{% endif %} aria-label="Slide {{ loop.index }}"></button>
{% endfor %}
</div>
</div> #}
{% endif %}
</div>
{% else %}
<p>No hay vídeos disponibles.</p>
{% endif %}
</div>
{# Segunda columna - Último artículo de opinión #}
<div class="col-lg-4 col-12 opinion-article">
<h2 class="mb-4">Última Opinión</h2>
{% if ultimo_articulo_opinion %}
<div class="h-100">
{% for article in ultimo_articulo_opinion %}
<div class="card secondary-article">
<a href="{{ article.link }}">
<img src="{{ article.thumbnail.src('medium') }}"
alt="{{ article.thumbnail.alt }}"
class="card-img"/>
<div class="card-img-overlay">
<h3 class="card-title text-wrap">
<a href="{{ article.link }}">{{ article.title }}</a>
</h3>
</div>
</a>
{# MODAL PARA REPRODUCIR VÍDEO #}
<div class="modal fade" id="videoModal" tabindex="-1" aria-labelledby="videoModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="videoModalLabel"></h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Cerrar"></button>
</div>
<div class="modal-body p-0">
<div class="ratio ratio-16x9">
<iframe id="modalVideoIframe"
src=""
title=""
frameborder="0"
allow=""
allowfullscreen
loading="lazy">
</iframe>
</div>
{% endfor %}
</div>
</div>
{% else %}
<p class="text-muted">No hay artículos de opinión disponibles.</p>
{% endif %}
</div>
</div>
{# Segunda columna - Último artículo de opinión #}
<div class="col-lg-4 col-12 opinion-article d-flex flex-column">
<p class="mb-4 position-relative fs-4 fw-bold sp-module-title">OPINIÓN</p>
<div class="flex-grow-1 d-flex">
{% if ultimo_articulo_opinion %}
{% for article in ultimo_articulo_opinion %}
<div class="card w-100 h-100 secondary-article">
<a class="h-100" href="{{ article.link }}">
<img src="{{ article.thumbnail.src('medium') }}"
alt="{{ article.thumbnail.alt }}"
class="card-img h-100 object-fit-cover"/>
<div class="card-img-overlay d-flex flex-column justify-content-end align-items-start">
<div>
<!-- Título -->
<p class="card-title text-wrap fs-6">
<a href="{{ article.link }}" class="text-white text-decoration-none">{{ article.title }}</a>
</p>
<!-- Icono + autor -->
<p class="text-white mb-0 fs-7 d-flex align-items-center">
<i class="bi bi-person me-1"></i>
{{ article.author }}
</p>
</div>
</div>
</a>
</div>
{% endfor %}
{% else %}
<p class="text-muted">No hay artículos de opinión disponibles.</p>
{% endif %}
</div>
</div>
</div>
</div>
</section>
</section>

View File

@ -16,6 +16,7 @@
<!-- Right side: RRSS -->
<div class="col d-flex justify-content-end">
{% include "partials/btn-search.twig" with {'items': menu.get_items} %}
<div class="btn-group m-1" role="group" aria-label="First group">
{% for red in redes_sociales %}
<a href="{{ red.url }}" class="btn btn-outline-dark btn-sm pt-0" target="_blank" rel="noopener noreferrer">

View File

@ -1,5 +1,6 @@
{% extends 'layouts/base.twig' %}
{% block content %}
<div class="page-portada">
{# Sección noticias #}
{% if recent_posts_noticias %}
@ -25,7 +26,7 @@
<div class="col-md-4">
<div class="d-flex flex-column h-100 justify-content-between">
{% for article in recent_posts_noticias[1:3] %}
<div class="card secondary-article">
<div class="card secondary-article {% if loop.first %}media-mb{% endif %}">
<a href="{{ article.link }}">
<img src="{{ article.thumbnail.src('medium') }}"
alt="{{ article.thumbnail.alt }}"
@ -48,6 +49,8 @@
{# Sección Logos #}
{% if botones_imagen %}
<section class="custom-buttons-section my-5">
<p class="mb-4 position-relative fs-4 fw-bold sp-module-title">ENLACES</p>
<div class="row g-3">
{% for boton in botones_imagen %}
<div class="col-md-3 col-sm-6">
@ -66,9 +69,57 @@
{% include 'partials/section-videos.twig' %}
{# Sección Campañas / conlfictos #}
<h2> Sección Campañas / conflictos</h2>
<section class="recent-posts py-4">
<div class="container">
<div class="row align-items-stretch">
{% if posts_campana %}
<div class="col-6">
<p class="mb-4 position-relative fs-4 fw-bold sp-module-title">CAMPAÑAS</p>
{% set main_article = posts_campana[0] %}
<div class="card main-article">
<a href="{{ main_article.link }}">
<img src="{{ main_article.thumbnail.src('medium') }}"
alt="{{ main_article.thumbnail.alt }}"
class="card-img card-img-fixed" />
<div class="card-img-overlay">
<h3 class="card-title text-wrap">
<a href="{{ main_article.link }}">{{ main_article.title }}</a>
</h3>
</div>
</div>
</div>
{% else %}
<h2>no hay artículos</h2>
{% endif %}
{% if posts_campana %}
<div class="col-6">
<p class="mb-4 position-relative fs-4 fw-bold sp-module-title">CONFLICTOS LABORALES</p>
{% set main_article = posts_campana[0] %}
<div class="card main-article">
<a href="{{ main_article.link }}">
<img src="{{ main_article.thumbnail.src('medium') }}"
alt="{{ main_article.thumbnail.alt }}"
class="card-img card-img-fixed" />
<div class="card-img-overlay">
<h3 class="card-title text-wrap">
<a href="{{ main_article.link }}">{{ main_article.title }}</a>
</h3>
</div>
</div>
</div>
{% else %}
<h2>no hay artículos</h2>
{% endif %}
</div>
</div>
</section>
</div>
{% endblock %}