diff --git a/src/Microdown-Blog-Tests/MicBlogCreatorTest.class.st b/src/Microdown-Blog-Tests/MicBlogCreatorTest.class.st index 704795c9..41c5a732 100644 --- a/src/Microdown-Blog-Tests/MicBlogCreatorTest.class.st +++ b/src/Microdown-Blog-Tests/MicBlogCreatorTest.class.st @@ -220,6 +220,22 @@ MicBlogCreatorTest >> testCreateHtmlSummarize [ self assert: (fileSystem / 'html/index.html') exists ] +{ #category : 'tests' } +MicBlogCreatorTest >> testInitializeMonthList [ + + | listSingleSummarizer | + + listSingleSummarizer := Array new: 3. + +listSingleSummarizer at:1 put: (MicSingleSummarizer new summarizeFile: fileSystem / 'source/anExample1.md'). +listSingleSummarizer at:2 put: (MicSingleSummarizer new summarizeFile: fileSystem / 'source/anExample2.md'). +listSingleSummarizer at:3 put: (MicSingleSummarizer new summarizeFile: fileSystem / 'source/test/anExample3.md'). + + blog initializeMonthList: listSingleSummarizer. + +self assert: (fileSystem / 'html/_monthBlog') allFiles size equals: 2. +] + { #category : 'tests' } MicBlogCreatorTest >> testRenameMarkdownIntoHtmlFile [ diff --git a/src/Microdown-Blog-Tests/MicMonthListCreatorTest.class.st b/src/Microdown-Blog-Tests/MicMonthListCreatorTest.class.st index 995bff7b..111962df 100644 --- a/src/Microdown-Blog-Tests/MicMonthListCreatorTest.class.st +++ b/src/Microdown-Blog-Tests/MicMonthListCreatorTest.class.st @@ -43,3 +43,24 @@ MicMonthListCreatorTest >> testGenerateMicListBlockOfLinkDateTo [ equals: '[' , Date today month asString , '](/html/_monthBlog/' , Date today month name , '_' , Date today year asString, '.html)' ] + +{ #category : 'tests' } +MicMonthListCreatorTest >> testGenerateMicListBlockOfLinkDateWithTo [ + + | dateList fileSystem | + fileSystem := FileSystem memory. + fileSystem createDirectory: '/html'. + + dateList := MicMonthListCreator new + generateMicListBlockOfLinkDateTo: + fileSystem workingDirectory / '/html'. + + self assert: (dateList isKindOf: MicUnorderedListBlock). + self + assert: dateList children size equals: self numberOfMonthSince2014; + assert: dateList children first children first plainText + equals: '[January 2014](/html/_monthBlog/January_2014.html)'; + assert: dateList children last children first plainText + equals: '[' , Date today month asString , '](/html/_monthBlog/' + , Date today month name , '_' , Date today year asString , '.html)' +] diff --git a/src/Microdown-Blog/MicBlogCreator.class.st b/src/Microdown-Blog/MicBlogCreator.class.st index 64bdc531..475b4562 100644 --- a/src/Microdown-Blog/MicBlogCreator.class.st +++ b/src/Microdown-Blog/MicBlogCreator.class.st @@ -178,6 +178,32 @@ MicBlogCreator >> initialize [ self cssFrameworkName: 'Axist'. ] +{ #category : 'rendering' } +MicBlogCreator >> initializeMonthList: listOfSingleSummarize [ + + | summar sum date | + sum := MicSummarizer new. + sum targetDirectory: targetDirectory. + + dateList := MicMonthListCreator new generateDateListSince2014. + date := dateList copy. + + date do: [ :each | + summar := sum group: listOfSingleSummarize byDate: each. + summar isEmpty ifTrue: [ dateList := dateList copyWithout: each ] ]. + + date := dateList copy. + + dateList := MicMonthListCreator new + generateMicListBlockOfLinkDateWith: dateList + To: targetDirectory. + + date do: [ :each | + summar := sum group: listOfSingleSummarize byDate: each. + summar := sum summarize: summar. + self createHtmlGroupFile: summar at: each ] +] + { #category : 'as yet unclassified' } MicBlogCreator >> levelPathDifferenceForCSS: aStringPath [ diff --git a/src/Microdown-Blog/MicMonthListCreator.class.st b/src/Microdown-Blog/MicMonthListCreator.class.st index 385fdde9..e31d4448 100644 --- a/src/Microdown-Blog/MicMonthListCreator.class.st +++ b/src/Microdown-Blog/MicMonthListCreator.class.st @@ -22,14 +22,20 @@ MicMonthListCreator >> generateDateListSince2014 [ { #category : 'generate' } MicMonthListCreator >> generateMicListBlockOfLinkDateTo: aFileReference [ + ^ self generateMicListBlockOfLinkDateWith: self generateDateListSince2014 To: aFileReference +] + +{ #category : 'generate' } +MicMonthListCreator >> generateMicListBlockOfLinkDateWith: aDateList To: aFileReference [ + | root link listElement disk | root := MicUnorderedListBlock new. (aFileReference fileSystem store isKindOf: WindowsStore) ifTrue: [ - disk := 'File:///', aFileReference fileSystem store currentDisk ]. + disk := 'File:///' , aFileReference fileSystem store currentDisk ]. disk ifNil: [ disk := '' ]. - self generateDateListSince2014 do: [ :each | + aDateList do: [ :each | listElement := MicListItemBlock new. link := self makeALink: each asString