From 5a7078e2f21d91637d3873272b83d8276a401e1c Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Sun, 5 Feb 2017 20:04:31 +0000 Subject: [PATCH] Loading links from web as playgrounds. Now using the node links field, instead of the node header. --- .../Grafoscopio/GrafoscopioNode.class.st | 5 ++-- .../Grafoscopio/GrafoscopioNotebook.class.st | 25 ++++++++++++------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/repository/Grafoscopio/GrafoscopioNode.class.st b/repository/Grafoscopio/GrafoscopioNode.class.st index 9f14ea8..51e80f8 100644 --- a/repository/Grafoscopio/GrafoscopioNode.class.st +++ b/repository/Grafoscopio/GrafoscopioNode.class.st @@ -493,7 +493,7 @@ GrafoscopioNode >> level: anInteger [ { #category : #accessing } GrafoscopioNode >> links [ "I model local or remote links that are associated to a particular node." - ^ links ifNil: [ ^ links := OrderedCollection new ] + ^ links ifNil: [ ^ links = OrderedCollection new ] ] { #category : #accessing } @@ -528,7 +528,8 @@ GrafoscopioNode >> markdownContent [ If special nodes types are present, converts them into proper markup to be embedded inside markdown" | markdown embedNodes temporalBody invisibleChildren | markdown := '' writeStream. - (self class specialWords includes: self header) not & (self class specialWords includes: ((self header findTokens: $ ) at: 1)) not & (self tags = 'código') not + (self class specialWords includes: self header) not & + (self class specialWords includes: ((self header findTokens: $ ) at: 1)) not & (self tags = 'código') not ifTrue: [ self level timesRepeat: [ markdown nextPutAll: '#' ]. markdown nextPutAll: ' '. diff --git a/repository/Grafoscopio/GrafoscopioNotebook.class.st b/repository/Grafoscopio/GrafoscopioNotebook.class.st index 69b8215..32c712a 100644 --- a/repository/Grafoscopio/GrafoscopioNotebook.class.st +++ b/repository/Grafoscopio/GrafoscopioNotebook.class.st @@ -176,11 +176,12 @@ GrafoscopioNotebook >> initializePresenter [ (tree highlightedItem content header) = arg ifFalse: [ (tree highlightedItem) content header: arg. - tree roots: tree roots. - self updateForSpecialHeader]]. + tree roots: tree roots]]. links whenTextChanged: [ :arg | - (tree highlightedItem content links) = arg - ifFalse: [ (tree highlightedItem) content links: arg]] + ((tree highlightedItem content links) includes: arg) + ifFalse: [ + (tree highlightedItem) content links add: arg. + self updateForSpecialLinks]] ] { #category : #initialization } @@ -325,7 +326,13 @@ GrafoscopioNotebook >> newWindowMainMenu [ name: nil; description: 'Visit link'; icon: Smalltalk ui icons glamorousRight; - action: [ self visitNodeLink ] ]. + action: [ self visitNodeLink ] ]. + group addItem: [ :item | + item + name: nil; + description: 'Load link'; + icon: Smalltalk ui icons glamorousRefresh; + action: [ self updateForSpecialLinks ] ]. group addItem: [ :item | item name: nil; @@ -663,17 +670,17 @@ GrafoscopioNotebook >> updateBodyFor: aNodeContainer [ ] { #category : #operation } -GrafoscopioNotebook >> updateForSpecialHeader [ +GrafoscopioNotebook >> updateForSpecialLinks [ "I see if a node header is an url located at 'http://ws.stfx.eu', wich means that is a shared workspace, and convert the node body to an interactive playground" | currentNode nodeContent | currentNode := tree highlightedItem. currentNode ifNil: [ ^ self ]. nodeContent := currentNode content. - nodeContent header isAsciiString ifFalse: [ ^ self ]. - nodeContent header asUrl host = 'ws.stfx.eu' ifFalse: [ ^ self ]. + nodeContent links last isAsciiString ifFalse: [ ^ self ]. + nodeContent links last asUrl host = 'ws.stfx.eu' ifFalse: [ ^ self ]. nodeContent - body: (ZnClient new get: nodeContent header); + body: (ZnClient new get: nodeContent links last); tagAs: 'código'. self updateBodyFor: currentNode ]