Creating web server in TWServer and configuration methods.

This commit is contained in:
ruidajo 2022-10-17 21:40:33 -05:00
parent a1270d6ca2
commit b4b04967cc

View File

@ -2,7 +2,8 @@ Class {
#name : #TWServer,
#superclass : #Object,
#instVars : [
'wikis'
'wikis',
'webServer'
],
#category : #TiddlyWiki
}
@ -13,7 +14,8 @@ TWServer class >> new [
| instance |
instance := super new.
^ instance
wikis: Dictionary new
wikis: Dictionary new;
webServer: TLWebserver new
]
@ -25,6 +27,40 @@ TWServer >> exportTiddlersFrom: aWikiName tagged: aTag into: aFolder [
^ wiki exportJSONTiddlersTagged: aTag in: aFolder
]
{ #category : #accessing }
TWServer >> initWikiTagDynamicRoute [
webServer teapot
GET: '/<wiki>/<tag>' -> [ :req | (self exportTiddlersFrom: (req at: #wiki) tagged: (req at: #tag) into: FileLocator temp) contents ];
output: #text
]
{ #category : #accessing }
TWServer >> port: aPortInteger [
webServer configuration: { #port -> aPortInteger };
refreshTeapot
]
{ #category : #accessing }
TWServer >> removeAllDynamicRoutes [
webServer teapot removeAllDynamicRoutes
]
{ #category : #accessing }
TWServer >> startAndBrowse [
webServer start.
webServer teapot browse
]
{ #category : #accessing }
TWServer >> webServer: aTealightWebServer [
webServer := aTealightWebServer
]
{ #category : #accessing }
TWServer >> wikiNames [