]> err.no Git - sope/commitdiff
code cleanups
authorhelge <helge@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Sun, 5 Sep 2004 23:36:02 +0000 (23:36 +0000)
committerhelge <helge@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Sun, 5 Sep 2004 23:36:02 +0000 (23:36 +0000)
git-svn-id: http://svn.opengroupware.org/SOPE/trunk@107 e4a50df8-12e2-0310-a44c-efbce7f8a7e3

sope-appserver/NGObjWeb/ChangeLog
sope-appserver/NGObjWeb/Version
sope-appserver/NGObjWeb/WOResourceManager.m

index af2e36783cb2b29e588085a2a755cd25742ec840..93b6de515d4f841bcd9c9a8494d70848474a7b5e 100644 (file)
@@ -1,3 +1,7 @@
+2004-09-06  Helge Hess  <helge.hess@opengroupware.org>
+
+       * WOResourceManager.m: minor code cleanups (v4.3.26)
+
 2004-09-05  Helge Hess  <helge.hess@opengroupware.org>
 
        * WOResourceRequestHandler.m: added some debug logging, send a 404
index 7dbad158de186a5b1650c076ee6d2774ed355d6e..d147d54ee36af43c6388baa79fc48363eb754125 100644 (file)
@@ -1,6 +1,6 @@
 # version file
 
-SUBMINOR_VERSION:=25
+SUBMINOR_VERSION:=26
 
 # v4.2.413 requires libSaxObjC      v4.2.33
 # v4.2.341 requires libNGExtensions v4.2.77
index e64888b76778cf31b719ea3244c09bb5e9c38850..8133b66b82c690dfebd62d7f899164697008602f 100644 (file)
@@ -81,6 +81,7 @@
 static Class    UrlClass             = Nil;
 static NSString *resourcePrefix      = @"";
 static NSString *rapidTurnAroundPath = nil;
+static NSString *suffix              = nil;
 static NSNull   *null                = nil;
 static BOOL     debugOn                 = NO;
 static BOOL     debugComponentLookup    = NO;
@@ -106,7 +107,8 @@ static BOOL     genMissingResourceLinks = NO;
   debugComponentLookup    = [ud boolForKey:@"WODebugComponentLookup"];
   debugResourceLookup     = [ud boolForKey:@"WODebugResourceLookup"];
   genMissingResourceLinks = [ud boolForKey:@"WOGenerateMissingResourceLinks"];
-  rapidTurnAroundPath     = [[ud stringForKey:@"WOProjectDirectory"] copy];
+  rapidTurnAroundPath     = [[ud stringForKey:@"WOProjectDirectory"]  copy];
+  suffix                  = [[ud stringForKey:@"WOApplicationSuffix"] copy];
 }
 
 static inline BOOL
@@ -334,10 +336,13 @@ _pathExists(WOResourceManager *self, NSFileManager *fm, NSString *path)
   fm        = [self fileManager];
   langCount = [_languages count];
   
-  if ((w3rp = [self webServerResourcesPath])) {
+  if ((w3rp = [self webServerResourcesPath]) != nil) {
     NSString *langPath = nil;
     unsigned i;
     
+    if (debugResourceLookup)
+      [self logWithFormat:@"  WebServerResources: %@", w3rp];
+    
     // first check Language.lproj in WebServerResources
     for (i = 0; i < langCount; i++) {
       langPath = [_languages objectAtIndex:i];
@@ -348,7 +353,7 @@ _pathExists(WOResourceManager *self, NSFileManager *fm, NSString *path)
         if (debugResourceLookup) {
           [self logWithFormat:
                   @"  no language project for '%@' in WebServerResources: %@",
-                  [_languages objectAtIndex:i],resource];
+                  [_languages objectAtIndex:i], langPath];
         }
         continue;
       }
@@ -423,13 +428,29 @@ _pathExists(WOResourceManager *self, NSFileManager *fm, NSString *path)
 
 /* URL methods */
 
+- (NSString *)_urlForMissingResource:(NSString *)_name request:(WORequest *)_r{
+  WOApplication *app;
+
+  app = [WOApplication application];
+  
+  if (!genMissingResourceLinks)
+    return nil;
+  
+  return [NSString stringWithFormat:
+                    @"/missingresource?name=%@&application=%@",
+                     _name, app ? [app name] : [_r applicationName]];
+}
+
 - (NSString *)urlForResourceNamed:(NSString *)_name
   inFramework:(NSString *)_frameworkName
   languages:(NSArray *)_languages
   request:(WORequest *)_request
 {
-  WOApplication *app;
+  WOApplication   *app;
+  NSMutableString *url;
   NSString *resource = nil, *tmp;
+  NSString *path = nil, *sbase;
+  unsigned len;
   
   app = [WOApplication application];
   
@@ -447,65 +468,51 @@ _pathExists(WOResourceManager *self, NSFileManager *fm, NSString *path)
 #endif
 #if 0
   tmp = [resource stringByStandardizingPath];
-  if (tmp) resource = tmp;
+  if (tmp != nil) resource = tmp;
 #endif
   
-  if (resource) {
-    NSString *path = nil, *sbase;
-    unsigned len;
-    
-    sbase = self->base;
-    tmp  = [sbase commonPrefixWithString:resource options:0];
+  if (resource == nil) {
+    if (debugResourceLookup)
+      [self logWithFormat:@"did not find resource (cannot build URL)"];
+    return [self _urlForMissingResource:_name request:_request];
+  }
+  
+  sbase = self->base;
+  tmp  = [sbase commonPrefixWithString:resource options:0];
     
-    len  = [tmp length];
-    path = [sbase    substringFromIndex:len];
-    tmp  = [resource substringFromIndex:len];
-    if (([path length] > 0) && ![tmp hasPrefix:@"/"] && ![tmp hasPrefix:@"\\"])
-      path = [path stringByAppendingString:@"/"];
-    path = [path stringByAppendingString:tmp];
+  len  = [tmp length];
+  path = [sbase    substringFromIndex:len];
+  tmp  = [resource substringFromIndex:len];
+  if (([path length] > 0) && ![tmp hasPrefix:@"/"] && ![tmp hasPrefix:@"\\"])
+    path = [path stringByAppendingString:@"/"];
+  path = [path stringByAppendingString:tmp];
 
 #ifdef __WIN32__
-    {
+  {
       NSArray *cs;
       cs   = [path componentsSeparatedByString:@"\\"];
       path = [cs componentsJoinedByString:@"/"];
-    }
+  }
 #endif
     
-    if (path) {
-      static NSString *suffix = nil;
-      NSMutableString *url = nil;
-
-      if (suffix == nil) {
-       NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
-        suffix = [ud stringForKey:@"WOApplicationSuffix"];
-      }
-      
-      url = [[NSMutableString alloc] initWithCapacity:256];
+  if (path == nil)
+    return [self _urlForMissingResource:_name request:_request];
+  
+  url = [[NSMutableString alloc] initWithCapacity:256];
 #if 0
-      [url appendString:[_request adaptorPrefix]];
+  [url appendString:[_request adaptorPrefix]];
 #endif
-      if (resourcePrefix)
-        [url appendString:resourcePrefix];
-      if (![url hasSuffix:@"/"]) [url appendString:@"/"];
-      [url appendString:app ? [app name] : [_request applicationName]];
-      [url appendString:suffix];
-      if (![path hasPrefix:@"/"]) [url appendString:@"/"];
-      [url appendString:path];
+  if (resourcePrefix)
+    [url appendString:resourcePrefix];
+  if (![url hasSuffix:@"/"]) [url appendString:@"/"];
+  [url appendString:app ? [app name] : [_request applicationName]];
+  [url appendString:suffix];
+  if (![path hasPrefix:@"/"]) [url appendString:@"/"];
+  [url appendString:path];
       
-      path = [url copy];
-      [url release];
-      
-      return [path autorelease];
-    }
-  }
-  
-  if (genMissingResourceLinks) {
-    return [NSString stringWithFormat:
-                       @"/missingresource?name=%@&application=%@",
-                       _name, app ? [app name] : [_request applicationName]];
-  }
-  return nil;
+  path = [url copy];
+  [url release];
+  return [path autorelease];
 }
 
 - (NSString *)urlForResourceNamed:(NSString *)_name {