Skip to content

Commit

Permalink
fix css link in a file in a different folder level
Browse files Browse the repository at this point in the history
  • Loading branch information
quentin.moutte.etu committed Jun 13, 2024
1 parent fa65945 commit bda316a
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 18 deletions.
22 changes: 11 additions & 11 deletions src/Microdown-Blog-Tests/MicBlogCreatorTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ Class {
#package : 'Microdown-Blog-Tests'
}

{ #category : 'as yet unclassified' }
{ #category : 'initialization' }
MicBlogCreatorTest >> fileContent1 [

^ '{
^ '{
"date" : "8 January 2019"
}
# A Cool Story
Expand All @@ -21,11 +21,10 @@ 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!
'

'
]

{ #category : 'as yet unclassified' }
{ #category : 'initialization' }
MicBlogCreatorTest >> fileContent2 [

^ '{
Expand All @@ -41,7 +40,7 @@ Pharo is a pure _object-oriented programming language_ in the tradition of Small

]

{ #category : 'as yet unclassified' }
{ #category : 'initialization' }
MicBlogCreatorTest >> fileContent3 [

^ '{
Expand All @@ -59,7 +58,7 @@ When you participate to the mooc you get access to the quizz and the credit vali
'
]

{ #category : 'as yet unclassified' }
{ #category : 'initialization' }
MicBlogCreatorTest >> generateArchitecture [

| ref1 ref2 ref3 ref4 |
Expand All @@ -81,7 +80,7 @@ MicBlogCreatorTest >> generateArchitecture [
ref4 writeStreamDo: [ :stream | stream nextPutAll: 'Du java' ]
]

{ #category : 'as yet unclassified' }
{ #category : 'initialization' }
MicBlogCreatorTest >> listOfFile [

^ (fileSystem / 'source') allFiles
Expand Down Expand Up @@ -144,16 +143,17 @@ MicBlogCreatorTest >> testCreateAllHtmlFile [
{ #category : 'tests' }
MicBlogCreatorTest >> testCreateFromTo [

| allFile nbMonthFile |
| allFile nbMonthFile nbCSSFile|
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
self assert: allFile size equals: 5 + nbMonthFile + nbCSSFile
]

{ #category : 'tests' }
Expand Down Expand Up @@ -251,7 +251,7 @@ MicBlogCreatorTest >> testWriteToNamed [
root := Microdown parse: file contents.
html := (MicHTMLVisitor new visit: root) at: 1.

MicBlogCreator new
blog
write: html
to: fileSystem / 'html'
named: 'test.html'.
Expand Down
32 changes: 25 additions & 7 deletions src/Microdown-Blog/MicBlogCreator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -172,18 +172,17 @@ MicBlogCreator >> dateList: aDateList [
dateList := aDateList.
]

{ #category : 'as yet unclassified' }
{ #category : 'css' }
MicBlogCreator >> downloadCSS [

| a |
targetDirectory fileSystem / 'css'.
(targetDirectory / 'css') ensureCreateDirectory.
a := MicCSSProvider new.
a
findCssNamed: cssFrameworkName;
destinationPath:
'/Users/qmout/Documents/Pharo/images/Microdown/output/html/css'.
destinationPath: targetDirectory / 'css'.
a cssDownloader downloadCSSFramework:
(MicCSSProvider forCSSNamed: 'Axist')
(MicCSSProvider forCSSNamed: cssFrameworkName)
]

{ #category : 'initialization' }
Expand All @@ -193,6 +192,20 @@ MicBlogCreator >> initialize [
self cssFrameworkName: 'Axist'.
]

{ #category : 'as yet unclassified' }
MicBlogCreator >> levelPathDifferenceForCSS: aStringPath [

| result string |
string := aStringPath copyReplaceAll: '\' with: '/'.

result := ''.

2 to: (string substrings: '/') size do: [ :each |
result := result , '../' ].

^ result
]

{ #category : 'rendering' }
MicBlogCreator >> renameMarkdownIntoHtmlFile: aFileReference [

Expand Down Expand Up @@ -237,15 +250,20 @@ MicBlogCreator >> targetDirectory: arg1 [
{ #category : 'rendering' }
MicBlogCreator >> write: aMicHTMLVisitor to: aPath named: aName [

| htmlDocument fileName|
| htmlDocument fileName cssFramework |
fileName := aName withoutPrefix: '/'.
fileName := fileName withoutPrefix: '\'.

cssFramework := MicCSSProvider forCSSNamed: cssFrameworkName.
cssFramework basePath:
(self levelPathDifferenceForCSS: fileName) , 'css/'.

htmlDocument := MicHTMLDocument new.
htmlDocument configuration: aMicHTMLVisitor configuration.
htmlDocument configuration document: htmlDocument.
htmlDocument
setCharSetUTF8;
addCSSNamed: cssFrameworkName;
addCSS: cssFramework;
destinationPath: aPath.
^ htmlDocument
fileName: fileName;
Expand Down
6 changes: 6 additions & 0 deletions src/Microdown-HTMLExporter/MicCSSEntity.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ MicCSSEntity >> basePath [
ifNil: [ basePath := self defaultBasePath ]
]

{ #category : 'defaults' }
MicCSSEntity >> basePath: anObject [

basePath := anObject
]

{ #category : 'accessing' }
MicCSSEntity >> cssFile [
"Answer the receiver's <MicCSSFile>"
Expand Down

0 comments on commit bda316a

Please sign in to comment.