From a5878177900bfc8efad143ee845f47256e43613c Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Tue, 3 Jan 2023 20:02:05 -0500 Subject: [PATCH] Refresh web preview button initial version working. --- src/MiniDocs/LePage.extension.st | 8 ++++++++ src/MiniDocs/LePageHeaderBuilder.extension.st | 4 ++-- src/MiniDocs/TeaCompositeRouter.extension.st | 6 ++++++ src/MiniDocs/TeaStaticRouter.extension.st | 6 ++++++ src/MiniDocs/Teapot.extension.st | 6 ++++++ 5 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 src/MiniDocs/TeaCompositeRouter.extension.st create mode 100644 src/MiniDocs/TeaStaticRouter.extension.st create mode 100644 src/MiniDocs/Teapot.extension.st diff --git a/src/MiniDocs/LePage.extension.st b/src/MiniDocs/LePage.extension.st index 553b015..ae17b9a 100644 --- a/src/MiniDocs/LePage.extension.st +++ b/src/MiniDocs/LePage.extension.st @@ -126,6 +126,14 @@ LePage >> latestEditTime: aLeTime [ latestEditTime := aLeTime ] +{ #category : #'*MiniDocs' } +LePage >> localHostAddress [ + | localUrl route | + route := MiniDocsServer teapot staticRouter prefix joinUsing: '/'. + localUrl := MiniDocsServer teapot server localUrl asString. + ^ localUrl, route, '/', self markdeepFileName +] + { #category : #'*MiniDocs' } LePage >> markdeepFileName [ diff --git a/src/MiniDocs/LePageHeaderBuilder.extension.st b/src/MiniDocs/LePageHeaderBuilder.extension.st index 61f9902..2458b21 100644 --- a/src/MiniDocs/LePageHeaderBuilder.extension.st +++ b/src/MiniDocs/LePageHeaderBuilder.extension.st @@ -23,8 +23,8 @@ LePageHeaderBuilder >> addRefreshWebViewButton [ aptitude: BrGlamorousButtonWithIconAptitude; label: 'Refresh web view'; icon: BrGlamorousVectorIcons refresh; - action: [ :aButton | + action: [ self page asMarkdeep exportAsFileOn: (self page storage / self page markdeepFileName). - aButton phlow spawnObject: self page localHostAddress ]. + WebBrowser openOn: self page localHostAddress ]. self toolbarElement addItem: newButton. ] diff --git a/src/MiniDocs/TeaCompositeRouter.extension.st b/src/MiniDocs/TeaCompositeRouter.extension.st new file mode 100644 index 0000000..f95e8bb --- /dev/null +++ b/src/MiniDocs/TeaCompositeRouter.extension.st @@ -0,0 +1,6 @@ +Extension { #name : #TeaCompositeRouter } + +{ #category : #'*MiniDocs' } +TeaCompositeRouter >> staticRouters [ + ^ routers +] diff --git a/src/MiniDocs/TeaStaticRouter.extension.st b/src/MiniDocs/TeaStaticRouter.extension.st new file mode 100644 index 0000000..62e8d1a --- /dev/null +++ b/src/MiniDocs/TeaStaticRouter.extension.st @@ -0,0 +1,6 @@ +Extension { #name : #TeaStaticRouter } + +{ #category : #'*MiniDocs' } +TeaStaticRouter >> delegate [ + ^ delegate +] diff --git a/src/MiniDocs/Teapot.extension.st b/src/MiniDocs/Teapot.extension.st new file mode 100644 index 0000000..127f021 --- /dev/null +++ b/src/MiniDocs/Teapot.extension.st @@ -0,0 +1,6 @@ +Extension { #name : #Teapot } + +{ #category : #'*MiniDocs' } +Teapot >> staticRouter [ + ^ staticRouter delegate +]