New methods for updating documentation.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2016-10-09 15:55:20 +00:00
parent c298317620
commit ca68729708
2 changed files with 29 additions and 26 deletions

View File

@ -22,12 +22,30 @@ GrafoscopioDocumentation class >> current [
| gfcDocumentation |
gfcDocumentation := self new.
gfcDocumentation repository: (FossilRepo new url: 'http://mutabit.com/repos.fossil/grafoscopio').
gfcDocumentation documents add: 'Docs/Es/Tutoriales/tutorial.ston'.
gfcDocumentation documents
add: 'Docs/Es/Tutoriales/tutorial.ston';
add: 'Docs/Es/Manual/manual-grafoscopio.ston';
add: 'Docs/En/dev-notes.ston'.
gfcDocumentation localPlace.
^ gfcDocumentation
]
{ #category : #updating }
GrafoscopioDocumentation class >> download: fileNameWithRelativePath [
| fileName relativePathFolders newPath parentFolder |
fileName := (fileNameWithRelativePath splitOn: $/) last.
relativePathFolders := (fileNameWithRelativePath splitOn: $/) allButLast.
newPath := self current localPlace path.
relativePathFolders do: [ :folder | newPath := newPath / folder ].
parentFolder := newPath asFileReference.
parentFolder exists ifFalse: [ parentFolder ensureCreateDirectory ].
GrafoscopioGUI
downloadingFrom: self current repository url asString, '/doc/tip/', fileNameWithRelativePath
withMessage: 'Downloading ', fileName
into: parentFolder
]
{ #category : #updating }
GrafoscopioDocumentation class >> isUpdated [
^ (self listOutdated size > 0) ifTrue: [ ^ false ] ifFalse: [ ^ true ]
@ -50,6 +68,16 @@ GrafoscopioDocumentation class >> listOutdated [
^ self current documents select: [ :doc | (self isUpdatedFor: doc) = false ]
]
{ #category : #updating }
GrafoscopioDocumentation class >> update [
self isUpdated
ifTrue: [ self inform: 'All documents are already updated' ]
ifFalse: [
self listOutdated do: [ :eachDoc | self download: eachDoc ].
self inform: 'Documentation updating finished']
]
{ #category : #accessing }
GrafoscopioDocumentation >> documents [
^ documents ifNil: [ documents := OrderedCollection new ]

View File

@ -301,31 +301,6 @@ GrafoscopioGUI class >> initialize [
self startDockingBar.
]
{ #category : #updating }
GrafoscopioGUI 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.
aDocumentType 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 := FileLocator documents / 'Grafoscopio', (docInfo at: 'relativePath'), (docInfo at: 'filename').
localTutorial exists
ifFalse: [
self docDownloadFor: 'tutorial'.
^ true.
]
ifTrue: [
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' }
GrafoscopioGUI class >> messageAbout [
"Shows the author, license, sponsors and main contributors to the project and point to further documentation on the web"