Syncing to explore development on Moose 6.
This commit is contained in:
parent
47a9e4bf8f
commit
4185ae05bd
@ -29,30 +29,6 @@ Class {
|
|||||||
#category : #'Grafoscopio-UI'
|
#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 }
|
{ #category : #updating }
|
||||||
GrafoscopioBrowser class >> docDataManual [
|
GrafoscopioBrowser class >> docDataManual [
|
||||||
"I define some metadata associated to the manual document.
|
"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'.
|
"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"
|
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 = 'tutorial') ifTrue: [ docInfo := self docDataTutorial ].
|
||||||
(aDocumentType = 'manual') ifTrue: [ docInfo := self docDataManual ].
|
(aDocumentType = 'manual') ifTrue: [ docInfo := self docDataManual ].
|
||||||
localDoc := './', (docInfo at: 'relativePath'), (docInfo at: 'filename').
|
rootFolder := (FileLocator documents asFileReference / 'Grafoscopio').
|
||||||
temporalBackup := './', (docInfo at: 'relativePath'), aDocumentType, '.temp.ston'.
|
rootFolder exists ifFalse: [
|
||||||
remoteDoc := (self docDataTutorial at: 'remoteRepo'), 'doc/tip/', (self docDataTutorial at: 'relativePath'), (self docDataTutorial at: 'filename').
|
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
|
localDoc asFileReference exists
|
||||||
ifTrue: [
|
ifTrue: [
|
||||||
temporalBackup asFileReference exists ifTrue: [ temporalBackup asFileReference delete].
|
temporalBackup asFileReference exists ifTrue: [ temporalBackup asFileReference delete].
|
||||||
@ -109,7 +92,7 @@ GrafoscopioBrowser class >> docDownloadFor: aDocumentType [
|
|||||||
client
|
client
|
||||||
get: remoteDoc;
|
get: remoteDoc;
|
||||||
signalProgress: true;
|
signalProgress: true;
|
||||||
downloadTo: ('./', (docInfo at: 'relativePath')). ]
|
downloadTo: (rootFolder fullName, '/', (docInfo at: 'relativePath')). ]
|
||||||
on: HTTPProgress
|
on: HTTPProgress
|
||||||
do: [ :progress |
|
do: [ :progress |
|
||||||
progress isEmpty ifFalse: [ bar current: progress percentage ].
|
progress isEmpty ifFalse: [ bar current: progress percentage ].
|
||||||
@ -139,19 +122,25 @@ GrafoscopioBrowser class >> downloadingFrom: downloadUrl withMessage: aString in
|
|||||||
GrafoscopioBrowser class >> isDocUpdatedFor: aDocumentType [
|
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,
|
"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.
|
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"
|
Now documentation is mainly on Spanish. When support for multiple languages be enabled this method needs revision"
|
||||||
|
|
||||||
| folderLastContents lastRemoteTutorial localTutorial docInfo |
|
| folderLastContents lastRemoteTutorial localTutorial docInfo |
|
||||||
|
|
||||||
(aDocumentType = 'tutorial') ifTrue: [ docInfo := self docDataTutorial ].
|
(aDocumentType = 'tutorial') ifTrue: [ docInfo := self docDataTutorial ].
|
||||||
(aDocumentType = 'manual') ifTrue: [ docInfo := self docDataManual ].
|
(aDocumentType = 'manual') ifTrue: [ docInfo := self docDataManual ].
|
||||||
localTutorial := './', (docInfo at: 'relativePath'), (docInfo at: 'filename').
|
localTutorial := FileLocator documents / 'Grafoscopio', (docInfo at: 'relativePath'), (docInfo at: 'filename').
|
||||||
|
localTutorial exists
|
||||||
|
ifFalse: [
|
||||||
|
self docDownloadFor: 'tutorial'.
|
||||||
|
^ true.
|
||||||
|
]
|
||||||
|
ifTrue: [
|
||||||
folderLastContents := NeoJSONReader fromString:
|
folderLastContents := NeoJSONReader fromString:
|
||||||
(ZnEasy get: (docInfo at: 'remoteRepo'), 'json/dir?ci=tip&name=', (docInfo at: 'relativePath')) contents.
|
(ZnEasy get: (docInfo at: 'remoteRepo'), 'json/dir?ci=tip&name=', (docInfo at: 'relativePath')) contents.
|
||||||
lastRemoteTutorial := ((folderLastContents at: 'payload') at: 'entries')
|
lastRemoteTutorial := ((folderLastContents at: 'payload') at: 'entries')
|
||||||
detect: [:entry | (entry at: 'name') = (docInfo at: 'filename') ].
|
detect: [:entry | (entry at: 'name') = (docInfo at: 'filename') ].
|
||||||
^ (lastRemoteTutorial at: 'uuid') = (SHA1 new hashMessage: (localTutorial asFileReference contents)) hex
|
^ (lastRemoteTutorial at: 'uuid') = (SHA1 new hashMessage: (localTutorial asFileReference contents)) hex]
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -707,7 +696,7 @@ GrafoscopioBrowser >> exportAsHtml [
|
|||||||
self inform: 'Archivo exportado como html en: ', htmlFileLocation].
|
self inform: 'Archivo exportado como html en: ', htmlFileLocation].
|
||||||
Smalltalk platform name = 'Win32'
|
Smalltalk platform name = 'Win32'
|
||||||
ifTrue: [ OSProcess command: 'pandoc ', markdownFileLocation , ' --standalone -o ' , htmlFileLocation ]]
|
ifTrue: [ OSProcess command: 'pandoc ', markdownFileLocation , ' --standalone -o ' , htmlFileLocation ]]
|
||||||
ifFalse: [GrafoscopioBrowser configureSettings].
|
ifFalse: [ExternalApp pandoc].
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #persistence }
|
{ #category : #persistence }
|
||||||
@ -841,7 +830,7 @@ GrafoscopioBrowser >> open [
|
|||||||
This is changed when the file is saved with the 'Save as' menu option"
|
This is changed when the file is saved with the 'Save as' menu option"
|
||||||
|
|
||||||
"Opens a new browser with a default tree"
|
"Opens a new browser with a default tree"
|
||||||
GrafoscopioBrowser configureSettings.
|
"GrafoscopioBrowser configureSettings."
|
||||||
self openDefault.
|
self openDefault.
|
||||||
|
|
||||||
]
|
]
|
||||||
@ -849,7 +838,7 @@ GrafoscopioBrowser >> open [
|
|||||||
{ #category : #persistence }
|
{ #category : #persistence }
|
||||||
GrafoscopioBrowser >> openDefault [
|
GrafoscopioBrowser >> openDefault [
|
||||||
"Opens a new browser with a default tree"
|
"Opens a new browser with a default tree"
|
||||||
GrafoscopioBrowser configureSettings.
|
"GrafoscopioBrowser configureSettings."
|
||||||
self buildBrowserNamed: 'draft.ston'.
|
self buildBrowserNamed: 'draft.ston'.
|
||||||
mainTree := GrafoscopioNode new.
|
mainTree := GrafoscopioNode new.
|
||||||
mainTree becomeDefaultTree.
|
mainTree becomeDefaultTree.
|
||||||
@ -865,7 +854,7 @@ GrafoscopioBrowser >> openFromFile: aFileName [
|
|||||||
"Opens a tree from a file named aFileName"
|
"Opens a tree from a file named aFileName"
|
||||||
|
|
||||||
| currentChildren |
|
| currentChildren |
|
||||||
GrafoscopioBrowser configureSettings.
|
"GrafoscopioBrowser configureSettings."
|
||||||
|
|
||||||
workingFile := aFileName.
|
workingFile := aFileName.
|
||||||
currentChildren := (STON fromString: aFileName contents).
|
currentChildren := (STON fromString: aFileName contents).
|
||||||
@ -884,7 +873,7 @@ GrafoscopioBrowser >> openFromFileSelector [
|
|||||||
"REFACTORING NOTES: This sould call openFromFile, instead of having the code repeated here.
|
"REFACTORING NOTES: This sould call openFromFile, instead of having the code repeated here.
|
||||||
This creates errors on debugging and worse on proper behaviour"
|
This creates errors on debugging and worse on proper behaviour"
|
||||||
| fileStream currentChildren |
|
| fileStream currentChildren |
|
||||||
GrafoscopioBrowser configureSettings.
|
"GrafoscopioBrowser configureSettings."
|
||||||
fileStream := UITheme builder
|
fileStream := UITheme builder
|
||||||
fileOpen: 'Elija un archivo .ston'
|
fileOpen: 'Elija un archivo .ston'
|
||||||
extensions: #('ston').
|
extensions: #('ston').
|
||||||
@ -915,7 +904,7 @@ GrafoscopioBrowser >> openFromUrl: anUrl [
|
|||||||
client get: anUrl.
|
client get: anUrl.
|
||||||
client isSuccess
|
client isSuccess
|
||||||
ifTrue:[
|
ifTrue:[
|
||||||
GrafoscopioBrowser configureSettings.
|
"GrafoscopioBrowser configureSettings."
|
||||||
fileName := draftsLocation / ((anUrl findTokens: '/') last).
|
fileName := draftsLocation / ((anUrl findTokens: '/') last).
|
||||||
fileName writeStreamDo: [:stream | stream nextPutAll: client contents asString ].
|
fileName writeStreamDo: [:stream | stream nextPutAll: client contents asString ].
|
||||||
self openFromFile: fileName.]
|
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"
|
"This method generates the UI for the openFromUrl: method, it asks for a URL from the user"
|
||||||
|
|
||||||
| fileUrl |
|
| fileUrl |
|
||||||
GrafoscopioBrowser configureSettings.
|
"GrafoscopioBrowser configureSettings."
|
||||||
fileUrl := UIManager default
|
fileUrl := UIManager default
|
||||||
textEntry: 'Ingrese la URL'
|
textEntry: 'Ingrese la URL'
|
||||||
title: 'Nuevo documento desde URL'.
|
title: 'Nuevo documento desde URL'.
|
||||||
@ -940,7 +929,7 @@ GrafoscopioBrowser >> openHelpInGrafoscopio [
|
|||||||
"Opens the help tree from a file"
|
"Opens the help tree from a file"
|
||||||
|
|
||||||
| currentChildren |
|
| currentChildren |
|
||||||
GrafoscopioBrowser configureSettings.
|
"GrafoscopioBrowser configureSettings."
|
||||||
workingFile := (FileSystem disk workingDirectory / 'Docs' / 'Es' / 'Manual' / 'manual-grafoscopio.ston') asFileReference.
|
workingFile := (FileSystem disk workingDirectory / 'Docs' / 'Es' / 'Manual' / 'manual-grafoscopio.ston') asFileReference.
|
||||||
currentChildren := (STON fromString: workingFile contents).
|
currentChildren := (STON fromString: workingFile contents).
|
||||||
self buildBrowserNamed: workingFile basenameWithIndicator.
|
self buildBrowserNamed: workingFile basenameWithIndicator.
|
||||||
@ -956,7 +945,7 @@ GrafoscopioBrowser >> openTutorialInGrafoscopio [
|
|||||||
"Opens the help tree from a file"
|
"Opens the help tree from a file"
|
||||||
|
|
||||||
| currentChildren |
|
| currentChildren |
|
||||||
GrafoscopioBrowser configureSettings.
|
"GrafoscopioBrowser configureSettings."
|
||||||
workingFile := (FileSystem disk workingDirectory / 'Docs' / 'Es' / 'Tutoriales' / 'tutorial.ston') asFileReference.
|
workingFile := (FileSystem disk workingDirectory / 'Docs' / 'Es' / 'Tutoriales' / 'tutorial.ston') asFileReference.
|
||||||
currentChildren := (STON fromString: workingFile contents).
|
currentChildren := (STON fromString: workingFile contents).
|
||||||
self buildBrowserNamed: workingFile basenameWithIndicator.
|
self buildBrowserNamed: workingFile basenameWithIndicator.
|
||||||
|
Loading…
Reference in New Issue
Block a user