diff --git a/src/Microdown-Blog-Tests/MicBlogCreatorTest.class.st b/src/Microdown-Blog-Tests/MicBlogCreatorTest.class.st index eb867069..e8d90817 100644 --- a/src/Microdown-Blog-Tests/MicBlogCreatorTest.class.st +++ b/src/Microdown-Blog-Tests/MicBlogCreatorTest.class.st @@ -164,7 +164,7 @@ MicBlogCreatorTest >> testCreateHtmlEmptyGroupFileAt [ blog createHtmlEmptyGroupFileAt: (Month year: 2019 month: 'January'). - file := fileSystem / 'html/_monthBlog/January 2019.html'. + file := fileSystem / 'html/_monthBlog/January_2019.html'. self assert: file exists; @@ -205,7 +205,7 @@ MicBlogCreatorTest >> testCreateHtmlGroupFileAt [ at: (Month year: 2019 month: 'January'). self assert: - (fileSystem / 'html/_monthBlog/January 2019.html') exists + (fileSystem / 'html/_monthBlog/January_2019.html') exists ] { #category : 'tests' } @@ -246,13 +246,15 @@ MicBlogCreatorTest >> testRootAssembly [ { #category : 'tests' } MicBlogCreatorTest >> testWriteToNamed [ - | root file html| - + | root file html | file := self listOfFile at: 1. root := Microdown parse: file contents. html := (MicHTMLVisitor new visit: root) at: 1. - - MicBlogCreator new write: html to: fileSystem / 'html' named: 'test.html'. - + + MicBlogCreator new + write: html + to: fileSystem / 'html' + named: 'test.html'. + self assert: (fileSystem / 'html/test.html') exists ] diff --git a/src/Microdown-Blog-Tests/MicMonthListCreatorTest.class.st b/src/Microdown-Blog-Tests/MicMonthListCreatorTest.class.st index 46c5cb1b..995bff7b 100644 --- a/src/Microdown-Blog-Tests/MicMonthListCreatorTest.class.st +++ b/src/Microdown-Blog-Tests/MicMonthListCreatorTest.class.st @@ -26,15 +26,20 @@ MicMonthListCreatorTest >> testGenerateDateListSince2014 [ { #category : 'tests' } MicMonthListCreatorTest >> testGenerateMicListBlockOfLinkDateTo [ - | dateList | + | dateList fileSystem | + fileSystem := FileSystem memory. + fileSystem createDirectory: '/html'. + dateList := MicMonthListCreator new - generateMicListBlockOfLinkDateTo: '/html'. + 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)'; + 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 asString ,')' + 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 62d4692b..977851b3 100644 --- a/src/Microdown-Blog/MicBlogCreator.class.st +++ b/src/Microdown-Blog/MicBlogCreator.class.st @@ -23,9 +23,13 @@ Class { MicBlogCreator class >> createFrom: source to: target [ | tmp1 | + (source fileSystem store isKindOf: WindowsStore) ifTrue: [ + source fileSystem store currentDisk ]. + (target fileSystem store isKindOf: WindowsStore) ifTrue: [ + target fileSystem store currentDisk ]. tmp1 := self new. tmp1 - sourceDirectory: source; + sourceDirectory: source; targetDirectory: target. tmp1 createAllHtmlFile ] @@ -49,9 +53,8 @@ MicBlogCreator >> copySourceDirectoryInTarget [ MicBlogCreator >> createAllHtmlFile [ | allFile allFileParse sum summar listOfSingleSummarize | - - dateList := MicMonthListCreator new generateMicListBlockOfLinkDateTo: - targetDirectory fullName. + dateList := MicMonthListCreator new + generateMicListBlockOfLinkDateTo: targetDirectory. "Copy the source directory in the target directory" self copySourceDirectoryInTarget. @@ -80,7 +83,7 @@ MicBlogCreator >> createAllHtmlFile [ targetDirectory fullName , '/_monthBlog'. MicMonthListCreator new generateDateListSince2014 do: [ :each | - summar := sum group: allFileParse byDate: each. + summar := sum group: listOfSingleSummarize byDate: each. summar isNotEmpty ifTrue: [ summar := sum summarize: summar. @@ -89,10 +92,9 @@ MicBlogCreator >> createAllHtmlFile [ ] { #category : 'rendering' } -MicBlogCreator >> createHtmlEmptyGroupFileAt: aDate [ +MicBlogCreator >> createHtmlEmptyGroupFileAt: aMonth [ - | a fileRef root| - + | a fileRef root | root := Microdown parse: 'No files found'. self rootAssembly: root. @@ -100,7 +102,7 @@ MicBlogCreator >> createHtmlEmptyGroupFileAt: aDate [ fileRef := targetDirectory / '_monthBlog'. - self write: a to: fileRef named: aDate asString , '.html' + self write: a to: fileRef named: aMonth name , '_' , aMonth year asString , '.html' ] { #category : 'rendering' } @@ -121,7 +123,7 @@ MicBlogCreator >> createHtmlFile: aMicRoot toReplace: aFileReference [ ] { #category : 'rendering' } -MicBlogCreator >> createHtmlGroupFile: aMicRoot at: aDate [ +MicBlogCreator >> createHtmlGroupFile: aMicRoot at: aMonth [ | a fileRef | self rootAssembly: aMicRoot. @@ -130,7 +132,10 @@ MicBlogCreator >> createHtmlGroupFile: aMicRoot at: aDate [ fileRef := targetDirectory / '_monthBlog'. - self write: a to: fileRef named: aDate asString , '.html' + self + write: a + to: fileRef + named: aMonth name , '_' , aMonth year asString , '.html' ] { #category : 'rendering' } diff --git a/src/Microdown-Blog/MicMonthListCreator.class.st b/src/Microdown-Blog/MicMonthListCreator.class.st index 9b397df9..385fdde9 100644 --- a/src/Microdown-Blog/MicMonthListCreator.class.st +++ b/src/Microdown-Blog/MicMonthListCreator.class.st @@ -1,3 +1,6 @@ +" +Create a list of date since january 2014 +" Class { #name : 'MicMonthListCreator', #superclass : 'MicAbstractBlogCreator', @@ -17,18 +20,22 @@ MicMonthListCreator >> generateDateListSince2014 [ ] { #category : 'generate' } -MicMonthListCreator >> generateMicListBlockOfLinkDateTo: aDestination [ +MicMonthListCreator >> generateMicListBlockOfLinkDateTo: aFileReference [ - | root link listElement | + | root link listElement disk | root := MicUnorderedListBlock new. + (aFileReference fileSystem store isKindOf: WindowsStore) ifTrue: [ + disk := 'File:///', aFileReference fileSystem store currentDisk ]. + disk ifNil: [ disk := '' ]. + self generateDateListSince2014 do: [ :each | listElement := MicListItemBlock new. link := self makeALink: each asString to: - aDestination asString , '/_monthBlog/' - , each asString. + disk , aFileReference fullPath pathString , '/_monthBlog/' + , each name , '_' , each year asString , '.html'. link parent: listElement. listElement parent: root ]. ^ root diff --git a/src/Microdown-Blog/MicSingleSummarizer.class.st b/src/Microdown-Blog/MicSingleSummarizer.class.st index 4c360b59..6abaaca5 100644 --- a/src/Microdown-Blog/MicSingleSummarizer.class.st +++ b/src/Microdown-Blog/MicSingleSummarizer.class.st @@ -65,13 +65,17 @@ MicSingleSummarizer >> firstParagraphBlockOf: aMicRootBlock [ { #category : 'parsing' } MicSingleSummarizer >> headerLink: aMicRootBlock [ - | headerLink header | + | headerLink header disk | headerLink := MicHeaderBlock new. header := self firstHeaderBlockOf: aMicRootBlock. + + (aMicRootBlock fromFile fileSystem store isKindOf: WindowsStore) ifTrue: [ + disk := 'File:///' , aMicRootBlock fromFile fileSystem store currentDisk ]. + disk ifNil: [ disk := '' ]. headerLink addChild: - (self makeALink: header text to: aMicRootBlock fromFile fullName); + (self makeALink: header text to: disk, aMicRootBlock fromFile fullName); level: header level. ^ headerLink diff --git a/src/Microdown-Blog/MicSummarizer.class.st b/src/Microdown-Blog/MicSummarizer.class.st index 28d35bb0..426f9511 100644 --- a/src/Microdown-Blog/MicSummarizer.class.st +++ b/src/Microdown-Blog/MicSummarizer.class.st @@ -39,13 +39,10 @@ MicSummarizer >> maximumFile: aNumber [ { #category : 'as yet unclassified' } MicSummarizer >> summarize: aListOfSingleSummarizer [ - | summarize root singleSummarizer selectionSize | + | summarize root selectionSize | summarize := MicRootBlock new. - singleSummarizer := MicSingleSummarizer new. - singleSummarizer targetDirectory: targetDirectory. - - selectionSize := maximumFile min: aListOfSingleSummarizer size. + selectionSize := maximumFile min: aListOfSingleSummarizer size. 1 to: selectionSize do: [ :each | root := aListOfSingleSummarizer at: each.