Skip to content

Commit 293353f

Browse files
committed
Allow use from CDN
1 parent a9d55fc commit 293353f

File tree

5 files changed

+278
-99
lines changed

5 files changed

+278
-99
lines changed

iwsy/resources/ecs/blocks.txt

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,33 @@
3636
variable N
3737
variable M
3838
variable NBlocks
39+
variable Args
40+
variable Protocol
41+
variable Domain
42+
variable Resources
43+
variable Properties
44+
variable CDN
3945

46+
json parse url the location as Args
47+
put property `protocol` of Args into Protocol
48+
put property `domain` of Args into Domain
49+
50+
rest get Properties from Protocol cat Domain cat `/easycoder-properties.json`
51+
if Properties is not empty
52+
begin
53+
put property `resources` of Properties into Resources
54+
end
55+
if Resources is empty
56+
begin
57+
put `resources` into Resources
58+
put `https://easycoder.github.io/iwsy/resources` into CDN
59+
end
60+
else put Protocol cat Domain cat `/` cat Resources into CDN
61+
4062
put -1 into SelectedBlock
4163

42-
rest get PropertyNames from `/resources/json/propertyNames.json`
43-
rest get PropertyDefaults from `/resources/json/propertyDefaults.json`
64+
rest get PropertyNames from CDN cat `/json/propertyNames.json`
65+
rest get PropertyDefaults from CDN cat `/json/propertyDefaults.json`
4466

4567
on message go to Start
4668
set ready
@@ -275,4 +297,4 @@ SaveSelectedBlock:
275297
set property `action` of Message to `refresh`
276298
set property `source` of Message to `blocks`
277299
send Message to parent
278-
return
300+
return

iwsy/resources/ecs/fileman.txt

Lines changed: 69 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,28 @@
3535
variable UserRecord
3636
variable Email
3737
variable Password
38+
variable AdminPassword
3839
variable CurrentPath
3940
variable FilePath
4041
variable Path
4142
variable N
4243
variable Even
44+
variable Args
45+
variable Protocol
46+
variable Domain
47+
variable Properties
48+
variable UserPath
49+
variable Resources
50+
variable Message
51+
variable Post
52+
53+
json parse url the location as Args
54+
put property `protocol` of Args into Protocol
55+
put property `domain` of Args into Domain
56+
rest get Properties from Protocol cat Domain cat `/easycoder-properties.json`
57+
put property `path` of Properties into UserPath
58+
put property `resources` of Properties into Resources
59+
if Resources is empty put `resources` into Resources
4360

4461
if portrait
4562
begin
@@ -122,23 +139,50 @@
122139
Show:
123140
set style `display` of Container to `block`
124141

125-
get UserRecord from storage as `.user`
126-
put property `email` of UserRecord into Email
127-
get Password from storage as `user.password`
128-
put property `home` of UserRecord into Home
129-
put Home cat `/` cat property `id` of UserRecord cat `/images` into Home
130-
put `users/` cat Home into Home
142+
if UserPath
143+
begin
144+
put UserPath cat `/images` into Home
145+
end
146+
else
147+
begin
148+
get UserRecord from storage as `.user`
149+
put property `email` of UserRecord into Email
150+
get Password from storage as `user.password`
151+
put property `home` of UserRecord into Home
152+
put Home cat `/` cat property `id` of UserRecord cat `/images` into Home
153+
put `users/` cat Home into Home
154+
end
131155
get CurrentPath from storage as `.filepath`
132156
if CurrentPath is empty put Home into CurrentPath
157+
get AdminPassword from storage as `.password`
133158

134159
! Build the list
135160
Browser:
136161
put CurrentPath into storage as `.filepath`
137-
rest get Content from `ulist/` cat Email cat `/` cat Password cat `/` cat CurrentPath cat `?v=` cat now
138-
or begin
139-
alert `Failed to list files.`
140-
put empty into storage as `.filepath`
141-
go to Show
162+
if UserPath
163+
begin
164+
if AdminPassword is empty
165+
begin
166+
set Message to object
167+
set property `Action` of Message to `password`
168+
send Message to parent
169+
stop
170+
end
171+
rest get Content from `list/` cat AdminPassword cat `/` cat CurrentPath cat `?v=` cat now
172+
or begin
173+
alert `Failed to list files.`
174+
put empty into storage as `.filepath`
175+
stop
176+
end
177+
end
178+
else
179+
begin
180+
rest get Content from `ulist/` cat Email cat `/` cat Password cat `/` cat CurrentPath cat `?v=` cat now
181+
or begin
182+
alert `Failed to list files.`
183+
put empty into storage as `.filepath`
184+
stop
185+
end
142186
end
143187
put CurrentPath into Path
144188
set the content of Location to `Current path: ` cat Path
@@ -199,7 +243,9 @@ Browser:
199243
if FileCount is 0
200244
begin
201245
put Path into CurrentPath
202-
rest post to `udelete/` cat Email cat `/` cat Password cat `/` cat CurrentPath or
246+
if UserPath put `delete/` cat AdminPassword cat `/` cat CurrentPath into Post
247+
else put `udelete/` cat Email cat `/` cat Password cat `/` cat CurrentPath into Post
248+
rest post to Post or
203249
begin
204250
alert `Failed to delete a file.`
205251
stop
@@ -240,12 +286,14 @@ SelectFile:
240286
set the text of URL to `resources/` cat FilePath
241287
on click DeleteButton
242288
begin
243-
rest post to `udelete/` cat Email cat `/` cat Password cat `/` cat FilePath or
244-
begin
245-
alert `Failed to delete the image.`
246-
stop
247-
end
248-
go to CloseMedia
289+
if UserPath put `delete/` cat AdminPassword cat `/` cat FilePath into Post
290+
else put `udelete/` cat Email cat `/` cat Password cat `/` cat FilePath into Post
291+
rest post to Post or
292+
begin
293+
alert `Failed to delete the image.`
294+
stop
295+
end
296+
go to CloseMedia
249297
end
250298
end
251299
stop
@@ -267,12 +315,13 @@ Upload:
267315
else
268316
begin
269317
put CurrentPath into Path
270-
put `upload/` cat Email cat `/` cat Password cat `/` cat Path into Path
318+
if UserPath put `upload/` cat AdminPassword cat `/` cat Path into Path
319+
else put `uupload/` cat Password cat `/` cat Email cat `/` cat Password cat `/` cat Path into Path
271320
upload UploadFile to Path with UploadProgress and UploadStatus
272321
goto Browser
273322
end
274323
stop
275324

276325
Exit:
277326
set style `display` of Container to `none`
278-
stop
327+
stop

iwsy/resources/ecs/help.txt

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,28 @@
2222
variable Item
2323
variable Len
2424
variable N
25+
variable Args
26+
variable Protocol
27+
variable Domain
28+
variable Resources
29+
variable Properties
30+
variable CDN
31+
32+
json parse url the location as Args
33+
put property `protocol` of Args into Protocol
34+
put property `domain` of Args into Domain
35+
36+
rest get Properties from Protocol cat Domain cat `/easycoder-properties.json`
37+
if Properties is not empty
38+
begin
39+
put property `resources` of Properties into Resources
40+
end
41+
if Resources is empty
42+
begin
43+
put `resources` into Resources
44+
put `https://easycoder.github.io/iwsy/resources` into CDN
45+
end
46+
else put Protocol cat Domain cat `/` cat Resources into CDN
2547

2648
if portrait
2749
begin
@@ -59,7 +81,7 @@ GetPage:
5981
put 0 into ImageCount
6082
put 0 into LinkCount
6183
iwsy remove styles
62-
rest get Content from `/resources/help/` cat Page cat `.md?v=` cat now
84+
rest get Content from CDN cat `/help/` cat Page cat `.md?v=` cat now
6385
or begin
6486
put empty into Page
6587
go to GetPage
@@ -101,7 +123,7 @@ GetPage:
101123
! Decorate is called for every occurrence of ~...~ in the topic data
102124
Decorate:
103125
put the payload of DecoratorCallback into Payload
104-
if Payload is `iwsy` put `<img src="resources/icon/iwsy.png?v=` cat now cat `" `
126+
if Payload is `iwsy` put `<img src="` cat CDN cat `/icon/iwsy.png?v=` cat now cat `" `
105127
cat `style="height:0.8em;position:relative;top:0.1em" />` into Payload
106128
else if Payload is `clear` put `<div style="height:1px;clear:both"></div>` into Payload
107129
else
@@ -185,4 +207,4 @@ ProcessEmbed:
185207

186208
Exit:
187209
set style `display` of Container to `none`
188-
stop
210+
stop

0 commit comments

Comments
 (0)