Importing errors track conflicting local and remote content now.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2022-10-09 18:12:15 -05:00
parent 2a238ae2c2
commit fd3b4d7925
1 changed files with 32 additions and 30 deletions

View File

@ -2,38 +2,37 @@ Extension { #name : #LeDatabase }
{ #category : #'*MiniDocs' }
LeDatabase >> addPageFromMarkdeep: markdeepDocTree withRemote: externalDocLocation [
| remoteMetadata divSnippets snippets page |
divSnippets := (markdeepDocTree xpath: '//div[@st-class]')
asOrderedCollection collect: [ :xmlElement | xmlElement postCopy ].
snippets := divSnippets collect: [ :xmlElement |
(xmlElement attributes at: 'st-class') = 'LeTextSnippet'
ifTrue: [ LeTextSnippet new contentFrom: xmlElement ]
ifFalse: [ (xmlElement attributes at: 'st-class') = 'LePharoSnippet'
ifTrue: [ LePharoSnippet new contentFrom: xmlElement ]
]
].
divSnippets := (markdeepDocTree xpath: '//div[@st-class]') asOrderedCollection
collect: [ :xmlElement | xmlElement postCopy ].
snippets := divSnippets
collect: [ :xmlElement |
(xmlElement attributes at: 'st-class') = 'LeTextSnippet'
ifTrue: [ LeTextSnippet new contentFrom: xmlElement ]
ifFalse: [ (xmlElement attributes at: 'st-class') = 'LePharoSnippet'
ifTrue: [ LePharoSnippet new contentFrom: xmlElement ] ] ].
remoteMetadata := Markdeep new metadataFromXML: markdeepDocTree.
page := LePage new
title: (remoteMetadata at: 'title');
basicUid: (UUID fromString36: (remoteMetadata at: 'id'));
createTime: (LeTime new time: ((remoteMetadata at: 'created') asDateAndTime));
editTime: (LeTime new time: ((remoteMetadata at: 'modified') asDateAndTime));
latestEditTime: (LeTime new time: ((remoteMetadata at: 'modified') asDateAndTime));
createEmail: (LeEmail new email:(remoteMetadata at: 'creator'));
editEmail: (LeEmail new email:(remoteMetadata at: 'modifier')).
title: (remoteMetadata at: 'title');
basicUid: (UUID fromString36: (remoteMetadata at: 'id'));
createTime: (LeTime new time: (remoteMetadata at: 'created') asDateAndTime);
editTime: (LeTime new time: (remoteMetadata at: 'modified') asDateAndTime);
latestEditTime: (LeTime new time: (remoteMetadata at: 'modified') asDateAndTime);
createEmail: (LeEmail new email: (remoteMetadata at: 'creator'));
editEmail: (LeEmail new email: (remoteMetadata at: 'modifier')).
snippets do: [ :snippet | page addSnippet: snippet ].
page children do: [ :snippet |
(self hasBlockUID: (snippet uid))
ifTrue: [ | existingPage |
existingPage := self pages detect: [ :pageTemp | pageTemp includesSnippetUid: snippet uid ].
self importErrorMessage: existingPage.
^ self ]
ifFalse: [
snippet database: self.
self registerSnippet: snippet ] ].
page children
do: [ :snippet |
(self hasBlockUID: snippet uid)
ifTrue: [ | existingPage |
existingPage := self pages
detect: [ :pageTemp | pageTemp includesSnippetUid: snippet uid ].
self importErrorForLocal: existingPage withRemote: externalDocLocation.
^ self ]
ifFalse: [ snippet database: self.
self registerSnippet: snippet ] ].
self addPage: page.
^ page
^ page
]
{ #category : #'*MiniDocs' }
@ -42,7 +41,7 @@ LeDatabase >> addPageFromMarkdeepUrl: aString [
page := self detectLocalPageForRemote: aString.
page
ifNotNil: [ :arg |
self importErrorMessage: page.
self importErrorForLocal: page withRemote: aString.
^ self ].
^ self addPageFromMarkdeep: (self docTreeForLink: aString) withRemote: aString
]
@ -121,7 +120,7 @@ LeDatabase >> gtViewErrorDetailsOn: aView [
]
{ #category : #'*MiniDocs' }
LeDatabase >> importErrorMessage: page [
LeDatabase >> importErrorForLocal: page withRemote: externalDocLocation [
| message id |
id := page uidString.
@ -137,7 +136,10 @@ LeDatabase >> importErrorMessage: page [
nextPut: Character lf;
nextPutAll: 'already exists in this database and includes overlapping contents';
nextPut: Character lf;
nextPutAll: 'with the page you are trying to import.';
nextPutAll: 'with the page you are trying to import from:
';
nextPut: Character lf;
nextPutAll: externalDocLocation;
nextPut: Character lf;
nextPut: Character lf;
nextPutAll: