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 }
GrafoscopioBrowser class >> downloadTutorial [
"I download the interactive tutorial in STON format.
@ -66,9 +131,9 @@ GrafoscopioBrowser class >> downloadTutorial [
| client localTutorial temporalBackup remoteTutorial |
localTutorial := './', (self tutorialData at: 'relativePath'), (self tutorialData at: 'filename').
temporalBackup := './', (self tutorialData at: 'relativePath'), 'tutorial.temp.ston'.
remoteTutorial := (self tutorialData at: 'remoteRepo'), 'doc/tip/', (self tutorialData at: 'relativePath'), (self tutorialData at: 'filename').
localTutorial := './', (self docDataTutorial at: 'relativePath'), (self docDataTutorial at: 'filename').
temporalBackup := './', (self docDataTutorial at: 'relativePath'), 'tutorial.temp.ston'.
remoteTutorial := (self docDataTutorial at: 'remoteRepo'), 'doc/tip/', (self docDataTutorial at: 'relativePath'), (self docDataTutorial at: 'filename').
localTutorial asFileReference exists
ifTrue: [
temporalBackup asFileReference exists ifTrue: [ temporalBackup asFileReference delete].
@ -80,7 +145,7 @@ GrafoscopioBrowser class >> downloadTutorial [
client
get: remoteTutorial;
signalProgress: true;
downloadTo: ('./', (self tutorialData at: 'relativePath')). ]
downloadTo: ('./', (self docDataTutorial at: 'relativePath')). ]
on: HTTPProgress
do: [ :progress |
progress isEmpty ifFalse: [ bar current: progress percentage ].
@ -106,6 +171,26 @@ GrafoscopioBrowser class >> downloadingFrom: downloadUrl withMessage: aString in
] 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' }
GrafoscopioBrowser class >> messageAbout [
"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
add: 'Grafoscopio' target: GrafoscopioBrowser selector: #updateGrafoscopio;
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: 'Herramientas externas' target: GrafoscopioBrowser selector: #messageNotImplementedYet;
add: 'Ruta a pandoc' target: ExternalApp selector: #configurePandoc;
@ -292,39 +375,6 @@ GrafoscopioBrowser class >> startDockingBar [
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 }
GrafoscopioBrowser class >> updateDataviz [
"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 [
"Updates documentation (manual, tutorials) from official repository"
| update filePath fileLocation client docs |
| update docs unnecessaryUpdate |
docs := #('tutorial' 'manual').
update := (UIManager default
confirm: '¿Desea actualizar la documentación?'
label: 'Actualizar documentación').
update
ifTrue: [
docs := Dictionary
with: 'manual' -> ( Dictionary
with: 'remote' -> 'http://mutabit.com/repos.fossil/grafoscopio/doc/tip/Docs/Es/Manual/manual-grafoscopio.ston'
with: 'local' -> './Docs/Es/Manual/'
)
with: 'tutorial' -> (Dictionary
with: 'remote' -> 'http://mutabit.com/repos.fossil/grafoscopio/doc/tip/Docs/Es/Tutoriales/tutorial.ston'
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.' ]
docs do: [ :eachDoc |
(self isDocUpdatedFor: eachDoc)
ifFalse: [ self docDownloadFor: eachDoc]
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'.
unnecessaryUpdate := UIManager default
abort: 'El ', eachDoc,' ya se encuentra en su versión más reciente.'
title: 'Nada que actualizar!'
]
]
].
]
]
{ #category : #updating }
@ -540,7 +573,7 @@ GrafoscopioBrowser class >> updateTutorial [
label: 'Actualizar el tutorial'.
update
ifTrue: [
self tutorialIsUpdated
(self isDocUpdatedFor: 'tutorial')
ifFalse: [self downloadTutorial]
ifTrue: [
unnecessaryUpdate := UIManager default
@ -781,7 +814,7 @@ GrafoscopioBrowser >> exportAsSton: aTree on: locator [
prettyPrint: true;
keepNewLines: true;
nextPut: aTree children].
locator nextPutAll: stonPrettyString "(STON toStringPretty: aTree children)"
locator nextPutAll: stonPrettyString
]
{ #category : #'graphical interface' }