From dbd9a495c23ca94e9d5da6edfba08033e8852bfb Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Mon, 2 Jan 2023 17:38:49 -0500 Subject: [PATCH] Starting local server for exported documents. Exported pages by default on the same folder as their Lepiter JSON counterparts. --- src/MiniDocs/LePage.extension.st | 10 ++++---- src/MiniDocs/MiniDocsServer.class.st | 36 ++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 src/MiniDocs/MiniDocsServer.class.st diff --git a/src/MiniDocs/LePage.extension.st b/src/MiniDocs/LePage.extension.st index e2560e0..bc0a2c6 100644 --- a/src/MiniDocs/LePage.extension.st +++ b/src/MiniDocs/LePage.extension.st @@ -73,7 +73,7 @@ LePage >> asMarkdown [ { #category : #'*MiniDocs' } LePage >> asMarkdownFile [ | folder | - folder := self options at: 'storage' ifAbsent: [ FileLocator temp ]. + folder := self storage. ^ MarkupFile exportAsFileOn: folder / self markdownFileName containing: self asMarkdown contents ] @@ -211,9 +211,9 @@ LePage >> sharedVariablesBindings [ { #category : #'*MiniDocs' } LePage >> storage [ - | temporal | - temporal := (FileLocator temp / 'lepiter') ensureCreateDirectory. - self optionAt: 'storage' ifAbsent: [ ^ temporal ]. - (self optionAt: 'storage') ifNil: [ ^ temporal ]. + | current | + current := self database attachmentsDirectory parent. + self optionAt: 'storage' ifAbsent: [ ^ current ]. + (self optionAt: 'storage') ifNil: [ ^ current ]. ^ self optionAt: 'storage' ] diff --git a/src/MiniDocs/MiniDocsServer.class.st b/src/MiniDocs/MiniDocsServer.class.st new file mode 100644 index 0000000..fa4fb16 --- /dev/null +++ b/src/MiniDocs/MiniDocsServer.class.st @@ -0,0 +1,36 @@ +Class { + #name : #MiniDocsServer, + #superclass : #Teapot, + #classInstVars : [ + 'storage' + ], + #category : #MiniDocs +} + +{ #category : #accessing } +MiniDocsServer class >> addStorage: anObject [ + self storage add: anObject. +] + +{ #category : #accessing } +MiniDocsServer class >> initialize [ + self addStorage: FileLocator documents / 'lepiter' / 'default' +] + +{ #category : #accessing } +MiniDocsServer class >> start [ + self initialize. + ^ self superclass on + serveStatic: '/lepiter/doc/' from: self storage first pathString; + start +] + +{ #category : #accessing } +MiniDocsServer class >> storage [ + ^ storage ifNil: [ storage := OrderedCollection new] +] + +{ #category : #accessing } +MiniDocsServer class >> storage: aFoldersOrderedCollection [ + storage := aFoldersOrderedCollection +]