Syncing to explore development on Moose 6.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2016-04-10 11:27:09 +00:00 committed by SantiagoBragagnolo
parent f2ccfd15cc
commit b7cb437ac0
1 changed files with 34 additions and 45 deletions

View File

@ -29,30 +29,6 @@ Class {
#category : #'Grafoscopio-UI'
}
{ #category : #configuration }
GrafoscopioBrowser class >> configureSettings [
"I stablish several 'global' settings according to to image location and the operative system.
For the moment we're gonna use hardcoded paths, but in the future this will be a smarter method finding
the proper external tool and setting up it."
draftsLocation := FileSystem disk workingDirectory / 'Grafoscopio' / 'Drafts'.
draftsLocation ensureCreateDirectory.
Smalltalk platform name = 'unix'
ifTrue: [
fossil := (FileSystem disk workingDirectory parent / 'Platform' / 'Linux' / 'Programs' / 'Fossil'/ 'fossil') fullName.
pandoc := (FileSystem disk workingDirectory parent / 'Platform' / 'Linux' / 'Programs' / 'Pandoc' / 'pandoc') fullName].
Smalltalk platform name = 'Win32'
ifTrue: [
fossil := (FileSystem disk workingDirectory / 'Platform' / 'Windows' / 'Programs' / 'Fossil' / 'fossil.exe') fullName.
pandoc := (FileSystem disk workingDirectory / 'Platform' / 'Windows' / 'Programs' / 'Pandoc' / 'pandoc.exe') fullName].
Smalltalk platform name = 'Mac OS'
ifTrue: [
fossil := ((FileLocator desktop) asFileReference / 'fossil') fullName.
pandoc := (FileSystem disk / 'usr' / 'local' / 'bin' / 'pandoc') fullName.
]
]
{ #category : #updating }
GrafoscopioBrowser class >> docDataManual [
"I define some metadata associated to the manual document.
@ -91,13 +67,20 @@ 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 |
| docInfo client rootFolder 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').
rootFolder := (FileLocator documents asFileReference / 'Grafoscopio').
rootFolder exists ifFalse: [
rootFolder ensureCreateDirectory.
OSProcess command: ('exec mkdir -p ', rootFolder fullName, '/', (docInfo at: 'relativePath'))
].
localDoc := rootFolder fullName, '/', (docInfo at: 'relativePath'), (docInfo at: 'filename').
temporalBackup := rootFolder fullName, '/', (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].
@ -109,7 +92,7 @@ GrafoscopioBrowser class >> docDownloadFor: aDocumentType [
client
get: remoteDoc;
signalProgress: true;
downloadTo: ('./', (docInfo at: 'relativePath')). ]
downloadTo: (rootFolder fullName, '/', (docInfo at: 'relativePath')). ]
on: HTTPProgress
do: [ :progress |
progress isEmpty ifFalse: [ bar current: progress percentage ].
@ -139,19 +122,25 @@ GrafoscopioBrowser class >> downloadingFrom: downloadUrl withMessage: aString in
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.
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 := './', (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
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]
]
@ -707,7 +696,7 @@ GrafoscopioBrowser >> exportAsHtml [
self inform: 'Archivo exportado como html en: ', htmlFileLocation].
Smalltalk platform name = 'Win32'
ifTrue: [ OSProcess command: 'pandoc ', markdownFileLocation , ' --standalone -o ' , htmlFileLocation ]]
ifFalse: [GrafoscopioBrowser configureSettings].
ifFalse: [ExternalApp pandoc].
]
{ #category : #persistence }
@ -841,7 +830,7 @@ GrafoscopioBrowser >> open [
This is changed when the file is saved with the 'Save as' menu option"
"Opens a new browser with a default tree"
GrafoscopioBrowser configureSettings.
"GrafoscopioBrowser configureSettings."
self openDefault.
]
@ -849,7 +838,7 @@ GrafoscopioBrowser >> open [
{ #category : #persistence }
GrafoscopioBrowser >> openDefault [
"Opens a new browser with a default tree"
GrafoscopioBrowser configureSettings.
"GrafoscopioBrowser configureSettings."
self buildBrowserNamed: 'draft.ston'.
mainTree := GrafoscopioNode new.
mainTree becomeDefaultTree.
@ -865,7 +854,7 @@ GrafoscopioBrowser >> openFromFile: aFileName [
"Opens a tree from a file named aFileName"
| currentChildren |
GrafoscopioBrowser configureSettings.
"GrafoscopioBrowser configureSettings."
workingFile := aFileName.
currentChildren := (STON fromString: aFileName contents).
@ -884,7 +873,7 @@ GrafoscopioBrowser >> openFromFileSelector [
"REFACTORING NOTES: This sould call openFromFile, instead of having the code repeated here.
This creates errors on debugging and worse on proper behaviour"
| fileStream currentChildren |
GrafoscopioBrowser configureSettings.
"GrafoscopioBrowser configureSettings."
fileStream := UITheme builder
fileOpen: 'Elija un archivo .ston'
extensions: #('ston').
@ -915,7 +904,7 @@ GrafoscopioBrowser >> openFromUrl: anUrl [
client get: anUrl.
client isSuccess
ifTrue:[
GrafoscopioBrowser configureSettings.
"GrafoscopioBrowser configureSettings."
fileName := draftsLocation / ((anUrl findTokens: '/') last).
fileName writeStreamDo: [:stream | stream nextPutAll: client contents asString ].
self openFromFile: fileName.]
@ -927,7 +916,7 @@ GrafoscopioBrowser >> openFromUrlUI [
"This method generates the UI for the openFromUrl: method, it asks for a URL from the user"
| fileUrl |
GrafoscopioBrowser configureSettings.
"GrafoscopioBrowser configureSettings."
fileUrl := UIManager default
textEntry: 'Ingrese la URL'
title: 'Nuevo documento desde URL'.
@ -940,7 +929,7 @@ GrafoscopioBrowser >> openHelpInGrafoscopio [
"Opens the help tree from a file"
| currentChildren |
GrafoscopioBrowser configureSettings.
"GrafoscopioBrowser configureSettings."
workingFile := (FileSystem disk workingDirectory / 'Docs' / 'Es' / 'Manual' / 'manual-grafoscopio.ston') asFileReference.
currentChildren := (STON fromString: workingFile contents).
self buildBrowserNamed: workingFile basenameWithIndicator.
@ -956,7 +945,7 @@ GrafoscopioBrowser >> openTutorialInGrafoscopio [
"Opens the help tree from a file"
| currentChildren |
GrafoscopioBrowser configureSettings.
"GrafoscopioBrowser configureSettings."
workingFile := (FileSystem disk workingDirectory / 'Docs' / 'Es' / 'Tutoriales' / 'tutorial.ston') asFileReference.
currentChildren := (STON fromString: workingFile contents).
self buildBrowserNamed: workingFile basenameWithIndicator.