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' }
|
{ #category : #'*MiniDocs' }
|
||||||
LePage >> asMarkdeepFile [
|
LePage >> asMarkdeepFile [
|
||||||
|
|
||||||
^ self asMarkdeep exportAsFileOn: self storage / self markdeepFileName
|
^ self asMarkdeep notifyExportAsFileOn: self storage / self markdeepFileName
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #'*MiniDocs' }
|
{ #category : #'*MiniDocs' }
|
||||||
|
@ -13,3 +13,18 @@ LePageHeaderBuilder >> addExportPageButton [
|
|||||||
aButton phlow spawnObject: self page asMarkdeepFile ].
|
aButton phlow spawnObject: self page asMarkdeepFile ].
|
||||||
self toolbarElement addItem: newButton.
|
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 |
|
| newFile |
|
||||||
self markdownFile ifNil: [ self inform: 'Define an input Markdown file or use #exportAsFileOn: instead.' ].
|
self markdownFile ifNil: [ self inform: 'Define an input Markdown file or use #exportAsFileOn: instead.' ].
|
||||||
newFile := (self markdownFile file fullName, '.html') asFileReference.
|
newFile := (self markdownFile file fullName, '.html') asFileReference.
|
||||||
^ self exportAsFileOn: newFile.
|
^ self notifyExportAsFileOn: newFile.
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #persistence }
|
{ #category : #persistence }
|
||||||
@ -156,8 +156,6 @@ Markdeep >> exportAsFileOn: aFileReference [
|
|||||||
aFileReference exists ifFalse: [ aFileReference ensureCreateFile ].
|
aFileReference exists ifFalse: [ aFileReference ensureCreateFile ].
|
||||||
aFileReference writeStreamDo: [ :stream |
|
aFileReference writeStreamDo: [ :stream |
|
||||||
stream nextPutAll: self contents ].
|
stream nextPutAll: self contents ].
|
||||||
self inform: 'Exported as: ', String cr, aFileReference fullName.
|
|
||||||
^ aFileReference
|
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #utilities }
|
{ #category : #utilities }
|
||||||
@ -272,6 +270,13 @@ Markdeep >> navTop: aString [
|
|||||||
navTop:= aString.
|
navTop:= aString.
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #persistence }
|
||||||
|
Markdeep >> notifyExportAsFileOn: aFileReference [
|
||||||
|
self exportAsFileOn: aFileReference.
|
||||||
|
self inform: 'Exported as: ', String cr, aFileReference fullName.
|
||||||
|
^ aFileReference
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
Markdeep >> options [
|
Markdeep >> options [
|
||||||
^ options ifNil: [
|
^ options ifNil: [
|
||||||
|
@ -2,7 +2,8 @@ Class {
|
|||||||
#name : #MiniDocsServer,
|
#name : #MiniDocsServer,
|
||||||
#superclass : #Teapot,
|
#superclass : #Teapot,
|
||||||
#classInstVars : [
|
#classInstVars : [
|
||||||
'storage'
|
'storage',
|
||||||
|
'singleton'
|
||||||
],
|
],
|
||||||
#category : #MiniDocs
|
#category : #MiniDocs
|
||||||
}
|
}
|
||||||
@ -17,10 +18,26 @@ MiniDocsServer class >> initialize [
|
|||||||
self addStorage: FileLocator documents / 'lepiter' / 'default'
|
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 }
|
{ #category : #accessing }
|
||||||
MiniDocsServer class >> start [
|
MiniDocsServer class >> start [
|
||||||
self initialize.
|
self initialize.
|
||||||
^ self superclass on
|
^ singleton := self superclass on
|
||||||
serveStatic: '/lepiter/doc/' from: self storage first pathString;
|
serveStatic: '/lepiter/doc/' from: self storage first pathString;
|
||||||
start
|
start
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user