Commit dd929d2d authored by Jim Tittsler's avatar Jim Tittsler

course: Fix wiki page name to file name mapping.

Remove more punctuation/non-ASCII characters when
wiki page names are mapped to filesystem names.
Similar to #4
parent 8df81db1
......@@ -2,8 +2,7 @@
nice node course.js --prevnext --brand MUN \
--logo example.png --link http://example.com/ \
--urlprefix /MUN \
http://wikieducator.org/MUN/Outline \
/MUN \
/MUN \
>/tmp/course-AMUN.txt
/MUN
......@@ -2,9 +2,9 @@
/* jshint node: true, multistr: true, trailing: true, esnext: true */
"use strict";
var VERSION = "0.7.2",
var VERSION = "0.7.3",
JQUERY = "http://code.jquery.com/jquery-2.1.1.min.js",
FILEPATH = ""; // should be '/home/www/www' on WE
FILEPATH = "/tmp"; // should be '/home/www/www' on WE
var jsdom = require("jsdom"),
docopt = require("docopt").docopt,
......@@ -77,25 +77,23 @@ if (opt["--wpurl"]) {
opt["--urlprefix"] = "";
getOutline();
} else {
if (opt["--urlprefix"].indexOf("/course") !== 0) {
if (opt["--urlprefix"] && opt["--urlprefix"].indexOf("/course") !== 0) {
opt["--urlprefix"] = "/course" + opt["--urlprefix"];
}
getOutline();
}
function pageToURL(p) {
return (
opt["--urlprefix"] +
p.replace(opt.PAGEPREFIX, "").replace("?", "").replace("%3F", "")
);
p = p
.replace(/%../g, "")
.replace(/ - /g, "-")
.replace(/[ _:;]/g, "-")
.replace(/[^-/a-zA-Z0-9]/g, "");
return opt["--urlprefix"] + p;
}
function courseURLToFile(u) {
return (
FILEPATH +
opt["--urlprefix"] +
u.replace(opt.PAGEPREFIX, "").replace("?", "").replace("%3F", "")
);
return FILEPATH + pageToURL(u);
}
// FIXME apply real Wordpress slug conversion rules
......
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