GrafoscopioUtils/repository/Grafoscopio-Utils/CodiMD.class.st

99 lines
2.0 KiB
Smalltalk

"
I model the interface between a CodiMD (https://demo.codimd.org) documentation
server and Grafoscopio.
I enable the interaction between Grafoscopio notebooks and CodiMD documents,
so one document can start online (as a CodiMD pad) and continue as a Grafoscopio
notebook or viceversa.
"
Class {
#name : #CodiMD,
#superclass : #Object,
#instVars : [
'server',
'pad',
'contents',
'url'
],
#category : #'Grafoscopio-Utils'
}
{ #category : #'as yet unclassified' }
CodiMD class >> newDefault [
^ self new
defaultServer.
]
{ #category : #'as yet unclassified' }
CodiMD >> defaultServer [
self server: 'https://docutopia.tupale.co'.
]
{ #category : #'as yet unclassified' }
CodiMD >> htmlUrl [
| link |
link := self url copy.
link segments insert: 's' before: 1.
^ link
]
{ #category : #'as yet unclassified' }
CodiMD >> importContents [
self contents: self retrieveContents
]
{ #category : #accessing }
CodiMD >> pad [
^ pad
]
{ #category : #accessing }
CodiMD >> pad: anObject [
pad := anObject
]
{ #category : #'as yet unclassified' }
CodiMD >> retrieveContents [
self url ifNil: [ ^ self ].
^ (self url addPathSegment: 'download') retrieveContents
]
{ #category : #'as yet unclassified' }
CodiMD >> retrieveHtmlContents [
| htmlContents |
self url ifNil: [ ^ self ].
htmlContents := self htmlUrl.
^ htmlContents retrieveContents
]
{ #category : #'as yet unclassified' }
CodiMD >> saveContentsToFile: aFileLocator [
self url ifNil: [ ^ self ].
^ (self url addPathSegment: 'download') saveContentsToFile: aFileLocator
]
{ #category : #'as yet unclassified' }
CodiMD >> saveHtmlContentsToFile: aFileLocator [
self url ifNil: [ ^ self ].
^ self htmlUrl saveContentsToFile: aFileLocator
]
{ #category : #accessing }
CodiMD >> server [
^ server
]
{ #category : #accessing }
CodiMD >> server: aUrlString [
server := aUrlString
]
{ #category : #accessing }
CodiMD >> url [
^ url asUrl
]
{ #category : #visiting }
CodiMD >> visit [
WebBrowser openOn: self server, '/', self pad.
]