diff --git a/src/.gitignore b/src/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..b8880c5553545f5ecb2ecea0c0d268db607a9e38 --- /dev/null +++ b/src/.gitignore @@ -0,0 +1,2 @@ +_build +/topfind_header.ml diff --git a/src/.merlin b/src/.merlin new file mode 100644 index 0000000000000000000000000000000000000000..818f31c7019cfff3f59cb262da323cf122a15ab1 --- /dev/null +++ b/src/.merlin @@ -0,0 +1,3 @@ +PKG tyxml +B _build +S . \ No newline at end of file diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..08ff24fc1bd07ce0f3d704cd4a2f2e147f3f78ba --- /dev/null +++ b/src/Makefile @@ -0,0 +1,52 @@ +# -------------------------------------------------------------------------- +# --- Build +# -------------------------------------------------------------------------- + +.PHONY: all build install uninstall clean + +all: generate + +clean: + rm -fr build *~ + ocamlbuild -clean + +# -------------------------------------------------------------------------- +# --- Compilation +# -------------------------------------------------------------------------- +PREFIX?=/usr/local +PACKAGES=tyxml +FLAGS= \ + -cflags -w,PSUZL+7,-warn-error,PSUZL+7 \ + -use-ocamlfind -tag debug \ + $(addprefix -package ,$(PACKAGES)) + +ifeq ($(DEVEL),YES) +FLAGS+=-tag bin_annot +endif + +PAGE=$(subst .page.ml,,$(wildcard *.page.ml)) + +generate: $(addprefix ../www/, $(addsuffix .html,$(PAGE))) + +HEADER=topfind_header.ml + +../www/%.html: %.page.ml $(HEADER) utils + @echo "Generating $*.html" + @echo "#1 \"$*.page.ml\"" | cat $(HEADER) - $< | ocaml -I _build -stdin $< > $@.tmp + @mv $@.tmp $@ + +$(HEADER): Makefile + @echo "Generate header for topfind" + @echo "#use \"topfind\";;" > $@.tmp + @$(foreach pkg, $(PACKAGES), echo "#require \"$(pkg)\";;" >> $@.tmp;) + @echo "#load \"utils.cma\";;" >> $@.tmp + @mv $@.tmp $@ + +utils: force + @echo "Compiling common library" + @ocamlbuild $(FLAGS) utils.cma + + + +#force allows to always run the rules that depends on it +.PHONY: force diff --git a/src/generate.ml b/src/generate.ml new file mode 100644 index 0000000000000000000000000000000000000000..7b23433cc70c4acbaf8307327dda3d0566f2239f --- /dev/null +++ b/src/generate.ml @@ -0,0 +1,8 @@ +open Html5.M + +let page ~title:t b = + let html = + html + (head (title (pcdata t)) [meta ~a:[a_charset "utf-8"] ()]) + (body b) in + Html5.P.print ~output:print_string html diff --git a/src/index.page.ml b/src/index.page.ml new file mode 100644 index 0000000000000000000000000000000000000000..7122e0d1dbb9273b46e169c0877cf89e125178cf --- /dev/null +++ b/src/index.page.ml @@ -0,0 +1,7 @@ + +open Html5.M +open Generate + +let () = Generate.page ~title:"Toto" [ + p [pcdata "C'est ça!"] +] diff --git a/src/utils.mllib b/src/utils.mllib new file mode 100644 index 0000000000000000000000000000000000000000..2615ec9650e68e01d970c8a51cb751fe7ab94336 --- /dev/null +++ b/src/utils.mllib @@ -0,0 +1 @@ +Generate \ No newline at end of file diff --git a/www/index.html b/www/index.html new file mode 100644 index 0000000000000000000000000000000000000000..a9ef376e1405add976f333b34d46f5a672fedec8 --- /dev/null +++ b/www/index.html @@ -0,0 +1,2 @@ + +Toto

C'est ça!

\ No newline at end of file