Improving Lepiter pages importation fom legacy Grafoscopio notebooks.
This commit is contained in:
parent
8488531726
commit
362659b584
@ -5,7 +5,7 @@ LeDatabase >> addPageCopy: aLePage [
|
||||
| page |
|
||||
page := LePage new.
|
||||
page title: ('Copy of ', aLePage title,' (id: ', (page uid asString copyFrom: 1 to: 8), ')').
|
||||
aLePage children do: [ :snippet | | newSnippet |
|
||||
aLePage allChildrenDepthFirst do: [ :snippet | | newSnippet |
|
||||
newSnippet := snippet class new.
|
||||
newSnippet className = 'LeTextSnippet' ifTrue: [ newSnippet
|
||||
string: snippet contentAsString ].
|
||||
@ -23,6 +23,7 @@ LeDatabase >> addPageFromMarkdeep: markdeepDocTree withRemote: externalDocLocati
|
||||
| remoteMetadata divSnippets snippets page |
|
||||
divSnippets := (markdeepDocTree xpath: '//div[@st-class]') asOrderedCollection
|
||||
collect: [ :xmlElement | xmlElement postCopy ].
|
||||
self sanitizeMarkdeepSnippets: divSnippets.
|
||||
snippets := divSnippets
|
||||
collect: [ :xmlElement |
|
||||
(xmlElement attributes at: 'st-class') = 'LeTextSnippet'
|
||||
|
@ -16,16 +16,22 @@ LeTextSnippet >> asLePage [
|
||||
{ #category : #'*MiniDocs' }
|
||||
LeTextSnippet >> contentFrom: markdeepDiv [
|
||||
|
||||
| sanitizedStringText metadata |
|
||||
| sanitizedStringText metadata creationTime modificationTime |
|
||||
metadata := STON fromString: (markdeepDiv attributes at: 'st-data').
|
||||
self uid: (LeUID new uidString: (metadata at: 'id')).
|
||||
"creationTime is needed to deal with empty values from Grafoscopio migrated notebooks."
|
||||
creationTime := metadata at: 'created'.
|
||||
modificationTime := (metadata at: 'modified') asDateAndTime.
|
||||
(creationTime isNil or: [ creationTime = 'nil']) ifTrue: [
|
||||
creationTime := modificationTime - 1 second.
|
||||
self addErrata: 'Older: created before it appears.'].
|
||||
sanitizedStringText := markdeepDiv contentString.
|
||||
sanitizedStringText := sanitizedStringText allButFirst.
|
||||
sanitizedStringText := sanitizedStringText allButLast.
|
||||
self string: sanitizedStringText;
|
||||
uid: (LeUID new uidString: (metadata at: 'id'));
|
||||
parent: (metadata at: 'parent');
|
||||
createTime: (LeTime new time: ((metadata at: 'created')asDateAndTime));
|
||||
editTime: (LeTime new time: ((metadata at: 'modified') asDateAndTime));
|
||||
createTime: (LeTime new time: creationTime asDateAndTime);
|
||||
editTime: (LeTime new time: modificationTime);
|
||||
editEmail: (metadata at: 'modifier');
|
||||
createEmail: (metadata at: 'creator')
|
||||
]
|
||||
@ -57,6 +63,7 @@ LeTextSnippet >> options [
|
||||
{ #category : #'*MiniDocs' }
|
||||
LeTextSnippet >> parentId [
|
||||
self parent ifNil: [ ^ self ].
|
||||
(self parent isString) ifTrue: [^ self parent].
|
||||
^ self parent uidString.
|
||||
]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user