-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cuis-Web.pck.st
1200 lines (869 loc) · 35.1 KB
/
Cuis-Web.pck.st
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
'From Cuis 5.0 of 7 November 2016 [latest update: #3812] on 15 July 2019 at 3:28:07 am'!
'Description Microframework web for Cuis Smalltalk
'!
!provides: 'Cuis-Web' 1 38!
!requires: 'WebClient' 1 17 nil!
!requires: 'JSON' 1 19 nil!
SystemOrganization addCategory: #'Cuis-Web'!
SystemOrganization addCategory: #'Cuis-Web-Components'!
SystemOrganization addCategory: #'Cuis-Web-Components-Tests'!
!classDefinition: #HeadingTest category: #'Cuis-Web-Components-Tests'!
TestCase subclass: #HeadingTest
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Cuis-Web-Components-Tests'!
!classDefinition: 'HeadingTest class' category: #'Cuis-Web-Components-Tests'!
HeadingTest class
instanceVariableNames: ''!
!classDefinition: #DynamicRoutingWebServer category: #'Cuis-Web'!
WebServer subclass: #DynamicRoutingWebServer
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Cuis-Web'!
!classDefinition: 'DynamicRoutingWebServer class' category: #'Cuis-Web'!
DynamicRoutingWebServer class
instanceVariableNames: ''!
!classDefinition: #CuisWebApplication category: #'Cuis-Web'!
Object subclass: #CuisWebApplication
instanceVariableNames: 'webServer rootPath'
classVariableNames: ''
poolDictionaries: ''
category: 'Cuis-Web'!
!classDefinition: 'CuisWebApplication class' category: #'Cuis-Web'!
CuisWebApplication class
instanceVariableNames: 'instance'!
!classDefinition: #Paginate category: #'Cuis-Web'!
Object subclass: #Paginate
instanceVariableNames: 'elements'
classVariableNames: ''
poolDictionaries: ''
category: 'Cuis-Web'!
!classDefinition: 'Paginate class' category: #'Cuis-Web'!
Paginate class
instanceVariableNames: ''!
!classDefinition: #Path category: #'Cuis-Web'!
Object subclass: #Path
instanceVariableNames: 'request'
classVariableNames: ''
poolDictionaries: ''
category: 'Cuis-Web'!
!classDefinition: 'Path class' category: #'Cuis-Web'!
Path class
instanceVariableNames: ''!
!classDefinition: #SmartPath category: #'Cuis-Web'!
Path subclass: #SmartPath
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Cuis-Web'!
!classDefinition: 'SmartPath class' category: #'Cuis-Web'!
SmartPath class
instanceVariableNames: ''!
!classDefinition: #StaticPath category: #'Cuis-Web'!
Path subclass: #StaticPath
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Cuis-Web'!
!classDefinition: 'StaticPath class' category: #'Cuis-Web'!
StaticPath class
instanceVariableNames: ''!
!classDefinition: #RootController category: #'Cuis-Web'!
Object subclass: #RootController
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Cuis-Web'!
!classDefinition: 'RootController class' category: #'Cuis-Web'!
RootController class
instanceVariableNames: ''!
!classDefinition: #View category: #'Cuis-Web'!
Object subclass: #View
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Cuis-Web'!
!classDefinition: 'View class' category: #'Cuis-Web'!
View class
instanceVariableNames: ''!
!classDefinition: #HTMLElement category: #'Cuis-Web-Components'!
Object subclass: #HTMLElement
instanceVariableNames: 'textContent cssClasses name'
classVariableNames: ''
poolDictionaries: ''
category: 'Cuis-Web-Components'!
!classDefinition: 'HTMLElement class' category: #'Cuis-Web-Components'!
HTMLElement class
instanceVariableNames: ''!
!classDefinition: #Div category: #'Cuis-Web-Components'!
HTMLElement subclass: #Div
instanceVariableNames: 'id content style'
classVariableNames: ''
poolDictionaries: ''
category: 'Cuis-Web-Components'!
!classDefinition: 'Div class' category: #'Cuis-Web-Components'!
Div class
instanceVariableNames: ''!
!classDefinition: #Footer category: #'Cuis-Web-Components'!
Div subclass: #Footer
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Cuis-Web-Components'!
!classDefinition: 'Footer class' category: #'Cuis-Web-Components'!
Footer class
instanceVariableNames: ''!
!classDefinition: #FileInput category: #'Cuis-Web-Components'!
HTMLElement subclass: #FileInput
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Cuis-Web-Components'!
!classDefinition: 'FileInput class' category: #'Cuis-Web-Components'!
FileInput class
instanceVariableNames: ''!
!classDefinition: #FormInput category: #'Cuis-Web-Components'!
HTMLElement subclass: #FormInput
instanceVariableNames: 'type value placeHolder required'
classVariableNames: ''
poolDictionaries: ''
category: 'Cuis-Web-Components'!
!classDefinition: 'FormInput class' category: #'Cuis-Web-Components'!
FormInput class
instanceVariableNames: ''!
!classDefinition: #Heading category: #'Cuis-Web-Components'!
HTMLElement subclass: #Heading
instanceVariableNames: 'level'
classVariableNames: ''
poolDictionaries: ''
category: 'Cuis-Web-Components'!
!classDefinition: 'Heading class' category: #'Cuis-Web-Components'!
Heading class
instanceVariableNames: ''!
!classDefinition: #HtmlTextarea category: #'Cuis-Web-Components'!
HTMLElement subclass: #HtmlTextarea
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Cuis-Web-Components'!
!classDefinition: 'HtmlTextarea class' category: #'Cuis-Web-Components'!
HtmlTextarea class
instanceVariableNames: ''!
!classDefinition: #Hyperlink category: #'Cuis-Web-Components'!
HTMLElement subclass: #Hyperlink
instanceVariableNames: 'href jsFunctionName target'
classVariableNames: ''
poolDictionaries: ''
category: 'Cuis-Web-Components'!
!classDefinition: 'Hyperlink class' category: #'Cuis-Web-Components'!
Hyperlink class
instanceVariableNames: 'target'!
!classDefinition: #Icon category: #'Cuis-Web-Components'!
HTMLElement subclass: #Icon
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Cuis-Web-Components'!
!classDefinition: 'Icon class' category: #'Cuis-Web-Components'!
Icon class
instanceVariableNames: ''!
!classDefinition: #Img category: #'Cuis-Web-Components'!
HTMLElement subclass: #Img
instanceVariableNames: 'src alt'
classVariableNames: ''
poolDictionaries: ''
category: 'Cuis-Web-Components'!
!classDefinition: 'Img class' category: #'Cuis-Web-Components'!
Img class
instanceVariableNames: ''!
!classDefinition: #Li category: #'Cuis-Web-Components'!
HTMLElement subclass: #Li
instanceVariableNames: 'content id'
classVariableNames: ''
poolDictionaries: ''
category: 'Cuis-Web-Components'!
!classDefinition: 'Li class' category: #'Cuis-Web-Components'!
Li class
instanceVariableNames: ''!
!classDefinition: #LineBreak category: #'Cuis-Web-Components'!
HTMLElement subclass: #LineBreak
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Cuis-Web-Components'!
!classDefinition: 'LineBreak class' category: #'Cuis-Web-Components'!
LineBreak class
instanceVariableNames: ''!
!classDefinition: #Nav category: #'Cuis-Web-Components'!
HTMLElement subclass: #Nav
instanceVariableNames: 'content'
classVariableNames: ''
poolDictionaries: ''
category: 'Cuis-Web-Components'!
!classDefinition: 'Nav class' category: #'Cuis-Web-Components'!
Nav class
instanceVariableNames: ''!
!classDefinition: #Paragraph category: #'Cuis-Web-Components'!
HTMLElement subclass: #Paragraph
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Cuis-Web-Components'!
!classDefinition: 'Paragraph class' category: #'Cuis-Web-Components'!
Paragraph class
instanceVariableNames: ''!
!classDefinition: #Select category: #'Cuis-Web-Components'!
HTMLElement subclass: #Select
instanceVariableNames: 'options'
classVariableNames: ''
poolDictionaries: ''
category: 'Cuis-Web-Components'!
!classDefinition: 'Select class' category: #'Cuis-Web-Components'!
Select class
instanceVariableNames: ''!
!classDefinition: #Smaller category: #'Cuis-Web-Components'!
HTMLElement subclass: #Smaller
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Cuis-Web-Components'!
!classDefinition: 'Smaller class' category: #'Cuis-Web-Components'!
Smaller class
instanceVariableNames: ''!
!classDefinition: #Span category: #'Cuis-Web-Components'!
HTMLElement subclass: #Span
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Cuis-Web-Components'!
!classDefinition: 'Span class' category: #'Cuis-Web-Components'!
Span class
instanceVariableNames: ''!
!classDefinition: #Table category: #'Cuis-Web-Components'!
HTMLElement subclass: #Table
instanceVariableNames: 'headers rows style'
classVariableNames: ''
poolDictionaries: ''
category: 'Cuis-Web-Components'!
!classDefinition: 'Table class' category: #'Cuis-Web-Components'!
Table class
instanceVariableNames: ''!
!classDefinition: #Ul category: #'Cuis-Web-Components'!
HTMLElement subclass: #Ul
instanceVariableNames: 'listItems id'
classVariableNames: ''
poolDictionaries: ''
category: 'Cuis-Web-Components'!
!classDefinition: 'Ul class' category: #'Cuis-Web-Components'!
Ul class
instanceVariableNames: ''!
!classDefinition: #Header category: #'Cuis-Web-Components'!
Object subclass: #Header
instanceVariableNames: 'content cssClasses'
classVariableNames: ''
poolDictionaries: ''
category: 'Cuis-Web-Components'!
!classDefinition: 'Header class' category: #'Cuis-Web-Components'!
Header class
instanceVariableNames: ''!
!classDefinition: #HtmlForm category: #'Cuis-Web-Components'!
Object subclass: #HtmlForm
instanceVariableNames: 'action method enctype contents'
classVariableNames: ''
poolDictionaries: ''
category: 'Cuis-Web-Components'!
!classDefinition: 'HtmlForm class' category: #'Cuis-Web-Components'!
HtmlForm class
instanceVariableNames: ''!
!classDefinition: #PlainHTML category: #'Cuis-Web-Components'!
Object subclass: #PlainHTML
instanceVariableNames: 'htmlCode'
classVariableNames: ''
poolDictionaries: ''
category: 'Cuis-Web-Components'!
!classDefinition: 'PlainHTML class' category: #'Cuis-Web-Components'!
PlainHTML class
instanceVariableNames: ''!
!HTMLElement methodsFor: 'as yet unclassified' stamp: 'GC 6/23/2019 03:39:53'!
name
^ name isEmptyOrNil
ifTrue: ['']
ifFalse: ['name="{1}"' format: { name }]! !
!FormInput methodsFor: 'as yet unclassified' stamp: 'GC 6/23/2019 03:00:37'!
name
^ name isEmptyOrNil
ifTrue: ['']
ifFalse: ['name="{1}"' format: { name }]! !
!HeadingTest methodsFor: 'as yet unclassified' stamp: 'GC 5/8/2019 00:01:34'!
aTextContent
^ 'i am a text content'! !
!HeadingTest methodsFor: 'as yet unclassified' stamp: 'GC 5/8/2019 00:01:51'!
test_01_with_a_text_content_returns_h1_with_that_content
| heading |
heading _ Heading with: self aTextContent.
self assert: heading render equals: '<h1>', self aTextContent, '</h1>'! !
!HeadingTest methodsFor: 'as yet unclassified' stamp: 'GC 5/8/2019 00:03:22'!
test_02_with_a_given_level_returns_heading_with_that_level
| heading headingLevel |
headingLevel _ 4.
heading _ Heading with: (self aTextContent) level: headingLevel.
self assert: heading render equals: '<h', headingLevel asString, '>', self aTextContent, '</h', headingLevel asString, '>'! !
!HeadingTest methodsFor: 'as yet unclassified' stamp: 'GC 5/8/2019 00:06:55'!
test_03_with_a_given_level_bigger_than_6_fails
| headingLevel |
headingLevel _ 7.
self should: [ Heading with: (self aTextContent) level: headingLevel ]
raise: Error
withMessageText: 'Heading tags can not go futher than level 6'! !
!DynamicRoutingWebServer methodsFor: 'as yet unclassified' stamp: 'GC 5/4/2019 08:36:12'!
classFor: request
^(StaticPath anyCanHandle: request) ifTrue: [ StaticPath ] ifFalse: [ SmartPath ]! !
!DynamicRoutingWebServer methodsFor: 'as yet unclassified' stamp: 'GC 6/25/2019 01:48:04'!
request: request
^ [
[ self classFor: request :: forRequest: request :: handle ]
valueWithin: self timeoutTolerance onTimeout: [ request send500Response: 'Timeout' ] ]
on: Error
do: [ :anError | request send500Response: (self errorReportFor: anError) ]! !
!DynamicRoutingWebServer methodsFor: 'as yet unclassified' stamp: 'GC 6/25/2019 01:48:15'!
timeoutTolerance
^ Duration seconds: 25! !
!CuisWebApplication methodsFor: 'as yet unclassified' stamp: 'GC 7/8/2019 02:51:03'!
initialize
webServer _ DynamicRoutingWebServer new.
rootPath _ ''! !
!CuisWebApplication methodsFor: 'as yet unclassified' stamp: 'GC 7/8/2019 02:52:35'!
rootPath
^ rootPath! !
!CuisWebApplication methodsFor: 'as yet unclassified' stamp: 'GC 7/8/2019 02:52:50'!
rootPath: aDirectoryPath
rootPath _ aDirectoryPath! !
!CuisWebApplication methodsFor: 'as yet unclassified' stamp: 'GC 6/29/2019 10:28:12'!
start
self startOn: self defaultPort ! !
!CuisWebApplication methodsFor: 'as yet unclassified' stamp: 'GC 6/29/2019 10:27:49'!
startOn: aPortNumber
webServer listenOn: aPortNumber! !
!CuisWebApplication methodsFor: 'as yet unclassified' stamp: 'GC 7/9/2019 20:18:28'!
stop
webServer stopListener! !
!CuisWebApplication methodsFor: 'accessing' stamp: 'GC 3/31/2019 03:57:58'!
defaultPort
^ 8080! !
!CuisWebApplication methodsFor: 'private' stamp: 'GC 3/30/2019 17:50:05'!
webServer
^ webServer! !
!CuisWebApplication class methodsFor: 'instance creation' stamp: 'GC 7/8/2019 03:06:01'!
instance
^ instance! !
!CuisWebApplication class methodsFor: 'instance creation' stamp: 'GC 3/30/2019 19:56:01'!
restart
instance ifNotNil: [ instance stop ].
instance _ self new.
instance start! !
!CuisWebApplication class methodsFor: 'instance creation' stamp: 'GC 3/30/2019 17:47:52'!
start
instance ifNil: [ instance _ self new ].
instance start! !
!CuisWebApplication class methodsFor: 'instance creation' stamp: 'GC 6/29/2019 10:30:29'!
startOn: portNumber
instance ifNil: [ instance _ self new ].
instance startOn: portNumber! !
!CuisWebApplication class methodsFor: 'instance creation' stamp: 'GC 6/29/2019 10:30:07'!
stop
instance ifNotNil: [ instance stop ]! !
!Paginate methodsFor: 'as yet unclassified' stamp: 'GC 6/17/2019 22:39:18'!
atPage: pageNumber
| startingIndex lastIndex |
startingIndex _ (pageNumber = 1)
ifTrue: [ 1 ]
ifFalse: [ (pageNumber asNumber) * self elementsPerPage ].
lastIndex _ (startingIndex + (self elementsPerPage - 1)).
lastIndex > elements size ifTrue: [ lastIndex _ elements size ].
^ elements copyFrom: startingIndex to: lastIndex! !
!Paginate methodsFor: 'as yet unclassified' stamp: 'GC 6/1/2019 01:54:38'!
elements: aCollection
elements _ aCollection asOrderedCollection! !
!Paginate methodsFor: 'as yet unclassified' stamp: 'GC 6/1/2019 01:49:29'!
elementsPerPage
^ 10! !
!Paginate methodsFor: 'as yet unclassified' stamp: 'GC 6/1/2019 01:42:18'!
totalPages
^ elements size / 10 :: ceiling ! !
!Paginate class methodsFor: 'as yet unclassified' stamp: 'GC 6/1/2019 01:38:36'!
: aCollection
^ self new :: elements: aCollection! !
!Path methodsFor: 'as yet unclassified' stamp: 'GC 3/31/2019 03:51:44'!
handle
self subclassResponsibility! !
!Path methodsFor: 'as yet unclassified' stamp: 'GC 3/30/2019 21:09:13'!
request: aRequest
request _ aRequest! !
!Path class methodsFor: 'instance creation' stamp: 'GC 3/30/2019 21:07:42'!
forRequest: aRequest
^ self new request: aRequest; yourself! !
!SmartPath methodsFor: 'as yet unclassified' stamp: 'GC 5/3/2019 03:30:42'!
actionSelector
|parsedPath|
(request isGetRequest and: [ request url = '/' ])
ifTrue: [ ^ #index: ]
ifFalse: [
parsedPath _ request url substrings: '/'.
(parsedPath size = 1)
ifTrue: [ ^ #index: ]
ifFalse: [ ^ parsedPath last :: append: ':' :: asSymbol ]
]! !
!SmartPath methodsFor: 'as yet unclassified' stamp: 'GC 4/18/2019 15:23:51'!
controllerClass
|parsedPath|
request url = '/'
ifTrue: [ ^ RootController ]
ifFalse: [
parsedPath _ request url withoutPrefix: '/' :: upToLastPathSeparator :: capitalized.
^ RootController subclasses
detect: [ :controller | controller name asString beginsWith: parsedPath ]
ifNone: [ request send404Response ]
]! !
!SmartPath methodsFor: 'as yet unclassified' stamp: 'GC 5/3/2019 03:21:04'!
handle
^ {self httpMethods . [ :aRequest | self controllerClass new perform: self actionSelector with: aRequest ]}! !
!SmartPath methodsFor: 'as yet unclassified' stamp: 'GC 3/31/2019 03:51:30'!
httpMethods
^ { request method }! !
!StaticPath class methodsFor: 'as yet unclassified' stamp: 'GC 4/18/2019 15:41:32'!
anyCanHandle: aRequest
^ self allSubclasses anySatisfy: [ :staticPathClass | staticPathClass canHandle: aRequest ]! !
!StaticPath class methodsFor: 'as yet unclassified' stamp: 'GC 4/18/2019 15:41:47'!
canHandle: aRequest
self subclassResponsibility! !
!StaticPath class methodsFor: 'as yet unclassified' stamp: 'GC 4/18/2019 18:24:54'!
forRequest: aRequest
| staticRouteForRequest |
staticRouteForRequest _ self subclasses detect: [ :staticPath | staticPath canHandle: aRequest ].
^ staticRouteForRequest new request: aRequest; yourself! !
!RootController methodsFor: 'as yet unclassified' stamp: 'GC 5/30/2019 01:32:42'!
index: request
self shouldBeImplemented ! !
!RootController methodsFor: 'as yet unclassified' stamp: 'GC 5/18/2019 13:41:00'!
respondSuccessfully: aRequest with: htmlContent
|header renderedContent|
renderedContent _ htmlContent render.
aRequest send200Response: renderedContent contentType: 'text/html; charset=utf-8'! !
!RootController methodsFor: 'as yet unclassified' stamp: 'GC 7/1/2019 23:31:53'!
respondSuccessfully: aRequest withImage: fileEntryForImage
| imageData |
imageData _ fileEntryForImage binaryContents readStream.
aRequest
stream200Response: imageData
size: imageData size
type: 'image/', fileEntryForImage extension! !
!RootController methodsFor: 'as yet unclassified' stamp: 'GC 7/1/2019 23:25:01'!
respondSuccessfully: aRequest withImageIn: imagePath
^ self respondSuccessfully: aRequest withImage: imagePath asFileEntry! !
!View methodsFor: 'as yet unclassified' stamp: 'GC 4/18/2019 22:00:47'!
body
self subclassResponsibility ! !
!View methodsFor: 'as yet unclassified' stamp: 'GC 6/5/2019 22:51:47'!
cssFrameworkCDN
^ 'https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.5/css/bulma.min.css'! !
!View methodsFor: 'as yet unclassified' stamp: 'GC 7/5/2019 00:54:29'!
render
^ '<!!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>CoDNaS Q</title>
<link rel="stylesheet" href="{1}">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma-utilities@0.3.6/css/bulma-utilities.css">
<link rel="stylesheet" href="{2}">
<script src="https://kit.fontawesome.com/4c7bfa2683.js"></script>
{3}
</head>
<body>{4}</body>
</html>' format: { self cssFrameworkCDN . self styles . self scripts . self body }! !
!View methodsFor: 'as yet unclassified' stamp: 'GC 6/5/2019 01:26:46'!
scripts
^ ''! !
!View methodsFor: 'as yet unclassified' stamp: 'GC 7/5/2019 00:57:04'!
styles
^ '/styles.css'
! !
!HTMLElement methodsFor: 'as yet unclassified' stamp: 'GC 6/5/2019 23:19:51'!
css: someCssClasses
cssClasses _ someCssClasses ! !
!HTMLElement methodsFor: 'as yet unclassified' stamp: 'GC 7/5/2019 00:42:02'!
cssClasses
^ cssClasses isEmptyOrNil ::
ifTrue: [ '' ]
ifFalse: [
'class="', (cssClasses inject: '' into: [ :allClasses :cssClass | allClasses, cssClass, ' ' ] :: withBlanksTrimmed), '"'
]! !
!HTMLElement methodsFor: 'as yet unclassified' stamp: 'GC 6/18/2019 02:31:40'!
initialize
super initialize.
name _ ''.
cssClasses _ OrderedCollection new! !
!HTMLElement methodsFor: 'as yet unclassified' stamp: 'GC 6/18/2019 02:31:26'!
name: elementName
name _ elementName ! !
!HTMLElement methodsFor: 'as yet unclassified' stamp: 'GC 5/3/2019 02:35:36'!
textContent: aTextContent
textContent _ aTextContent ! !
!HTMLElement class methodsFor: 'instance creation' stamp: 'GC 5/3/2019 02:48:53'!
with: textContent
^ self new :: textContent: textContent! !
!HTMLElement class methodsFor: 'object serialization' stamp: 'GC 5/3/2019 02:34:59'!
render
self subclassResponsibility ! !
!Div methodsFor: 'as yet unclassified' stamp: 'GC 6/1/2019 02:24:41'!
addContent: htmlElement
content add: htmlElement ! !
!Div methodsFor: 'as yet unclassified' stamp: 'GC 5/18/2019 13:28:42'!
class: someCSSClasses content: htmlElements
content _ htmlElements.
cssClasses _ someCSSClasses! !
!Div methodsFor: 'as yet unclassified' stamp: 'GC 5/3/2019 02:45:22'!
content: htmlElements
content _ htmlElements ! !
!Div methodsFor: 'as yet unclassified' stamp: 'GC 6/23/2019 02:07:34'!
id
^ id isEmptyOrNil ::
ifTrue: [ '' ]
ifFalse: [ 'id="{1}"' format: { id } ]! !
!Div methodsFor: 'as yet unclassified' stamp: 'GC 6/5/2019 01:23:25'!
id: elementId
id _ elementId ! !
!Div methodsFor: 'as yet unclassified' stamp: 'GC 6/17/2019 20:12:42'!
initialize
super initialize .
id _ ''.
style _ ''.
content _ OrderedCollection new! !
!Div methodsFor: 'as yet unclassified' stamp: 'GC 7/5/2019 00:35:45'!
render
^ '<div {1} {2} style="{3}" {4}>{5}</div>' format: { self id . self cssClasses . style . self name . self renderedContents}! !
!Div methodsFor: 'as yet unclassified' stamp: 'GC 7/5/2019 00:32:21'!
renderedContents
^ content inject: '' into: [:allContents :htmlElement | allContents, htmlElement render]! !
!Div methodsFor: 'as yet unclassified' stamp: 'GC 6/5/2019 01:36:24'!
style: inlineStyle
style _ inlineStyle ! !
!Div class methodsFor: 'as yet unclassified' stamp: 'GC 7/5/2019 00:44:50'!
containing: htmlElements
^ self new :: content: htmlElements! !
!Div class methodsFor: 'as yet unclassified' stamp: 'GC 6/5/2019 23:04:49'!
css: cssClasses containing: htmlElements
^ self new :: class: cssClasses content: htmlElements! !
!Div class methodsFor: 'as yet unclassified' stamp: 'GC 6/5/2019 01:23:16'!
id: elementId containing: htmlElements
^ self new :: id: elementId; content: htmlElements! !
!Footer methodsFor: 'as yet unclassified' stamp: 'GC 7/5/2019 00:32:46'!
initialize
super initialize.
cssClasses add: 'footer'! !
!Footer methodsFor: 'as yet unclassified' stamp: 'GC 7/5/2019 00:43:53'!
render
^ '<footer {1} {2} style="{3}" {4}>{5}</footer>' format: { self id . self cssClasses . style . self name . self renderedContents}! !
!FileInput methodsFor: 'as yet unclassified' stamp: 'GC 7/5/2019 00:36:25'!
initialize
super initialize.
cssClasses add: 'file'! !
!FileInput methodsFor: 'as yet unclassified' stamp: 'GC 7/5/2019 00:36:04'!
render
^ '
<div {1}>
<label class="file-label">
<input class="file-input" type="file" name="{2}">
<span class="file-cta">
<span class="file-icon">
<i class="fas fa-upload"></i>
</span>
<span class="file-label">
Choose a file...
</span>
</span>
</label>
</div>
' format: { self cssClasses . name}! !
!FormInput methodsFor: 'as yet unclassified' stamp: 'GC 6/25/2019 01:57:05'!
initialize
super initialize.
name _ ''.
type _ ''.
placeHolder _ ''.
value _ ''.
required _ false! !
!FormInput methodsFor: 'as yet unclassified' stamp: 'GC 6/25/2019 01:56:54'!
isRequired
required _ true! !
!FormInput methodsFor: 'as yet unclassified' stamp: 'GC 6/17/2019 18:20:51'!
placeHolder: aFormInputPlaceHolder
placeHolder _ aFormInputPlaceHolder ! !
!FormInput methodsFor: 'as yet unclassified' stamp: 'GC 7/5/2019 00:36:45'!
render
^ '<input {1} type="{2}" {3} value="{4}" placeholder="{5}" {6}>'
format: { self cssClasses . type . self name . value . placeHolder . self requiredField }! !
!FormInput methodsFor: 'as yet unclassified' stamp: 'GC 6/25/2019 01:57:48'!
requiredField
^ required ifTrue: [ 'required' ] ifFalse: [ '' ]! !
!FormInput methodsFor: 'as yet unclassified' stamp: 'GC 6/17/2019 18:18:45'!
type: aFormInputType
type _ aFormInputType! !
!FormInput methodsFor: 'as yet unclassified' stamp: 'GC 6/17/2019 18:20:20'!
value: aFormInputValue
value _ aFormInputValue! !
!Heading methodsFor: 'as yet unclassified' stamp: 'GC 6/5/2019 23:23:08'!
initialize
super initialize.
level _ 1! !
!Heading methodsFor: 'as yet unclassified' stamp: 'GC 5/7/2019 23:46:25'!
level
^ level asString ! !
!Heading methodsFor: 'as yet unclassified' stamp: 'GC 5/7/2019 23:47:16'!
level: headingLevel
level _ headingLevel ! !
!Heading methodsFor: 'as yet unclassified' stamp: 'GC 7/5/2019 00:37:36'!
render
^ '<h{1} {2}>{3}</h{1}>' format: { self level . self cssClasses . textContent }! !
!Heading class methodsFor: 'instance creation' stamp: 'GC 5/8/2019 00:11:26'!
with: textContent level: headingLevel
(headingLevel > 6) ifTrue: [ Error signal: 'Heading tags can not go futher than level 6' ].
^ self with: textContent :: level: headingLevel ! !
!HtmlTextarea methodsFor: 'as yet unclassified' stamp: 'GC 7/5/2019 00:37:43'!
render
^ '<textarea {1} name="{2}">{3}</p>' format: { self cssClasses . name . textContent }! !
!Hyperlink methodsFor: 'as yet unclassified' stamp: 'GC 7/15/2019 03:26:55'!
dataTarget
^ target isEmptyOrNil ::
ifTrue: ['']
ifFalse: ['data-target="{1}"' format: { target }]! !
!Hyperlink methodsFor: 'as yet unclassified' stamp: 'GC 5/3/2019 02:40:39'!
href: destinationAddress
href _ destinationAddress! !
!Hyperlink methodsFor: 'as yet unclassified' stamp: 'GC 7/15/2019 03:23:15'!
initialize
super initialize.
href _ '#'.
jsFunctionName _ ''.
target _ ''! !
!Hyperlink methodsFor: 'as yet unclassified' stamp: 'GC 6/23/2019 02:06:33'!
onClick
^ jsFunctionName isEmptyOrNil ::
ifTrue: ['']
ifFalse: ['onClick="{1}"' format: { jsFunctionName }]! !
!Hyperlink methodsFor: 'as yet unclassified' stamp: 'GC 6/23/2019 01:59:05'!
onClick: aJsFunctionName
jsFunctionName _ aJsFunctionName! !
!Hyperlink methodsFor: 'as yet unclassified' stamp: 'GC 7/15/2019 03:23:53'!
render
^ '<a name="{1}" href="{2}" {3} {4} {5}>{6}</a>' format: { name . href . self cssClasses . self onClick . self dataTarget . textContent }! !
!Hyperlink methodsFor: 'as yet unclassified' stamp: 'GC 7/15/2019 03:23:03'!
target: aTarget
target _ aTarget ! !
!Hyperlink class methodsFor: 'instance creation' stamp: 'GC 6/1/2019 02:35:03'!
name: anHTMLElementName to: addressDestination with: textContent
^ self with: textContent :: href: addressDestination :: name: anHTMLElementName! !
!Hyperlink class methodsFor: 'instance creation' stamp: 'GC 5/3/2019 02:43:00'!
to: addressDestination with: textContent
^ self with: textContent :: href: addressDestination! !
!Hyperlink class methodsFor: 'instance creation' stamp: 'GC 6/23/2019 01:57:29'!
with: textContent onClick: jsFunctionName
^ self with: textContent :: href: '#' :: onClick: jsFunctionName! !
!Icon methodsFor: 'as yet unclassified' stamp: 'GC 7/5/2019 00:37:56'!
render
^ '<i {1}></i>' format: { self cssClasses }! !
!Icon class methodsFor: 'as yet unclassified' stamp: 'GC 6/23/2019 00:40:30'!
css: someCssClasses
^ self new :: css: someCssClasses! !
!Img methodsFor: 'as yet unclassified' stamp: 'GC 6/21/2019 07:48:43'!
alt
^ alt! !
!Img methodsFor: 'as yet unclassified' stamp: 'GC 7/5/2019 00:38:02'!
render
^ '<img src="{1}" alt="{2}" {3}>' format: { self src . self alt . self cssClasses }! !
!Img methodsFor: 'as yet unclassified' stamp: 'GC 6/21/2019 07:48:37'!
src
^ src! !
!Img methodsFor: 'as yet unclassified' stamp: 'GC 6/21/2019 07:49:24'!
src: imgSrc alt: imgAlt
src _ imgSrc.
alt _ imgAlt! !
!Img class methodsFor: 'as yet unclassified' stamp: 'GC 6/21/2019 07:49:08'!
src: imgSrc alt: imgAlt
^ self new :: src: imgSrc alt: imgAlt! !
!Li methodsFor: 'as yet unclassified' stamp: 'GC 6/17/2019 23:53:17'!
containing: someContent
content _ someContent! !
!Li methodsFor: 'as yet unclassified' stamp: 'GC 6/17/2019 23:05:19'!
initialize
super initialize.
name _ ''.
id _ ''! !
!Li methodsFor: 'as yet unclassified' stamp: 'GC 7/5/2019 00:38:09'!
render
| renderedContents |
renderedContents _ content inject: '' into: [:allContents :htmlElement | allContents, htmlElement render].
^ '<li {1} name={2} id={3}>{4}</li>' format: { self cssClasses . name . id . renderedContents}! !
!Li class methodsFor: 'as yet unclassified' stamp: 'GC 6/17/2019 23:52:56'!
containing: contents
^ self new containing: contents ! !
!LineBreak class methodsFor: 'object serialization' stamp: 'GC 5/3/2019 03:08:22'!
render
^ '<br>'! !
!Nav methodsFor: 'as yet unclassified' stamp: 'GC 6/5/2019 23:00:35'!
content: htmlComponents
content _ htmlComponents ! !
!Nav methodsFor: 'as yet unclassified' stamp: 'GC 6/5/2019 23:00:24'!
css: someCssClasses
cssClasses _ someCssClasses ! !
!Nav methodsFor: 'as yet unclassified' stamp: 'GC 7/15/2019 02:30:03'!
render
| renderedContents|
renderedContents _ content inject: '' into: [:allContents :htmlElement | allContents, htmlElement render].
^ '<nav {1} role="navigation" aria-label="main navigation">{2}</nav>' format: { self cssClasses . renderedContents}! !
!Nav class methodsFor: 'as yet unclassified' stamp: 'GC 6/5/2019 23:03:00'!
css: cssClasses containing: htmlElements
^ self new :: css: cssClasses; content: htmlElements ! !
!Paragraph methodsFor: 'as yet unclassified' stamp: 'GC 7/5/2019 00:38:22'!
render
^ '<p {1} name="{2}">{3}</p>' format: { self cssClasses . name . textContent }! !
!Select methodsFor: 'as yet unclassified' stamp: 'GC 5/22/2019 01:36:08'!
options: selectOptions