From ea1dc02a79497e033c13e08197f8174f6f389666 Mon Sep 17 00:00:00 2001 From: "quentin.moutte.etu" Date: Mon, 27 May 2024 16:57:59 +0200 Subject: [PATCH 1/4] fix error where the link didn't work --- .../MicSingleSummarizerTest.class.st | 26 +++++++------ .../MicSummarizerTest.class.st | 17 +++++---- src/Microdown-Blog/MicBlogCreator.class.st | 37 ++++++++++--------- .../MicSingleSummarizer.class.st | 31 +++++++++------- src/Microdown-Blog/MicSummarizer.class.st | 4 +- 5 files changed, 65 insertions(+), 50 deletions(-) diff --git a/src/Microdown-Blog-Tests/MicSingleSummarizerTest.class.st b/src/Microdown-Blog-Tests/MicSingleSummarizerTest.class.st index b4ad04a0..cd3afee3 100644 --- a/src/Microdown-Blog-Tests/MicSingleSummarizerTest.class.st +++ b/src/Microdown-Blog-Tests/MicSingleSummarizerTest.class.st @@ -11,7 +11,10 @@ Class { { #category : 'enumerating' } MicSingleSummarizerTest >> createMicRootBlock [ - ^ Microdown parse: self generateFilesystemExample asFileReference contents + | micRootBlock | + + micRootBlock := Microdown parse: self generateFilesystemExample contents. + ^ micRootBlock fromFile: self generateFilesystemExample. ] { #category : 'enumerating' } @@ -39,7 +42,7 @@ this is a code blu blu ``` ' ]. - ^ file + ^ file asFileReference ] { #category : 'enumerating' } @@ -47,10 +50,9 @@ MicSingleSummarizerTest >> generateFilesystemExampleEmpty [ | file | file := FileSystem memory workingDirectory / 'anExample1.md'. - file writeStreamDo: [ :stream | - stream nextPutAll: '' ]. + file writeStreamDo: [ :stream | stream nextPutAll: '' ]. - ^ file + ^ file asFileReference ] { #category : 'enumerating' } @@ -78,7 +80,7 @@ this is a code blu blu ``` ' ]. - ^ file + ^ file asFileReference ] { #category : 'enumerating' } @@ -103,7 +105,7 @@ this is a code blu blu ``` ' ]. - ^ file + ^ file asFileReference ] { #category : 'running' } @@ -257,9 +259,9 @@ MicSingleSummarizerTest >> testWithMetaDataAndWithDate [ MicSingleSummarizerTest >> testWithMetaDataAndWithoutDate [ | root | - root := micSingleSummarizer summarize: - (Microdown parse: - self generateFilesystemExampleWithoutDateInMetadata). + + root := micSingleSummarizer summarizeFile: + self generateFilesystemExampleWithoutDateInMetadata. self assert: (root isKindOf: MicRootBlock); assert: root children size equals: 3; @@ -271,8 +273,8 @@ MicSingleSummarizerTest >> testWithMetaDataAndWithoutDate [ MicSingleSummarizerTest >> testWithoutMetaData [ | root | - root := micSingleSummarizer summarize: (Microdown parse: - self generateFilesystemExampleWithoutMetadata ). + root := micSingleSummarizer summarizeFile: + self generateFilesystemExampleWithoutMetadata. self assert: (root isKindOf: MicRootBlock); assert: root children size equals: 3; diff --git a/src/Microdown-Blog-Tests/MicSummarizerTest.class.st b/src/Microdown-Blog-Tests/MicSummarizerTest.class.st index 3a03e25e..edc5c40b 100644 --- a/src/Microdown-Blog-Tests/MicSummarizerTest.class.st +++ b/src/Microdown-Blog-Tests/MicSummarizerTest.class.st @@ -27,12 +27,15 @@ MicSummarizerTest >> createListOfMicRootBlock [ singleSummarizer := MicSingleSummarizer new. singleSummarizer targetDirectory: '/html/'. q - at: 1 put: (singleSummarizer summarize: (Microdown parse: - self generateFilesystemExample1 asFileReference contents)); - at: 2 put: (singleSummarizer summarize: (Microdown parse: - self generateFilesystemExample2 asFileReference contents)); - at: 3 put: (singleSummarizer summarize: (Microdown parse: - self generateFilesystemExample3 asFileReference contents)). + at: 1 put: (singleSummarizer summarize: + ((Microdown parse: self generateFilesystemExample1 contents) + fromFile: self generateFilesystemExample1)); + at: 2 put: (singleSummarizer summarize: + ((Microdown parse: self generateFilesystemExample2 contents) + fromFile: self generateFilesystemExample2)); + at: 3 put: (singleSummarizer summarize: + ((Microdown parse: self generateFilesystemExample3 contents) + fromFile: self generateFilesystemExample3)). ^ q ] @@ -53,7 +56,7 @@ Pharo is cool but _this is_ a superlong _paragraph_ Simple powerful language: No Amazing debugging experience: The Pharo environment includes a debugger unlike anything you''ve seen before. It allows you to step through code, restart the execution of methods, create methods on the fly, and much more! ' ]. - ^ file + ^ file asFileReference ] { #category : 'tests' } diff --git a/src/Microdown-Blog/MicBlogCreator.class.st b/src/Microdown-Blog/MicBlogCreator.class.st index 32710366..0a85853b 100644 --- a/src/Microdown-Blog/MicBlogCreator.class.st +++ b/src/Microdown-Blog/MicBlogCreator.class.st @@ -45,26 +45,32 @@ MicBlogCreator >> copySourceDirectoryInTarget [ { #category : 'rendering' } MicBlogCreator >> createAllHtmlFile [ - | allFile allFileParse sum summar | + | allFile allFileParse sum summar listOfSingleSummarize | + "Copy the source directory in the target directory" self copySourceDirectoryInTarget. + + "Collect and parse all Markdown file of targetDirectory" allFile := self collectAllMarkDownFile: targetDirectory. allFileParse := allFile collect: [ :each | - Microdown parse: each asFileReference contents ]. - - 1 to: allFile size do: [ :index | - self - createHtmlFile: (allFileParse at: index) - toReplace: (allFile at: index) ]. - + (Microdown parse: each asFileReference contents) + fromFile: each ]. + "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 summarizeFile: allFile). + self createHtmlSummarize: (sum summarize: listOfSingleSummarize). - "JUSQUE LA CA MARCHE" - targetDirectory fileSystem createDirectory: '/html/_monthBlog'. + "Create the directory with all month summarizer in html" + + targetDirectory fileSystem createDirectory: + targetDirectory fullName , '/_monthBlog'. MicMonthListCreator new generateDateListSince2014 do: [ :each | summar := sum group: allFileParse byDate: each. @@ -78,8 +84,8 @@ MicBlogCreator >> createHtmlFile: aMicRoot toReplace: aFileReference [ | html | self rootAssembly: aMicRoot. - html := (MicHTMLVisitor new visit: aMicRoot) at: 1. - + html := (MicHTMLVisitor new visit: aMicRoot) first. + self renameMarkdownIntoHtmlFile: aFileReference. aFileReference delete. @@ -111,10 +117,7 @@ MicBlogCreator >> createHtmlSummarize: aMicRoot [ a := (MicHTMLVisitor new visit: aMicRoot) at: 1. - fileRef := targetDirectory copyWithPath: - targetDirectory fullPath asUrl path. - - self write: a to: fileRef named: 'index.html' + self write: a to: targetDirectory named: 'index.html' ] { #category : 'rendering' } diff --git a/src/Microdown-Blog/MicSingleSummarizer.class.st b/src/Microdown-Blog/MicSingleSummarizer.class.st index 8959c123..bef14732 100644 --- a/src/Microdown-Blog/MicSingleSummarizer.class.st +++ b/src/Microdown-Blog/MicSingleSummarizer.class.st @@ -65,19 +65,23 @@ MicSingleSummarizer >> firstParagraphBlockOf: aMicRootBlock [ { #category : 'parsing' } MicSingleSummarizer >> headerLink: aMicRootBlock [ - | headerLink header date | + | headerLink header "date" | headerLink := MicHeaderBlock new. header := self firstHeaderBlockOf: aMicRootBlock. - date := (aMicRootBlock children at: 1) body at: #date. + "date := (aMicRootBlock children at: 1) body at: #date. date := date asDate. headerLink - addChild: (self - makeALink: header text - to: - targetDirectory printString, date year asString , '/' , date monthName - , '/' , date day asString , '/', header text); - level: header level. + addChild: (self + makeALink: header text + to: targetDirectory printString , date year asString , '/' + , date monthName , '/' , date day asString , '/' , header text); + level: header level." + headerLink + addChild: + (self makeALink: header text to: aMicRootBlock fromFile fullName); + level: header level. + ^ headerLink ] @@ -96,10 +100,10 @@ MicSingleSummarizer >> maximumWords: anInteger [ { #category : 'parsing' } MicSingleSummarizer >> summarize: aMicRootBlock [ - | element headerLink root| + | element headerLink root | root := self verifyDateMetadata: aMicRootBlock. element := MicRootBlock new. - headerLink := self headerLink: root. + headerLink := self headerLink: aMicRootBlock. element addChild: root children first; @@ -114,6 +118,7 @@ MicSingleSummarizer >> summarizeFile: aFileReference [ | p | p := Microdown parse: aFileReference asFileReference contents. + p fromFile: aFileReference. ^ self summarize: p ] @@ -129,12 +134,12 @@ MicSingleSummarizer >> verifyDateMetadata: aMicRootBlock [ metadata body: (Dictionary newFromKeys: #( #date ) - andValues: #( '25 December 1970' ))] + andValues: #( '25 December 1970' )) ] ifTrue: [ metadata := aMicRootBlock children at: 1. - (metadata body at: #date) ifNil: [ + (metadata body includesKey: #date) ifFalse: [ metadata body at: #date put: '25 December 1970' ] ]. - metadata parent: newMicRootBlock. + metadata parent: newMicRootBlock. aMicRootBlock children do: [ :each | newMicRootBlock addChild: each ] diff --git a/src/Microdown-Blog/MicSummarizer.class.st b/src/Microdown-Blog/MicSummarizer.class.st index 28d35bb0..3722143e 100644 --- a/src/Microdown-Blog/MicSummarizer.class.st +++ b/src/Microdown-Blog/MicSummarizer.class.st @@ -51,7 +51,9 @@ MicSummarizer >> summarize: aListOfSingleSummarizer [ root := aListOfSingleSummarizer at: each. summarize addChild: (root children at: 2); - addChild: (root children at: 3) ]. + addChild: (root children at: 3)]. + + ^ summarize ] From 151dc603f5079e7a2875ac9e8027bc70dbff1944 Mon Sep 17 00:00:00 2001 From: "quentin.moutte.etu" Date: Tue, 28 May 2024 11:33:30 +0200 Subject: [PATCH 2/4] update test --- ...st => MicAbstractBlogCreatorTest.class.st} | 8 ++-- .../MicBlogCreatorTest.class.st | 41 +++++++++++++------ .../MicMonthListCreatorTest.class.st | 7 +++- .../MicMonthListCreator.class.st | 4 +- .../MicSingleSummarizer.class.st | 12 +----- 5 files changed, 41 insertions(+), 31 deletions(-) rename src/Microdown-Blog-Tests/{MicDocumentTransformerTest.class.st => MicAbstractBlogCreatorTest.class.st} (78%) diff --git a/src/Microdown-Blog-Tests/MicDocumentTransformerTest.class.st b/src/Microdown-Blog-Tests/MicAbstractBlogCreatorTest.class.st similarity index 78% rename from src/Microdown-Blog-Tests/MicDocumentTransformerTest.class.st rename to src/Microdown-Blog-Tests/MicAbstractBlogCreatorTest.class.st index 64560654..f84674dd 100644 --- a/src/Microdown-Blog-Tests/MicDocumentTransformerTest.class.st +++ b/src/Microdown-Blog-Tests/MicAbstractBlogCreatorTest.class.st @@ -1,12 +1,12 @@ Class { - #name : 'MicDocumentTransformerTest', + #name : 'MicAbstractBlogCreatorTest', #superclass : 'TestCase', #category : 'Microdown-Blog-Tests', #package : 'Microdown-Blog-Tests' } { #category : 'tests' } -MicDocumentTransformerTest class >> testMakeALinkTo [ +MicAbstractBlogCreatorTest class >> testMakeALinkTo [ | link | link := MicInlineParser parse: '[Pharo is cool](Test)'. @@ -17,7 +17,7 @@ MicDocumentTransformerTest class >> testMakeALinkTo [ ] { #category : 'tests' } -MicDocumentTransformerTest >> testMakeALinkTo [ +MicAbstractBlogCreatorTest >> testMakeALinkTo [ | link | link := MicAbstractBlogCreator new makeALink: 'Pharo is cool' to: 'Test'. @@ -28,7 +28,7 @@ MicDocumentTransformerTest >> testMakeALinkTo [ ] { #category : 'tests' } -MicDocumentTransformerTest >> testMakeALinkToWithEmptyArguments [ +MicAbstractBlogCreatorTest >> testMakeALinkToWithEmptyArguments [ | link | link := MicAbstractBlogCreator new makeALink: '' to: ''. diff --git a/src/Microdown-Blog-Tests/MicBlogCreatorTest.class.st b/src/Microdown-Blog-Tests/MicBlogCreatorTest.class.st index dc144b82..9ed02499 100644 --- a/src/Microdown-Blog-Tests/MicBlogCreatorTest.class.st +++ b/src/Microdown-Blog-Tests/MicBlogCreatorTest.class.st @@ -62,10 +62,11 @@ When you participate to the mooc you get access to the quizz and the credit vali { #category : 'as yet unclassified' } MicBlogCreatorTest >> generateArchitecture [ - | ref1 ref2 ref3 | + | ref1 ref2 ref3 ref4 | fileSystem := FileSystem memory. fileSystem createDirectory: '/html'. fileSystem createDirectory: '/source'. + fileSystem createDirectory: '/source/test'. ref1 := fileSystem workingDirectory / 'source/anExample1.md'. ref1 writeStreamDo: [ :stream | stream nextPutAll: self fileContent1 ]. @@ -73,8 +74,11 @@ MicBlogCreatorTest >> generateArchitecture [ ref2 := fileSystem workingDirectory / 'source/anExample2.md'. ref2 writeStreamDo: [ :stream | stream nextPutAll: self fileContent2 ]. - ref3 := fileSystem workingDirectory / 'source/anExample3.md'. - ref3 writeStreamDo: [ :stream | stream nextPutAll: self fileContent3 ] + ref3 := fileSystem workingDirectory / 'source/test/anExample3.md'. + ref3 writeStreamDo: [ :stream | stream nextPutAll: self fileContent3 ]. + + ref4 := fileSystem workingDirectory / 'source/anExample4.java'. + ref4 writeStreamDo: [ :stream | stream nextPutAll: 'Du java' ] ] { #category : 'as yet unclassified' } @@ -111,7 +115,12 @@ MicBlogCreatorTest >> testCopySourceDirectoryInTarget [ blog copySourceDirectoryInTarget. - self assert: (fileSystem / 'html') children size equals: 3 + self + assert: (fileSystem / 'html') children size equals: 4; + assert: (fileSystem / 'html/anExample1.md') exists; + assert: (fileSystem / 'html/anExample2.md') exists; + assert: (fileSystem / 'html/test/anExample3.md') exists; + assert: (fileSystem / 'html/anExample4.java') exists ] { #category : 'tests' } @@ -122,7 +131,12 @@ MicBlogCreatorTest >> testCreateAllHtmlFile [ allFile := (fileSystem / 'html') allFiles. - self assert: allFile size equals: 6 + self assert: allFile size equals: 7; + assert: (fileSystem / 'html/index.html') exists; + assert: (fileSystem / 'html/anExample1.html') exists; + assert: (fileSystem / 'html/anExample2.html') exists; + assert: (fileSystem / 'html/test/anExample3.html') exists; + assert: (fileSystem / 'html/anExample4.java') exists ] { #category : 'tests' } @@ -142,22 +156,25 @@ MicBlogCreatorTest >> testCreateHtmlFileToReplace [ { #category : 'tests' } MicBlogCreatorTest >> testCreateHtmlGroupFileAt [ - | root summarizer allFileParse | + | root summarizer singleSummarizer allFileParse | summarizer := MicSummarizer new. summarizer targetDirectory: 'html'. - - allFileParse := self listOfFile collect: [ :each | - Microdown parse: each asFileReference contents ]. + + singleSummarizer := MicSingleSummarizer new. + + allFileParse := self listOfFile collect: [ :each | singleSummarizer summarizeFile: each ]. root := summarizer group: allFileParse byDate: (Month year: 2019 month: 'January'). root := summarizer summarize: root. - blog - createHtmlGroupFile: root at: (Month year: 2019 month: 'January'). + blog + createHtmlGroupFile: root + at: (Month year: 2019 month: 'January'). - self assert: (fileSystem / 'html/_monthBlog/January 2019.html') exists + self assert: + (fileSystem / 'html/_monthBlog/January 2019.html') exists ] { #category : 'tests' } diff --git a/src/Microdown-Blog-Tests/MicMonthListCreatorTest.class.st b/src/Microdown-Blog-Tests/MicMonthListCreatorTest.class.st index e128ef82..46c5cb1b 100644 --- a/src/Microdown-Blog-Tests/MicMonthListCreatorTest.class.st +++ b/src/Microdown-Blog-Tests/MicMonthListCreatorTest.class.st @@ -32,6 +32,9 @@ MicMonthListCreatorTest >> testGenerateMicListBlockOfLinkDateTo [ self assert: (dateList isKindOf: MicUnorderedListBlock). self - assert: dateList children size - equals: self numberOfMonthSince2014. + assert: dateList children size equals: self numberOfMonthSince2014; + assert: dateList children first children first plainText + equals: '[January 2014](/html/_monthBlog/January 2014)'; + assert: dateList children last children first plainText + equals: '[', Date today month asString ,'](/html/_monthBlog/', Date today month asString ,')' ] diff --git a/src/Microdown-Blog/MicMonthListCreator.class.st b/src/Microdown-Blog/MicMonthListCreator.class.st index 39171aeb..ad5db364 100644 --- a/src/Microdown-Blog/MicMonthListCreator.class.st +++ b/src/Microdown-Blog/MicMonthListCreator.class.st @@ -26,9 +26,7 @@ MicMonthListCreator >> generateMicListBlockOfLinkDateTo: aDestination [ listElement := MicListItemBlock new. link := self makeALink: each asString - to: - aDestination printString , '/' , each year asString , '/' - , each name , '/'. + to: aDestination asString , '/_monthBlog/' , each asString. link parent: listElement. listElement parent: root ]. ^ root diff --git a/src/Microdown-Blog/MicSingleSummarizer.class.st b/src/Microdown-Blog/MicSingleSummarizer.class.st index bef14732..4c360b59 100644 --- a/src/Microdown-Blog/MicSingleSummarizer.class.st +++ b/src/Microdown-Blog/MicSingleSummarizer.class.st @@ -65,23 +65,15 @@ MicSingleSummarizer >> firstParagraphBlockOf: aMicRootBlock [ { #category : 'parsing' } MicSingleSummarizer >> headerLink: aMicRootBlock [ - | headerLink header "date" | + | headerLink header | headerLink := MicHeaderBlock new. header := self firstHeaderBlockOf: aMicRootBlock. - "date := (aMicRootBlock children at: 1) body at: #date. - date := date asDate. - headerLink - addChild: (self - makeALink: header text - to: targetDirectory printString , date year asString , '/' - , date monthName , '/' , date day asString , '/' , header text); - level: header level." headerLink addChild: (self makeALink: header text to: aMicRootBlock fromFile fullName); level: header level. - + ^ headerLink ] From 0796c4039c0c3dea7e82b689c1dd991809ed2a2f Mon Sep 17 00:00:00 2001 From: "quentin.moutte.etu" Date: Tue, 28 May 2024 15:03:36 +0200 Subject: [PATCH 3/4] Fix link of month list --- .../MicBlogCreatorTest.class.st | 31 ++++++++++++------- src/Microdown-Blog/MicBlogCreator.class.st | 13 ++++---- .../MicMonthListCreator.class.st | 4 ++- src/Microdown-Blog/MicSummarizer.class.st | 4 +-- 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/src/Microdown-Blog-Tests/MicBlogCreatorTest.class.st b/src/Microdown-Blog-Tests/MicBlogCreatorTest.class.st index 9ed02499..ee25c106 100644 --- a/src/Microdown-Blog-Tests/MicBlogCreatorTest.class.st +++ b/src/Microdown-Blog-Tests/MicBlogCreatorTest.class.st @@ -139,18 +139,28 @@ MicBlogCreatorTest >> testCreateAllHtmlFile [ assert: (fileSystem / 'html/anExample4.java') exists ] +{ #category : 'tests' } +MicBlogCreatorTest >> testCreateFromTo [ + + | allFile | + MicBlogCreator createFrom: fileSystem / 'source' to: fileSystem / 'html'. + + allFile := (fileSystem / 'html') allFiles. + + self assert: allFile size equals: 7 +] + { #category : 'tests' } MicBlogCreatorTest >> testCreateHtmlFileToReplace [ | root file | - - file := self listOfFile at: 1 . - + file := self listOfFile at: 1. + root := Microdown parse: file contents. - - MicBlogCreator new createHtmlFile: root toReplace: file. - - self assert: file basename equals: 'anExample1.html' + + blog createHtmlFile: root toReplace: file. + + self assert: file basename equals: 'anExample1.html' ] { #category : 'tests' } @@ -204,12 +214,11 @@ MicBlogCreatorTest >> testRenameMarkdownIntoHtmlFile [ MicBlogCreatorTest >> testRootAssembly [ | root file | - file := self listOfFile at: 1. root := Microdown parse: file contents. - - MicBlogCreator new rootAssembly: root. - + + blog rootAssembly: root. + self assert: root children size equals: 5 ] diff --git a/src/Microdown-Blog/MicBlogCreator.class.st b/src/Microdown-Blog/MicBlogCreator.class.st index 0a85853b..85bca62b 100644 --- a/src/Microdown-Blog/MicBlogCreator.class.st +++ b/src/Microdown-Blog/MicBlogCreator.class.st @@ -39,6 +39,8 @@ MicBlogCreator >> collectAllMarkDownFile: aFileReference [ { #category : 'copying' } MicBlogCreator >> copySourceDirectoryInTarget [ + targetDirectory deleteAllChildren. + sourceDirectory copyAllTo: targetDirectory ] @@ -106,13 +108,13 @@ MicBlogCreator >> createHtmlGroupFile: aMicRoot at: aDate [ fileRef := targetDirectory / '_monthBlog'. - self write: a to: fileRef named: aDate asString,'.html' + self write: a to: fileRef named: aDate asString , '.html' ] { #category : 'rendering' } MicBlogCreator >> createHtmlSummarize: aMicRoot [ - | a fileRef | + | a | self rootAssembly: aMicRoot. a := (MicHTMLVisitor new visit: aMicRoot) at: 1. @@ -133,11 +135,10 @@ MicBlogCreator >> renameMarkdownIntoHtmlFile: aFileReference [ { #category : 'as yet unclassified' } MicBlogCreator >> rootAssembly: aMicRoot [ - aMicRoot addChild: (MicMonthListCreator new generateMicListBlockOfLinkDateTo: targetDirectory). + aMicRoot addChild: + (MicMonthListCreator new generateMicListBlockOfLinkDateTo: + targetDirectory fullName). ^ aMicRoot - - - ] { #category : 'accessing' } diff --git a/src/Microdown-Blog/MicMonthListCreator.class.st b/src/Microdown-Blog/MicMonthListCreator.class.st index ad5db364..9b397df9 100644 --- a/src/Microdown-Blog/MicMonthListCreator.class.st +++ b/src/Microdown-Blog/MicMonthListCreator.class.st @@ -26,7 +26,9 @@ MicMonthListCreator >> generateMicListBlockOfLinkDateTo: aDestination [ listElement := MicListItemBlock new. link := self makeALink: each asString - to: aDestination asString , '/_monthBlog/' , each asString. + to: + aDestination asString , '/_monthBlog/' + , each asString. link parent: listElement. listElement parent: root ]. ^ root diff --git a/src/Microdown-Blog/MicSummarizer.class.st b/src/Microdown-Blog/MicSummarizer.class.st index 3722143e..28d35bb0 100644 --- a/src/Microdown-Blog/MicSummarizer.class.st +++ b/src/Microdown-Blog/MicSummarizer.class.st @@ -51,9 +51,7 @@ MicSummarizer >> summarize: aListOfSingleSummarizer [ root := aListOfSingleSummarizer at: each. summarize addChild: (root children at: 2); - addChild: (root children at: 3)]. - - + addChild: (root children at: 3) ]. ^ summarize ] From 0aae53b6eaa2d3ad716dd13e03491c995e56c81c Mon Sep 17 00:00:00 2001 From: "quentin.moutte.etu" Date: Tue, 28 May 2024 16:03:43 +0200 Subject: [PATCH 4/4] creates empty html file for each month without file --- .../MicBlogCreatorTest.class.st | 15 +++++++++++++ src/Microdown-Blog/MicBlogCreator.class.st | 22 ++++++++++++++++--- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/Microdown-Blog-Tests/MicBlogCreatorTest.class.st b/src/Microdown-Blog-Tests/MicBlogCreatorTest.class.st index ee25c106..d53bd540 100644 --- a/src/Microdown-Blog-Tests/MicBlogCreatorTest.class.st +++ b/src/Microdown-Blog-Tests/MicBlogCreatorTest.class.st @@ -150,6 +150,21 @@ MicBlogCreatorTest >> testCreateFromTo [ self assert: allFile size equals: 7 ] +{ #category : 'tests' } +MicBlogCreatorTest >> testCreateHtmlEmptyGroupFileAt [ + +| file | + + blog + createHtmlEmptyGroupFileAt: (Month year: 2019 month: 'January'). + + file := fileSystem / 'html/_monthBlog/January 2019.html'. + + self assert: + file exists; + assert: (file contents findString: 'No files found') = 0 equals: false. +] + { #category : 'tests' } MicBlogCreatorTest >> testCreateHtmlFileToReplace [ diff --git a/src/Microdown-Blog/MicBlogCreator.class.st b/src/Microdown-Blog/MicBlogCreator.class.st index 85bca62b..54c8c047 100644 --- a/src/Microdown-Blog/MicBlogCreator.class.st +++ b/src/Microdown-Blog/MicBlogCreator.class.st @@ -64,8 +64,9 @@ MicBlogCreator >> createAllHtmlFile [ "create summarizer html file" sum := MicSummarizer new. sum targetDirectory: targetDirectory. - - listOfSingleSummarize := allFileParse collect: [ :each | MicSingleSummarizer new summarize: each ]. + + listOfSingleSummarize := allFileParse collect: [ :each | + MicSingleSummarizer new summarize: each ]. self createHtmlSummarize: (sum summarize: listOfSingleSummarize). @@ -78,7 +79,22 @@ MicBlogCreator >> createAllHtmlFile [ summar := sum group: allFileParse byDate: each. summar isNotEmpty ifTrue: [ summar := sum summarize: summar. - self createHtmlGroupFile: summar at: each ] ] + self createHtmlGroupFile: summar at: each ] ifFalse: [ self createHtmlEmptyGroupFileAt: each]] +] + +{ #category : 'rendering' } +MicBlogCreator >> createHtmlEmptyGroupFileAt: aDate [ + + | a fileRef root| + + root := Microdown parse: 'No files found'. + self rootAssembly: root. + + a := (MicHTMLVisitor new visit: root) at: 1. + + fileRef := targetDirectory / '_monthBlog'. + + self write: a to: fileRef named: aDate asString , '.html' ] { #category : 'rendering' }