Permalink
Browse files

Merge pull request #6 from Aqua-Ye/master

Fixed compilation and run with Opa 1.0.5
  • Loading branch information...
2 parents 1f87ee5 + c544aa2 commit 99b67c7c0a866e779bb49064981caffeabdaa5e4 @hbbio committed Jan 31, 2013
Showing with 42 additions and 41 deletions.
  1. +2 −2 Makefile
  2. +6 −6 src/config.opa
  3. +7 −6 src/dropbox.opa
  4. +7 −6 src/facebook.opa
  5. +9 −11 src/search.opa
  6. +10 −9 src/twitter.opa
  7. +1 −1 src/webshell.opa
View
@@ -1,4 +1,4 @@
-NAME = webshell.exe
+NAME = webshell.js
SRC = service.opa editor.opa config.opa login.opa webshell.opa \
calc.opa facebook.opa search.opa dropbox.opa twitter.opa
@@ -7,7 +7,7 @@ SRCS = $(SRC:%=src/%)
all: $(NAME)
$(NAME): $(SRCS)
- opa --parser js-like $(SRCS) -o $(NAME)
+ opa $(SRCS) -o $(NAME)
run: $(NAME)
./$(NAME)
View
@@ -8,8 +8,8 @@ module Config {
// TODO: abstract away this pattern
server host =
- _ = CommandLine.filter(
- { init: void
+ state = CommandLine.filter(
+ { init: none
, parsers: [{ CommandLine.default_parser with
names: ["--host"],
param_doc: "HOST",
@@ -18,8 +18,8 @@ module Config {
parser {
case host=(.*) :
{
- /host <- Text.to_string(host)
- {no_params: state}
+ // /host <- Text.to_string(host)
+ {no_params: some(Text.to_string(host))}
}
}
}
@@ -28,8 +28,8 @@ module Config {
, title: "General options"
}
)
- match (?/host) {
- case {some: host}: host
+ match (state) {
+ case {some: s}: s
default:
Log.error("webshell[config]", "Cannot read host configuration
Please re-run your application with: --host option")
View
@@ -16,8 +16,8 @@ type Dropbox.status = {no_credentials}
module DropboxConnect {
private server config =
- _ = CommandLine.filter(
- { init: void
+ state = CommandLine.filter(
+ { init: none
, parsers: [{ CommandLine.default_parser with
names: ["--dropbox-config"],
param_doc: "APP_KEY,APP_SECRET",
@@ -26,8 +26,9 @@ module DropboxConnect {
parser {
case app_key=Rule.alphanum_string [,] app_secret=Rule.alphanum_string :
{
- /dropbox_config <- ~{app_key, app_secret}
- {no_params: state}
+ db_config = ~{app_key, app_secret}
+ // /dropbox_config <- db_config
+ {no_params: some(db_config)}
}
}
}
@@ -36,7 +37,7 @@ module DropboxConnect {
, title: "Dropbox configuration"
}
)
- match (?/dropbox_config) {
+ match (state) {
case {some: config}: config
default:
Log.error("webshell[config]", "Cannot read Dropbox configuration (application key and/or secret key)
@@ -135,7 +136,7 @@ Please re-run your application with: --dropbox-config option")
match (segs) {
case []: []
case ["." | xs]: aux(xs)
- case [x, ".." | xs]: aux(xs)
+ case [_x, ".." | xs]: aux(xs)
case [x | xs]: [x | aux(xs)]
}
}
View
@@ -20,8 +20,8 @@ module FacebookConnect
{
server config =
- _ = CommandLine.filter(
- { init: void
+ state = CommandLine.filter(
+ { init: none
, parsers: [{ CommandLine.default_parser with
names: ["--fb-config"],
param_doc: "APP_ID,APP_SECRET",
@@ -30,8 +30,9 @@ module FacebookConnect
parser {
case app_id=Rule.alphanum_string [,] app_secret=Rule.alphanum_string:
{
- /facebook_config <- {~app_id, api_key: app_id, ~app_secret};
- {no_params: state}
+ fb_config = {~app_id, api_key: app_id, ~app_secret};
+ // /facebook_config <- fb_config
+ {no_params: some(fb_config)}
}
}
}
@@ -40,7 +41,7 @@ module FacebookConnect
, title: "Facebook configuration"
}
)
- match (?/facebook_config) {
+ match (state) {
case {some: config}: config
default:
Log.error("webshell[config]", "Cannot read Facebook configuration (application id and/or secret key)
@@ -104,7 +105,7 @@ Please re-run your application with: --fb-config option")
outcome = FbGraph.Post.feed(feed, creds.token)
response =
match (outcome) {
- case {~success}: <>Successfully published Facebook feed item: «{feed.message}»</>
+ case {success:_}: <>Successfully published Facebook feed item: «{feed.message}»</>
case {~error}: <>Error: <b>{error.error}</b>; {error.error_description}</>
}
Service.respond_with(response)
View
@@ -1,7 +1,5 @@
-
import stdlib.web.client
import stdlib.core.xhtml
-import stdlib.core.xmlm
type item = { option(string) title, option(string) link, option(string) guid, option(string) description, option(string) pubDate }
@@ -47,8 +45,8 @@ module SearchParser {
module Search {
auth =
- _ = CommandLine.filter(
- { init: void
+ state = CommandLine.filter(
+ { init: none
, parsers: [{ CommandLine.default_parser with
names: ["--blekko-config"],
param_doc: "AUTH_KEY",
@@ -57,8 +55,8 @@ module Search {
parser {
case auth_key=Rule.alphanum_string :
{
- /blekko_auth_key <- auth_key
- {no_params: state}
+ // /blekko_auth_key <- auth_key
+ {no_params: some(auth_key)}
}
}
}
@@ -67,7 +65,7 @@ module Search {
, title: "Blekko configuration"
}
)
- match (?/blekko_auth_key) {
+ match (state) {
case {some: key}: key
default:
Log.error("webshell[config]", "Cannot read Blekko configuration (auth_key)
@@ -111,7 +109,7 @@ Please re-run your application with: --blekko-config option")
(xhtml) match (WebClient.Get.try_get(uri)) {
case {failure:f}: <>"{f}"</>;
case {success:result}:
- match (Xmlm.try_parse(result.content)) {
+ match (Xmlns.try_parse(result.content)) {
case {some:xmlm}:
match (dig(xmlm)) {
case {success:(title,items)}: format_items(title,items);
@@ -167,7 +165,7 @@ Please re-run your application with: --blekko-config option")
function get_text(option(xml('a,'b)) xml_) {
match (xml_) {
- case {some:{args:_, content:[{~text}], namespace:_, specific_attributes:_, tag:_}}: {some:text};
+ case {some:{args:_, content:[{~text}], ...}}: {some:text};
default: none;
}
}
@@ -190,7 +188,7 @@ Please re-run your application with: --blekko-config option")
case {~content_unsafe}: {failure:content_unsafe};
case {fragment:_}: {failure:"fragment"};
case {xml_dialect:_}: {failure:"xml_dialect"};
- case {args:_, ~content, namespace:_, specific_attributes:_, tag:"rss"}:
+ case {~content, tag:"rss", ...}:
match (get_content(single_tag("channel",content))) {
case {some:content}:
title = get_text(single_tag("title",content));
@@ -222,7 +220,7 @@ Please re-run your application with: --blekko-config option")
function get_item(xml('a,'b) xml_) {
//jlog("xml_:{xml_}");
match (xml_) {
- case {args:_,~content, namespace:_, specific_attributes:_, tag:"item"}:
+ case {~content, tag:"item", ...}:
title = get_text(single_tag("title",content))
link = get_text(single_tag("link",content))
guid = get_text(single_tag("guid",content))
View
@@ -13,9 +13,9 @@ type Twitter.status = {no_credentials}
module TwitterConnect
{
- server config =
- _ = CommandLine.filter(
- { init: void
+ config =
+ state = CommandLine.filter(
+ { init: none
, parsers: [{ CommandLine.default_parser with
names: ["--twitter-config"],
param_doc: "APP_KEY,APP_SECRET",
@@ -24,10 +24,11 @@ module TwitterConnect
parser {
case app_key=Rule.alphanum_string [,] app_secret=Rule.alphanum_string:
{
- /twitter_config <- { consumer_key: app_key,
- consumer_secret: app_secret
- }
- {no_params: state}
+ tw_config = { consumer_key: app_key,
+ consumer_secret: app_secret
+ }
+ // /twitter_config <- tw_config
+ {no_params: some(tw_config)}
}
}
}
@@ -36,7 +37,7 @@ module TwitterConnect
, title: "Twitter configuration"
}
)
- match (?/twitter_config) {
+ match (state) {
case {some: config}: config
default:
Log.error("webshell[config]", "Cannot read Twitter configuration (application key and/or secret key)
@@ -80,7 +81,7 @@ Please re-run your application with: --twitter-config option")
private function authenticate() {
match (TWA.get_request_token(redirect)) {
- case {~error}:
+ case {error:_}:
Service.respond_with(<>Twitter authorization failed</>)
case {success: token}:
auth_url = TWA.build_authorize_url(token.token)
View
@@ -113,7 +113,7 @@ function page(cmd) {
}
function connect(connector, raw_data) {
- connector(Text.to_string(raw_data))
+ _ = connector(Text.to_string(raw_data))
Resource.default_redirection_page("/")
}

0 comments on commit 99b67c7

Please sign in to comment.