2022-02-01 03:12:33 +00:00
|
|
|
Extension { #name : #LeDatabase }
|
|
|
|
|
2022-02-02 23:35:39 +00:00
|
|
|
{ #category : #'*Grafoscopio-Utils-Core' }
|
|
|
|
LeDatabase >> addPageFromMarkdeepUrl: aString [
|
|
|
|
|
|
|
|
| page |
|
|
|
|
page := self detectLocalPageForRemote: aString.
|
2022-03-01 14:15:05 +00:00
|
|
|
page ifNotNil: [ :arg | ^ self importErrorMessage: page ].
|
|
|
|
self addPage: page.
|
2022-02-02 23:35:39 +00:00
|
|
|
]
|
|
|
|
|
2022-02-01 03:12:33 +00:00
|
|
|
{ #category : #'*Grafoscopio-Utils-Core' }
|
|
|
|
LeDatabase >> detectLocalPageForRemote: markdeepDocUrl [
|
|
|
|
| markdeepHelper id remoteMetadata docTree |
|
|
|
|
markdeepHelper := Markdeep new.
|
|
|
|
docTree := (XMLHTMLParser on: markdeepDocUrl asUrl retrieveContents) parseDocument.
|
|
|
|
remoteMetadata := markdeepHelper metadataFromXML: docTree.
|
|
|
|
id := remoteMetadata at: 'id' ifAbsent: [ ^ false ].
|
|
|
|
^ self pageWithID: id ifAbsent: [ nil ].
|
|
|
|
]
|
2022-02-02 23:35:39 +00:00
|
|
|
|
|
|
|
{ #category : #'*Grafoscopio-Utils-Core' }
|
|
|
|
LeDatabase >> importErrorMessage: page [
|
|
|
|
|
|
|
|
^ String streamContents: [ :stream |
|
|
|
|
stream
|
|
|
|
nextPutAll: 'IMPORTATION ERROR: a page with';
|
|
|
|
nextPut: Character lf;
|
|
|
|
nextPut: Character lf;
|
|
|
|
nextPutAll: ' id: ' , page uidString;
|
|
|
|
nextPut: Character lf;
|
|
|
|
nextPutAll: ' title: ' , page contentAsString;
|
|
|
|
nextPut: Character lf;
|
|
|
|
nextPut: Character lf;
|
|
|
|
nextPutAll: 'already exists in this database.';
|
|
|
|
nextPut: Character lf;
|
|
|
|
nextPut: Character lf;
|
|
|
|
nextPutAll:
|
|
|
|
'Please do one of those before retrying this procedure:
|
|
|
|
|
|
|
|
1) Move the existing page files (.lepiter and .bak) to another (sub)folder.
|
|
|
|
2) Import the page url to another database.' ]
|
|
|
|
]
|