Skip to content

Encode lastmod dates in engine_files #184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions src/common/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export interface ParchmentOptions extends Omit<GlkOteOptions, 'accept'> {
theme_cookie: string,
/** Whether to test the AsyncGlk GlkApi library */
use_asyncglk?: TruthyOption,
engine_files?: {[key: string]: string}

// Modules to pass to other modules

Expand Down
1 change: 1 addition & 0 deletions src/iplayif.com/app/src/front-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export default class FrontPage {

const options: SingleFileOptions = {
domain: `http${this.options.https ? 's' : ''}://${this.options.domain}`,
cdn_domain: this.options.cdn_domain,
story: {
author: data.author,
cover: !!data.cover,
Expand Down
10 changes: 10 additions & 0 deletions src/tools/index-processing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {escape, truncate} from 'lodash-es'
import type {TruthyOption} from '../upstream/asyncglk/src/index-common.js'
import {Uint8Array_to_base64} from '../common/file.js'
import type {FileSize, ParchmentOptions} from '../common/interface.js'
import {find_format} from '../common/formats.js'

// Is ASCII really okay here?
const utf8decoder = new TextDecoder('ascii', {fatal: true})
Expand All @@ -36,6 +37,7 @@ export interface Story {
export interface SingleFileOptions {
date?: TruthyOption
domain?: string
cdn_domain?: string
font?: TruthyOption
gzip?: TruthyOption
single_file?: TruthyOption
Expand Down Expand Up @@ -99,6 +101,14 @@ export async function process_index_html(options: SingleFileOptions, files: Map<
}
if (story.format) {
parchment_options.story.format = story.format
const {engines} = find_format(story.format)
if (engines) {
parchment_options.engine_files = Object.fromEntries(await Promise.all(engines[0].load.map(async (path) => {
const response = await fetch(`https://${options.cdn_domain}/dist/web/${path}`, {method: 'head'})
const last_modified = response.headers.get('last-modified') ?? ''
return [path, Math.floor(new Date(last_modified).getTime()/1000)]
})))
}
}
}

Expand Down
Loading