From 7b873479b0fd6eb426b190fae857b29f5be06747 Mon Sep 17 00:00:00 2001 From: Enterprisey Date: Fri, 14 Jan 2022 21:03:27 -0800 Subject: [PATCH] Use toolforge cdn's hogan, fixing licensing issue https://en.wikipedia.org/wiki/Wikipedia:Miscellany_for_deletion/MediaWiki:Gadget-afchelper.js/core.js --- Gruntfile.js | 14 +------------- package.json | 4 ---- server.js | 9 ++------- src/afch.js | 5 ++++- 4 files changed, 7 insertions(+), 25 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 12f0d6d..87c2123 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -9,17 +9,6 @@ module.exports = function ( grunt ) { } }, - concat: { - options: { - separator: ';' - }, - dependencies: { - files: { - 'build/modules/core.js': [ 'node_modules/hogan.js/build/gh-pages/builds/2.0.0/hogan-2.0.0.js', 'build/modules/core.js' ] - } - } - }, - clean: { build: { src: [ 'build' ] @@ -72,7 +61,6 @@ module.exports = function ( grunt ) { grunt.loadNpmTasks( 'grunt-autoprefixer' ); grunt.loadNpmTasks( 'grunt-contrib-clean' ); - grunt.loadNpmTasks( 'grunt-contrib-concat' ); grunt.loadNpmTasks( 'grunt-contrib-copy' ); grunt.loadNpmTasks( 'grunt-contrib-cssmin' ); grunt.loadNpmTasks( 'grunt-contrib-less' ); @@ -100,7 +88,7 @@ module.exports = function ( grunt ) { grunt.registerTask( 'build', 'Tests files, moves them to the /build directory, and minifies CSS.', - [ 'clean:build', 'test', 'copy', 'concat:dependencies', 'styling' ] + [ 'clean:build', 'test', 'copy', 'styling' ] ); grunt.registerTask( 'default', [ 'build' ] ); diff --git a/package.json b/package.json index a935678..7257d5f 100644 --- a/package.json +++ b/package.json @@ -15,9 +15,6 @@ "test": "grunt test", "generate-certificates": "node scripts/generate-certificates.js" }, - "dependencies": { - "hogan.js": "^3.0.2" - }, "devDependencies": { "eslint": "^7.31.0", "eslint-config-wikimedia": "^0.20.0", @@ -25,7 +22,6 @@ "grunt": "^1.4.1", "grunt-autoprefixer": "^3.0.4", "grunt-contrib-clean": "^2.0.0", - "grunt-contrib-concat": "^1.0.1", "grunt-contrib-copy": "^1.0.0", "grunt-contrib-cssmin": "^4.0.0", "grunt-contrib-less": "^3.0.0", diff --git a/server.js b/server.js index fa16c2f..e766f3f 100644 --- a/server.js +++ b/server.js @@ -4,18 +4,14 @@ // Serves the script from localhost for development purposes. // Note that we serve the un-built JS files from src/ instead of the built JS // files from build/. This avoids having to run the build process every time. -// The build process does almost nothing for JS (as it just concatenates the -// hogan file). const child_process = require('child_process'); const fs = require('fs'); const http = require('http'); const process = require('process'); -const HOGAN_FILE = 'node_modules/hogan.js/build/gh-pages/builds/2.0.0/hogan-2.0.0.js'; - -if(!fs.existsSync(HOGAN_FILE)) { - console.log('No file found at ' + HOGAN_FILE + ' - downloading it with "npm install"...'); +if(!fs.existsSync('./node_modules/jquery')) { + console.log('No file found at ./node_modules/jquery - downloading it with "npm install"...'); child_process.execSync('npm install', { stdio: 'inherit' }); } @@ -55,7 +51,6 @@ http.createServer({}, async function (req, res) { // This is the reverse of what happens to filenames in scripts/upload.py var content = ''; if(reqTitle.endsWith("core.js")) { - content += readFile(HOGAN_FILE) + ';'; content += readFile("src/modules/core.js"); // enable mockItUp by default for testing content = content.replace( diff --git a/src/afch.js b/src/afch.js index 044cd37..93bdcc9 100644 --- a/src/afch.js +++ b/src/afch.js @@ -35,7 +35,10 @@ AFCH.consts.baseurl = AFCH.consts.scriptpath + '?action=raw&ctype=text/javascript&title=MediaWiki:Gadget-afch.js'; - $.getScript( AFCH.consts.baseurl + '/core.js' ).done( function () { + $.when( + $.getScript( AFCH.consts.baseurl + '/core.js' ), + $.getScript( 'https://tools-static.wmflabs.org/cdnjs/ajax/libs/hogan.js/3.0.2/hogan.min.js' ) + ).done( function () { var loaded = AFCH.load( 'submissions' ); // perhaps eventually there will be more modules besides just 'submissions' if ( !loaded ) { mw.notify( 'AFCH could not be loaded: ' + ( AFCH.error || 'unknown error' ),