Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use a distinct file for error output of spawned processes. Minor refa…

…ctoring of publishing code. Correct handling of escape character in JSON string. Fixed issue where trailing junk was included in compressed outpout.
  • Loading branch information...
commit 5b3412a7c22e9767759c09766bae884eafedcf85 1 parent 559d050
@lparenteau authored
View
6 r/databallet.m
@@ -1,6 +1,6 @@
;
; This file is part of DataBallet.
- ; Copyright (C) 2012 Laurent Parenteau <laurent.parenteau@gmail.com>
+ ; Copyright (C) 2012-2013 Laurent Parenteau <laurent.parenteau@gmail.com>
;
; DataBallet is free software: you can redistribute it and/or modify
; it under the terms of the GNU Affero General Public License as published by
@@ -93,7 +93,7 @@ set conf("compressible","text/plain")=1
set conf("compressible","application/javascript")=1
; DataBallet version : YYYYMMDD
- set databalletver=20121217
+ set databalletver=20130125
quit
@@ -150,7 +150,7 @@ set conf("compressible","application/javascript")=1
. quit:$data(@TMP@("DataBallet","quit"))
. set handle=$piece(key,"|",2)
. ; Spawn a new process to handle the connection then close the connected socket as we won't use it from here.
- . zsystem "PORT="_port_" $gtm_dist/mumps -run serve^databallet <&"_socketfd_" >&"_socketfd_" 2>>"_conf("errorlog")_" &"
+ . zsystem "PORT="_port_" $gtm_dist/mumps -run serve^databallet <&"_socketfd_" >&"_socketfd_" 2>>"_conf("errorlog")_".fork &"
. close socket:(socket=handle:exception="new dontcare")
. use socket
close socket
View
12 r/githubnews.m
@@ -1,6 +1,6 @@
;
; This file is part of DataBallet.
- ; Copyright (C) 2012 Laurent Parenteau <laurent.parenteau@gmail.com>
+ ; Copyright (C) 2012-2013 Laurent Parenteau <laurent.parenteau@gmail.com>
;
; DataBallet is free software: you can redistribute it and/or modify
; it under the terms of the GNU Affero General Public License as published by
@@ -34,15 +34,7 @@
set payload=$zpiece(request("content"),"=",2)
set status=$$decode^json($$decode^url(payload),"push")
if status=0 do if 1
- . for i=0:1:$order(push("commits",""),-1) do
- . . tstart ():serial
- . . set (postid,@NEWS@("count"))=$get(@NEWS@("count"))+1
- . . set @NEWS@("post",postid,"title")="Code committed to GitHub!"
- . . set @NEWS@("post",postid,"summary")=push("commits",i,"message")
- . . set @NEWS@("post",postid,"content")="Commit <a href="""_push("commits",i,"url")_""">#"_push("commits",i,"id")_"</a>: "_push("commits",i,"message")
- . . set @NEWS@("post",postid,"updated")=$horolog
- . . set:$get(@NEWS@("post",postid,"published"))="" @NEWS@("post",postid,"published")=@NEWS@("post",postid,"updated")
- . . tcommit
+ . for i=0:1:$order(push("commits",""),-1) do publish^news("Code committed to GitHub!",push("commits",i,"message"),"Commit <a href="""_push("commits",i,"url")_""">#"_push("commits",i,"id")_"</a>: "_push("commits",i,"message"))
. do addcontent^response("Thanks! :)")
else do addcontent^response("Sorry... :(")
View
14 r/json.m
@@ -1,6 +1,6 @@
;
; This file is part of DataBallet.
- ; Copyright (C) 2012 Laurent Parenteau <laurent.parenteau@gmail.com>
+ ; Copyright (C) 2012-2013 Laurent Parenteau <laurent.parenteau@gmail.com>
;
; DataBallet is free software: you can redistribute it and/or modify
; it under the terms of the GNU Affero General Public License as published by
@@ -80,10 +80,16 @@
. . set json=$zextract(json,2,length) ; skip over [
. . set status=$$decode^json(.json,var,0,1)
. else if first="""" do if 1
+ . . new value,piece
. . set:$get(inarray,0)=1 var=base_"0)" ; First item of array, add a '0' subscript
- . . if $get(nextisname,0)=1 set var=base_""""_$zpiece(json,"""",2)_""")" set nextisname=0
- . . else set @var=$zpiece(json,"""",2)
- . . set json=$zpiece(json,"""",3,length) ; skip over ..."
+ . . set piece=2
+ . . set value=$zpiece(json,"""",piece)
+ . . for quit:$zextract(value,$zlength(value))'="\" do ; Handle espaced '"'
+ . . . set piece=piece+1
+ . . . set value=$zextract(value,1,$zlength(value)-1)_""""_$zpiece(json,"""",piece)
+ . . if $get(nextisname,0)=1 set var=base_""""_value_""")" set nextisname=0
+ . . else set @var=value
+ . . set json=$zpiece(json,"""",piece+1,length) ; skip over ..."
. else if first="}" do if 1
. . set json=$zextract(json,2,length) ; skip over }
. . set end=1
View
33 r/news.m
@@ -1,6 +1,6 @@
;
; This file is part of DataBallet.
- ; Copyright (C) 2012 Laurent Parenteau <laurent.parenteau@gmail.com>
+ ; Copyright (C) 2012-2013 Laurent Parenteau <laurent.parenteau@gmail.com>
;
; DataBallet is free software: you can redistribute it and/or modify
; it under the terms of the GNU Affero General Public License as published by
@@ -270,14 +270,7 @@ set response("headers","Content-Type")="text/html"
else if action="add" do if 1
. if $$methodis^request("PUT,POST") do if 1
. . for i=1:1:3 set value=$zpiece(request("content"),"&",i),content($zpiece(value,"=",1))=$$paragraph($$decode^url($zpiece(value,"=",2,$zlength(line))))
- . . tstart ():serial
- . . set:postid="" (postid,@NEWS@("count"))=$get(@NEWS@("count"))+1
- . . set @NEWS@("post",postid,"title")=$get(content("title"))
- . . set @NEWS@("post",postid,"summary")=$get(content("summary"))
- . . set @NEWS@("post",postid,"content")=$get(content("content"))
- . . set @NEWS@("post",postid,"updated")=$horolog
- . . set:$get(@NEWS@("post",postid,"published"))="" @NEWS@("post",postid,"published")=@NEWS@("post",postid,"updated")
- . . tcommit
+ . . do publish^news($get(content("title")),$get(content("summary")),$get(content("content")))
. . do set^response(303) set response("headers","Location")=urlroot_"admin/"
. else do set^response(404)
else if action="update" do if 1
@@ -305,3 +298,25 @@ set response("headers","Content-Type")="text/html"
for quit:$zfind(p,br)=0 do
. set p=$zpiece(p,br,1)_"</p><p>"_$zpiece(p,br,2,$zlength(p))
quit p
+
+publish(title,summary,content,published)
+ ;
+ ; Publish a NEWS entry.
+ ;
+ ; All parameters are optional and default to an empty string, expect for published which default to $horolog.
+ ;
+ new postid
+
+ ; Default NEWS
+ if '$data(NEWS) new NEWS set NEWS="^NEWS"
+
+ tstart ():serial
+ set (postid,@NEWS@("count"))=$get(@NEWS@("count"))+1
+ set @NEWS@("post",postid,"title")=$get(title)
+ set @NEWS@("post",postid,"summary")=$get(summary)
+ set @NEWS@("post",postid,"content")=$get(content)
+ set @NEWS@("post",postid,"updated")=$get(published,$horolog)
+ set:$get(@NEWS@("post",postid,"published"))="" @NEWS@("post",postid,"published")=@NEWS@("post",postid,"updated")
+ tcommit
+
+ quit
View
3  r/response.m
@@ -1,6 +1,6 @@
;
; This file is part of DataBallet.
- ; Copyright (C) 2012 Laurent Parenteau <laurent.parenteau@gmail.com>
+ ; Copyright (C) 2012-2013 Laurent Parenteau <laurent.parenteau@gmail.com>
;
; DataBallet is free software: you can redistribute it and/or modify
; it under the terms of the GNU Affero General Public License as published by
@@ -196,6 +196,7 @@ write connection("HTTPVER")_" "_response("status")_" "_conf("status",response("s
. use cmd
. write data
. write /eof
+ . set $X=0
. read data
. close cmd
. use old
Please sign in to comment.
Something went wrong with that request. Please try again.