Skip to content
Merged

Dev #3528

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/Nova/TrainingResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ public function fields(Request $request): array
->nullable()
->help('Optional scroll offset in pixels for in-page anchor links (useful with sticky headers).'),

Text::make('Roadmap PDF embed URL', 'roadmap_pdf_embed_url')
->nullable()
->rules('nullable', 'url')
->help('Optional HTTPS URL to a PDF shown inline in the Roadmap section. Put the literal text [[embed_roadmap_pdf]] in Content where the embed should appear (avoids Nova stripping iframes).'),

Text::make('Button text', 'button_text')->nullable(),

Text::make('Button URL', 'button_url')
Expand Down
1 change: 1 addition & 0 deletions app/TrainingResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class TrainingResource extends Model
'register_box_section',
'about_box_section',
'anchor_offset',
'roadmap_pdf_embed_url',
'button_text',
'button_url',
'secondary_button_text',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('training_resources', function (Blueprint $table) {
$table->string('roadmap_pdf_embed_url')->nullable()->after('anchor_offset');
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('training_resources', function (Blueprint $table) {
$table->dropColumn('roadmap_pdf_embed_url');
});
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ public function run(): void
[
'card_title' => 'Discover Digital Programme',
'card_author' => 'Code4Europe | Deliverable D4.2 | Public toolkit',
// Temporary thumbnail until final artwork is provided.
'card_image' => '/images/banner_training.svg',
'card_image' => 'https://codeweek-resources.s3.eu-west-1.amazonaws.com/+discover-digital-toolkit/DDP_thumbnail.png',
'page_title' => 'Discover Digital Programme',
'hero_author' => 'Code4Europe | Deliverable D4.2 | Public toolkit',
'hero_button_text' => 'Open the complete toolkit',
Expand All @@ -38,10 +37,10 @@ public function run(): void
<li>Plan evaluation and feedback to measure outcomes.</li>
<li>Use digital outreach and communication to build awareness and follow-up.</li>
</ol>
<div style="margin-top:2.25rem;max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;">
<div style="margin-top:2.25rem;max-width:100%;">
<h2>Roadmap</h2>
<p>Use this roadmap if you do not have time to read the full deliverable. The one-pagers mirror the toolkit flow and provide a practical checklist for implementation.</p>
<img src="https://codeweek-resources.s3.eu-west-1.amazonaws.com/+discover-digital-toolkit/DDP_toolkit_roadmap_small.svg" alt="Discover Digital Programme roadmap diagram" style="display:block;max-width:100%;width:auto;height:auto;margin:0 auto;" />
[[embed_roadmap_pdf]]
</div>
HTML,
'body_image' => null,
Expand Down Expand Up @@ -91,6 +90,7 @@ public function run(): void
</ul>
HTML,
'anchor_offset' => 120,
'roadmap_pdf_embed_url' => 'https://codeweek-resources.s3.eu-west-1.amazonaws.com/+discover-digital-toolkit/DDP_toolkit_roadmap.pdf',
'third_button_text' => 'Register an activity',
'third_button_url' => 'https://codeweek.eu/add?skip=1',
'meta_title' => 'Discover Digital Programme - Toolkit',
Expand Down
18 changes: 18 additions & 0 deletions resources/views/training/partials/roadmap-pdf-embed.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@props([
'url',
])
<div class="w-full max-w-full my-6 rounded-xl overflow-hidden border border-slate-200 bg-slate-100 shadow-sm">
<iframe
title="{{ __('Roadmap (PDF)') }}"
src="{{ $url }}"
class="w-full border-0 block"
style="height: min(75vh, 880px); min-height: 480px;"
loading="lazy"
></iframe>
</div>
<p class="text-sm mt-2 mb-0 text-[#333E48]">
<a href="{{ $url }}" target="_blank" rel="noopener noreferrer" class="text-dark-blue underline font-medium">
{{ __('Open roadmap PDF in a new tab') }}
</a>
— {{ __('if the preview does not load in your browser.') }}
</p>
16 changes: 14 additions & 2 deletions resources/views/training/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@

return \Illuminate\Support\Str::startsWith($url, ['http://', 'https://', '//']);
};

$renderedContent = $trainingResource->content ?? '';
$roadmapEmbedUrl = trim((string) ($trainingResource->roadmap_pdf_embed_url ?? ''));
if ($roadmapEmbedUrl !== '' && str_contains($renderedContent, '[[embed_roadmap_pdf]]')) {
$renderedContent = str_replace(
'[[embed_roadmap_pdf]]',
view('training.partials.roadmap-pdf-embed', ['url' => $roadmapEmbedUrl])->render(),
$renderedContent
);
} elseif (str_contains($renderedContent, '[[embed_roadmap_pdf]]')) {
$renderedContent = str_replace('[[embed_roadmap_pdf]]', '', $renderedContent);
}
@endphp

@section('title', $pageTitle)
Expand Down Expand Up @@ -87,9 +99,9 @@ class="mb-12 w-full h-full max-h-[630px] object-contain"
/>
@endif

@if(!empty($trainingResource->content))
@if(!empty($renderedContent))
<div class="{{ $contentClass }}">
{!! $trainingResource->content !!}
{!! $renderedContent !!}
</div>
@endif

Expand Down
Loading