Mercurial > repos > rhope
annotate framework.rhope @ 147:f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 22 Nov 2010 01:15:02 -0500 |
parents | 6202b866d72c |
children | f582fd6c75ee |
rev | line source |
---|---|
0 | 1 Import webserver.rhope |
2 | |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
3 _Key Value Map[list,index,newlist,worker:out] |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
4 { |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
5 newval,newkey <- [worker]Call[[list]Index[index], index] |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
6 |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
7 next <- [newlist]Set[newkey, newval] |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
8 |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
9 [list]Next[index] |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
10 { |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
11 out <- _Key Value Map[list, ~, next, worker] |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
12 }{ |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
13 out <- Val[next] |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
14 } |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
15 } |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
16 |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
17 Key Value Map[list,worker:out] |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
18 { |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
19 [list]First |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
20 { |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
21 out <- _Key Value Map[list, ~, New Like[list], worker] |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
22 }{ |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
23 out <- New Like[list] |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
24 } |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
25 } |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
26 |
0 | 27 Framework Handler[con,path,request type,queryvars,headers,handler,title,use session] |
28 { | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
29 page <- Page[title, path, use session, queryvars, headers] |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
30 handler page <- [handler]Call[page,path] |
0 | 31 If[[request type] = ["POST"]] |
32 { | |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
33 final page,ncon <- Process POST[handler page, con, headers] |
0 | 34 }{ |
35 final page <- Val[handler page] | |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
36 ncon <- Val[con] |
0 | 37 } |
38 string,out headers <- [final page]Render | |
39 | |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
40 after headers <- HTTP OK[ncon, Get Content Type[".html"], [string]Byte Length, out headers] |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
41 { Print["Sent status"] |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
42 { [[string]Write to File[after headers]]Close |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
43 { Print["Wrote data"] }}} |
0 | 44 } |
45 | |
46 Handler Fixer[handler:out] | |
47 { | |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
48 [(List(),List Leaf())]Find[=[?,Blueprint Of[handler]]] |
0 | 49 { |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
50 out <- Val[Framework Handler[?, ?, ?, ?, ?, [handler]Index[0], [handler]Index[1], [handler]Index[2]]] |
0 | 51 }{ |
52 out <- handler | |
53 } | |
54 } | |
55 | |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
56 Start Web[handlers,port] |
0 | 57 { |
58 Print["Starting Rhope Web Server"] | |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
59 workaround <- Init Sessions[] |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
60 Val[workaround] |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
61 { Listen on Port[port,Connection Start[?, ?, Map[handlers,Handler Fixer[?]]]] |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
62 { Wait Forever[] }} |
0 | 63 } |
64 | |
65 Get Class[container:class] | |
66 { | |
67 If[[[[container]Class >>]Length] > [0]] | |
68 { | |
69 class <- [[" class=\""]Append[[container]Class >>]]Append["\""] | |
70 }{ | |
71 class <- "" | |
72 } | |
73 } | |
74 | |
75 Blueprint Web Event | |
76 { | |
77 Event Name | |
78 Origin | |
79 Data | |
80 } | |
81 | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
82 Web Event[name,origin,data:out] |
0 | 83 { |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
84 out <- [[[Build[Web Event()]]Event Name <<[name]]Origin <<[origin]]Data <<[data] |
0 | 85 } |
86 | |
87 Blueprint Web Container | |
88 { | |
89 Tag Name | |
90 Class | |
91 Propagate Events | |
92 Children | |
93 Handlers | |
94 Named Children | |
95 Session | |
96 Use Session | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
97 Preformatted |
0 | 98 } |
99 | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
100 Web Container[class:out] |
0 | 101 { |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
102 out <- [[[[[[[[Build[Web Container()] |
0 | 103 ]Tag Name <<["div"] |
104 ]Class <<[class] | |
105 ]Propagate Events <<[No] | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
106 ]Children <<[List[]] |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
107 ]Named Children <<[Dictionary[]] |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
108 ]Handlers <<[Dictionary[]] |
0 | 109 ]Use Session <<[No] |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
110 ]Preformatted <<[No] |
0 | 111 } |
112 | |
113 Name@Web Container[cont:out,none] | |
114 { | |
115 none <- cont | |
116 } | |
117 | |
118 Render Child[start,container:out] | |
119 { | |
120 out <- [start]Append[[container]Render] | |
121 } | |
122 | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
123 _Preformatted[child,val:out] |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
124 { |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
125 If[[Blueprint Of[child]] = [Web Text()]] |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
126 { |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
127 out <- [child]Preformatted <<[val] |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
128 }{ |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
129 If[[Blueprint Of[child]] = [Web Container()]] |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
130 { |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
131 out <- [child]Preformatted[val] |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
132 }{ |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
133 out <- child |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
134 } |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
135 } |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
136 } |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
137 |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
138 Preformatted@Web Container[cont,preformatted?:out] |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
139 { |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
140 out <- [[cont]Children <<[ Map[[cont]Children >>, _Preformatted[?, preformatted?]] ] |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
141 ]Preformatted <<[preformatted?] |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
142 } |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
143 |
0 | 144 Set Session@Web Container[container,session:out] |
145 { | |
146 out <- [ | |
147 [ | |
148 [container]Use Session <<[Yes] | |
149 ]Session <<[session] | |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
150 ]Children <<[ Map[ [container]Children >>, Set Session[?, session] ] ] |
0 | 151 } |
152 | |
153 Set Handler@Web Container[container,event name,handler:out] | |
154 { | |
155 out <- [container]Handlers <<[ [[container]Handlers >> ]Set[event name, handler] ] | |
156 } | |
157 | |
158 Render@Web Container[container:out,headers] | |
159 { | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
160 If[[container]Preformatted >>] |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
161 { |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
162 newline <- "" |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
163 tab <- "" |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
164 }{ |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
165 newline <- "\n" |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
166 tab <- "\t" |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
167 } |
0 | 168 out <- [[[[[[["<"]Append[ [container]Tag Name >> ] |
169 ]Append[Get Class[container]] | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
170 ]Append[[[">"]Append[newline]]Append[tab]] |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
171 ]Append[Fold[Render Child[?], "", [container]Children >>]] |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
172 ]Append[[newline]Append["</"]] |
0 | 173 ]Append[ [container]Tag Name >> ] |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
174 ]Append[[">"]Append[newline]] |
0 | 175 } |
176 | |
177 Container Event Handler[container,events,index:cont,out events] | |
178 { | |
179 event <- [events]Index[index] | |
180 [[container]Handlers >>]Index[ [event]Event Name >>] | |
181 { | |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
182 //The original version, you had to populate the container output |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
183 //and optionally populate the new event output, but that won't work |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
184 //now. None of my existing code really needs to populate both so I've |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
185 //made them mutually exclusive. |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
186 new container <- [~]Call[container,event] |
0 | 187 { |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
188 out events <- Val[result events] |
0 | 189 }{ |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
190 out events <- [result events]Append[~] |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
191 new container <- Val[container] |
0 | 192 } |
193 }{ | |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
194 new container <- Val[container] |
0 | 195 out events <- Val[result events] |
196 } | |
197 | |
198 [events]Next[index] | |
199 { | |
200 cont, result events <- Container Event Handler[new container, events, ~] | |
201 }{ | |
202 cont <- Val[new container] | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
203 result events <- List[] |
0 | 204 } |
205 } | |
206 | |
207 Container Postback Helper[container,post data,index,events:out,out events] | |
208 { | |
209 ,current events <- [[[container]Children >>]Index[index]]Postback[post data] | |
210 { | |
211 new container <- [container]Children <<[[[container]Children >>]Set[index, ~]] | |
212 } | |
213 combined events <- Concatenate[events, current events] | |
214 [[new container]Children >>]Next[index] | |
215 { | |
216 out, out events <- Container Postback Helper[new container, post data, ~, combined events] | |
217 }{ | |
218 [combined events]First | |
219 { | |
220 out, newevents <- Container Event Handler[new container, combined events, ~] | |
221 out events <- Concatenate[combined events, newevents] | |
222 }{ | |
223 out <- Val[new container] | |
224 out events <- Val[combined events] | |
225 } | |
226 } | |
227 } | |
228 | |
229 Postback@Web Container[container,post data:out,events] | |
230 { | |
231 [[container]Children >>]First | |
232 { | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
233 out, postback events <- Container Postback Helper[container, post data, ~, List[]] |
0 | 234 If[[container]Propagate Events >>] |
235 { | |
236 events <- Val[postback events] | |
237 }{ | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
238 events <- List[] |
0 | 239 } |
240 }{ | |
241 out <- container | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
242 events <- List[] |
0 | 243 } |
244 } | |
245 | |
246 Add Child[cont,child:out] | |
247 { | |
248 If[[cont]Use Session >>] | |
249 { | |
250 prepped child <- [child]Set Session[[cont]Session >>] | |
251 }{ | |
252 prepped child <- Val[child] | |
253 } | |
254 with child <- [cont]Children <<[ [[cont]Children >>]Append[prepped child] ] | |
255 | |
256 [prepped child]Name | |
257 { | |
258 out <- [with child]Named Children <<[ [[with child]Named Children >>]Set[~, [[[with child]Children >>]Length] - [1]] ] | |
259 }{ | |
260 out <- Val[with child] | |
261 } | |
262 } | |
263 | |
264 Get Child By Name[container,name:out,not found] | |
265 { | |
266 ,not found <- [[container]Named Children >>]Index[name] | |
267 { | |
268 out <- [[container]Children >>]Index[~] | |
269 } | |
270 } | |
271 | |
272 Blueprint Page | |
273 { | |
274 Title | |
275 URL | |
276 CSS | |
277 Children | |
278 Named Children | |
279 Handlers | |
280 Use Session | |
281 Session | |
282 Session ID | |
283 } | |
284 | |
285 Set Handler@Page[container,event name,handler:out] | |
286 { | |
287 out <- [container]Handlers <<[ [[container]Handlers >> ]Set[event name, handler] ] | |
288 } | |
289 | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
290 Page[title,url,use session,queryvars,headers:out] |
0 | 291 { |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
292 page <- [[[[[[[Build[Page()] |
0 | 293 ]Title <<[title] |
294 ]URL <<[url] | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
295 ]CSS <<[[List[]]Append["/default.css"]] |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
296 ]Children <<[List[]] |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
297 ]Named Children <<[Dictionary[]] |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
298 ]Handlers <<[Dictionary[]] |
0 | 299 ]Use Session <<[use session] |
300 If[use session] | |
301 { | |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
302 Load Session[queryvars, headers] |
0 | 303 { |
304 out <- [[page]Session <<[~]]Session ID <<[ [~]Session ID>>] | |
305 } | |
306 }{ | |
307 out <- Val[page] | |
308 } | |
309 } | |
310 | |
311 Get Action@Page[page:out] | |
312 { | |
313 If[[page]Use Session>>] | |
314 { | |
315 [[page]Session >>]Get Link Params | |
316 { | |
317 out <- [[[page]URL >>]Append["?"]]Append[~] | |
318 }{ | |
319 out <- [page]URL >> | |
320 } | |
321 }{ | |
322 out <- [page]URL >> | |
323 } | |
324 } | |
325 | |
326 Render@Page[page:out,headers] | |
327 { | |
328 out <- [[[[[[["<html>\n\t<head>\n\t\t<title>"]Append[[page]Title >>] | |
329 ]Append["</title>\n\t\t<link rel=\"stylesheet\" href=\""] | |
330 ]Append[[[page]CSS >>]Join["\">\n\t\t<link rel=\"stylesheet\" href=\""]] | |
331 ]Append["\">\n\t</head>\n\t<body>\n\t<form method=\"POST\" action=\""] | |
332 ]Append[[[page]Get Action]Append["\">\n"]] | |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
333 ]Append[Fold[Render Child[?], "", [page]Children >>]] |
0 | 334 ]Append["\t</form>\n\t</body>\n</html>"] |
335 If[[page]Use Session>>] | |
336 { | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
337 headers <- [[page]Session >>]Finalize[Dictionary[]] |
0 | 338 }{ |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
339 headers <- Dictionary[] |
0 | 340 } |
341 } | |
342 | |
343 Clear Children[page:out] | |
344 { | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
345 out <- [[page]Children <<[List[]]]Named Children <<[Dictionary[]] |
0 | 346 } |
347 | |
348 Set@Page[page,key,val:out] | |
349 { | |
350 out <- [page]Session <<[ [[page]Session >>]Set[key, val] ] | |
351 } | |
352 | |
353 Index@Page[page,key:out,not found] | |
354 { | |
355 out,not found <- [[page]Session >>]Index[key] | |
356 } | |
357 | |
358 First@Page[page:first,not found] | |
359 { | |
360 first,not found <- [[page]Session >>]First | |
361 } | |
362 | |
363 Next@Page[page,last:next,not found] | |
364 { | |
365 next,not found <- [[page]Session >>]Next[last] | |
366 } | |
367 | |
368 Add CSS@Page[page,css:out] | |
369 { | |
370 out <- [page]CSS <<[ [[page]CSS >>]Append[css] ] | |
371 } | |
372 | |
373 Clear CSS@Page[page:out] | |
374 { | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
375 out <- [page]CSS <<[List[]] |
0 | 376 } |
377 | |
378 Decode Helper Decode[list,destlist,index:out] | |
379 { | |
380 code,rest <- [[list]Index[index]]Slice[2] | |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
381 decoded <- String[[Array[]]Append[Trunc UInt8[Abs UInt[Hex Int32[code]]]]] |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
382 newlist <- [destlist]Set[index, [decoded]Append[rest]] |
0 | 383 [list]Next[index] |
384 { | |
1
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
385 out <- Decode Helper Decode[list, newlist, ~] |
0 | 386 }{ |
387 out <- Val[newlist] | |
388 } | |
389 } | |
390 | |
391 Decode Helper Straight[list,destlist,index:out] | |
392 { | |
393 newlist <- [destlist]Set[index, [list]Index[index]] | |
394 [list]Next[index] | |
395 { | |
396 out <- Decode Helper Decode[list, newlist, ~] | |
397 }{ | |
398 out <- Val[newlist] | |
399 } | |
400 } | |
401 | |
402 URL Decode[val:out] | |
403 { | |
404 parts <- [val]Split["%"] | |
405 [parts]First | |
406 { | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
407 out <- [Decode Helper Straight[parts, List[], ~]]Join[""] |
0 | 408 }{ |
409 out <- val | |
410 } | |
411 } | |
412 | |
413 URL Encode Path[string:out] | |
414 { | |
415 out <- [[[[string]Replace["%","%25"]]Replace[" ","%20"]]Replace["/","%2F"]]Replace["?","%3F"] | |
416 } | |
417 | |
418 Decode Pair[val,key:oval,okey] | |
419 { | |
420 oval <- URL Decode[val] | |
421 okey <- URL Decode[key] | |
422 } | |
423 | |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
424 Process POST[page,con,headers:out,ncon] |
0 | 425 { |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
426 ,ncon <- [con]Read[[headers]Index["Content-Length"]] |
0 | 427 { |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
428 post string <- [String[~]]Replace["+"," "] |
0 | 429 } |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
430 post data <- Key Value Map[Dict Split[post string, "=", "&"], Decode Pair[?]] |
0 | 431 out <- [page]Postback[post data] |
432 } | |
433 | |
434 Postback@Page[page,post data:out,events] | |
435 { | |
436 [[page]Children >>]First | |
437 { | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
438 out, events <- Container Postback Helper[page, post data, ~, List[]] |
0 | 439 }{ |
440 out <- page | |
441 } | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
442 events <- List[] |
0 | 443 } |
444 | |
445 Blueprint Web Text | |
446 { | |
447 Text | |
448 Enclosing Tag | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
449 Preformatted |
0 | 450 } |
451 | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
452 Web Text[text,tag:out] |
0 | 453 { |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
454 out <- [[[Build[Web Text()]]Text <<[text]]Enclosing Tag <<[tag]]Preformatted <<[No] |
0 | 455 } |
456 | |
457 Name@Web Text[text:out,none] | |
458 { | |
459 none <- text | |
460 } | |
461 | |
462 Escape HTML Text[string:out] | |
463 { | |
464 out <- [[[string]Replace["&","&"]]Replace["<", "<"]]Replace[">", ">"] | |
465 } | |
466 | |
467 Render@Web Text[text:out,headers] | |
468 { | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
469 escaped <- Escape HTML Text[[text]Text >>] |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
470 If[[text]Preformatted >>] |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
471 { |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
472 processed text <- Val[escaped] |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
473 }{ |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
474 processed text <- [escaped]Replace["\n","<br>\n\t"] |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
475 } |
0 | 476 If[[[[text]Enclosing Tag >>]Length] = [0]] |
477 { | |
478 out <- Val[processed text] | |
479 }{ | |
480 out <- [[[["<"]Append[[text]Enclosing Tag >>]]Append[">"]]Append[processed text]]Append[[["</"]Append[[text]Enclosing Tag >>]]Append[">"]] | |
481 } | |
482 } | |
483 | |
484 Postback@Web Text[text,post data:out,events] | |
485 { | |
486 out <- text | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
487 events <- List[] |
0 | 488 } |
489 | |
490 Set Session@Web Text[text,session:out] | |
491 { | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
492 out <- text |
0 | 493 } |
494 | |
495 Render@String[string:out,headers] | |
496 { | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
497 out <- [Web Text[string,""]]Render |
0 | 498 } |
499 | |
500 Name@String[string:out,none] | |
501 { | |
502 none <- string | |
503 } | |
504 | |
505 Postback@String[in,post data:out,events] | |
506 { | |
507 out <- in | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
508 events <- List[] |
0 | 509 } |
510 | |
511 Set Session@String[in,session:out] | |
512 { | |
513 out <- in | |
514 } | |
515 | |
516 Blueprint Web Field | |
517 { | |
518 Name | |
519 Value | |
520 Type | |
521 Class | |
522 } | |
523 | |
524 Name@Web Field[field:name,none] | |
525 { | |
526 name <- [field]Name >> | |
527 } | |
528 | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
529 Web Field[name,value,type:out] |
0 | 530 { |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
531 out <- [[[[Build[Web Field()]]Name <<[name]]Value <<[value]]Type <<[type]]Class <<[""] |
0 | 532 } |
533 | |
534 Set Session@Web Field[in,session:out] | |
535 { | |
536 out <- in | |
537 } | |
538 | |
539 Render@Web Field[field:out,headers] | |
540 { | |
541 If[[[field]Type >>] = ["multiline"]] | |
542 { | |
543 out <- [[[[[["<textarea name=\""]Append[[field]Name >>]]Append["\""]]Append[Get Class[field]]]Append[">"]]Append[[field]Value >>]]Append["</textarea>"] | |
544 }{ | |
545 out <- [[[[[[[["<input type=\""]Append[[field]Type >>]]Append["\" name=\""]]Append[[field]Name >>]]Append["\""]]Append[Get Class[field]]]Append[" value=\""]]Append[[field]Value >>]]Append["\">"] | |
546 } | |
547 | |
548 } | |
549 | |
550 Postback@Web Field[field,post data:out,event] | |
551 { | |
552 [post data]Index[[field]Name >>] | |
553 { | |
554 out <- [field]Value <<[~] | |
555 | |
556 If[[[field]Value >>] = [~]] | |
557 { | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
558 event <- List[] |
0 | 559 }{ |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
560 event <- [List[]]Append[ Web Event["change", [field]Name >>, [field]Value >>] ] |
0 | 561 } |
562 }{ | |
563 out <- field | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
564 event <- List[] |
0 | 565 } |
566 } | |
567 | |
568 Blueprint Web Button | |
569 { | |
570 Name | |
571 Label | |
572 Class | |
573 } | |
574 | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
575 Web Button[name,label:out] |
0 | 576 { |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
577 out <- [[[Build[Web Button()]]Name <<[name]]Label <<[label]]Class <<[""] |
0 | 578 } |
579 | |
580 Name@Web Button[button:name,none] | |
581 { | |
582 name <- [button]Name >> | |
583 } | |
584 | |
585 Set Session@Web Button[in,session:out] | |
586 { | |
587 out <- in | |
588 } | |
589 | |
590 Postback@Web Button[button,post data:out,events] | |
591 { | |
592 out <- button | |
593 [post data]Index[[button]Name >>] | |
594 { | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
595 events <- [List[]]Append[ Web Event["click", [button]Name >>, 0] ] |
0 | 596 }{ |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
597 events <- List[] |
0 | 598 } |
599 } | |
600 | |
601 Render@Web Button[button:out,headers] | |
602 { | |
603 out <- [[[[[["<input type=\"submit\" name=\""]Append[[button]Name >>]]Append["\""]]Append[Get Class[button]]]Append[" value=\""]]Append[[button]Label >>]]Append["\">"] | |
604 } | |
605 | |
606 Blueprint Session | |
607 { | |
608 Session ID | |
609 IP Address | |
610 Use Cookies | |
611 Data | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
612 Dirty |
0 | 613 } |
614 | |
615 Get Unique ID[:out] uses Session | |
616 { | |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
617 Print["Get Unique ID"] |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
618 out <- [[String[Session::ID]]Append["_"]]Append[String[Random[]]] |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
619 { Session::ID <- [Session::ID]+[1] } |
0 | 620 } |
621 | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
622 Session[:out] |
0 | 623 { |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
624 out <- [[[[Build[Session()]]Session ID <<[Get Unique ID[]]]Use Cookies <<[No]]Data <<[Dictionary[]]]Dirty <<[No] |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
625 { Print["Built session"] } |
0 | 626 } |
627 | |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
628 Load Session[queryvars,headers:out] uses Session |
0 | 629 { |
630 ,checkquery <- [headers]Index["Cookie"] | |
631 { | |
632 parts <- Dict Split[~, "=", "; "] | |
633 ,checkquery <- [parts]Index["session_id"] | |
634 { | |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
635 ,checkquery <- [Session::Sessions]Index[~] |
0 | 636 { |
637 out <- [~]Use Cookies <<[Yes] | |
638 } | |
639 } | |
640 } | |
641 | |
642 | |
643 Val[checkquery] | |
644 { | |
645 ,makenew <- [queryvars]Index["session_id"] | |
646 { | |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
647 out, makenew <- [Session::Sessions]Index[~] |
0 | 648 } |
649 } | |
650 | |
651 Val[makenew] | |
652 { | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
653 out <- Session[] |
0 | 654 } |
655 } | |
656 | |
657 Get Link Params@Session[session:out,no params] | |
658 { | |
659 If[[session]Use Cookies >>] | |
660 { | |
661 no params <- No | |
662 }{ | |
663 out <- ["session_id="]Append[[session]Session ID >>] | |
664 } | |
665 } | |
666 | |
667 Set@Session[session,key,val:out] | |
668 { | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
669 out <- [[session]Data <<[ [[session]Data >>]Set[key, val] ]]Dirty <<[Yes] |
0 | 670 } |
671 | |
672 Index@Session[session,key:out,not found] | |
673 { | |
674 out,not found <- [[session]Data >>]Index[key] | |
675 } | |
676 | |
677 First@Session[session:first,not found] | |
678 { | |
679 first,not found <- [[session]Data >>]First | |
680 } | |
681 | |
682 Next@Session[session,last:next,not found] | |
683 { | |
684 next,not found <- [[session]Data >>]Next[last] | |
685 } | |
686 | |
687 Init Sessions[:out] uses Session | |
688 { | |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
689 Session::Sessions <- Dictionary[] |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
690 out <- Yes |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
691 } |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
692 |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
693 Globals Session |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
694 { |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
695 ID <- 1 |
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
696 Sessions <- No |
0 | 697 out <- 0 |
698 } | |
699 | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
700 Save@Session[session:out] uses Session |
0 | 701 { |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
702 Session::Sessions <- [Session::Sessions]Set[[session]Session ID >>, session] |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
703 } |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
704 |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
705 Finalize@Session[session,headers:out headers] |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
706 { |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
707 If[[session]Dirty >>] |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
708 { |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
709 Save[session] |
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
710 } |
0 | 711 out headers <- [headers]Set["Set-Cookie", ["session_id="]Append[[session]Session ID >>]] |
712 } | |
713 | |
714 Blueprint Web Link | |
715 { | |
716 Text | |
717 Target | |
718 Class | |
719 Query Params | |
720 } | |
721 | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
722 Web Link[text,target:out] |
0 | 723 { |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
724 out <- [[[[Build[Web Link()]]Text <<[text]]Target <<[target]]Class <<[""]]Query Params <<[Dictionary[]] |
0 | 725 } |
726 | |
727 | |
728 With Session@Web Link[text,target,session:out] | |
729 { | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
730 Web Link[text, target] |
0 | 731 { |
732 out <- [~]Query Params <<[[[~]Query Params >>]Set["session_id", [session]Session ID >>]] | |
733 } | |
734 } | |
735 | |
736 Render@Web Link[link:out,headers] | |
737 { | |
738 [[link]Query Params>>]First | |
739 { | |
740 queryvars <- ["?"]Append[Key Value Join[[link]Query Params>>, "=","&"]] | |
741 }{ | |
742 queryvars <- "" | |
743 } | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
744 out <- [[[[[[["<a href=\""]Append[[link]Target>>]]Append[queryvars]]Append["\""] |
0 | 745 ]Append[Get Class[link]]]Append[">"]]Append[Escape HTML Text[[link]Text>>]]]Append["</a>"] |
746 } | |
747 | |
748 Postback@Web Link[in,post data:out,events] | |
749 { | |
750 out <- in | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
751 events <- List[] |
0 | 752 } |
753 | |
754 Name@Web Link[link:name,none] | |
755 { | |
756 none <- link | |
757 } | |
758 | |
759 Set Session@Web Link[link,session:out] | |
760 { | |
761 If[[[[link]Target >>]Slice[7]] = ["http://"]] | |
762 { | |
763 out <- link | |
764 }{ | |
765 If[[session]Use Cookies >>] | |
766 { | |
767 out <- link | |
768 }{ | |
769 out <- [link]Query Params <<[[[link]Query Params >>]Set["session_id", [session]Session ID>>]] | |
770 } | |
771 } | |
772 } | |
773 | |
774 Blueprint Web Table | |
775 { | |
776 Headers | |
777 Data | |
778 } | |
779 | |
47
6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
Mike Pavone <pavone@retrodev.com>
parents:
1
diff
changeset
|
780 Web Table[headers,data:out] |
0 | 781 { |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
782 out <- [[Build[Web Table()]]Headers <<[headers]]Data <<[data] |
0 | 783 } |
784 | |
785 Name@Web Table[link:name,none] | |
786 { | |
787 none <- link | |
788 } | |
789 | |
790 Set Session@Web Table[in,session:out] | |
791 { | |
792 out <- in | |
793 } | |
794 | |
795 Postback@Web Table[table,post data:out,events] | |
796 { | |
797 out <- table | |
798 events <- () | |
799 } | |
800 | |
801 Make Header Row[string,header:out] | |
802 { | |
803 out <- [[[string]Append["\t\t\t<th>"]]Append[header]]Append["</th>\n"] | |
804 } | |
805 | |
806 Get Header Row@Web Table[table:out] | |
807 { | |
808 If[[[[table]Headers >>]Length] > [0]] | |
809 { | |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
810 out <- [Fold[Make Header Row[?], "\t\t<tr>\n", [table]Headers >>]]Append["\t\t</tr>\n"] |
0 | 811 }{ |
812 out <- "" | |
813 } | |
814 } | |
815 | |
816 Make Table Cell[string,cell:out] | |
817 { | |
818 out <- [[[string]Append["\t\t\t<td>"]]Append[[cell]Render]]Append["</td>\n"] | |
819 } | |
820 | |
821 Make Table Row[string,row:out] | |
822 { | |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
823 out <- [Fold[Make Table Cell[?], [string]Append["\t\t<tr>\n"], row]]Append["\t\t</tr>"] |
0 | 824 } |
825 | |
826 Render@Web Table[table:out,headers] | |
827 { | |
828 out <- [ | |
829 [ | |
830 ["\t<table>\n"]Append[[table]Get Header Row] | |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
831 ]Append[ Fold[Make Table Row[?], "", [table]Data >>] ] |
0 | 832 ]Append["\t</table>\n"] |
833 } | |
1
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
834 |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
835 Blueprint Web Image |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
836 { |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
837 Source |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
838 Alt |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
839 } |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
840 |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
841 Web Image[source,alt:out] |
1
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
842 { |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
47
diff
changeset
|
843 out <- [[Build[Web Image()]]Source <<[source]]Alt <<[alt] |
1
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
844 } |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
845 |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
846 Name@Web Image[image:name,none] |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
847 { |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
848 name <- [image]Source >> |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
849 } |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
850 |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
851 Set Session@Web Image[in,session:out] |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
852 { |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
853 out <- in |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
854 } |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
855 |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
856 Postback@Web Image[image,post data:out,events] |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
857 { |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
858 out <- image |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
859 events <- () |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
860 } |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
861 |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
862 Render@Web Image[image:out,headers] |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
863 { |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
864 out <- [[[["<img src=\""]Append[[image]Source >>]]Append["\" alt=\""]]Append[[image]Alt >>]]Append["\">"] |
b3f71490858c
Small fixes and enhancements from main windows box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
865 } |