Skip to content

Commit fe279c7

Browse files
committed
Encode lastmod dates in engine_files
Apropos #177
1 parent ed192dd commit fe279c7

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

src/common/interface.ts

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export interface ParchmentOptions extends Omit<GlkOteOptions, 'accept'> {
5151
theme_cookie: string,
5252
/** Whether to test the AsyncGlk GlkApi library */
5353
use_asyncglk?: TruthyOption,
54+
engine_files?: {[key: string]: string}
5455

5556
// Modules to pass to other modules
5657

src/iplayif.com/app/src/front-page.ts

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export default class FrontPage {
5454

5555
const options: SingleFileOptions = {
5656
domain: `http${this.options.https ? 's' : ''}://${this.options.domain}`,
57+
cdn_domain: this.options.cdn_domain,
5758
story: {
5859
author: data.author,
5960
cover: !!data.cover,

src/tools/index-processing.ts

+10
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {escape, truncate} from 'lodash-es'
1616
import type {TruthyOption} from '../upstream/asyncglk/src/index-common.js'
1717
import {Uint8Array_to_base64} from '../common/file.js'
1818
import type {FileSize, ParchmentOptions} from '../common/interface.js'
19+
import {find_format} from '../common/formats.js'
1920

2021
// Is ASCII really okay here?
2122
const utf8decoder = new TextDecoder('ascii', {fatal: true})
@@ -36,6 +37,7 @@ export interface Story {
3637
export interface SingleFileOptions {
3738
date?: TruthyOption
3839
domain?: string
40+
cdn_domain?: string
3941
font?: TruthyOption
4042
gzip?: TruthyOption
4143
single_file?: TruthyOption
@@ -99,6 +101,14 @@ export async function process_index_html(options: SingleFileOptions, files: Map<
99101
}
100102
if (story.format) {
101103
parchment_options.story.format = story.format
104+
const {engines} = find_format(story.format)
105+
if (engines) {
106+
parchment_options.engine_files = Object.fromEntries(await Promise.all(engines[0].load.map(async (path) => {
107+
const response = await fetch(`https://${options.cdn_domain}/dist/web/${path}`, {method: 'head'})
108+
const last_modified = response.headers.get('last-modified') ?? ''
109+
return [path, Math.floor(new Date(last_modified).getTime()/1000)]
110+
})))
111+
}
102112
}
103113
}
104114

0 commit comments

Comments
 (0)