From 92a686de960ae8d3ad94243fe868d95cbbb6c8fb Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Wed, 25 Oct 2023 06:50:15 -0500 Subject: [PATCH] Copy of nested docs working thanks to botwhytho's LepiterBuiddingBlocs. --- .../BaselineOfMiniDocs.class.st | 1 + src/MiniDocs/LeDatabase.extension.st | 19 ++++++------------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/BaselineOfMiniDocs/BaselineOfMiniDocs.class.st b/src/BaselineOfMiniDocs/BaselineOfMiniDocs.class.st index 159b682..6f2ee38 100644 --- a/src/BaselineOfMiniDocs/BaselineOfMiniDocs.class.st +++ b/src/BaselineOfMiniDocs/BaselineOfMiniDocs.class.st @@ -14,6 +14,7 @@ BaselineOfMiniDocs >> baseline: spec [ spec baseline: 'Mustache' with: [ spec repository: 'github://noha/mustache' ]; baseline: 'Tealight' with: [ spec repository: 'github://astares/Tealight:main/src' ]; + baseline: 'LepiterBuildingBlocs' with: [spec repository: 'github://botwhytho/LepiterBuildingBlocs:main/src']; baseline: 'PetitParser' with: [ spec loads: #('Minimal' 'Core' 'Tests' 'Islands'); diff --git a/src/MiniDocs/LeDatabase.extension.st b/src/MiniDocs/LeDatabase.extension.st index 9cc1035..a54583d 100644 --- a/src/MiniDocs/LeDatabase.extension.st +++ b/src/MiniDocs/LeDatabase.extension.st @@ -2,19 +2,12 @@ Extension { #name : #LeDatabase } { #category : #'*MiniDocs' } LeDatabase >> addPageCopy: aLePage [ - | page | - page := LePage new. - page title: ('Copy of ', aLePage title,' (id: ', (page uid asString copyFrom: 1 to: 8), ')'). - aLePage allChildrenDepthFirst do: [ :snippet | | newSnippet | - newSnippet := snippet class new. - newSnippet className = 'LeTextSnippet' ifTrue: [ newSnippet - string: snippet contentAsString ]. - newSnippet className = 'LePharoSnippet' ifTrue: [ newSnippet code: snippet contentAsString ]. - newSnippet uid: LeUID new. - page addSnippet: newSnippet. - newSnippet database: self. - self registerSnippet: newSnippet ]. - self addPage: page. + | pageTitle timestamp shortID page | + timestamp := DateAndTime now asString. + pageTitle := 'Copy of ', aLePage title. + page := aLePage duplicatePageWithNewName: pageTitle, timestamp. + shortID := '(id: ', (page uid asString copyFrom: 1 to: 8), ')'. + page title: (page title copyReplaceAll: timestamp with: shortID). ^ page ]