From: Ferruccio Guidi Date: Mon, 9 Dec 2019 23:24:30 +0000 (+0100) Subject: mechanizing the generation of index files for λδ web site X-Git-Tag: make_still_working~212 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=cb9a85ca34af1e956c1e4714b0d64bd38c7feb18;p=helm.git mechanizing the generation of index files for λδ web site + initial commit --- diff --git a/helm/www/lambdadelta/bin/index/Makefile b/helm/www/lambdadelta/bin/index/Makefile new file mode 100644 index 000000000..faf88603f --- /dev/null +++ b/helm/www/lambdadelta/bin/index/Makefile @@ -0,0 +1,10 @@ +EXECS = index + +REQUIRES = unix + +include ../Makefile.common + +test: +# @$(MAKE) --no-print-directory -C ../../ www + +.PHONY: test diff --git a/helm/www/lambdadelta/bin/index/index.ml b/helm/www/lambdadelta/bin/index/index.ml new file mode 100644 index 000000000..c7fd48d90 --- /dev/null +++ b/helm/www/lambdadelta/bin/index/index.ml @@ -0,0 +1,49 @@ +module KF = Filename +module KP = Printf +module KU = Unix + +let out_entry dname och dirs name = + let fname = KF.concat dname name in + let stats = KU.lstat fname in + match stats.KU.st_kind with + | KU.S_REG -> + KP.fprintf och " %s\n" fname name; + dirs + | KU.S_DIR -> name :: dirs + | _ -> dirs + +let list_dir dname och = + let dir = Sys.readdir dname in + Array.sort String.compare dir; + Array.fold_left (out_entry dname och) [] dir + +let out_index dname och = + KP.fprintf och "\n\n"; + KP.fprintf och "\n"; + KP.fprintf och " \n"; + KP.fprintf och " Index\n"; + KP.fprintf och " \n"; + + KP.fprintf och " \n"; + KP.fprintf och " \n"; + let dirs = list_dir dname och in + KP.fprintf och " \n"; + KP.fprintf och "
\n"; + KP.fprintf och "
\n"; + dirs + +let rec out_dir dname = + let och = open_out (KF.concat dname "index.ldw.xml") in + let dirs = out_index dname och in + close_out och; + let map name = out_dir (KF.concat dname name) in + List.iter map dirs + +let help = "Usage: index [ ]*" + +let main = + Arg.parse [ + ] out_dir help