Preliminary support for fossil.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2014-11-04 00:06:50 +00:00
parent 6035c6b3be
commit b59afbf924

View File

@ -15,7 +15,13 @@ Class {
'browser',
'explorer',
'mainTree',
'workingFile'
'workingFile',
'fossil',
'pandoc',
'localRepository',
'remoteRepository',
'repositoryUser',
'repositoryPassword'
],
#classVars : [
'DefaultUbakyeBrowser'
@ -33,6 +39,24 @@ GrafoscopioBrowser class >> openLandscape [
^ self new openLandscape
]
{ #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 : #'graphical interface' }
GrafoscopioBrowser >> bodyOn: constructor [
"Shows the body of a selected node"
@ -179,6 +203,19 @@ browser
on: $s entitled: 'Accept' with: [:text | text text ]].
]
{ #category : #'system-support' }
GrafoscopioBrowser >> configureSettings [
"Stablish several 'global' settings according to the operative system"
Smalltalk platform name = 'unix'
ifTrue: [
fossil := (FileSystem disk workingDirectory / 'Platform' / 'Linux' / 'Programs' / 'Fossil' / 'fossil') fullName.
pandoc := (FileSystem disk workingDirectory / 'Platform' / 'Linux' / 'Programs' / 'Pandoc' / 'pandoc') fullName.
].
localRepository := (FileSystem disk workingDirectory / 'Grafoscopio' / 'Projects' / 'SoftwareLibre-Educacion' / 'soliedu.fossil')..
remoteRepository := 'http://mutabit.com/deltas/repos.fossil/soliedu'.
]
{ #category : #bibliography }
GrafoscopioBrowser >> customKeys [
"Replaces the default key in a BibTeX file for a custom key taken from the 'shorttitle' field.
@ -196,14 +233,26 @@ GrafoscopioBrowser >> customKeys [
key: ((bibliography entries at: index) fields at: 2) value ]]].
]
{ #category : #persistence }
GrafoscopioBrowser >> enableRepository [
"Just a temporary message to enable working with fossil on a specific repository. This should be generalized"
| repositoryLocalPath repositoryRemotePath |
(FileSystem disk workingDirectory / 'Grafoscopio' / 'Projects' / 'SoftwareLibre-Educacion') ensureCreateDirectory.
repositoryLocalPath := (FileSystem disk workingDirectory / 'Grafoscopio' / 'Projects' / 'SoftwareLibre-Educacion') fullName.
repositoryRemotePath := 'http://mutabit.com/deltas/repos.fossil/soliedu'.
OSProcess command: 'cd ', repositoryLocalPath,'; ',
fossil, ' clone ', repositoryRemotePath, ' soliedu.fossil; ',
fossil, ' open ', repositoryLocalPath, '/soliedu.fossil ;',
' echo "fossil repo OK"'.
]
{ #category : #persistence }
GrafoscopioBrowser >> exportAsHtml [
"Exports the current tree to HTML, using the same name but different extension (.html)"
| markdownFileLocation htmlFileLocation pandoc |
| markdownFileLocation htmlFileLocation |
markdownFileLocation := ((workingFile parent) / workingFile basenameWithoutExtension) fullName, '.markdown'.
htmlFileLocation := ((workingFile parent) / workingFile basenameWithoutExtension) fullName, '.html'.
Smalltalk platform name = 'unix'
ifTrue: [ pandoc := (FileSystem disk workingDirectory / 'Platform' / 'Linux' / 'Programs' / 'Pandoc' / 'pandoc') fullName ].
OSProcess command: 'exec ', pandoc, ' ', markdownFileLocation , ' --standalone -o ' , htmlFileLocation.
self customKeys.
self inform: 'Archivo exportado como html'.
@ -249,10 +298,11 @@ 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.
self buildBrowser.
mainTree := GrafoscopioNode new.
mainTree becomeDefaultTree.
draftsLocation := FileSystem disk workingDirectory / 'Drafts'.
draftsLocation := FileSystem disk workingDirectory / 'Grafoscopio' / 'Drafts'.
draftsLocation ensureCreateDirectory.
workingFile := draftsLocation / 'draft.ston'.
browser openOn: mainTree children.
@ -262,6 +312,7 @@ GrafoscopioBrowser >> open [
{ #category : #persistence }
GrafoscopioBrowser >> openDefault [
"Opens a new browser with a default tree"
self configureSettings.
self buildBrowser.
mainTree := GrafoscopioNode new.
mainTree becomeDefaultTree.
@ -273,8 +324,8 @@ GrafoscopioBrowser >> openDefault [
GrafoscopioBrowser >> openFromFile [
"Opens a tree from a file. Maybe this should be integrated with the 'open' method"
| fileStream currentChildren |
| fileStream currentChildren |
self configureSettings.
self buildBrowser.
fileStream := UITheme builder
fileOpen: 'Elija un archivo .ston'
@ -284,7 +335,7 @@ GrafoscopioBrowser >> openFromFile [
workingFile := fileStream name asFileReference.
currentChildren := (STON fromStream: fileStream).
mainTree := GrafoscopioNode new
header: 'Bootstrapping the research object';
header: 'Arbol principal';
level: 0.
mainTree children: currentChildren.
browser openOn: mainTree children.
@ -324,6 +375,24 @@ GrafoscopioBrowser >> openWorking [
]
{ #category : #persistence }
GrafoscopioBrowser >> repositoryCommit [
"Commits current changes to the open repository"
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 [
"Saves the current tree to a file"
@ -423,9 +492,16 @@ GrafoscopioBrowser >> treeOn: constructor [
entitled: 'Save current tree';
"Menu options"
act: [ GrafoscopioBrowser new openFromFile] entitled: 'Abrir/Cargar ...';
act: [self saveToFile] entitled: 'Guardar como ...';
act: [self exportAsHtml] entitled: 'Exportar como html';
act: [ GrafoscopioBrowser new openFromFile] entitled: 'Arbol > Abrir/Cargar ...';
act: [self saveToFile] entitled: 'Arbol > Guardar como ...';
act: [self exportAsHtml] entitled: 'Arbol > Exportar como html';
"act: [:x | x printString inspect] entitled: 'Arbol > Definir título';"
act: [self enableRepository] entitled: 'Proyecto > Activar';
act: [self addFileToRepository] entitled: 'Proyecto > Agregar archivo';
act: [:x | x printString inspect] entitled: 'Proyecto > Eliminar archivo';
act: [self repositoryCommit] entitled: 'Proyecto > Agregar al histórico';
act: [self repositoryCredentials] entitled: 'Proyecto > Acreditarse';
act: [:x | x printString inspect] entitled: 'Proyecto > Sincronizar';
act: [self updateSystem] entitled: 'Actualizar Grafoscopio';
act: [:x | x printString inspect] entitled: 'Acerca de...'.