From 3944308338cbc6c659f1f75b42701941d42d24c7 Mon Sep 17 00:00:00 2001
From: Arnaud Legrand
Date: Tue, 26 Mar 2019 09:29:07 +0100
Subject: [PATCH] [HTML] Move all the grunt work to perl and produce a nice
looking index
---
.gitlab-ci.yml | 5 +-
bin/pandoc_fixer.pl | 193 ++++++++++++++++++++++++++------------------
gitlab-ci.org | 117 +--------------------------
3 files changed, 115 insertions(+), 200 deletions(-)
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index d6e0252..6df84ed 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -5,14 +5,11 @@ pages:
- pandoc --version
# - pandoc --help
# - pandoc --list-input-formats # Broken as pandoc dates from 2013 on this image! :(
+ - bin/pandoc_fixer.pl html_src_files.lst;
- for file in `cat html_src_files.lst | sed 's/#.*//g' `; do
- bin/pandoc_fixer.pl ${file};
- echo "Creating" public/`dirname ${file}`;
mkdir -p public/`dirname ${file}`;
mv ${file%.*}.html public/`dirname ${file}`/;
done
- - cat html_src_files.lst | sed -e 's|\.md |.html |' -e 's|\.org |\.html |' -e 's|^./\([^ ]*\) *# *\([^ ]*\)|- [[./\1]] (\2)|' > index.org
- - pandoc -s -f org -t html -o public/index.html index.org
- cd module2/ressources/; tar zcf rr_org_archive.tgz rr_org/init.el rr_org/journal.org rr_org/init.org ; cd ../.. ; mv module2/ressources/rr_org_archive.tgz public/module2/ressources/
- cd module2/ressources/; make -C replicable_article/ all ../replicable_article.tgz ; cd ../.. ; mv module2/ressources/replicable_article.tgz public/module2/ressources/
artifacts:
diff --git a/bin/pandoc_fixer.pl b/bin/pandoc_fixer.pl
index 9c2e05b..810de0f 100755
--- a/bin/pandoc_fixer.pl
+++ b/bin/pandoc_fixer.pl
@@ -1,95 +1,128 @@
#!/usr/bin/perl -w
use strict;
-my($usage) = "Usage: pandox_fixer.pl input.md";
+my($usage) = "Usage: pandox_fixer.pl org_md_files.lst";
($#ARGV==0) or die $usage;
-my($input)=shift(@ARGV);
-
-########### Git date #################
-my($gitdate)=`git log --date=short $input | grep Date | head -n 1`;
-chomp($gitdate);
-$gitdate =~ s/Date: *//g;
-$gitdate =~ s/\s*\+.*$//g;
-
-########### Input file ###############
-my($type) = "";
-my($output) = $input;
-if($input =~ /.md$/) {
- $type = "gfm";
- $output =~ s/.md$/.html/;
-} elsif ($input =~ /.org$/) {
- $type = "org";
- $output =~ s/.org$/.html/;
-} else {
- die "Usage: pandox_fixer.pl input.md";
-}
-my($output_temp) = $output."tmp";
-
-########### URL Fixing ###############
-
-my($input_path)=$input;
-$input_path =~ s|/[^/]*$||g;
-my($raw_path) = "https://gitlab.inria.fr/learninglab/mooc-rr/mooc-rr-ressources/raw/master/".$input_path;
-my($raw_path_percent) = $raw_path; $raw_path_percent =~ s/^http/%/g;
-my($tree_path) = "https://gitlab.inria.fr/learninglab/mooc-rr/mooc-rr-ressources/tree/master/".$input_path;
-my($pages_path) = "https://learninglab.gitlabpages.inria.fr/mooc-rr/mooc-rr-ressources/".$input_path;
-my($pages_path_percent) = $pages_path; $pages_path_percent =~ s/^http/%/g;
-my($gitlab_origin)= "https://gitlab.inria.fr/learninglab/mooc-rr/mooc-rr-ressources/blob/master/";
-
-########### Pandoc #################
-
-print "Exporting $input\n";
-my($pandoc_output) = `LANG=C ; pandoc -s --mathjax -f $type -t html -o $output_temp $input`;open INPUT, $output_temp or die;
-open OUTPUT, "> ".$output or die;
-
-
-while(defined(my $line=)) {
- if($line =~ /
.*broken-links:nil/) { next; }
-
-# $line =~ s|https://gitlab.inria.fr/learninglab/|https://learninglab.gitlabpages.inria.fr/|g; ## Not such a good idea!
- if($line =~ /
.*broken-links:nil/) { next; }
+
+ # $line =~ s|https://gitlab.inria.fr/learninglab/|https://learninglab.gitlabpages.inria.fr/|g; ## Not such a good idea!
+ if($line =~ /