diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d6e02528f4f405b818c7bb78a1c043965e4fb593..6df84ed04a3da35eba2d8cdd5c66e196e74d7ece 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 9c2e05b96d2d63d5e1d873526213c0434bd283d9..810de0fd023e654de1c5bcb7a93ab519b1bd931e 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 =~ //) { - if($output=~ /_fr.html/) { - $line =~ s||Les sources de ce document sont disponibles sur gitlab.|g; - $line .= "
Version du $gitdate.


\n" - } else { - $line =~ s||The source of this document is available on gitlab.|g; - $line .= "
Last version: $gitdate

\n" - } +sub pandoc_export { + my($input)=shift(@_); + ########### 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"; } - $line =~ s|TOC||g; + 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 =~ //) { + if($output=~ /_fr.html/) { + $line =~ s||Les sources de ce document sont disponibles sur gitlab.|g; + $line .= "
Version du $gitdate.


\n" + } else { + $line =~ s||The source of this document is available on gitlab.|g; + $line .= "
Last version: $gitdate

\n" + } + } + $line =~ s|TOC||g; + + $line =~ s|---

|
|g; + # $line =~ s|Date:.*Date: $gitdateTITLE:\(.*\)TITLE:$1|
|g; - # $line =~ s|Date:.*Date: $gitdateTITLE:\(.*\)TITLE:$1 public/index.org" or die; + my($f); + print INDEX "| Gitlab Origin | Pandoc HTML (Gitlab pages) | FUN Outcome | +|---+---+---|\n"; + + while(defined($f = )) { + chomp($f); + if($f =~ /^\s*$/) { + print INDEX "|---+---+---|\n"; + next; + } + my($file,$url) = split(/\s*#\s*/,$f); + if($file eq "" || !defined($url)) { warn "Malformed line"; next;} + # print "'$file' --- '$url'\n"; +# pandoc_export($file); + + my($html)=$file; $html=~ s/\.[^\.]*$/.html/g; + my($url_id) = $url; $url_id =~ s|^.*jump_to_id/||g; + print INDEX "| [[https://gitlab.inria.fr/learninglab/mooc-rr/mooc-rr-ressources/tree/master/$file][$file]] | [[$html]] | [[$url][$url_id]] |\n"; } - print OUTPUT $line; + print INDEX "|---+---+---|\n"; + close INDEX; + close LIST; + + my($pandoc_output) = `LANG=C ; pandoc -s -c http://www.pirilampo.org/styles/readtheorg/css/readtheorg.css -f org -t html -o public/index.html public/index.org`; } -close OUTPUT; -close INPUT; -unlink($output_temp); +main() diff --git a/gitlab-ci.org b/gitlab-ci.org index 9ecf44e6299427e20c4e1310eee825bfaa5b14da..e7fa1273a1ca1727b67302c52ad34af3a403c9e1 100644 --- a/gitlab-ci.org +++ b/gitlab-ci.org @@ -13,14 +13,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: @@ -117,115 +114,3 @@ chmod +x ./gitlab-ci.sh ./gitlab-ci.sh #+end_src -#+RESULTS: -#+begin_example -pandoc 2.2.1 -Compiled with pandoc-types 1.17.5.1, texmath 0.11.1, skylighting 0.7.5 -Default user data directory: /home/alegrand/.pandoc -Copyright (C) 2006-2018 John MacFarlane -Web: http://pandoc.org -This is free software; see the source for copying conditions. -There is no warranty, not even for merchantability or fitness -for a particular purpose. -Exporting ./module2/ressources/maintaining_a_journal.org -Creating public/./module2/ressources -Exporting ./module2/ressources/jupyter_fr.org -Creating public/./module2/ressources -Exporting ./module2/ressources/rstudio_fr.org -Creating public/./module2/ressources -Exporting ./module2/ressources/gitlab_fr.org -Creating public/./module2/ressources -Exporting ./module2/ressources/emacs_orgmode_fr.org -Creating public/./module2/ressources -Exporting ./module2/ressources/jupyter.org -Creating public/./module2/ressources -Exporting ./module2/ressources/emacs_orgmode.org -Creating public/./module2/ressources -Exporting ./module2/ressources/maintaining_a_journal_fr.org -Creating public/./module2/ressources -Exporting ./module2/ressources/rstudio.org -Creating public/./module2/ressources -Exporting ./module2/ressources/gitlab.org -Creating public/./module2/ressources -Exporting ./module2/ressources/orgmode_examples/README.org -Creating public/./module2/ressources/orgmode_examples -Exporting ./module2/ressources/orgmode_examples/README_fr.org -Creating public/./module2/ressources/orgmode_examples -Exporting ./module2/exo4/stat_activity.org -Creating public/./module2/exo4 -Exporting ./module2/slides/ressources_fr.org -Creating public/./module2/slides -Exporting ./module2/slides/ressources.org -Creating public/./module2/slides -Exporting ./module3/ressources/iso_date_format.org -Creating public/./module3/ressources -Exporting ./module3/ressources/iso_date_format_fr.org -Creating public/./module3/ressources -Exporting ./module3/ressources/influenza-like-illness-analysis-orgmode+R.org -Creating public/./module3/ressources -Exporting ./module3/ressources/influenza-like-illness-analysis-orgmode+Lisp+Python+R.org -Creating public/./module3/ressources -Exporting ./module3/ressources/influenza-like-illness-analysis-orgmode.org -Creating public/./module3/ressources -Exporting ./module3/ressources/analyse-syndrome-grippal-orgmode.org -Creating public/./module3/ressources -Exporting ./module3/ressources/analyse-syndrome-grippal-orgmode+R.org -Creating public/./module3/ressources -Exporting ./module3/ressources/analyse-syndrome-grippal-orgmode+Lisp+Python+R.org -Creating public/./module3/ressources -Exporting ./module1/ressources/Module1_1_MaterielSupplementaire_fr.org -Creating public/./module1/ressources -Exporting ./module1/ressources/Module1_2_MaterielSupplementaire_fr.org -Creating public/./module1/ressources -Exporting ./module1/ressources/Module1_3_MaterielSupplementaire_fr.org -Creating public/./module1/ressources -Exporting ./module1/ressources/Module1_5_MaterielSupplementaire_fr.org -Creating public/./module1/ressources -Exporting ./module1/ressources/Module1_1_SupplementaryMaterial.org -Creating public/./module1/ressources -Exporting ./module1/ressources/Module1_2_SupplementaryMaterial.org -Creating public/./module1/ressources -Exporting ./module1/ressources/introduction_to_markdown_fr.org -Creating public/./module1/ressources -Exporting ./module1/ressources/introduction_to_markdown.org -Creating public/./module1/ressources -Exporting ./module1/ressources/module1_supplementary_material.org -Creating public/./module1/ressources -Exporting ./module1/ressources/module1_additionalRessources.md -Creating public/./module1/ressources -Exporting ./module1/ressources/sequence3_fr.org -Creating public/./module1/ressources -Exporting ./module1/ressources/sequence5_fr.org -Creating public/./module1/ressources -Exporting ./module1/ressources/sequence2_fr.org -Creating public/./module1/ressources -Exporting ./module1/ressources/sequence1_fr.org -Creating public/./module1/ressources -Exporting ./module4/ressources/resources_refs.org -Creating public/./module4/ressources -Exporting ./module4/ressources/resources_refs_fr.org -Creating public/./module4/ressources -Exporting ./module4/ressources/exo1.org -Creating public/./module4/ressources -Exporting ./module4/ressources/exo2.org -Creating public/./module4/ressources -Exporting ./module4/ressources/exo3.org -Creating public/./module4/ressources -Exporting ./module4/ressources/resources_environment.org -Creating public/./module4/ressources -Exporting ./module4/ressources/resources_environment_fr.org -Creating public/./module4/ressources -Exporting ./documents/notebooks/notebook_RStudio_SASmarkdown.md -Creating public/./documents/notebooks -Exporting ./documents/tuto_git_gtlab/tuto_git_gitlab.md -Creating public/./documents/tuto_git_gtlab -Exporting ./documents/tuto_rstudio_gitlab/tuto_rstudio_gitlab.md -Creating public/./documents/tuto_rstudio_gitlab -Exporting ./documents/tuto_magit/tuto_magit.md -Creating public/./documents/tuto_magit -Exporting ./documents/tuto_emacs_windows/tuto_emacs_windows.md -Creating public/./documents/tuto_emacs_windows -Exporting ./documents/tuto_jupyter_windows/tuto_jupyter_windows.md -Creating public/./documents/tuto_jupyter_windows -#+end_example -