...
 
Commits (2)
...@@ -14,11 +14,11 @@ These sample scripts require [Node.js](https://nodejs.org/en/) 6.x.x or greater. ...@@ -14,11 +14,11 @@ These sample scripts require [Node.js](https://nodejs.org/en/) 6.x.x or greater.
> If you don't already have Node.js installed, using > If you don't already have Node.js installed, using
> [nvm](https://github.com/creationix/nvm) is an easy > [nvm](https://github.com/creationix/nvm) is an easy
> way to proceed. > way to proceed.
> >
> You can install nvm using cURL: > You can install nvm using cURL:
> >
> `curl https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash` > `curl https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash`
> >
> *or* Wget: > *or* Wget:
> >
> `wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash` > `wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash`
...@@ -88,3 +88,7 @@ of course-sized open educational resources stored in WikiEducator. ...@@ -88,3 +88,7 @@ of course-sized open educational resources stored in WikiEducator.
I expect that different institutions (and even different courses I expect that different institutions (and even different courses
within an institution) will have different needs, organizations, and within an institution) will have different needs, organizations, and
styling. styling.
Update 2019-07-23: added iFrame embedding capability using the new [WEiFrame template](https://wikieducator.org/Template:WEiFrame) on WikiEducator.
The main concern with this is that if the site you're wanting to include in the iframe has "X-Frame-Options" (in the sites website configuration, e.g. Apache or NGINX) is set to "sameorigin". That will block the iframe display.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* jshint node: true, multistr: true, trailing: true, esnext: true */ /* jshint node: true, multistr: true, trailing: true, esnext: true */
"use strict"; "use strict";
const VERSION = "1.0.0", const VERSION = "1.1.0",
JQUERY = "http://code.jquery.com/jquery-2.1.1.min.js", JQUERY = "http://code.jquery.com/jquery-2.1.1.min.js",
FILEPATH = "/home/www/www"; FILEPATH = "/home/www/www";
...@@ -12,6 +12,7 @@ var jsdom = require("jsdom"), ...@@ -12,6 +12,7 @@ var jsdom = require("jsdom"),
mkdirp = require("mkdirp"), mkdirp = require("mkdirp"),
path = require("path"), path = require("path"),
wordpress = require("wordpress"), wordpress = require("wordpress"),
iframes, h5p,
theme; theme;
var pages = [], // list of page URLs to be processed var pages = [], // list of page URLs to be processed
...@@ -55,6 +56,8 @@ Options: ...@@ -55,6 +56,8 @@ Options:
--wppass=PASS WordPress password. --wppass=PASS WordPress password.
--wpmenu Generate menu in newSplashWP theme. --wpmenu Generate menu in newSplashWP theme.
--wpdelete Delete pages in WordPress. --wpdelete Delete pages in WordPress.
--iframes Support the use of embedded iFrames using WEiFrame
--h5p Support the use of H5P short codes
--debugout Show content to be written. --debugout Show content to be written.
-h, --help Show this help. -h, --help Show this help.
--version Display version. --version Display version.
...@@ -68,6 +71,12 @@ console.log(opt); ...@@ -68,6 +71,12 @@ console.log(opt);
if (opt["--theme"]) { if (opt["--theme"]) {
theme = require("./themes/" + opt["--theme"]); theme = require("./themes/" + opt["--theme"]);
} }
if (opt["--iframes"]) {
iframes = require("./extras/iframes.js");
}
if (opt["--h5p"]) {
h5p = require("./extras/h5p.js");
}
if (opt["--link"] && opt["--link"].indexOf("//") === -1) { if (opt["--link"] && opt["--link"].indexOf("//") === -1) {
opt["--link"] = "http://" + opt["--link"]; opt["--link"] = "http://" + opt["--link"];
} }
...@@ -432,6 +441,18 @@ function processPage(pi) { ...@@ -432,6 +441,18 @@ function processPage(pi) {
theme.wrap($); theme.wrap($);
if (opt["--iframes"]) {
console.log("+++++");
iframes.process($, opt);
console.log("+++++");
}
if (opt["--h5p"]) {
console.log("+++++");
h5p.process($, opt);
console.log("+++++");
}
if (opt["--prevnext"]) { if (opt["--prevnext"]) {
var pl, nl; var pl, nl;
var pp = getPrev(pi, pages); var pp = getPrev(pi, pages);
...@@ -771,6 +792,7 @@ function getOutline() { ...@@ -771,6 +792,7 @@ function getOutline() {
}); });
if (opt["--wpurl"]) { if (opt["--wpurl"]) {
console.log('--wpurl');
// allow the user to make the first page have no WP title // allow the user to make the first page have no WP title
// by giving it a slug, but seting the text to an empty string // by giving it a slug, but seting the text to an empty string
if (options.hasOwnProperty("no_landing_page_title")) { if (options.hasOwnProperty("no_landing_page_title")) {
...@@ -781,6 +803,7 @@ function getOutline() { ...@@ -781,6 +803,7 @@ function getOutline() {
} }
} }
if (opt["--wpdelete"]) { if (opt["--wpdelete"]) {
console.log('--wpdelete');
var posts = []; var posts = [];
function deletePages() { function deletePages() {
var post; var post;
...@@ -800,7 +823,7 @@ function getOutline() { ...@@ -800,7 +823,7 @@ function getOutline() {
setImmediate(processPages); setImmediate(processPages);
} }
} }
console.log('before getPosts');
wp.getPosts({ post_type: "page", number: 200 }, ["post_id"], function( wp.getPosts({ post_type: "page", number: 200 }, ["post_id"], function(
err, err,
data data
......
console.log('in h5p.js!');
module.exports = {
version: "0.0.1",
process: function($, opt) {
console.log('in h5p.js module!');
}
}
console.log('in iframe.js!');
module.exports = {
version: "0.1.0",
process: function($, opt) {
console.log('in iframe.js module!');
var ifcount = 0,
iframe,
ifurl,
ifheight,
ifwidth,
ifstyle,
ifstyle_string,
ifclasses,
ifid;
// find the nodes in the Dom...
$(".WEiFrame").each(function() {
iframe = ifurl = ifheight = ifwidth = ifstyle = ifstyle_string = ifclasses = ifid = "";
ifcount += 1;
console.log('WEiFrame '+ifcount+' ...');
$(this).find("div").each(function() {
ifclass = $(this).attr('class');
//console.log('found '+ifclass+'='+$(this).text());
if (ifclass == 'url') {
ifurl = $(this).text();
console.log('url = '+ifurl);
iframe += ' src="'+ifurl+'"';
} else if (ifclass == 'height') {
ifheight = $(this).text();
console.log('height = '+ifheight);
ifstyle_string += ' height:'+ifheight+';';
} else if (ifclass == 'width') {
ifwidth = $(this).text();
console.log('width = '+ifwidth);
ifstyle_string += ' width:'+ifwidth+';';
} else if (ifclass == 'style') {
ifstyle = $(this).text();
console.log('style = '+ifstyle);
ifstyle_string += ' '+ifstyle;
} else if (ifclass == 'classes') {
ifclasses = $(this).text();
console.log('classes = '+ifclasses);
iframe += ' class="'+ifclasses+'"';
} else if (ifclass == 'id') {
ifid = $(this).text();
console.log('id = '+ifid);
iframe += ' id="'+ifid+'"';
}
});
if (ifstyle_string != "") {
iframe += ' style="'+ifstyle_string+'"';
}
//iframe = '<div class="WEiFrame"><iframe frameborder="0" '+iframe+' /></div>';
iframe = '<div class="WEiFrame"><iframe '+iframe+' /></div>';
console.log(ifcount+'. '+iframe);
$(this).replaceWith(iframe);
});
}
}