diff --git a/src/MiniDocs/PubPub.class.st b/src/MiniDocs/PubPub.class.st index 4495372..be60422 100644 --- a/src/MiniDocs/PubPub.class.st +++ b/src/MiniDocs/PubPub.class.st @@ -5,11 +5,25 @@ Class { 'address', 'tableOfContents', 'titles', - 'folder' + 'folder', + 'currentLanguage' ], #category : #'MiniDocs-Model' } +{ #category : #accessing } +PubPub >> addTableOfContents: anOrderedDictionary [ + self tableOfContents + at: (self currentLanguage) put: anOrderedDictionary; + yourself +] + +{ #category : #accessing } +PubPub >> addTitle: aString [ + self titles + at: (self currentLanguage) put: aString +] + { #category : #accessing } PubPub >> address [ ^ address @@ -20,11 +34,39 @@ PubPub >> address: anUrl [ address := anUrl ] +{ #category : #accessing } +PubPub >> currentLanguage [ + ^ currentLanguage +] + +{ #category : #accessing } +PubPub >> currentLanguage: twoLettersInISO639_1 [ + currentLanguage := twoLettersInISO639_1 +] + { #category : #accessing } PubPub >> defaultTitle [ ^ self titles associations first value ] +{ #category : #accessing } +PubPub >> downloadContents [ + | workingDirectory | + workingDirectory := self folder / self currentLanguage / 'book'. + self tableOfContents keysAndValuesDo: [ :name :chapterAddress | + ZnClient new + get: self address, 'pub/', chapterAddress, '/download/markdown'; + downloadTo: workingDirectory . + workingDirectory / 'markdown' renameTo: name, '--', chapterAddress, '.md' + ]. + ^ workingDirectory +] + +{ #category : #accessing } +PubPub >> folder [ + ^ folder ensureCreateDirectory +] + { #category : #accessing } PubPub >> folder: localDirectory [ folder := localDirectory @@ -37,9 +79,10 @@ PubPub >> printOn: aStream [ nextPutAll: '(',self defaultTitle, ' | ', self address, ' )' ] -{ #category : #'as yet unclassified' } +{ #category : #accessing } PubPub >> tableOfContents [ - ^ tableOfContents ifNil: [tableOfContents := Dictionary new] + tableOfContents ifNil: [^ tableOfContents := Dictionary new]. + ^ tableOfContents at: self currentLanguage ] { #category : #accessing }