diff --git a/Makefile b/Makefile index 8a1cf14..36b8640 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ NAME = webshell.exe -SRC = parser.opa editor.opa webshell.opa login.opa facebook.opa serach.opa dropbox.opa +SRC = parser.opa editor.opa webshell.opa login.opa facebook.opa search.opa dropbox.opa config.opa SRCS = $(SRC:%=src/%) all: $(NAME) diff --git a/src/config.opa b/src/config.opa new file mode 100644 index 0000000..5ddbe4b --- /dev/null +++ b/src/config.opa @@ -0,0 +1,37 @@ +// license: AGPL +// (c) MLstate, 2011, 2012 +// author: Adam Koprowski + +database string /host + +module Config { + + // TODO: abstract away this pattern + server host = + _ = CommandLine.filter( + { init: void + , parsers: [{ CommandLine.default_parser with + names: ["--host"], + param_doc: "HOST", + description: "Sets the address of the application (needed for all redirects)", + function on_param(state) { + parser host=(.*) -> + { + /host <- Text.to_string(host) + {no_params: state} + } + } + }] + , anonymous: [] + , title: "General options" + } + ) + match (?/host) { + case {some: host}: host + default: + Log.error("webshell[config]", "Cannot read host configuration +Please re-run your application with: --host option") + System.exit(1) + } + +} diff --git a/src/facebook.opa b/src/facebook.opa index 1dcae82..cab68dd 100644 --- a/src/facebook.opa +++ b/src/facebook.opa @@ -46,7 +46,7 @@ Please re-run your application with: --fb-config option") private FBA = FbAuth(config) private FBG = FbGraph - private redirect = "http://webshell.tutorials.opalang.org/connect" + private redirect = "http://{Config.host}/connect/facebook" private function get_fb_name(token) { opts = { FBG.Read.default_object with token:token.token }