Skip to content

Commit

Permalink
Merge pull request #775 from moufort/modificationStructure
Browse files Browse the repository at this point in the history
Delete all empty month summary
  • Loading branch information
Ducasse authored Jun 20, 2024
2 parents 826f0e2 + 1132b64 commit 7879310
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 28 deletions.
23 changes: 18 additions & 5 deletions src/Microdown-Blog-Tests/MicBlogCreatorTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,14 @@ MicBlogCreatorTest >> testCreateAllHtmlFile [
{ #category : 'tests' }
MicBlogCreatorTest >> testCreateFromTo [

| allFile nbMonthFile nbCSSFile|
| allFile |
MicBlogCreator
createFrom: fileSystem / 'source'
to: fileSystem / 'html'.

allFile := (fileSystem / 'html') allFiles.

nbMonthFile := (Date today year - 2014) * 12 + Date today month index.
nbCSSFile := 1.

self assert: allFile size equals: 5 + nbMonthFile + nbCSSFile
self assert: allFile size equals: 8
]

{ #category : 'tests' }
Expand Down Expand Up @@ -220,6 +217,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 [

Expand Down
21 changes: 21 additions & 0 deletions src/Microdown-Blog-Tests/MicMonthListCreatorTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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)'
]
58 changes: 37 additions & 21 deletions src/Microdown-Blog/MicBlogCreator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -53,43 +53,33 @@ MicBlogCreator >> copySourceDirectoryInTarget [
{ #category : 'rendering' }
MicBlogCreator >> createAllHtmlFile [

| allFile allFileParse sum summar listOfSingleSummarize |
dateList := MicMonthListCreator new
generateMicListBlockOfLinkDateTo: targetDirectory.
| allFile allFileParse sum listOfSingleSummarize |
"Copy the source directory in the target directory"
self copySourceDirectoryInTarget.

"Download the CSS"
self downloadCSS.

self downloadCSS.

"Collect and parse all Markdown file of targetDirectory"
allFile := self collectAllMarkDownFile: targetDirectory.
allFileParse := allFile collect: [ :each |
(Microdown parse: each asFileReference contents)
fromFile: each ].


"Create _monthListBlog"
self initializeMonthList: allFileParse.

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

"create summarizer html file"
sum := MicSummarizer new.
sum targetDirectory: targetDirectory.

listOfSingleSummarize := allFileParse collect: [ :each |
MicSingleSummarizer new summarize: each ].
self createHtmlSummarize: (sum summarize: listOfSingleSummarize).

"Create the directory with all month summarizer in html"
targetDirectory fileSystem createDirectory:
targetDirectory fullName , '/_monthBlog'.

MicMonthListCreator new generateDateListSince2014 do: [ :each |
summar := sum group: listOfSingleSummarize byDate: each.
summar isNotEmpty
ifTrue: [
summar := sum summarize: summar.
self createHtmlGroupFile: summar at: each ]
ifFalse: [ self createHtmlEmptyGroupFileAt: each ] ]

self createHtmlSummarize: (sum summarize: listOfSingleSummarize)
]

{ #category : 'rendering' }
Expand Down Expand Up @@ -178,6 +168,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 [

Expand Down
10 changes: 8 additions & 2 deletions src/Microdown-Blog/MicMonthListCreator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7879310

Please sign in to comment.