Refactoring, so functionality can be called without the GUI.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2024-04-08 12:46:42 -05:00
parent 9ae7a6ec62
commit 8fb6373a83
2 changed files with 18 additions and 5 deletions

View File

@ -184,6 +184,16 @@ LeDatabase >> gtViewErrorDetailsOn: aView withKey: erroKey [
]. ].
] ]
{ #category : #'*MiniDocs' }
LeDatabase >> importDocumentFrom: aURL [
| doc |
"Using file extension in URL as a cheap (non-robuts) way of detecting the kind of document.
Better file type detection should be implemented in the future."
(aURL endsWith: '.md.html') ifTrue: [ ^ self addPageFromMarkdeepUrl: aURL ].
doc := HedgeDoc fromLink: aURL asString.
^ self addPage: doc asLePage
]
{ #category : #'*MiniDocs' } { #category : #'*MiniDocs' }
LeDatabase >> importErrorForLocal: page withRemote: externalDocLocation [ LeDatabase >> importErrorForLocal: page withRemote: externalDocLocation [

View File

@ -42,22 +42,25 @@ LeMiniDocsImport >> createURLeditable [
text: 'Document link'; text: 'Document link';
switchToEditor. switchToEditor.
editable when: BrEditorAcceptWish do: [ :aWish | editable when: BrEditorAcceptWish do: [ :aWish |
self importHedgedoc: aWish text asString. self importDocumentFrom: aWish text asString.
]. ].
base addChild: editable. base addChild: editable.
^ base ^ base
] ]
{ #category : #accessing }
LeMiniDocsImport >> database [
^ database
]
{ #category : #accessing } { #category : #accessing }
LeMiniDocsImport >> database: aLeDatabase [ LeMiniDocsImport >> database: aLeDatabase [
database := aLeDatabase database := aLeDatabase
] ]
{ #category : #accessing } { #category : #accessing }
LeMiniDocsImport >> importHedgedoc: aURL [ LeMiniDocsImport >> importDocumentFrom: aURL [
| doc | ^ self database importDocumentFrom: aURL.
doc := HedgeDoc fromLink: aURL asString.
^ database addPage: doc asLePage
] ]
{ #category : #accessing } { #category : #accessing }