Name the Local area, say what each News section needs, and credit its sources

Local reads the area at the view centre (`/outline?at=`) and asks the feed
for its reports (`at`): the area is outlined faintly on the globe and named
at the top of the section ("News from Kazakhstan"; within 500 km at sea).
A disputed area is named as itself. A read that a newer look replaced, or
one left behind by a switch to Conflicts, is dropped, and a server without
the area route is asked once.

A section read from a key the server lacks says which key it needs
(503 `no_key`), that the key was refused (`key_rejected`) or that its
daily allowance is spent (`key_quota`); the other section keeps reading.
Liveuamap and World News API join the key registry.

Cards name the service a report came through ("via GDELT Project"), and
Liveuamap and Natural Earth are credited once their data shows. Economy is
a category of its own. Disputed-area labels are smaller and show the name
only; outlines keep up to 300 parts.
This commit is contained in:
Denis Groshev committed 2026-11-06 00:45:31 +01:00
1 parent fa736a7cd5
commit edb5837ae5
27 files changed
+1343 -154

No files matched your search

+9 -6
View File
@@ -5,12 +5,14 @@ import UiButton from '../kit/UiButton.vue';
// One event in the News panel: the publisher's
// picture when the event has one, the headline, a mono meta line (severity
// marker, category, place, sources, age), who reported it, and its
// attestation and media chips. A click chooses it (the layer flies there and
// opens its card on the globe); open, it plays the post's clip when it has
// one (on request, with sound and controls), and shows the summary, the other
// sides' reports and the link to the original article. The layer computes every
// value shown (feedCardView in src/layers/news/model.js).
// marker, category, place, sources, age), who reported it, its attestation
// and media chips, and the service it came through ("via …"), which some ask
// to be credited wherever their reports show. A click chooses it (the layer
// flies there and opens its card on the globe); open, it plays the post's
// clip when it has one (on request, with sound and controls), and shows the
// summary, the other sides' reports and the link to the original article.
// The layer computes every value shown (feedCardView in
// src/layers/news/model.js).
const props = defineProps({
item: { type: Object, required: true },
open: { type: Boolean, default: false },
@@ -108,6 +110,7 @@ const meta = () =>
>{{ chip.label }}</span
></span
>
<span v-if="item.via" class="news-card__via ui-mono">{{ item.via }}</span>
</button>
<div v-if="open" class="news-card__open">
<video
+32 -4
View File
@@ -11,9 +11,13 @@ import NewsCard from './NewsCard.vue';
// fewer where the host serves less), or a shorter one chosen at the
// top (24/12/6/3/1 h), and two sections. Conflicts: hotspot chips, the
// severity floor, the chosen event and a continuous feed, newest first.
// Local: every report near the view centre while the camera is low, which the
// map then shows instead of the hotspots' news. It renders the `feed` view the news
// layer publishes and acts only through `onParams`.
// Local: every report in the area at the view centre (its country, a large
// country's state; within a radius at sea) while the camera is low, named at
// the top, which the map then shows, outlined, instead of the hotspots' news.
// A section read from a key the server lacks (or whose allowance for the day
// is spent) says which key instead. It
// renders the `feed` view the news layer publishes and acts only through
// `onParams`.
const props = defineProps({
view: { type: Object, default: null },
onParams: { type: Function, default: () => {} },
@@ -75,6 +79,15 @@ const selectedApart = computed(() => {
: props.view.items.some((item) => item.id === chosen.id);
return listed ? null : chosen;
});
// What Local reads: the area named, else the radius; neither while the
// first area is being named, so the radius does not flash before it.
const areaHead = computed(() => {
const inView = props.view?.inView;
if (!inView?.active) return '';
if (inView.area) return t('News from {area}', { area: inView.area });
if (inView.areaLoading) return '';
return t('Within {km} km of the view centre', { km: inView.radiusKm });
});
const status = computed(() => {
const view = props.view;
if (!view) return '';
@@ -162,11 +175,20 @@ const clear = () => props.onParams({ clear: true });
class="news-readout__section"
:aria-label="t('Local')"
>
<p v-if="areaHead" class="news-readout__head news-readout__area ui-mono">
{{ areaHead }}
</p>
<UiEmpty
v-if="!view.inView.active"
class="news-readout__empty"
:title="t('Zoom in to see local news')"
/>
<UiEmpty
v-else-if="view.inView.key"
class="news-readout__empty"
:title="view.inView.key.title"
:hint="view.inView.key.hint"
/>
<p v-else-if="view.inView.error" class="news-readout__status">
{{ view.inView.error }}
</p>
@@ -202,8 +224,14 @@ const clear = () => props.onParams({ clear: true });
:aria-label="t('Latest news')"
>
<h3 class="news-readout__head ui-mono">{{ t('Latest') }}</h3>
<UiEmpty
v-if="view.key"
class="news-readout__empty"
:title="view.key.title"
:hint="view.key.hint"
/>
<ol
v-if="view.items.length"
v-else-if="view.items.length"
class="news-readout__list news-readout__feed"
>
<li v-for="item in view.items" :key="item.id">
+74
View File
@@ -250,6 +250,80 @@ test('filters, the Local section and empty or failed reads', () => {
news.destroy();
});
test('each section says which key it lacks; Local names the area it reads', () => {
const { news, panel } = fixture();
const key = {
title: 'Liveuamap key required',
hint: 'Needs LIVEUAMAP_API_KEY — add it in Provider Settings',
};
news.update(view({ key, items: [], hasMore: false }));
const latest = panel.querySelector('[aria-label="Latest news"]');
assert.match(latest.textContent, /Liveuamap key required/);
assert.match(latest.textContent, /Needs LIVEUAMAP_API_KEY/);
assert.doesNotMatch(latest.textContent, /No news matches/);
const localView = (inView) =>
view({
filters: normalizeFilters({ section: 'local' }),
inView: {
active: true,
loading: false,
error: null,
items: [],
radiusKm: 500,
...inView,
},
});
const section = () => panel.querySelector('[aria-label="Local"]');
const heading = () => section().querySelector('.news-readout__area');
news.update(
localView({
key: {
title: 'World News API limit reached for today',
hint: 'News resumes tomorrow, or with a paid plan',
},
}),
);
assert.match(section().textContent, /World News API limit reached for today/);
assert.match(section().textContent, /News resumes tomorrow/);
assert.doesNotMatch(section().textContent, /Nothing reported near here/);
// The area named, else the radius at sea.
news.update(localView({ area: 'Ukraine' }));
assert.equal(heading().textContent.trim(), 'News from Ukraine');
news.update(localView({ area: null }));
assert.equal(
heading().textContent.trim(),
'Within 500 km of the view centre',
);
// While the first area is named, neither: the radius does not flash.
news.update(localView({ area: null, areaLoading: true, loading: true }));
assert.equal(heading(), null);
// A new area on the way keeps the one shown.
news.update(localView({ area: 'Ukraine', areaLoading: true, loading: true }));
assert.equal(heading().textContent.trim(), 'News from Ukraine');
news.destroy();
});
test('a card credits the service its report came through', () => {
const { news, panel } = fixture();
news.update(
view({
items: [
feedCardView(report('gdelt', { attribution: 'GDELT Project' }), NOW),
feedCardView(report('own'), NOW),
],
}),
);
const [credited, own] = panel.querySelectorAll('.news-card');
assert.equal(
credited.querySelector('.news-card__via').textContent,
'via GDELT Project',
);
assert.equal(own.querySelector('.news-card__via'), null);
news.destroy();
});
test('scrolling to the end asks once per page, again after a filter change or a failed read', () => {
const { news, calls } = fixture();
const body = document.getElementById('news-panel-body');
+14
View File
@@ -116,6 +116,10 @@
letter-spacing: 0.12em;
text-transform: uppercase;
}
/* What Local reads, in the primary colour so it reads before the list. */
.news-readout__area {
color: var(--text-primary);
}
.news-readout__sections,
.news-readout__chips {
display: flex;
@@ -169,6 +173,11 @@
color: var(--text-dim);
font: 10px var(--font-mono);
}
/* A missing key's next step, under what it holds back. */
.news-readout__empty .ui-empty__hint {
display: block;
margin-top: 2px;
}
.news-readout__footer {
display: flex;
align-items: center;
@@ -306,6 +315,11 @@
fill: var(--news-color);
stroke: none;
}
/* The service a report came through: credited, and kept quiet. */
.news-card__via {
color: var(--text-dim);
font: 9px var(--font-mono);
}
.news-card__severity {
flex: none;
color: var(--news-color);