Skip to content

Commit

Permalink
Rescue changes of Quentin.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ducasse committed Jun 24, 2024
1 parent c21efd3 commit 3e8e5d9
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 37 deletions.
22 changes: 22 additions & 0 deletions src/Microdown-Blog-Tests/MicBlogCreatorTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ MicBlogCreatorTest >> testCollectAllMarkDownFile [
self assert: fileList size equals: 3
]

{ #category : 'tests' }
MicBlogCreatorTest >> testCollectAndParseAllMarkdownFile [

| allFileParse |

blog copySourceDirectoryInTarget.
allFileParse := blog collectAndParseAllMarkdownFile.

self assert: allFileParse size equals: 3.
self assert: (allFileParse first isKindOf: MicRootBlock)
]

{ #category : 'tests' }
MicBlogCreatorTest >> testCopySourceDirectoryInTarget [

Expand Down Expand Up @@ -202,6 +214,16 @@ MicBlogCreatorTest >> testCreateHtmlSummarize [
self assert: (fileSystem / 'html/index.html') exists
]

{ #category : 'tests' }
MicBlogCreatorTest >> testDownloadCSS [

blog cssFrameworkName: 'Axist'.
blog downloadCSS.

self assert: (fileSystem / 'html' / 'css') isDirectory.
self assert: (fileSystem / 'html' / 'css' / 'axist.min.css') exists
]

{ #category : 'tests' }
MicBlogCreatorTest >> testInitializeMonthList [

Expand Down
14 changes: 6 additions & 8 deletions src/Microdown-Blog/MicAbstractBlogCreator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ Class {
MicAbstractBlogCreator >> makeALink: aText to: aLink [

| text link |

(aText isNil or: aText isEmpty)
ifTrue: [ text := 'Undefined' ]
ifFalse: [ text := aText ].

(aLink isNil or: aLink isEmpty)
ifTrue: [ link := 'Undefined' ]
ifFalse: [ link := aLink ].
text := aText.
(text isNil or: text isEmpty)
ifTrue: [ text := 'Undefined' ].

link := aLink.
(link isNil or: link isEmpty)
ifTrue: [ link := 'Undefined' ].
^ (MicInlineParser parse: '[' , text , '](' , link , ')') first
]

Expand Down
41 changes: 14 additions & 27 deletions src/Microdown-Blog/MicBlogCreator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,23 @@ MicBlogCreator >> copySourceDirectoryInTarget [
{ #category : 'rendering' }
MicBlogCreator >> createAllHtmlFile [

| allFileParse |

| allFileParse listOfSingleSummary |
self copySourceDirectoryInTarget.

self downloadCSS.

allFileParse := self collectAndParseAllMarkdownFile.

"Create _monthListBlog"
self initializeMonthList: allFileParse.
listOfSingleSummary := allFileParse collect: [ :each |
MicSingleSummarizer new summarize: each ].
self initializeMonthList: listOfSingleSummary.

"transform all markdown file into html file"
allFileParse do: [ :each |
self createHtmlFile: each toReplace: each fromFile ].

self generateMainSummary: allFileParse.


self createHtmlSummarize: (sum summarize: listOfSingleSummary)
]

{ #category : 'rendering' }
Expand All @@ -109,14 +108,13 @@ MicBlogCreator >> createHtmlFile: aMicRoot toReplace: aFileReference [
{ #category : 'rendering' }
MicBlogCreator >> createHtmlGroupFile: aMicRoot at: aMonth [

| visitor fileRef |
| visitor |
self rootAssembly: aMicRoot.
visitor := (MicHTMLVisitor new visit: aMicRoot) first.
fileRef := targetDirectory / '_monthBlog'.
self
write: visitor
to: fileRef
named: aMonth name , '_' , aMonth year asString , '.html'
to: targetDirectory
named: '_monthBlog/' ,aMonth name , '_' , aMonth year asString , '.html'
]

{ #category : 'rendering' }
Expand Down Expand Up @@ -145,25 +143,14 @@ MicBlogCreator >> dateList: aDateList [
{ #category : 'css' }
MicBlogCreator >> downloadCSS [

| a |
| cssProvider |
(targetDirectory / 'css') ensureCreateDirectory.
a := MicCSSProvider new.
a
cssProvider := MicCSSProvider new.
cssProvider
findCssNamed: cssFrameworkName;
destinationPath: targetDirectory / 'css'.
a cssDownloader downloadCSSFramework:
(MicCSSProvider forCSSNamed: cssFrameworkName)
]

{ #category : 'rendering' }
MicBlogCreator >> generateMainSummary: allFileParse [

| listOfSingleSummary |

listOfSingleSummary := allFileParse collect: [ :each |
MicSingleSummarizer new summarize: each ].

self createHtmlSummarize: (sum summarize: listOfSingleSummary)
cssProvider cssDownloader downloadCSSFramework:
(cssProvider findCssNamed: cssFrameworkName)
]

{ #category : 'initialization' }
Expand Down
3 changes: 1 addition & 2 deletions src/Microdown-Blog/MicMonthListCreator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ MicMonthListCreator >> generateMicListBlockOfLinkDateWith: aDateList To: aFileRe

| root link listElement disk |
root := MicUnorderedListBlock new.

disk := ''.
(aFileReference fileSystem store isKindOf: WindowsStore) ifTrue: [
disk := 'File:///' , aFileReference fileSystem store currentDisk ].
disk ifNil: [ disk := '' ].

aDateList do: [ :each |
listElement := MicListItemBlock new.
Expand Down

0 comments on commit 3e8e5d9

Please sign in to comment.