Maybe funny new PWS SwikiAction
Mathieu vanEchtelt
squeakit at hotmail.com
Thu Jan 13 16:11:40 UTC 2000
A maybe funny, but not that usefull, extension of PWS is ServerAction
'PromptAction'. When you install it and serve to
"http://Servername/prompt/" you can put smalltalk code behind it. For
example: "http://servername/prompt/10 factorial" will return the answer to
your browser. In other words, you can use the url-input-field of your
browser to write and execute Smalltalk code in.
All you have to do is:
- put: PromptAction in the ActionTable by: PWS link: 'prompt' to:
PromptAction new.
- create dir: (squeak/server)/prompt
- put in /prompt file: prompt.html (see attachment)
- and file in the following code:
'From Squeak2.6 of 11 October 1999 [latest update: #1559] on 13 January 2000
at 3:28:28 pm'!
SwikiAction subclass: #PromptAction
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'VOC-ServerActions '!
!PromptAction methodsFor: 'processing' stamp: 'mat 1/13/2000 14:14'!
process: request
| argument action |
argument:=self getSmalltalkOutOfUrl: request .
argument:=(Compiler evaluate: argument) printString.
argument isNil ifFalse:[
action:='Prompt'.
request fields: (request decodeFields: ('promptAnswer=',argument)).
request message: (OrderedCollection with: 'embedded' with: action,
'.html').
request url: '/Prompt/',action,'.html'].
(PWS actionTable at: 'embedded') process: request
! !
!PromptAction methodsFor: 'services' stamp: 'mat 1/13/2000 15:26'!
getSmalltalkOutOfUrl: aRequest
"in the (aRequest) header array, the smalltalk code (every word is an array
entry) is placed from key:3 to the key with the HTTP version. (So do not
write smalltalk code with HTTP in it)"
| stream index coll class messages |
coll:=aRequest header.
stream:=WriteStream on: (String new:128).
aRequest header do: [ :i | ('*HTTP*' match: i) ifTrue: [index:=i]].
index:= aRequest header indexOf: index.
messages:= coll copyFrom: 3 to: (index-1).
class:=aRequest message last.
stream nextPutAll: class; space.
messages do: [:i | stream nextPutAll: i; space].
^stream contents! !
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20000113/5733a3be/Prompt.html
More information about the Squeak-dev
mailing list
|