-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #794 from ocsigen/config
Use Eliom without configuration file (static link)
- Loading branch information
Showing
87 changed files
with
1,691 additions
and
313 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
(lang dune 3.6) | ||
|
||
(name eliom) | ||
(version 10.4.1) | ||
(version 11.0.0) | ||
(maintainers [email protected]) | ||
(authors [email protected]) | ||
(license "LGPL-2.1-only WITH OCaml-LGPL-linking-exception") | ||
|
@@ -34,11 +34,11 @@ The client-side code is compiled to JS using Ocsigen Js_of_ocaml or to Wasm usin | |
lwt_log | ||
(lwt_ppx (>= 1.2.3)) | ||
(tyxml (and (>= 4.6.0) (< 4.7.0))) | ||
(ocsigenserver (and (>= 5.1.0) (< 6.0.0))) | ||
(ocsigenserver (and (>= 6.0.0) (< 7.0.0))) | ||
(ipaddr (>= 2.1)) | ||
(reactiveData (>= 0.2.1)) | ||
base-bytes | ||
(ocsipersist (and (>= 1.0) (< 2.0))) | ||
(ocsipersist (and (>= 2.0) (< 3.0))) | ||
ppx_optcomp)) | ||
|
||
(generate_opam_files) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
(data_only_dirs templates) | ||
(install | ||
(section lib) | ||
(files (glob_files templates/client-server.basic/**) | ||
(glob_files templates/basic.ppx/**))) | ||
(files | ||
(glob_files templates/app.exe/**) | ||
(glob_files templates/app.lib/**) | ||
(glob_files templates/basic.ppx/**))) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Local server configuration | ||
local | ||
|
||
# Eliom | ||
.depend | ||
_client | ||
_deps | ||
_server | ||
|
||
static/css/project_name.css.map | ||
|
||
# Dune | ||
_build |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
##---------------------------------------------------------------------- | ||
## DISCLAIMER | ||
## | ||
## This file contains the rules to make an Eliom project. The project is | ||
## configured through the variables in the file Makefile.options. | ||
##---------------------------------------------------------------------- | ||
|
||
##---------------------------------------------------------------------- | ||
## Internals | ||
|
||
## Required binaries | ||
OCSIGENSERVER := ocsigenserver | ||
OCSIGENSERVER.OPT := ocsigenserver.opt | ||
|
||
ifneq ($(DEBUG),yes) | ||
DUNE_OPTIONS = --profile release | ||
endif | ||
|
||
##---------------------------------------------------------------------- | ||
|
||
##---------------------------------------------------------------------- | ||
## General | ||
|
||
.PHONY: all css byte opt | ||
|
||
DIST_DIRS := $(ETCDIR) $(DATADIR) $(LIBDIR) $(LOGDIR) \ | ||
$(FILESDIR)/avatars/tmp $(ELIOMSTATICDIR) \ | ||
$(shell dirname $(CMDPIPE)) | ||
JS_PREFIX := $(TEST_PREFIX)$(ELIOMSTATICDIR)/$(PROJECT_NAME) | ||
|
||
all:: css byte opt staticfiles | ||
|
||
##---------------------------------------------------------------------- | ||
|
||
##---------------------------------------------------------------------- | ||
## Testing | ||
|
||
DIST_FILES = $(ELIOMSTATICDIR)/$(PROJECT_NAME).js $(LIBDIR)/$(PROJECT_NAME).cma | ||
|
||
.PHONY: test.byte test.opt staticfiles | ||
|
||
test.byte:: byte | $(addprefix $(TEST_PREFIX),$(DIST_DIRS)) staticfiles | ||
@echo "==== The website is available at http://localhost:$(TEST_PORT) ====" | ||
dune exec ./$(PROJECT_NAME)_main.bc | ||
test.opt:: opt | $(addprefix $(TEST_PREFIX),$(DIST_DIRS)) staticfiles | ||
@echo "==== The website is available at http://localhost:$(TEST_PORT) ====" | ||
dune exec ./$(PROJECT_NAME)_main.exe | ||
|
||
test.static.byte: test.byte | ||
|
||
test.static.opt: test.opt | ||
|
||
$(addprefix $(TEST_PREFIX), $(DIST_DIRS)): | ||
mkdir -p $@ | ||
|
||
staticfiles: | ||
cp -rf $(LOCAL_STATIC_CSS) $(TEST_PREFIX)$(ELIOMSTATICDIR) | ||
|
||
##---------------------------------------------------------------------- | ||
## Installing & Running | ||
|
||
.PHONY: install install.static install.lib run | ||
install: all install.static | $(addprefix $(PREFIX),$(DATADIR) $(LOGDIR) $(shell dirname $(CMDPIPE))) | ||
dune install | ||
install.static: $(TEST_PREFIX)$(ELIOMSTATICDIR)/$(PROJECT_NAME).js | $(PREFIX)$(STATICDIR) $(PREFIX)$(ELIOMSTATICDIR) | ||
cp -r $(LOCAL_STATIC_CSS) $(PREFIX)$(FILESDIR) | ||
HASH=`md5sum _build/default/client/$(PROJECT_NAME).bc.js | cut -d ' ' -f 1` && \ | ||
install $(addprefix -o ,$(WWWUSER)) $(JS_PREFIX)_$$HASH.js $(PREFIX)$(ELIOMSTATICDIR) && \ | ||
ln -sf $(PROJECT_NAME)_$$HASH.js $(PREFIX)$(ELIOMSTATICDIR)/$(PROJECT_NAME).js | ||
[ -z $(WWWUSER) ] || chown -R $(WWWUSER) $(PREFIX)$(FILESDIR) | ||
|
||
.PHONY: | ||
print-install-files: | ||
@echo $(PREFIX)$(LIBDIR) | ||
@echo $(PREFIX)$(ELIOMSTATICDIR) | ||
@echo $(PREFIX)$(ETCDIR) | ||
|
||
$(addprefix $(PREFIX),$(ETCDIR) $(LIBDIR)): | ||
install -d $@ | ||
$(addprefix $(PREFIX),$(DATADIR) $(LOGDIR) $(ELIOMSTATICDIR) $(shell dirname $(CMDPIPE))): | ||
install $(addprefix -o ,$(WWWUSER)) -d $@ | ||
|
||
##---------------------------------------------------------------------- | ||
|
||
##---------------------------------------------------------------------- | ||
## Compilation | ||
|
||
.PHONY: gen-dune config-files | ||
|
||
config-files: | $(TEST_PREFIX)$(ELIOMSTATICDIR) $(TEST_PREFIX)$(LIBDIR) | ||
HASH=`md5sum _build/default/client/$(PROJECT_NAME).bc.js | cut -d ' ' -f 1` && \ | ||
cp -f _build/default/client/$(PROJECT_NAME).bc.js $(JS_PREFIX)_$$HASH.js && \ | ||
ln -sf $(PROJECT_NAME)_$$HASH.js $(JS_PREFIX).js | ||
cp -f _build/default/$(PROJECT_NAME).cm* $(TEST_PREFIX)$(LIBDIR)/ | ||
|
||
all:: | ||
$(ENV_PSQL) dune build $(DUNE_OPTIONS) @install @$(PROJECT_NAME) | ||
|
||
js:: | ||
$(ENV_PSQL) dune build $(DUNE_OPTIONS) client/$(PROJECT_NAME).bc.js | ||
|
||
byte:: js | ||
$(ENV_PSQL) dune build $(DUNE_OPTIONS) $(PROJECT_NAME)_main.bc | ||
make config-files PROJECT_NAME=$(PROJECT_NAME) | ||
|
||
opt:: js | ||
$(ENV_PSQL) dune build $(DUNE_OPTIONS) $(PROJECT_NAME)_main.exe | ||
make config-files PROJECT_NAME=$(PROJECT_NAME) | ||
|
||
run: | ||
$(PREFIX)bin/$(PROJECT_NAME) | ||
|
||
|
||
##---------------------------------------------------------------------- | ||
|
||
##---------------------------------------------------------------------- | ||
## Clean up | ||
|
||
.PHONY: clean | ||
|
||
clean:: | ||
dune clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#---------------------------------------------------------------------- | ||
# SETTINGS FOR THE ELIOM PROJECT %%%PROJECT_NAME%%% | ||
#---------------------------------------------------------------------- | ||
# Required binaries | ||
OPAM := opam | ||
|
||
PROJECT_NAME := %%%PROJECT_NAME%%% | ||
|
||
##---------------------------------------------------------------------- | ||
|
||
##---------------------------------------------------------------------- | ||
## The following part contains the settings for the compilation process like the | ||
## server/client OPAM packages and the server/client files. | ||
|
||
# OCamlfind packages for the server (for modules which defines services) | ||
SERVER_ELIOM_PACKAGES := | ||
|
||
# OCamlfind packages for the server | ||
SERVER_PACKAGES := | ||
|
||
##---------------------------------------------------------------------- | ||
|
||
##---------------------------------------------------------------------- | ||
## The following part contains the configuration for the ocsigenserver. | ||
|
||
# Port for running the server (make run) | ||
PORT := 8080 | ||
|
||
# Port for testing (make test.*) | ||
TEST_PORT := 8080 | ||
|
||
# Root of installation (must end with /) | ||
# PREFIX := /usr/local/ | ||
PREFIX := ${OPAM_SWITCH_PREFIX}/ | ||
|
||
# Local folder for make test.* (must end with /) | ||
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 restart > $(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} | ||
|
||
# Project's static files | ||
FILESDIR := var/www/${PROJECT_NAME} | ||
|
||
# Project's JavaScript file directory | ||
ELIOMSTATICDIR := var/www/${PROJECT_NAME} | ||
|
||
LOCAL_STATIC := static | ||
LOCAL_STATIC_CSS := $(LOCAL_STATIC)/css | ||
CSS_PREFIX := $(LOCAL_STATIC_CSS)/${PROJECT_NAME} | ||
##---------------------------------------------------------------------- | ||
|
||
|
||
##---------------------------------------------------------------------- | ||
## The following part contains the settings for debugging | ||
|
||
# Debug application (yes/no): Debugging info in compilation, | ||
# JavaScript, ocsigenserver | ||
DEBUG := yes | ||
|
||
##---------------------------------------------------------------------- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
(* This file was generated by Eliom-distillery. | ||
Feel free to use it, modify it, and redistribute it as you wish. *) | ||
|
||
let%server application_name = "%%%PROJECT_NAME%%%" | ||
let%client application_name = Eliom_client.get_application_name () | ||
|
||
let%server () = | ||
Ocsipersist_settings.set_db_file "local/var/data/%%%PROJECT_NAME%%%/%%%PROJECT_NAME%%%_db"; | ||
|
||
(* Create a module for the application. See | ||
https://ocsigen.org/eliom/manual/clientserver-applications for more | ||
information. *) | ||
module%shared App = Eliom_registration.App (struct | ||
let application_name = application_name | ||
let global_data_path = Some ["__global_data__"] | ||
end) | ||
|
||
(* As the headers (stylesheets, etc) won't change, we ask Eliom not to | ||
update the <head> of the page when changing page. (This also avoids | ||
blinking when changing page in iOS). *) | ||
let%client _ = Eliom_client.persist_document_head () | ||
|
||
let%server main_service = | ||
Eliom_service.create ~path:(Eliom_service.Path []) | ||
~meth:(Eliom_service.Get Eliom_parameter.unit) () | ||
|
||
let%client main_service = ~%main_service | ||
|
||
let%shared () = | ||
App.register ~service:main_service (fun () () -> | ||
Lwt.return | ||
Eliom_content.Html.F.( | ||
html | ||
(head | ||
(title (txt "%%%PROJECT_NAME%%%")) | ||
[ css_link | ||
~uri: | ||
(make_uri | ||
~service:(Eliom_service.static_dir ()) | ||
["css"; "%%%PROJECT_NAME%%%.css"]) | ||
() ]) | ||
(body [h1 [txt "Welcome to Eliom!"]]))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
opam-version: "2.0" | ||
name: "%%%PROJECT_NAME%%%" | ||
version: "0.1" | ||
synopsis: "%%%PROJECT_NAME%%%" | ||
|
||
depends: [ | ||
"eliom" {>= "11.0.0" & < "12.0.0"} | ||
"ocsipersist-sqlite-config" {>= "2.0" & < "3.0"} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
(** This is the main file if you are using static linking without config file. | ||
*) | ||
|
||
module%shared %%%MODULE_NAME%%% = %%%MODULE_NAME%%% | ||
|
||
let%server _ = | ||
Ocsigen_server.start | ||
~ports:[`All, 8080] | ||
~veryverbose:() | ||
~debugmode:true | ||
~logdir:"local/var/log/%%%PROJECT_NAME%%%" | ||
~datadir:"local/var/data/%%%PROJECT_NAME%%%" | ||
~uploaddir:(Some "/tmp") | ||
~usedefaulthostname:true | ||
~command_pipe:"local/var/run/%%%PROJECT_NAME%%%-cmd" | ||
~default_charset:(Some "utf-8") | ||
[ Ocsigen_server.host | ||
[Staticmod.run ~dir:"local/var/www/%%%PROJECT_NAME%%%" (); Eliom.run ()] ] |
Oops, something went wrong.