PubPub downloading books by language.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2023-05-16 09:37:40 -05:00
parent 745e9d8e6e
commit baba99ec84

View File

@ -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 }