Ad-hoc singleton patter implementation. We need for literature about the proper way to do it.
This commit is contained in:
parent
dbd9a495c2
commit
f3171fa09e
@ -49,7 +49,7 @@ LePage >> asMarkdeep [
|
||||
{ #category : #'*MiniDocs' }
|
||||
LePage >> asMarkdeepFile [
|
||||
|
||||
^ self asMarkdeep exportAsFileOn: self storage / self markdeepFileName
|
||||
^ self asMarkdeep notifyExportAsFileOn: self storage / self markdeepFileName
|
||||
]
|
||||
|
||||
{ #category : #'*MiniDocs' }
|
||||
|
@ -13,3 +13,18 @@ LePageHeaderBuilder >> addExportPageButton [
|
||||
aButton phlow spawnObject: self page asMarkdeepFile ].
|
||||
self toolbarElement addItem: newButton.
|
||||
]
|
||||
|
||||
{ #category : #'*MiniDocs' }
|
||||
LePageHeaderBuilder >> addRefreshWebViewButton [
|
||||
<leHeaderAction>
|
||||
| newButton |
|
||||
|
||||
newButton := BrButton new
|
||||
aptitude: BrGlamorousButtonWithIconAptitude;
|
||||
label: 'Refresh web view';
|
||||
icon: BrGlamorousVectorIcons refresh;
|
||||
action: [ :aButton |
|
||||
self page asMarkdeep exportAsFileOn: (self page storage / self page markdownFileName).
|
||||
aButton phlow spawnObject: self page localHostAddress ].
|
||||
self toolbarElement addItem: newButton.
|
||||
]
|
||||
|
@ -147,7 +147,7 @@ Markdeep >> exportAsFile [
|
||||
| newFile |
|
||||
self markdownFile ifNil: [ self inform: 'Define an input Markdown file or use #exportAsFileOn: instead.' ].
|
||||
newFile := (self markdownFile file fullName, '.html') asFileReference.
|
||||
^ self exportAsFileOn: newFile.
|
||||
^ self notifyExportAsFileOn: newFile.
|
||||
]
|
||||
|
||||
{ #category : #persistence }
|
||||
@ -156,8 +156,6 @@ Markdeep >> exportAsFileOn: aFileReference [
|
||||
aFileReference exists ifFalse: [ aFileReference ensureCreateFile ].
|
||||
aFileReference writeStreamDo: [ :stream |
|
||||
stream nextPutAll: self contents ].
|
||||
self inform: 'Exported as: ', String cr, aFileReference fullName.
|
||||
^ aFileReference
|
||||
]
|
||||
|
||||
{ #category : #utilities }
|
||||
@ -272,6 +270,13 @@ Markdeep >> navTop: aString [
|
||||
navTop:= aString.
|
||||
]
|
||||
|
||||
{ #category : #persistence }
|
||||
Markdeep >> notifyExportAsFileOn: aFileReference [
|
||||
self exportAsFileOn: aFileReference.
|
||||
self inform: 'Exported as: ', String cr, aFileReference fullName.
|
||||
^ aFileReference
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Markdeep >> options [
|
||||
^ options ifNil: [
|
||||
|
@ -2,7 +2,8 @@ Class {
|
||||
#name : #MiniDocsServer,
|
||||
#superclass : #Teapot,
|
||||
#classInstVars : [
|
||||
'storage'
|
||||
'storage',
|
||||
'singleton'
|
||||
],
|
||||
#category : #MiniDocs
|
||||
}
|
||||
@ -17,10 +18,26 @@ MiniDocsServer class >> initialize [
|
||||
self addStorage: FileLocator documents / 'lepiter' / 'default'
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
MiniDocsServer class >> isRunning [
|
||||
^ self singleton server isRunning
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
MiniDocsServer class >> restart [
|
||||
self stopAll.
|
||||
^ self start
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
MiniDocsServer class >> singleton [
|
||||
^ singleton
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
MiniDocsServer class >> start [
|
||||
self initialize.
|
||||
^ self superclass on
|
||||
^ singleton := self superclass on
|
||||
serveStatic: '/lepiter/doc/' from: self storage first pathString;
|
||||
start
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user