Commit 19371164 authored by Dave Lane's avatar Dave Lane

initial commit of new iframes and h5p functionality

parent da2c5d35
......@@ -12,6 +12,7 @@ var jsdom = require("jsdom"),
mkdirp = require("mkdirp"),
path = require("path"),
wordpress = require("wordpress"),
iframes, h5p,
theme;
var pages = [], // list of page URLs to be processed
......@@ -55,6 +56,8 @@ Options:
--wppass=PASS WordPress password.
--wpmenu Generate menu in newSplashWP theme.
--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.
-h, --help Show this help.
--version Display version.
......@@ -68,6 +71,12 @@ console.log(opt);
if (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) {
opt["--link"] = "http://" + opt["--link"];
}
......@@ -432,6 +441,18 @@ function processPage(pi) {
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"]) {
var pl, nl;
var pp = getPrev(pi, pages);
......
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.0.1",
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 '+iframe+' /></div>';
console.log(ifcount+'. '+iframe);
$(this).replaceWith(iframe);
});
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment