Implementing openFromUrl for an easier work with web published documents.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2015-03-29 17:48:20 +00:00 committed by SantiagoBragagnolo
parent b78f33abff
commit ab56aa07c6
1 changed files with 23 additions and 4 deletions

View File

@ -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"