recentchanges

This commit is contained in:
Michael Murtaugh
2019-07-22 17:20:59 +02:00
parent 004d262004
commit 8896a0ed62
21 changed files with 1148 additions and 80 deletions

3
dist/index.js vendored
View File

@@ -28,6 +28,9 @@ function resize() {
// Match size of parent
svg.setAttribute("width", page.clientWidth);
svg.setAttribute("height", page.clientHeight);
// Checks if narrow device
if (x>600){ g.querySelector("#cats").classList.add("expanded")}
}
async function doload () {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 948 B

After

Width:  |  Height:  |  Size: 886 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 448 B

After

Width:  |  Height:  |  Size: 480 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 879 B

After

Width:  |  Height:  |  Size: 828 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 340 B

After

Width:  |  Height:  |  Size: 462 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -13,7 +13,7 @@
<svg id="svg"></svg>
<div id="cats">
<div class="body"></div>
<div class="placeholder">?</div>
<div class="placeholder"></div>
</div>
<div class="zoom-controls">
<div class="leaflet-control-zoom leaflet-bar leaflet-control">
@@ -26,8 +26,9 @@
</div>
<div id="specialselectdiv">
<select id="special">
<option value="">carte</option>
<option value="/m/special/recentfiles/recentfiles.html">nouveaux fichiers</option>
<option value="">Carte</option>
<option value="/m/special/recentfiles/">Nouveaux fichiers</option>
<option value="/m/special/recentchanges/">Modifications récentes</option>
</select>
</div>
<div id="specialiframediv"></div>

View File

@@ -0,0 +1,6 @@
all: dist/app.js
dist/app.js: src/*.js
# node_modules/.bin/rollup src/index.js --file dist/index.js --format iife
node_modules/.bin/rollup -c

View File

@@ -0,0 +1,915 @@
(function () {
'use strict';
var xhtml = "http://www.w3.org/1999/xhtml";
var namespaces = {
svg: "http://www.w3.org/2000/svg",
xhtml: xhtml,
xlink: "http://www.w3.org/1999/xlink",
xml: "http://www.w3.org/XML/1998/namespace",
xmlns: "http://www.w3.org/2000/xmlns/"
};
function namespace(name) {
var prefix = name += "", i = prefix.indexOf(":");
if (i >= 0 && (prefix = name.slice(0, i)) !== "xmlns") name = name.slice(i + 1);
return namespaces.hasOwnProperty(prefix) ? {space: namespaces[prefix], local: name} : name;
}
function creatorInherit(name) {
return function() {
var document = this.ownerDocument,
uri = this.namespaceURI;
return uri === xhtml && document.documentElement.namespaceURI === xhtml
? document.createElement(name)
: document.createElementNS(uri, name);
};
}
function creatorFixed(fullname) {
return function() {
return this.ownerDocument.createElementNS(fullname.space, fullname.local);
};
}
function creator(name) {
var fullname = namespace(name);
return (fullname.local
? creatorFixed
: creatorInherit)(fullname);
}
function none() {}
function selector(selector) {
return selector == null ? none : function() {
return this.querySelector(selector);
};
}
function selection_select(select) {
if (typeof select !== "function") select = selector(select);
for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) {
for (var group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node, subnode, i = 0; i < n; ++i) {
if ((node = group[i]) && (subnode = select.call(node, node.__data__, i, group))) {
if ("__data__" in node) subnode.__data__ = node.__data__;
subgroup[i] = subnode;
}
}
}
return new Selection(subgroups, this._parents);
}
function empty() {
return [];
}
function selectorAll(selector) {
return selector == null ? empty : function() {
return this.querySelectorAll(selector);
};
}
function selection_selectAll(select) {
if (typeof select !== "function") select = selectorAll(select);
for (var groups = this._groups, m = groups.length, subgroups = [], parents = [], j = 0; j < m; ++j) {
for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
if (node = group[i]) {
subgroups.push(select.call(node, node.__data__, i, group));
parents.push(node);
}
}
}
return new Selection(subgroups, parents);
}
function matcher(selector) {
return function() {
return this.matches(selector);
};
}
function selection_filter(match) {
if (typeof match !== "function") match = matcher(match);
for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) {
for (var group = groups[j], n = group.length, subgroup = subgroups[j] = [], node, i = 0; i < n; ++i) {
if ((node = group[i]) && match.call(node, node.__data__, i, group)) {
subgroup.push(node);
}
}
}
return new Selection(subgroups, this._parents);
}
function sparse(update) {
return new Array(update.length);
}
function selection_enter() {
return new Selection(this._enter || this._groups.map(sparse), this._parents);
}
function EnterNode(parent, datum) {
this.ownerDocument = parent.ownerDocument;
this.namespaceURI = parent.namespaceURI;
this._next = null;
this._parent = parent;
this.__data__ = datum;
}
EnterNode.prototype = {
constructor: EnterNode,
appendChild: function(child) { return this._parent.insertBefore(child, this._next); },
insertBefore: function(child, next) { return this._parent.insertBefore(child, next); },
querySelector: function(selector) { return this._parent.querySelector(selector); },
querySelectorAll: function(selector) { return this._parent.querySelectorAll(selector); }
};
function constant(x) {
return function() {
return x;
};
}
var keyPrefix = "$"; // Protect against keys like “__proto__”.
function bindIndex(parent, group, enter, update, exit, data) {
var i = 0,
node,
groupLength = group.length,
dataLength = data.length;
// Put any non-null nodes that fit into update.
// Put any null nodes into enter.
// Put any remaining data into enter.
for (; i < dataLength; ++i) {
if (node = group[i]) {
node.__data__ = data[i];
update[i] = node;
} else {
enter[i] = new EnterNode(parent, data[i]);
}
}
// Put any non-null nodes that dont fit into exit.
for (; i < groupLength; ++i) {
if (node = group[i]) {
exit[i] = node;
}
}
}
function bindKey(parent, group, enter, update, exit, data, key) {
var i,
node,
nodeByKeyValue = {},
groupLength = group.length,
dataLength = data.length,
keyValues = new Array(groupLength),
keyValue;
// Compute the key for each node.
// If multiple nodes have the same key, the duplicates are added to exit.
for (i = 0; i < groupLength; ++i) {
if (node = group[i]) {
keyValues[i] = keyValue = keyPrefix + key.call(node, node.__data__, i, group);
if (keyValue in nodeByKeyValue) {
exit[i] = node;
} else {
nodeByKeyValue[keyValue] = node;
}
}
}
// Compute the key for each datum.
// If there a node associated with this key, join and add it to update.
// If there is not (or the key is a duplicate), add it to enter.
for (i = 0; i < dataLength; ++i) {
keyValue = keyPrefix + key.call(parent, data[i], i, data);
if (node = nodeByKeyValue[keyValue]) {
update[i] = node;
node.__data__ = data[i];
nodeByKeyValue[keyValue] = null;
} else {
enter[i] = new EnterNode(parent, data[i]);
}
}
// Add any remaining nodes that were not bound to data to exit.
for (i = 0; i < groupLength; ++i) {
if ((node = group[i]) && (nodeByKeyValue[keyValues[i]] === node)) {
exit[i] = node;
}
}
}
function selection_data(value, key) {
if (!value) {
data = new Array(this.size()), j = -1;
this.each(function(d) { data[++j] = d; });
return data;
}
var bind = key ? bindKey : bindIndex,
parents = this._parents,
groups = this._groups;
if (typeof value !== "function") value = constant(value);
for (var m = groups.length, update = new Array(m), enter = new Array(m), exit = new Array(m), j = 0; j < m; ++j) {
var parent = parents[j],
group = groups[j],
groupLength = group.length,
data = value.call(parent, parent && parent.__data__, j, parents),
dataLength = data.length,
enterGroup = enter[j] = new Array(dataLength),
updateGroup = update[j] = new Array(dataLength),
exitGroup = exit[j] = new Array(groupLength);
bind(parent, group, enterGroup, updateGroup, exitGroup, data, key);
// Now connect the enter nodes to their following update node, such that
// appendChild can insert the materialized enter node before this node,
// rather than at the end of the parent node.
for (var i0 = 0, i1 = 0, previous, next; i0 < dataLength; ++i0) {
if (previous = enterGroup[i0]) {
if (i0 >= i1) i1 = i0 + 1;
while (!(next = updateGroup[i1]) && ++i1 < dataLength);
previous._next = next || null;
}
}
}
update = new Selection(update, parents);
update._enter = enter;
update._exit = exit;
return update;
}
function selection_exit() {
return new Selection(this._exit || this._groups.map(sparse), this._parents);
}
function selection_join(onenter, onupdate, onexit) {
var enter = this.enter(), update = this, exit = this.exit();
enter = typeof onenter === "function" ? onenter(enter) : enter.append(onenter + "");
if (onupdate != null) update = onupdate(update);
if (onexit == null) exit.remove(); else onexit(exit);
return enter && update ? enter.merge(update).order() : update;
}
function selection_merge(selection) {
for (var groups0 = this._groups, groups1 = selection._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m; ++j) {
for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge = merges[j] = new Array(n), node, i = 0; i < n; ++i) {
if (node = group0[i] || group1[i]) {
merge[i] = node;
}
}
}
for (; j < m0; ++j) {
merges[j] = groups0[j];
}
return new Selection(merges, this._parents);
}
function selection_order() {
for (var groups = this._groups, j = -1, m = groups.length; ++j < m;) {
for (var group = groups[j], i = group.length - 1, next = group[i], node; --i >= 0;) {
if (node = group[i]) {
if (next && node.compareDocumentPosition(next) ^ 4) next.parentNode.insertBefore(node, next);
next = node;
}
}
}
return this;
}
function selection_sort(compare) {
if (!compare) compare = ascending;
function compareNode(a, b) {
return a && b ? compare(a.__data__, b.__data__) : !a - !b;
}
for (var groups = this._groups, m = groups.length, sortgroups = new Array(m), j = 0; j < m; ++j) {
for (var group = groups[j], n = group.length, sortgroup = sortgroups[j] = new Array(n), node, i = 0; i < n; ++i) {
if (node = group[i]) {
sortgroup[i] = node;
}
}
sortgroup.sort(compareNode);
}
return new Selection(sortgroups, this._parents).order();
}
function ascending(a, b) {
return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
}
function selection_call() {
var callback = arguments[0];
arguments[0] = this;
callback.apply(null, arguments);
return this;
}
function selection_nodes() {
var nodes = new Array(this.size()), i = -1;
this.each(function() { nodes[++i] = this; });
return nodes;
}
function selection_node() {
for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) {
for (var group = groups[j], i = 0, n = group.length; i < n; ++i) {
var node = group[i];
if (node) return node;
}
}
return null;
}
function selection_size() {
var size = 0;
this.each(function() { ++size; });
return size;
}
function selection_empty() {
return !this.node();
}
function selection_each(callback) {
for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) {
for (var group = groups[j], i = 0, n = group.length, node; i < n; ++i) {
if (node = group[i]) callback.call(node, node.__data__, i, group);
}
}
return this;
}
function attrRemove(name) {
return function() {
this.removeAttribute(name);
};
}
function attrRemoveNS(fullname) {
return function() {
this.removeAttributeNS(fullname.space, fullname.local);
};
}
function attrConstant(name, value) {
return function() {
this.setAttribute(name, value);
};
}
function attrConstantNS(fullname, value) {
return function() {
this.setAttributeNS(fullname.space, fullname.local, value);
};
}
function attrFunction(name, value) {
return function() {
var v = value.apply(this, arguments);
if (v == null) this.removeAttribute(name);
else this.setAttribute(name, v);
};
}
function attrFunctionNS(fullname, value) {
return function() {
var v = value.apply(this, arguments);
if (v == null) this.removeAttributeNS(fullname.space, fullname.local);
else this.setAttributeNS(fullname.space, fullname.local, v);
};
}
function selection_attr(name, value) {
var fullname = namespace(name);
if (arguments.length < 2) {
var node = this.node();
return fullname.local
? node.getAttributeNS(fullname.space, fullname.local)
: node.getAttribute(fullname);
}
return this.each((value == null
? (fullname.local ? attrRemoveNS : attrRemove) : (typeof value === "function"
? (fullname.local ? attrFunctionNS : attrFunction)
: (fullname.local ? attrConstantNS : attrConstant)))(fullname, value));
}
function defaultView(node) {
return (node.ownerDocument && node.ownerDocument.defaultView) // node is a Node
|| (node.document && node) // node is a Window
|| node.defaultView; // node is a Document
}
function styleRemove(name) {
return function() {
this.style.removeProperty(name);
};
}
function styleConstant(name, value, priority) {
return function() {
this.style.setProperty(name, value, priority);
};
}
function styleFunction(name, value, priority) {
return function() {
var v = value.apply(this, arguments);
if (v == null) this.style.removeProperty(name);
else this.style.setProperty(name, v, priority);
};
}
function selection_style(name, value, priority) {
return arguments.length > 1
? this.each((value == null
? styleRemove : typeof value === "function"
? styleFunction
: styleConstant)(name, value, priority == null ? "" : priority))
: styleValue(this.node(), name);
}
function styleValue(node, name) {
return node.style.getPropertyValue(name)
|| defaultView(node).getComputedStyle(node, null).getPropertyValue(name);
}
function propertyRemove(name) {
return function() {
delete this[name];
};
}
function propertyConstant(name, value) {
return function() {
this[name] = value;
};
}
function propertyFunction(name, value) {
return function() {
var v = value.apply(this, arguments);
if (v == null) delete this[name];
else this[name] = v;
};
}
function selection_property(name, value) {
return arguments.length > 1
? this.each((value == null
? propertyRemove : typeof value === "function"
? propertyFunction
: propertyConstant)(name, value))
: this.node()[name];
}
function classArray(string) {
return string.trim().split(/^|\s+/);
}
function classList(node) {
return node.classList || new ClassList(node);
}
function ClassList(node) {
this._node = node;
this._names = classArray(node.getAttribute("class") || "");
}
ClassList.prototype = {
add: function(name) {
var i = this._names.indexOf(name);
if (i < 0) {
this._names.push(name);
this._node.setAttribute("class", this._names.join(" "));
}
},
remove: function(name) {
var i = this._names.indexOf(name);
if (i >= 0) {
this._names.splice(i, 1);
this._node.setAttribute("class", this._names.join(" "));
}
},
contains: function(name) {
return this._names.indexOf(name) >= 0;
}
};
function classedAdd(node, names) {
var list = classList(node), i = -1, n = names.length;
while (++i < n) list.add(names[i]);
}
function classedRemove(node, names) {
var list = classList(node), i = -1, n = names.length;
while (++i < n) list.remove(names[i]);
}
function classedTrue(names) {
return function() {
classedAdd(this, names);
};
}
function classedFalse(names) {
return function() {
classedRemove(this, names);
};
}
function classedFunction(names, value) {
return function() {
(value.apply(this, arguments) ? classedAdd : classedRemove)(this, names);
};
}
function selection_classed(name, value) {
var names = classArray(name + "");
if (arguments.length < 2) {
var list = classList(this.node()), i = -1, n = names.length;
while (++i < n) if (!list.contains(names[i])) return false;
return true;
}
return this.each((typeof value === "function"
? classedFunction : value
? classedTrue
: classedFalse)(names, value));
}
function textRemove() {
this.textContent = "";
}
function textConstant(value) {
return function() {
this.textContent = value;
};
}
function textFunction(value) {
return function() {
var v = value.apply(this, arguments);
this.textContent = v == null ? "" : v;
};
}
function selection_text(value) {
return arguments.length
? this.each(value == null
? textRemove : (typeof value === "function"
? textFunction
: textConstant)(value))
: this.node().textContent;
}
function htmlRemove() {
this.innerHTML = "";
}
function htmlConstant(value) {
return function() {
this.innerHTML = value;
};
}
function htmlFunction(value) {
return function() {
var v = value.apply(this, arguments);
this.innerHTML = v == null ? "" : v;
};
}
function selection_html(value) {
return arguments.length
? this.each(value == null
? htmlRemove : (typeof value === "function"
? htmlFunction
: htmlConstant)(value))
: this.node().innerHTML;
}
function raise() {
if (this.nextSibling) this.parentNode.appendChild(this);
}
function selection_raise() {
return this.each(raise);
}
function lower() {
if (this.previousSibling) this.parentNode.insertBefore(this, this.parentNode.firstChild);
}
function selection_lower() {
return this.each(lower);
}
function selection_append(name) {
var create = typeof name === "function" ? name : creator(name);
return this.select(function() {
return this.appendChild(create.apply(this, arguments));
});
}
function constantNull() {
return null;
}
function selection_insert(name, before) {
var create = typeof name === "function" ? name : creator(name),
select = before == null ? constantNull : typeof before === "function" ? before : selector(before);
return this.select(function() {
return this.insertBefore(create.apply(this, arguments), select.apply(this, arguments) || null);
});
}
function remove() {
var parent = this.parentNode;
if (parent) parent.removeChild(this);
}
function selection_remove() {
return this.each(remove);
}
function selection_cloneShallow() {
return this.parentNode.insertBefore(this.cloneNode(false), this.nextSibling);
}
function selection_cloneDeep() {
return this.parentNode.insertBefore(this.cloneNode(true), this.nextSibling);
}
function selection_clone(deep) {
return this.select(deep ? selection_cloneDeep : selection_cloneShallow);
}
function selection_datum(value) {
return arguments.length
? this.property("__data__", value)
: this.node().__data__;
}
var filterEvents = {};
if (typeof document !== "undefined") {
var element = document.documentElement;
if (!("onmouseenter" in element)) {
filterEvents = {mouseenter: "mouseover", mouseleave: "mouseout"};
}
}
function filterContextListener(listener, index, group) {
listener = contextListener(listener, index, group);
return function(event) {
var related = event.relatedTarget;
if (!related || (related !== this && !(related.compareDocumentPosition(this) & 8))) {
listener.call(this, event);
}
};
}
function contextListener(listener, index, group) {
return function(event1) {
try {
listener.call(this, this.__data__, index, group);
} finally {
}
};
}
function parseTypenames(typenames) {
return typenames.trim().split(/^|\s+/).map(function(t) {
var name = "", i = t.indexOf(".");
if (i >= 0) name = t.slice(i + 1), t = t.slice(0, i);
return {type: t, name: name};
});
}
function onRemove(typename) {
return function() {
var on = this.__on;
if (!on) return;
for (var j = 0, i = -1, m = on.length, o; j < m; ++j) {
if (o = on[j], (!typename.type || o.type === typename.type) && o.name === typename.name) {
this.removeEventListener(o.type, o.listener, o.capture);
} else {
on[++i] = o;
}
}
if (++i) on.length = i;
else delete this.__on;
};
}
function onAdd(typename, value, capture) {
var wrap = filterEvents.hasOwnProperty(typename.type) ? filterContextListener : contextListener;
return function(d, i, group) {
var on = this.__on, o, listener = wrap(value, i, group);
if (on) for (var j = 0, m = on.length; j < m; ++j) {
if ((o = on[j]).type === typename.type && o.name === typename.name) {
this.removeEventListener(o.type, o.listener, o.capture);
this.addEventListener(o.type, o.listener = listener, o.capture = capture);
o.value = value;
return;
}
}
this.addEventListener(typename.type, listener, capture);
o = {type: typename.type, name: typename.name, value: value, listener: listener, capture: capture};
if (!on) this.__on = [o];
else on.push(o);
};
}
function selection_on(typename, value, capture) {
var typenames = parseTypenames(typename + ""), i, n = typenames.length, t;
if (arguments.length < 2) {
var on = this.node().__on;
if (on) for (var j = 0, m = on.length, o; j < m; ++j) {
for (i = 0, o = on[j]; i < n; ++i) {
if ((t = typenames[i]).type === o.type && t.name === o.name) {
return o.value;
}
}
}
return;
}
on = value ? onAdd : onRemove;
if (capture == null) capture = false;
for (i = 0; i < n; ++i) this.each(on(typenames[i], value, capture));
return this;
}
function dispatchEvent(node, type, params) {
var window = defaultView(node),
event = window.CustomEvent;
if (typeof event === "function") {
event = new event(type, params);
} else {
event = window.document.createEvent("Event");
if (params) event.initEvent(type, params.bubbles, params.cancelable), event.detail = params.detail;
else event.initEvent(type, false, false);
}
node.dispatchEvent(event);
}
function dispatchConstant(type, params) {
return function() {
return dispatchEvent(this, type, params);
};
}
function dispatchFunction(type, params) {
return function() {
return dispatchEvent(this, type, params.apply(this, arguments));
};
}
function selection_dispatch(type, params) {
return this.each((typeof params === "function"
? dispatchFunction
: dispatchConstant)(type, params));
}
var root = [null];
function Selection(groups, parents) {
this._groups = groups;
this._parents = parents;
}
function selection() {
return new Selection([[document.documentElement]], root);
}
Selection.prototype = selection.prototype = {
constructor: Selection,
select: selection_select,
selectAll: selection_selectAll,
filter: selection_filter,
data: selection_data,
enter: selection_enter,
exit: selection_exit,
join: selection_join,
merge: selection_merge,
order: selection_order,
sort: selection_sort,
call: selection_call,
nodes: selection_nodes,
node: selection_node,
size: selection_size,
empty: selection_empty,
each: selection_each,
attr: selection_attr,
style: selection_style,
property: selection_property,
classed: selection_classed,
text: selection_text,
html: selection_html,
raise: selection_raise,
lower: selection_lower,
append: selection_append,
insert: selection_insert,
remove: selection_remove,
clone: selection_clone,
datum: selection_datum,
on: selection_on,
dispatch: selection_dispatch
};
function select(selector) {
return typeof selector === "string"
? new Selection([[document.querySelector(selector)]], [document.documentElement])
: new Selection([[selector]], root);
}
/*
Uses the Mediawiki API to display a list of recent images and a link to
the page where the image has been used/placed.
Makes use of the following API calls:
* https://www.mediawiki.org/wiki/API:Allimages
* https://www.mediawiki.org/wiki/API:Imageinfo
* https://www.mediawiki.org/wiki/API:Imageusage
*/
var PAGE_COUNT = 25; /* how many edits to show per load*/
var main = select("#content"),
baseurl = "/mw/api.php?action=query&list=recentchanges&rclimit=25&rcnamespace=0&rctoponly=1&format=json&formatversion=2&aisort=timestamp&aidir=older&aiprop=timestamp|user|url|mime|size",
url = baseurl;
async function get_json (url) {
var resp = await fetch(url);
return await resp.json();
}
function url_for_title (title) {
return "/w/"+encodeURI(title.replace(/ /g, "_"));
}
async function load () {
let count = 0;
while (count < PAGE_COUNT) {
// console.log("starting loop", "count", count, "url", url);
let data = await get_json(url),
recentchanges = data.query.recentchanges;
console.log("recentchanges", recentchanges);
let items = main.selectAll("div.edit")
.data(recentchanges, d=>d.title)
.enter()
.append("div")
.attr("class", "edit")
.append("a")
.attr("href", d=>url_for_title(d.title))
.attr("target", "wikiframe")
.text(d=>d.title);
if (data.continue) {
url = baseurl+"&rccontinue="+data.continue.rccontinue;
} else {
return;
}
count += recentchanges.length;
}
}
document.addEventListener("DOMContentLoaded", load);
document.querySelector("a#more").addEventListener("click", function (e) {
e.preventDefault();
load();
});
}());

View File

@@ -0,0 +1,53 @@
<!DOCTYPE html>
<html>
<head>
<title>erg: modifications récentes</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="/m/style.css">
<style>
body {
margin: 5%;
margin-left: 50px;
margin-top: 10px;
background: #111111;
color: white;
overflow: auto;
}
h1 {
margin: 0;
font-family: Combined;
font-size: 100%;
}
#content {
margin-top: 1em;
}
div#footer {
clear: both;
text-align: center;
margin-top: 1em;
}
a {
color: white;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
a#more {
color: black;
text-decoration: none;
background: white;
padding: 5px;
}
div.edit {
margin-bottom: 0.5em;
}
</style>
</head>
<body>
<h1>Modifications récentes</h1>
<div id="content"></div>
<div id="footer"><a href="#" id="more">en plus&hellip;</a></div>
<script src="dist/recentchanges.js"></script>
</body>
</html>

View File

@@ -0,0 +1,16 @@
{
"name": "recentfiles",
"version": "1.0.0",
"description": "",
"main": "rollup.config.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"d3-selection": "^1.4.0",
"rollup": "^1.17.0"
}
}

View File

@@ -0,0 +1,17 @@
// rollup.config.js
// https://github.com/rollup/rollup-plugin-commonjs
import commonjs from 'rollup-plugin-commonjs';
import resolve from 'rollup-plugin-node-resolve';
export default [{
input: 'src/recentchanges.js',
output: {
file: 'dist/recentchanges.js',
format: 'iife',
name: 'app'
},
plugins: [
resolve(),
commonjs()
]
}];

View File

@@ -0,0 +1,55 @@
import { selectAll, select } from 'd3-selection';
/*
Uses the Mediawiki API to display a list of recent images and a link to
the page where the image has been used/placed.
Makes use of the following API calls:
* https://www.mediawiki.org/wiki/API:Allimages
* https://www.mediawiki.org/wiki/API:Imageinfo
* https://www.mediawiki.org/wiki/API:Imageusage
*/
var PAGE_COUNT = 25; /* how many edits to show per load*/
var main = select("#content"),
baseurl = "/mw/api.php?action=query&list=recentchanges&rclimit=25&rcnamespace=0&rctoponly=1&format=json&formatversion=2&aisort=timestamp&aidir=older&aiprop=timestamp|user|url|mime|size",
url = baseurl;
async function get_json (url) {
var resp = await fetch(url);
return await resp.json();
}
function url_for_title (title) {
return "/w/"+encodeURI(title.replace(/ /g, "_"));
}
async function load () {
let count = 0;
while (count < PAGE_COUNT) {
// console.log("starting loop", "count", count, "url", url);
let data = await get_json(url),
recentchanges = data.query.recentchanges;
console.log("recentchanges", recentchanges);
let items = main.selectAll("div.edit")
.data(recentchanges, d=>d.title)
.enter()
.append("div")
.attr("class", "edit")
.append("a")
.attr("href", d=>url_for_title(d.title))
.attr("target", "wikiframe")
.text(d=>d.title);
if (data.continue) {
url = baseurl+"&rccontinue="+data.continue.rccontinue;
} else {
return;
}
count += recentchanges.length;
}
}
document.addEventListener("DOMContentLoaded", load);
document.querySelector("a#more").addEventListener("click", function (e) {
e.preventDefault();
load();
});

View File

@@ -858,7 +858,6 @@
}
/*
Uses the Mediawiki API to display a list of recent images and a link to
the page where the image has been used/placed.
@@ -867,9 +866,11 @@
* https://www.mediawiki.org/wiki/API:Allimages
* https://www.mediawiki.org/wiki/API:Imageinfo
* https://www.mediawiki.org/wiki/API:Imageusage
*/
var NUM_FILES = 10; /* how many files to show */
var main = select("#content"),
baseurl = "/mw/api.php?action=query&list=allimages&ailimit=1&format=json&formatversion=2&aisort=timestamp&aidir=older&aiprop=timestamp|user|url|mime|size",
url = baseurl;
async function get_json (url) {
var resp = await fetch(url);
@@ -881,43 +882,29 @@
}
async function load () {
var main = select("#content"),
baseurl = "/mw/api.php?action=query&list=allimages&ailimit=1&format=json&formatversion=2&aisort=timestamp&aidir=older&aiprop=timestamp|user|url|mime|size",
url = baseurl,
count = 0;
let count = 0;
while (count < NUM_FILES) {
// console.log("starting loop", debugloopcount, "count", count, "url", url);
let resp = await fetch(url),
data = await resp.json(),
// console.log("starting loop", "count", count, "url", url);
let data = await get_json(url),
allimages = data.query.allimages,
useimages = [];
// console.log("got data", data.query.allimages.length);
// For each image:
// Use API:Imageinfo request/get the URL to a thumbnail image
//
for (var i=0, l=allimages.length; i<l; i++) {
let image = allimages[i];
// console.log("image", image.name);
let iu_data = await get_json(`/mw/api.php?action=query&list=imageusage&iutitle=${image.title}&iunamespace=0&format=json&formatversion=2`);
image.imageusage = iu_data.query.imageusage;
if (image.imageusage.length == 0) {
continue;
}
let ii_data = await get_json(`/mw/api.php?action=query&prop=imageinfo&titles=${image.title}&iiprop=url|size&dimensions|mime&iiurlwidth=320&format=json&formatversion=2`);
image.imageinfo = ii_data.query.pages[0].imageinfo[0];
if (!image.imageinfo.thumburl) {
continue;
}
useimages.push(image);
// console.log("imageusage", image.name, image.imageusage.length);
// console.log("imageinfo", image.name, image.imageinfo);
}
// console.log("allimages", allimages);
// allimages = allimages.filter(d=>d.imageinfo.thumburl && (d.imageusage.length > 0));
let items = main.selectAll("div.file")
.data(useimages, d=>d.title)
.enter()
@@ -929,14 +916,16 @@
.append("img")
.attr('src', d=>d.imageinfo.thumburl);
count += useimages.length;
if (data.continue) {
url = baseurl+"&aicontinue="+data.continue.aicontinue;
}
// if (debugloopcount >= 5) break;
count += useimages.length;
}
}
document.addEventListener("DOMContentLoaded", load);
document.querySelector("a#more").addEventListener("click", function (e) {
e.preventDefault();
load();
});
}());

View File

@@ -18,10 +18,21 @@
div.file img {
max-width: 100%;
}
div#footer {
clear: both;
text-align: center;
}
a#more {
color: white;
text-decoration: none;
background: black;
padding: 5px;
}
</style>
</head>
<body>
<div id="content"></div>
<div id="footer"><a href="#" id="more">en plus&hellip;</a></div>
<script src="dist/recentfiles.js"></script>
</body>
</html>

View File

@@ -1,7 +1,5 @@
import { selectAll, select } from 'd3-selection';
/*
Uses the Mediawiki API to display a list of recent images and a link to
the page where the image has been used/placed.
@@ -10,9 +8,11 @@ Makes use of the following API calls:
* https://www.mediawiki.org/wiki/API:Allimages
* https://www.mediawiki.org/wiki/API:Imageinfo
* https://www.mediawiki.org/wiki/API:Imageusage
*/
var NUM_FILES = 10; /* how many files to show */
var main = select("#content"),
baseurl = "/mw/api.php?action=query&list=allimages&ailimit=1&format=json&formatversion=2&aisort=timestamp&aidir=older&aiprop=timestamp|user|url|mime|size",
url = baseurl;
async function get_json (url) {
var resp = await fetch(url);
@@ -24,44 +24,29 @@ function url_for_title (title) {
}
async function load () {
var main = select("#content"),
baseurl = "/mw/api.php?action=query&list=allimages&ailimit=1&format=json&formatversion=2&aisort=timestamp&aidir=older&aiprop=timestamp|user|url|mime|size",
url = baseurl,
count = 0;
let debugloopcount = 0;
let count = 0;
while (count < NUM_FILES) {
// console.log("starting loop", debugloopcount, "count", count, "url", url);
let resp = await fetch(url),
data = await resp.json(),
// console.log("starting loop", "count", count, "url", url);
let data = await get_json(url),
allimages = data.query.allimages,
useimages = [];
// console.log("got data", data.query.allimages.length);
// For each image:
// Use API:Imageinfo request/get the URL to a thumbnail image
//
for (var i=0, l=allimages.length; i<l; i++) {
let image = allimages[i];
// console.log("image", image.name);
let iu_data = await get_json(`/mw/api.php?action=query&list=imageusage&iutitle=${image.title}&iunamespace=0&format=json&formatversion=2`);
image.imageusage = iu_data.query.imageusage;
if (image.imageusage.length == 0) {
continue;
}
let ii_data = await get_json(`/mw/api.php?action=query&prop=imageinfo&titles=${image.title}&iiprop=url|size&dimensions|mime&iiurlwidth=320&format=json&formatversion=2`);
image.imageinfo = ii_data.query.pages[0].imageinfo[0];
if (!image.imageinfo.thumburl) {
continue;
}
useimages.push(image);
// console.log("imageusage", image.name, image.imageusage.length);
// console.log("imageinfo", image.name, image.imageinfo);
}
// console.log("allimages", allimages);
// allimages = allimages.filter(d=>d.imageinfo.thumburl && (d.imageusage.length > 0));
let items = main.selectAll("div.file")
.data(useimages, d=>d.title)
.enter()
@@ -73,15 +58,14 @@ async function load () {
.append("img")
.attr('src', d=>d.imageinfo.thumburl);
count += useimages.length;
if (data.continue) {
url = baseurl+"&aicontinue="+data.continue.aicontinue;
}
debugloopcount += 1;
// if (debugloopcount >= 5) break;
count += useimages.length;
}
}
document.addEventListener("DOMContentLoaded", load);
document.querySelector("a#more").addEventListener("click", function (e) {
e.preventDefault();
load();
});

View File

@@ -146,7 +146,7 @@ use {
/* Categories */
#cats .body {
/*display: none;*/
display: none;
}
#cats .placeholder {
@@ -160,7 +160,20 @@ use {
}
#cats.expanded .placeholder {
display: none;
display: block;
}
#cats.expanded .placeholder:hover {
color: var(--color-b);
}
#cats.expanded .placeholder:before {
content: "×";
font-size: 17px;
cursor: pointer;
}
#cats .placeholder:before {
content: "?";
font-size: 12px;
cursor: pointer;
}
#cats {
@@ -203,6 +216,11 @@ use {
color: black;
text-decoration: none;
}
#cats div.cat.highlight span.icon {
background-color: var(--color-b);
background-blend-mode: screen;
}
#cats div.cat a:hover,
#cats div.cat.highlight a {
color: var(--color-b);
}

View File

@@ -15,7 +15,7 @@
version="1.1"
id="svg5507"
inkscape:version="0.92.4 5da689c313, 2019-01-14"
sodipodi:docname="symbols.svg"
sodipodi:docname="symbols.new.svg"
enable-background="new">
<defs
id="defs5501" />
@@ -26,9 +26,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="15.839192"
inkscape:cx="2.6413863"
inkscape:cy="122.46453"
inkscape:zoom="7.919596"
inkscape:cx="-11.795379"
inkscape:cy="127.59394"
inkscape:document-units="mm"
inkscape:current-layer="layer8"
showgrid="false"
@@ -52,7 +52,7 @@
inkscape:snap-smooth-nodes="true"
inkscape:snap-center="true"
inkscape:snap-object-midpoints="true"
showguides="true"
showguides="false"
inkscape:guide-bbox="true">
<sodipodi:guide
position="1.2695302,37.647915"
@@ -84,8 +84,8 @@
style="display:none">
<path
id="Main"
d="m 0.05427516,-1.0836044 c -0.3145139,0 -0.6143881,0.069209 -0.886913,0.18447807 -0.27252616,0.11526864 -0.51761266,0.2834672 -0.72372176,0.48957617 -0.2061091,0.2061091 -0.3743076,0.4511958 -0.4895767,0.7237215 -0.1152682,0.2725256 -0.1773827,0.5723994 -0.1773827,0.88691326 0,0.3145142 0.062114,0.6072926 0.1773827,0.8798184 0.1152691,0.2725256 0.2834676,0.5247077 0.4895767,0.7308165 0.2061091,0.2061091 0.4511956,0.3672123 0.72372176,0.4824809 0.2725249,0.1152689 0.5723991,0.1844781 0.886913,0.1844781 0.314514,0 0.614388,-0.069209 0.886913,-0.1844781 C 1.2137144,3.1789318 1.4588008,3.0178286 1.6649099,2.8117195 1.871019,2.6056107 2.0392175,2.3534286 2.1544867,2.080903 2.2697548,1.8083772 2.3318695,1.5155988 2.3318695,1.2010846 2.3318695,0.88657074 2.2697548,0.58669694 2.1544867,0.31417134 2.0392175,0.04164564 1.871019,-0.20344106 1.6649099,-0.40955016 1.4588008,-0.61565913 1.2137144,-0.78385769 0.94118816,-0.89912633 0.66866316,-1.014395 0.36878916,-1.0836044 0.05427516,-1.0836044 Z"
style="display:inline;fill-opacity:1;stroke-width:0.72655946;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.99615389;marker-start:none"
d="m 0.00702812,-2.920128 c -0.40161335,0 -0.78453276,0.088375 -1.13252892,0.2355662 -0.3479978,0.1471904 -0.660957,0.3619688 -0.9241446,0.6251563 -0.2631876,0.2631876 -0.4779659,0.576147 -0.6251569,0.9241442 -0.1471898,0.34799704 -0.2265059,0.73091595 -0.2265059,1.1325292 0,0.4016138 0.079315,0.7754723 0.2265059,1.1234696 0.147191,0.3479971 0.3619693,0.6700169 0.6251569,0.9332041 0.2631876,0.2631876 0.5761468,0.4689057 0.9241446,0.6160961 0.34799616,0.1471907 0.73091557,0.2355662 1.13252892,0.2355662 0.40161346,0 0.78453263,-0.088375 1.13252898,-0.2355662 C 1.487555,2.5228473 1.800514,2.3171292 2.0637016,2.0539416 2.3268892,1.7907544 2.5416675,1.4687346 2.6888586,1.1207375 2.8360483,0.7727402 2.9153647,0.3988817 2.9153647,-0.0027321 c 0,-0.40161325 -0.079316,-0.78453216 -0.2265061,-1.1325292 C 2.5416675,-1.4832585 2.3268892,-1.7962179 2.0637016,-2.0594055 1.800514,-2.322593 1.487555,-2.5373714 1.1395571,-2.6845618 0.79156075,-2.8317522 0.40864158,-2.920128 0.00702812,-2.920128 Z"
style="display:inline;fill-opacity:1;stroke-width:0.92776811;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.99615389;marker-start:none"
inkscape:connector-curvature="0"
inkscape:label="#path6386-5-5" />
</g>
@@ -97,7 +97,7 @@
<g
id="Orientations"
style="fill-opacity:1;stroke-opacity:0.99615389"
transform="matrix(0.40423298,0,0,0.40423298,35.516699,1.0220982)">
transform="matrix(0.40423298,0,0,0.40423298,35.516699,-0.22522322)">
<path
id="Orientations-0"
d="m -87.8577,-14.01912 c -8.05454,0 -14.59375,6.50796 -14.59375,14.5625 0,8.05454 6.53921,14.59375 14.59375,14.59375 8.05454,0 14.59375,-6.53921 14.59375,-14.59375 0,-8.05454 -6.53921,-14.5625 -14.59375,-14.5625 z"
@@ -116,9 +116,9 @@
inkscape:label="Ateliers_pluridisciplinaires"
style="display:none">
<g
transform="matrix(0.65256016,0,0,0.65256016,58.839197,-27.116613)"
transform="matrix(0.65256016,0,0,0.65256016,58.839197,-28.341992)"
id="Ateliers_pluridisciplinaires"
style="">
style="stroke:#000000">
<circle
r="19.208878"
cy="40.264759"
@@ -147,8 +147,8 @@
<g
id="Cours_de_soutien_a_l_orientation"
style="display:inline;fill-opacity:1;stroke-opacity:0.99615389"
transform="matrix(0.40423297,0,0,0.40423297,35.552134,0.97198436)"
inkscape:label="#Cours_de_soutien_a_l_orientation">
transform="matrix(0.40423297,0,0,0.40423297,35.552134,-0.25339243)"
inkscape:label="#Cours_de_soutien_a_l'orientation">
<path
id="Orientations-0-7"
d="m -87.940348,-13.895148 c -8.05454,0 -14.593742,6.5079588 -14.593742,14.56249871 0,8.05454009 6.539202,14.59375129 14.593742,14.59375129 8.05454,0 14.59375,-6.5392112 14.59375,-14.59375129 0,-8.05453991 -6.53921,-14.56249871 -14.59375,-14.56249871 z"
@@ -169,7 +169,7 @@
<g
id="Cours_de_soutien_specifique"
style="fill-opacity:0.99615389;stroke-opacity:0.99615389"
transform="matrix(0.40361541,0,0,0.40361541,36.375644,35.301905)">
transform="matrix(0.40361541,0,0,0.40361541,36.375644,34.076526)">
<path
transform="translate(-446.2952,-500.01912)"
id="path6358"
@@ -203,7 +203,7 @@
style="display:none">
<g
id="Cours_techniques"
transform="matrix(0.41014612,0,0,-0.41014612,-14.018646,82.999971)"
transform="matrix(0.41014612,0,0,-0.41014612,-14.018646,81.774592)"
inkscape:label="#g3142"
style="fill-opacity:1;stroke-opacity:1">
<title
@@ -230,8 +230,8 @@
inkscape:label="Actualites"
style="display:none">
<path
d="M 6.15217,1.2480664 C 6.15217,4.6458175 3.397748,7.4002357 -7.9603524e-7,7.4002357 -3.3977514,7.4002357 -6.1521696,4.6458175 -6.1521696,1.2480664 c 0,-3.397751 2.7544182,-6.1521693 6.15216880396476,-6.1521693 C 3.397748,-4.9041029 6.15217,-2.1496846 6.15217,1.2480664 Z"
style="fill-opacity:1;stroke-width:0.77512467;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:2.23606801;stroke-dasharray:2.32537419, 2.32537419;stroke-dashoffset:0;stroke-opacity:1;marker-start:none;marker-mid:none;marker-end:none"
d="M 6.15217,0.02268961 C 6.15217,3.4204406 3.397748,6.1748588 -7.9603524e-7,6.1748588 -3.3977514,6.1748588 -6.1521696,3.4204406 -6.1521696,0.02268961 -6.1521696,-3.3750615 -3.3977514,-6.1294798 -7.9603524e-7,-6.1294798 3.397748,-6.1294798 6.15217,-3.3750615 6.15217,0.02268961 Z"
style="fill:#ffffff;fill-opacity:1;stroke-width:0.77512467;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:2.23606801;stroke-dasharray:2.32537419, 2.32537419;stroke-dashoffset:0;stroke-opacity:1;marker-start:none;marker-mid:none;marker-end:none"
id="Actualites"
inkscape:connector-curvature="0"
inkscape:label="#path87-1"
@@ -245,7 +245,7 @@
<g
id="Cours_theoriques"
style="display:inline;fill-opacity:1;stroke-opacity:0.99615389"
transform="matrix(0.40423298,0,0,0.40423298,35.552135,0.97198353)"
transform="matrix(0.40423298,0,0,0.40423298,35.552135,-0.25339326)"
inkscape:label="#Cours_theoriques">
<path
id="Orientations-0-7-6"
@@ -266,11 +266,11 @@
style="display:inline">
<path
sodipodi:type="star"
style="fill-opacity:1;stroke-width:0.974;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
style="fill-opacity:1;stroke-width:0.97391373;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="Enseignants"
sodipodi:sides="3"
sodipodi:cx="0.49757248"
sodipodi:cy="1.1894979"
sodipodi:cx="0.0018145076"
sodipodi:cy="0.13116495"
sodipodi:r1="6.7946506"
sodipodi:r2="3.397325"
sodipodi:arg1="0.52606642"
@@ -278,9 +278,9 @@
inkscape:flatsided="true"
inkscape:rounded="0"
inkscape:randomized="0"
d="M 6.3735112,4.6013333 -5.395133,4.5722924 0.51433925,-5.6051319 Z"
inkscape:transform-center-x="0.013378058"
inkscape:transform-center-y="2.6969222"
d="M 5.8777532,3.5430003 -5.8908909,3.5139594 0.01858127,-6.6634649 Z"
inkscape:transform-center-x="-0.0012016352"
inkscape:transform-center-y="0.24243705"
inkscape:label="#path3225-6-7-7" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB