78 lines
1.4 KiB
Smalltalk
78 lines
1.4 KiB
Smalltalk
Class {
|
|
#name : #TWServer,
|
|
#superclass : #Object,
|
|
#instVars : [
|
|
'wikis',
|
|
'webServer'
|
|
],
|
|
#category : #TiddlyWiki
|
|
}
|
|
|
|
{ #category : #'instance creation' }
|
|
TWServer class >> new [
|
|
|
|
| instance |
|
|
instance := super new.
|
|
^ instance
|
|
wikis: Dictionary new;
|
|
webServer: TLWebserver new
|
|
|
|
]
|
|
|
|
{ #category : #'export - json' }
|
|
TWServer >> exportTiddlersFrom: aWikiName tagged: aTag into: aFolder [
|
|
|
|
| wiki |
|
|
wiki := wikis at: aWikiName.
|
|
^ 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 [
|
|
|
|
| return |
|
|
return := OrderedCollection new.
|
|
wikis keysDo: [ :key | return add: key ].
|
|
^ return
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
TWServer >> wikis: aTiddlyWikisDictionary [
|
|
|
|
wikis := aTiddlyWikisDictionary
|
|
]
|