Migrating from GrafoscopioUtils.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2022-07-26 17:59:22 -05:00
parent 5f37293f4d
commit 3876b12eb9
3 changed files with 71 additions and 5 deletions

View File

@ -84,6 +84,13 @@ LePage >> defaultPandocTemplate [
^ FileLocator home / '.pandoc' / 'templates' / 'clean-menu-mod.html'
]
{ #category : #'*MiniDocs' }
LePage >> detectParentSnippetWithUid: uidString [
"Answer a boolean indicating whether the supplied uid is present"
^ self preorderTraversal detect: [ :snippet | snippet uidString = uidString ] ifNone: [ ^ self ]
]
{ #category : #'*MiniDocs' }
LePage >> exportedFileName [
| sanitized |
@ -91,6 +98,28 @@ LePage >> exportedFileName [
^ sanitized , '--' , (self uidString copyFrom: 1 to: 5)
]
{ #category : #'*MiniDocs' }
LePage >> fileName [
^ self title asDashedLowercase, '.', ((self uidString copyFrom: 1 to: 5 ) copyWithoutAll: '/'), '.md.html'
]
{ #category : #'*MiniDocs' }
LePage >> fromMarkdeepUrl: aString [
| docTree pageMetadata |
docTree := GrafoscopioUtils xmlFromUrl: aString.
pageMetadata := Markdeep new metadataFromXML: docTree.
self
basicUid: (pageMetadata at: 'id');
title: (pageMetadata at: 'title');
createTime: (pageMetadata at: 'created') asDateAndTime;
editTime: (pageMetadata at: 'modified') asDateAndTime;
createEmail: (pageMetadata at: 'creator');
editEmail: (pageMetadata at: 'modifier');
optionAt: 'metadata' put: pageMetadata.
self populateChildrenFrom: (docTree xpath: '//div')
]
{ #category : #'*MiniDocs' }
LePage >> htmlFileName [
^ self exportedFileName, '.html'
@ -126,6 +155,15 @@ LePage >> metadataInit [
yourself
]
{ #category : #'*MiniDocs' }
LePage >> navTop [
| topNavFile |
topNavFile := ((self optionAt: 'storage') / '_navtop.html').
topNavFile exists
ifFalse: [ ^ '' ]
ifTrue: [ ^ topNavFile contents ]
]
{ #category : #'*MiniDocs' }
LePage >> options [
^ options
@ -139,6 +177,13 @@ LePage >> preorderTraversal [
^ output.
]
{ #category : #'*MiniDocs' }
LePage >> removeSnippetsMetadata [
self preorderTraversal do: [ :snippet |
(snippet options isNotNil and: [ snippet options includesKey: 'metadata' ])
ifTrue: [ snippet options removeKey: 'metadata' ] ]
]
{ #category : #'*MiniDocs' }
LePage >> storage [

View File

@ -1,5 +1,13 @@
Extension { #name : #LePharoSnippet }
{ #category : #'*MiniDocs' }
LePharoSnippet >> contentAsStringCustomized [
| customCoder |
(self tags includes: 'output') ifFalse: [ ^ self contentAsString ].
customCoder := GtPharoSnippetCoder forSource: self contentAsString.
^ (customCoder doItAll) value greaseString
]
{ #category : #'*MiniDocs' }
LePharoSnippet >> markdeepCustomCloser [
^ String streamContents: [ :stream |
@ -20,6 +28,7 @@ LePharoSnippet >> markdeepCustomOpener [
{ #category : #'*MiniDocs' }
LePharoSnippet >> markdownCustomCloser [
(self tags includes: 'output') ifTrue: [^ String with: Character lf].
^ String streamContents: [:stream |
stream
nextPutAll: '~~~'; lf
@ -28,8 +37,10 @@ LePharoSnippet >> markdownCustomCloser [
{ #category : #'*MiniDocs' }
LePharoSnippet >> markdownCustomOpener [
^ String streamContents: [:stream |
(self tags includes: 'output') ifTrue: [ ^ String with: Character lf ].
^ String
streamContents: [ :stream |
stream
nextPutAll: '~~~ Smalltalk'; lf
]
nextPutAll: '~~~ Smalltalk';
lf ]
]

View File

@ -10,12 +10,17 @@ LeTextualSnippet >> asMarkdown [
nextPutAll: '<div st-class="', self class asString, '"'; lf;
nextPutAll: ' st-data="', (STON toString: self metadata), '">'; lf;
nextPutAll: self markdownCustomOpener;
nextPutAll: self contentAsString; lf;
nextPutAll: self contentAsStringCustomized; lf;
nextPutAll: self markdownCustomCloser;
nextPutAll: '</div>'; lf; lf.
^ output contents
]
{ #category : #'*MiniDocs' }
LeTextualSnippet >> contentAsStringCustomized [
^ self contentAsString
]
{ #category : #'*MiniDocs' }
LeTextualSnippet >> markdeepCustomCloser [
^ ''
@ -35,3 +40,8 @@ LeTextualSnippet >> markdownCustomCloser [
LeTextualSnippet >> markdownCustomOpener [
^ self markdeepCustomOpener
]
{ #category : #'*MiniDocs' }
LeTextualSnippet >> tags [
^ self metadata at: 'tags'
]