Improving HedgeDoc page importation.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2024-03-26 12:53:55 -05:00
parent e7f2910a51
commit aec4b58e23
3 changed files with 9 additions and 5 deletions

View File

@ -16,6 +16,11 @@ Class {
#category : #'MiniDocs-Core' #category : #'MiniDocs-Core'
} }
{ #category : #accessing }
HedgeDoc class >> fromLink: aUrl [
^ self new fromLink: aUrl
]
{ #category : #'as yet unclassified' } { #category : #'as yet unclassified' }
HedgeDoc class >> newDefault [ HedgeDoc class >> newDefault [
^ self new ^ self new

View File

@ -37,14 +37,13 @@ LeHomeDatabaseHeaderElement >> initializeButtons [
{ #category : #'*MiniDocs' } { #category : #'*MiniDocs' }
LeHomeDatabaseHeaderElement >> initializeMiniDocsImportButton [ LeHomeDatabaseHeaderElement >> initializeMiniDocsImportButton [
"importMinidocsButtonElement := self newImportMiniDocsButton."
self userData at: 'importMinidocsButtonElement' put: self newImportMiniDocsButton. self userData at: 'importMinidocsButtonElement' put: self newImportMiniDocsButton.
] ]
{ #category : #'*MiniDocs' } { #category : #'*MiniDocs' }
LeHomeDatabaseHeaderElement >> newImportMiniDocsButton [ LeHomeDatabaseHeaderElement >> newImportMiniDocsButton [
^ LeMiniDocsImport new ^ LeMiniDocsImport new
tooltip: 'Import MiniDocs from url'; tooltip: 'Import document from link';
contentExtent: 200 @ 30 contentExtent: 200 @ 30
] ]

View File

@ -39,7 +39,7 @@ LeMiniDocsImport >> createURLeditable [
yourself. yourself.
editable := BrEditableLabel new editable := BrEditableLabel new
aptitude: BrGlamorousEditableLabelAptitude new glamorousRegularFontAndSize; aptitude: BrGlamorousEditableLabelAptitude new glamorousRegularFontAndSize;
text: 'Hedgedoc url'; text: 'Document link';
switchToEditor. switchToEditor.
editable when: BrEditorAcceptWish do: [ :aWish | editable when: BrEditorAcceptWish do: [ :aWish |
self importHedgedoc: aWish text asString. self importHedgedoc: aWish text asString.
@ -56,9 +56,9 @@ LeMiniDocsImport >> database: aLeDatabase [
{ #category : #accessing } { #category : #accessing }
LeMiniDocsImport >> importHedgedoc: aURL [ LeMiniDocsImport >> importHedgedoc: aURL [
| doc text page | | doc text page |
doc := HedgeDoc new url: aURL asString. doc := HedgeDoc fromLink: aURL asString.
text := doc retrieveContents; contents. text := doc retrieveContents; contents.
page := LePage named: (doc metadata at: 'title'). page := LePage named: (doc title).
page addSnippet: (LeTextSnippet string: text). page addSnippet: (LeTextSnippet string: text).
^ database addPage: page ^ database addPage: page
] ]