mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 18:10:06 -05:00
The minimal server-rendered GIF-slideshow document preview (added this week to cut dependency weight) kept failing with a bare 415 - its own rasterization dependency chain (pdf-to-img -> pdfjs-dist's optional @napi-rs/canvas) needed three separate fixes in a single day for a missing package, a worker path resolved into the wrong bundle directory, and a stale stored filename, and still left a text-only fallback as the best case for a PDF. Restore the previous full-featured viewer instead: office-open-xml-viewer (MIT, canvas-based, zero runtime dependencies) renders DOCX/XLSX/PPTX client-side, and PDF goes back to the browser's own native <embed> viewer - simpler, zero extra dependencies, and gets the browser's own zoom/search/ print for free. The server-side full-text search this week's change introduced is kept: server/lib/documentGif.js now does nothing but extract plain text for the search index (indexDocumentText, triggered in the background from Attachments.onAfterUpload) - no rendering, no HTML, no page images - so pdf-to-img and @napi-rs/canvas are dropped entirely (nothing rasterizes a PDF page server-side any more) while pdfjs-dist stays, now as a direct dependency, for its text-only extraction. Searching attachment contents from the card search box keeps working exactly as before. Thanks to xet7 !
35 lines
1.7 KiB
JavaScript
35 lines
1.7 KiB
JavaScript
'use strict';
|
|
|
|
const test = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
const root = path.join(__dirname, '..');
|
|
const read = file => fs.readFileSync(path.join(root, file), 'utf8');
|
|
|
|
test('page startup uses the standard Meteor browser interface', () => {
|
|
assert.match(read('server/imports.js'), /import '\/server\/modernBrowsers'/);
|
|
assert.match(read('config/router.js'), /FlowRouter\.route/);
|
|
assert.doesNotMatch(read('server/imports.js'), /legacyHtml4|legacyOmi/);
|
|
assert.doesNotMatch(read('server/routes/universalFileServer.js'), /\/legacy-html4\//);
|
|
for (const file of ['server/legacyHtml4.js', 'imports/lib/legacyHtml4.js',
|
|
'public/legacy-html4.css', 'server/lib/legacyHtml4Session.js']) {
|
|
assert.equal(fs.existsSync(path.join(root, file)), false, file);
|
|
}
|
|
});
|
|
|
|
test('retained image features use the independent GIF utilities', () => {
|
|
// server/lib/documentGif.js still uses the shared GIF utilities to build the
|
|
// search index (bounded reads, cache keys) even though document PREVIEW is
|
|
// now the restored office-open-xml-viewer / native <embed>, not a GIF
|
|
// slideshow - so universalFileServer.js no longer needs imageGif itself.
|
|
assert.match(read('server/lib/documentGif.js'), /[/.]imageGif'/);
|
|
for (const file of ['server/lib/documentGif.js',
|
|
'server/routes/universalFileServer.js']) {
|
|
assert.doesNotMatch(read(file), /legacyHtml4Gif|omiGifCacheKey/);
|
|
}
|
|
assert.doesNotMatch(read('server/imports.js'), /import '\/server\/brandingImages'/);
|
|
assert.equal(fs.existsSync(path.join(root, 'server/brandingImages.js')), false);
|
|
assert.match(read('server/routes/universalFileServer.js'), /export async function indexAttachmentDocumentText/);
|
|
});
|