Skip to content

Commit 46cb195

Browse files
committed
Add a webArchive resource page block
Ships a theme-provided resource page block layout (Omeka S 4.2+) that renders the WebArchive module's ReplayWeb.page player. It outputs nothing when an item carries no capture, so it is safe to leave in the default block stack. Web-archive media are excluded from mediaEmbeds so the two blocks can never both mount a player over the same .wacz — that would mean two service-worker clients and twice the range traffic. Because resource_page_blocks in theme.ini is only a fallback (core prefers site-stored settings), established sites need the block added via Admin -> Themes -> Configure resource pages before captures render. Matches application/warc as well as application/wacz: the module plays both through the same viewer, so matching only wacz would silently drop a warc.
1 parent 85d97e1 commit 46cb195

6 files changed

Lines changed: 80 additions & 1 deletion

File tree

config/theme.ini

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,23 @@ resource_page_regions.item_sets.right = "Right sidebar"
294294
resource_page_regions.media.right = "Right sidebar"
295295

296296

297+
; Theme-provided block layouts (Omeka S 4.2+). Each needs a label, the resource
298+
; types it may be placed on, and the partial under
299+
; view/common/resource-page-block-layout/. Core wraps these in
300+
; ThemeProvidedResourcePageBlockLayout, which passes the partial only
301+
; ['resource' => $resource] — any other data must be derived in the template.
302+
;
303+
; webArchive renders the WebArchive module's ReplayWeb.page player and outputs
304+
; nothing on items without a capture, so it is safe to leave in the default
305+
; stack. Web-archive media are excluded from mediaEmbeds to keep the two blocks
306+
; from mounting duplicate players; see web-archive.phtml.
307+
resource_page_block_layouts.webArchive.label = "Web archive"
308+
resource_page_block_layouts.webArchive.compatible_resource_names[] = "items"
309+
resource_page_block_layouts.webArchive.partial = "web-archive"
310+
311+
297312
resource_page_blocks.items.main[] = "mediaEmbeds"
313+
resource_page_blocks.items.main[] = "webArchive"
298314
resource_page_blocks.items.main[] = "values"
299315
resource_page_blocks.items.main[] = "itemSets"
300316
resource_page_blocks.items.main[] = "sitePages"

language/fr.mo

93 Bytes
Binary file not shown.

language/fr.po

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ msgstr "Tout"
4444
msgid "An error occurred while processing your request. Please try again later."
4545
msgstr "Une erreur s’est produite lors du traitement de votre demande. Veuillez réessayer plus tard."
4646

47+
#: view/common/resource-page-block-layout/web-archive.phtml:33
48+
msgid "Archived web page"
49+
msgid_plural "Archived web pages"
50+
msgstr[0] "Page web archivée"
51+
msgstr[1] "Pages web archivées"
52+
4753
#: view/common/banner.phtml:143
4854
msgid "Audiovisual minutes"
4955
msgstr "Minutes audiovisuelles"

language/template.pot

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ msgstr ""
4646
msgid "An error occurred while processing your request. Please try again later."
4747
msgstr ""
4848

49+
#: view/common/resource-page-block-layout/web-archive.phtml:33
50+
msgid "Archived web page"
51+
msgid_plural "Archived web pages"
52+
msgstr[0] ""
53+
msgstr[1] ""
54+
4955
#: view/common/banner.phtml:143
5056
msgid "Audiovisual minutes"
5157
msgstr ""

view/common/resource-page-block-layout/media-embeds.phtml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
<?php
2-
$resourceMedia = $resource->media();
32
$decoration = $this->themeSetting('image_decoration');
3+
4+
// Web-archive media are rendered by the dedicated `webArchive` block
5+
// (web-archive.phtml), not here. Without this exclusion an item with both
6+
// blocks enabled would mount two ReplayWeb.page players over the same .wacz —
7+
// two service-worker clients and twice the range traffic. Keep the type list in
8+
// sync with web-archive.phtml (both mirror WebArchive\Module::MEDIA_TYPES).
9+
$resourceMedia = [];
10+
foreach ($resource->media() as $media) {
11+
if (!in_array($media->mediaType(), ['application/wacz', 'application/warc'], true)) {
12+
$resourceMedia[] = $media;
13+
}
14+
}
415
?>
516
<?php if ($resourceMedia): ?>
617
<div class="media-embeds <?php echo is_array($decoration) && in_array('media', $decoration) ? 'decoration' : ''; ?>">
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/**
3+
* Web archive block — renders the WebArchive module's ReplayWeb.page player for
4+
* any web-archive media on this item.
5+
*
6+
* Renders nothing when the item carries no capture, so the block can sit in the
7+
* default stack without leaving an empty heading on every other item.
8+
*
9+
* Web-archive media are deliberately excluded from `media-embeds.phtml` so the
10+
* two blocks can never both mount a player: two ReplayWeb.page instances over
11+
* one .wacz means two service-worker clients and twice the range traffic. The
12+
* corollary is that a site which does not enable this block (Admin → Themes →
13+
* Configure resource pages) will not render captures at all.
14+
*
15+
* @var \Laminas\View\Renderer\PhpRenderer $this
16+
* @var \Omeka\Api\Representation\ItemRepresentation $resource
17+
*/
18+
19+
$archives = [];
20+
foreach ($resource->media() as $media) {
21+
// Mirrors WebArchive\Module::MEDIA_TYPES. The module plays both formats
22+
// through the same viewer, so matching only 'application/wacz' would
23+
// silently drop a .warc upload.
24+
if (in_array($media->mediaType(), ['application/wacz', 'application/warc'], true)) {
25+
$archives[] = $media;
26+
}
27+
}
28+
?>
29+
<?php if ($archives): ?>
30+
<div id="web-archive" class="web-archive">
31+
<div class="web-archive__header">
32+
<h3 class="web-archive__heading">
33+
<?php echo $this->translatePlural('Archived web page', 'Archived web pages', count($archives)); ?>
34+
</h3>
35+
</div>
36+
<?php foreach ($archives as $media): ?>
37+
<?php echo $media->render(); ?>
38+
<?php endforeach; ?>
39+
</div>
40+
<?php endif; ?>

0 commit comments

Comments
 (0)