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

View File

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