Skip to content

Commit

Permalink
Merge pull request #758 from moufort/blog
Browse files Browse the repository at this point in the history
fix navigation and link of summary
  • Loading branch information
Ducasse authored May 31, 2024
2 parents 081050d + f0e38d0 commit 350fe55
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 33 deletions.
16 changes: 9 additions & 7 deletions src/Microdown-Blog-Tests/MicBlogCreatorTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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' }
Expand Down Expand Up @@ -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
]
13 changes: 9 additions & 4 deletions src/Microdown-Blog-Tests/MicMonthListCreatorTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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)'
]
27 changes: 16 additions & 11 deletions src/Microdown-Blog/MicBlogCreator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
Expand All @@ -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.

Expand Down Expand Up @@ -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.
Expand All @@ -89,18 +92,17 @@ 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.

a := (MicHTMLVisitor new visit: root) at: 1.

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' }
Expand All @@ -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.
Expand All @@ -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' }
Expand Down
15 changes: 11 additions & 4 deletions src/Microdown-Blog/MicMonthListCreator.class.st
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"
Create a list of date since january 2014
"
Class {
#name : 'MicMonthListCreator',
#superclass : 'MicAbstractBlogCreator',
Expand All @@ -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
Expand Down
8 changes: 6 additions & 2 deletions src/Microdown-Blog/MicSingleSummarizer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 2 additions & 5 deletions src/Microdown-Blog/MicSummarizer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 350fe55

Please sign in to comment.