Created
June 28, 2015 23:44
-
-
Save Drahflow/c463717d5c72e114ac63 to your computer and use it in GitHub Desktop.
Elymas example program
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
"utils.ey" include | |
{ "=>" via | |
<< | |
»SELECT * FROM categories { ":" via | |
<< :color '' ==>color >> :name ==> | |
} each | |
>> "application/json; charset=utf-8" =>ok | |
} /returnCategories deffst | |
{ "=>" via | |
[[ | |
»SELECT l.*, c.name AS category FROM layers l JOIN categories c ON c.id = l.category ORDER BY l.day DESC, l.name ASC |rowData each | |
]] | |
"application/json; charset=utf-8" =>ok | |
} /returnLayers deffst | |
{ "=>" via # ==layer | |
»SELECT * FROM transformations WHERE layer = $1 | |
_ len { 0 -01 * ":" via | |
<< | |
"1" ==>exists | |
[[ | |
:xl1 :yl1 :xg1 :yg1 | |
:xl2 :yl2 :xg2 :yg2 | |
:xl3 :yl3 :xg3 :yg3 | |
]] ==>correlate | |
>> | |
} { -- << >> } ? * | |
"application/json; charset=utf-8" =>ok | |
} /returnTransformation deffst | |
{ _ "=>" via .args ":" via ==layer | |
[ | |
{ :pw UPDATEPW eq not }' { "<html><body>wrong password</body></html>" "text/html" =>fail } | |
{ :v "," split _ len 12 neq }' { -- "<html><body>correlates not in correct format</body></html>" "text/html" =>fail } | |
{ 1 }' { # ==reverseCorrelates | |
layer »DELETE FROM transformations WHERE layer = $1 | |
_ 12 dearray layer »INSERT INTO transformations VALUES ($13, $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12) | |
dump layer dump "correlates updated" dump | |
"<html><body>updated</body></html>" "text/html" =>ok | |
} | |
] conds | |
} /updateTransformation deffst | |
{ _ "=>" via .args ":" via ==user | |
[ | |
{ user :pw »SELECT 1 FROM comments WHERE name = $1 AND pw = $2 len not }' | |
{ "<html><body>wrong password</body></html>" "text/html" =>fail } | |
{ 1 }' { | |
user :pw :v »UPDATE comments SET value = $3 WHERE name = $1 AND pw = $2 | |
dump user dump "comment updated" dump | |
"<html><body>updated</body></html>" "text/html" =>ok | |
} | |
] conds | |
} /updateComments deffst | |
{ "=>" via # ==user | |
»SELECT * FROM comments WHERE name = $1 | |
_ len { 0 -01 * ":" via | |
<< | |
"1" ==>exists | |
:value ==>value | |
>> | |
} { -- << >> } ? * | |
"application/json; charset=utf-8" =>ok | |
} /returnComments deffst | |
net .alg .httpServer "|-" via | |
{ 8090 } |-port | |
{ _ ":" via ":." == :url dump | |
[ | |
{ :url "/categories" eq } { | |
:. returnCategories } | |
{ :url "/layers" eq } { | |
:. returnLayers } | |
{ :url "/transformation/(\\d+)" regex } { | |
:. :args .?pw |updateTransformation |returnTransformation ? * } | |
{ :url "/transformation/(\\d+)" regex } { | |
:. returnTransformation } | |
{ :url "/comments/(.+)" regex :args .?pw and } { | |
:. updateComments } | |
{ :url "/comments/(.+)" regex } { | |
:. returnComments } | |
{ 1 }' { | |
:. "<html><body>Page not found.</body></html>" "text/html" :fail } | |
] conds | |
} |-request | |
|-run | |
# vim: syn=elymas |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment