Skip to content

Commit 6a0e2c3

Browse files
authored
Merge pull request #3527 from codeeu/feature/ddp-training-resource
Feature/ddp training resource
2 parents 78ae490 + 9b142cd commit 6a0e2c3

6 files changed

Lines changed: 70 additions & 6 deletions

File tree

app/Nova/TrainingResource.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ public function fields(Request $request): array
153153
->nullable()
154154
->help('Optional scroll offset in pixels for in-page anchor links (useful with sticky headers).'),
155155

156+
Text::make('Roadmap PDF embed URL', 'roadmap_pdf_embed_url')
157+
->nullable()
158+
->rules('nullable', 'url')
159+
->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).'),
160+
156161
Text::make('Button text', 'button_text')->nullable(),
157162

158163
Text::make('Button URL', 'button_url')

app/TrainingResource.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class TrainingResource extends Model
3434
'register_box_section',
3535
'about_box_section',
3636
'anchor_offset',
37+
'roadmap_pdf_embed_url',
3738
'button_text',
3839
'button_url',
3940
'secondary_button_text',
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::table('training_resources', function (Blueprint $table) {
15+
$table->string('roadmap_pdf_embed_url')->nullable()->after('anchor_offset');
16+
});
17+
}
18+
19+
/**
20+
* Reverse the migrations.
21+
*/
22+
public function down(): void
23+
{
24+
Schema::table('training_resources', function (Blueprint $table) {
25+
$table->dropColumn('roadmap_pdf_embed_url');
26+
});
27+
}
28+
};

database/seeders/TrainingResourceDiscoverDigitalProgrammeSeeder.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ public function run(): void
1717
[
1818
'card_title' => 'Discover Digital Programme',
1919
'card_author' => 'Code4Europe | Deliverable D4.2 | Public toolkit',
20-
// Temporary thumbnail until final artwork is provided.
21-
'card_image' => '/images/banner_training.svg',
20+
'card_image' => 'https://codeweek-resources.s3.eu-west-1.amazonaws.com/+discover-digital-toolkit/DDP_thumbnail.png',
2221
'page_title' => 'Discover Digital Programme',
2322
'hero_author' => 'Code4Europe | Deliverable D4.2 | Public toolkit',
2423
'hero_button_text' => 'Open the complete toolkit',
@@ -38,10 +37,10 @@ public function run(): void
3837
<li>Plan evaluation and feedback to measure outcomes.</li>
3938
<li>Use digital outreach and communication to build awareness and follow-up.</li>
4039
</ol>
41-
<div style="margin-top:2.25rem;max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;">
40+
<div style="margin-top:2.25rem;max-width:100%;">
4241
<h2>Roadmap</h2>
4342
<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>
44-
<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;" />
43+
[[embed_roadmap_pdf]]
4544
</div>
4645
HTML,
4746
'body_image' => null,
@@ -91,6 +90,7 @@ public function run(): void
9190
</ul>
9291
HTML,
9392
'anchor_offset' => 120,
93+
'roadmap_pdf_embed_url' => 'https://codeweek-resources.s3.eu-west-1.amazonaws.com/+discover-digital-toolkit/DDP_toolkit_roadmap.pdf',
9494
'third_button_text' => 'Register an activity',
9595
'third_button_url' => 'https://codeweek.eu/add?skip=1',
9696
'meta_title' => 'Discover Digital Programme - Toolkit',
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@props([
2+
'url',
3+
])
4+
<div class="w-full max-w-full my-6 rounded-xl overflow-hidden border border-slate-200 bg-slate-100 shadow-sm">
5+
<iframe
6+
title="{{ __('Roadmap (PDF)') }}"
7+
src="{{ $url }}"
8+
class="w-full border-0 block"
9+
style="height: min(75vh, 880px); min-height: 480px;"
10+
loading="lazy"
11+
></iframe>
12+
</div>
13+
<p class="text-sm mt-2 mb-0 text-[#333E48]">
14+
<a href="{{ $url }}" target="_blank" rel="noopener noreferrer" class="text-dark-blue underline font-medium">
15+
{{ __('Open roadmap PDF in a new tab') }}
16+
</a>
17+
{{ __('if the preview does not load in your browser.') }}
18+
</p>

resources/views/training/show.blade.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@
2323
2424
return \Illuminate\Support\Str::startsWith($url, ['http://', 'https://', '//']);
2525
};
26+
27+
$renderedContent = $trainingResource->content ?? '';
28+
$roadmapEmbedUrl = trim((string) ($trainingResource->roadmap_pdf_embed_url ?? ''));
29+
if ($roadmapEmbedUrl !== '' && str_contains($renderedContent, '[[embed_roadmap_pdf]]')) {
30+
$renderedContent = str_replace(
31+
'[[embed_roadmap_pdf]]',
32+
view('training.partials.roadmap-pdf-embed', ['url' => $roadmapEmbedUrl])->render(),
33+
$renderedContent
34+
);
35+
} elseif (str_contains($renderedContent, '[[embed_roadmap_pdf]]')) {
36+
$renderedContent = str_replace('[[embed_roadmap_pdf]]', '', $renderedContent);
37+
}
2638
@endphp
2739

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

90-
@if(!empty($trainingResource->content))
102+
@if(!empty($renderedContent))
91103
<div class="{{ $contentClass }}">
92-
{!! $trainingResource->content !!}
104+
{!! $renderedContent !!}
93105
</div>
94106
@endif
95107

0 commit comments

Comments
 (0)