Commit d5385b03 authored by Jim Tittsler's avatar Jim Tittsler

WP: improve processing of legacy iDevices

parent 0da69a34
......@@ -2,9 +2,9 @@
/* jshint node: true, multistr: true, trailing: true, esnext: true */
"use strict";
var VERSION = '0.11.1',
JQUERY = 'http://code.jquery.com/jquery-2.1.1.min.js',
FILEPATH = '/home/www/www';
const VERSION = '0.11.2',
JQUERY = 'http://code.jquery.com/jquery-2.1.1.min.js',
FILEPATH = '/home/www/www';
var jsdom = require('jsdom'),
docopt = require('docopt').docopt,
......@@ -31,8 +31,8 @@ var pages = [], // list of page URLs to be processed
pi = 0, // process index
base_url = 'http://wikieducator.org', // no trailing slash
wp,
opt,
doc = `Usage:
opt;
const doc = `Usage:
course [options] OUTLINE PAGEPREFIX
course -h | --help
course --version
......
......@@ -9,7 +9,7 @@ function quotedWPstring(s) {
}
module.exports = {
version: '0.1.1',
version: '0.1.2',
// emit headers
header: function ($, opt) {
......@@ -241,10 +241,10 @@ module.exports = {
// restyle iDevices
$('.eXe-iDevice').each(function(){
var classes, $tloc, $inner,
idtype = $(this).data('idevice'),
idtheme = $(this).data('theme') || 'line',
idtitle, idbody;
var classes, $inner, $idtitle, idtitle, idbody,
idtype = $(this).data('iDevice'),
idtheme = $(this).data('theme') || 'line';
idtheme = idtheme.toLowerCase();
if (!idtype) {
classes = $(this).attr('class').split(' ');
......@@ -261,14 +261,28 @@ module.exports = {
idbody = $(this).find('.iDevice-body').html();
} else {
// in old iDevices there are (at least) three places where the title might be
$inner = $(this).children('div:eq(0)');
if ($inner.children('div:eq(1)').length > 0) {
idtitle = $inner.children('div:eq(1)').html();
} else if ($inner.find('h1:first').length > 0) {
idtitle = $inner.find('h1:first').html();
// <div class="iDevice"><div><h1>title</h1></div>
// <div class="iDevice"><div style="{big}">title</div>
// <div class="iDevice"><h1>title</h1>
$inner = $(this).children('div>div>h1');
if ($inner.length) {
$idtitle = $inner.first();
} else {
idtitle = $(this).children('div:eq(1)').html();
$inner = $(this).find('div[style*="font-size"]');
if ($inner.length) {
$idtitle = $inner.first();
} else {
$idtitle = $(this).find('h1:first');
}
}
// get rid of any wrapping span
$inner = $idtitle.find('span[class="mw-headline"]');
if ($inner.length) {
idtitle = $inner.html();
} else {
idtitle = $idtitle.html();
}
idtitle = $.trim(idtitle);
idbody = $(this).find('table:first tr td').html();
}
......
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