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

114 lines
2.2 KiB
Smalltalk
Raw Normal View History

2019-05-29 12:31:04 +00:00
"
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 : #HedgeDoc,
2019-05-29 12:31:04 +00:00
#superclass : #Object,
#instVars : [
'server',
2020-05-02 23:59:57 +00:00
'pad',
'contents',
'url'
2019-05-29 12:31:04 +00:00
],
#category : #'Grafoscopio-Utils'
}
{ #category : #'as yet unclassified' }
HedgeDoc class >> newDefault [
2019-05-29 12:31:04 +00:00
^ self new
defaultServer.
]
2020-08-29 01:24:25 +00:00
{ #category : #accessing }
HedgeDoc >> contents [
2020-08-29 01:24:25 +00:00
^ contents
]
{ #category : #accessing }
HedgeDoc >> contents: anObject [
2020-08-29 01:24:25 +00:00
contents := anObject
]
2019-05-29 12:31:04 +00:00
{ #category : #'as yet unclassified' }
HedgeDoc >> defaultServer [
2019-05-29 12:31:04 +00:00
self server: 'https://docutopia.tupale.co'.
]
{ #category : #'as yet unclassified' }
HedgeDoc >> htmlUrl [
| link |
link := self url copy.
link segments insert: 's' before: 1.
^ link
]
{ #category : #'as yet unclassified' }
HedgeDoc >> importContents [
self contents: self retrieveContents
]
2019-05-29 12:31:04 +00:00
{ #category : #accessing }
HedgeDoc >> pad [
2019-05-29 12:31:04 +00:00
^ pad
]
{ #category : #accessing }
HedgeDoc >> pad: anObject [
2019-05-29 12:31:04 +00:00
pad := anObject
]
{ #category : #'as yet unclassified' }
HedgeDoc >> retrieveContents [
self url ifNil: [ ^ self ].
^ (self url addPathSegment: 'download') retrieveContents
]
{ #category : #'as yet unclassified' }
HedgeDoc >> retrieveHtmlContents [
| htmlContents |
self url ifNil: [ ^ self ].
htmlContents := self htmlUrl.
^ htmlContents retrieveContents
]
{ #category : #'as yet unclassified' }
HedgeDoc >> saveContentsToFile: aFileLocator [
self url ifNil: [ ^ self ].
^ (self url addPathSegment: 'download') saveContentsToFile: aFileLocator
]
{ #category : #'as yet unclassified' }
HedgeDoc >> saveHtmlContentsToFile: aFileLocator [
self url ifNil: [ ^ self ].
^ self htmlUrl saveContentsToFile: aFileLocator
]
2019-05-29 12:31:04 +00:00
{ #category : #accessing }
HedgeDoc >> server [
2019-05-29 12:31:04 +00:00
^ server
]
{ #category : #accessing }
HedgeDoc >> server: aUrlString [
2019-05-29 12:31:04 +00:00
server := aUrlString
]
2020-05-02 23:59:57 +00:00
{ #category : #accessing }
HedgeDoc >> url [
^ url asUrl
2020-05-02 23:59:57 +00:00
]
2020-08-29 01:24:25 +00:00
{ #category : #accessing }
HedgeDoc >> url: anObject [
2020-08-29 01:24:25 +00:00
url := anObject
]
2019-05-29 12:31:04 +00:00
{ #category : #visiting }
HedgeDoc >> visit [
WebBrowser openOn: self server, '/', self pad.
2019-05-29 12:31:04 +00:00
]