18
0
mirror of https://github.com/c3d2/slidenado/ synced 2024-06-19 22:25:59 +02:00

moar generation goodness

This commit is contained in:
Astro 2016-07-06 19:25:46 +02:00
parent 642833bbab
commit 86fef07844
6 changed files with 35 additions and 19 deletions

View File

@ -1,5 +1,6 @@
ALL: $(patsubst lectures/%.yaml, lectures/%, $(wildcard lectures/*.yaml))
ALL: $(patsubst dates/%.yaml, dates/%, $(wildcard dates/*.yaml))
lectures/%: lectures/%.yaml
mkdir $@
dates/%: dates/%.yaml
mkdir -p $@
./generate.rb $< $@
make -C $@

View File

@ -1,3 +0,0 @@
\title{Digitale Selbstverteidigung}
\author{\small Marius \\\large Chaos Computer Club Dresden}
\date{22.06.2016}

6
dates/16_06_22.yaml Normal file
View File

@ -0,0 +1,6 @@
title: Digitale Selbstverteidigung
author: Marius
organization: Chaos Computer Club Dresden
date: 22.06.2016
deck: digitale-selbstverteidigung.yaml

View File

@ -1,19 +1,29 @@
#!/usr/bin/env ruby
require 'yaml'
require 'erb'
# Load files
lecture_path = ARGV[0]
lecture = YAML::load_file lecture_path
sections = YAML::load_file File.join(File.dirname(lecture_path), lecture['sections'])
section_files = []
sections.each do |name, files|
p :name => name, :files => files
section_files.push *files
lecture = YAML.load_file lecture_path
deck = YAML.load_file File.join("decks", lecture['deck'])
# Convert pathes to be relative to outdir_path
deck.each do |name, files|
files.map! do |f|
File.join("..", "..", "content", f)
end
end
# Prepare flat list of included .tex files
deck_files = []
deck.each do |name, files|
deck_files.push *files
end
outdir_path = ARGV[1]
# TODO: convert to erb as well?
File.write File.join(outdir_path, "Makefile"), <<EOF
slides.pdf: slides.tex #{section_files.join " "}
\tpdflatex $<
EOF
makefile_template = ERB.new(File.read("makefile_template.erb"))
File.write File.join(outdir_path, "Makefile"), makefile_template.result
latex_template = ERB.new(File.read("latex_template.tex.erb"))
File.write File.join(outdir_path, "slides.tex"), latex_template.result

View File

@ -28,11 +28,11 @@
\begin{document}
\maketitle
<% @deck.each do |section, snippets| %>
<% deck.each do |section, snippets| %>
\section{<%= section %>}
\subsection{}
<% snippets.each do |snippet| %>
\include{<%= snippet %>}
\input{<%= snippet.sub(/\.tex$/, "") %>}
<% end %>
<% end %>

2
makefile_template.erb Normal file
View File

@ -0,0 +1,2 @@
slides.pdf: slides.tex <%= deck_files.join " " %>
pdflatex $<