files from erg serer
commit
d348e9316e
@ -0,0 +1,2 @@
|
||||
dist
|
||||
node_modules
|
@ -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
|
@ -0,0 +1,55 @@
|
||||
<!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: 1.5em;
|
||||
margin-left: 40px;
|
||||
margin-top: 2.5em;
|
||||
background: #333;
|
||||
color: white;
|
||||
overflow: auto;
|
||||
font-family: Vega;
|
||||
font-size: 17px;
|
||||
}
|
||||
h1 {
|
||||
margin: 0;
|
||||
font-family: Combined;
|
||||
font-size: 1.5em;
|
||||
}
|
||||
#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: 1em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Modifications récentes</h1>
|
||||
<div id="content"></div>
|
||||
<div id="footer"><a href="#" id="more">en plus…</a></div>
|
||||
<script src="dist/recentchanges.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "recentfiles",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@types/estree": {
|
||||
"version": "0.0.39",
|
||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz",
|
||||
"integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw=="
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "12.6.8",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.6.8.tgz",
|
||||
"integrity": "sha512-aX+gFgA5GHcDi89KG5keey2zf0WfZk/HAQotEamsK2kbey+8yGKcson0hbK8E+v0NArlCJQCqMP161YhV6ZXLg=="
|
||||
},
|
||||
"acorn": {
|
||||
"version": "6.2.1",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.2.1.tgz",
|
||||
"integrity": "sha512-JD0xT5FCRDNyjDda3Lrg/IxFscp9q4tiYtxE1/nOzlKCk7hIRuYjhq1kCNkbPjMRMZuFq20HNQn1I9k8Oj0E+Q=="
|
||||
},
|
||||
"d3-selection": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/d3-selection/-/d3-selection-1.4.0.tgz",
|
||||
"integrity": "sha512-EYVwBxQGEjLCKF2pJ4+yrErskDnz5v403qvAid96cNdCMr8rmCYfY5RGzWz24mdIbxmDf6/4EAH+K9xperD5jg=="
|
||||
},
|
||||
"rollup": {
|
||||
"version": "1.17.0",
|
||||
"resolved": "https://registry.npmjs.org/rollup/-/rollup-1.17.0.tgz",
|
||||
"integrity": "sha512-k/j1m0NIsI4SYgCJR4MWPstGJOWfJyd6gycKoMhyoKPVXxm+L49XtbUwZyFsrSU2YXsOkM4u1ll9CS/ZgJBUpw==",
|
||||
"requires": {
|
||||
"@types/estree": "0.0.39",
|
||||
"@types/node": "^12.6.2",
|
||||
"acorn": "^6.2.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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"
|
||||
}
|
||||
}
|
@ -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()
|
||||
]
|
||||
}];
|
@ -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&rcshow=!minor|!bot|!redirect|!anon",
|
||||
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();
|
||||
});
|
Loading…
Reference in New Issue