Commit 59ba801a authored by Benoit Barbot's avatar Benoit Barbot
Browse files

progress

parent bdc538d1
Pipeline #1737 failed with stage
in 51 seconds
##----------------------------------------------------------------------
## DISCLAIMER
##
## This file contains the rules to make an Eliom project. The project is
## configured through the variables in the file Makefile.options.
##----------------------------------------------------------------------
include Makefile.options
##----------------------------------------------------------------------
## Internals
## Required binaries
ELIOMC := eliomc -ppx
ELIOMOPT := eliomopt -ppx
JS_OF_ELIOM := js_of_eliom -ppx
ELIOMDEP := eliomdep
OCSIGENSERVER := ocsigenserver
OCSIGENSERVER.OPT := ocsigenserver.opt
## Where to put intermediate object files.
## - ELIOM_{SERVER,CLIENT}_DIR must be distinct
## - ELIOM_CLIENT_DIR must not be the local dir.
## - ELIOM_SERVER_DIR could be ".", but you need to
## remove it from the "clean" rules...
export ELIOM_SERVER_DIR := _server
export ELIOM_CLIENT_DIR := _client
export ELIOM_TYPE_DIR := _server
DEPSDIR := _deps
ifeq ($(DEBUG),yes)
GENERATE_DEBUG ?= -g
RUN_DEBUG ?= "-v"
DEBUG_JS ?= -jsopt -pretty -jsopt -noinline -jsopt -debuginfo
endif
##----------------------------------------------------------------------
## General
.PHONY: all byte opt
all: byte opt
byte opt:: $(TEST_PREFIX)$(ELIOMSTATICDIR)/${PROJECT_NAME}.js
byte opt:: $(TEST_PREFIX)$(ETCDIR)/$(PROJECT_NAME).conf
byte opt:: $(TEST_PREFIX)$(ETCDIR)/$(PROJECT_NAME)-test.conf
byte:: $(TEST_PREFIX)$(LIBDIR)/${PROJECT_NAME}.cma
opt:: $(TEST_PREFIX)$(LIBDIR)/${PROJECT_NAME}.cmxs
DIST_DIRS = $(ETCDIR) $(DATADIR) $(LIBDIR) $(LOGDIR) $(STATICDIR) $(ELIOMSTATICDIR) $(shell dirname $(CMDPIPE))
##----------------------------------------------------------------------
## Testing
DIST_FILES = $(ELIOMSTATICDIR)/$(PROJECT_NAME).js $(LIBDIR)/$(PROJECT_NAME).cma
.PHONY: test.byte test.opt
test.byte: $(addprefix $(TEST_PREFIX),$(ETCDIR)/$(PROJECT_NAME)-test.conf $(DIST_DIRS) $(DIST_FILES))
$(OCSIGENSERVER) $(RUN_DEBUG) -c $<
test.opt: $(addprefix $(TEST_PREFIX),$(ETCDIR)/$(PROJECT_NAME)-test.conf $(DIST_DIRS) $(patsubst %.cma,%.cmxs, $(DIST_FILES)))
$(OCSIGENSERVER.OPT) $(RUN_DEBUG) -c $<
$(addprefix $(TEST_PREFIX), $(DIST_DIRS)):
mkdir -p $@
##----------------------------------------------------------------------
## Installing & Running
.PHONY: install install.byte install.byte install.opt install.static install.etc install.lib install.lib.byte install.lib.opt run.byte run.opt
install: install.byte install.opt
install.byte: install.lib.byte install.etc install.static | $(addprefix $(PREFIX),$(DATADIR) $(LOGDIR) $(shell dirname $(CMDPIPE)))
install.opt: install.lib.opt install.etc install.static | $(addprefix $(PREFIX),$(DATADIR) $(LOGDIR) $(shell dirname $(CMDPIPE)))
install.lib: install.lib.byte install.lib.opt
install.lib.byte: $(TEST_PREFIX)$(LIBDIR)/$(PROJECT_NAME).cma | $(PREFIX)$(LIBDIR)
install $< $(PREFIX)$(LIBDIR)
install.lib.opt: $(TEST_PREFIX)$(LIBDIR)/$(PROJECT_NAME).cmxs | $(PREFIX)$(LIBDIR)
install $< $(PREFIX)$(LIBDIR)
install.static: $(TEST_PREFIX)$(ELIOMSTATICDIR)/$(PROJECT_NAME).js | $(PREFIX)$(STATICDIR) $(PREFIX)$(ELIOMSTATICDIR)
cp -r $(LOCAL_STATIC)/* $(PREFIX)$(STATICDIR)
[ -z $(WWWUSER) ] || chown -R $(WWWUSER) $(PREFIX)$(STATICDIR)
install $(addprefix -o ,$(WWWUSER)) $< $(PREFIX)$(ELIOMSTATICDIR)
install.etc: $(TEST_PREFIX)$(ETCDIR)/$(PROJECT_NAME).conf | $(PREFIX)$(ETCDIR)
install $< $(PREFIX)$(ETCDIR)/$(PROJECT_NAME).conf
.PHONY:
print-install-files:
@echo $(PREFIX)$(LIBDIR)
@echo $(PREFIX)$(STATICDIR)
@echo $(PREFIX)$(ELIOMSTATICDIR)
@echo $(PREFIX)$(ETCDIR)
$(addprefix $(PREFIX),$(ETCDIR) $(LIBDIR)):
install -d $@
$(addprefix $(PREFIX),$(DATADIR) $(LOGDIR) $(STATICDIR) $(ELIOMSTATICDIR) $(shell dirname $(CMDPIPE))):
install $(addprefix -o ,$(WWWUSER)) -d $@
run.byte:
$(OCSIGENSERVER) $(RUN_DEBUG) -c ${PREFIX}${ETCDIR}/${PROJECT_NAME}.conf
run.opt:
$(OCSIGENSERVER.OPT) $(RUN_DEBUG) -c ${PREFIX}${ETCDIR}/${PROJECT_NAME}.conf
##----------------------------------------------------------------------
## Aux
# Use `eliomdep -sort' only in OCaml>4
ifeq ($(shell ocamlc -version|cut -c1),4)
eliomdep=$(shell $(ELIOMDEP) $(1) -ppx -sort $(2) $(filter %.eliom %.ml,$(3))))
else
eliomdep=$(3)
endif
objs=$(patsubst %.ml,$(1)/%.$(2),$(patsubst %.eliom,$(1)/%.$(2),$(filter %.eliom %.ml,$(3))))
depsort=$(call objs,$(1),$(2),$(call eliomdep,$(3),$(4),$(5)))
##----------------------------------------------------------------------
## Config files
FINDLIB_PACKAGES=$(patsubst %,\<extension\ findlib-package=\"%\"\ /\>,$(SERVER_PACKAGES))
EDIT_WARNING=DON\'T EDIT THIS FILE! It is generated from $(PROJECT_NAME).conf.in, edit that one, or the variables in Makefile.options
SED_ARGS := -e "/^ *%%%/d"
SED_ARGS += -e "s|%%PROJECT_NAME%%|$(PROJECT_NAME)|g"
SED_ARGS += -e "s|%%DATABASE_NAME%%|$(DATABASE_NAME)|g"
SED_ARGS += -e "s|%%DATABASE_USER%%|$(DATABASE_USER)|g"
SED_ARGS += -e "s|%%CMDPIPE%%|%%PREFIX%%$(CMDPIPE)|g"
SED_ARGS += -e "s|%%LOGDIR%%|%%PREFIX%%$(LOGDIR)|g"
SED_ARGS += -e "s|%%DATADIR%%|%%PREFIX%%$(DATADIR)|g"
SED_ARGS += -e "s|%%PERSISTENT_DATA_BACKEND%%|$(PERSISTENT_DATA_BACKEND)|g"
SED_ARGS += -e "s|%%LIBDIR%%|%%PREFIX%%$(LIBDIR)|g"
SED_ARGS += -e "s|%%WARNING%%|$(EDIT_WARNING)|g"
SED_ARGS += -e "s|%%PACKAGES%%|$(FINDLIB_PACKAGES)|g"
SED_ARGS += -e "s|%%ELIOMSTATICDIR%%|%%PREFIX%%$(ELIOMSTATICDIR)|g"
ifeq ($(DEBUG),yes)
SED_ARGS += -e "s|%%DEBUGMODE%%|\<debugmode /\>|g"
else
SED_ARGS += -e "s|%%DEBUGMODE%%||g"
endif
LOCAL_SED_ARGS := -e "s|%%PORT%%|$(TEST_PORT)|g"
LOCAL_SED_ARGS += -e "s|%%STATICDIR%%|$(LOCAL_STATIC)|g"
LOCAL_SED_ARGS += -e "s|%%USERGROUP%%||g"
GLOBAL_SED_ARGS := -e "s|%%PORT%%|$(PORT)|g"
GLOBAL_SED_ARGS += -e "s|%%STATICDIR%%|%%PREFIX%%$(STATICDIR)|g"
ifeq ($(WWWUSER)$(WWWGROUP),)
GLOBAL_SED_ARGS += -e "s|%%USERGROUP%%||g"
else
GLOBAL_SED_ARGS += -e "s|%%USERGROUP%%|<user>$(WWWUSER)</user><group>$(WWWGROUP)</group>|g"
endif
$(TEST_PREFIX)${ETCDIR}/${PROJECT_NAME}.conf: ${PROJECT_NAME}.conf.in Makefile.options | $(TEST_PREFIX)$(ETCDIR)
sed $(SED_ARGS) $(GLOBAL_SED_ARGS) $< | sed -e "s|%%PREFIX%%|$(PREFIX)|g" > $@
$(TEST_PREFIX)${ETCDIR}/${PROJECT_NAME}-test.conf: ${PROJECT_NAME}.conf.in Makefile.options | $(TEST_PREFIX)$(ETCDIR)
sed $(SED_ARGS) $(LOCAL_SED_ARGS) $< | sed -e "s|%%PREFIX%%|$(TEST_PREFIX)|g" > $@
##----------------------------------------------------------------------
## Server side compilation
SERVER_INC := ${addprefix -package ,${SERVER_PACKAGES}}
${ELIOM_TYPE_DIR}/%.type_mli: %.eliom
${ELIOMC} -infer ${SERVER_INC} $<
$(TEST_PREFIX)$(LIBDIR)/$(PROJECT_NAME).cma: $(call objs,$(ELIOM_SERVER_DIR),cmo,$(SERVER_FILES)) | $(TEST_PREFIX)$(LIBDIR)
${ELIOMC} -a -o $@ $(GENERATE_DEBUG) \
$(call depsort,$(ELIOM_SERVER_DIR),cmo,-server,$(SERVER_INC),$(SERVER_FILES))
$(TEST_PREFIX)$(LIBDIR)/$(PROJECT_NAME).cmxa: $(call objs,$(ELIOM_SERVER_DIR),cmx,$(SERVER_FILES)) | $(TEST_PREFIX)$(LIBDIR)
${ELIOMOPT} -a -o $@ $(GENERATE_DEBUG) \
$(call depsort,$(ELIOM_SERVER_DIR),cmx,-server,$(SERVER_INC),$(SERVER_FILES))
%.cmxs: %.cmxa
$(ELIOMOPT) -shared -linkall -o $@ $(GENERATE_DEBUG) $<
${ELIOM_SERVER_DIR}/%.cmi: %.mli
${ELIOMC} -c ${SERVER_INC} $(GENERATE_DEBUG) $<
${ELIOM_SERVER_DIR}/%.cmi: %.eliomi
${ELIOMC} -c ${SERVER_INC} $(GENERATE_DEBUG) $<
${ELIOM_SERVER_DIR}/%.cmo: %.ml
${ELIOMC} -c ${SERVER_INC} $(GENERATE_DEBUG) $<
${ELIOM_SERVER_DIR}/%.cmo: %.eliom
${ELIOMC} -c ${SERVER_INC} $(GENERATE_DEBUG) $<
${ELIOM_SERVER_DIR}/%.cmx: %.ml
${ELIOMOPT} -c ${SERVER_INC} $(GENERATE_DEBUG) $<
${ELIOM_SERVER_DIR}/%.cmx: %.eliom
${ELIOMOPT} -c ${SERVER_INC} $(GENERATE_DEBUG) $<
##----------------------------------------------------------------------
## Client side compilation
CLIENT_LIBS := ${addprefix -package ,${CLIENT_PACKAGES}}
CLIENT_INC := ${addprefix -package ,${CLIENT_PACKAGES}}
CLIENT_OBJS := $(filter %.eliom %.ml, $(CLIENT_FILES))
CLIENT_OBJS := $(patsubst %.eliom,${ELIOM_CLIENT_DIR}/%.cmo, ${CLIENT_OBJS})
CLIENT_OBJS := $(patsubst %.ml,${ELIOM_CLIENT_DIR}/%.cmo, ${CLIENT_OBJS})
$(TEST_PREFIX)$(ELIOMSTATICDIR)/$(PROJECT_NAME).js: $(call objs,$(ELIOM_CLIENT_DIR),cmo,$(CLIENT_FILES)) | $(TEST_PREFIX)$(ELIOMSTATICDIR)
${JS_OF_ELIOM} -o $@ $(GENERATE_DEBUG) $(CLIENT_INC) $(DEBUG_JS) \
$(call depsort,$(ELIOM_CLIENT_DIR),cmo,-client,$(CLIENT_INC),$(CLIENT_FILES))
${ELIOM_CLIENT_DIR}/%.cmi: %.mli
${JS_OF_ELIOM} -c ${CLIENT_INC} $(GENERATE_DEBUG) $<
${ELIOM_CLIENT_DIR}/%.cmo: %.eliom
${JS_OF_ELIOM} -c ${CLIENT_INC} $(GENERATE_DEBUG) $<
${ELIOM_CLIENT_DIR}/%.cmo: %.ml
${JS_OF_ELIOM} -c ${CLIENT_INC} $(GENERATE_DEBUG) $<
${ELIOM_CLIENT_DIR}/%.cmi: %.eliomi
${JS_OF_ELIOM} -c ${CLIENT_INC} $(GENERATE_DEBUG) $<
##----------------------------------------------------------------------
## Dependencies
include .depend
.depend: $(patsubst %,$(DEPSDIR)/%.server,$(SERVER_FILES)) $(patsubst %,$(DEPSDIR)/%.client,$(CLIENT_FILES))
cat $^ > $@
$(DEPSDIR)/%.server: % | $(DEPSDIR)
$(ELIOMDEP) -server -ppx $(SERVER_INC) $< > $@
$(DEPSDIR)/%.client: % | $(DEPSDIR)
$(ELIOMDEP) -client -ppx $(CLIENT_INC) $< > $@
$(DEPSDIR):
mkdir $@
##----------------------------------------------------------------------
## Clean up
all:
ocamlbuild -use-ocamlfind ta_editor.byte
js_of_ocaml --no-inline ta_editor.byte
clean:
-rm -f *.cm[ioax] *.cmxa *.cmxs *.o *.a *.annot
-rm -f *.type_mli
-rm -f ${PROJECT_NAME}.js
-rm -rf ${ELIOM_CLIENT_DIR} ${ELIOM_SERVER_DIR}
distclean: clean
-rm -rf $(TEST_PREFIX) $(DEPSDIR) .depend
ocamlbuild -clean
rm -rf ta_editor.byte ta_editor.js
#----------------------------------------------------------------------
# SETTINGS FOR THE ELIOM PROJECT cosmosweb
#----------------------------------------------------------------------
PROJECT_NAME := cosmosweb
# Source files for the server
SERVER_FILES := $(wildcard *.eliomi *.eliom)
# Source files for the client
CLIENT_FILES := $(wildcard *.eliomi *.eliom) TAGraph.ml
# OCamlfind packages for the server
SERVER_PACKAGES := js_of_ocaml-ppx_deriving_json xml-light
# OCamlfind packages for the client
CLIENT_PACKAGES := js_of_ocaml-ppx js_of_ocaml-ppx_deriving_json xml-light GraphEditor
# Directory with files to be statically served
LOCAL_STATIC = static
# The backend for persistent data. Can be dbm or sqlite.
# Make sure you have the following packages installed
# - *dbm* if you use dbm --> opam install dbm.
# - *sqlite3* if you use sqlite --> opam install sqlite3.
PERSISTENT_DATA_BACKEND = sqlite
# Debug application (yes/no): Debugging info in compilation,
# JavaScript, ocsigenserver
DEBUG := no
# User to run server with (make run.*)
WWWUSER := www-data
WWWGROUP := www-data
# Port for running the server (make run.*)
PORT := 80
# Port for testing (make test.*)
TEST_PORT := 8080
# Root of installation (must end with /)
PREFIX := /usr/local/
# Local folder for make test.* (must end with /)
# Do not add files manually in this directory.
# It is just here to test your installation before installing in /
TEST_PREFIX := local/
# The installation tree (relative to $(PREFIX) when
# installing/running or $(TEST_PREFIX) when testing).
# Configuration file $(PROJECT_NAME).conf
ETCDIR := etc/${PROJECT_NAME}
# Project's library $(PROJECT_NAME).cma (cmxs)
LIBDIR := lib/${PROJECT_NAME}
# Command pipe, eg. $ echo reload > $(INSTALL_PREFIX)$(CMDPIPE)
CMDPIPE := var/run/${PROJECT_NAME}-cmd
# Ocsigenserver's logging files
LOGDIR := var/log/${PROJECT_NAME}
# Ocsigenserver's persistent data files
DATADIR := var/data/${PROJECT_NAME}
# Copy of $(LOCAL_STATIC)
STATICDIR := var/www/${PROJECT_NAME}/static
# Project's JavaScript file
ELIOMSTATICDIR := var/www/${PROJECT_NAME}/eliom
......@@ -8,32 +8,38 @@
| `String of string
| `Color of string ]
let init_def () = ()
let init_arc _ _ = Some 1.0
let state_id = ref 0
let init_state () = incr state_id;
("s"^(string_of_int !state_id), ["toto"])
let draw_state (s,_) p = [
let draw_state (s,_) p = [
`RoundedRectangle (p,10.0,0.75,5.0);
`Text(p,s);
]
let draw_arc arc (source_sh,target_sh) =
let open DrawingGeom in
let pos1 = center_shape source_sh in
let pos2 = projection_shape pos1 target_sh in
let pos3 = projection_shape pos2 source_sh in
let pos2 = center_shape target_sh in
let text = string_of_float arc in
let middle = mult 0.5 (pos3 +.. pos2) in
let rho = angle (pos3 -..pos2) in
let textvect = middle +.. rot rho (0.0,8.0) in
[`Line (pos1,pos3); `Arrow (pos2,pos1) ; `Text(textvect, text)]
let get_state_attr (s, at) =
if source_sh<>target_sh then begin
shapes_of_path source_sh [`Text (0.5,text)] ~arrow2:(Some (fun x y -> `Arrow (x,y))) target_sh
end else begin
let p1 = pos1 +.. (40.0 , -.25.0)
and p2 = pos2 +.. (40.0 , 25.0) in
shapes_of_path source_sh [`ControlPoint p1; `Text (0.5,text);`ControlPoint p2] ~arrow2:(Some (fun x y -> `Arrow (x,y))) target_sh
end
let get_state_attr (s, at) =
"Node", ((0,"content",`String s) ::
(List.mapi (fun i sv -> (i+1),"attribute "^(string_of_int (i+1)),(`String sv )) at))
(List.mapi (fun i sv -> (i+1),"attribute "^(string_of_int (i+1)),(`String sv )) at))
let update_state_attr (s,at) attr_id = function
| None ->
if attr_id = 0 then Some ("",at)
......@@ -50,12 +56,12 @@
(i+1, newv::l) else (i+1, at::l)) (0,[]) at in
Some (s,listat)
| _ -> None
let get_new_state_attr (s,at) _ = []
let get_arc_attr prob =
"Arc", [(0,"Probability",`String (string_of_float prob)) ]
let get_arc_attr prob =
"Arc", [(0,"Probability",`String (string_of_float prob)) ]
let update_arc_attr _ _ = function
| None ->
begin try let p = 1.0 in
......@@ -68,9 +74,9 @@
with _ -> None
end
| _ -> None
let get_new_arc_attr atlist _ = []
let string_of_attribute = function
| `Prob arc -> string_of_float arc
| `StringExpr s -> s
......@@ -78,12 +84,12 @@
| `Choice [] -> ""
| `ControlPoint _ -> ""
let download_file_name = "markovChain.dot"
let print f stateit arcit =
let print = [
"dot", (fun f stateit arcit ->
Format.fprintf f "digraph {\n";
stateit (fun _ (s,_) (x,y) -> Format.fprintf f "%s [pos=\"%f,%f\"];\n" s (x) (y));
arcit (fun _ _ ((_,(source,_),_),(_,(target,_),_)) ->
Format.fprintf f "%s -> %s;\n" source target);
Format.fprintf f "}"
Format.fprintf f "}"), "markovChain.dot" ]
let parse_file _ add_node add_arc = ()
......@@ -82,12 +82,13 @@
| `Choice [] -> ""
| `ControlPoint _ -> ""
let download_file_name = "markovChain.dot"
let print f stateit arcit =
let print =
["dot" , (fun f stateit arcit ->
Format.fprintf f "digraph {\n";
stateit (fun _ (s,_) (x,y) -> Format.fprintf f "%s [pos=\"%f,%f\"];\n" s (x) (y));
arcit (fun _ _ ((_,(source,_),_),(_,(target,_),_)) ->
Format.fprintf f "%s -> %s;\n" source target);
Format.fprintf f "}"
Format.fprintf f "}") , "markovChain.dot"
]
let parse_file _ add_node add_arc = ()
......@@ -15,6 +15,13 @@ module Cosmosweb_app =
let global_data_path = None
end)
[%%client
module TAGraphEd = GraphDrawing.GraphEditor(SimpleGraph.S(TAGraph))
]
let canvas_elt =
canvas ~a:[a_width width; a_height height]
[pcdata "your browser doesn't support canvas"]
......@@ -27,12 +34,6 @@ let attribute_div =
attribute_list_div;
]
[%%client
module TAGraphEd = GraphDrawing.GraphEditor(SimpleGraph.S(TAGraph))
]
let create_form =
div []
......
......@@ -14,22 +14,40 @@ let br () =
let br = Dom_html.(createBr document) in
(br :> t)
let tr items =
let ul ?id items =
let ul = Dom_html.(createUl document) in
(match id with None -> () | Some ids -> ul##.id := Js.string ids);
List.iter (append_node ul) items;
(ul :> t)
let tr ?id items =
let tr = Dom_html.(createTr document) in
(match id with None -> () | Some ids -> tr##.id := Js.string ids);
List.iter (append_node tr) items;
(tr :> t)
let td items =
let td ?id items =
let td = Dom_html.(createTd document) in
(match id with None -> () | Some ids -> td##.id := Js.string ids);
List.iter (append_node td) items;
(td :> t)
let table items =
let table ?id items =
let table = Dom_html.(createTable document) in
(match id with None -> () | Some ids -> table##.id := Js.string ids);
List.iter (append_node table) items;
(table :> t)
let div_raw ?(class_ = "") ?(title="") ?id items =
let div = Dom_html.(createDiv document) in
List.iter (append_node div) items;
(match id with None -> () | Some ids -> div##.id := Js.string ids);
div##.title := Js.string title;
div##.className := Js.string class_;
div
let div ?(class_ = "") ?(title="") ?id items =
let div = Dom_html.(createDiv document) in
List.iter (append_node div) items;
......@@ -131,3 +149,24 @@ let rec split_attr s i =
let query = Js.to_string Dom_html.window##.location##.search in
let m = split_attr query 1 in
List.assoc_opt s m
let run html =
let on_load _ =
let html = html () in
let body =
let find_tag name =
let elements =
Dom_html.window##.document##getElementsByTagName(Js.string name)
in
let element =
Js.Opt.get (elements##item(0))
(fun () -> failwith ("find_tag("^name^")"))
in
element
in
find_tag "body"
in
let _: t = body##appendChild(html) in
Js._false
in
Dom_html.window##.onload := Dom.handler on_load
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment