Commit 3de15a02 authored by Dave Lane's avatar Dave Lane

addressed in-page anchor URL issue, updated all references to http://wikieducator.org to https://

parent c334001e
......@@ -3,6 +3,5 @@
nice node course.js --prevnext --brand MUN \
--logo example.png --link http://example.com/ \
--urlprefix /MUN \
http://wikieducator.org/MUN/Outline \
https://wikieducator.org/MUN/Outline \
/MUN
......@@ -4,6 +4,5 @@ nice node courseWP.js --prevnext --brand Art \
--theme newSplashWP \
--link https://www.tru.ca/ \
--logo https://wikieducator.org/images/e/ef/Thompson_Rivers_University.png \
http://wikieducator.org/Art_Appreciation_and_Techniques/Outline_demo \
https://wikieducator.org/Art_Appreciation_and_Techniques/Outline_demo \
"/Art Appreciation and Techniques"
......@@ -59,7 +59,7 @@ root (so that the course files can be served to users).
{--theme THEMENAME} \
{--logo logopath} \
{--link http://link-for-logo} \
http://WikiEducator.org/OutlinePage \
https://wikieducator.org/OutlinePage \
/localfilesystem/path
### WordPress snapshot
......@@ -77,13 +77,13 @@ root (so that the course files can be served to users).
{--siteid SITEID} \
{--wiki base_url} \
{--debugout} \
http://wikieducator.org/path-to-outline-page \
https://wikieducator.org/path-to-outline-page \
"/Course name"
## N.B.
These scripts are *simple examples* of
[ways you might make snapshots](http://wikieducator.org/User:JimTittsler/Theming#Course_Snapshot)
[ways you might make snapshots](https://wikieducator.org/User:JimTittsler/Theming#Course_Snapshot)
of course-sized open educational resources stored in WikiEducator.
I expect that different institutions (and even different courses
within an institution) will have different needs, organizations, and
......@@ -91,4 +91,4 @@ 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.
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.
......@@ -29,7 +29,7 @@ var pages = [], // list of page URLs to be processed
urls = {}, // map of original URLs to course URLs
parent_ids = {}, // map from URL to wp page id
pi = 0, // process index
base_url = "http://wikieducator.org", // no trailing slash
base_url = "https://wikieducator.org", // no trailing slash
wp,
opt,
doc = `Usage:
......@@ -354,7 +354,7 @@ function processPage(pi) {
href.charAt(0) === "/" &&
href.charAt(1) !== "/"
) {
$(this).attr("href", "http://wikieducator.org" + href);
$(this).attr("href", "https://wikieducator.org" + href);
}
});
$("html").find("script[src]").each(function() {
......@@ -365,7 +365,7 @@ function processPage(pi) {
href.charAt(0) === "/" &&
href.charAt(1) !== "/"
) {
$(this).attr("src", "http://wikieducator.org" + href);
$(this).attr("src", "https://wikieducator.org" + href);
}
});
// add user fetch
......@@ -395,7 +395,7 @@ function processPage(pi) {
var req = new XMLHttpRequest();
window.wgUserLoading = 1;
req.onload = gotUser;
req.open("get", "http://wikieducator.org/api.php?action=query&meta=userinfo&uiprop=realname&format=json");
req.open("get", "https://wikieducator.org/api.php?action=query&meta=userinfo&uiprop=realname&format=json");
req.send();
}());
</script>`);
......@@ -515,7 +515,7 @@ function processPage(pi) {
src.indexOf("//") !== 0 &&
src.indexOf("/wp") !== 0
) {
$(this).attr("src", "http://WikiEducator.org" + src);
$(this).attr("src", "https://wikieducator.org" + src);
}
});
$("script").remove();
......
......@@ -111,6 +111,9 @@ if (opt["--wpurl"]) {
opt["--urlprefix"] = "";
// split into hostname and URI within host
let wpURLparts = opt["--wpurl"].replace(/^(https?:)?\/\//, "").split("/", 2);
console.log("============ wpURLparts ==============");
console.log(wpURLparts);
console.log("============ /wpURLparts ==============");
if (wpURLparts.length === 2 && wpURLparts[1]) {
// remove any trailing slash
opt["--urlprefix"] = "/" + wpURLparts[1].replace(/\/$/, "");
......@@ -124,10 +127,10 @@ if (opt["--wpurl"]) {
}
function pageToURL(p) {
return (
opt["--urlprefix"] +
p.replace(opt.PAGEPREFIX, "").replace("?", "").replace("%3F", "")
);
val = opt["--urlprefix"] +
p.replace(opt.PAGEPREFIX, "").replace("?", "").replace("%3F", "");
console.log('converting '+p+' into '+val);
return (val);
}
function courseURLToFile(u) {
......@@ -319,12 +322,24 @@ function processPage(pi) {
// rejig the URLs we are moving
$("a").each(function(i, e) {
var orig = $(this).attr("href");
//console.log("checking if orig = "+orig+" is a known outline page...");
if (urls.hasOwnProperty(orig)) {
//console.log('replacing value of '+orig+' with '+urls[orig]);
$(this).attr("href", urls[orig]);
} else if (typeof orig === 'string' && orig.indexOf('#') != -1) {
// if the # is the first character, we need to use the
console.log('Found a # anchor! - '+orig);
if (orig.indexOf('#') == 0) {
//console.log('URI starts with a #!');
}
} else {
//console.log('orig "'+orig+'" isn\'t listed in the urls array');
// other WikiEducator relative pages that are not in the outline
if (orig && orig.indexOf("//") === -1) {
$(this).attr("href", "//wikieducator.org" + orig);
console.log(orig+' is another relative wikieducator page, so we\'re giving it a url based on '+base_url+'.');
//$(this).attr("href", "//wikieducator.org" + orig);
//$(this).attr("href", "//TEST" + orig);
$(this).attr("href", base_url + orig);
}
}
});
......@@ -389,7 +404,8 @@ function processPage(pi) {
href.charAt(0) === "/" &&
href.charAt(1) !== "/"
) {
$(this).attr("href", "https://wikieducator.org" + href);
//$(this).attr("href", "https://wikieducator.org" + href);
$(this).attr("href", base_url + href);
}
});
$("html").find("script[src]").each(function() {
......@@ -400,12 +416,13 @@ function processPage(pi) {
href.charAt(0) === "/" &&
href.charAt(1) !== "/"
) {
$(this).attr("src", "https://wikieducator.org" + href);
// $(this).attr("src", "https://wikieducator.org" + href);
$(this).attr("src", base_url + href);
}
});
// add user fetch
$('meta[charset="UTF-8"]').after(`
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="X-UA-Compatible-TEST!" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script>
(function() {
......@@ -430,7 +447,7 @@ function processPage(pi) {
var req = new XMLHttpRequest();
window.wgUserLoading = 1;
req.onload = gotUser;
req.open("get", "https://wikieducator.org/api.php?action=query&meta=userinfo&uiprop=realname&format=json");
req.open("get", "`+base_url+`/api.php?action=query&meta=userinfo&uiprop=realname&format=json");
req.send();
}());
</script>`);
......@@ -565,7 +582,8 @@ function processPage(pi) {
src.indexOf("//") !== 0 &&
src.indexOf("/wp") !== 0
) {
$(this).attr("src", "https://WikiEducator.org" + src);
//$(this).attr("src", "https://WikiEducator.org" + src);
$(this).attr("src", base_url + src);
}
});
$("script").remove();
......@@ -575,8 +593,8 @@ function processPage(pi) {
.append($("footer"))
.html();
pagename = path.basename(outline[pi].text).replace("Practice:OCL4Ed", "");
console.log(`pagename=${pagename}`);
console.log(outline[pi]);
//console.log(`pagename=${pagename}`);
//console.log(outline[pi]);
if (pagename === "" && !outline[pi].slug) {
setImmediate(processPages);
return;
......@@ -722,21 +740,25 @@ function getOutline() {
}
linked = false;
}
console.log('pushing wkpage '+wkpage);
pages.push(wkpage);
if (opt["--wpurl"]) {
url = slugify(text);
if (path) {
url = baseurl + "/" + url;
}
console.log('path = '+path+', url = '+url);
} else {
url = pageToURL(wkpage);
}
url = opt["--urlprefix"] + url;
console.log('adding url '+url+' for wikipage '+wkpage);
urls[wkpage] = url;
hasPage = true;
} else {
// item has no link, so not a real page
wkpage = $(this).contents().eq(0).text().trim();
console.log('not a real page: '+wkpage);
text = wkpage;
if (opt["--wpurl"]) {
url = slugify(text);
......
......@@ -16,7 +16,7 @@ $(function() {
function iFrameSrc(s) {
var $iframeDiv = $('#WEregistrationIFrameDiv');
$iframeDiv.find('iframe')
.attr('src', 'http://wikieducator.org/index.php?returnto=Course&title=Special:User' + s);
.attr('src', 'https://wikieducator.org/index.php?returnto=Course&title=Special:User' + s);
$iframeDiv.find('h4').text('WikiEducator ' + s);
}
......@@ -30,7 +30,7 @@ $(function() {
<h4>WikiEducator login</h4>\n\
</div>\n\
<div class="modal-body">\n\
<iframe src="http://wikieducator.org/index.php?title=Special:UserLogin&returnto=Course" width=500 height=510></iframe>\n\
<iframe src="https://wikieducator.org/index.php?title=Special:UserLogin&returnto=Course" width=500 height=510></iframe>\n\
</div>\n\
</div>\n\
</div>\n\
......@@ -59,7 +59,7 @@ $(function() {
// registration page
if ($('div.WEcourseRegistration').length) {
$('body').append('<div id="WEregistrationIFrame">\n\
<iframe src="http://wikieducator.org/index.php?title=Special:UserLogin&returnto=Practice:OCL4Ed/_Registration" width=500 height=520></iframe>\n\
<iframe src="https://wikieducator.org/index.php?title=Special:UserLogin&returnto=Practice:OCL4Ed/_Registration" width=500 height=520></iframe>\n\
</div>\n');
}
if ($('#WEcourseFormGoLogin').length) {
......@@ -119,10 +119,10 @@ $(function() {
}
// activate the current location in the SCAN page
//loc = window.location.href.replace('http://wikieducator.org', '');
//loc = window.location.href.replace('https://wikieducator.org', '');
old = window.location.href;
loc = window.location.href.replace('wikieducator.org', '');
console.log('************* old:'+old+'->loc:'+loc);
console.log('************* old:'+old+'->loc:'+loc+' and just for fun, base_url = '+base_url);
$('#scanpage a[href="' + loc + '"]').addClass('active')
.addClass('btn-success')
.removeClass('btn-primary')
......
......@@ -39,7 +39,7 @@ module.exports = {
'"></a></div>'
);
$("#footer-places").append(
'<li><a href="http://wikieducator.org' +
'<li><a href="https://wikieducator.org' +
pages[pi] +
'?action=history">Authors</a></li>'
);
......
......@@ -60,7 +60,7 @@ module.exports = {
'" alt="institution logo"></a></div>'
);
/*
$('#footer-places').append('<li><a href="http://wikieducator.org' + pages[pi] + '?action=history">Authors</a></li>');
$('#footer-places').append('<li><a href="https://wikieducator.org' + pages[pi] + '?action=history">Authors</a></li>');
// move the license icon
$('#footer-copyrightico').detach()
.appendTo('#footer-places');
......@@ -72,16 +72,16 @@ module.exports = {
<div class="row">\n\
<div class="col-md-6">\n\
<div class="footertext">Content is available under the \n\
<a rel="license" href="http://WikiEducator.org/WikiEducator:Copyrights" title="WikiEducator:Copyrights">Creative Commons Attribution Share Alike License</a>.\n\
<a rel="license" href="https://wikieducator.org/WikiEducator:Copyrights" title="WikiEducator:Copyrights">Creative Commons Attribution Share Alike License</a>.\n\
</div>\n\
<div class="footertext"><a href="http://wikieducator.org/WikiEducator:Privacy_policy">Privacy Policy</a> | <a href="http://wikieducator.org' +
<div class="footertext"><a href="https://wikieducator.org/WikiEducator:Privacy_policy">Privacy Policy</a> | <a href="https://wikieducator.org' +
pages[pi] +
'?action=history">Authors</a><a href="http://creativecommons.org/licenses/by-sa/3.0/"><img class="cc" src="' +
'?action=history">Authors</a><a href="https://creativecommons.org/licenses/by-sa/3.0/"><img class="cc" src="' +
p +
'CC-BY-SA.png" alt="Creative Commons Attribution Share-Alike License"></a></div>\n\
</div>\n\
<div class="col-md-6">\n\
<a href="http://' +
<a href="https://' +
opt["--link"] +
'">\n\
<img src="' +
......@@ -441,7 +441,7 @@ module.exports = {
$("a.image").each(function() {
var dst = $(this).attr("href");
if (dst.indexOf("/File:") === 0) {
$(this).attr("href", "http://WikiEducator.org" + dst);
$(this).attr("href", "https://wikieducator.org" + dst);
}
});
// FIXME images should be uploaded to Wordpress rather than hotlinked
......@@ -461,7 +461,7 @@ module.exports = {
dst.charAt(0) === "/" &&
dst.charAt(1) !== "/"
) {
dst = "//WikiEducator.org" + dst;
dst = "//wikieducator.org" + dst;
$(this).attr("src", dst);
// FIXME rewrite sourceset srcs rather than removing them
$(this).removeAttr("srcset");
......
......@@ -41,10 +41,10 @@ if row is None:
opt = json.loads(row['opt'])
inoutline = opt['outline'].strip()
if not inoutline.lower().startswith('http://wikieducator.org'):
if not inoutline.lower().startswith('https://wikieducator.org'):
if inoutline[0] <> '/':
inoutline = '/' + inoutline
opt['outline'] = 'http://wikieducator.org' + inoutline
opt['outline'] = 'https://wikieducator.org' + inoutline
# mark in progress
c.execute("""UPDATE mw_snapshot
......@@ -141,4 +141,3 @@ else:
Please check the URL, username, and password.\n"""
% (opt['outline'].encode('utf-8'), )
)
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