Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0cfd54e
Give `addWebcShortcode` a default value for `attributeNames` argument
anderspollack Dec 19, 2023
9594b22
Upgrade `is-land` to 3.0.2
anderspollack Dec 19, 2023
5fb7ea2
Copy `is-land` module into client package
anderspollack Dec 19, 2023
06d0e07
Add support for `formats: false`
anderspollack Dec 19, 2023
8d981a9
Implement basic `on:visible` lazy asset loading
anderspollack Dec 19, 2023
b406ee5
Give `caption.js` `caption` and `credit` args a default value of `''`
anderspollack Jan 4, 2024
d652886
Fix passthrough copy paths in `.eleventy.js`
anderspollack Jan 4, 2024
958bd0a
Reimplement static inline figures in `quire-figure.webc`
anderspollack Jan 19, 2024
cde0da4
Implement conditional rendering for canvas images (static/annotations)
anderspollack Jan 19, 2024
63fc12e
Update figure table
anderspollack Jan 19, 2024
aa5e32f
Add annotations UI back to inline canvas figures
anderspollack Jan 19, 2024
777112b
Wrap images in modal link
anderspollack Jan 19, 2024
8c71efd
await media element component call
anderspollack Jan 19, 2024
9692f08
Fix Vite CLI error
anderspollack Jan 26, 2024
6230a0f
Fix errors relating to missing `src` in `getSrc` method
anderspollack Jan 26, 2024
f584af5
Add missing `id` arg to `attributes` fn in `figure-image.webc`
anderspollack Jan 30, 2024
a111e84
Ensure `<figcaption>` is not wrapped in empty `<p> </p>` tags
anderspollack Jan 30, 2024
7883bc5
Render video source URL in print output only
anderspollack Jan 30, 2024
4800892
Exclude `is-land.js` from vite
anderspollack Jan 30, 2024
a953f68
Properly import `is-land`
anderspollack Jan 30, 2024
54fbeb7
Update `figureGroup` to apply grid column classnames to row instead o…
anderspollack Jan 30, 2024
63a71af
Don't write figure data JSON to page until circular reference bug wit…
anderspollack Jan 30, 2024
cf1417f
Fix things
anderspollack Jan 30, 2024
f741c26
Fix broken build by adding back passthrough copy of `is-land` module
anderspollack Jan 31, 2024
df64568
Move closing figure tag to next line
mphstudios Mar 25, 2024
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
7 changes: 6 additions & 1 deletion packages/11ty/.eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,12 @@ module.exports = function(eleventyConfig) {
*/
if (process.env.ELEVENTY_ENV === 'production') eleventyConfig.addPassthroughCopy(publicDir)
eleventyConfig.addPassthroughCopy(`${inputDir}/_assets`)
eleventyConfig.addPassthroughCopy({ '_includes/web-components': '_assets/javascript' })
eleventyConfig.addPassthroughCopy({ '_includes/web-components': '_assets/javascript/' })

/**
* Manually copy `is-land` module into client package
*/
eleventyConfig.addPassthroughCopy({ 'node_modules/@11ty/is-land/is-land.js': '_assets/javascript/is-land.js' })

/**
* Watch the following additional files for changes and rerun server
Expand Down
24 changes: 13 additions & 11 deletions packages/11ty/_components/figure-image.webc
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
Nota bene: `webc:is` does not support dynamic values (see 11ty/webc#143);
use webc conditional statements and call the `attributes` function multiple times rather than using a fancier pattern of implementation.
--->
<canvas-panel webc:if="isCanvas(id)" @attributes="attributes(id, image_dir).canvasPanel"></canvas-panel>
<image-service webc:elseif="isImageService(id)" @attributes="attributes(id, image_dir).imageService"></image-service>
<image-sequence webc:elseif="isSequence(id)" @attributes="attributes(id, image_dir).imageSequence"></image-sequence>
<image-tag webc:else @attributes="attributes(id, image_dir).imageTag"></image-tag>
<canvas-panel webc:if="isCanvas(id, is_static)" @attributes="attributes(id, image_dir, is_static, preset).canvasPanel"></canvas-panel>
<image-service webc:elseif="isImageService(id, is_static)" @attributes="attributes(id, image_dir, is_static, preset).imageService"></image-service>
<image-sequence webc:elseif="isSequence(id, is_static)" @attributes="attributes(id, image_dir, is_static, preset).imageSequence"></image-sequence>
<image-tag webc:else @attributes="attributes(id, image_dir, is_static, preset).imageTag"></image-tag>
</template>
<script webc:setup>
const attributes = (id, image_dir) => {
const attributes = (id, image_dir, is_static, preset_override) => {
const {
alt,
canvasId,
Expand All @@ -22,6 +22,7 @@ const attributes = (id, image_dir) => {
region,
src,
startCanvas,
staticInlineFigureImage,
textEnabled,
textSelectionEnabled,
virtualSizes,
Expand All @@ -34,7 +35,7 @@ const attributes = (id, image_dir) => {
height,
'iiif-content': iiifContent,
'manifest-id': manifestId,
preset,
preset: preset_override || preset,
region,
'virtual-sizes': virtualSizes,
width
Expand All @@ -43,7 +44,7 @@ const attributes = (id, image_dir) => {
id,
'manifest-id': manifestId,
margin,
preset,
preset: preset_override || preset,
'start-canvas': startCanvas,
'text-enabled': textEnabled,
'text-selection-enabled': textSelectionEnabled
Expand All @@ -54,12 +55,13 @@ const attributes = (id, image_dir) => {
imageTag: {
alt,
image_dir,
src
src: is_static && !src ? staticInlineFigureImage : src
}
}
}

const isCanvas = (id) => this.getFigure(id).isCanvas
const isImageService = (id) => this.getFigure(id).isImageService
const isSequence = (id) => this.getFigure(id).isSequence
const shouldRenderCanvas = (id, is_static) => this.getFigure(id).annotations || !is_static
const isCanvas = (id, is_static) => shouldRenderCanvas(id, is_static) && this.getFigure(id).isCanvas
const isImageService = (id, is_static) => shouldRenderCanvas(id, is_static) && this.getFigure(id).isImageService
const isSequence = (id, is_static) => shouldRenderCanvas(id, is_static) && this.getFigure(id).isSequence
</script>
2 changes: 1 addition & 1 deletion packages/11ty/_components/image-tag.webc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<img :alt="alt" class="q-figure__image" :src="getSrc(src, image_dir)" />
<script webc:setup>
const getSrc = async (src, imageDir) => {
return src.startsWith('http') ? src : [imageDir, src].join('/')
return src.startsWith('http') || src.startsWith('/') ? src : [imageDir, src].join('/')
}
</script>
24 changes: 16 additions & 8 deletions packages/11ty/_components/quire-figure.webc
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
<figure :id="slugify(id)" :class="getClasses(classes, id)">
<template webc:nokeep @html="component(id, image_dir)"></template>
<template webc:nokeep @html="getCaption(id)"></template>
</figure>
<is-land on:visible>
<figure :id="slugify(id)" :class="getClasses(classes, id)">
<template webc:nokeep @html="component(id, image_dir, is_static, preset)"></template>
<template webc:nokeep @html="getAnnotations(id)"></template><template webc:nokeep @html="getCaption(id)"></template>
</figure>
</is-land>
<script webc:setup>
const component = async (id, imageDir) => {
const component = async (id, imageDir, isStatic, preset) => {
const figure = this.getFigure(id)
const { mediaType } = figure
const { figureAudio, figureImageWebc, figureTable, figureVideo } = this
const { figureAudio, figureImageWebc, figureModalLink, figureTable, figureVideo } = this
if (mediaType === 'image') {
return await figureImageWebc.call(this, id, imageDir)
const imageElement = await figureImageWebc.call(this, id, imageDir, isStatic, preset)
return figureModalLink({ content: imageElement, id })
}
const mediaTypeToComponentMap = {
soundcloud: figureAudio,
Expand All @@ -17,7 +20,12 @@ const component = async (id, imageDir) => {
vimeo: figureVideo,
youtube: figureVideo
}
return await mediaTypeToComponentMap[mediaType](figure)
const mediaElement = await mediaTypeToComponentMap[mediaType](figure)
return figureModalLink({ content: mediaElement, id })
}
const getAnnotations = (id) => {
const figure = this.getFigure(id)
return this.annotationsUI({ figure })
}

const getCaption = (id) => {
Expand Down
11 changes: 3 additions & 8 deletions packages/11ty/_includes/components/figure/caption.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,12 @@ const { oneLine } = require('~lib/common-tags')
module.exports = function(eleventyConfig) {
const markdownify = eleventyConfig.getFilter('markdownify')
const figureMediaEmbedUrl = eleventyConfig.getFilter('figureMediaEmbedUrl')
return function({ caption, credit, content='', mediaId, mediaType}) {
const { sourceUrl } = figureMediaEmbedUrl({ mediaId, mediaType })
const mediaSourceLink = sourceUrl
? `<span class="q-figure__caption-embed-link"><a href="${sourceUrl}"><em>${sourceUrl}</em></a></span>`
: ''
return function({ caption='', credit='', content='' }) {
return oneLine`
<figcaption class="q-figure__caption">
${mediaSourceLink}
${markdownify(content)}
<span class="q-figure__caption-content">${markdownify(caption || '')}</span>
<span class="q-figure__credit">${markdownify(credit || '')}</span>
<span class="q-figure__caption-content">${markdownify(caption)}</span>
<span class="q-figure__credit">${markdownify(credit)}</span>
</figcaption>
`
}
Expand Down
6 changes: 2 additions & 4 deletions packages/11ty/_includes/components/figure/table/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = function(eleventyConfig) {
const tableElement = eleventyConfig.getFilter('figureTableElement')
const markdownify = eleventyConfig.getFilter('markdownify')

return async function({ id, src }) {
return async function({ caption='', id, src }) {
const table = await tableElement({ src })
const title = markdownify(caption)

Expand All @@ -21,9 +21,7 @@ module.exports = function(eleventyConfig) {
class="q-figure__modal-link"
href="#${id}"
title="${title}"
>
${table}
</a>
>${table}</a>
`
}
}
8 changes: 8 additions & 0 deletions packages/11ty/_includes/components/figure/video/print.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,18 @@ const logger = chalkFactory('Figure Video')
*/
module.exports = function(eleventyConfig) {
const { imageDir } = eleventyConfig.globalData.config.figures
const figureMediaEmbedUrl = eleventyConfig.getFilter('figureMediaEmbedUrl')

return function({
aspect_ratio: aspectRatio,
mediaId,
mediaType,
poster=''
}) {
const { sourceUrl } = figureMediaEmbedUrl({ mediaId, mediaType })
const mediaSourceLink = sourceUrl
? `<span class="q-figure__caption-embed-link"><a href="${sourceUrl}"><em>${sourceUrl}</em></a></span>`
: ''
if (!poster) {
logger.warn(`Figure '${id}' does not have a 'poster' property. Print media will not render a fallback image for id: ${id}`)
}
Expand All @@ -30,6 +37,7 @@ module.exports = function(eleventyConfig) {
return html`
<div class="q-figure__media-wrapper--${ aspectRatio || 'widescreen' }">
<img src="${posterSrc}" />
${mediaSourceLink}
</div>
`
}
Expand Down
2 changes: 2 additions & 0 deletions packages/11ty/_includes/components/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ module.exports = function(eleventyConfig) {
<link rel="canonical" href="${canonicalURL}">
<link rel="version-history" href="${publication.repositoryUrl}">

<script type="module" src="/_assets/javascript/is-land.js"></script>

<script src="https://cdn.jsdelivr.net/npm/@digirati/canvas-panel-web-components@1.0.56" type="module"></script>
<script src="https://cdn.jsdelivr.net/npm/@iiif/vault-helpers@latest/dist/index.umd.js"></script>

Expand Down
9 changes: 8 additions & 1 deletion packages/11ty/_layouts/base.11ty.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ module.exports = async function(data) {
const id = this.slugify(url) || path.parse(inputPath).name
const pageId = `page-${id}`
const figures = pageData.page.figures
const figuresJSON = figures ? JSON.stringify(figures) : '{}'
/**
* This is currently throwing an error about circular references in figure data
* Removing until we need quire-data written to page
*
* TODO: add `quire-data` when refactoring lightbox and modal to use webc + is-land
*/
// const figuresJSON = figures ? JSON.stringify(figures) : '{}'
const figuresJSON = '{}';

return html`
<!doctype html>
Expand Down
2 changes: 1 addition & 1 deletion packages/11ty/_plugins/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ module.exports = function(eleventyConfig, collections, options) {
/**
* Note: WebC attribute names must be all lowercase or snake_case
*/
addWebcShortcode('figureImageWebc', 'figure-image', ['id', 'image_dir'])
addWebcShortcode('figureImageWebc', 'figure-image', ['id', 'image_dir', 'is_static', 'preset'])
}
2 changes: 1 addition & 1 deletion packages/11ty/_plugins/components/shortcodeFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = function(eleventyConfig, collections) {
* @param {String} tagName A template tag name for the component
* @param {String} webcElementName A webc component tag name
*/
addWebcShortcode: function(tagName, componentName, attributeNames) {
addWebcShortcode: function(tagName, componentName, attributeNames=[]) {
eleventyConfig.addShortcode(tagName, async function(...args) {
const renderTemplate = eleventyConfig.getFilter('renderTemplate')
const renderedAttributes = attributeNames.map((name, index) => `${name}="${args[index]}"`).join(' ')
Expand Down
2 changes: 1 addition & 1 deletion packages/11ty/_plugins/shortcodes/contributors.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = function (eleventyConfig) {

const formats = ['bio', 'initials', 'name', 'name-title', 'name-title-block', 'string']

if (!formats.includes(format)) {
if (format && !formats.includes(format)) {
logger.error(
`Unrecognized contributors shortcode format "${format}". Supported format values are: ${formats.join(', ')}`
)
Expand Down
8 changes: 7 additions & 1 deletion packages/11ty/_plugins/shortcodes/figure.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ module.exports = function (eleventyConfig) {
this.page.figures ||= []
this.page.figures.push(figure)

return await quireFigure.call(this, classes, id, imageDir)
/**
* Render static versions of IIIF images inline
*/
const isStatic = true
const preset = 'responsive'

return await quireFigure.call(this, classes, id, imageDir, isStatic, preset)
}
}
4 changes: 2 additions & 2 deletions packages/11ty/_plugins/shortcodes/figureGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module.exports = function (eleventyConfig, { page }) {
// logger.warn(`NoMediaType: One of the figures passed to the q-figures shortcode is missing the 'media_type' attribute. Figures in 'figures.yaml' must be have a 'media_type' attribute with a value of either "vimeo" or "youtube"`)
// }

const classes = ['column', 'q-figure--group__item', `quire-grid--${columns}`]
const classes = ['column', 'q-figure--group__item']
const rows = Math.ceil(ids.length / columns)
let figureTags = []
for (let i=0; i < rows; ++i) {
Expand All @@ -42,7 +42,7 @@ module.exports = function (eleventyConfig, { page }) {
for (let id of ids.slice(startIndex, columns + startIndex)) {
row += await figure(eleventyConfig, { page }).bind(this)(id, classes)
}
figureTags.push(`<div class="q-figure--group__row columns">${row}</div>`)
figureTags.push(`<div class="q-figure--group__row columns quire-grid--${columns}">${row}</div>`)
}

return oneLine`
Expand Down
2 changes: 1 addition & 1 deletion packages/11ty/_plugins/shortcodes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ module.exports = function(eleventyConfig, collections, options) {
/**
* Note: WebC attribute names must be all lowercase or snake_case
*/
addWebcShortcode('quireFigure', 'quire-figure', ['classes', 'id', 'image_dir'])
addWebcShortcode('quireFigure', 'quire-figure', ['classes', 'id', 'image_dir', 'is_static', 'preset'])
}
2 changes: 1 addition & 1 deletion packages/11ty/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/11ty/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"@11ty/eleventy-plugin-syntaxhighlight": "^4.2.0",
"@11ty/eleventy-plugin-vite": "^4.0.0",
"@11ty/eleventy-plugin-webc": "^0.11.1",
"@11ty/is-land": "^3.0.1",
"@11ty/is-land": "^3.0.2",
"@iiif/parser": "^1.1.2",
"@iiif/vault": "^0.9.22",
"ajv": "^8.12.0",
Expand Down