Documentation: Updating all in a single step, now that we have a lighter document format.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2016-03-26 11:41:03 +00:00
parent 0d1a7fabf0
commit 3e2e38309d

View File

@ -59,6 +59,71 @@ GrafoscopioBrowser class >> configureSettings [
] ]
] ]
{ #category : #updating }
GrafoscopioBrowser class >> docDataManual [
"I define some metadata associated to the manual document.
Language is provided according to the ISO 639-1 code convention."
| docData |
docData := Dictionary
with: 'type' -> 'manual'
with: 'languageCode' -> 'ES_CO'
with: 'remoteRepo' -> 'http://mutabit.com/repos.fossil/grafoscopio/'
with: 'relativePath' -> 'Docs/Es/Manual/'
with: 'filename' -> 'manual-grafoscopio.ston'.
^ docData
]
{ #category : #updating }
GrafoscopioBrowser class >> docDataTutorial [
"I define some metadata associated to the tutorial document.
Language is provided according to the ISO 639-1 code convention."
| docData |
docData := Dictionary
with: 'type' -> 'tutorial'
with: 'languageCode' -> 'ES_CO'
with: 'remoteRepo' -> 'http://mutabit.com/repos.fossil/grafoscopio/'
with: 'relativePath' -> 'Docs/Es/Tutoriales/'
with: 'filename' -> 'tutorial.ston'.
^ docData
]
{ #category : #updating }
GrafoscopioBrowser class >> docDownloadFor: aDocumentType [
"I download the interactive documentation in STON format, according to the document time which can be: 'tutorial' or 'manual'.
If a the documentation is already present in the system I made a temporal backup and download a new copy"
| docInfo client localDoc temporalBackup remoteDoc |
(aDocumentType = 'tutorial') ifTrue: [ docInfo := self docDataTutorial ].
(aDocumentType = 'manual') ifTrue: [ docInfo := self docDataManual ].
localDoc := './', (docInfo at: 'relativePath'), (docInfo at: 'filename').
temporalBackup := './', (docInfo at: 'relativePath'), aDocumentType, '.temp.ston'.
remoteDoc := (self docDataTutorial at: 'remoteRepo'), 'doc/tip/', (self docDataTutorial at: 'relativePath'), (self docDataTutorial at: 'filename').
localDoc asFileReference exists
ifTrue: [
temporalBackup asFileReference exists ifTrue: [ temporalBackup asFileReference delete].
localDoc asFileReference renameTo: aDocumentType, '.temp.ston'
].
[: bar |
bar title: 'Actualizando el ', aDocumentType,'...'.
[client := ZnClient new.
client
get: remoteDoc;
signalProgress: true;
downloadTo: ('./', (docInfo at: 'relativePath')). ]
on: HTTPProgress
do: [ :progress |
progress isEmpty ifFalse: [ bar current: progress percentage ].
progress resume ].
] asJob run.
]
{ #category : #updating } { #category : #updating }
GrafoscopioBrowser class >> downloadTutorial [ GrafoscopioBrowser class >> downloadTutorial [
"I download the interactive tutorial in STON format. "I download the interactive tutorial in STON format.
@ -66,9 +131,9 @@ GrafoscopioBrowser class >> downloadTutorial [
| client localTutorial temporalBackup remoteTutorial | | client localTutorial temporalBackup remoteTutorial |
localTutorial := './', (self tutorialData at: 'relativePath'), (self tutorialData at: 'filename'). localTutorial := './', (self docDataTutorial at: 'relativePath'), (self docDataTutorial at: 'filename').
temporalBackup := './', (self tutorialData at: 'relativePath'), 'tutorial.temp.ston'. temporalBackup := './', (self docDataTutorial at: 'relativePath'), 'tutorial.temp.ston'.
remoteTutorial := (self tutorialData at: 'remoteRepo'), 'doc/tip/', (self tutorialData at: 'relativePath'), (self tutorialData at: 'filename'). remoteTutorial := (self docDataTutorial at: 'remoteRepo'), 'doc/tip/', (self docDataTutorial at: 'relativePath'), (self docDataTutorial at: 'filename').
localTutorial asFileReference exists localTutorial asFileReference exists
ifTrue: [ ifTrue: [
temporalBackup asFileReference exists ifTrue: [ temporalBackup asFileReference delete]. temporalBackup asFileReference exists ifTrue: [ temporalBackup asFileReference delete].
@ -80,7 +145,7 @@ GrafoscopioBrowser class >> downloadTutorial [
client client
get: remoteTutorial; get: remoteTutorial;
signalProgress: true; signalProgress: true;
downloadTo: ('./', (self tutorialData at: 'relativePath')). ] downloadTo: ('./', (self docDataTutorial at: 'relativePath')). ]
on: HTTPProgress on: HTTPProgress
do: [ :progress | do: [ :progress |
progress isEmpty ifFalse: [ bar current: progress percentage ]. progress isEmpty ifFalse: [ bar current: progress percentage ].
@ -106,6 +171,26 @@ GrafoscopioBrowser class >> downloadingFrom: downloadUrl withMessage: aString in
] asJob run. ] asJob run.
] ]
{ #category : #updating }
GrafoscopioBrowser class >> isDocUpdatedFor: aDocumentType [
"I compare the cryptografic signatures of the local copy of aDocumentType and the remote one to see if the're the same,
in which case I return True or False in any other cases.
aDocuaDocumentType is a string that can be 'tutorial' or 'manual' according to the type of document we're querying for.
Now documentation is mainly on Spanish. When support for multiple languages be enabled this method needs revision"
| folderLastContents lastRemoteTutorial localTutorial docInfo |
(aDocumentType = 'tutorial') ifTrue: [ docInfo := self docDataTutorial ].
(aDocumentType = 'manual') ifTrue: [ docInfo := self docDataManual ].
localTutorial := './', (docInfo at: 'relativePath'), (docInfo at: 'filename').
folderLastContents := NeoJSONReader fromString:
(ZnEasy get: (docInfo at: 'remoteRepo'), 'json/dir?ci=tip&name=', (docInfo at: 'relativePath')) contents.
lastRemoteTutorial := ((folderLastContents at: 'payload') at: 'entries')
detect: [:entry | (entry at: 'name') = (docInfo at: 'filename') ].
^ (lastRemoteTutorial at: 'uuid') = (SHA1 new hashMessage: (localTutorial asFileReference contents)) hex
]
{ #category : #'graphical interface' } { #category : #'graphical interface' }
GrafoscopioBrowser class >> messageAbout [ GrafoscopioBrowser class >> messageAbout [
"Shows the author, license, sponsors and main contributors to the project and point to further documentation on the web" "Shows the author, license, sponsors and main contributors to the project and point to further documentation on the web"
@ -265,8 +350,6 @@ GrafoscopioBrowser class >> startDockingBar [
updateMenu updateMenu
add: 'Grafoscopio' target: GrafoscopioBrowser selector: #updateGrafoscopio; add: 'Grafoscopio' target: GrafoscopioBrowser selector: #updateGrafoscopio;
add: 'Paquete DataViz' target: GrafoscopioBrowser selector: #updateDataviz; add: 'Paquete DataViz' target: GrafoscopioBrowser selector: #updateDataviz;
add: 'Complementos' target: GrafoscopioBrowser selector: #updatePrerrequisites;
add: 'Documentación > Tutorial' target: GrafoscopioBrowser selector: #updateTutorial;
add: 'Documentación > Toda' target: GrafoscopioBrowser selector: #updateDocumentation; add: 'Documentación > Toda' target: GrafoscopioBrowser selector: #updateDocumentation;
add: 'Herramientas externas' target: GrafoscopioBrowser selector: #messageNotImplementedYet; add: 'Herramientas externas' target: GrafoscopioBrowser selector: #messageNotImplementedYet;
add: 'Ruta a pandoc' target: ExternalApp selector: #configurePandoc; add: 'Ruta a pandoc' target: ExternalApp selector: #configurePandoc;
@ -292,39 +375,6 @@ GrafoscopioBrowser class >> startDockingBar [
openInWorld. openInWorld.
] ]
{ #category : #updating }
GrafoscopioBrowser class >> tutorialData [
"I define some metadata associated to the tutorial document.
Language is provided according to the ISO 639-1 code convention."
| docData |
docData := Dictionary
with: 'type' -> 'tutorial'
with: 'languageCode' -> 'ES_CO'
with: 'remoteRepo' -> 'http://mutabit.com/repos.fossil/grafoscopio/'
with: 'relativePath' -> 'Docs/Es/Tutoriales/'
with: 'filename' -> 'tutorial.ston'.
^ docData
]
{ #category : #updating }
GrafoscopioBrowser class >> tutorialIsUpdated [
"I compare the cryptografic signatures of the local copy of the tutorial and the remote one to see if the're the same,
in which case I return True or False in any other cases."
| folderLastContents lastRemoteTutorial localTutorial |
localTutorial := './', (GrafoscopioBrowser tutorialData at: 'relativePath'), (GrafoscopioBrowser tutorialData at: 'filename').
folderLastContents := NeoJSONReader fromString:
(ZnEasy get: (self tutorialData at: 'remoteRepo'), 'json/dir?ci=tip&name=', (self tutorialData at: 'relativePath')) contents.
lastRemoteTutorial := ((folderLastContents at: 'payload') at: 'entries')
detect: [:entry | (entry at: 'name') = (self tutorialData at: 'filename') ].
^ (lastRemoteTutorial at: 'uuid') = (SHA1 new hashMessage: (localTutorial asFileReference contents)) hex
]
{ #category : #updating } { #category : #updating }
GrafoscopioBrowser class >> updateDataviz [ GrafoscopioBrowser class >> updateDataviz [
"Updates Dataviz package with new versions of itself take from the source code repository and "Updates Dataviz package with new versions of itself take from the source code repository and
@ -350,41 +400,24 @@ GrafoscopioBrowser class >> updateDataviz [
GrafoscopioBrowser class >> updateDocumentation [ GrafoscopioBrowser class >> updateDocumentation [
"Updates documentation (manual, tutorials) from official repository" "Updates documentation (manual, tutorials) from official repository"
| update filePath fileLocation client docs | | update docs unnecessaryUpdate |
docs := #('tutorial' 'manual').
update := (UIManager default update := (UIManager default
confirm: '¿Desea actualizar la documentación?' confirm: '¿Desea actualizar la documentación?'
label: 'Actualizar documentación'). label: 'Actualizar documentación').
update update
ifTrue: [ ifTrue: [
docs := Dictionary docs do: [ :eachDoc |
with: 'manual' -> ( Dictionary (self isDocUpdatedFor: eachDoc)
with: 'remote' -> 'http://mutabit.com/repos.fossil/grafoscopio/doc/tip/Docs/Es/Manual/manual-grafoscopio.ston' ifFalse: [ self docDownloadFor: eachDoc]
with: 'local' -> './Docs/Es/Manual/' ifTrue: [
) unnecessaryUpdate := UIManager default
with: 'tutorial' -> (Dictionary abort: 'El ', eachDoc,' ya se encuentra en su versión más reciente.'
with: 'remote' -> 'http://mutabit.com/repos.fossil/grafoscopio/doc/tip/Docs/Es/Tutoriales/tutorial.ston' title: 'Nada que actualizar!'
with: 'local' -> './Docs/Es/Tutoriales/' ]
).
UIManager default
displayProgress: 'Actualizando la documentación'
from: 0.0 to: 0.1
during: [
docs do: [:each |
client := ZnClient new.
client get: (each at: 'remote').
client isSuccess
ifFalse: [ self inform: 'Algo salió mal. Verifique su conexión a Internet.' ]
ifTrue: [
filePath := each at: 'local'.
filePath asFileReference ensureCreateDirectory.
fileLocation := filePath, ((each at: 'remote') splitOn: '/') last.
fileLocation asFileReference
writeStreamDo: [:stream |
stream write: client contents utf8Decoded asString].
]].
self inform: 'Actualización de la documentación terminada'.
] ]
]. ]
] ]
{ #category : #updating } { #category : #updating }
@ -540,7 +573,7 @@ GrafoscopioBrowser class >> updateTutorial [
label: 'Actualizar el tutorial'. label: 'Actualizar el tutorial'.
update update
ifTrue: [ ifTrue: [
self tutorialIsUpdated (self isDocUpdatedFor: 'tutorial')
ifFalse: [self downloadTutorial] ifFalse: [self downloadTutorial]
ifTrue: [ ifTrue: [
unnecessaryUpdate := UIManager default unnecessaryUpdate := UIManager default
@ -781,7 +814,7 @@ GrafoscopioBrowser >> exportAsSton: aTree on: locator [
prettyPrint: true; prettyPrint: true;
keepNewLines: true; keepNewLines: true;
nextPut: aTree children]. nextPut: aTree children].
locator nextPutAll: stonPrettyString "(STON toStringPretty: aTree children)" locator nextPutAll: stonPrettyString
] ]
{ #category : #'graphical interface' } { #category : #'graphical interface' }