Skip to content

Commit

Permalink
Use toolforge cdn's hogan, fixing licensing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
enterprisey committed Jan 15, 2022
1 parent cb217ed commit 7b87347
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 25 deletions.
14 changes: 1 addition & 13 deletions Gruntfile.js
Expand Up @@ -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' ]
Expand Down Expand Up @@ -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' );
Expand Down Expand Up @@ -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' ] );
Expand Down
4 changes: 0 additions & 4 deletions package.json
Expand Up @@ -15,17 +15,13 @@
"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",
"eslint-plugin-jsdoc": "^36.0.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",
Expand Down
9 changes: 2 additions & 7 deletions server.js
Expand Up @@ -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' });
}

Expand Down Expand Up @@ -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(
Expand Down
5 changes: 4 additions & 1 deletion src/afch.js
Expand Up @@ -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' ),
Expand Down

0 comments on commit 7b87347

Please sign in to comment.