Public
Edited
Jan 5, 2024
1 fork
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
get_date = ({ article, project = "en.wikipedia.org" }) => {
const query =
`SELECT ?item ?itemLabel ?date
WHERE {
SERVICE wikibase:mwapi {
bd:serviceParam wikibase:endpoint "` +
project +
`";
wikibase:api "Generator";
mwapi:generator "links";
mwapi:titles "` +
article +
`";.
?item wikibase:apiOutputItem mwapi:item.
}
FILTER BOUND (?item)
?item wdt:P585 ?date .
?item rdfs:label ?itemLabel filter (lang(?itemLabel) = "en") .
}
ORDER BY DESC(?date)`;

return fetch(
`https://query.wikidata.org/sparql?query=${encodeURIComponent(query)}`,
{ headers: { accept: "application/sparql-results+json" } }
)
.then((response) => response.json())
.then((d) =>
d.results.bindings.map((res) => ({
item: res.item.value,
itemLabel: res.itemLabel.value,
date: d3.utcParse("%Y-%m-%dT%H:%M:%SZ")(res.date.value)
}))
);
}
Insert cell
Insert cell
get_default = () => {
const params = new URL(document.URL).searchParams;
const defaults = {
article: "Ethiopia",
wikipedia: "en.wikipedia.org"
};
if (params.has("article")) {
defaults.article = params.get("article");
}
if (params.has("wikipedia")) {
defaults.wikipedia = params.get("wikipedia");
}
return defaults;
}
Insert cell
Insert cell
import { SearchForm } from "@floatingpurr/input-autocomplete"
Insert cell
import {wikipedias} from "@pac02/user-level-gender-statistics-for-wikipedia"
Insert cell
import { wikilink } from "@pac02/explore-gender-diversity-in-a-single-wikipedia-article"
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more