2022-10-13 01:26:48 +00:00
|
|
|
Class {
|
|
|
|
#name : #TWServer,
|
|
|
|
#superclass : #Object,
|
|
|
|
#instVars : [
|
2022-10-18 02:40:33 +00:00
|
|
|
'wikis',
|
|
|
|
'webServer'
|
2022-10-13 01:26:48 +00:00
|
|
|
],
|
|
|
|
#category : #TiddlyWiki
|
|
|
|
}
|
|
|
|
|
|
|
|
{ #category : #'instance creation' }
|
|
|
|
TWServer class >> new [
|
|
|
|
|
|
|
|
| instance |
|
|
|
|
instance := super new.
|
|
|
|
^ instance
|
2022-10-18 02:40:33 +00:00
|
|
|
wikis: Dictionary new;
|
|
|
|
webServer: TLWebserver new
|
2022-10-13 01:26:48 +00:00
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #'export - json' }
|
|
|
|
TWServer >> exportTiddlersFrom: aWikiName tagged: aTag into: aFolder [
|
|
|
|
|
|
|
|
| wiki |
|
|
|
|
wiki := wikis at: aWikiName.
|
|
|
|
^ wiki exportJSONTiddlersTagged: aTag in: aFolder
|
|
|
|
]
|
|
|
|
|
2022-10-18 02:40:33 +00:00
|
|
|
{ #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
|
|
|
|
]
|
|
|
|
|
2022-10-13 01:26:48 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TWServer >> wikiNames [
|
|
|
|
|
|
|
|
| return |
|
|
|
|
return := OrderedCollection new.
|
|
|
|
wikis keysDo: [ :key | return add: key ].
|
|
|
|
^ return
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
TWServer >> wikis: aTiddlyWikisDictionary [
|
|
|
|
|
|
|
|
wikis := aTiddlyWikisDictionary
|
|
|
|
]
|