Grafoscopio/repository/Grafoscopio/GrafoscopioBrowser.class.st

1329 lines
42 KiB
Smalltalk

"
An UbakyeExplorer is a graphical interface for showing trees and outlines.
Instance Variables
browser: <Object>
browser
- xxxxx
"
Class {
#name : #GrafoscopioBrowser,
#superclass : #Object,
#instVars : [
'browser',
'mainTree',
'tagsAvailable',
'\r\t\t\t\t\t\t\t\t\tnonVar1',
'cacheNode',
'workingFile',
'\r\t\t\t\t\t\t\t\t\tnonVar2',
'localRepository',
'remoteRepository',
'repositoryUser',
'repositoryPassword'
],
#classVars : [
'DefaultUbakyeBrowser',
'dockingBar',
'draftsLocation',
'fossil',
'pandoc',
'recentTrees'
],
#classInstVars : [
'workingFile'
],
#category : #'Grafoscopio-UI'
}
{ #category : #'as yet unclassified' }
GrafoscopioBrowser class >> configureFossil [
"Stablish where is located fossil according to the operative system and the input of the user"
| fileStream |
fileStream := UITheme builder
fileOpen: 'Coloque la ruta de fossil'.
fileStream isNil ifTrue: [ ^nil ].
fossil := fileStream name asFileReference fullName.
]
{ #category : #'as yet unclassified' }
GrafoscopioBrowser class >> configurePandoc [
"Stablish where is located pandoc according to the operative system and/or the input of the user"
| fileStream |
fileStream := UITheme builder
fileOpen: 'Coloque la ruta de pandoc'.
fileStream isNil ifTrue: [ ^nil ].
pandoc := fileStream name asFileReference fullName.
]
{ #category : #'as yet unclassified' }
GrafoscopioBrowser class >> configureSettings [
"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: [
fossil := (FileSystem disk workingDirectory parent / 'Platform' / 'Linux' / 'Programs' / 'Fossil'/ 'fossil') fullName.
pandoc := (FileSystem disk workingDirectory parent / 'Platform' / 'Linux' / 'Programs' / 'Pandoc' / 'pandoc') fullName].
Smalltalk platform name = 'Win32'
ifTrue: [
fossil := (FileSystem disk workingDirectory / 'Platform' / 'Windows' / 'Programs' / 'Fossil' / 'fossil.exe') fullName.
pandoc := (FileSystem disk workingDirectory / 'Platform' / 'Windows' / 'Programs' / 'Pandoc' / 'pandoc.exe') fullName].
]
{ #category : #'as yet unclassified' }
GrafoscopioBrowser class >> messageAbout [
"Shows the author, license, sponsors and main contributors to the project and point to further documentation on the web"
UIManager default alert:
'Grafosocpio',
(String with: Character cr),
'(c) Copyright 2014 by Offray Vladimir Luna Cárdenas',
(String with: Character cr),
'Covered under MIT license.',
(String with: Character cr),
(String with: Character cr),
'SPONSORS:',
(String with: Character cr),
'mutabiT | www.mutabit.com ',
(String with: Character cr),
'Fundación Universitaria Los Libertadores | www.ulibertadores.edu.co ',
(String with: Character cr),
(String with: Character cr),
'For further details and versions go to:',
(String with: Character cr),
(String with: Character cr),
'http://mutabit.com/grafoscopio'
title: 'About Grafoscopio'.
]
{ #category : #'as yet unclassified' }
GrafoscopioBrowser class >> messageNoRecentDocuments [
"Shows that a feature is not implemeted and point to further documentation on the web"
UIManager default abort:
'No hay documentos recientes.',
(String with: Character cr),
'Abra un documento usando el menú:',
(String with: Character cr),
(String with: Character cr),
'"Lanzar > Documento interactivo desde archivo"',
(String with: Character cr),
(String with: Character cr)
title: 'No hay documentos recientes'.
]
{ #category : #'as yet unclassified' }
GrafoscopioBrowser class >> messageNotImplementedYet [
"Shows that a feature is not implemeted and point to further documentation on the web"
UIManager default abort:
'Esta funcionalidad aún no está implementada!',
(String with: Character cr),
'Para información sobre futuras versiones, por favor visite: ',
(String with: Character cr),
(String with: Character cr),
'http://mutabit.com/grafoscopio',
(String with: Character cr),
(String with: Character cr)
title: 'No implementado aún'.
]
{ #category : #'as yet unclassified' }
GrafoscopioBrowser class >> open [
^ self new open
]
{ #category : #'as yet unclassified' }
GrafoscopioBrowser class >> openFromRecentlyUsed [
"Tags the node passed as argument with a value from the collection of tags available"
| selection |
recentTrees isNil
ifFalse: [
selection := UIManager default chooseFrom: recentTrees title: 'Elija una documento'.
GrafoscopioBrowser new openFromFile: (recentTrees at: selection)
]
ifTrue: [self messageNoRecentDocuments].
"browser update".
]
{ #category : #'as yet unclassified' }
GrafoscopioBrowser class >> openHelpInHtml [
"Launches the help manual in PDF format in an external viewer."
| htmlHelpFileLocation |
htmlHelpFileLocation := (FileSystem disk workingDirectory parent / 'Docs' /'Es' / 'Manual' / 'manual-grafoscopio.html') fullName.
Smalltalk platform name = 'unix'
ifTrue: [
OSProcess command: 'xdg-open ', htmlHelpFileLocation.
].
Smalltalk platform name = 'Win32'
ifTrue: [
OSProcess command: 'explorer ', htmlHelpFileLocation.
].
]
{ #category : #'as yet unclassified' }
GrafoscopioBrowser class >> openHelpInPdf [
"Launches the help manual in PDF format in an external viewer."
| pdfHelpFileLocation |
pdfHelpFileLocation := (FileSystem disk workingDirectory parent / 'Docs' /'Es' / 'Manual' / 'manual-grafoscopio.pdf') fullName.
Smalltalk platform name = 'unix'
ifTrue: [
OSProcess command: 'xdg-open ', pdfHelpFileLocation.
].
Smalltalk platform name = 'Win32'
ifTrue: [
OSProcess command: 'explorer ', pdfHelpFileLocation.
].
]
{ #category : #'as yet unclassified' }
GrafoscopioBrowser class >> showSettings [
"Shows the settings in a Transcript. This should return a dictionary for better management of the settings. For the moment
is a quick a dirty hack"
Transcript show: fossil; cr.
Transcript show: pandoc
]
{ #category : #'as yet unclassified' }
GrafoscopioBrowser class >> startDockingBar [
"Creates a custom docking bar for grafoscopio on top, with shorcuts for most used actions, and a fixed place for asking for help.
Some of the functionalities implemented now in the grafoscopio interface for document trees should be moved here, like the ones
related with help, external tools and grafoscopio updates and about"
| launchMenu helpMenu updateMenu |
launchMenu := MenuMorph new.
launchMenu
add: 'Documento interactivo nuevo' target: GrafoscopioBrowser selector: #open;
add: 'Documento interactivo desde archivo' target: (GrafoscopioBrowser new) selector: #openFromFileSelector;
add: 'Documentos interactivos recientes' target: GrafoscopioBrowser selector: #openFromRecentlyUsed;
add: 'Documentos interactivos de ejemplo' target: GrafoscopioBrowser selector: #messageNotImplementedYet;
add: 'Ejemplos de visualizaciones en Roassal' target: (RTExampleBrowser new) selector: #open;
add: 'Playground' target: (Smalltalk tools) selector: #openWorkspace;
add: 'Transcript' target: (Smalltalk tools) selector: #openTranscript.
updateMenu := MenuMorph new.
updateMenu
add: 'Documentación' target: GrafoscopioBrowser selector: #updateDocumentation;
add: 'Grafoscopio' target: GrafoscopioBrowser selector: #updateGrafoscopio;
add: 'Prerrequisitos' target: GrafoscopioBrowser selector: #updatePrerrequisites;
add: 'Herramientas externas' target: GrafoscopioBrowser selector: #messageNotImplementedYet;
add: 'Ruta a pandoc' target: GrafoscopioBrowser selector: #configurePandoc;
add: 'Ruta a fossil' target: GrafoscopioBrowser selector: #configureFossil;
add: 'Todo el sistema' target: GrafoscopioBrowser selector: #updateSystem.
helpMenu := MenuMorph new.
helpMenu
add: 'Manual en PDF' target: GrafoscopioBrowser selector: #openHelpInPdf;
add: 'Manual en HTML' target: GrafoscopioBrowser selector: #openHelpInHtml;
add: 'Manual en grafoscopio' target: (GrafoscopioBrowser new) selector: #openHelpInGrafoscopio;
add: 'Ir a la documentación en línea' target: GrafoscopioBrowser selector: #messageNotImplementedYet;
add: 'Acerca de Grafoscopio' target: GrafoscopioBrowser selector: #messageAbout.
dockingBar := DockingBarMorph new.
dockingBar
add: 'Lanzar' subMenu: launchMenu;
add: 'Actualizar' subMenu: updateMenu;
add: 'Ayuda' subMenu: helpMenu.
dockingBar
adhereToTop;
openInWorld.
]
{ #category : #'as yet unclassified' }
GrafoscopioBrowser class >> updateDocumentation [
| localRepository remoteRepository |
localRepository := FileSystem disk workingDirectory parent / 'grafoscopio.fossil'.
remoteRepository := 'http://mutabit.com/deltas/repos.fossil/grafoscopio/'.
localRepository exists
ifFalse: [
OSProcess command: 'exec ', fossil, ' clone ' , remoteRepository, ' ', localRepository fullName.
OSProcess command: 'exec echo "Repositorio clonado."'.
]
ifTrue: [
(FileSystem disk workingDirectory parent / '.flsckout') exists
ifFalse: [
OSProcess command: 'exec ', fossil, ' open ', localRepository fullName .
OSProcess command: 'exec echo "Repositorio abierto."'.
] .
OSProcess command: 'exec ', fossil, ' update ' .
OSProcess command: 'exec echo "Repositorio actualizado."'.
]
]
{ #category : #'as yet unclassified' }
GrafoscopioBrowser class >> updateGrafoscopio [
"Updates Grafoscopio with new versions of itself take from the source code repository and the User Interface"
Gofer new
smalltalkhubUser: 'Offray' project: 'Grafoscopio';
package: 'Grafoscopio';
load.
self updateUI.
]
{ #category : #'as yet unclassified' }
GrafoscopioBrowser class >> updatePrerrequisites [
"Updates the system prerequisites with new versions of itself take from the source code repository"
"Visualization library (which also makes main menu loadable)"
Gofer it
smalltalkhubUser: 'ObjectProfile' project: 'Roassal2';
configurationOf: 'Roassal2';
loadDevelopment.
"Open/save files on STON format"
Gofer new
smalltalkhubUser: 'SvenVanCaekenberghe' project: 'STON';
configurationOf: 'Ston';
loadBleedingEdge.
"Moose and Roassal integration"
Gofer new
smalltalkhubUser: 'Moose' project: 'Glamour';
package: 'Glamour-Tools';
package: 'Glamour-Roassal2-Presentations';
load.
Gofer new
smalltalkhubUser: 'Moose' project: 'GToolkit';
package: 'GT-InspectorExtensions-CoreRoassal';
load.
"HTML scrapping"
Gofer new
smalltalkhubUser: 'PharoExtras' project: 'Soup';
configurationOf: 'Soup';
loadStable.
"Data visualization"
Gofer new
smalltalkhubUser: 'Offray' project: 'Dataviz';
package: 'Dataviz';
load.
]
{ #category : #'as yet unclassified' }
GrafoscopioBrowser class >> updateSystem [
"Updates the system with new versions of itself take from the source code repository"
Gofer it
smalltalkhubUser: 'ObjectProfile' project: 'Roassal2';
configurationOf: 'Roassal2';
loadStable.
Gofer new
smalltalkhubUser: 'SvenVanCaekenberghe' project: 'STON';
package: 'STON-Core';
load.
Gofer new squeaksource: 'Citezen';
package: 'ConfigurationOfCitezen';
load.
(ConfigurationOfCitezen project latestVersion: #development) load.
Gofer new
smalltalkhubUser: 'Offray' project: 'Grafoscopio';
package: 'Grafoscopio';
load.
]
{ #category : #'as yet unclassified' }
GrafoscopioBrowser class >> updateUI [
"Updates the User Interface (UI) with new versions of the docking bar or logos where available. Helpful while testing new functionality
that should be expossed to the user via the UI"
dockingBar delete.
self startDockingBar.
]
{ #category : #persistence }
GrafoscopioBrowser >> addFileToRepository [
"Adds a selected file to a defined repository."
| fileStream fileToAdd |
self buildBrowser.
fileStream := UITheme builder
fileOpen: 'Elija un archivo para agregar al repositorio'.
fileStream isNil ifTrue: [ ^nil ].
fileToAdd := fileStream fullName.
OSProcess command:
'cd ', localRepository parent fullName, '; ',
fossil, ' add ', fileToAdd, '; ',
'echo "Added file to enabled repository"'.
]
{ #category : #tags }
GrafoscopioBrowser >> addTagTo: aNode [
"Tags the node passed as argument with a value from the collection of tags available"
| selection |
tagsAvailable isNil
ifFalse: [
selection := UIManager default chooseFrom: tagsAvailable title: 'Elija una etiqueta'.
aNode tagAs: (tagsAvailable at: selection)
]
ifTrue: [self messageNoTagsAvailable].
browser update.
]
{ #category : #tags }
GrafoscopioBrowser >> addToTagsAvailable [
"Adds a tag to the collection of tags available"
| tag |
tagsAvailable isNil
ifTrue: [tagsAvailable := OrderedCollection new].
tag := UIManager default
textEntry: 'Nombre de la etiqueta'
title: 'Agregue una etiqueta'.
tagsAvailable add: tag.
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> body2ForTransmediaIn: constructor for: aNode [
"Shows the body of a transmedia type of nodes, which are tagged as 'original' and 'transmediado'"
| innerBrowser originalNode transmediaNode |
aNode tags = 'original'
ifFalse: [^self ]
ifTrue: [
innerBrowser := GLMTabulator new.
GLMTabulator new.
innerBrowser
column: [ :c |
c row: [ :r | r column: #original; column: #transmediado] span: 7";
row: #buttons; span: 1"].
originalNode := aNode.
originalNode children isNotNil
ifTrue: [transmediaNode := originalNode children detect: [:node | node tags = 'transmediado']
ifNone: [ transmediaNode := nil ] ].
constructor custom: innerBrowser]
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> bodyForCodeIn: constructor for: aNode [
"Shows the body of a node as an interactive playground. If node is not tagged it will return itself,
so it can be rendered properly for other messages"
| innerBrowser |
aNode tags = 'código'
ifFalse: [^self].
innerBrowser := GTPlayground new.
constructor custom: innerBrowser.
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> bodyForTransmediaIn: constructor for: aNode [
"Shows the body of a transmedia type of nodes, which are tagged as 'original' and 'transmediado'"
aNode tags = 'original'
ifFalse: [^self ]
ifTrue: [constructor custom: (self panelTransmediaFor: aNode)]
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> bodyForTransmediaOn: constructor [
"Shows the body of a transmedia type of node"
constructor custom: self panelBrowserForTransmediaton.
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> bodyIn: constructor [
"Shows the body of a selected node"
(constructor text)
title: 'Texto';
format:[:eachNode |
(eachNode body) isNil
ifTrue: [ '' ]
ifFalse: [ eachNode body]].
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> bodyIn: constructor for: aNode [
"Shows the body in a constructor for selected node, if node is not tagged. If it is tagged it will return itself, so it can be rendered
properly for other messages"
| specialTags |
specialTags := #('código' 'original').
(specialTags includes: aNode tags)
ifTrue: [^self ].
(constructor text)
title: 'Texto ';
format:[
aNode body isNil
ifTrue: [ '' ]
ifFalse: [ aNode body]].
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> browser [
"Returns de browser object, which represents the graphical interface. Useful for debugging purposes"
^ browser.
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> buildBrowser [
"Main method for building the interface for trees and its nodes"
browser := GLMTabulator new
title: ' | Grafoscopio'.
browser
column: [:c |
c row: #tree span: 6;
row: #nodeHeader span: 1] span: 2;
column: [ :c |
c row: #nodeBody span: 2] span: 5.
browser
updateOn: GLMItemAdded from: #yourself;
updateOn: GLMItemRemoved from: #yourself.
(browser transmit)
to: #tree;
andShow: [:a | self treeOn: a].
"Creating a self updateable body pane"
(browser transmit)
to: #nodeBody;
from: #tree;
andShow: [ :a | self bodyIn: a].
(browser transmit )
from: #tree port: #selection;
from: #nodeBody port: #text;
when: [:node :text | text notNil];
to: #nodeBody port: #neverland;
transformed: [:node :text | node body: text asString].
(browser transmit)
from: #tree;
to: #nodeHeader;
andShow: [ :h | self headerOn: h ].
(browser transmit )
from: #tree port: #selection;
from: #nodeHeader port: #text;
when: [:node :text | text notNil];
to: #nodeHeader port: #neverland1;
transformed: [:node :text | node header: text asString]
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> buildBrowserLandscape [
browser := GLMTabulator new
title: 'Grafoscopio'.
browser
column: #original span: 3;
column: #transmediado span: 3.
browser
updateOn: GLMItemAdded from: #yourself;
updateOn: GLMItemRemoved from: #yourself.
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> buildBrowserNamed: aName [
"Main method for building the interface for trees and its nodes. The name of the browser corresponds to the name of the file
where tree is stored (or is named 'draft.ston' by default)"
self configureInitialTags.
browser := GLMTabulator new
title: aName, ' | Grafoscopio'.
browser
column: [:c |
c row: #tree span: 6;
row: #nodeHeader span: 1] span: 2;
column: [ :c |
c row: #nodeBody span: 2] span: 5.
browser
updateOn: GLMItemAdded from: #yourself;
updateOn: GLMItemRemoved from: #yourself.
(browser transmit)
to: #tree;
andShow: [:a | self treeOn: a].
"Creating a self updatable body pane"
(browser transmit)
from: #tree port: #selection;
to: #nodeBody;
when: [:selection | selection notNil];
andShow: [ :a :node |
self bodyIn: a for: node.
self bodyForCodeIn: a for: node.
self bodyForTransmediaIn: a for: node ].
(browser transmit )
from: #tree port: #selection;
from: #nodeBody port: #text;
when: [:node :text | text notNil & node notNil];
to: #nodeBody port: #neverland;
transformed: [:node :content |
node tags = 'código'
ifFalse: [node body: content asString]
ifTrue: [node body: content]].
(browser transmit)
from: #tree;
to: #nodeHeader;
andShow: [ :h | self headerOn: h ].
(browser transmit )
from: #tree port: #selection;
from: #nodeHeader port: #text;
to: #nodeHeader port: #neverland1;
when: [:node :text | text notNil & node notNil];
transformed: [:node :text | node header: text asString]
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> buildBrowserNamed: aName inMode: aModeName [
"Main method for building the interface for trees and its nodes. The name of the browser corresponds to the name of the file
where tree is stored (or is named 'draft.ston' by default). The name of the mode correspond to a way of showing and dealing with
the data.
The idea is to support several modes in the future, starting with the 'Transmediaton' mode and adding more as needed."
self configureInitialTags.
browser := GLMTabulator new
title: aName, ' | Grafoscopio'.
browser
column: [:c |
c row: #tree span: 6;
row: #nodeHeader span: 1] span: 2;
column: [ :c |
c row: #nodeBody span: 2] span: 5.
browser
updateOn: GLMItemAdded from: #yourself;
updateOn: GLMItemRemoved from: #yourself.
(browser transmit)
to: #tree;
andShow: [:a | self treeOn: a].
"Creating a self updatable body pane"
(browser transmit)
to: #nodeBody;
from: #tree;
andShow: [ :a |
(aModeName = 'transmedia')
ifTrue: [self bodyForTransmediaOn: a]].
(browser transmit )
from: #tree port: #selection;
from: #nodeBody port: #text;
when: [:node :text | text notNil];
to: #nodeBody port: #neverland;
transformed: [:node :text | node body: text asString].
(browser transmit)
from: #tree;
to: #nodeHeader;
andShow: [ :h | self headerOn: h ].
(browser transmit )
from: #tree port: #selection;
from: #nodeHeader port: #text;
when: [:node :text | text notNil];
to: #nodeHeader port: #neverland1;
transformed: [:node :text | node header: text asString]
]
{ #category : #'system-support' }
GrafoscopioBrowser >> configureInitialTags [
"Configures a list of predefined tags available to use. More tags should be added from a repository.
The idea is that nodes are processed and show differently according to their tags. So users should be
able to define their own tags with custom UI and behaviour"
tagsAvailable := OrderedCollection new.
tagsAvailable
add: 'código';
add: 'ejercicio';
add: 'invisible';
add: 'obra';
add: 'original';
add: 'transmediado'.
]
{ #category : #persistence }
GrafoscopioBrowser >> copyNodeIntoCache: aNode [
"Copy the contents of the current node into cacheNode. It doesn't work recursively yet, so it doen't copy the children of the nodes"
cacheNode := GrafoscopioNode new.
cacheNode header: (aNode header).
cacheNode body: (aNode body).
self inform: 'Nodo copiado: ', aNode header
]
{ #category : #bibliography }
GrafoscopioBrowser >> customKeys [
"Replaces the default key in a BibTeX file for a custom key taken from the 'shorttitle' field.
Useful when autogenerated BibTeX has cryptic or non easy to memorize keys (for example in some
Zotero exports)"
| bibFile bibliography bibStream bibOutputer |
bibFile := ((workingFile parent) children
detect: [:each | each basename endsWith: 'bib' ] ifNone: [ ]).
bibFile ifNotNil: [
bibliography := CZBibParser parse: bibFile contents.
bibStream := '' writeStream.
(bibliography entries) do: [:bibItem |
bibItem fields do: [:some | some key = 'shorttitle'
ifTrue: [ bibItem key: some value ]].
bibOutputer := CZBibtexOutputer new.
bibStream nextPutAll:
(bibOutputer entryToBibtexString: bibItem); cr].
bibFile writeStreamDo: [:stream |
stream nextPutAll: bibStream contents withUnixLineEndings ]].
]
{ #category : #persistence }
GrafoscopioBrowser >> defineRemoteRepository [
"Defines a remote fossil repository from an url"
"| temporary variable names |
statements"
]
{ #category : #persistence }
GrafoscopioBrowser >> enableLocalRepository [
"Just a temporary message to enable working with fossil on a specific repository. This should be generalized"
| fileStream |
fileStream := UITheme builder
fileOpen: 'Coloque la ruta al repositorio del proyecto (.fossil)'
extensions: #('fossil').
fileStream isNil ifTrue: [ ^nil ].
localRepository := fileStream name asFileReference.
OSProcess command:
'cd ', localRepository parent fullName,';',
'exec ', fossil, ' open ', localRepository fullName.
]
{ #category : #persistence }
GrafoscopioBrowser >> exportAsHtml [
"Exports the current tree to HTML, using the same name but different extension (.html)"
| markdownFileLocation htmlFileLocation |
markdownFileLocation := ((workingFile parent) / workingFile basenameWithoutExtension) fullName, '.markdown'.
htmlFileLocation := ((workingFile parent) / workingFile basenameWithoutExtension) fullName, '.html'.
pandoc notNil
ifTrue:[
Smalltalk platform name = 'unix'
ifTrue: [
OSProcess command: 'exec ', pandoc, ' ', markdownFileLocation , ' --standalone -o ' , htmlFileLocation.
OSProcess command: 'exec echo "exportando como html"'.
self inform: 'Archivo exportado como html en: ', htmlFileLocation.
self inform: pandoc].
Smalltalk platform name = 'Win32'
ifTrue: [ OSProcess command: pandoc, ' ', markdownFileLocation , ' --standalone -o ' , htmlFileLocation ]]
ifFalse: [GrafoscopioBrowser configurePandoc ].
self customKeys.
]
{ #category : #persistence }
GrafoscopioBrowser >> exportAsMarkdown: aTree on: locator [
locator writeStreamDo: [:stream | stream nextPutAll: aTree asMarkdown]
]
{ #category : #persistence }
GrafoscopioBrowser >> exportAsPdf [
"Exports the current tree to HTML, using the same name but different extension (.pdf).
IMPORTANT: The user needs to have installed TeX to create the pdf."
| markdownFileLocation pdfFileLocation |
markdownFileLocation := ((workingFile parent) / workingFile basenameWithoutExtension) fullName, '.markdown'.
pdfFileLocation := ((workingFile parent) / workingFile basenameWithoutExtension) fullName, '.pdf'.
pandoc notNil
ifTrue:[
Smalltalk platform name = 'unix'
ifTrue: [
OSProcess command: 'exec ', pandoc, ' ', markdownFileLocation , ' -o ' , pdfFileLocation.
OSProcess command: 'exec echo "exportando como pdf"'.
self inform: 'Archivo exportado como pdf en: ', pdfFileLocation.].
Smalltalk platform name = 'Win32'
ifTrue: [ OSProcess command: pandoc, ' ', markdownFileLocation , ' -o ' , pdfFileLocation ]]
ifFalse: [GrafoscopioBrowser configurePandoc ].
self customKeys.
]
{ #category : #persistence }
GrafoscopioBrowser >> exportAsSton: aTree on: locator [
locator nextPutAll: (STON toStringPretty: aTree children)
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> headerOn: constructor [
"Shows the body of a selected node"
(constructor text)
title: 'Cabecera ';
format:[:eachNode |
(eachNode header) isNil
ifTrue: [ '' ]
ifFalse: [ eachNode header]].
]
{ #category : #'system-support' }
GrafoscopioBrowser >> installPandoc [
"Installs pandoc binary for each major platform: Linux, Windows, Mac"
| linuxSupplies |
linuxSupplies := (FileSystem disk workingDirectory
/ 'Platform' / 'Linux' / 'Programs' / 'Pandoc')
ensureCreateDirectory.
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> messageNoTagsAvailable [
"Shows that there is no tags available and the procedure to add some tags"
UIManager default
abort:
'Use primero el menu:',
(String with: Character cr),
'"Etiquetas > Agregar a disponibles"',
(String with: Character cr),
'para agregar etiquetas y luego sí agregue etiquetas al nodo'
title: 'Sin etiquetas disponibles!'
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> messageNotImplementedYet [
"Shows that a feature is not implemeted and point to further documentation on the web"
UIManager default abort:
'Esta funcionalidad aún no está implementada!',
(String with: Character cr),
'Para información sobre futuras versiones, por favor visite: ',
(String with: Character cr),
(String with: Character cr),
'http://mutabit.com/grafoscopio',
(String with: Character cr),
(String with: Character cr)
title: 'No implementado aún'.
]
{ #category : #persistence }
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"
"Opens a new browser with a default tree"
GrafoscopioBrowser configureSettings.
self openDefault.
]
{ #category : #persistence }
GrafoscopioBrowser >> openDefault [
"Opens a new browser with a default tree"
GrafoscopioBrowser configureSettings.
self buildBrowser.
mainTree := GrafoscopioNode new.
mainTree becomeDefaultTree.
workingFile := draftsLocation / 'draft.ston'.
self saveToFile: workingFile.
self openFromFile: workingFile.
" browser openOn: mainTree children."
]
{ #category : #persistence }
GrafoscopioBrowser >> openFromFile: aFileName [
"Opens a tree from a file named aFileName"
| currentChildren |
GrafoscopioBrowser configureSettings.
workingFile := aFileName.
currentChildren := (STON fromString: aFileName contents).
self buildBrowserNamed: aFileName basenameWithIndicator.
mainTree := GrafoscopioNode new
header: 'Arbol principal';
level: 0.
mainTree children: currentChildren.
browser openOn: mainTree children.
]
{ #category : #persistence }
GrafoscopioBrowser >> openFromFile: aFileName inMode: aModeName [
"Opens a tree from a file named aFileName"
| currentChildren |
GrafoscopioBrowser configureSettings.
aFileName isNil ifTrue: [ ^nil ].
workingFile := aFileName name asFileReference.
currentChildren := (STON fromString: aFileName contents).
self buildBrowserNamed: aFileName basenameWithIndicator inMode: aModeName.
mainTree := GrafoscopioNode new
header: 'Arbol principal';
level: 0.
mainTree children: currentChildren.
browser openOn: mainTree children.
]
{ #category : #persistence }
GrafoscopioBrowser >> openFromFileSelector [
"Opens a tree from a file by using the file selector GUI."
| fileStream currentChildren |
GrafoscopioBrowser configureSettings.
fileStream := UITheme builder
fileOpen: 'Elija un archivo .ston'
extensions: #('ston').
fileStream isNil ifTrue: [ ^nil ].
workingFile := fileStream name asFileReference.
currentChildren := (STON fromStream: fileStream).
self buildBrowserNamed: workingFile basenameWithIndicator.
recentTrees isNil
ifTrue:[recentTrees := OrderedCollection new].
recentTrees add: workingFile.
mainTree := GrafoscopioNode new
header: 'Arbol principal';
level: 0.
mainTree children: currentChildren.
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"
| currentChildren |
GrafoscopioBrowser configureSettings.
workingFile := (FileSystem disk workingDirectory parent / 'Docs' / 'Es' / 'Manual' / 'manual-grafoscopio.ston') asFileReference.
currentChildren := (STON fromString: workingFile contents).
self buildBrowserNamed: workingFile basenameWithIndicator.
mainTree := GrafoscopioNode new
header: 'Arbol principal';
level: 0.
mainTree children: currentChildren.
browser openOn: mainTree children.
]
{ #category : #'as yet unclassified' }
GrafoscopioBrowser >> openLandscape [
"Opens a new browser with a default tree in landscape mode"
self buildBrowserLandscape.
mainTree := GrafoscopioNode new.
mainTree becomeDefaultTree.
browser openOn: mainTree children.
]
{ #category : #persistence }
GrafoscopioBrowser >> openLast [
"Opens a new browser with a fixed 'last' working tree. May be this should be changed"
| workingFile currentChildren| "workingChildren would sound too cruel!"
self buildBrowser.
workingFile := '/home/offray/Documentos/U/Libertadores/Grafoscopio/bootstrapping-objeto-investigacion.ston' asFileReference readStream.
currentChildren := (STON fromStream: workingFile).
mainTree := GrafoscopioNode new
header: 'Bootstrapping the research object';
level: 0.
mainTree children: currentChildren.
browser openOn: mainTree children.
]
{ #category : #persistence }
GrafoscopioBrowser >> openWorking [
"Opens a new browser with the last working tree"
self buildBrowser.
mainTree := '/home/offray/Documentos/U/Libertadores/Grafoscopio/bootstrapping-objeto-investigacion.ston' asFileReference readStream.
browser openOn: mainTree children.
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> panelAsCodeFor: aNode [
"Shows an interactive playground for Smalltalk code in a node body"
browser := GLMTabulator new.
browser title: 'Código'.
browser column: #code.
browser transmit
to: #code;
transformed: [ GTPlayPage new content: aNode body ];
andShow: [ :a | a custom: GTPlayground new ].
browser sendToOutside: #nodeBody from: #code -> #text.
^ browser.
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> panelBrowserForTransmediaton [
"**Experimental feature.**
Opens grafoscopio in several 'modes'. Each mode corresponds to a operation way, with an specific interface.
We will start with a 'transmediaton' mode to let the people create some transmedia content.
After that we will enable other modes"
| transmediaNode originalNode |
browser := GLMTabulator new.
browser
column: [ :c |
c row: [ :r | r column: #original; column: #transmediado] span: 7";
row: #buttons; span: 1"].
(browser transmit)
to: #original;
andShow: [ :a |
a text
title: 'Original';
format:[:eachNode |
(eachNode tags) = 'original'
ifFalse: [ '' ]
ifTrue: [
originalNode := eachNode.
originalNode children isNotNil
ifTrue: [transmediaNode := originalNode children detect: [:node | node tags = 'transmediado'] ifNone: [ transmediaNode := nil ] ].
originalNode body]]].
(browser transmit)
from: #original;
toOutsidePort: #text.
(browser transmit)
to: #transmediado;
andShow: [ :a |
a text
title: 'Transmediado';
format:[transmediaNode isNotNil
ifFalse: [ '' ]
ifTrue: [transmediaNode body]
]
].
" (browser transmit)
to: #buttons;
andShow: [ :a |
a actionList
act: [:entity | entity inspect ] entitled: 'Subir';
act: [:entity | entity explore ] entitled: 'Previsualizar';
act: [:entity | entity explore ] entitled: 'Publicar'].
"
^ browser.
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> panelTransmediaFor: aNode [
""
| transmediaNode originalNode |
browser := GLMTabulator new.
browser
column: [ :c |
c row: [ :r | r column: #original; column: #transmediado] span: 7";
row: #buttons; span: 1"].
originalNode := aNode.
originalNode children isNotNil
ifTrue: [transmediaNode := originalNode children
detect: [:node | node tags = 'transmediado']
ifNone: [ transmediaNode := nil ] ].
(browser transmit)
to: #original;
andShow: [ :a |
a text
title: 'Original';
format:[ aNode body isNil
ifTrue: [ '' ]
ifFalse: [ aNode body ]
]].
(browser transmit)
from: #original;
toOutsidePort: #text.
(browser transmit)
to: #transmediado;
andShow: [ :a |
a text
title: 'Transmediado';
format:[transmediaNode isNotNil
ifFalse: [ '' ]
ifTrue: [transmediaNode body]
]
].
" (browser transmit)
to: #buttons;
andShow: [ :a |
a actionList
act: [:entity | entity inspect ] entitled: 'Subir';
act: [:entity | entity explore ] entitled: 'Previsualizar';
act: [:entity | entity explore ] entitled: 'Publicar'].
"
^ browser.
]
{ #category : #persistence }
GrafoscopioBrowser >> replaceContentsFromCache: aNode [
"Replaces the contents of aNode from the ones in cacheNode. It doesn't work recursively yet, so it doen't copy the children of the nodes"
cacheNode notNil
ifTrue: [
aNode header: cacheNode header.
aNode body: cacheNode body.
self inform: 'Contenidos reemplazados']
ifFalse: [self inform: 'El nodo cache está vacio']
]
{ #category : #persistence }
GrafoscopioBrowser >> repositoryCommit [
"Commits current changes to the open repository"
fossil notNil ifTrue: [
OSProcess command:
'cd ', localRepository parent fullName, '; ',
fossil, ' commit -m "" --no-warnings; ',
'echo "Commited changes to the repository"'. ]
]
{ #category : #persistence }
GrafoscopioBrowser >> repositoryCredentials [
"Asks for the user credentials of the current project repository"
repositoryUser := UIManager default request: 'Ingrese su usuario en el repositorio del proyecto'.
repositoryPassword := UIManager default request: 'Ingrese su contraseña en el repositorio del proyecto'.
]
{ #category : #persistence }
GrafoscopioBrowser >> saveToFile: aFileReference [
"Saves the current tree/document to a file"
| file writeStream markdownFile |
file := aFileReference.
file ifNil: [ self inform: 'Exportación cancelada'. ^ self ].
writeStream := file writeStream.
workingFile := writeStream name asFileReference.
markdownFile := (workingFile parent) / (workingFile basenameWithoutExtension, '.markdown').
[ self exportAsSton: mainTree on: writeStream.
self exportAsMarkdown: mainTree on: markdownFile ]
ensure: [ writeStream ifNotNil: #close ].
recentTrees isNil
ifTrue:[recentTrees := OrderedCollection new].
recentTrees add: workingFile.
browser update.
]
{ #category : #persistence }
GrafoscopioBrowser >> saveToFileUI [
"Saves the current tree to a file"
| file |
file := UITheme builder
fileSave: 'Guardar archivo como...'
extensions: #('ston')
path: nil.
file
ifNil: [ self inform: 'Exportación cancelada'. ^ self ]
"ifNotNilDo:[self saveToFile: file]".
browser update.
]
{ #category : #persistence }
GrafoscopioBrowser >> saveWorkingTree [
"Saves the current tree to the user predefined file location used when he/she opened it."
| fileStream markdownFile |
fileStream := workingFile writeStream.
markdownFile := (workingFile parent) / (workingFile basenameWithoutExtension, '.markdown').
[ self exportAsSton: mainTree on: fileStream.
self exportAsMarkdown: mainTree on: markdownFile ]
ensure: [ fileStream ifNotNil: #close.].
"self customKeys."
self inform: 'Archivo guardado como: ', workingFile asString.
]
{ #category : #tags }
GrafoscopioBrowser >> showTagsAvailable [
"Adds a tag to the collection of tags available"
tagsAvailable isNil
ifTrue: [self messageNoTagsAvailable]
ifFalse: [self messageNotImplementedYet]
]
{ #category : #'graphical interface' }
GrafoscopioBrowser >> treeOn: constructor [
"Shows the correspondent tree of a node"
(constructor tree) "Layout"
title: mainTree header;
children: [ :eachNode |
(eachNode children) isNil
ifTrue: [ self inform: 'Seleccione un nodo para ver su contenido' ]
ifFalse:[ eachNode children ] ];
format:[:eachNode |
(eachNode header) isNil
ifTrue: [ '' ]
ifFalse: [ eachNode header ]];
tags: [:eachNode |
(eachNode tags) isNil
ifFalse: [ (eachNode tags) asSymbol ]
ifTrue: [ #() ] ];
"Nodes Toolbar
=============="
"Adding nodes"
act: [:treePresentation |
(treePresentation selection) isNotNil
ifTrue: [treePresentation selection addNodeAfter].
treePresentation update]
icon: GLMUIThemeExtraIcons glamorousZoomIn
entitled: 'Adicionar nodo';
"Removing nodes"
act: [:treePresentation |
(treePresentation selection isNotNil)
ifTrue: [(treePresentation selection parent)
removeNode: treePresentation selection]
ifFalse: [treePresentation entity removeLast].
treePresentation update]
icon: GLMUIThemeExtraIcons glamorousZoomOut
entitled: 'Remover nodo';
"Move nodes in the same hierarchy"
act: [:treePresentation |
(treePresentation selection isNotNil)
ifTrue: [treePresentation selection moveBefore].
treePresentation update]
icon: GLMUIThemeExtraIcons glamorousUp
entitled: 'Mover nodo hacia arriba';
act: [:treePresentation |
(treePresentation selection isNotNil)
ifTrue: [treePresentation selection moveAfter].
treePresentation update]
icon: GLMUIThemeExtraIcons glamorousDown
entitled: 'Mover nodo hacia abajo';
act: [:treePresentation |
(treePresentation selection isNotNil)
ifTrue: [treePresentation selection promote].
treePresentation update]
icon: GLMUIThemeExtraIcons glamorousLeft
entitled: 'Mover nodo hacia la izquierda';
act: [:treePresentation |
(treePresentation selection isNotNil)
ifTrue: [treePresentation selection demote].
treePresentation update]
icon: GLMUIThemeExtraIcons glamorousRight
entitled: 'Mover nodo hacia la derecha';
act: [ :treePresentation | treePresentation update ]
icon: GLMUIThemeExtraIcons glamorousRefresh
entitled: 'Actualizar vista del árbol';
act: [self saveWorkingTree]
icon: GLMUIThemeExtraIcons glamorousSave
entitled: 'Guardar árbol';
"Options Menu
============="
"For trees"
act: [self saveToFileUI] entitled: 'Guardar como ...' categorized: 'Arbol';
act: [self saveWorkingTree; exportAsHtml] entitled: 'Exportar como HTML' categorized: 'Arbol';
act: [self saveWorkingTree; exportAsPdf] entitled: 'Exportar como PDF (requiere LaTeX)' categorized: 'Arbol';
act: [self messageNotImplementedYet] entitled: 'Ver HTML' categorized: 'Arbol';
act: [self messageNotImplementedYet] entitled: 'Ver PDF' categorized: 'Arbol';
"For nodes"
act: [:treePresentation |
(treePresentation selection isNotNil)
ifTrue: [self copyNodeIntoCache: treePresentation selection].
treePresentation update] entitled: 'Copiar nodo' categorized: 'Nodo';
act: [:treePresentation |
(treePresentation selection isNotNil)
ifTrue: [self replaceContentsFromCache: treePresentation selection].
treePresentation update] entitled: 'Pegar nodo' categorized: 'Nodo';
"For tags"
act: [:treePresentation |
(treePresentation selection isNotNil)
ifTrue: [self addTagTo: treePresentation selection]]
entitled: 'Etiquetar nodo como...' categorized: 'Etiquetas';
act: [:treePresentation |
(treePresentation selection isNotNil)
ifTrue: [
treePresentation selection tagAs: nil.
browser update.
]]
entitled: 'Desetiquetar nodo como...' categorized: 'Etiquetas';
act: [self showTagsAvailable] entitled: 'Ver disponibles' categorized: 'Etiquetas';
act: [self addToTagsAvailable] entitled: 'Agregar a disponibles' categorized: 'Etiquetas';
"For projects"
act: [self enableLocalRepository] entitled: 'Activar repositorio local...' categorized: 'Proyecto';
act: [self messageNotImplementedYet "addFileToRepository"] entitled: 'Agregar archivo' categorized: 'Proyecto';
act: [self messageNotImplementedYet] entitled: 'Eliminar archivo' categorized: 'Proyecto';
act: [self messageNotImplementedYet "repositoryCommit"] entitled: 'Enviar al histórico' categorized: 'Proyecto';
act: [self messageNotImplementedYet "repositoryCredentials"] entitled: 'Acreditarse' categorized: 'Proyecto'.
]