@@ -221,6 +221,7 @@ sub handle_example_dir {
221
221
$other_examples_html .= " </ul>" ;
222
222
223
223
my $category_description = get_category_description($category );
224
+ my $preview_image = get_example_thumbnail($project , $category , $example );
224
225
225
226
my $html = ' ' ;
226
227
open my $htmltemplate , ' <' , " $examples_dir /template.html" or die (" Couldn't open '$examples_dir /template.html': $! \n " );
@@ -232,6 +233,7 @@ sub handle_example_dir {
232
233
s /\@ javascript_file\@ / $jsfname / g ;
233
234
s /\@ htmlified_source_code\@ / $htmlified_source_code / g ;
234
235
s /\@ description\@ / $description / g ;
236
+ s /\@ preview_image\@ / $preview_image / g ;
235
237
s /\@ other_examples_html\@ / $other_examples_html / g ;
236
238
$html .= $_ ;
237
239
}
@@ -242,6 +244,20 @@ sub handle_example_dir {
242
244
close ($htmloutput );
243
245
}
244
246
247
+ sub get_example_thumbnail {
248
+ my $project = shift ;
249
+ my $category = shift ;
250
+ my $example = shift ;
251
+
252
+ if ( -f " $examples_dir /$category /$example /thumbnail.png" ) {
253
+ return " /$project /$category /$example /thumbnail.png" ;
254
+ } elsif ( -f " $examples_dir /$category /thumbnail.png" ) {
255
+ return " /$project /$category /thumbnail.png" ;
256
+ }
257
+
258
+ return " /$project /thumbnail.png" ;
259
+ }
260
+
245
261
sub generate_example_thumbnail {
246
262
my $project = shift ;
247
263
my $category = shift ;
@@ -250,20 +266,13 @@ sub generate_example_thumbnail {
250
266
my $example_no_num = " $example " ;
251
267
$example_no_num =~ s /\A\d +\- // ;
252
268
253
- my $example_image_url ;
254
- if ( -f " $examples_dir /$category /$example /thumbnail.png" ) {
255
- $example_image_url = " /$project /$category /$example /thumbnail.png" ;
256
- } elsif ( -f " $examples_dir /$category /thumbnail.png" ) {
257
- $example_image_url = " /$project /$category /thumbnail.png" ;
258
- } else {
259
- $example_image_url = " /$project /thumbnail.png" ;
260
- }
269
+ my $example_image_url = get_example_thumbnail($project , $category , $example );
261
270
262
271
my $example_mouseover_html = ' ' ;
263
272
if ( -f " $examples_dir /$category /$example /onmouseover.webp" ) {
264
- $example_mouseover_html = " onmouseover=\" this.src='/$project /$category /$example /onmouseover.webp'\" onmouseout=\" this.src='$example_image_url '\" ; " ;
273
+ $example_mouseover_html = " onmouseover=\" this.src='/$project /$category /$example /onmouseover.webp'\" onmouseout=\" this.src='$example_image_url '; \" " ;
265
274
} elsif ( -f " $examples_dir /$category /onmouseover.webp" ) {
266
- $example_mouseover_html = " onmouseover=\" this.src='/$project /$category /onmouseover.webp'\" onmouseout=\" this.src='$example_image_url '\" ; " ;
275
+ $example_mouseover_html = " onmouseover=\" this.src='/$project /$category /onmouseover.webp'\" onmouseout=\" this.src='$example_image_url '; \" " ;
267
276
}
268
277
269
278
return "
@@ -312,6 +321,10 @@ sub handle_category_dir {
312
321
do_copy(" $examples_dir /$category /onmouseover.webp" , " $dst /onmouseover.webp" ) if ( -f " $examples_dir /$category /onmouseover.webp" );
313
322
314
323
my $category_description = get_category_description($category );
324
+ my $preview_image = " /$project /thumbnail.png" ;
325
+ if ( -f " $examples_dir /$category /thumbnail.png" ) {
326
+ $preview_image = " /$project /$category /thumbnail.png" ;
327
+ }
315
328
316
329
# write category page
317
330
my $html = ' ' ;
@@ -321,6 +334,7 @@ sub handle_category_dir {
321
334
s /\@ category_name\@ / $category / g ;
322
335
s /\@ category_description\@ / $category_description / g ;
323
336
s /\@ examples_list_html\@ / $examples_list_html / g ;
337
+ s /\@ preview_image\@ / $preview_image / g ;
324
338
$html .= $_ ;
325
339
}
326
340
close ($htmltemplate );
@@ -379,12 +393,15 @@ sub handle_category_dir {
379
393
$homepage_list_html .= " </div>" ;
380
394
}
381
395
396
+ my $preview_image = " /$project /thumbnail.png" ;
397
+
382
398
my $dst = " $output_dir /" ;
383
399
my $html = ' ' ;
384
400
open my $htmltemplate , ' <' , " $examples_dir /template-homepage.html" or die (" Couldn't open '$examples_dir /template-category.html': $! \n " );
385
401
while (<$htmltemplate >) {
386
402
s /\@ project_name\@ / $project / g ;
387
403
s /\@ homepage_list_html\@ / $homepage_list_html / g ;
404
+ s /\@ preview_image\@ / $preview_image / g ;
388
405
$html .= $_ ;
389
406
}
390
407
close ($htmltemplate );
0 commit comments