Extending special cases for generic urls plus the urls for playgrounds.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2017-07-31 18:27:57 +00:00
parent bf7c15d5cd
commit f2d6d9d515
2 changed files with 64 additions and 24 deletions

View File

@ -229,7 +229,7 @@ GrafoscopioNode >> becomeDefaultTestTree [
{ #category : #initialization }
GrafoscopioNode >> becomeDefaultTree [
"I create a starting tree for all grafoscopio notebooks with just one textual node"
"I create a starting tree for all Grafoscopio notebooks with just one textual node as child."
| node1 |
self level: 0.
self header: 'Arbol principal'.
@ -311,6 +311,13 @@ GrafoscopioNode >> copyToClipboard [
]
{ #category : #operation }
GrafoscopioNode >> cryptoSignature [
"I return the SHA1SUM of the current tree. I'm used to test changes on the contents
and for traceability of how the document tree is converted to other formats, as markdown."
^ (SHA1 new hashMessage: self root flatten asSton) hex
]
{ #category : #utility }
GrafoscopioNode >> deleteReferencesToRoot: aRootNode [
@ -518,6 +525,24 @@ GrafoscopioNode >> icon: aSymbol [
icon := aSymbol
]
{ #category : #importing }
GrafoscopioNode >> importLinkContent [
"I take the last link and import its contents in node body. "
self links last asUrl host = 'ws.stfx.eu' ifTrue: [ ^ self ].
self
body: (ZnClient new get: self links last).
]
{ #category : #importing }
GrafoscopioNode >> importPlaygroundLink [
"I take the last link and import its contents in node body.
Last links should be hosted in http://zn.stfx.eu/"
self links last asUrl host = 'ws.stfx.eu' ifFalse: [ ^ self ].
self
body: (ZnClient new get: self links last);
tagAs: 'código'.
]
{ #category : #initialization }
GrafoscopioNode >> initialize [
"I create a empty new node"
@ -687,18 +712,22 @@ GrafoscopioNode >> metadata [
{ #category : #exporting }
GrafoscopioNode >> metadataAsYamlIn: markdownStream [
"I convert the first '%metadata' node into a YAML preamble to be used by Pandoc exportation."
self metadata ifNil: [ ^ self ].
markdownStream
nextPutAll: '---';
nextPutAll: '---';
lf;
nextPutAll: 'exportedFrom: ', self cryptoSignature;
lf.
self metadata
keysAndValuesDo: [ :k :v |
markdownStream
nextPutAll: (k , ': ' , v asString) withInternetLineEndings;
nextPutAll: String cr ].
self metadata
ifNotNil: [
self metadata
keysAndValuesDo: [ :k :v |
markdownStream
nextPutAll: (k , ': ' , v asString) withInternetLineEndings;
nextPutAll: String cr ]].
markdownStream
nextPutAll: '---';
lf; lf
lf;
lf
]
{ #category : #movement }

View File

@ -47,7 +47,7 @@ GrafoscopioNotebook class >> defaultSpec [
bc add: #body; add: #links height: self toolbarHeight ]]]
]
{ #category : #'as yet unclassified' }
{ #category : #'instance creation' }
GrafoscopioNotebook class >> newDefault [
^ self new.
]
@ -95,6 +95,16 @@ GrafoscopioNotebook >> copyNodeToClipboard [
self notebookContent: notebook.
]
{ #category : #utilities }
GrafoscopioNotebook >> cryptoSignature [
"I return the cryptographic signature of the workingFile where this notebook is being stored.
I'm useful for data provenance and traceability of derivated files related with this source
notebook."
self workingFile ifNil: [ ^ self ].
self workingFile contents = '' ifTrue: [ ^ self ].
^ (SHA1 new hashMessage: (self workingFile contents)) hex.
]
{ #category : #'editing nodes' }
GrafoscopioNotebook >> cutNodeToClipboard [
self copyNodeToClipboard; removeNode.
@ -122,7 +132,7 @@ GrafoscopioNotebook >> debugWithSelector: aSymbol [
^ (nodeContent perform: aSymbol asSymbol) inspect
]
{ #category : #'as yet unclassified' }
{ #category : #utilities }
GrafoscopioNotebook >> defineDebugMessageUI [
| answer |
answer := UIManager default
@ -234,6 +244,16 @@ GrafoscopioNotebook >> header: anObject [
header := anObject
]
{ #category : #initialization }
GrafoscopioNotebook >> initialize [
super initialize.
self
notebook: (GrafoscopioNode new becomeDefaultTree);
title: ' New | Grafoscopio notebook'.
self notebookContent: self notebook.
]
{ #category : #initialization }
GrafoscopioNotebook >> initializePresenter [
tree whenHighlightedItemChanged: [ :item |
@ -415,14 +435,8 @@ GrafoscopioNotebook >> okToChange [
{ #category : #persistence }
GrafoscopioNotebook >> openDefault [
"I open a new default notebook"
| nb |
nb := self class new.
nb
notebook: (GrafoscopioNode new becomeDefaultTree);
title: ' New | Grafoscopio notebook';
notebookContent: nb notebook.
^ nb openWithSpec.
^ self class new openWithSpec.
]
{ #category : #persistence }
@ -774,11 +788,8 @@ GrafoscopioNotebook >> updateForSpecialLinks [
currentNode := tree highlightedItem.
currentNode ifNil: [ ^ self ].
nodeContent := currentNode content.
nodeContent links last isAsciiString ifFalse: [ ^ self ].
nodeContent links last asUrl host = 'ws.stfx.eu' ifFalse: [ ^ self ].
nodeContent
body: (ZnClient new get: nodeContent links last);
tagAs: 'código'.
nodeContent importPlaygroundLink.
nodeContent importLinkContent.
self updateBodyFor: currentNode
]