diff --git a/repository/Grafoscopio-Utils/GrafoscopioUtils.class.st b/repository/Grafoscopio-Utils/GrafoscopioUtils.class.st index f108f3d..2c2a564 100644 --- a/repository/Grafoscopio-Utils/GrafoscopioUtils.class.st +++ b/repository/Grafoscopio-Utils/GrafoscopioUtils.class.st @@ -58,6 +58,13 @@ GrafoscopioUtils class >> ensureCreateDirectory: fileNameWithRelativePath into: ] +{ #category : #persistence } +GrafoscopioUtils class >> exportAsSton: anObject on: aFileReference [ + "comment stating purpose of message" + + +] + { #category : #'graphical interface' } GrafoscopioUtils class >> getContentsFrom: url withMessage: aString [ | client | diff --git a/repository/Grafoscopio-Utils/PandocWork.class.st b/repository/Grafoscopio-Utils/PandocWork.class.st index 5ec9021..6a37068 100644 --- a/repository/Grafoscopio-Utils/PandocWork.class.st +++ b/repository/Grafoscopio-Utils/PandocWork.class.st @@ -20,26 +20,17 @@ Class { 'contents', 'metadataFiles', 'rootFolder', - 'manifest' + 'manifests' ], #category : #'Grafoscopio-Utils' } -{ #category : #utilities } -PandocWork >> buildManifest [ - "I create a manifest, that lists all the files which are needed to create a - derivate file (PDF, EPUB, etc) with their checksums and folder locations. - - I can be used to associated derivated files with their sources." - | checksums | - checksums := OrderedDictionary new. - self contents keysDo: [ :folder | - (self contents at: folder) do: [ :fileName | | keyName contentFile | - keyName := fileName, self defaultFileExtension. - contentFile := self rootFolder / self language / folder / keyName. - checksums at: keyName put: (GrafoscopioUtils checksumFor: contentFile)]. - self manifest at: folder put: checksums ]. - +{ #category : #utlity } +PandocWork >> buildManifestForLanguage: anISOCode [ + self + metadataManifestForLanguage: anISOCode; + contentsManifestForLanguage: anISOCode. + ^ self manifests ] { #category : #accessing } @@ -56,6 +47,35 @@ PandocWork >> contents: anOrderedDictionary [ contents := anOrderedDictionary ] +{ #category : #utilities } +PandocWork >> contentsManifest [ + + | checksums | + checksums := OrderedDictionary new. + self contents keysDo: [ :folder | + (self contents at: folder) do: [ :fileName | | keyName contentFile | + keyName := fileName, self defaultFileExtension. + contentFile := self rootFolder / self language / folder / keyName. + checksums at: keyName put: (GrafoscopioUtils checksumFor: contentFile)]. + self manifest at: folder put: checksums ]. + ^ self manifest +] + +{ #category : #utilities } +PandocWork >> contentsManifestForLanguage: anISOCode [ + + | checksums | + checksums := OrderedDictionary new. + self contents keysDo: [ :folder | + (self contents at: folder) do: [ :fileName | | keyName contentFile | + keyName := fileName, self defaultFileExtension. + contentFile := self rootFolder / anISOCode / folder / keyName. + checksums at: keyName put: (GrafoscopioUtils checksumFor: contentFile)]. + (self manifestForLanguage: anISOCode) + add: {folder -> checksums} asOrderedDictionary ]. + ^ self manifests at: anISOCode +] + { #category : #utilities } PandocWork >> defaultFileExtension [ ^ '.md' @@ -77,18 +97,23 @@ PandocWork >> language: aISOLangString [ language := aISOLangString ] -{ #category : #accessing } -PandocWork >> manifest [ - "I create a manifest, that lists all the files which are needed to create a - derivate file (PDF, EPUB, etc) with their checksums and folder locations. - - I can be used to associated derivated files with their sources." - ^ manifest ifNil: [ ^ manifest := OrderedDictionary new ] +{ #category : #utlity } +PandocWork >> manifestForLanguage: anISOCode [ + self manifests at: anISOCode ifAbsent: [ + self manifests + at: anISOCode put: OrderedCollection new; + yourself]. + ^ self manifests at: anISOCode ] { #category : #accessing } -PandocWork >> manifest: anOrderedDictionary [ - manifest := anOrderedDictionary +PandocWork >> manifests [ + ^ manifests ifNil: [ ^ manifests := OrderedDictionary new ] +] + +{ #category : #accessing } +PandocWork >> manifests: anOrderedDictionary [ + manifests := anOrderedDictionary ] { #category : #accessing } @@ -106,6 +131,30 @@ PandocWork >> metadataFiles: aCollection [ metadataFiles := aCollection ] +{ #category : #utilities } +PandocWork >> metadataManifest [ + + | languageFolder | + languageFolder := self language. + "Could the similar parts of this and contentsManifest be refactored?" + self metadataFiles do: [ :fileName | | contentFile | + contentFile := self rootFolder / languageFolder / fileName. + self manifest at: languageFolder put: {fileName -> (GrafoscopioUtils checksumFor: contentFile)} asOrderedDictionary ]. + ^ self manifest +] + +{ #category : #utilities } +PandocWork >> metadataManifestForLanguage: anISOCode [ + "anISOCode is the ISO 639-1 two letters language code" + + "Could the similar parts of this and contentsManifest be refactored?" + self metadataFiles do: [ :fileName | | contentFile | + contentFile := self rootFolder / anISOCode / fileName. + (self manifestForLanguage: anISOCode) + add: {fileName -> (GrafoscopioUtils checksumFor: contentFile)} asOrderedDictionary]. + ^ self manifests at: anISOCode +] + { #category : #accessing } PandocWork >> rootFolder [ ^ rootFolder