Improved CodiMD support and abstracting operations with markup files.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2020-06-08 16:08:39 -05:00
parent 9c7a9bb280
commit b632b72da1
2 changed files with 46 additions and 5 deletions

View File

@ -38,6 +38,19 @@ 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
@ -48,6 +61,32 @@ 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
@ -60,7 +99,7 @@ CodiMD >> server: aUrlString [
{ #category : #accessing }
CodiMD >> url [
^ url
^ url asUrl
]
{ #category : #accessing }

View File

@ -8,9 +8,11 @@ Class {
}
{ #category : #persistence }
MarkupFile class >> exportAsFileOn: aFileReference containing: contents [
aFileReference exists ifFalse: [ aFileReference ensureCreateFile ].
aFileReference writeStreamDo: [ :stream |
MarkupFile class >> exportAsFileOn: aFileReferenceOrFileName containing: contents [
| file |
file := aFileReferenceOrFileName asFileReference.
file exists ifFalse: [ file ensureCreateFile ].
file writeStreamDo: [ :stream |
stream nextPutAll: contents ].
self inform: 'Exported as: ', String cr, aFileReference fullName
self inform: 'Exported as: ', String cr, file fullName
]