mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Give the Cesium renderer the contract's credits port
The shared Cesium ports gain credits, on both the conformance renderer and the application's. list() reports what Cesium owes as plain data: its logo, its static credits and the last drawn frame's imagery, terrain and tile credits, read from the credit display through internals.js, with the credits the app adds listed as given where the display shows them. addStatic shows a credit through Cesium's display, as markup built from the plain data with every value escaped and only web links kept, so attribution stays on screen. change fires when the app adds or removes a credit, and after a drawn frame whose Cesium credits differ from the last one's. src/render/creditMarkup.js reads markup credits as plain data. The credits listener check moves out of renderer.listenerRules into its own check, so a renderer without every port can run it; it and the credits check now run on Cesium.
This commit is contained in:
1 parent
28b5de7196
commit
979e2213b9
13 files changed
+803
-15
No files matched your search
@@ -0,0 +1,55 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { creditFromMarkup } from './creditMarkup.js';
|
||||
|
||||
test('text, the first link and the first logo are read from markup', () => {
|
||||
assert.deepEqual(
|
||||
creditFromMarkup(
|
||||
'Map data <a href="https://www.openstreetmap.org/copyright" target="_blank">© OpenStreetMap</a> (<a href="https://opendatacommons.org/">ODbL</a>)',
|
||||
),
|
||||
{
|
||||
text: 'Map data © OpenStreetMap (ODbL)',
|
||||
href: 'https://www.openstreetmap.org/copyright',
|
||||
},
|
||||
);
|
||||
assert.deepEqual(
|
||||
creditFromMarkup(
|
||||
'<a href=\'https://cesium.com/\'><img src="/ion.png" title="Cesium ion"/></a>',
|
||||
),
|
||||
{ text: 'Cesium ion', href: 'https://cesium.com/', logoUrl: '/ion.png' },
|
||||
);
|
||||
assert.deepEqual(creditFromMarkup('<img src=x.png alt="Logo">'), {
|
||||
text: 'Logo',
|
||||
logoUrl: 'x.png',
|
||||
});
|
||||
});
|
||||
|
||||
test('character references decode; tags, comments and scripts drop', () => {
|
||||
assert.deepEqual(
|
||||
creditFromMarkup(
|
||||
' A &'B—&unknown; <!-- c --><script>x</script>\n <b>C</b>',
|
||||
),
|
||||
{ text: "A &'B—&unknown; C" },
|
||||
);
|
||||
assert.deepEqual(creditFromMarkup('<a data-href="no" href="yes">x</a>'), {
|
||||
text: 'x',
|
||||
href: 'yes',
|
||||
});
|
||||
assert.deepEqual(
|
||||
creditFromMarkup(
|
||||
'<a title="A > B" href="https://example.com/?q=>">Provider</a>',
|
||||
),
|
||||
{ text: 'Provider', href: 'https://example.com/?q=>' },
|
||||
);
|
||||
assert.deepEqual(
|
||||
creditFromMarkup(
|
||||
'<a href="javascript:alert(1)"><img src="javascript:x" alt="L"></a>',
|
||||
),
|
||||
{ text: 'L' },
|
||||
);
|
||||
assert.deepEqual(creditFromMarkup('<img src="data:text/html,x" alt="L">'), {
|
||||
text: 'L',
|
||||
});
|
||||
assert.deepEqual(creditFromMarkup(''), { text: '' });
|
||||
assert.deepEqual(creditFromMarkup(undefined), { text: '' });
|
||||
});
|
||||
Reference in new issue
Block a user