Implementing openFromUrl for an easier work with web published documents.
This commit is contained in:
parent
bc3cc05b78
commit
0817d2d484
@ -27,6 +27,7 @@ Class {
|
||||
#classVars : [
|
||||
'DefaultUbakyeBrowser',
|
||||
'dockingBar',
|
||||
'draftsLocation',
|
||||
'fossil',
|
||||
'pandoc',
|
||||
'recentTrees'
|
||||
@ -59,7 +60,10 @@ GrafoscopioBrowser class >> configurePandoc [
|
||||
|
||||
{ #category : #'as yet unclassified' }
|
||||
GrafoscopioBrowser class >> configureSettings [
|
||||
"Stablish several 'global' settings according to the operative system"
|
||||
"Stablish several 'global' settings according to to image location and the operative system"
|
||||
|
||||
draftsLocation := FileSystem disk workingDirectory / 'Grafoscopio' / 'Drafts'.
|
||||
draftsLocation ensureCreateDirectory.
|
||||
|
||||
Smalltalk platform name = 'unix'
|
||||
ifTrue: [
|
||||
@ -811,12 +815,10 @@ GrafoscopioBrowser >> messageNotImplementedYet [
|
||||
GrafoscopioBrowser >> open [
|
||||
"Opens a new browser with a default tree and assigns a default draft file for storing it.
|
||||
This is changed when the file is saved with the 'Save as' menu option"
|
||||
| draftsLocation |
|
||||
|
||||
"self configureSettings."
|
||||
mainTree := GrafoscopioNode new.
|
||||
mainTree becomeDefaultTree.
|
||||
draftsLocation := FileSystem disk workingDirectory / 'Grafoscopio' / 'Drafts'.
|
||||
draftsLocation ensureCreateDirectory.
|
||||
workingFile := draftsLocation / 'draft.ston'.
|
||||
self buildBrowserNamed: workingFile basenameWithIndicator.
|
||||
browser openOn: mainTree children.
|
||||
@ -893,6 +895,23 @@ GrafoscopioBrowser >> openFromFileSelector [
|
||||
browser openOn: mainTree children.
|
||||
]
|
||||
|
||||
{ #category : #persistence }
|
||||
GrafoscopioBrowser >> openFromUrl: anUrl [
|
||||
"Opens a tree from a file named aFileName"
|
||||
|
||||
| client fileName |
|
||||
|
||||
client := ZnClient new.
|
||||
client get: anUrl.
|
||||
client isSuccess
|
||||
ifTrue:[
|
||||
GrafoscopioBrowser configureSettings.
|
||||
fileName := draftsLocation / ((anUrl findTokens: '/') last).
|
||||
fileName writeStreamDo: [:stream | stream nextPutAll: client contents asString ].
|
||||
self openFromFile: fileName.]
|
||||
ifFalse: [self inform: 'Algo salió mal. Verifique su conexión a Internet y que el contenido buscado estén disponibles' ]
|
||||
]
|
||||
|
||||
{ #category : #persistence }
|
||||
GrafoscopioBrowser >> openHelpInGrafoscopio [
|
||||
"Opens the help tree from a file"
|
||||
|
Loading…
Reference in New Issue
Block a user