This repository has been archived by the owner on Oct 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
launch.hl
144 lines (119 loc) · 3.5 KB
/
launch.hl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
* URL resolver for Micro.
*
* Includes support for downloading files using __[micro.download.file]__ and uploading files
* using the __[micro.widgets.upload-button]__.
*/
/*
* Checking if this is a download request.
*/
split:x:/../*/url?value
=:/
=:?
if:x:/@split/1?name
=:download
/*
* This is a download request, making sure we've got a file reference in our session.
*/
p5.web.session.get:micro.download.file
if:x:/@p5.web.session.get/*
/*
* Clearing session value.
*/
p5.web.session.set:micro.download.file
/*
* Echoing file back to client, adding all HTTP headers first.
*/
for-each:x:/@p5.web.session.get/*/*/*
p5.web.header.set:x:/@_dp/#?name
src:x:/@_dp/#?value
p5.web.echo-file:x:/@p5.web.session.get/*/*/file?value
else
/*
* The client is not supposed to be allowed to download a file at this time.
*/
p5.web.response.set-status-code:404
p5.web.echo:Oops 404, the place where URLs go to die!
else-if:x:/@split/1?name
=:upload
/*
* Upload request.
*
* Verifying that user has previously created an upload button, to avoid drowning
* server in fake uploads.
*
* Notice, since we persist all uploads in the same folder, there is no need
* to implement this for each button - Rather simply verify that an upload button
* has been previously created is enough ...
*/
if
fetch:x:/0/0?value
p5.web.session.get:micro.widgets.upload-button
/*
* Uploads allowed.
*
* First parsing mime message, using "~/temp/" folder as attachment folder.
*/
p5.web.request.parse-mime
attachment-folder:~/temp/
/*
* Then returning all files that were successfully uploaded to client as JSON.
*/
.files
for-each:x:/@p5.web.request.parse-mime/*/multipart/*/*/filename
eval-x:x:/+/*/*
add:x:/@.files
src
:{0}{1}{2}
:x:/@_dp/#/*/folder?value
:x:/@_dp/#/*/prefix?value
:x:/@_dp/#?value
lambda2json:x:/@.files/*
p5.web.header.set:Content-Type
src:application/json
p5.web.echo:x:/@lambda2json?value
else
/*
* Uploads not allowed, since there doesn't exist any upload button on page.
*/
p5.web.response.set-status-code:404
p5.web.echo:Oops 404, the place where URLs go to die!
else-if:x:/@split/1?name
=:pgp
/*
* Some sort of PGP key retrieval request.
*
* Checking first it it was not parametrised at all, at which point we assume
* the caller is requesting the server's main public PGP key.
*/
if:x:/@split/*?count
=:int:2
/*
* Returning server's main public PGP key.
*/
p5.auth.pgp.get-fingerprint
p5.crypto.pgp-keys.public.get:x:/-/0?name
p5.web.echo:x:/-/0?value
else-if:x:/@split/2?name
=:list
/*
* Listing all public PGP keys server has access to.
*/
p5.crypto.pgp-keys.public.list
p5.crypto.pgp-keys.get-details:x:/-/*?name
lambda2hyper:x:/-/*
p5.web.echo:x:/-?value
else
/*
* Assuming third argument is some sort of search criteria for looking up PGP keys.
*/
p5.crypto.pgp-keys.public.get:x:/@split/2?name
join:x:/-/*?value
sep:"\r\n"
p5.web.echo:x:/-?value
else
/*
* Non-existing URL.
*/
p5.web.response.set-status-code:404
p5.web.echo:Oops 404, the place where URLs go to die!