aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPBundleHTMLOutputController.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-12-13 09:13:35 +0000
committerBibiko <bibiko@eva.mpg.de>2010-12-13 09:13:35 +0000
commit3205740f8679f3408a3d5e4246d943b74db80f47 (patch)
treec9ec9880384e70b677c8e1f0ccabb207096fc96f /Source/SPBundleHTMLOutputController.m
parent3adfcf0898f78a8459aedd46be5e89ec906f0314 (diff)
downloadsequelpro-3205740f8679f3408a3d5e4246d943b74db80f47.tar.gz
sequelpro-3205740f8679f3408a3d5e4246d943b74db80f47.tar.bz2
sequelpro-3205740f8679f3408a3d5e4246d943b74db80f47.zip
• HTML output window
- a BASH script called via window.system.run() inherits the current shell vars and the associated SP_PROCESS_ID if set to make it easier to run sequelpro URL scheme commands from JavaScript via BASH - improved error handling
Diffstat (limited to 'Source/SPBundleHTMLOutputController.m')
-rw-r--r--Source/SPBundleHTMLOutputController.m22
1 files changed, 17 insertions, 5 deletions
diff --git a/Source/SPBundleHTMLOutputController.m b/Source/SPBundleHTMLOutputController.m
index a632a51a..8a5b66e6 100644
--- a/Source/SPBundleHTMLOutputController.m
+++ b/Source/SPBundleHTMLOutputController.m
@@ -30,6 +30,7 @@
@synthesize docTitle;
@synthesize initHTMLSourceString;
@synthesize windowUUID;
+@synthesize docUUID;
/**
* Initialisation
@@ -63,7 +64,6 @@
{
[[self window] orderFront:nil];
-
[self setInitHTMLSourceString:content];
[[webView mainFrame] loadHTMLString:content baseURL:nil];
@@ -208,6 +208,7 @@
[webView close];
[self setInitHTMLSourceString:@""];
windowUUID = @"";
+ docUUID = @"";
[self release];
}
@@ -330,6 +331,7 @@
- (void)webView:(WebView *)sender windowScriptObjectAvailable: (WebScriptObject *)windowScriptObject
{
+
[windowScriptObject setValue:self forKey:@"system"];
}
@@ -380,7 +382,7 @@
*/
- (NSString *)getShellEnvironmentForName:(NSString*)keyName
{
- return [[[NSApp delegate] shellEnvironment] objectForKey:keyName];
+ return [[[NSApp delegate] shellEnvironmentForDocument:nil] objectForKey:keyName];
}
/**
@@ -403,6 +405,9 @@
NSString *command = nil;
NSString *uuid = nil;
+ if([self docUUID] && [[self docUUID] length])
+ uuid = [self docUUID];
+
if([call isKindOfClass:[NSString class]])
command = [NSString stringWithString:call];
else if([[[call class] description] isEqualToString:@"WebScriptObject"]){
@@ -426,8 +431,15 @@
NSString *output = nil;
if(uuid == nil)
output = [command runBashCommandWithEnvironment:nil atCurrentDirectoryPath:nil error:&err];
- else
- output = [command runBashCommandWithEnvironment:nil
+ else {
+ NSMutableDictionary *theEnv = [NSMutableDictionary dictionary];
+ [theEnv addEntriesFromDictionary:[[NSApp delegate] shellEnvironmentForDocument:nil]];
+ [theEnv setObject:uuid forKey:SPBundleShellVariableProcessID];
+ [theEnv setObject:[NSString stringWithFormat:@"%@%@", SPURLSchemeQueryInputPathHeader, uuid] forKey:SPBundleShellVariableQueryFile];
+ [theEnv setObject:[NSString stringWithFormat:@"%@%@", SPURLSchemeQueryResultPathHeader, uuid] forKey:SPBundleShellVariableQueryResultFile];
+ [theEnv setObject:[NSString stringWithFormat:@"%@%@", SPURLSchemeQueryResultStatusPathHeader, uuid] forKey:SPBundleShellVariableQueryResultStatusFile];
+ [theEnv setObject:[NSString stringWithFormat:@"%@%@", SPURLSchemeQueryResultMetaPathHeader, uuid] forKey:SPBundleShellVariableQueryResultMetaFile];
+ output = [command runBashCommandWithEnvironment:theEnv
atCurrentDirectoryPath:nil
callerInstance:[NSApp delegate]
contextInfo:[NSDictionary dictionaryWithObjectsAndKeys:
@@ -436,7 +448,7 @@
uuid, SPBundleFileInternalexecutionUUID,
nil]
error:&err];
-
+ }
if(err != nil) {
NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Error while executing JavaScript BASH command", @"error while executing javascript bash command")