From cb9a85ca34af1e956c1e4714b0d64bd38c7feb18 Mon Sep 17 00:00:00 2001 From: Ferruccio Guidi Date: Tue, 10 Dec 2019 00:24:30 +0100 Subject: [PATCH] =?utf8?q?mechanizing=20the=20generation=20of=20index=20fi?= =?utf8?q?les=20for=20=CE=BB=CE=B4=20web=20site?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit + initial commit --- helm/www/lambdadelta/bin/index/Makefile | 10 +++++ helm/www/lambdadelta/bin/index/index.ml | 49 +++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 helm/www/lambdadelta/bin/index/Makefile create mode 100644 helm/www/lambdadelta/bin/index/index.ml 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 -- 2.39.2