Commit f1208545 authored by eric's avatar eric
Browse files

Update documentation now that publication is archived

parent 8c32a731
Relearn Publication
===================
Script that generates a publication off of http://relearn.be
The relearn 2013 web publication, and a script to generate a PDF print publication
based on these HTML files.
If you have PhantomJS and CasperJS installed, you can run the script like this:
Consult the online version at <http://relearn.be/2013/>
Download the pdf at <http://relearn.be/media/relearn-2013.pdf>
We were first editing this publication dynamically using Ethertoff
and then switched to static HTML files that you can find in this repository.
To generate the publication we rely on the Table of Contents specified
in `toc.json`. We send a ‘headless browser’ to visit all pages specified
in this file and to print them to pdf. The headless browser we use is
called PhantomJS and we use CasperJS to provide an easy to read script.
If you have PhantomJS and CasperJS installed, you can run this script like this:
casperjs render.js
......
// To generate the publication we rely on the Table of Contents specified
// in `toc.json`. We send a ‘headless browser’ to visit all pages specified
// in this file and to print them to pdfs.
//
// Run this script with the following command line: `casperjs render.js`
//
// Output files will be stored in the folder `render`
//
var fs = require('fs');
var casper = require('casper').create({
......
This is where the separate page PDF’s will be stored temporarily
var casper = require('casper').create({
viewportSize : {width: 1190, height: 873},
verbose: true,
logLevel: "debug"
});
var counter = 2;
var makeUris = function(names) {
var uris = [];
for (var i=0; i<names.length; i++) {
uris.push('http://127.0.0.1:8000/r/' + names[i]);
}
return uris;
}
var deUri = function(uri) {
return uri.replace('http://127.0.0.1:8000/r/', '');
}
var test = ['test::first-test', 'worksession'];
casper.start()
casper.page.paperSize = { format: 'A5', orientation: 'portrait',
margin: {
left : "25mm",
top : "6mm",
right : "9mm",
bottom : "6mm"
}
};
/*
casper.thenOpen('http://127.0.0.1:8000/', function() {
this.echo("Start RELEARN PDF generation");
this.evaluate(function() {
$("#content").html("<h1>1. General test</h1>");
});S
this.capture('render/01-01-Test test.pdf');
this.evaluate(function() {
$("body").prepend('<div class="title" id="cover"><h1>This is the cover that covers the cover</h1><h2>Relearn - A general publication (soon)</h2></div>')
});
this.capture('render/00-Cover.pdf');
});
*/
casper.thenOpen('http://relearn.be/', function() {
this.echo("Start RELEARN PDF generation");
this.evaluate(function() {
$("#content").html('<p class="titlepages">1. Introduction</p>');
});
this.capture('render/01-01-Introduction.pdf');
this.evaluate(function() {
$("#content").html('<p class="titlepages">2. Worksessions</p>');
});
this.capture('render/02-01-Worksessions.pdf');
this.evaluate(function() {
$("#content").remove();
$("body").prepend('<div class="print-only" id="cover"><p class="covertitle">This is the cover that covers the cover</p><p class ="coversubtitle">Relearn - A general publication (soon)</p></div>')
});
this.capture('render/00-Cover.pdf');
});
casper.eachThen(makeUris(test), function(response) {
this.echo(deUri(response.data));
this.thenOpen(response.data, function(response) {
this.capture('render/01-0' + counter + '-' + deUri(response.url) + '.pdf');
});
counter += 1;
});
casper.run();
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