Commit 141a7554 authored by Gerson Sunyé's avatar Gerson Sunyé

Add support to generate a PDF document from Asciidoc documents

Add a new asciidoc file for joining all others.
Add a Makefile to generate PDFs.
Remove unused files.
parent 49032121
Pipeline #15862 passed with stages
in 44 seconds
......@@ -3,3 +3,4 @@ source 'https://rubygems.org'
gem 'asciidoctor'
gem 'asciidoctor-revealjs'
gem 'asciidoctor-diagram'
gem 'asciidoctor-pdf'
# Generated on 2017-12-29 using generator-reveal 1.0.0
module.exports = (grunt) ->
grunt.initConfig
pkg: grunt.file.readJSON 'package.json'
watch:
livereload:
options:
livereload: true
files: [
'index.html'
'slides/{,*/}*.{md,html}'
'js/*.js'
'resources/**'
]
index:
files: [
'templates/_index.html'
'templates/_section.html'
'slides/list.json'
]
tasks: ['buildIndex']
coffeelint:
files: ['Gruntfile.coffee']
tasks: ['coffeelint']
jshint:
files: ['js/*.js']
tasks: ['jshint']
connect:
livereload:
options:
port: 9000
base: '.'
open: true
livereload: true
coffeelint:
options:
indentation:
value: 4
max_line_length:
level: 'ignore'
all: ['Gruntfile.coffee']
jshint:
options:
jshintrc: '.jshintrc'
all: ['js/*.js']
copy:
dist:
files: [{
expand: true
src: [
'slides/**'
'bower_components/**'
'js/**'
'resources/**'
]
dest: 'public/'
},{
expand: true
src: ['index.html']
dest: 'public/'
filter: 'isFile'
}]
buildcontrol:
options:
dir: 'dist'
commit: true
push: true
message: 'Built from %sourceCommit% on branch %sourceBranch%'
pages:
options:
remote: '<%= pkg.repository.url %>'
branch: 'gh-pages'
# Load all grunt tasks.
require('load-grunt-tasks')(grunt)
grunt.registerTask 'buildIndex',
'Build index.html from templates/_index.html and slides/list.json.',
->
indexTemplate = grunt.file.read 'templates/_index.html'
sectionTemplate = grunt.file.read 'templates/_section.html'
slides = grunt.file.readJSON 'slides/list.json'
html = grunt.template.process indexTemplate, data:
slides:
slides
section: (slide) ->
grunt.template.process sectionTemplate, data:
slide:
slide
grunt.file.write 'index.html', html
grunt.registerTask 'test',
'*Lint* javascript and coffee files.', [
'coffeelint'
'jshint'
]
grunt.registerTask 'serve',
'Run presentation locally and start watch process (living document).', [
'buildIndex'
'connect:livereload'
'watch'
]
grunt.registerTask 'dist',
'Save presentation files to *dist* directory.', [
'test'
'buildIndex'
'copy'
]
grunt.registerTask 'deploy',
'Deploy to Github Pages', [
'dist'
'buildcontrol'
]
# Define default task.
grunt.registerTask 'default', [
'test'
'serve'
]
SLIDE_DIR := src/asciidoc
SITE_DIR := target/site
BOOK_DIR := target/book
RESOURCE_SOURCE_DIR := src/images
RESOURCE_TARGET_DIR := $(SITE_DIR)/images
# Reveal.js
REVEALJS_DIR=$(SITE_DIR)/reveal.js
MDE=$(SITE_DIR)/mde-languages.min.js
STEREOPTICON=$(REVEALJS_DIR)/css/theme/stereopticon.css
SLIDE_SOURCES := $(wildcard $(SLIDE_DIR)/*.adoc)
SLIDE_TARGETS := $(patsubst $(SLIDE_DIR)/%.adoc, $(SITE_DIR)/%.html, $(SLIDE_SOURCES))
.PHONY: clean slides book
$(SITE_DIR)/%.html: $(SLIDE_DIR)/%.adoc
@echo '[Generating Reveal.js website]'
bundle exec asciidoctor-revealjs \
-r asciidoctor-diagram \
-o $@ $<
$(BOOK_DIR)/book.pdf: src/book/asciidoc/book.adoc
@echo '[Generating PDF files]'
bundle exec asciidoctor-pdf \
-r asciidoctor-diagram \
--attribute imagesdir=../../images \
--attribute allow-uri-read=true \
-o $@ $<
slides: resources $(SLIDE_TARGETS)
book: $(BOOK_DIR)/book.pdf
resources: prepare
@echo '[Preparing resources]'
mkdir -p $(RESOURCE_TARGET_DIR)
rsync -r $(RESOURCE_SOURCE_DIR)/ $(RESOURCE_TARGET_DIR)
prepare: $(REVEALJS_DIR) $(STEREOPTICON) $(MDE)
$(REVEALJS_DIR):
git clone -b 3.9.2 --depth 1 https://github.com/hakimel/reveal.js.git $(REVEALJS_DIR) 2> /dev/null || (cd $(REVEALJS_DIR) ; git pull)
$(MDE):
wget --directory-prefix=$(SITE_DIR) https://github.com/highlightjs/highlightjs-mde-languages/releases/download/0.1.0/mde-languages.min.js
$(STEREOPTICON):
cd $(REVEALJS_DIR); curl -sL https://gitlab.univ-nantes.fr/bousse-e/stereopticon/raw/master/install-or-update-stereopticon.sh | bash -
clean:
rm -rf $(SITE_DIR)
{
"name": "software-construction-and-evolution",
"version": "0.0.1",
"dependencies": {
"reveal.js": "~3.3.0",
"highlightjs": "~9.0.0"
}
}
// Modified from markdown.js from Hakim to handle external html files
(function () {
/*jslint loopfunc: true, browser: true*/
/*globals alert*/
'use strict';
var querySlidingHtml = function () {
var sections = document.querySelectorAll('[data-html]'),
section, j, jlen;
for (j = 0, jlen = sections.length; j < jlen; j++) {
section = sections[j];
if (section.getAttribute('data-html').length) {
var xhr = new XMLHttpRequest(),
url = section.getAttribute('data-html'),
cb = function () {
if (xhr.readyState === 4) {
if (
(xhr.status >= 200 && xhr.status < 300) ||
xhr.status === 0 // file protocol yields status code 0 (useful for local debug, mobile applications etc.)
) {
section.innerHTML = xhr.responseText;
} else {
section.outerHTML = '<section data-state="alert">ERROR: The attempt to fetch ' + url + ' failed with the HTTP status ' + xhr.status + '. Check your browser\'s JavaScript console for more details.</p></section>';
}
}
};
xhr.onreadystatechange = cb;
xhr.open('GET', url, false);
try {
xhr.send();
} catch (e) {
alert('Failed to get file' + url + '.' + e);
}
}
}
};
querySlidingHtml();
})();
:sectnums: true
= Software Construction and Evolution
include::../../asciidoc/construction.adoc[leveloffset=+1]
include::../../asciidoc/mapping.adoc[leveloffset=+1]
include::../../asciidoc/behavior.adoc[leveloffset=+1]
include::../../asciidoc/build.adoc[leveloffset=+1]
include::../../asciidoc/patterns.adoc[leveloffset=+1]
include::../../asciidoc/refactorings.adoc[leveloffset=+1]
include::../../asciidoc/test.adoc[leveloffset=+1]
include::../../asciidoc/evolution.adoc[leveloffset=+1]
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Software Construction and Evolution</title>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui"/>
<link rel="stylesheet" href="bower_components/reveal.js/css/reveal.css"/>
<link rel="stylesheet" href="resources/css/custom.css"/>
<link rel="stylesheet" href="bower_components/reveal.js/css/theme/simple.css" id="theme"/>
<!-- For syntax highlighting -->
<link rel="stylesheet" href="bower_components/highlightjs/styles/zenburn.css"/>
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'bower_components/reveal.js/css/print/pdf.css' : 'bower_components/reveal.js/css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
<!--[if lt IE 9]>
<script src="bower_components/reveal.js/lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<div class="slides">
<% _.forEach(slides, function(slide) { %>
<% if (!_.isArray(slide)) { %>
<%= section(slide) %>
<% } %>
<% if (_.isArray(slide)) { %>
<section>
<% _.forEach(slide, function(verticalslide) { %>
<%= section(verticalslide) %>
<% }); %>
</section>
<% } %>
<% }); %>
</div>
</div>
<script src="bower_components/reveal.js/lib/js/head.min.js"></script>
<script src="bower_components/reveal.js/js/reveal.js"></script>
<script>
// Full list of configuration options available at:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
slideNumber: true,
width: 1280,
height: 800,
margin:0,
transition: 'slide', // none/fade/slide/convex/concave/zoom
// Optional reveal.js plugins
dependencies: [
{ src: 'bower_components/reveal.js/lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'bower_components/reveal.js/plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'bower_components/reveal.js/plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'bower_components/reveal.js/plugin/highlight/highlight.js', async: true, condition: function() { return !!document.querySelector( '[data-html]' ) || !!document.querySelector( 'pre code' ) || !!document.querySelector( '[data-markdown]' ); }, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'bower_components/reveal.js/plugin/zoom-js/zoom.js', async: true },
{ src: 'bower_components/reveal.js/plugin/notes/notes.js', async: true },
{ src: 'js/loadhtmlslides.js', condition: function() { return !!document.querySelector( '[data-html]' ); } }
]
});
</script>
</body>
</html>
<% if (!_.isString(slide) && !_.isArray(slide) && _.isObject(slide)) { %>
<section <%= _.map(slide.attr, function (val, attr) {return attr + '="' + val + '"'}).join(' ')%> <% if (_.isString(slide.filename)) { %>data-<% if (slide.filename.indexOf('.html') !== -1) { %>html<% } else { %>markdown<% }%>="slides/<%= slide.filename %>"<% } %>></section>
<% } %><% if (_.isString(slide)) { %>
<section data-<% if (slide.indexOf('.html') !== -1) { %>html<% } else { %>markdown<% }%>="slides/<%= slide %>" data-separator="^\n---$" data-separator-vertical="^\n----$"></section>
<% } %>
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