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
parent bc3cc05b78
commit 0817d2d484

View File

@ -27,6 +27,7 @@ Class {
#classVars : [ #classVars : [
'DefaultUbakyeBrowser', 'DefaultUbakyeBrowser',
'dockingBar', 'dockingBar',
'draftsLocation',
'fossil', 'fossil',
'pandoc', 'pandoc',
'recentTrees' 'recentTrees'
@ -59,7 +60,10 @@ GrafoscopioBrowser class >> configurePandoc [
{ #category : #'as yet unclassified' } { #category : #'as yet unclassified' }
GrafoscopioBrowser class >> configureSettings [ 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' Smalltalk platform name = 'unix'
ifTrue: [ ifTrue: [
@ -811,12 +815,10 @@ GrafoscopioBrowser >> messageNotImplementedYet [
GrafoscopioBrowser >> open [ GrafoscopioBrowser >> open [
"Opens a new browser with a default tree and assigns a default draft file for storing it. "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" This is changed when the file is saved with the 'Save as' menu option"
| draftsLocation |
"self configureSettings." "self configureSettings."
mainTree := GrafoscopioNode new. mainTree := GrafoscopioNode new.
mainTree becomeDefaultTree. mainTree becomeDefaultTree.
draftsLocation := FileSystem disk workingDirectory / 'Grafoscopio' / 'Drafts'.
draftsLocation ensureCreateDirectory.
workingFile := draftsLocation / 'draft.ston'. workingFile := draftsLocation / 'draft.ston'.
self buildBrowserNamed: workingFile basenameWithIndicator. self buildBrowserNamed: workingFile basenameWithIndicator.
browser openOn: mainTree children. browser openOn: mainTree children.
@ -893,6 +895,23 @@ GrafoscopioBrowser >> openFromFileSelector [
browser openOn: mainTree children. 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 } { #category : #persistence }
GrafoscopioBrowser >> openHelpInGrafoscopio [ GrafoscopioBrowser >> openHelpInGrafoscopio [
"Opens the help tree from a file" "Opens the help tree from a file"