Commit 1e414867 authored by Dave Lane's avatar Dave Lane
Browse files

updated footer and versioning behaviour

parent 933292af
......@@ -4,7 +4,9 @@
const VERSION = "1.3.0",
JQUERY = "http://code.jquery.com/jquery-2.1.1.min.js",
FILEPATH = "/home/www/www";
FILEPATH = "/home/data/wikieducator/course-snapshot/src",
GENERATOR_URL = "https://git.oeru.org/wikieducator/course-snapshot",
GENERATOR = "OERu Course Snapshot";
var jsdom = require("jsdom"),
docopt = require("docopt").docopt,
......@@ -13,8 +15,7 @@ var jsdom = require("jsdom"),
path = require("path"),
wordpress = require("wordpress"),
uri = require("uri-js"),
iframes, h5p,
theme;
iframes, h5p, timestamp, generator, theme;
var pages = [], // list of page URLs to be processed
outline = [], // list of maps of page info
......@@ -89,16 +90,13 @@ const doc = `Usage:
`;
console.log('one...');
opt = docopt(doc, {exit: false});
console.log(
`========================= ${new Date().toJSON()} =========================`
);
console.log(opt);
// work out the base_url for Wiki pages
console.log('Outline = ', opt['OUTLINE']);
base_url = getBaseURL(opt);
console.log('base_url: ', base_url);
//
// deal with other options
if (opt["--theme"]) {
......@@ -185,15 +183,52 @@ if (opt["--wpurl"]) {
getOutline();
}
function setMetaName(head, name, content) {
var meta = '<meta name="' + name + '" content="' + content + '">';
console.log('setting new meta: ', meta);
head.append(meta);
}
function setAppMeta(head) {
setMetaName(head, "snapshot-generator", GENERATOR);
setMetaName(head, "snapshot-generator-version", VERSION);
setMetaName(head, "snapshot-generation-time", getTimestamp());
}
function getGenerator() {
var ts = getTimestamp();
var gen = '<a href="' + GENERATOR_URL + '" title="Created by ' + GENERATOR + ' version ' + VERSION + '">' + GENERATOR + '</a>, updated ' + ts;
return gen;
}
function getNotices(outlineItem, iconsrc) {
var divider = ' | ', disclaimer = "", contentURL = `${outlineItem.base_url}${outlineItem.wkpage}`;
if (opt['--disclaimer']) { disclaimer = ` ${divider} <a href="${opt['--disclaimer']}">Disclaimer</a>`; }
var notices = `<div class="links"><a href="https://oeru.org/terms-of-service">Terms of Service</a>${divider}<a href="https://oeru.org/privacy">Privacy Policy</a>${divider}<a href="https://wikieducator.org${outlineItem.wkpage}?action=history">Authors</a>${disclaimer}</div>`;
notices += `<div class="copyright"><a href="${contentURL}" title="original content in WikiEducator" target="WikiEducator">Content</a> available under the <a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/" title="CC-BY-SA 4.0 International">Creative Commons Attribution-ShareAlike</a> license. <a href="https://creativecommons.org/licenses/by-sa/4.0/"><img class="cc" src="${iconsrc}" alt="Creative Commons Attribution-ShareAlike license"></a></div>`;
generator = getGenerator();
notices += `<div class="generator">${generator}</div>`;
return notices;
}
function getTimestamp() {
if (timestamp != "") {
var d = new Date();
// timestamp = d.toLocaleString(); // "8/12/2013 18.55.38"
timestamp = d.toUTCString(); // "Sun, 08 Dec 2013 17:55:38 GMT"
}
return timestamp;
}
function getBaseURL(opt) {
let u = uri.parse(opt['OUTLINE']);
console.log('u: ', u);
base_url = u.scheme + '://' + u.host;
if (u.port) {
console.log("adding port: ", u.port);
base_url += ':' + u.port;
}
return base_url;
let u = uri.parse(opt['OUTLINE']);
console.log('u: ', u);
base_url = u.scheme + '://' + u.host;
if (u.port) {
console.log("adding port: ", u.port);
base_url += ':' + u.port;
}
return base_url;
}
function pageToURL(p) {
......@@ -509,8 +544,12 @@ function processPage(pi) {
}
});
// add our header stuff
var header = $("head");
setAppMeta(header);
// make stylesheet & Javascript references point to WikiEducator
$("head").find('link[rel="stylesheet"]').each(function() {
header.find('link[rel="stylesheet"]').each(function() {
var href = $(this).attr("href");
if (
href &&
......@@ -568,7 +607,9 @@ function processPage(pi) {
theme.header($, opt);
theme.footer($, opt, pages, pi, outline[pi]);
var iconsrc = $("#footer-copyrightico img").attr("src").replace("/icons/", "/buttons/");
var notices = getNotices(outline[pi], iconsrc);
theme.footer($, opt, pages, pi, outline[pi], notices, iconsrc);
theme.wrap($);
......
......@@ -39,11 +39,11 @@ module.exports = {
`);
},
footer: function($, opt, pages, pi, outlineItem) {
footer: function($, opt, pages, pi, outlineItem, notices, iconsrc) {
// use silver CC-BY-* buttons instead of Free Cultural Works orange
var iconsrc = $("#footer-copyrightico img")
/*var iconsrc = $("#footer-copyrightico img")
.attr("src")
.replace("/icons/", "/buttons/");
.replace("/icons/", "/buttons/");*/
var footerlogo = "",
contentURL = `${outlineItem.base_url}${outlineItem.wkpage}`;
if (opt['--logo']) {
......@@ -92,10 +92,11 @@ module.exports = {
}
// because there's always a subfooter, we'll put a divider on the bottom of the footer logo if there is one
if (footerlogo != "") { footerlogo = `<div class="logos">${footerlogo}</div><div class="clear" /><div class="rule"/>`; }
divider = ' | ';
/*divider = ' | ';
disclaimer = "";
if (opt['--disclaimer']) { disclaimer = ` ${divider} <a href="${opt['--disclaimer']}">Disclaimer</a>`; }
notices = `<div class="copyright"><a href="${contentURL}" title="original content in WikiEducator" target="WikiEducator">Content</a> is available under the <a rel="license" href="https://wikieducator.org/WikiEducator:Copyrights" title="WikiEducator:Copyrights">Creative Commons Attribution Share Alike License</a>. <a href="https://creativecommons.org/licenses/by-sa/4.0/"><img class="cc" src="${iconsrc}" alt="Creative Commons Attribution Share-Alike License"></a></div><div class="links"><a href="https://oeru.org/terms-of-service">Terms of Service</a>${divider}<a href="https://oeru.org/privacy">Privacy Policy</a>${divider}<a href="https://wikieducator.org${outlineItem.wkpage}?action=history">Authors</a>${disclaimer}</div>`;
//generator = '<div class="generator">Created <span class="timestamp">' + getTimestamp() + '</span>, <span class="generator">' + GENERATOR + '</span> version <span class="version">' + VERSION + '</span></div>'; */
$(".printfooter").remove();
$("body").append(`<footer>[oeru_advanced_footer content='${footerlogo}<div class="notices">${notices}</div>']</footer>`);
$("footer img.cc").attr("src", iconsrc);
......
Supports Markdown
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